From e89b9239a9ab4f2931ec0c4ca6b534de8eef77ca Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Mon, 22 Dec 2014 08:40:28 +0100 Subject: [PATCH] Better backdrop move --- Gui/NodeGraph.cpp | 19 ++++++++++++++----- Gui/NodeGraphUndoRedo.cpp | 5 +++++ Gui/NodeGraphUndoRedo.h | 2 ++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Gui/NodeGraph.cpp b/Gui/NodeGraph.cpp index c28e337382..008e0e06aa 100644 --- a/Gui/NodeGraph.cpp +++ b/Gui/NodeGraph.cpp @@ -291,6 +291,7 @@ struct NodeGraphPrivate bool _knobLinksVisible; double _accumDelta; bool _detailsVisible; + bool _mergeMoveCommands; NodeGraphPrivate(Gui* gui, NodeGraph* p) @@ -336,6 +337,7 @@ struct NodeGraphPrivate , _knobLinksVisible(true) , _accumDelta(0) , _detailsVisible(false) + , _mergeMoveCommands(false) { } @@ -794,7 +796,7 @@ void NodeGraph::mousePressEvent(QMouseEvent* e) { assert(e); - + _imp->_mergeMoveCommands = false; if ( buttonDownIsMiddle(e) ) { _imp->_evtState = MOVING_AREA; @@ -1087,6 +1089,8 @@ NodeGraph::mouseReleaseEvent(QMouseEvent* e) { EVENT_STATE state = _imp->_evtState; + _imp->_nodesWithinBDAtPenDown.clear(); + _imp->_mergeMoveCommands = false; _imp->_firstMove = true; _imp->_evtState = DEFAULT; _imp->_nodesWithinBDAtPenDown.clear(); @@ -1403,11 +1407,16 @@ NodeGraph::mouseMoveEvent(QMouseEvent* e) } mustUpdateNavigator = true; pushUndoCommand( new MoveMultipleNodesCommand(nodesToMove, - _imp->_selection.bds, - newPos.x() - _imp->_lastScenePosClick.x(), - newPos.y() - _imp->_lastScenePosClick.y(),newPos) ); + _imp->_selection.bds, + newPos.x() - _imp->_lastScenePosClick.x(), + newPos.y() - _imp->_lastScenePosClick.y(), + _imp->_mergeMoveCommands, + newPos) ); + if (!_imp->_mergeMoveCommands) { + _imp->_mergeMoveCommands = true; + } } - + if (_imp->_selection.nodes.size() == 1) { ///try to find a nearby edge boost::shared_ptr selectedNode = _imp->_selection.nodes.front(); diff --git a/Gui/NodeGraphUndoRedo.cpp b/Gui/NodeGraphUndoRedo.cpp index 12fda6780c..83715fa563 100644 --- a/Gui/NodeGraphUndoRedo.cpp +++ b/Gui/NodeGraphUndoRedo.cpp @@ -37,6 +37,7 @@ MoveMultipleNodesCommand::MoveMultipleNodesCommand(const std::list & const std::list & bds, double dx, double dy, + bool doMerge, const QPointF & mouseScenePos, QUndoCommand *parent) : QUndoCommand(parent) @@ -46,6 +47,7 @@ MoveMultipleNodesCommand::MoveMultipleNodesCommand(const std::list & , _mouseScenePos(mouseScenePos) , _dx(dx) , _dy(dy) + , _doMerge(doMerge) { assert( !nodes.empty() || !bds.empty() ); } @@ -89,6 +91,9 @@ MoveMultipleNodesCommand::mergeWith(const QUndoCommand *command) if (!mvCmd) { return false; } + if (!mvCmd->_doMerge || !_doMerge) { + return false; + } if ( ( mvCmd->_bds.size() != _bds.size() ) || ( mvCmd->_nodes.size() != _nodes.size() ) ) { return false; } diff --git a/Gui/NodeGraphUndoRedo.h b/Gui/NodeGraphUndoRedo.h index 7efb0c279b..a1e6bb0da6 100644 --- a/Gui/NodeGraphUndoRedo.h +++ b/Gui/NodeGraphUndoRedo.h @@ -50,6 +50,7 @@ class MoveMultipleNodesCommand const std::list & bds, double dx, double dy, + bool doMerge, const QPointF & mouseScenePos, QUndoCommand *parent = 0); virtual void undo(); @@ -70,6 +71,7 @@ class MoveMultipleNodesCommand std::list _bds; QPointF _mouseScenePos; double _dx,_dy; + bool _doMerge; };