/
GlobalXYWnd.h
183 lines (141 loc) · 5.29 KB
/
GlobalXYWnd.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#pragma once
#include <list>
#include <map>
#include "iorthoview.h"
#include "iclipper.h"
#include "iregistry.h"
#include "icommandsystem.h"
#include "imousetoolmanager.h"
#include "XYWnd.h"
class wxMouseEvent;
namespace ui
{
class XYWndManager :
public IXWndManager
{
// Store an indexed map of XYWnds. When one is deleted, it will notify
// the XYWndManager of its index so that it can be removed from the map
typedef std::map<int, XYWndPtr> XYWndMap;
XYWndMap _xyWnds;
// The active XYWnd
XYWndPtr _activeXY;
// True, if the view is moved when the mouse cursor exceeds the view window borders
bool _chaseMouse;
int _chaseMouseCap;
bool _camXYUpdate;
// The various display settings for xyviews
bool _showCrossHairs;
bool _showGrid;
bool _showSizeInfo;
bool _showBlocks;
bool _showCoordinates;
bool _showOutline;
bool _showAxes;
bool _showWorkzone;
unsigned int _defaultBlockSize;
private:
// Get a unique ID for the XYWnd map
int getUniqueID() const;
void observeKey(const std::string&);
void refreshFromRegistry();
public:
// Constructor
XYWndManager();
// Returns the state of the xy view preferences
bool chaseMouse() const;
int chaseMouseCap() const;
bool camXYUpdate() const;
bool showCrossHairs() const;
bool showGrid() const;
bool showBlocks() const;
bool showCoordinates() const;
bool showOutline() const;
bool showAxes() const;
bool showWorkzone() const;
bool showSizeInfo() const;
bool higherEntitySelectionPriority() const;
unsigned int defaultBlockSize() const;
// Passes a draw call to each allocated view, set force to true
// to redraw immediately instead of queueing the draw.
void updateAllViews(bool force = false) override;
// Free all the allocated views from the heap
void destroyViews() override;
// Saves the current state of all open views to the registry
void saveState();
// Restores the xy windows according to the state saved in the XMLRegistry
void restoreState();
XYWndPtr getActiveXY() const;
/**
* Set the given XYWnd to active state.
*
* @param id
* Unique ID of the XYWnd to set as active.
*/
void setActiveXY(int id);
// Shortcut commands for connect view the EventManager
void setActiveViewXY(const cmd::ArgumentList& args); // top view
void setActiveViewXZ(const cmd::ArgumentList& args); // side view
void setActiveViewYZ(const cmd::ArgumentList& args); // front view
void splitViewFocus(const cmd::ArgumentList& args); // Re-position all available views
void zoom100(const cmd::ArgumentList& args); // Sets the scale of all windows to 1
void focusActiveView(const cmd::ArgumentList& args); // sets the focus of the active view
// Sets the origin of all available views
void setOrigin(const Vector3& origin) override;
Vector3 getActiveViewOrigin() override;
// Sets the scale of all available views
void setScale(float scale) override;
// Zooms the currently active view in/out
void zoomIn(const cmd::ArgumentList& args);
void zoomOut(const cmd::ArgumentList& args);
// Positions the view of all available views / the active view
void positionAllViews(const Vector3& origin) override;
void positionActiveView(const Vector3& origin) override;
// Returns the view type of the currently active view
EViewType getActiveViewType() const override;
void setActiveViewType(EViewType viewType) override;
void toggleActiveView(const cmd::ArgumentList& args);
// Retrieves the pointer to the first view matching the given view type
// @returns: NULL if no matching window could be found, the according pointer otherwise
XYWndPtr getView(EViewType viewType);
/**
* Create a non-floating (embedded) ortho view. DEPRECATED
*/
XYWndPtr createEmbeddedOrthoView();
/**
* Create a non-floating (embedded) orthoview of the given type
*/
XYWndPtr createEmbeddedOrthoView(EViewType viewType, wxWindow* parent);
/**
* Create a new floating ortho view, as a child of the main window.
*/
XYWndPtr createFloatingOrthoView(EViewType viewType);
/**
* Parameter-less wrapper for createFloatingOrthoView(), for use by the
* event manager. The default orientation of XY is used.
*/
void createXYFloatingOrthoView(const cmd::ArgumentList& args);
/**
* greebo: This removes a certain orthoview ID, usually initiating
* destruction of the XYWnd/FloatingOrthoView object.
*/
void destroyXYWnd(int id);
MouseToolStack getMouseToolsForEvent(wxMouseEvent& ev);
void foreachMouseTool(const std::function<void(const MouseToolPtr&)>& func);
// RegisterableModule implementation
const std::string& getName() const override;
const StringSet& getDependencies() const override;
void initialiseModule(const ApplicationContext& ctx) override;
void shutdownModule() override;
private:
/* greebo: This function determines the point currently being "looked" at, it is used for toggling the ortho views
* If something is selected the center of the selection is taken as new origin, otherwise the camera
* position is considered to be the new origin of the toggled orthoview. */
Vector3 getFocusPosition();
// Construct the orthoview preference page and add it to the given group
void constructPreferences();
// Registers all the XY commands in the EventManager
void registerCommands();
}; // class XYWndManager
} // namespace
// Use this method to access the global XYWnd manager class
ui::XYWndManager& GlobalXYWnd();