ui: Improved horizontal graph layout

* extend horizontal edges to origin column width
* leave horizontal gap in the middle of the left and right buckets for routing edges
* move left and right buckets vertically so that edges enter and leave horizontally
* removed third pivoting for graph edges, all edges enter and leave relative to the node center now
This commit is contained in:
Eberhard Graether
2018-04-10 01:45:56 +02:00
parent 535f7c1a9c
commit 20f87b084f
10 changed files with 194 additions and 68 deletions
@@ -133,7 +133,6 @@ void QtGraphEdge::updateLine()
QtLineItemBezier* bezier = new QtLineItemBezier(this);
bezier->updateLine(ownerRect, rect, ownerParentRect, rect, style, m_weight, false);
bezier->setRoute(route);
bezier->setPivot(QtLineItemBase::PIVOT_MIDDLE);
QtLineItemStraight* line = new QtLineItemStraight(this);
if (route == QtLineItemBase::ROUTE_HORIZONTAL)
@@ -154,7 +153,6 @@ void QtGraphEdge::updateLine()
QtLineItemBezier* bezier = new QtLineItemBezier(this);
bezier->updateLine(ownerRect, targetRect, ownerParentRect, targetParentRect, style, m_weight, showArrow);
bezier->setRoute(route);
bezier->setPivot(QtLineItemBase::PIVOT_MIDDLE);
if (ownerNonGroupParent == targetNonGroupParent)
{
@@ -170,6 +168,11 @@ void QtGraphEdge::updateLine()
}
else
{
const Vec2i& ownerColumnSize = m_owner->getLastParent()->getColumnSize();
const Vec2i& targetColumnSize = m_target->getLastParent()->getColumnSize();
ownerParentRect.z = std::max(ownerParentRect.x + ownerColumnSize.x, ownerParentRect.z());
targetParentRect.z = std::max(targetParentRect.x + targetColumnSize.x, targetParentRect.z());
if (!m_child)
{
m_child = new QtLineItemAngled(this);
@@ -214,11 +217,6 @@ void QtGraphEdge::updateLine()
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)
{
@@ -109,6 +109,7 @@ bool QtGraphNode::setPosition(const Vec2i& position)
if (offset.x != 0 || offset.y != 0)
{
this->moveBy(offset.x, offset.y);
setColumnSize(Vec2i());
notifyEdgesAfterMove();
return true;
}
@@ -116,7 +117,7 @@ bool QtGraphNode::setPosition(const Vec2i& position)
return false;
}
Vec2i QtGraphNode::getSize() const
const Vec2i& QtGraphNode::getSize() const
{
return m_size;
}
@@ -130,6 +131,16 @@ void QtGraphNode::setSize(const Vec2i& size)
m_undefinedRect->setRect(1, 1, size.x - 2, size.y - 2);
}
const Vec2i& QtGraphNode::getColumnSize() const
{
return m_columnSize;
}
void QtGraphNode::setColumnSize(const Vec2i& size)
{
m_columnSize = size;
}
QSize QtGraphNode::size() const
{
return QSize(m_size.x, m_size.y);
@@ -46,9 +46,12 @@ public:
Vec2i getPosition() const;
virtual bool setPosition(const Vec2i& position);
Vec2i getSize() const;
const Vec2i& getSize() const;
void setSize(const Vec2i& size);
const Vec2i& getColumnSize() const;
void setColumnSize(const Vec2i& size);
QSize size() const;
void setSize(const QSize& size);
@@ -124,6 +127,7 @@ protected:
QGraphicsPixmapItem* m_icon = nullptr;
Vec2i m_size;
Vec2i m_columnSize;
bool m_isActive = false;
bool m_multipleActive = false;