Thursday, March 29, 2012

Updating the unit tests

Before doing more changes I thought of checking the unit tests and what they're doing right now. There are several projects in the UnitTests folder, each of them containing groups of tests.

They all run using the nunit-x86.exe file that is in $(repPath)\Lib\NUnit\bin\ so the installed version of Nunit doesn't matter. To run each of them, simply set them as startup project and run. You might notice that some of them have the output type 'Class Library' and opening them from your own installation of Nunit doesn't work - they are set up to run from the project configuration panel, the Debug tab.

Today I worked on the tests in the MetaActionTests project. There are two ways of constructing the shapes there: adding mouse clicks and adding the dependecy objects. I fixed some of the tests that added mouse clicks and didn't use the new node structure and added some more asserts so it's clear not only how many nodes we're expecting, but also what they should be. For the other type of tests, the ProposeCandidate and PushValue calls from ShapeBuildHelp.cs need to be updated to use references and the tests need to be updated to use the changed setup object.


Wednesday, March 28, 2012

Selecting and editing shapes and view change issues

There was a crash after changing the view (View tab -> any of the orientation options) because there were some operations on the DocumentNodeBuilder which is this case doesn't exist so a null reference exception was thrown. Added the necessary checks and the view is changed correctly and editing/selection can continue.

A second issue was selecting the shapes, because the EditingHandlers for some shapes didn't use the new structure where references were passed. After selection started working, I tested editing the shapes using the handles that appear after selection and fixed the crashes.

Editing for arcs is possible using either of the three points:
For the Center, Start, End arcs dragging one of the arc margin points (Start or End) allows us to redefine the size of the arc by moving the point on the contour of the 'circle'. Dragging the Center allows us to change the radius of the arc. There is a problem when previewing this, because the arc keeps flickering and getting really big radius changes in the same point, but I'm working on it.

For the Start, End, Radius arcs dragging one of the margins (Start or End) changes that margin's position (this time it's not done only on the circle contour). After the distance between these points is the desired one, moving the third point sets the new radius.

When editing the shapes, a control appears in its middle, with the planes and axes. These are not done on the same scale as the shape, but as the main axis system, so if the view is zoomed they becomes too big or too small. Also, clicking/dragging it causes the shape to behave in strange ways. Same zooming problem with selection markers and the dimension arrows.

The spline tools work ok, with a small problem for the interpolated spline and spline control points: after drawing and selecting the spline, its line becomes white and is difficult be seen (hovering over it turns it red, so it can be selected). The Split spline and Spline Combine actions work well (the split/combine points are visible).

The changes are here. For the next revision I'll try to fix the issues I've mentioned here:
* CSE arc resize
* edit controls scaling
* edit axis system behaviour
* spline line color

Tuesday, March 27, 2012

Arc drawing fixed

I started working on the NaroCAD code in a new repository, using the most recent code, from here.

After a few small fixes so everything would build and start, I tested the 2D drawing tools and found some problems for the two types of arcs, the drawing for splines and the trim function.

The arcs were not displayed correctly because the plane axis was not passed correctly after the new sketch mode was added. After adding this, the CSE arc was drawn correctly. The SER arc was previewed correctly but when the drawing was finalized it was sometimes reversed (if we previewed the minor arc, the major one was drawn).

The previewing was done using FunctionNames.Arc3P and the drawing was done with FunctionNames.Arc. I've changed the drawing to use the same one as the preview, but since the CSE arc uses FunctionNames.Arc, I'll try to adapt the preview to use it, as well.

You can find the changes here.

Sunday, March 11, 2012

NaroPAD - a very light version of NaroCAD

As my life was (and still is) busy with other activities, I thought it would make sense to make a small yet useful tool for mere mortals.
OpenCascade 6.5. work would take an eternity for our small team, and I know that it would need a lot of work for making it not only to update, but to make all tools to work as smooth as before, so I started from the things that already work.
So what worked well in NaroCAD: the regular shapes and tools, Step loading/saving, most of Undo/Redo operations. In short, it worked the shape creation and documents operations. What it didn't: complex interactions (with selection code for example), some tools (like Layers) would be made ad-hoc so some changes (like picking layer colors) would not reflect in all cases in code.
What is NaroPAD? Is a NaroCAD distribution that expose just the Boo coding and the OpenCascade view. It is also intended for people to preview fast some shapes in OpenCascade and if needed to extend based on specific needs.

The code to create a yellow box using 4 lines, fill them, extrude them and setting the color is the following:

import System.Drawing

util = Self.Shapes
# draw the lines
util.Line(0,0,10,0)
util.Line(10,10,10,0)
util.Line(10,10,0,10)
line = util .Line(0,0,0,10)
#fill the face based on searching the auto-facing
face = util.TryAutoGroup(line)
#pick a framework function named Extrude
ex = Self.Get(Func.Extrude)
#set custom function parameters
ex[0].ReferenceBuilder = face
ex[2].Real = 8
ex.Run()
#set extrude's color as yellow
ex.Color = Color.Yellow

To make your own NaroPAD (or to extend it), you need to take a 1 year old version of NaroCAD (from Mercurial, this revision), and replace the Source folder with the NaroPad_Source.zip.

Execute action have the capability to give the triangle list or to export the shape as Step file. If you dig in NaroCAD's source, you can import fairly easy a step file. So it can be made a fast prototype/preview tool. Also as the text editor is a full Boo language support, there is support for all Boo constructs not limited to classes, control flow (like if/while/for). If you want to learn about Boo, please look here.
If you want just to try it, download it from here.
(License is GPL2 as this code is derived from NaroCAD's GPL2 codebase)