Tuesday, June 16, 2009

Love is all around ... in fixes

Based on work of the last weekend and fixes of today, Line3D visual action can be rewritten in 5 lines of code.

public class AlternateLine : NewShapeModifier
{
public AlternateLine(WorkItem workItem)
: base(ModifierNames.AlternateLine, "Line", workItem) { }
}

But the NewShapeModifier base class have some internal limitations that was based on already existing limitations of Actions/Inputs framework in NaroCAD. One of them was that it was not possible to add inputs live. Right now you can, but the bad thing is that you cannot remove them live.

Why is needed to add/remove live inputs?

Firstly we have to understand how Naro's actions framework works. In principle, an action is a button that change the current document/modeller in a specific state. Because this state should be extensible from one point, and to avoid tight coupling, any action may require resources, named inputs, that give to this action what it needs, like (but not limited to): document, OpenCascade context, OpenCascade view, tree view, property view, a current face, a 3d coordinate that is triggered on mouse move, etc.

The NewShapeModifier tries to implement the following thing: for a given shape, that is defined by it's function name, to create an action that do all internal stuff (like document life cycle, connecting to various inputs) internally to populate function's dependency. And at the end to create this shape in current document. This part of code take in case of Line3D more than 150 lines and is error prone. But NewShapeModifier needs to open different inputs based on different shapes, so this is the reason it was needed to be possible to add dynamically new inputs.

If NewShapeModifier will work will make trivial at least for simple shapes to add the corresponding action. And it will work from scratch, with (almost) no extra setup.

I will continue to make possible making real annotations to dependencies and based on this Extrude action (which is not a trivial action as was line3D) to be possible.

No comments: