Results 1 to 4 of 4

Thread: Outlining a group of QGraphicsItems in a Scene

  1. #1
    Join Date
    Jun 2009
    Posts
    33
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Outlining a group of QGraphicsItems in a Scene

    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.

    any general suggestions?


    JW
    Attached Images Attached Images

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

    Default Re: Outlining a group of QGraphicsItems in a Scene

    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.
    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.


  3. #3
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Outlining a group of QGraphicsItems in a Scene

    You may have to use CGAL for your purpose...

  4. #4
    Join Date
    Jun 2009
    Posts
    33
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Outlining a group of QGraphicsItems in a Scene

    wysota: Thanks for that, I'll try it and see what I can make of it.

    ini : O.k. what is CGAL?


    JW

Similar Threads

  1. Copy and Paste of QGraphicsItems in a Scene
    By subash in forum Qt Programming
    Replies: 6
    Last Post: 6th July 2011, 15:15
  2. Replies: 1
    Last Post: 10th September 2008, 16:49
  3. How to make a list of QGraphicsItems on the scene
    By Holy in forum Qt Programming
    Replies: 8
    Last Post: 10th June 2008, 13:43
  4. Creating new scene from a part of an old one
    By maverick_pol in forum Qt Programming
    Replies: 6
    Last Post: 28th November 2007, 18:14
  5. Creating a scene from piece of another scene
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 17:51

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.