diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 0e9a49432b..ae4bbd66cf 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -85,7 +85,7 @@ opencs_units (view/widget opencs_units (view/render scenewidget worldspacewidget pagedworldspacewidget unpagedworldspacewidget - previewwidget editmode instancemode + previewwidget editmode instancemode instanceselectionmode ) opencs_units_noqt (view/render diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp index 449d9d7a6f..53ebc70525 100644 --- a/apps/opencs/view/render/instancemode.cpp +++ b/apps/opencs/view/render/instancemode.cpp @@ -16,10 +16,11 @@ #include "object.hpp" #include "worldspacewidget.hpp" #include "pagedworldspacewidget.hpp" +#include "instanceselectionmode.hpp" CSVRender::InstanceMode::InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent) : EditMode (worldspaceWidget, QIcon (":placeholder"), Element_Reference, "Instance editing", - parent), mSubMode (0) + parent), mSubMode (0), mSelectionMode (0) { } @@ -48,16 +49,30 @@ void CSVRender::InstanceMode::activate (CSVWidget::SceneToolbar *toolbar) "Not implemented yet"); } + if (!mSelectionMode) + mSelectionMode = new InstanceSelectionMode (toolbar); + EditMode::activate (toolbar); toolbar->addTool (mSubMode); + toolbar->addTool (mSelectionMode); } void CSVRender::InstanceMode::deactivate (CSVWidget::SceneToolbar *toolbar) { - toolbar->removeTool (mSubMode); - delete mSubMode; - mSubMode = 0; + if (mSelectionMode) + { + toolbar->removeTool (mSelectionMode); + delete mSelectionMode; + mSelectionMode = 0; + } + + if (mSubMode) + { + toolbar->removeTool (mSubMode); + delete mSubMode; + mSubMode = 0; + } EditMode::deactivate (toolbar); } diff --git a/apps/opencs/view/render/instancemode.hpp b/apps/opencs/view/render/instancemode.hpp index 1eec62874d..78836878a4 100644 --- a/apps/opencs/view/render/instancemode.hpp +++ b/apps/opencs/view/render/instancemode.hpp @@ -10,10 +10,13 @@ namespace CSVWidget namespace CSVRender { + class InstanceSelectionMode; + class InstanceMode : public EditMode { Q_OBJECT CSVWidget::SceneToolMode *mSubMode; + InstanceSelectionMode *mSelectionMode; public: diff --git a/apps/opencs/view/render/instanceselectionmode.cpp b/apps/opencs/view/render/instanceselectionmode.cpp new file mode 100644 index 0000000000..9fd8259991 --- /dev/null +++ b/apps/opencs/view/render/instanceselectionmode.cpp @@ -0,0 +1,27 @@ + +#include "instanceselectionmode.hpp" + +CSVRender::InstanceSelectionMode::InstanceSelectionMode (CSVWidget::SceneToolbar *parent) +: CSVWidget::SceneToolMode (parent, "Selection Mode") +{ + addButton (":placeholder", "cube-centre", + "Centred cube" + "