ui: Remove virtual nodes in depth graph edges when moving nodes (issue #639)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
);
|
||||
|
||||
@@ -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 ------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user