From 8e87b48866e66c1546c7d7f7914f9ab4f7fd015e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 29 Sep 2015 16:07:14 +0200 Subject: [PATCH] handle context-sensitive select mode in instance editing --- apps/opencs/view/render/instancemode.cpp | 23 ++++++++++++++++++++--- apps/opencs/view/render/instancemode.hpp | 6 ++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp index 2e8f8cda2..333d91656 100644 --- a/apps/opencs/view/render/instancemode.cpp +++ b/apps/opencs/view/render/instancemode.cpp @@ -1,25 +1,42 @@ #include "instancemode.hpp" +#include "../../model/settings/usersettings.hpp" + #include "elements.hpp" #include "object.hpp" #include "worldspacewidget.hpp" CSVRender::InstanceMode::InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent) : EditMode (worldspaceWidget, QIcon (":placeholder"), Element_Reference, "Instance editing", - parent) + parent), mContextSelect (false) { } -void CSVRender::InstanceMode::primaryEditPressed (osg::ref_ptr tag) +void CSVRender::InstanceMode::activate (CSVWidget::SceneToolbar *toolbar) { + EditMode::activate (toolbar); + mContextSelect = CSMSettings::UserSettings::instance().setting ("scene-input/context-select")=="true"; } -void CSVRender::InstanceMode::secondaryEditPressed (osg::ref_ptr tag) +void CSVRender::InstanceMode::updateUserSetting (const QString& name, const QStringList& value) +{ + if (name=="scene-input/context-select") + mContextSelect = value.at (0)=="true"; +} + +void CSVRender::InstanceMode::primaryEditPressed (osg::ref_ptr tag) { + if (mContextSelect) + selectPressed (tag); +} +void CSVRender::InstanceMode::secondaryEditPressed (osg::ref_ptr tag) +{ + if (mContextSelect) + selectPressed (tag); } void CSVRender::InstanceMode::selectPressed (osg::ref_ptr tag) diff --git a/apps/opencs/view/render/instancemode.hpp b/apps/opencs/view/render/instancemode.hpp index 6071aedf0..cc4fd5434 100644 --- a/apps/opencs/view/render/instancemode.hpp +++ b/apps/opencs/view/render/instancemode.hpp @@ -9,10 +9,16 @@ namespace CSVRender { Q_OBJECT + bool mContextSelect; + public: InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent = 0); + virtual void activate (CSVWidget::SceneToolbar *toolbar); + + virtual void updateUserSetting (const QString& name, const QStringList& value); + virtual void primaryEditPressed (osg::ref_ptr tag); virtual void secondaryEditPressed (osg::ref_ptr tag);