Results 1 to 3 of 3

Thread: Problem with graph drawing

  1. #1
    Join Date
    Aug 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Problem with graph drawing

    Hello, Qt Centre!

    I am creating a graph/automata drawing tool with Qt and it's QGraphicsView framework. Lately I've been working around a geometrical problem that I just can't solve by myself. I need to draw oriented edges and arcs (edges are strigt lines, while arcs are curved splines). I use QGraphicsLineItem objects and QGraphicsPolygonItem to represent an edge and its arrow; for the arcs I use QGraphicsPathItem objects. What happens is that, since transitions (both, edges and arcs) are always oriented (that is, the arrow is always pointing) to the center of the node's items, I need to solve two problems.

    First of all, the arrow position (and the edge's tip point too) should have an offset accordingly to the shape of the node. The arrow should be fixed to the outer point of the node's graphical object. The problem is that nodes may have arbitrary shapes and dimensions so I can't just define a fixed offset. I have to find a way to get an intersection point of the node's shape and the edge's line. It seems that the Qt documentation has no explicit technique to do that. So I'm asking your help...

    The second problem rises from the first one. When a arc is added to a node, the end point is the node's center point. So the spline drawing is oriented to that point. If I change the fixing point to the outer point on the node's shape (that I describe in the first question) the rendering of the spline will also be affected (I use the path.quadTo(const QPointF & c, const QPointF & endPoint) method to draw the spline). So my question is: how can I keep the spline's orientation to the node's center point, but draw it only to the fixing point on the node's shape? And thus place the arrow to that fixing point.

    Thanks in advance for your attention.
    FB27 BB4C 8F03 4980 C311 0968 E66B 9831 BF6F 0265

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problem with graph drawing

    It seems that the Qt documentation has no explicit technique to do that. So I'm asking your help...
    I don't see why it even should include such a thing?
    Its very specific problem, that has nothing to do with Qt, but with a specific application implementation.

    The problem is that nodes may have arbitrary shapes and dimensions so I can't just define a fixed offset. I have to find a way to get an intersection point of the node's shape and the edge's line.
    The most obvious way would be to get the shapes bounding rect, and have the intersection at the middle of the upper face.

    how can I keep the spline's orientation to the node's center point, but draw it only to the fixing point on the node's shape?
    Maybe I don't understand, but you can draw it oriented to the center, and than translate it to the outer point...
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Aug 2011
    Location
    Pune, India
    Posts
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with graph drawing

    may be elasticnode example of Qt can help.
    •graphicsview/elasticnodes/

Similar Threads

  1. Problem to plot 3D graph using QWT
    By johnMick in forum Qwt
    Replies: 4
    Last Post: 26th July 2011, 09:44
  2. Whats the right approach for drawing a simple graph?
    By Menia in forum Qt Programming
    Replies: 1
    Last Post: 2nd September 2010, 15:34
  3. Drawing of graph(data structure) !
    By Abeer in forum Newbie
    Replies: 1
    Last Post: 23rd May 2010, 21:47
  4. Replies: 5
    Last Post: 21st March 2009, 09:10
  5. graph drawing
    By swathi in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2008, 09:27

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.