From 1240e0c716fee64a072affaabaad3a42c84037e8 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 4 Mar 2016 15:19:26 +0100 Subject: [PATCH] cancel instance move on drag abort --- apps/opencs/view/render/cell.cpp | 8 ++++++++ apps/opencs/view/render/cell.hpp | 4 ++++ apps/opencs/view/render/instancemode.cpp | 6 ++++++ apps/opencs/view/render/instancemode.hpp | 4 ++++ apps/opencs/view/render/object.cpp | 7 +++++++ apps/opencs/view/render/object.hpp | 4 ++++ apps/opencs/view/render/pagedworldspacewidget.cpp | 7 +++++++ apps/opencs/view/render/pagedworldspacewidget.hpp | 3 +++ apps/opencs/view/render/unpagedworldspacewidget.cpp | 5 +++++ apps/opencs/view/render/unpagedworldspacewidget.hpp | 3 +++ apps/opencs/view/render/worldspacewidget.hpp | 3 +++ 11 files changed, 54 insertions(+) diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index 6e47d3594..782a37796 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -376,3 +376,11 @@ void CSVRender::Cell::setSubMode (int subMode, unsigned int elementMask) iter!=mObjects.end(); ++iter) iter->second->setSubMode (subMode); } + +void CSVRender::Cell::reset (unsigned int elementMask) +{ + if (elementMask & Mask_Reference) + for (std::map::const_iterator iter (mObjects.begin()); + iter!=mObjects.end(); ++iter) + iter->second->reset(); +} diff --git a/apps/opencs/view/render/cell.hpp b/apps/opencs/view/render/cell.hpp index 21949992d..4af5e4a25 100644 --- a/apps/opencs/view/render/cell.hpp +++ b/apps/opencs/view/render/cell.hpp @@ -122,6 +122,10 @@ namespace CSVRender std::vector > getEdited (unsigned int elementMask) const; void setSubMode (int subMode, unsigned int elementMask); + + /// Erase all overrides and restore the visual representation of the cell to its + /// true state. + void reset (unsigned int elementMask); }; } diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp index 91923e004..332753811 100644 --- a/apps/opencs/view/render/instancemode.cpp +++ b/apps/opencs/view/render/instancemode.cpp @@ -259,6 +259,12 @@ void CSVRender::InstanceMode::dragCompleted() mDragMode = DragMode_None; } +void CSVRender::InstanceMode::dragAborted() +{ + getWorldspaceWidget().reset (Mask_Reference); + mDragMode = DragMode_None; +} + void CSVRender::InstanceMode::dragWheel (int diff, double speedFactor) { if (mDragMode==DragMode_Move) diff --git a/apps/opencs/view/render/instancemode.hpp b/apps/opencs/view/render/instancemode.hpp index 5a744ea88..94bdbb08f 100644 --- a/apps/opencs/view/render/instancemode.hpp +++ b/apps/opencs/view/render/instancemode.hpp @@ -53,6 +53,10 @@ namespace CSVRender virtual void dragCompleted(); + /// \note dragAborted will not be called, if the drag is aborted via changing + /// editing mode + virtual void dragAborted(); + virtual void dragWheel (int diff, double speedFactor); virtual void dragEnterEvent (QDragEnterEvent *event); diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index 1771acdf9..6ca751ba5 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -574,3 +574,10 @@ void CSVRender::Object::setSubMode (int subMode) updateMarker(); } } + +void CSVRender::Object::reset() +{ + mOverrideFlags = 0; + adjustTransform(); + updateMarker(); +} diff --git a/apps/opencs/view/render/object.hpp b/apps/opencs/view/render/object.hpp index 12cb0c78b..a5cc141a0 100644 --- a/apps/opencs/view/render/object.hpp +++ b/apps/opencs/view/render/object.hpp @@ -175,6 +175,10 @@ namespace CSVRender void apply (QUndoStack& undoStack); void setSubMode (int subMode); + + /// Erase all overrides and restore the visual representation of the object to its + /// true state. + void reset(); }; } diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index 68c8949f3..0ca3ff706 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -582,6 +582,13 @@ void CSVRender::PagedWorldspaceWidget::setSubMode (int subMode, unsigned int ele iter->second->setSubMode (subMode, elementMask); } +void CSVRender::PagedWorldspaceWidget::reset (unsigned int elementMask) +{ + for (std::map::const_iterator iter = mCells.begin(); + iter!=mCells.end(); ++iter) + iter->second->reset (elementMask); +} + CSVWidget::SceneToolToggle *CSVRender::PagedWorldspaceWidget::makeControlVisibilitySelector ( CSVWidget::SceneToolbar *parent) { diff --git a/apps/opencs/view/render/pagedworldspacewidget.hpp b/apps/opencs/view/render/pagedworldspacewidget.hpp index c77c3ebd2..fe533be2d 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.hpp +++ b/apps/opencs/view/render/pagedworldspacewidget.hpp @@ -117,6 +117,9 @@ namespace CSVRender virtual void setSubMode (int subMode, unsigned int elementMask); + /// Erase all overrides and restore the visual representation to its true state. + virtual void reset (unsigned int elementMask); + protected: virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle2 *tool); diff --git a/apps/opencs/view/render/unpagedworldspacewidget.cpp b/apps/opencs/view/render/unpagedworldspacewidget.cpp index 60aeeb4d8..16c28cf93 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.cpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.cpp @@ -142,6 +142,11 @@ void CSVRender::UnpagedWorldspaceWidget::setSubMode (int subMode, unsigned int mCell->setSubMode (subMode, elementMask); } +void CSVRender::UnpagedWorldspaceWidget::reset (unsigned int elementMask) +{ + mCell->reset (elementMask); +} + void CSVRender::UnpagedWorldspaceWidget::referenceableDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) { diff --git a/apps/opencs/view/render/unpagedworldspacewidget.hpp b/apps/opencs/view/render/unpagedworldspacewidget.hpp index a3718d9f3..c5bfd22e6 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.hpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.hpp @@ -65,6 +65,9 @@ namespace CSVRender virtual void setSubMode (int subMode, unsigned int elementMask); + /// Erase all overrides and restore the visual representation to its true state. + virtual void reset (unsigned int elementMask); + private: virtual void referenceableDataChanged (const QModelIndex& topLeft, diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index eee618ed1..55b0f1f55 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -158,6 +158,9 @@ namespace CSVRender virtual void setSubMode (int subMode, unsigned int elementMask) = 0; + /// Erase all overrides and restore the visual representation to its true state. + virtual void reset (unsigned int elementMask) = 0; + protected: /// Visual elements in a scene