ui: Improved vertical layout for override and inheritance edges

This commit is contained in:
Eberhard Graether
2018-02-07 23:15:55 +01:00
parent 683b87d0b8
commit 9773c30fdc
8 changed files with 75 additions and 35 deletions
@@ -575,7 +575,12 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(
style.arrowLength = 20;
style.arrowWidth = 14;
style.arrowClosed = true;
style.originOffset.x = 7;
style.targetOffset.x = 34;
style.originOffset.y = -15;
style.targetOffset.y = 15;
style.verticalOffset = 0;
style.cornerRadius = 7;
style.zValue = isActive ? 2 : -3;
break;
case Edge::EDGE_INCLUDE:
@@ -17,7 +17,7 @@ public:
return "MessageScrollSpeedChange";
}
virtual void print(std::ostream& os) const
virtual void print(std::wostream& os) const
{
os << scrollSpeed;
}
+15 -5
View File
@@ -8,7 +8,7 @@ QtLineItemBase::QtLineItemBase(QGraphicsItem* parent)
, m_showArrow(true)
, m_onFront(false)
, m_onBack(false)
, m_horizontalIn(false)
, m_earlyBend(false)
, m_route(ROUTE_ANY)
, m_pivot(PIVOT_THIRD)
{
@@ -64,9 +64,9 @@ void QtLineItemBase::setOnBack(bool back)
m_onBack = back;
}
void QtLineItemBase::setHorizontalIn(bool horizontal)
void QtLineItemBase::setEarlyBend(bool earlyBend)
{
m_horizontalIn = horizontal;
m_earlyBend = earlyBend;
}
QPolygon QtLineItemBase::getPath() const
@@ -96,6 +96,7 @@ QPolygon QtLineItemBase::getPath() const
float dist = -1;
std::map<int, float> dists;
// find start and end points
if (m_onFront)
{
io = 3;
@@ -139,6 +140,7 @@ QPolygon QtLineItemBase::getPath() const
}
}
// start/end and offsetted start/end points
Vec2f o[4];
getPivotPoints(o, oR, oR, oOff.y, false);
@@ -167,11 +169,12 @@ QPolygon QtLineItemBase::getPath() const
case 3: c.setX(c.x() - oOff.x); break;
}
// move one offsetted point
if (it != io)
{
if ((it == 1 && b.x() < c.x()) || (io == 1 && b.x() > c.x()))
{
if (m_horizontalIn)
if (m_earlyBend)
{
b.setX(c.x());
}
@@ -182,7 +185,14 @@ QPolygon QtLineItemBase::getPath() const
}
else if ((it == 2 && b.y() < c.y()) || (io == 2 && b.y() > c.y()))
{
c.setY(b.y());
if (m_earlyBend)
{
b.setY(c.y());
}
else
{
c.setY(b.y());
}
}
else if (
(it == 3 && b.x() < c.x()) || (io == 3 && b.x() > c.x()) ||
+2 -2
View File
@@ -38,7 +38,7 @@ public:
void setOnFront(bool front);
void setOnBack(bool back);
void setHorizontalIn(bool horizontal);
void setEarlyBend(bool earlyBend);
protected:
QPolygon getPath() const;
@@ -54,7 +54,7 @@ protected:
bool m_onFront;
bool m_onBack;
bool m_horizontalIn;
bool m_earlyBend;
Route m_route;
Pivot m_pivot;
@@ -37,8 +37,6 @@ QtGraphEdge::QtGraphEdge(
, m_target(target)
, m_child(nullptr)
, m_isActive(isActive)
, m_fromActive(false)
, m_toActive(false)
, m_isFocused(false)
, m_weight(weight)
, m_direction(direction)
@@ -55,9 +53,6 @@ QtGraphEdge::QtGraphEdge(
m_target = temp;
}
m_fromActive = m_owner->getIsActive();
m_toActive = m_target->getIsActive();
s_focusedEdge = nullptr;
s_focusedBezierEdge = nullptr;
}
@@ -99,6 +94,12 @@ void QtGraphEdge::updateLine()
Edge::EdgeType type = (getData() ? getData()->getType() : Edge::EDGE_AGGREGATION);
GraphViewStyle::EdgeStyle style = GraphViewStyle::getStyleForEdgeType(type, m_isActive | m_isFocused, false, m_isTrailEdge);
Vec4i ownerRect = owner->getBoundingRect();
Vec4i targetRect = target->getBoundingRect();
Vec4i ownerParentRect = owner->getParentBoundingRect();
Vec4i targetParentRect = target->getParentBoundingRect();
if (m_useBezier)
{
for (QGraphicsItem* item : childItems())
@@ -110,9 +111,6 @@ void QtGraphEdge::updateLine()
style.originOffset.y() = 0;
style.targetOffset.y() = 0;
Vec4i ownerRect = owner->getBoundingRect();
Vec4i ownerParentRect = owner->getParentBoundingRect();
QtLineItemBase::Route route =
m_isHorizontalTrail ? QtLineItemBase::ROUTE_HORIZONTAL : QtLineItemBase::ROUTE_VERTICAL;
@@ -140,9 +138,7 @@ void QtGraphEdge::updateLine()
bool showArrow = m_direction != TokenComponentAggregation::DIRECTION_NONE;
QtLineItemBezier* bezier = new QtLineItemBezier(this);
bezier->updateLine(
ownerRect, target->getBoundingRect(), ownerParentRect, target->getParentBoundingRect(),
style, m_weight, showArrow);
bezier->updateLine(ownerRect, targetRect, ownerParentRect, targetParentRect, style, m_weight, showArrow);
bezier->setRoute(route);
bezier->setPivot(QtLineItemBase::PIVOT_MIDDLE);
@@ -167,32 +163,49 @@ void QtGraphEdge::updateLine()
QtLineItemAngled* child = dynamic_cast<QtLineItemAngled*>(m_child);
if (m_fromActive && owner->getLastParent() == target->getLastParent())
if (owner->getIsActive() && owner->getLastParent() == target->getLastParent())
{
child->setOnBack(true);
}
if (m_toActive)
if (target->getIsActive())
{
child->setHorizontalIn(true);
child->setEarlyBend(true);
if (owner->getLastParent() == target->getLastParent())
if (owner->getLastParent() == target->getLastParent() ||
(type == Edge::EDGE_OVERRIDE &&
targetParentRect.z() + style.targetOffset.x + style.originOffset.x > ownerParentRect.x()))
{
child->setOnFront(true);
}
else
{
child->setOnFront(false);
}
}
if (type != Edge::EDGE_INHERITANCE &&
(type != Edge::EDGE_AGGREGATION || owner != owner->getLastParent() || target != target->getLastParent()))
if (type == Edge::EDGE_INHERITANCE)
{
child->setRoute(QtLineItemBase::ROUTE_VERTICAL);
if (target->hasActiveChild())
{
child->setEarlyBend(true);
}
}
else if (type != Edge::EDGE_AGGREGATION || owner != owner->getLastParent() || target != target->getLastParent())
{
child->setRoute(QtLineItemBase::ROUTE_HORIZONTAL);
}
if (type == Edge::EDGE_AGGREGATION || type == Edge::EDGE_INHERITANCE)
{
child->setPivot(QtLineItemBase::PIVOT_MIDDLE);
}
bool showArrow = true;
if (type == Edge::EDGE_AGGREGATION)
{
child->setPivot(QtLineItemBase::PIVOT_MIDDLE);
showArrow = m_direction != TokenComponentAggregation::DIRECTION_NONE;
}
@@ -205,10 +218,7 @@ void QtGraphEdge::updateLine()
}
}
child->updateLine(
owner->getBoundingRect(), target->getBoundingRect(),
owner->getParentBoundingRect(), target->getParentBoundingRect(),
style, m_weight, showArrow);
child->updateLine(ownerRect, targetRect, ownerParentRect, targetParentRect, style, m_weight, showArrow);
}
this->setZValue(style.zValue);
@@ -41,7 +41,6 @@ public:
bool getIsActive() const;
void setIsActive(bool isActive);
void setFromAndToActive(bool fromActive, bool toActive);
void setIsFocused(bool isFocused);
@@ -81,9 +80,6 @@ private:
QGraphicsItem* m_child;
bool m_isActive;
bool m_fromActive;
bool m_toActive;
bool m_isFocused;
size_t m_weight;
@@ -182,6 +182,24 @@ void QtGraphNode::setMultipleActive(bool multipleActive)
m_multipleActive = multipleActive;
}
bool QtGraphNode::hasActiveChild() const
{
if (m_isActive)
{
return true;
}
for (auto subNode : m_subNodes)
{
if (subNode->hasActiveChild())
{
return true;
}
}
return false;
}
std::wstring QtGraphNode::getName() const
{
return m_text->text().toStdWString();
@@ -63,6 +63,7 @@ public:
bool getIsActive() const;
void setIsActive(bool isActive);
void setMultipleActive(bool multipleActive);
bool hasActiveChild() const;
std::wstring getName() const;
void setName(const std::wstring& name);