ui: Remove virtual nodes in depth graph edges when moving nodes (issue #639)

This commit is contained in:
Eberhard Graether
2019-01-10 16:52:40 +01:00
parent 934131b877
commit 7d94302712
5 changed files with 61 additions and 1 deletions
@@ -516,6 +516,27 @@ void GraphController::handleMessage(MessageGraphNodeMove* message)
{
node->position += message->delta;
if (m_graph->getTrailMode() != Graph::TRAIL_NONE)
{
std::set<Id> childNodeIds;
for (const std::pair<Id, Id>& p : m_topLevelAncestorIds)
{
if (p.second == message->tokenId)
{
childNodeIds.insert(p.first);
}
}
for (std::shared_ptr<DummyEdge> edge : m_dummyEdges)
{
if (childNodeIds.find(edge->ownerId) != childNodeIds.end() ||
childNodeIds.find(edge->targetId) != childNodeIds.end())
{
edge->path.clear();
}
}
}
if (message->isReplayed())
{
buildGraph(message, GraphView::GraphParams());
@@ -492,3 +492,8 @@ void QtGraphEdge::setUseBezier(bool useBezier)
m_useBezier = useBezier;
m_isHorizontal = true;
}
void QtGraphEdge::clearPath()
{
m_path.clear();
}
@@ -58,6 +58,7 @@ public:
void setIsTrailEdge(std::vector<Vec4i> path, bool horizontal);
void setUseBezier(bool useBezier);
void clearPath();
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
@@ -506,6 +506,7 @@ void QtGraphNode::notifyEdgesAfterMove()
forEachEdge(
[](QtGraphEdge* edge)
{
edge->clearPath();
edge->updateLine();
}
);
+33 -1
View File
@@ -151,6 +151,38 @@ void level_5_func()
// END ------------------------------------------------------------------------
// TEST: virtual nodes removed when moving nodes
// START ----------------------------------------------------------------------
namespace virtual_nodes
{
void func1(); // <- ACTION 1: activate
void func2();
void func3();
void func4();
struct Parent
{
static void func5();
};
void func1() { func2(); Parent::func5(); }
void func2() { func3(); }
void func3() { func4(); Parent::func5(); }
void func4() { Parent::func5(); }
void func5() { }
}
// ACTION 2: show callee graph
// ACTION 3: move func5 above node func2
// RESULT 3: virtual nodes are removed from the graph routes
// ACTION 4: activate func4
// ACTION 5: undo
// RESULT 5: the depth graph is restored with the virtual nodes removed
// END ------------------------------------------------------------------------
// TEST: pentagram graph
// START ----------------------------------------------------------------------
@@ -170,7 +202,7 @@ void func4() { func1(); func2(); func3(); func4(); func5(); }
void func5() { func1(); func2(); func3(); func4(); func5(); }
}
// ACTION 2: show caller and calle graph
// ACTION 2: show caller and callee graph
// RESULT 2: layout works without crash
// END ------------------------------------------------------------------------