Friday, July 31, 2009


Constraints are working. There are made three constraints for now:
- Fixed value for any shape's field that is a double
- Range value for any shape field that is a double
- CoLocation point meaning that you can setup a point to "follow" other point

Also because constraints are invisible, the treeview is cleanly separated and show their dependencies.

The editing framework is similar with the Options's dialog framework so you can define your own dialog for applying your new defined constraint.

In the upper screenshot, moving the sphere will move the attached rectangle point.

Naro art

Wrench drawn with Naro using Group, a few Lines, a Spline, an Extrude and a Cut. The model lacks precision, that will be improved.

Group functionality

Implemented Grouping and multiselect functionality. Using shift+click multiple wires like lines and splines can be grouped together as a Face. This allows creating complex shapes from simple ones, having the possibility to apply Features like extrude on the generated Face. This improves a lot the Sketching capabilities.

Attached a screenshot with an extruded spline combined with a line and also multiple line grouped and extruded.

Will continue exploring other capabilities to combine other types of shapes (like rectangle with circle). Also Ungrouping will be implemented.

Thursday, July 30, 2009

Basic constraints support

Right now you can setup two kinds of constraints and in work will be the third.

The first two are for every shape that have a double/real field, you can set a fixed value/or a range for it. Setting this constraint will make ignore any setup like property grid, etc.

For now the code have some limitations and the point that need to follow other point of other shape is not implemented. So, I will go to address them. The interesting part is also that the constraint dialogs can locate fields based on scanning shape dependencies making more easier for user to pick their wanted dimension.

The constraints in themselves works like a shape that observe other shapes (like for example: extrude), amd it tries to check if the constraints are met, and if they are not, it tries to correct them.

In the next day(s) I will try to stabilize the code and to find any other potential problems. Also constraints are not visible right now in the object list being experimental feature. Very soon you will get them more usable from user point of view but the concept is working.

Wednesday, July 29, 2009

Interactive help, mouse coordinates layer

Implemented interactive help, when a tool is chosen explanations about it are displayed in the help window. In the following days the help will be completed to cover all the tools.

Generated a new version of wrappers with improvements at Aspect_Window and WNT_Window. Using these and Visual3d_Layer added a 2D Layer over the 3D drawing area. On this layer the 3d mouse coordinates are displayed.

Monday, July 27, 2009

Started iteration 1.03

Started the Iteration 1.03. Among the tasks proposed to be solved during this iteration are scheduled the following:
- Add Cut to depth, improve the current Cut functionality,
- Improve geometric solver and magic points,
- Improve command line, add commands for all shapes,
- Improve application usability,
- Fix the synchronicity between transformations and shape center/location,
- Add two new features: revolve, sweep,

As a lower priority tasks would be:
- Implement constraints, dimensions,

The tasks made during the previous iteration and also released as version 1.0.2:

- Added an Option Dialog to add remove the toolbars,
- Added transform operations: from property grid on each object can be set Translate on x, y, z axis, Rotate around x, y, z axis using also a pivot point, Scale. Translation can be done also using the mouse,
- Added new shapes: circle and spline,
- Reimplemented the ellipse so that the first click is the ellipse center,
- Implemented copy paste,
- Added 3d shapes: Sphere, Cylinder, Cone,
- Added boolean operations: Boolean cut, Boolean fuse, Boolean intersect,
- Improved the installer and the NaroStarter (the tool that among other functionality catches the errors and logs them on Sourceforge),
- Added at the geometric solver detection of parallel lines.

Spline, 3D primitives

On the current iteration will focus on solving bugs and improving the current existing functionality.

Yesterday worked at reviewing and improving the spline drawing, added markers at the spline points.
Enabled and finished box, added box descriptor so that the location, length, width and height can be changed from property grid, improved usability at cylinder and cone drawing by enabling/disabling the face picker and planes excluded from picking. The location change from property grid for 3D shapes seems to have bugs, will fix it.

Friday, July 24, 2009


Added descriptors for the cylinder and shape so that the location, radius, height, angle can be changed form the property grid.

Investigated half a day on some synchronization losing between center position change and translation changes, after changing these several times the object location is not the same with the location displayed on grid. Bug not solved yet.

Attached also a photo with some radius and angle changes at cone and cylinder.

Will continue working at fixing and improving the current funcitonality.

Thursday, July 23, 2009

Code improvement

This week will close the iteration 1.2. No new features will be added, will work at improving, fixing, finishing and stabilizing the current code. Started fixing the transformation operations. Will make also some code refactorings and cleanup.

Implemented a marker class that displays magic points that are not affected by the zoom. The solution found was the following:

var _marker = new OCAIS_Point(new OCGeom_CartesianPoint(x, y, z));
OCAIS_Drawer drawer = _marker.Attributes();
// Set marker type, color, Scale
drawer.SetPointAspect(new OCPrs3d_PointAspect(OCAspect_TypeOfMarker.Aspect_TOM_BALL, Color, 1.3));
// Show the marker and deactivate selection on it
context.Display(_marker, updateViewer);

Wednesday, July 22, 2009

Released Naro 1.0.2

The new features added at version 1.0.2 are:

- Added an Option Dialog to add remove the toolbars,
- Added transform operations: from property grid on each object can be set Translate on x, y, z axis, Rotate around x, y, z axis using also a pivot point, Scale. Translation can be done also using the mouse,
- Added new shapes: circle and spline,
- Reimplemented the ellipse so that the first click is the ellipse center,
- Implemented copy paste,
- Added 3d shapes: Sphere, Cylinder, Cone,
- Added boolean operations: Boolean cut, Boolean fuse, Boolean intersect,
- Improved the installer and the NaroStarter (the tool that among other functionality catches the errors and logs them on Sourceforge),
- Added at the geometric solver detection of parallel lines,
- Made many fixes at the previous functionality.

Attached also a screenshot with NaroCad 1.0.2 and a shape drawn with it.

Preparing for update release

NaroCAD using the 1.0 codebase have huge jumps over adding new shapes, UI improvements, fixes, options dialog to hide toolbars. So it is better and greater.

Copy-Paste have some cases when it did not work properly and those problems are addressed.

Do someone see the problem here:
foreach(var childInterpreter in source.Interpreters)
AttributeData data = new AttributeData(childInterpreter.Key);

destionation.Interpreters[childInterpreter.Key] = AttributeInterpreterFactory.GetInterpreter(

This code should iterate over all node's source data, serialize it, and deserialize in Paste's destination node.

The problem is that some interpreters are writing other interpreters like: Function modifies Shape interpreter, visibility changes again Shape interpreter, etc.
So the line:
destionation.Interpreters[childInterpreter.Key] = AttributeInterpreterFactory.GetInterpreter(
was replacing other already built interpreters. The solution is to create the interpreters before and deseralize them after.

This means that a lot of small touches are there and makes things to run smooth.

Tuesday, July 21, 2009

Code finalizing

Finished implementing the transformations. Fixed the descriptors and the translate with mouse so that the mouse translation appears in the grid. Fixed all the other transformations to display proper data in the property grid.

Finished implementing Cylinder and Cone drawing with the mouse, improved the Sphere code. Reimplemented the Box drawing code but still have problems, the position of the user clicks one related to the other don't define properly the box location and orientation.

Investigated the copy paste bug (the original copied shape gets affected by the copy paste), fixed the crash but couldn't find the bug.

Spline real time, last options corrections and looking for bugs

Setted options work over the application life cycle and are saved and restored over multiple runs. Also, even sounds bad, the apply button did not work previously just because the toolbar component hider was not connected to the apply change events. Right now is fixed, so

Spline action was changed to work real time.

Also I work on some bugs to target 1.0.2 release on this Wendsay. Hope to find solutions.

Sunday, July 19, 2009

Options dialog improved

The options dialog have some problems but they were addressed like:
- support of multiple sections. This is done using a global factory system. Before this you had to complete the list of pages and populate and would make harder.
- the search work contextually so it search the content of options pages without any code necessarily from dialog creators. This means that if you will create an option dialogs using your Windows.Forms dialog and all content is indexed. This will mean if the options dialogs will increase in count, the search will be relevant and simplify the usage of this dialog
- the toolbar checkboxes order were in wrong order

Options dialog working

Options dialog is working. The made framework around it, can show/hide the toolbars depends of your usage. But the design follow two principles:
- it uses NaroCAD document system, so the options can be saved to an XML file, can store custom data, even a shape. So Apply is equivalent with Document.Commit, and the Cancel button is the same with Document.Revert
- it is made to be customizable and user friendly. This is done by letting you to create any UserControl and you will get the associated document node section where you can setup any structure you will want.

The current design only just works but miss some functionality, like you cannot filter the sections you can have around. The scope of it is to prove that the current design works and will most likely be included in 1.0.2 as it will make to user more easy to hide the corresponding toolbars

Friday, July 17, 2009

Uploaded 1.0.1, preparing for 1.0.2

Uploaded again the 1.0.1 release version, same functionality with an improved installer. Some of the errors reported by users are solved.
Also scheduled for Wednesday morning to make the 1.0.2 release with the new features and functionality fixes.

Thursday, July 16, 2009

Copy/paste implemented, tree optimizer, XYZ non vertex descriptor

Copy/Paste is working. Any shape can be copy pasted using Control+C/Control+V. It simply copy the selected shape content to a new entity. I've also made a mini clipboard manager, so at the moment will be possible to select multiple shapes, the clipboard will need minimal changes to be extended to use all those shapes.

The deleted nodes will be removed from tree silently at save. The deleted nodes are considered the hidden nodes (like the ones when you press Delete key) and are not referenced by other shapes.

In the past the Property Grid was dependent for X, Y, Z coordinate members to have an associated Point3D (or vertex). Right now is created one that pack an X, Y, Z value without need to create an child vertex. Transformations property is translated to this new visual descriptor.

setup improvements

Worked at investigating and fixing the setup issues, it seems to be better now. Tomorrow will make again the 1.0.1 release version and upload it on Sourceforge. Next week at the end of the iteration (if possible sooner) will also start preparing the 1.0.2 release, among the new features will be new ellipse drawing circle shape, spline, 3D primitives like box, cylinder, cone, sphere, boolean operations like cut, fuse, intersect, transformations like translate, functionality fixes.

Investigated also on the OpenCascade transformation bug. Tried to translate shapes using gp_Trsf and gp_GTrsf and found out that at least for translations gp_Trsf doesn't have this bug. Devast will investigate further if it is possible to implement the other transformations we need like rotations and scaling with gp_Trsf instead of gp_GTrsf. Another issue encountered in Naro with gp_GTrsf translated shapes was that the face picker code wasn't detecting the shapes, the picker detects the shapes translated with gp_Trsf.

The translation code:

OCgp_Trsf trsf = new OCgp_Trsf();
trsf.SetTranslation(new OCgp_Vec(mouseData.Point.X() - _deltaTranslate.X(), mouseData.Point.Y() - _deltaTranslate.Y(), mouseData.Point.Z() - _deltaTranslate.Z()));
var myBRepTransformation = new OCBRepBuilderAPI_Transform(shape, trsf, true);

OCTopoDS_Shape TransformedShape = myBRepTransformation.Shape();

Wednesday, July 15, 2009

Spline shape is working

Why is so important? Because Spline is the shape that is generated by a dynamic number of children/dependencies. It works nice even is not real time. Also I had continue working to a bug report.

I integrated Devast's contribution shapes, more precisely Torus, Cylinder and Cone. Those are basic shapes, so they are not yet appearing to screen but they will soon appear in Naro's shape pallete.

Visual C++ Runtime errors

Some users report that their NaroCAD crash right at start. For them, as an workaround, they have to install manually the Visual C++ Runtime. Probably something makes to not use the right one installed with NaroCAD.

So please download Visual C++ 2008 Runtime SP1 and report back in case you still have problems:

Also, if you think that this solved the problem, you may comment what is your machine configuration (like your OS, language, etc. to check if we can reproduce the situation and solve it for good).

Tuesday, July 14, 2009

Small fixes to properties dialog and other works

I get closer to the design of property dialog. Also I did a small time working to upload the installer with a fixed environment problem and I spend some time on the spline shape.

This is off topic, but seems for me very nice and for who is interested on an interesting device based on a Wee remote and how it can do it, here it is:

Monday, July 13, 2009


Added two new toolbars at NaroCad: the 3D primitives toolbar (sphere, box, cylinder, cone) and the transformations toolbar (translate).

Implemented the translation operation in 3 clicks: the first click is used to select the object to translate, the second one to choose the reference point and the third click to show the destination point. Between clicks at mouse move some helper line is drawn to show the distance for the translation. Added a screenshot with the 3 initial rectangles translated.

Finished the sphere implementation by adding realtime drawing (a temporary sphere is drawn at mouse move until click). Added also a sphere descriptor so that the sphere radius can be changed from the property grid. The sphere center will have to be added in the property grid.

Started Iteration 1.2

Started the Iteration 1.2. Among the tasks proposed to be solved during this iteration are scheduled the following:

- finish all the 2d primitives: remained to implement drawing spline, polyline and infinite line,
- improve the property grid to display info that has composed elements like the three elements dx, dy, dz that compose a translation,
- finish boolean operations and their descriptors,
- finish sphere realtime drawing and descriptors,
- finish translation using the mouse and descriptors,
- implement copy paste,
- toolbar hider: possibility to configure which toolbars should be hidden and which visible,
- finish drawing 3d primitives: sphere, box, cylinder, cone,
- improve delete. Currently the deleted shapes are hidden, the shapes that are not referenced by other shapes should be removed completely,
- fix reported bugs.

Sunday, July 12, 2009

Boolean operations working + sphere

Boolean operations are checked and they are working. Also created the sphere shape.

The spline and polyline will be added right after as they seem working. Also fixed a bug that saving to Step format will save also hidden (i.e. deleted) shapes.

The mandatory screenshot is here using spheres and boolean operations. (intersect and substract one)

Saturday, July 11, 2009

Document livecycle issue

The NaroCAD's document format stores a tree that is also save with the list of undo-redo steps. To make things clearer, the undo/redo steps are done in this way:
- before you change the document, you do a document.Transact(); meaning before you add a scene shape, before you change a property, etc.
- you do the changes till you find a state that your document can be saved as restore point
- you do a document.Commit(reason); meaning that the restore point will be set up to here.

This is close to transactional database model. This leads to a problem, that is like this: what if two scene elements wants to change the document? It should not happen but it happens in real life. For example the best case is the situation in that someone forgets to do a Commit after do it a Transact(), or do a Commit twice. This problem can lead to bad race document issues and the document may get wrong. The problem is that the document will not need to have any invalid states in the working of it. It should be guaranteed by design.

So right now doing a series of multiple transacts, without commits will transform like this:
Transact1, Transact2, ... TransactN to Transact1, Revert, Transact2, ... Revert, TransactN, so on TransactN it will get a valid state that continues from the last commit.

Also the Commit1, ... CommitN will be replaced internally to Commit1, Revert, Revert, ... Revert, so the stage of CommitN it will be the same with Commit1.

It is safe? Yes, because the Transact/Commit say that in-between the state of document is not safe. So you have to not be able to either consider a Transact state in between or outside of it a commit.

This makes also possible at least at the design level to make two work flows to be possible conceptually and if they override one each other's state, to make that only one to work. Also, it will force developers to make the changes in document more atomic to not break themselves the document.

The good thing is that if that if they will try do it, they will not break it, but only change for a moment the document in an invalid state, and afterward, everything it will revert.

Thursday, July 9, 2009

Transformations added

Devast added transformations to NaroCAD. Kudos from me!

Here are his struggles doing it:

After struggling with naro and occ for a week, seem i finally have managed simple transformations. Now there are 4 options which can be used: pivot point (center), translation, rotation and scale. Pivot point is used for rotation and scaling, so these two operations are always done around pivot. Translation is plain simple, just apply translation to the shape. Rotation is stored as 3 euler angles, not very handy ofcourse, but acceptable for manual control. And finally scaling is stored as 3 values, one for each axis, thus allowing non-uniform scaling.

Overall design (which was developed on the second attempt) is very simple. There is transformation (gp_GTrsf) that is applied to the shape. Every time a new transformation should be applied, old transformation is unapplied (i.e. applied inverted). For example we have current transformation tr1 and we want to add some rotation. Delta rotation is computed (that is difference between new and old euler angles, example: current is 45, new is 100, than delta will be 55 degrees). So to apply rotation we create new gp_GTrsf wich rotates around the pivot using delta rotation, define tr2 transformation as tr2 = tr1.Multiply(rotate_delta), then to make change we use BRepBuilderAPI_GTransform to apply tr1.Inverted followed by tr2 (same delta logic is also used for translation and scaling).

Now looking forward to find bugs!

Wednesday, July 8, 2009

Boolean Add is done but are some issues

Boolean Add is done. Seems to work well but are problems udatting the tree. The shapes should be dissapear from tree as they get unified. After I will figure out why it does not work, the rest of remaining boolean operations will be done right away (excluding naming, it differs only by setting one integer for corresponding operation).

Circle action was added also.

Hopefully I will create action for the rest of shapes that have been created underlined model shapes. NaroCAD (and OpenCascade) have to be defined both visual shapes and topological shapes. Right now the topological shapes are created, excluding the polyline. The design issue that have to handle dinamically a different dependency count was made part of spline topological shape. So hopefully very soon will be both there as actions also.

Hopefully tomorrow I will put some screenshots.

Monday, July 6, 2009

Ellipse drawing, parallelism magic points

Changed the ellipse code so that the first click is the ellipse center. Updated also the descriptors so that the property grid reflects the properties of the new ellipse style.

Worked also at implementing in the geometric solver detection of magic points that make parallel lines. It started detecting some parallelism but it doesn't work well yet, also it needs better integration with the other types of magic points. Probably in a few more hours of work it will work ok.

The current code for parallelism calculation is the following:

// Build a vector with each two points from the magic point list
OCgp_Vec sceneVec = new OCgp_Vec(pointList[i].Point, pointList[j].Point);
// Try to find a parallelism
if (vec.IsParallel(sceneVec, tolerance))
// If parallels found, build a line from the two points
OCgp_Lin line = new OCgce_MakeLin(pointList[i].Point, pointList[j].Point).Value();
// Make a parallel line with this line starting from the initial point
OCgp_Lin resultLine = new OCgce_MakeLin(line, initialPosition.Point).Value();
OCGeom_Line geomLine = new OCGeom_Line(resultLine);
// Project the point on the parallel line, with this finding the magic point that
// makes the parallelism
var projectionPoint = new OCGeomAPI_ProjectPointOnCurve(currentPoint.Point, geomLine);
if (projectionPoint.NbPoints() > 0)
return new SolverPoint(projectionPoint.NearestPoint(), GeometryType.Parallel);

Sunday, July 5, 2009

New shapes preparations

Working on new shapes. I did add at the model level the following shapes: Sphere, Circle, Boolean Operations (Cut, Fuse and Common). Also I've look forward to make other shapes: polyline, inifinite line, circle click on center, arc, spline.

Polyline and spline needs a design change as they need multiple dependencies. I did not finish this yet.

After I will implement them I will make them accessible from interface. So stay tuned!

Friday, July 3, 2009

Why design patterns are dangerous

There are many persons that say pro or against design patterns.

Here is the topic on Wikipedia about them.

What are them: they are specific solutions for Object Oriented paradigm that solves in an elegant/proven way a specific problem.

What is wrong about them? Because programmers whom knows them very well try to match any actual problem to meet the pattern, but not to apply the pattern when it match with pattern's solution.

I will give a small tale regarding this, known as "the needed hammer". There is a need of a software that have two classes, Wall and Nail, to get the Nail in Wall. The architect say: "The design is the following: we will need a hammer. We cannot stop here anyway. A hammer cannot appear by itself. So we need a factory of hammers. This factory of hammers cannot appear in itself, and there can be a shop, another kind of factory, so we need an Abstract factory."

Anyone in fact can say: why do we need more than a hammer? Many software developers want and create very big designs for very simple problems. They would say: what if is not a hammer but another tool to push the nail? And a lot of others: "What if ... ?". The problem is that in most cases this "What if ... " will not happen but the developer will have a huge amount of code that do nothing that create two factories to define an abstract factory.

Also, don't think that I'm the only one who say this. There are more anti-patterns (where patterns fails) than patterns themselves. Look here the article about antipatterns on Wikipedia.

You may argue: the spaghetti code is just because no pattern is used. I cannot disagree more. Spagetti code means mostly tight coupling, which can be fixed with a refactoring as Joel Spolski says. Also, the most concerning in using patterns are not the fact that patterns work, they do, and do it very well, but the problem that peoples try to build things from pattern to pattern. And the patterns themselves are fairly heavy in class numbers, but they mix in most of cases with facade code/proxy code that makes *most* of code to be design code and really few to do something useful.

Do NaroCAD use patterns? Yes, of course, but they come as a result of a specific problem (as we use Pipes and Filters to separate the UI events from UI logic). Can we create a pattern for every class in code!? Most probably we can but we are not gonna fix it.

Thursday, July 2, 2009

Review code, new features and a rant

Unit testing was reviewed to make easier to write non OpenCascade unit tests. A requested feature from an OpenCascade forum's user is to add transformations and with his help probably it will be added soon at least for most common of them (translate, scale, rotate). If you will draw a line you will see what is it about.

Automatic numbering feature was finished and works combined with filtering. That means that is easier to find your shape from a large list of shapes.

But the main body of this post is about a rant. I had looked to the opensource initiative of Microsoft about Windows Presentation Foundation (WPF). The single interesting feature that may give is not a themable data grid but a premade Ribbon UI. Going further to see if it worth, I've get stunned about it's very bad chosen license. In short the license say something like that: if you use this widget, your application should follow the Office UI guidelines. The bad point is that Microsoft have right to change them and you should update after them, at least at their notice.

Why this thing gets plain wrong? Let's suppose that because we are oversmart people around NaroCAD tomorrow and we will use Ribbon. All users are happy (why!? because of gradients!?). After this, we continue to integrate further our work around Ribbon UI which means changes in organising of UI code, changes in how it expose a lot of items, for instance the Object properties. But after when we are almost done, and we are a very close RC, we've got a notice from Microsoft that we must follow the updated OfficeUI style guidelines that have to add support of multitouch. With two fingers you should be able to zoom in, and with three fingers you should be able to rotate the scene. (this is an hypothetical scenario) This will lead us to do two things: to postpone our release, because we are bind legally to Office UI guidelines, and also, we may need to patch OpenCascade as it does not support multitouch. A great addition for OpenCascade in itself and for OpenSource in particular, but for sure is not economical feasible for real life projects.