Monday, February 28, 2011

Combine Spline Tool. Angle Between Lines Tool

Spline have a new tool that is used to combine two coincident splines. It is useful if you will work with multiple splines or you split an already existing spline and you found (later) that you want to be again in one piece.
A tool to chose the angle between lines (this tool is a bit unpolished, so may change a little in future).
A preview is shown below:

Updater - Part IV

The updater now does a file compression. This means that NaroCAD downloads the compressed files, makes an uncompressing and continues with its job. By downloading compressed files, the download is 3-4 times smaller. One other advantage is that NaroCAD can detect if the file was downloaded correctly by trying to uncompress. If it works, the download was successful. If not, the uncompressing will fail. This way, it’s much easier to determine if a file was downloaded correctly or not. While this change is definitely good for the user, it also benefits us, because it doesn’t take so much time to upload NaroCAD and makes testing the updater a bit faster.

Sunday, February 27, 2011

Spline Tools Improvements

Split Spline is a new tool. It will preview the points you defined your spline so you can split in parts. Spline tools have a fast-access buttons (this view right under ribbon control) will make much faster to access without going to contextual spline menu over and over (you may try for example to define an interpolated spline, then try to split and then go back to interpolated spline and you will understand right away what I'm talking about :) ).
Interpolated Spline and Control Point spline have two small improvements:
- pressing shift for a point on a spline will delete it. This is useful if you made a point that was defined on a wrong coordinate and you don't want to remake it
- if you start dragging a point, you can insert the coordinate from command line, so you may can work right away and fix it later.
The editing component of spline is not yet finished, but expect more goodies in this area.

See a small demo here:

Spline Undo/Redo Fixes

Spline have a representation that was prone to Undo/Redo errors as there is a need for custom logic for having a dynamic sized shape. This logic is fixed
Also I've did the skeleton work for Split Spline tool but this will be described (most likely) in the next blog post.

Friday, February 25, 2011

Block Plane Enhancement

Block Plane is smarter: if you will select a face like on XOY, YOZ or ZOX plane, the view will also follow suit (for example if you picked XOY design, the view will switch to Top), so you can start doing designs right away.
Hinter is also shown live how it works as it can be seen here:

Thursday, February 24, 2011

TreeView Assert Fix and Solver Quick Enablement

TreeView can assert (and crash) sometimes with an assertion. This assertion is made to not introduce twice the same element. Right now even if an element is introduced twice, the event is logged but will not crash NaroCAD.
Solver options are exposed from the main interface to be one click away. One other change is that (excluding this screenshot that was a development photo) is changed to be named Hinter. In this way I will not use erroneously interchangeably those two words.

Updater - Part III

I managed to solve all the problems related to downloading the needed files. The main problem was that I made too many tests after downloading the files, so many that the integrity of files was never ok. I also made a cool trick while fixing these problems. NaroCAD will not only download the newer files, but will also check if the current files are still valid. Because I couldn’t use the hash code for many of the files, I checked the file lengths (in case they even exist on disk). What does this mean? Let’s say that the user “accidentally” deletes the help files, some NaroCAD icons, and more. If NaroCAD needs update and still has enough files to start, the update will verify that even the unchanged files still exist on disk and that they have the correct size. This way, the updater will automatically download those files for you, and will fix and update NaroCAD at the next start-up. Even if you have the latest version, and “accidentally” delete some files that are not critical to NaroCAD at start-up, just change the version number from the Version file to a lower one. NaroCAD will try an update and will heal itself :) Don’t worry if the internet connection is lost during that process. NaroCAD will try again at the next start-up, not from scratch, but it will continue from where it had left off.

Wednesday, February 23, 2011

Cubic Spline Improvments

I've finished polishing spline related tools in NaroCAD to be more complete and easier to use.
So you will have three spline types under NaroCAD and they will work a bit better than in the past.
Some fixes may be still needed but at large Spline related tools are nice to work with and you may enjoy using them (in next releases). OpenCascade 2D layers do not work concomitantly (or I've misunderstood how they work) but I've rewrite to make possible to write multiple texts so when you will use Spline you will see coordinates)
Note: cause of internal changes, if you was using in the past Spline Path tool, I do recommend you to work with nighties, because this functionality is rewritten in a non compatible way. Also the old code was making to add features on it (like a proper editing code) very hard, so will be unlikely to get fixes will be in that area.
So take a look:

Mistake: cubic splines are defined by 4 points.

Arc gizmos

For simpler editing of Arc(start, end, radius) and Arc (radius, start, end) added Gizmos for them. Made Gizmos also for the cone base, that would allow users to modify the cone base by dragging with mouse.

Updater - Part II

Yesterday I told you that NaroCAD will only download the files that were changed during the new release. Although I encountered problem with checking the file length, the hash code was a bit tricky. The main problem is that the hash code had different values depending on the time the file was created, and other parameters.

The main problem was that every build changed the hash code of the project files. The only solution to this problem would be to study how the date information is stored in files, study the encryption and decide whether the new file has useful information or not. Still, we mustn’t forget that the size of these files is small (very small if compressed). Even if I were to study these changes, I would still have to download the file in order to do the analysis. Even more, the analysis would be time consuming. The best way is to download all the generated files and check if changes were made to all the other files. This is a bit easier because these files don’t suffer from small changes, usually no changes at all. Given that the files without such problems are more than 70% of all NaroCAD files, the updater will prove much faster than actually downloading and installing NaroCAD.

To tell the truth, even the other files have different hash code when created by the installer. The advantage is that building the projects will not change these files. This means that the developers will not store different hash code for these files when generating the information of the versioning files. If these files are changed, the information from the versioning files will also change. Knowing this helps me to implement a faster updater. The only trick is that the newer hash code of these files (for example OpenCascade libraries, icons, etc) will be compared with the hash code from the current versioning files. This way, the contents of these files will not be red. What does this mean? If someone changes a character of such a file on purpose (so that the length remains the same) the updater will not be able to tell the difference.

So, to make it brief: the files generated by the NaroCAD projects will always be replaced in the new versions, and all other files will be downloaded only if needed.

Tuesday, February 22, 2011

NaroCAD Startup Time And Lazy Loading

NaroCAD historically was used to use SCSF and as it was removed for some time, NaroCAD improves start time from like (I will use timing from my machine) 7-8 seconds to 4 seconds. Most of this time was because of JIT of SCSF and SCSF related logic.
As of today the startup time is splitted like this: library startup (.Net, DirectX subset used by WPF, OpenCascade startup, browser control that is used both on Tips window and on Help view), JIT (still, but at a smaller margin), layouting (Ribbon control will layout all buttons to fit right, all menu items and so on), NaroCAD framework logic and some Boo evaluation code.
So as for now on my machine (which is an i5M CPU class laptop) is around 3 seconds and I will explain what was changed in mostly the last 2 months, from when SCSF was removed and how JIT time was also greatly removed.
When we register things in NaroCAD (like actions, buttons) we always hit constructors. And this constructors are compiled with everything is in them. So, the logic that was in the past, regarding them was moved to an external method, that can be overriden named OnRegister. This will be called lazily as needed, so you will likely you will not see that an action will need a list of inputs to be setup. Another thing is that most actions will inherit mostly two classes (ModifierContainer or DrawingLiveShape) making precompiling to happen just once.
Another small issue was that layouting of all tabs take around 0.7 seconds, so tabs are also layouted from first time when you activate them. This will add just 0.2 seconds on average (for first time) when you will switch tab, but is much better if you will start often NaroCAD (hopefully not for crashing reasons).
Another section that was seen in profiling, and was made in 1.5.7 timeframe (so you get this even without nightly builds) is that Boo expression evaluator will be used in any instance using an interpreter. This will mean that your expresions if are like loops, they will likely execute slower (yet, external methods are executed through a compiler). To run as an interpreter, makes the logic of the code much simpler from Boo parsing and executing side and will likely speedup 3x in most cases.
At the end, regular poly tool was compiled at NaroCAD startup, but today is compiled just first time when is used.
Why I wrote this post? Mostly to know that we do keep an eye on how NaroCAD works both outside (we get on average fewer errors than in previous releases as bug reports even as download count goes up) and from inside.
Also, I wanted to you to know how and why "NaroCAD is slow": WPF is like starting a small DirectX game, and similarly when we start OpenCascade libraries (that load OpenGL libraries), Internet Explorer control, Ribbon to do layouting, and so on, at the end you will get this startup time.
Do you have a specific case when NaroCAD works slow for you? May you share it with us? Use NaroCAD and with your feedback we will make it better.
As an update: sometimes Polar Coordinate setup may lose its values from options and all around bugs were fixed. We use cubic spline "magic number", so if you will draw splines that are placed in corned of a square, the 4 leg spline will approximate a circle as described here. The next nightly may show it to you.

Updater - Part I

I’ve started to implement an updater. Since it’s a lot to explain and since my work is not done yet, I will do it step by step. The user will be able to use 2 check boxes that allow NaroCAD to search for nightly builds, stable builds or nothing at all. I will use a button with different colors in order to tell the user if new updates are available, if files are being downloaded, or if the latest download is finished. One of my purposes is to download as less as possible in order to update NaroCAD. This is why I will use a versioning file that contains the current version (nightly or stable) and information about critical files in NaroCAD. As expected, newer versions will have a different version number and some of the files will disappear, new ones might probably appear or some of them might change because new features were implemented. In order to investigate if one of these files was changed, I decided to check the length of the file and its hash code. With this strategy, just a few files will be downloaded for each new NaroCAD version. I will end for today with the explanation of the 2 check boxes: the first one is called “Check for updates”; if this check box is unchecked, NaroCAD will not search for any new updates. When checking it, a new check box will appear “Experimental builds (nightly)”; if the user doesn’t check it, only the stable builds will be downloaded. If both of them are checked, NaroCAD will search for every Nightly Build. Note that the nightly builds contain the stable builds, so don’t worry, no features will be lost.

Monday, February 21, 2011

Polar Coordinate Match

The last release (1.5.7) have a nice tool that locks lines on three major axis (OX, OY and OZ) that can be enabled/disabled (named Ortho tool). At the end I hope that you will feel more at home with free angles.
Look how it works in this small video. If you want to test it, pick the nightly build from right:


Note, if you will want to test the new spline code, this code is fairly broken.

Saturday, February 19, 2011

Non Common Cases Crash Fixes. Reviewed To Improve Spline

Some categories of bugs are named "bugs that are not in normal flow". One of those bugs was noticed by Sami and is that some parts of the code are done "just in the right moment", like "Tree View node creation". Sometimes this Tree View can be updated forcifully and can lead to crashes because scanning of shapes in scene can encounter invalid shapes when is populated, or can appear artifacts. Sadly this crash can be triggered in cases when you change solver options.
So the solution is for now to not update any time tree view, and when is needed, will restore everything in a stable state (to be certain that those crashes will not happen).
Splines in major design tools are of three types:
- one of as many points as possible, being the equation that is defined by all points of it. Was our original spline tool implementation
- another two are based on 4 point spline "legs", one is made by using control points and other one for simplicity uses the same control points but will interpolate the values for user, because it reduces the click count by a third
So logically the "Control Point" and "Interpolated" spline are both implemented in the same time, anyway, as both shapes have some exceptions from other shapes, some problems in implementation were obvious (like is one shape that transformation is handled separately). Editing in 1.5.7 works just for first leg of Spline, and so on.
I was evaluated problems of it and I've looked to other how they do it, and I found and I'm on the right track to solve all class of problems: Spline (interpolate and control point) will be consolidated in a single shape), also the actions that expose it will share a good bunch of code (excluding the interpolate "automatical generation of points" that will be different between those two tools). In this time I've also evaluated and solve some small issues I've found around the way: NaroCAD had no dashed fixed distance (not infinite) line that I wanted to use it for previewing the control lines. Also a small bug, but for certain annyoing was that the code for setup the color was not working for "interactives", and the root cause was that we setup style for shapes (a great thing for rectangles).
So in short hopefully soon you will see a spline that will work fairly right in most design ways and will be a useful and friendly tool.
Note: Did you know that you can insert coordinates for Spline from command line? In case you wanted a precise tunning?

Friday, February 18, 2011

Magic points with Gizmos

Enabled magic points on Gizmos. The feature seems to behave well and is useful in many situations/ Will work with it more to see if it has problems.

A video sample of using it:

Horizontal and Vertical lines intersection points

Finalized the horizontal vertical lines intersection magic points. This feature will allow users to use horizontal and vertical lines as guidelines for other geometry.

Thursday, February 17, 2011

Fixed and improved Fillet and Chamfer tools

Fixed the Fillet 2D, Fillet 3D, Chamfer 2D and Chamfer 3D tools.

Simplified the usage of all these tools. Now the usage flow is the following: click on the tool icon, the tool when starts automatically changes selection mode to edge (where needed), the user clicks on the edge/wire to fillet/chamfer, a dialog appears on which the user can enter the fillet/chamfer radius (the modifications on the dialog are previewed live on scene).

Because fillet/chamfer were the last tools that needed the selection change tool, disabled for the moment the change selection tool.

Wednesday, February 16, 2011

NaroCAD 1.5.7 Released

"Thinking in 2D": A lot of 2D related work was done inside NaroCAD codebase and you can enjoy it by downloading the last release (link bellow):
  • Added Ortho tool: Blocks drawing on horizontal vertical direction:
  • Added Trim tool: so you can make proper designs combining 2D shapes
  • Block plane tool: The user can block drawing on a specific plane: you can work without annoyances in any free form plane so you can make your designs to really work
  • Measurement tool: so you can see distances without actually creating geometry
  • Enhanced line tool: The line length can be inserted on command line.
  • Added spline path tool: is an enhanced spline, with fewer of "multi-point" spline. It is more precise and you will get more changes later.
  • Copy paste tool: combines copy paste with precision translate: so will make repetitive shape creation even nicer
  • Modify solver precision with scene zoom level: so the solver will feel both precise and useful
  • The solver returns the closest point, not the first solution found: making an "non-calibrated" solver to give relevant point that you may search
Download it from here.
We also ported (mostly, some bugs stop to make it even as a future prospect, but who knows, we welcome reviewing code) SketchSolve, and in case it will be finished, a full 2D solver, C# based may be a part of NaroCAD.

Saturday, February 12, 2011

Bug Fixing and Zoom

I've work on bug fixing as the next week will go in this area. One small feature is implemented also, so is existing framework so when is computed the zoom level to view, this will be used to have "around area" solver sensitivity. This will make it more smooth "around point" experience.
Line as it was rewritten to handle command line differently, a bug was that you could possibly create a zero length line. Right now the "double clicks" are ignored.

Thursday, February 10, 2011

Line Improvements

I've mostly fixed problems with Line tool handling in two kind of fixes:
- Line will not compute parallel line solver checks with points from previous line
- command line was fixed to handle custom "Unknown" type (previously command line was used to work with specifed types only) to make
In the last days I've converted line to line to C# SketchSolve. Anyway, there are some problems and that code works a lot with pointers/references and for this reason, the code does not work as it should. There may be little mistakes, but are enough to make this code to break. Most likely I do work on a copy when I should not, or vice-versa. If are any takers that need a full solver in 2D (with constraints) and want to be C# ready, please take a look to this project and try to spot where are the problems. The code include both code-bases in a project under: Lib\Install\Lib\NaroSketchSolve\NaroSketchSolve\. I'll put the code as LGPL, so if you will fix, please contribute back this source code but also you will be able later to put it under your project, even is comercial. If you are pleased with the original C only implementation, you may wrap it using P/Invoke, so you will not have any LGPL restriction, but will be hard to see where are problems and why. (The original code is under BSD) This project is also better written as is OOP, it mostly respect NaroCAD codestyle, (even will keep for now a lot of variables and names from original code), so you may find it easier to navigate than the original code.

NaroCAD shape locations on scene

Lately we had a lot of problems at tools like Trim and Mirror caused by the way we generate shapes vs the way Opencascade generates shapes:
- when building a line let's say as example the (10, 10, 0) to (20, 20, 0) line we generate internally the (0, 0, 0) to (10, 10, 0) line and hold on some transformation interpreter the transformations applied on the shape, in our case a translation to (10, 10, 0). In this way we can expose to the user on the property grid the shape transformations and allow user to change them. A simulated shape in Draw Test Harness is like the following:

vertex v1 0 0 0
vertex v2 10 10 0
edge e1 v1 v2
ttranslate e1 10 10 0
dump e1

The dump result is:

Dump of 1 Curves
-------
1 : Line
Origin :0, 0, 0
Axis :0.707106781186547, 0.707106781186547, 0
Dump of 1 Locations
-------
1 :
Elementary location
( 1 0 0 10 )
( 0 1 0 10 )
( 0 0 1 0 )

The shape geometry is generated on (0, 0, 0) and holds the shape transformation on Location.

- When applying Opencascade algorithms like Trim or Mirror on our geometry like the one described above the result is a shape with Geometry generated in (10, 10, 0) and Location to (0, 0, 0). This creates us a lot of problems because we don't know where geometry is located, we don't have access to transformations, we have problems when a shape generated like this is passed to an algorithm together with a shape generated like in the case below. A Draw Test Harness sample of this type of shape:

vertex v1 10 10 0
vertex v1 20 20 0
edge e1 v1 v2
dump e1

The dump result:

Dump of 1 Curves
-------

1 : Line
Origin :20, 20, 0
Axis :-0.707106781186547, -0.707106781186547, 0

-------
Dump of 0 Locations
-------

The solution:

We decided to use everywhere only shapes located on (0, 0, 0) and hold transformations on our internal interpreter. That assumes an extra step on our side to prepare geometry before using OCC API: we have to save current transformations, translate all shapes involved towards origin, apply the API, translate the result at the saved transformations by applying the transformations on the interpreter.

Modified the Pipe and Trim tool to work like this and it seems to work well even on shapes that have rotations applied on them. If testing passes successfully we'll start modifying tools like mirror, extrude, cut to use this approach.

Wednesday, February 9, 2011

Trimming tool

Finalized a first version of the Trim tool that works on basic situations like line intersecting line or line intersecting circle. Had difficulties making the tool work not because of the trimming algorithm but mostly because of the way we and Opencascade generate shapes. Will make another post with technical details related to this issue.

A circle and 2 lines trimmed with another line:

Sunday, February 6, 2011

Copy/Paste Fix

Copy/Paste when you copy and nothing is selected crash is fixed. I've did some work on an improved 2D solver logic but yet the advances are there but is not yet something substantial, because I've started from a C codebase, but I will be back with details if things will get in a proper direction.
So make sure that you select something before you try using Ctrl+C to copy an object to not crash on Paste.

Wednesday, February 2, 2011

Lines' Length and Orthogonal Axis Lock

You will be able to set either the next coordinate or to write just the length for line (in command line) and the line will be drawn accordingly.
You can also lock drawing to make it that you can move mouse just parallel with main axis. This works internally as a Solver mechanism, so in some cases that disable solver all-together may seem to not work, but in general with every shape drawn you will have this possibility.
To use it, you may check the nightly build.

Tuesday, February 1, 2011

New Spline Code

Spline will have a new way of creation. The original spline used an equation that will add-up as much as many points are done. This is both imprecise and fairly unconventional. So the design worked to improve this are by making spline as defined in portions that are defined by two end points and two control points. This also scales better, as the old spline was limited to around 20 points, this one will get as many points you will throw to it, because the full spline is a chain of smaller splines. The implementation was mostly done from yesterday, but the work was done to define automatically good defaults for handlers, so you will have a precise spline with a clear preview. So, enjoy using it (is named Spline Path and is under the Spline drop down).
A handy tool is the measure tool: you will click between points and you will get the distance between them. It may be used to define distances between shapes without defining extra geometry in scene.

Trimming tool

Implemented a Trim method that receives as parameters two edges and a point in space. The method trimms one of the edges with the second one on the side shown by the point in space. For now it seems to work well on unit tests made for it.

The output of Trim is for the moment a wire in space. In order to make the tool much more powerful the plan for the final Trim tool is to generate geometry that we "know" in Naro. Ex: a trimmed Circle will create an Arc Node in Tree View editable in Property Grid, a trimmed Line will generate a Line Node.

Smart Copy Tool

This tool isn't as simple as Ctrl+C and Ctrl+V. The main idea is to create more copies of an object. We saw that the circular and array pattern create copies of an object that have a calculated location compared to the base shape. What if the copies are to be made at locations that do not correspond with any pattern? The idea is to copy a shape at any desired location with just one mouse click.
Copy works like this:
- The user presses the "Copy" button
- The user selects the shape to be copied
- The user selects the desired base point
- The user selects a location where the copy is to be made. The base point of the copy will become the selected location
- The user selects other locations where other copies are to be made
Be careful that this command does not end. Any given point will generate a copy of the desired object. The user can create as many copies as necessary. The base point is required, because NaroCAD needs it in order to calculate the translation vector (move the object from the base point to the given location). Without giving the base point, NaroCAD would have to use the pivot or the gravity center as default. I prefer not to use values that cannot be changed when making a new feature. This way, the user has enough control over the shapes that are to be copied. After selecting the base shape and the base point, the user just has to select the desired locations where the copy is to be made. At every mouse click, a new copy will be generated. In order to try out this tool, you can download the last nightly build from www.narocad.com, under the downloads section.