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
+1 -7
View File
@@ -10,7 +10,6 @@ QtLineItemBase::QtLineItemBase(QGraphicsItem* parent)
, m_onBack(false)
, m_earlyBend(false)
, m_route(ROUTE_ANY)
, m_pivot(PIVOT_THIRD)
{
this->setAcceptHoverEvents(true);
}
@@ -49,11 +48,6 @@ void QtLineItemBase::setRoute(Route route)
m_route = route;
}
void QtLineItemBase::setPivot(Pivot pivot)
{
m_pivot = pivot;
}
void QtLineItemBase::setOnFront(bool front)
{
m_onFront = front;
@@ -406,7 +400,7 @@ void QtLineItemBase::drawArrow(const QPolygon& poly, QPainterPath* path, QPainte
void QtLineItemBase::getPivotPoints(Vec2f* p, const Vec4i& in, const Vec4i& out, int offset, bool target) const
{
float f = m_pivot == PIVOT_THIRD ? (target ? 2 / 3.f : 1 / 3.f) : 1 / 2.f;
float f = 1 / 2.f;
p[0] = Vec2f(in.x + (in.z - in.x) * f + offset, out.y);
p[2] = Vec2f(in.x + (in.z - in.x) * f + offset, out.w);
-8
View File
@@ -18,12 +18,6 @@ public:
ROUTE_VERTICAL
};
enum Pivot
{
PIVOT_THIRD,
PIVOT_MIDDLE
};
QtLineItemBase(QGraphicsItem* parent);
virtual ~QtLineItemBase();
@@ -34,7 +28,6 @@ public:
size_t weight, bool showArrow);
void setRoute(Route route);
void setPivot(Pivot pivot);
void setOnFront(bool front);
void setOnBack(bool back);
@@ -57,7 +50,6 @@ protected:
bool m_earlyBend;
Route m_route;
Pivot m_pivot;
private:
Vec4i m_ownerRect;
+1
View File
@@ -987,6 +987,7 @@ QtGraphNode* QtGraphView::createNodeRecursive(
newNode->setPosition(node->position);
newNode->setSize(node->size);
newNode->setColumnSize(node->columnSize);
newNode->setIsActive(node->active);
newNode->setMultipleActive(multipleActive);
@@ -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;