Friday, April 27, 2012

Rectangle update

In the last version, the rectangle was constrained to be parallel to the axes, which meant that it couldn't be rotated, and with two fixed points which didn't allow it to be resized properly. I've replaced these constraints with 2 parallel and one perpendicular constraint. After this change, the rectangle can be rotated and can be resized using any of the 4 corners.

Constraints with lines also work, so if we draw a line parallel to one of the rectangle lines and then drag one of the corners, it won't allow us to rotate the rectangle anymore.

Thursday, April 26, 2012

Solver, logger and tests updates

Today I commited the changes I had so far for the solver, and I will prepare a detailed explanation of how the solver works for the release.

Some of the main changes are:
- The shapes are ordered in the shapesList according to the level on which they are compared to the mouse point. The list has all the points, with the mouse position last, then any other shapes and constraints.
- The parameters and constraints are kept in an OrderedDictionary, which maintains the order in which the elements are inserted (Dictionary doesn't and SortedDictionary orders the elements by key).
- When editing a shape, the points are divided in two categories: free points, which are related to the point that is currently changed, and fixed points. Related points are those points which have the same ancestor on the shape reference list.
- When editing a shape, we try to find the solution with the minimum number of changed free points.
- When adding new shapes, there are no free points.

I've updated the constraint tests for the case when the lines are parallel to the y-axis. We check if two lines are parallel by comparing their slopes, but for lines parallel to the y-axis we had division by 0 or very large numbers. I've updated the method to return double.PositiveInfinity for this case and check for this value in the tests.

I've also updated the logger to write in the AppData folder and to save messages for NaroStarter.

There are several commits for these changes; the most recent one, which has everything, is here.

Wednesday, April 25, 2012

Solver update: replacing SortedDictionary

SortedDictionary was used for keeping solver related data, but because of the new ordering of the parameters I had to remove them. Initially I tried to replace only the shapeList SortedDictionary, but this causes wrong references to be passed to the Solver and no solutions are found. I've been working on updating all the other relevant SortedDictionaries and fixing the code that relied on those dictionaries being sorted.

There are still some more fixes to be done and a lot of testing. Until we get to more complicated shapes, here is how two parallel lines behave:

Monday, April 23, 2012

Solver update

The first step in updating the solver was changing it so it will modify only some of the parameters that are passed to it. In the old version, it changed all the parameters so that the difference for each coordinate was minimal. Now we'll specify which points can be changed and which not. The solve method will have one additional parameter, which will hold the number of free points, and the parameters list will be sorted to have the free points first.

The changes for the solve method are complete, and now I'm updating the ReferingNode method to use a generic way of correctly ordering the parameters and determining the number of free points.

Friday, April 20, 2012

Released NaroCAD 1.6.3

After almost one year we finally released a new version of NaroCAD. This version added some new fixes on 2D tools:

Fixed arc drawing (both CSE and SER),
The Edit Gizmo is resizing as we zoom in and out,
Fixed plane view change crash,
Fixed shape selection and editing,
Fixed the New File crash,
Updated the Trim tool to work on Circle,
Updated unit tests to use the new Sketch structure,
Added unit tests for the shapes that didn't have any.

You can download it here.

Next release is planned for May 4th. On this version we planned to add a new enhanced solver, more 2D tools fixes, Gizmo fixes.

Thursday, April 19, 2012

Updates to the editing handlers and solver

I've updated the editing handler zooming to be limited, so that when the stage is zoomed out too much (the axes aren't visible anymore) the handles won't be visible, either. It seems to be working ok this way, if there will be a need to customize this differently depending on the drawing we can add the parameters in the UI options. This update will be included in tomorrow's release.

We've also done some changes to the solver so that only specific points are changed, instead of all, and I'm currently working on the algorithm that sets which points should be changed. The solver updates won't be ready for tomorrow's release, but will be included in the next one.

Monday, April 16, 2012

Updating the solver

I've been working on updating the solver to better handle creating and editing lines (the only shape that is currently implemented using SketchActions). The solver returns solutions for the existing contraints, but at the wrong coordinates. This causes the shapes to move around when only one shape is being added or edited.
I'm working on converting the coordinates that the Solver returns so that for a line that is being drawn or edited, using a constraint, only the second line's coordinates are being changed.

The constraints that I'm working with are:
- horizontal and vertical line (parallel to the plane's axes)
- parallel lines
- perpendicular lines
- point on line

Wednesday, April 11, 2012

Editing handler and gizmo zoom fixed

When editing a shape, the editing handlers and gizmo didn't scale according to the zoom level, so if the zoom was different than the default they were too big, sometimes covering the entire shape, or too small and couldn't be used. I've updated the code to scale them according to the zoom level and to update the scale during zoom in or zoom out if a shape is already selected.

You can find the changes here and here.

Tuesday, April 10, 2012

New tests and new file crash fix

I'm working on improving the hinter and solver, but in the meantime I added some unit tests for the four line rectangle and arcs and fixed some small issues that I discovered while writing these. I've also started working on the spline tests, but they're a bit more complicated and I've postponed them a bit. The changes are here.

I've also fixed a crash that was caused by the sketch editing not being closed before opening a new file. The changes for this are here.

Thursday, April 5, 2012

Planning NaroCAD 1.6.3 Beta Release

Good news for NaroCAD users: we planned for April 20 to release NaroCAD 1.6.3 and hopefully after that version every 2-3 weeks we'll deliver a new version.

On 1.6.3 we'll focus on finalizing the Sketching concept and fix the 2D tools to work with it.

The new solver, porting to OpenCascade 6.5.x and fixing the 3D tools are postponed for next versions.

Wednesday, April 4, 2012

Trim tool fixes

The trim tool allows us to cut a part of a curve using another curve to define the start/end points. Using it, we can obtain complex shapes easily:

When doing a trim, we need to select the guide line, click on the Trim tool and then click on the part of the line that we want to be cut out (the two shapes must have at least one intersecting point). The trimming tool didn't work because the mouse click was sent as a Point3D instead of Reference and it was always (0,0,0). After changing that and enabling the code that actually retrieves the intersection points, trimming a line using another line as a guide worked, but more 'complicated' shapes didn't. The problem is that wrapper that returns the intersection points returns extra points, as well.

For a circle and line, for example, we get the two intersection points, as well as the points that are produced by the perpendicular to the drawn line:

To eliminate the extra points, I've added a check using ExtremaExtPC which checks if the points are on the line and only returns the two points we need.

After this change the circle trim works ok (and the unit tests pass) but there are some issues with trimming arcs and splines that I'm working on.
Another issue is when trying to apply a trim on a trim result, e.g. we trim a circle using a line and then we want to trim the resulting shape again, using another line.

The changes are here

Tuesday, April 3, 2012

Unit tests updated

I'm done with one batch of unit test updates, for the tests in MetaActionTests. Aside for the 3D related tests which are currently disabled/failing the 2D drawing tests are all passing. There are some tests that need to be added for the shapes that aren't currently covered (spline, arc and four lines rectangle) and there is a small issue with the Mirror line because of the way the axis is passed, but all tests use the current sketch / point reference structure.

There are three ways in which the shapes are 'drawn' in the unit tests:

- MetaActions-specific: we push the dependency objects to a MetaActionContainer object.
- using clicks: we add mouse clicks by calling setup.MouseInput.MouseDown and setup.MouseInput.MouseUp
- using NodeBuilder: we create a new nodeBuilder and add the needed dependencies, then call ExecuteFunction()

and depending on the shape type, we call one of the methods in ShapeBuildHelp.cs

After I'll add the missing tests I'll clean up the files and remove all old MetaAction related code that isn't used anymore and move the non-MetaAction tests in another solution.

You can find the changes here.

Monday, April 2, 2012

Still working on the tests

I'm still working on the unit test updates, but I'm almost done and hopefully tomorrow I'll be able to commit some of the changes. There are some updates because of the new shape structure, so the Point3Ds were replaced by references and the asserts were updated accordingly and some changes to the shape drawing methods because of the Action/MetaAction changes.

I've updated the code for the 3D shapes that used Circle as a base shape but didn't pass the correct parameters (torus, cylinder, cone). The tests for these don't pass yet, because of some solver related errors, but the shape drawing part is working.

I've also reverted to LineAction for line drawing (instead of SketchLineAction) and the solver works a lot better when multiple lines are drawn on the sketch. I've disabled the tests for ParallelLine and NormalLine as the tools are disabled - when/if we decide to reactivate them, I'll come back to tests and update them.

Now I'm working on updating the MirrorPoint and MirrorLine tests to fix the MetaAction specific code.

Sunday, April 1, 2012

NaroPAD - an update

I know is April 1st, you may know it too, but you don't know what you read and why to read it.
I will move the development forward of NaroPAD (a minimalist subset of NaroCAD framework) as a separate endeavor (as I don't have time to keep things in sync with NaroCAD codebase, as I'm involved with my life projects). If the team will want to use another name for NaroPAD (to not seem like a ripoff). When I will have time, I will write on a separate blog. So this is a farewell from NaroCAD (no prank), and wish to the team best of luck.