Sunday, 19 January 2014

Updates to the Drawing Module

I'd promise to get some wrote by the end of the week, so here's my attempt on covering updates I have made to the Drawing Module over pretty much the last half of the year.

In general there's been a lot of incremental small fixes that have accumulated over such a long time, which is a stark contrast when I look at the last blog post on this and might seem significant.

One of the big changes was adding initial support for drawing the page background given the width and height and recently spending time switching the origin of the coordinate system to the bottom left with the y-axis pointing upwards - see this post. QGraphicsView orients with the y-axis pointing downwards which is also used in SVG. It's a trivial fix, where the y coordinate is inverted for the position of every Drawing Views. This is needed to ensure consistency with CAD packages and other formats.

The next step for improving the functionality is adding support for templates and displaying this on the background.



These leads onto talking about further work on improving the dimensions. The most obvious detail is the improved presentation of dimensions. There are now arrow heads, which later will be allowed to be changed to a few standard ISO options and the use of a font called osifont, which I was recommended for a starting point for datum labels. The license needs checking as it appears to be GPL 3 - I'm not entirely sure if this is compatible for distribution directly with the FreeCAD release but in the worst case an be installed separately by the user or made a dependency on the packaging front and be used if available by default.


The datum values can be used calculated as project or as true values - if an orthographic projection is used then projected values are used by default. The leader lines are also calculated to the end points of the lines avoiding any overlapping. The dimensions also use caching and now don't need to recalculate when these are moved on the canvas by the user. 


There is now an orthographic container, which contains ortho-views -orthographic projections such as front, left, top etc. These benefit of having a container is that the child orthoviews are much smarter and allow various properties such as scale or the type of projection (first or third angle) to be set from the container which are then cascaded down to the child views. 

QGraphicsView is quite flexible and allows some nice interactivity too. A little feature I implemented was having alignment between views: and can be interactively moved along one axis. You can seen in the screenshot from above the are all aligned correctly. This originally took a while to figure out because the projection used in the current release of FreeCAD is not consistent - the simple trick was ensuring that the centroid of the part is used as the origin of the projection plane. 


Another little feature I added was support for angles - although there are a few cases where an exception is thrown. The final thing I currently can think of working on is improving the print support which is slowly getting there:




Anyway that's an overview and hopefully give some incentive to give the drawing branch another try!





12 comments:

  1. Splendid work Luke! If I understand correctly, this is a complete rewrite of the Drawing module, or are you reusing some code?

    I'll try to test this soon!

    ReplyDelete
  2. Great! I'll give it a test too... Reconnecting to your github repo right now!

    ReplyDelete
  3. @Normand

    It's continuation of what I've been working on over the past year but it is a pretty much a near complete rewrite of the Drawing Module in the master which was used as the starting point.

    ReplyDelete
  4. Looks good;) Luke's implementation should be pushed to the master after very short testing period and released as default Drawing module in the 0.14 stable. There is no interference with other modules AFAIK.

    ReplyDelete
  5. Since 0.14 release is more of a test version with the assembly module, it might be a credible idea but it depends when 0.14 will be released to the public. Last two years it has been around February, but probably will be abit later.

    It might interfere with Yorik's draft/arch module, as I'm sure it uses native projection functions. However, I can always leave the old projections classes in for the transition period since I haven't developed any python interface just yet :)

    ReplyDelete
  6. Luke, have you uploaded changes to https://github.com/mrlukeparry/FreeCAD_sf_master.git drawing branch? A have no Drawing workbench at all now...

    ReplyDelete
  7. hi Adrian,

    yes that is correct. The drawing branch is up to date and that is the correct repo - last commit was made 20 hours ago.

    Check that src/mod/Drawing/Gui has loads of files e.g. QGraphicsOrthoView
    Check that the module is compiling - if it isn't, it sounds like it might be cmake option (FREECAD_BUILD_DRAWING) maybe not be set.
    Final option is to maybe try a fresh install or update the .FreeCAD config directory...

    Hope that might help!
    Luke

    ReplyDelete
  8. Had to remove the .FreeCAD directory and it's fine now. Thanks!

    ReplyDelete
  9. So if I understand correctly, merging into master will obliterate j-dowsett's recent work on the Drawing module. His ortho views and axonometric views wizard works very well. I would suggest that the merge happen after the 0.14 release as his work would not be completely wasted and would stay on the next stable version.

    Luke and Adrian, you may not know but Jriegel has about decided to postpone merging of the Assembly module before the stable release. He wants to plan ahead and fears problems in the long run if it gets merged for 0.14 (he probably has the topology naming problem in mind...). The Part Design Body work along with working planes by JRheinlander would be merged before release.

    ReplyDelete
  10. Hi Normand,

    Thanks for the tip about 0.14 - it seemed to good to be true that assembly was coming early.

    The good thing is that j-dowsett work can still be incorporated into what I've been doing. The automatic scale calculation and position of orthographic views should be able to transferred over without much problem - including the Gui tool. The template stuff I'm not sure about, but deliberately left to him. I'm not a fan of duplication so I like to avoid it at all costs ;)

    I'm not sure if we'll get it in 0.14 but we have a rolling master pretty much so there's no stopping up merging this in after the release for avid testers ;)

    ReplyDelete
  11. Normand, Luke,
    the discussion becomes more and more interesting - maybe we should start a new thread on the FreeCAD forum? It's a better place (nothing personal Luke;)

    I think, the assembly module can break many things (we have even no document for assembly AFAIK!) and should be postponed. Decent drawing module is the single most anticipated FreeCAD feature since... hmm 2009? The question is if it can break others (j-dowsett) work?

    ReplyDelete
  12. I wish I got email notifications from comments here!

    More talk about Assembly (for Adrian, as Luke already joined the discussion): http://forum.freecadweb.org/viewtopic.php?f=8&t=5462

    The Assembly branch may be merged into master after all, but Jürgen requests that it not be built in release builds (unstable Mac binaries, Win installers and daily builds PPA).

    As for Drawing, I'm glad that j-dowsett's work can be integrated with yours, Luke.

    ReplyDelete