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