Results 1 to 4 of 4

Thread: Creating compound paths

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Creating compound paths

    Hi, I am writing a printed circuit board image file (Gerber) viewer that must render to am interactive vector image. The image files are lists of coordinates and drawing mode switches (line vs arc vs outline fill) in between. There are usually many filled polygons with holes knocked out of them. The problem is that these knockouts are not independent in that the solid parts of the shapes are listed first, and then the knockouts are listed on top. This means that I cannot draw a complete compound shape at once and must later look at all shapes underneath the knockouts to subtract them if they overlap.

    I am currently parsing these files into QPainterPaths and adding respective QGraphicsPainterItems to a QGraphicsScene. When I get to the knockouts, I find all the colliding items with the knockout path using QGraphicsScene::collidingItems and subtract the knockout path from the solid paths using QPainterPath::operator-. I do this instead of drawing the background color over the solid shapes because I need to be able to see items on different board layers through the holes. It is extremely slow, however, to do many of these Boolean path operations, making it take an unreasonable amount of time to load some files into the graphics scene. I also considered just adding paths to create compound paths using the even-odd painter drawing mode, but that doesn't work when the knockout shape overlaps multiple paths or even extends outside the boundary of any intersecting path.

    Basically what I want to do is very similar to path differences or object masks in popular vector editing software. Here is a very simple example of the sort of vector image I am rendering:
    pcbtool.png

    Does anyone have any ideas about what I may be able to do here to increase performance or a different approach to consider?
    Thanks

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Creating compound paths

    Thanks for a well constructed question

    I am not intimate with the Gerber File spec.

    The first observation is that knockout entries need only be compared against earlier entries in the same Gerber information layer. Perhaps you could cache an layer's QPainterPaths outside the scene until you see the knockouts (or end of layer) then deal with the in-memory structures without the overhead of the graphics view elements. At the end of the layer add all the painter paths to the scene.


    I am sure someone with more experience of the graphics view will have more ideas.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creating compound paths

    If using bitmaps is an option then one could draw the paths on QPixmap, QImage or similar using QPainter and when the knockout data is available, change the composition mode to Clear and draw the knockouts. After a layer is complete, it can be added to the scene as a single pixmap item. This will result in improved speed at a cost of possible reduced quality while zooming.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 12
    Last Post: 24th June 2011, 09:22
  2. Relative paths in Qt
    By drmath in forum Qt Programming
    Replies: 2
    Last Post: 30th June 2010, 16:50
  3. X11 include and lib paths
    By Oluwafemi in forum Installation and Deployment
    Replies: 1
    Last Post: 3rd April 2010, 15:25
  4. include paths
    By altec in forum Installation and Deployment
    Replies: 0
    Last Post: 8th August 2008, 11:59
  5. How to set paths?
    By hoborg in forum Installation and Deployment
    Replies: 11
    Last Post: 24th February 2006, 19:08

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.