Friday, 26 April 2013

Drawing Updates & Bloodhound SSC

Pardon me for starting the post off-topic, but last night I went to a talk given by Richard Noble the director of Bloodhound SSC (below), aiming to achieve Mach 1.4 or 1000 mph (~1600km/h ). I freely admit it was an inspiring talk and especially given how little I knew from the small excerpts produced by IMechE - UK's institute for Mechanical Engineering, it provided to be very informative.
Bloodhound SSC
Why I raise this, is that one of the key emphases on the talk is about inspiring the next generation of Engineers not just in the UK but all over the world - akin to Nasa's Moon Landing Programme in the 60's. We share a responsibility as engineers to foster the development of the youth. Many open design such Raspberry Pi and Adruino  are sharing such successes involving children and young adults alike.

Without becoming too philosophical, FreeCAD would be part of this idealistic goal. Being able to provide free but importantly open tools that I never had when I was at school would bring opportunities I wouldn't have dreamt off - I was the one of the last generation at our school to produce hand-drawn drawings, which shockingly was only six years ago.

Ultimately if you cannot contribute to FreeCAD as a programmer, there are endless ways you could help and I wish to thank the members of our community for doing so without initiative!

Back on topic: Drawing Tweaks and Updates

Probably the biggest changes came last night and was most surprisingly because of the fact how tired I was. The Drawing View (QGraphicsView) updates itself when you change it's property, this includes dimensions too and surprisingly works very well. Additionally the drawings are correctly created when you restore a document. 

Hopefully I'll publish a video to better demonstrate this, because  find it a satisfying result.

The other changes is scale independent rendering, edges retain the same stroke width regardless of the document zoom.All this we get for (nearly) free in QGraphicsView! There's a problem with selection at the minute, but hopefully will be sorted out soon (Fixed). I don't believe this is easily done using SVG because transformations are applied at object level. 

The example of above scales as you would expect, which was scaled really small on my screen but is not desirable in CAD drawings. You don't want lines to obscure each other when you zoom in, especially on an extremely complicated part with greater detail such as below.

I've also added a scale option. This currently transforms the original FreeCAD Part, however, I am still unsure is the best approach in terms of performance which could be natively applied in the projection algorithm. However, now it appears to work correctly.

In the previous drawing module the scale was applied at the presentation layer in SVG and wasn't really the best solution although it worked.

I wanted to put a picture up but I am currently upgrading Kubuntu. It will most likely not go smoothly, but atleast I'll be ready to report any problems compiling with FreeCAD.

Taken a short screen cast to show off the Drawing Module in it's current state. Only had 15 minutes to make it this morning, so sorry for the lack of quality!

Note: The drawing artefacts appear when recording the video for some reason but otherwise are not there normally.

Saturday, 20 April 2013

Finally we have arcs that work!

For over a month this has been a problem where on 3D projections, arcs are turned into partial ellipses but were being incorrectly drawn. Attempts to diagnose the problem were unproductive - see the forum topic

There a sudden moments that make you realise that perhaps there is an easier way, just like last night. I though of mimicking the previous code that generates SVG directly. Instead of creating an actual ellipse arc, an cubic arc is produced instead - see the Mozilla Docs.For Qt to render SVG it must process this, so that there must be a method for drawing these somewhere. After some searching I found a function available in qsvg/qsvghandler.cpp. This had what I desperately needed and thanks to Opensource is possible.

Literally copy and pasting the relevant code - later will be re factored to be simplified if possible, this morning I got it working and produced the results I was craving!

This accomplishment crowns the ending of my Easter Vacation. I return to University tomorrow.

The couple of bigs tasks remaining are growing smaller. Ideally, I need the drawing to update automatically by itself, but changes don't propagate into non-3d views. Also we need working templates - looked at by Joshua.

The other is re-doing the export code - we get .svg and .pdf free with QGraphicsView, but .dxf.One thing I am going to enquire is an export to librecad. dxf sounds like the devil, so I think promoting an open format would go well.

The remainder should be smaller jobs that other people could get involved with. By then I hope I could get this be ready for testing by mid-summer. 

Thursday, 18 April 2013

Little updates

Spent the past few days tidying up the Drawing Module as a needed break from revision.

It is starting to come together:

  • Added support for radius dimensions on arcs.
  • Added support for point to point dimension
  • Improved selection of edges and vertexes
  • Antialiased Edges
For an hour I spent adding a nicer selection box for moving a views around which definitely helps prevent annoying selection of the view. 

Dimensions are coming together too quite nicely, although the radius dimensions don't work yet in 3D view. I probably add some arrows, but these are not high priority. 

I've started the work on correctly showing hidden lines. I am pretty pleased with the result. I have opted for selecting the whole edge (visible and hidden), hopefully that seems reasonable.

I was slightly disappointed to find that references for some edges cannot be find in 3D views, however is a limitation imposed by Open Cascade. If a reference cannot be found, these edges are not selectable, since they cannot be used for any measurements. One possible idea to circumvent this problem is to compare the projected edges with references to edges on the original geometry that weren't found. This isn't really ideal, but would be a temporary solution.

One of the other problems is ellipse arcs which still I cannot figure out.

Friday, 12 April 2013

Parametric dimensions in the Drawing Module

After about three weeks, of having to work on various assignments (nearing completion) and revision, I finally had a day off to work on dimension support in the Drawing Module (see above and compare to previous post).

Obviously the dimensions look much better and are correctly positioned and it also shares similar behaviour to sketcher where if the datum label lies outside the arrow lines change position accordingly.

Additionally the dimension can be set to the edge length in X or Y direction now quite easily by changing the dimension mode. Currently the dimensions only work for Straight Line edges, but I plan to address some support for vertexes and obviously circular arcs.

One of the interesting things that had to be thought was how to reference edges that are broken up into smaller segments by any geometry in front.

My first attempt at this failed miserably, where I thought I would reference each segment of the edge and find the ends from there but clearly it wouldn't work. After scratching my head, I thought the best way to go was getting the reference to the original geometry and projecting the whole edge and using this instead for dimensions.

The limitation with this strategy is that if the original reference isn't available you won't be able to get true parametric dimensions. Generally this isn't a problem - nearly all the time I have found references are available and if they aren't usually it is for curves projected onto a 3D view.

It was a bit of work to get to work, because I was using HLRBrep_Curve and that require figuring out what type of curve was produced when finished. I kept to this OpenCascade Algorithm to allow perspective projections if they were ever needed. Luckily it worked!

Behold Parametric Dimensions!

The big test really was to change the projection direction and see what happens...

And yes it worked - although the datum label positions need correcting, nothing else had to be changed. Now changing the geometry (nothing too drastic)...

It's a pleasing result because it's been several months in the works to get this working, not knowing if this would be even possible. Obviously there's a lot left to do.One of my biggest problems at the minute is that if there are changes in the Document Structure, the drawing view must be closed and re-opened

The next priority is to tidy the module up more as it's still feels experimental.