logic: Show inheritance edges between parents of active symbol and other visible symbols (issue #167)
* add inheritance edges between parents of active symbol and other visible symbols * add dashed inheritance edges when symbols are no direct decendants * inheritance edges are also respected in layouting, putting base/derived classes in the correct top/bottom spot now bug id = 167
This commit is contained in:
@@ -32,7 +32,8 @@ QPainterPath QtLineItemAngled::shape() const
|
||||
|
||||
void QtLineItemAngled::paint(QPainter* painter, const QStyleOptionGraphicsItem* options, QWidget* widget)
|
||||
{
|
||||
painter->setPen(pen());
|
||||
QPen p = pen();
|
||||
painter->setPen(p);
|
||||
|
||||
QPainterPath path;
|
||||
|
||||
@@ -169,7 +170,17 @@ void QtLineItemAngled::paint(QPainter* painter, const QStyleOptionGraphicsItem*
|
||||
partRect = getArrowBoundingRect(poly);
|
||||
if (drawRect.intersects(partRect) && m_showArrow)
|
||||
{
|
||||
drawArrow(poly, &path);
|
||||
if (m_style.dashed)
|
||||
{
|
||||
QPainterPath arrowPath;
|
||||
drawArrow(poly, &path, &arrowPath);
|
||||
|
||||
painter->drawPath(arrowPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawArrow(poly, &path);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -177,5 +188,11 @@ void QtLineItemAngled::paint(QPainter* painter, const QStyleOptionGraphicsItem*
|
||||
}
|
||||
}
|
||||
|
||||
if (m_style.dashed)
|
||||
{
|
||||
p.setStyle(Qt::DashLine);
|
||||
painter->setPen(p);
|
||||
}
|
||||
|
||||
painter->drawPath(path);
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ QRectF QtLineItemBase::getArrowBoundingRect(const QPolygon& poly) const
|
||||
return rect;
|
||||
}
|
||||
|
||||
void QtLineItemBase::drawArrow(const QPolygon& poly, QPainterPath* path) const
|
||||
void QtLineItemBase::drawArrow(const QPolygon& poly, QPainterPath* path, QPainterPath* arrowPath) const
|
||||
{
|
||||
int dir = getDirection(poly.at(1), poly.at(0));
|
||||
|
||||
@@ -364,7 +364,6 @@ void QtLineItemBase::drawArrow(const QPolygon& poly, QPainterPath* path) const
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (m_style.arrowClosed)
|
||||
{
|
||||
path->lineTo(tip + toBack);
|
||||
@@ -375,6 +374,12 @@ void QtLineItemBase::drawArrow(const QPolygon& poly, QPainterPath* path) const
|
||||
path->lineTo(tip);
|
||||
}
|
||||
|
||||
if (arrowPath)
|
||||
{
|
||||
path = arrowPath;
|
||||
path->moveTo(tip);
|
||||
}
|
||||
|
||||
path->lineTo(tip + toBack + toLeft);
|
||||
|
||||
if (m_style.arrowClosed)
|
||||
|
||||
@@ -45,7 +45,7 @@ protected:
|
||||
int getDirection(const QPointF& a, const QPointF& b) const;
|
||||
|
||||
QRectF getArrowBoundingRect(const QPolygon& poly) const;
|
||||
void drawArrow(const QPolygon& poly, QPainterPath* path) const;
|
||||
void drawArrow(const QPolygon& poly, QPainterPath* path, QPainterPath* arrowPath = nullptr) const;
|
||||
|
||||
void getPivotPoints(Vec2f* p, const Vec4i& in, const Vec4i& out, int offset, bool target) const;
|
||||
|
||||
|
||||
@@ -398,6 +398,7 @@ MessageActivateTrail QtGraphView::getMessageActivateTrail(bool forward)
|
||||
|
||||
switch (node->getData()->getType())
|
||||
{
|
||||
case Node::NODE_NON_INDEXED:
|
||||
case Node::NODE_CLASS:
|
||||
case Node::NODE_STRUCT:
|
||||
case Node::NODE_INTERFACE:
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "data/graph/Edge.h"
|
||||
#include "data/graph/token_component/TokenComponentAggregation.h"
|
||||
#include "data/graph/token_component/TokenComponentInheritanceChain.h"
|
||||
#include "qt/graphics/QtLineItemAngled.h"
|
||||
#include "qt/graphics/QtLineItemBezier.h"
|
||||
#include "qt/graphics/QtLineItemStraight.h"
|
||||
@@ -207,6 +208,15 @@ void QtGraphEdge::updateLine()
|
||||
showArrow = m_direction != TokenComponentAggregation::DIRECTION_NONE;
|
||||
}
|
||||
|
||||
if (getData())
|
||||
{
|
||||
TokenComponentInheritanceChain* componentInheritance = getData()->getComponent<TokenComponentInheritanceChain>();
|
||||
if (componentInheritance && componentInheritance->inheritanceEdgeIds.size() > 1)
|
||||
{
|
||||
style.dashed = true;
|
||||
}
|
||||
}
|
||||
|
||||
child->updateLine(
|
||||
owner->getBoundingRect(), target->getBoundingRect(),
|
||||
owner->getParentBoundingRect(), target->getParentBoundingRect(),
|
||||
@@ -262,9 +272,11 @@ void QtGraphEdge::onClick()
|
||||
}
|
||||
else
|
||||
{
|
||||
TokenComponentInheritanceChain* componentInheritance = getData()->getComponent<TokenComponentInheritanceChain>();
|
||||
|
||||
MessageActivateEdge msg(
|
||||
getData()->getId(),
|
||||
getData()->getType(),
|
||||
componentInheritance ? Edge::EDGE_AGGREGATION : getData()->getType(),
|
||||
getData()->getFrom()->getNameHierarchy(),
|
||||
getData()->getTo()->getNameHierarchy()
|
||||
);
|
||||
@@ -274,6 +286,10 @@ void QtGraphEdge::onClick()
|
||||
msg.aggregationIds =
|
||||
utility::toVector<Id>(getData()->getComponent<TokenComponentAggregation>()->getAggregationIds());
|
||||
}
|
||||
else if (componentInheritance)
|
||||
{
|
||||
msg.aggregationIds = componentInheritance->inheritanceEdgeIds;
|
||||
}
|
||||
|
||||
msg.dispatch();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user