diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp
index 80529d80d..6fa8ddaa8 100644
--- a/apps/opencs/view/render/instancemode.cpp
+++ b/apps/opencs/view/render/instancemode.cpp
@@ -27,8 +27,8 @@ int CSVRender::InstanceMode::getSubModeFromId (const std::string& id) const
CSVRender::InstanceMode::InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent)
: EditMode (worldspaceWidget, QIcon (":placeholder"), Mask_Reference, "Instance editing",
- parent), mSubMode (0), mSelectionMode (0), mDragMode (DragMode_None), mDragAxis (-1),
- mLocked (false)
+ parent), mSubMode (0), mSubModeId ("move"), mSelectionMode (0), mDragMode (DragMode_None),
+ mDragAxis (-1), mLocked (false)
{
}
@@ -51,6 +51,8 @@ void CSVRender::InstanceMode::activate (CSVWidget::SceneToolbar *toolbar)
""
"Not implemented yet");
+ mSubMode->setButton (mSubModeId);
+
connect (mSubMode, SIGNAL (modeChanged (const std::string&)),
this, SLOT (subModeChanged (const std::string&)));
}
@@ -454,6 +456,7 @@ int CSVRender::InstanceMode::getSubMode() const
void CSVRender::InstanceMode::subModeChanged (const std::string& id)
{
+ mSubModeId = id;
getWorldspaceWidget().abortDrag();
getWorldspaceWidget().setSubMode (getSubModeFromId (id), Mask_Reference);
}
diff --git a/apps/opencs/view/render/instancemode.hpp b/apps/opencs/view/render/instancemode.hpp
index 20b685916..db7fdaa96 100644
--- a/apps/opencs/view/render/instancemode.hpp
+++ b/apps/opencs/view/render/instancemode.hpp
@@ -23,6 +23,7 @@ namespace CSVRender
};
CSVWidget::SceneToolMode *mSubMode;
+ std::string mSubModeId;
InstanceSelectionMode *mSelectionMode;
DragMode mDragMode;
int mDragAxis;
diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp
index 08e8ad5a4..c91890c69 100644
--- a/apps/opencs/view/widget/scenetoolmode.cpp
+++ b/apps/opencs/view/widget/scenetoolmode.cpp
@@ -38,6 +38,27 @@ void CSVWidget::SceneToolMode::adjustToolTip (const ModeButton *activeMode)
setToolTip (toolTip);
}
+void CSVWidget::SceneToolMode::setButton (std::map::iterator iter)
+{
+ for (std::map::const_iterator iter2 = mButtons.begin();
+ iter2!=mButtons.end(); ++iter2)
+ iter2->first->setChecked (iter2==iter);
+
+ setIcon (iter->first->icon());
+ adjustToolTip (iter->first);
+
+ if (mCurrent!=iter->first)
+ {
+ if (mCurrent)
+ mCurrent->deactivate (mToolbar);
+
+ mCurrent = iter->first;
+ mCurrent->activate (mToolbar);
+ }
+
+ emit modeChanged (iter->second);
+}
+
CSVWidget::SceneToolMode::SceneToolMode (SceneToolbar *parent, const QString& toolTip)
: SceneTool (parent), mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize()),
mToolTip (toolTip), mFirst (0), mCurrent (0), mToolbar (parent)
@@ -101,9 +122,20 @@ std::string CSVWidget::SceneToolMode::getCurrentId() const
return mButtons.find (mCurrent)->second;
}
+void CSVWidget::SceneToolMode::setButton (const std::string& id)
+{
+ for (std::map::iterator iter = mButtons.begin();
+ iter!=mButtons.end(); ++iter)
+ if (iter->second==id)
+ {
+ setButton (iter);
+ break;
+ }
+}
+
void CSVWidget::SceneToolMode::selected()
{
- std::map::const_iterator iter =
+ std::map::iterator iter =
mButtons.find (dynamic_cast (sender()));
if (iter!=mButtons.end())
@@ -111,22 +143,6 @@ void CSVWidget::SceneToolMode::selected()
if (!iter->first->hasKeepOpen())
mPanel->hide();
- for (std::map::const_iterator iter2 = mButtons.begin();
- iter2!=mButtons.end(); ++iter2)
- iter2->first->setChecked (iter2==iter);
-
- setIcon (iter->first->icon());
- adjustToolTip (iter->first);
-
- if (mCurrent!=iter->first)
- {
- if (mCurrent)
- mCurrent->deactivate (mToolbar);
-
- mCurrent = iter->first;
- mCurrent->activate (mToolbar);
- }
-
- emit modeChanged (iter->second);
+ setButton (iter);
}
}
diff --git a/apps/opencs/view/widget/scenetoolmode.hpp b/apps/opencs/view/widget/scenetoolmode.hpp
index c274d84ab..192b3ee78 100644
--- a/apps/opencs/view/widget/scenetoolmode.hpp
+++ b/apps/opencs/view/widget/scenetoolmode.hpp
@@ -41,6 +41,8 @@ namespace CSVWidget
/// items to be added, the function must return true anyway.
virtual bool createContextMenu (QMenu *menu);
+ void setButton (std::map::iterator iter);
+
public:
SceneToolMode (SceneToolbar *parent, const QString& toolTip);
@@ -59,6 +61,9 @@ namespace CSVWidget
/// Must not be called if there aren't any buttons yet.
std::string getCurrentId() const;
+ /// Manually change the current mode
+ void setButton (const std::string& id);
+
signals:
void modeChanged (const std::string& id);