5 Attachment(s)
Re-engineering the Diagram Scene Example - Issues
Hello forum,
I have made some changes to test inside the diagram scene example to make the concept work in the main application i am working on.
Lets take a look inside the original example and flag the things that i have changed and the rest that remained same
1. Arrow class - (CHANGED) A new Super class is created called ArrowGraphicsItem as follows:
Attachment 7316
The subclass of the above class will decide based on the over-ridden shape() function if the specialized subclasses will render line arrow or some other customized cubic arrows.
To make the view crispy enough almost all the functionalities has been moved to a new class called DiagramSceneView and the declaration of the class is as follows:
Attachment 7317
Now i have another new class that Specialize the ArrowGraphicsItem and it is actually will try to implement the Arrow class using the QPainterPath and this is where i m getting stuck . The class declaration of the specialized arrow graphics item is as follows:
I am getting some artifact when i re-implemented the specialized arrow class with the painter path instead of the graphics line itemAttachment 7318. If we take look at the original Arrow class in the Diagram Scene Example we can see that it has sub-classed the QLineGraphicsItem . The change that i am doing is that i have sub-classed the ArrowGraphicsItem and i have to make some changes inside the following function of the Arrow class
The above function is removed and move its implementation into the shape() instead as follows:
Code:
{
//if the start and the end item collides we do not draw anything
if (myStartItem->collidesWithItem(myEndItem))
QLineF centerLine
(myStartItem
->pos
(),myEndItem
->pos
());
QPolygonF startPolygon
= myStartItem
->polygon
();
QPointF p1
= endPolygon.
first() + myEndItem
->pos
();
QPointF p2
= startPolygon.
first() + myStartItem
->pos
();
for(int i = 1; i < startPolygon.count();++i)
{
p3 = startPolygon.at(i) + myStartItem->pos();
QLineF::IntersectType intersectType
= polyLine.
intersect(centerLine,
&intersectPointFirst
);
if(intersectType
== QLineF::BoundedIntersection) break;
p2 = p3;
}
for (int i = 1; i < endPolygon.count(); ++i)
{
p3 = endPolygon.at(i) + myEndItem->pos();
QLineF::IntersectType intersectType
= polyLine.intersect(centerLine, &intersectPointSecond);
if (intersectType
== QLineF::BoundedIntersection) break;
p1 = p3;
}
m_path->moveTo(intersectPointFirst);
m_path->lineTo(intersectPointSecond);
m_destinationHeadDirection = ArrowHeadDirectionEveryWhere;
return *m_path;
}
Please Check the following attachment
Attachment 7320
Attachment 7319
I think i am doing something wrong in the shape() and updatePositoin() function of NewGraphicsItem.
Please go through and help me to get around this issue.
Regards
Sajjad
Re: Re-engineering the Diagram Scene Example - Issues
I can't see you calling prepareGeometryChange() anywhere.