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:
Does anyone have any ideas about what I may be able to do here to increase performance or a different approach to consider?