PDA

View Full Version : Outlining a group of QGraphicsItems in a Scene



spawn9997
26th June 2009, 23:52
Hello all,

I am looking for a way to obtain the outline, shape(), of several QGraphicsItems that may or may not be overlapping. They are all children of a single QGraphicsItem for which I currently am drawing the boundingRect(). I computed this rectangle from the union of all of the boundingRect() of the child items; so I figured, instead of this large square I can somehow get the shape of all of the child items combined.

If the group of items looks like attached pic (someItemSet.png),
then I want my shape to look like this attached pic (someSetShape.png).


For simplicity, assume squares of the same size that do not change. It does not have to be so perfect or curvy, that is just how I drew it in Gimp; but, it could form any shape based on the data for the items.

I know about QPainterPath and QPainterPathStroker but can't quite come up with the algorithm. Maybe I'm too tired or maybe it is because of Friday. :D

any general suggestions?


JW

wysota
27th June 2009, 00:12
See the QRegion class and especially its QRegion::united and operator+ members.

There is also QPainterPath::addRegion() if you are interested in obtaining a path covering the whole region.

lni
27th June 2009, 00:13
You may have to use CGAL for your purpose...

spawn9997
29th June 2009, 17:03
wysota: Thanks for that, I'll try it and see what I can make of it.

ini : O.k. what is CGAL?


JW