/
ManipulatorToggle.h
70 lines (56 loc) · 2.04 KB
/
ManipulatorToggle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#include "iselection.h"
#include "ui/ieventmanager.h"
#include "iclipper.h"
#include <sigc++/connection.h>
namespace ui
{
// Adaptor class connecting the EventSystem toggles covering the
// various SelectionSystem manipulator mode to the actual state
// of the backend RadiantSelectionSystem.
class ManipulatorToggle
{
private:
sigc::connection _activeManipulatorChanged;
public:
ManipulatorToggle()
{
_activeManipulatorChanged = GlobalSelectionSystem().signal_activeManipulatorChanged()
.connect(sigc::mem_fun(this, &ManipulatorToggle::onActiveManipulatorChanged));
GlobalEventManager().addToggle("ToggleClipper", [this](bool)
{
GlobalCommandSystem().executeCommand("ToggleManipulatorMode", { "Clip" });
});
GlobalEventManager().addToggle("MouseTranslate", [this](bool)
{
GlobalCommandSystem().executeCommand("ToggleManipulatorMode", { "Translate" });
});
GlobalEventManager().addToggle("MouseRotate", [this](bool)
{
GlobalCommandSystem().executeCommand("ToggleManipulatorMode", { "Rotate" });
});
GlobalEventManager().addToggle("MouseDrag", [this](bool)
{
GlobalCommandSystem().executeCommand("ToggleManipulatorMode", { "Drag" });
});
GlobalEventManager().addToggle("ToggleModelScaleManipulator", [this](bool)
{
GlobalCommandSystem().executeCommand("ToggleManipulatorMode", { "ModelScale" });
});
onActiveManipulatorChanged(GlobalSelectionSystem().getActiveManipulatorType());
}
~ManipulatorToggle()
{
_activeManipulatorChanged.disconnect();
}
private:
void onActiveManipulatorChanged(selection::IManipulator::Type type)
{
GlobalEventManager().setToggled("ToggleClipper", GlobalClipper().clipMode());
GlobalEventManager().setToggled("MouseTranslate", type == selection::IManipulator::Translate);
GlobalEventManager().setToggled("MouseRotate", type == selection::IManipulator::Rotate);
GlobalEventManager().setToggled("MouseDrag", type == selection::IManipulator::Drag);
GlobalEventManager().setToggled("ToggleModelScaleManipulator", type == selection::IManipulator::ModelScale);
}
};
}