/
GlobalXYWnd.cpp
730 lines (604 loc) · 20.3 KB
/
GlobalXYWnd.cpp
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
#include "GlobalXYWnd.h"
#include "FloatingOrthoView.h"
#include "i18n.h"
#include "ieventmanager.h"
#include "iuimanager.h"
#include "ipreferencesystem.h"
#include "itextstream.h"
#include "registry/registry.h"
#include "module/StaticModule.h"
#include "camera/GlobalCamera.h"
#include "wxutil/MouseButton.h"
#include "tools/BrushCreatorTool.h"
#include "tools/ClipperTool.h"
#include "tools/ZoomTool.h"
#include "tools/CameraAngleTool.h"
#include "tools/CameraMoveTool.h"
#include "tools/MoveViewTool.h"
#include "tools/MeasurementTool.h"
#include <functional>
namespace ui
{
namespace
{
const std::string RKEY_XYVIEW_ROOT = "user/ui/xyview";
const std::string RKEY_CHASE_MOUSE = RKEY_XYVIEW_ROOT + "/chaseMouse";
const std::string RKEY_CHASE_MOUSE_CAP = RKEY_XYVIEW_ROOT + "/chaseMouseCap";
const std::string RKEY_CAMERA_XY_UPDATE = RKEY_XYVIEW_ROOT + "/camXYUpdate";
const std::string RKEY_SHOW_CROSSHAIRS = RKEY_XYVIEW_ROOT + "/showCrossHairs";
const std::string RKEY_SHOW_GRID = RKEY_XYVIEW_ROOT + "/showGrid";
const std::string RKEY_SHOW_SIZE_INFO = RKEY_XYVIEW_ROOT + "/showSizeInfo";
const std::string RKEY_SHOW_ENTITY_ANGLES = RKEY_XYVIEW_ROOT + "/showEntityAngles";
const std::string RKEY_SHOW_ENTITY_NAMES = RKEY_XYVIEW_ROOT + "/showEntityNames";
const std::string RKEY_SHOW_BLOCKS = RKEY_XYVIEW_ROOT + "/showBlocks";
const std::string RKEY_SHOW_COORDINATES = RKEY_XYVIEW_ROOT + "/showCoordinates";
const std::string RKEY_SHOW_OUTLINE = RKEY_XYVIEW_ROOT + "/showOutline";
const std::string RKEY_SHOW_AXES = RKEY_XYVIEW_ROOT + "/showAxes";
const std::string RKEY_SHOW_WORKZONE = RKEY_XYVIEW_ROOT + "/showWorkzone";
const std::string RKEY_DEFAULT_BLOCKSIZE = "user/ui/xyview/defaultBlockSize";
const std::string RKEY_TRANSLATE_CONSTRAINED = "user/ui/xyview/translateConstrained";
const int DEFAULT_CHASE_MOUSE_CAP = 32; // pixels per chase moue timer interval
}
// Constructor
XYWndManager::XYWndManager()
{}
/* greebo: This method restores all xy views from the information stored in the registry.
*
* Note: The window creation code looks very unelegant (in fact it is), but this is required
* to restore the exact position of the windows (at least on my WinXP/GTK2+ system).
*
* The position of the TransientWindow has to be set IMMEDIATELY after creation, before
* any widgets are added to this container. When trying to apply the position restore
* on the fully "fabricated" xyview widget, the position tends to be some 20 pixels below
* the original position. I have no full explanation for this and it is nasty, but the code
* below seems to work.
*/
void XYWndManager::restoreState()
{
xml::NodeList views = GlobalRegistry().findXPath(RKEY_XYVIEW_ROOT + "//views");
if (!views.empty())
{
// Find all <view> tags under the first found <views> tag
xml::NodeList viewList = views[0].getNamedChildren("view");
for (xml::NodeList::const_iterator i = viewList.begin();
i != viewList.end();
++i)
{
// Assemble the XPath for the viewstate
std::string path = RKEY_XYVIEW_ROOT +
"/views/view[@name='" + i->getAttributeValue("name") + "']";
const std::string typeStr = i->getAttributeValue("type");
EViewType type = XY;
if (typeStr == "YZ")
{
type = YZ;
}
else if (typeStr == "XZ")
{
type = XZ;
}
else
{
type = XY;
}
// Create the view and restore the size
XYWndPtr newWnd = createFloatingOrthoView(type);
}
}
else
{
// Create at least one XYView, if no view info is found
rMessage() << "XYWndManager: No xywindow information found in XMLRegistry, creating default view.\n";
// Create a default OrthoView
createFloatingOrthoView(XY);
}
}
void XYWndManager::saveState()
{
// Delete all the current window states from the registry
GlobalRegistry().deleteXPath(RKEY_XYVIEW_ROOT + "//views");
// Create a new node
std::string rootNodePath(RKEY_XYVIEW_ROOT + "/views");
for (XYWndMap::iterator i = _xyWnds.begin(); i != _xyWnds.end(); ++i)
{
// Save each XYView state to the registry
FloatingOrthoViewPtr floatingView = std::dynamic_pointer_cast<FloatingOrthoView>(i->second);
if (floatingView)
{
floatingView->SaveWindowState();
}
}
}
// Free the allocated XYViews from the heap
void XYWndManager::destroyViews()
{
// Discard the whole list
for (XYWndMap::iterator i = _xyWnds.begin(); i != _xyWnds.end(); /* in-loop incr.*/)
{
// Extract the pointer to prevent the destructor from firing
XYWndPtr candidate = i->second;
// Now remove the item from the map, increase the iterator
_xyWnds.erase(i++);
// greebo: Release the shared_ptr, this fires the destructor chain
// which eventually reaches notifyXYWndDestroy(). This is safe at this
// point, because the id is not found in the map anymore, thus
// double-deletions are prevented.
candidate = XYWndPtr();
}
_activeXY = XYWndPtr();
}
void XYWndManager::registerCommands()
{
GlobalCommandSystem().addCommand("NewOrthoView", std::bind(&XYWndManager::createXYFloatingOrthoView, this, std::placeholders::_1));
GlobalCommandSystem().addCommand("NextView", std::bind(&XYWndManager::toggleActiveView, this, std::placeholders::_1));
GlobalCommandSystem().addCommand("ZoomIn", std::bind(&XYWndManager::zoomIn, this, std::placeholders::_1));
GlobalCommandSystem().addCommand("ZoomOut", std::bind(&XYWndManager::zoomOut, this, std::placeholders::_1));
GlobalCommandSystem().addCommand("ViewTop", std::bind(&XYWndManager::setActiveViewXY, this, std::placeholders::_1));
GlobalCommandSystem().addCommand("ViewSide", std::bind(&XYWndManager::setActiveViewXZ, this, std::placeholders::_1));
GlobalCommandSystem().addCommand("ViewFront", std::bind(&XYWndManager::setActiveViewYZ, this, std::placeholders::_1));
GlobalCommandSystem().addCommand("CenterXYViews", std::bind(&XYWndManager::splitViewFocus, this, std::placeholders::_1));
GlobalCommandSystem().addCommand("CenterXYView", std::bind(&XYWndManager::focusActiveView, this, std::placeholders::_1));
GlobalCommandSystem().addCommand("Zoom100", std::bind(&XYWndManager::zoom100, this, std::placeholders::_1));
GlobalEventManager().addRegistryToggle("ToggleCrosshairs", RKEY_SHOW_CROSSHAIRS);
GlobalEventManager().addRegistryToggle("ToggleGrid", RKEY_SHOW_GRID);
GlobalEventManager().addRegistryToggle("ShowAngles", RKEY_SHOW_ENTITY_ANGLES);
GlobalEventManager().addRegistryToggle("ShowNames", RKEY_SHOW_ENTITY_NAMES);
GlobalEventManager().addRegistryToggle("ShowBlocks", RKEY_SHOW_BLOCKS);
GlobalEventManager().addRegistryToggle("ShowCoordinates", RKEY_SHOW_COORDINATES);
GlobalEventManager().addRegistryToggle("ShowWindowOutline", RKEY_SHOW_OUTLINE);
GlobalEventManager().addRegistryToggle("ShowAxes", RKEY_SHOW_AXES);
GlobalEventManager().addRegistryToggle("ShowWorkzone", RKEY_SHOW_WORKZONE);
GlobalEventManager().addRegistryToggle("ToggleShowSizeInfo", RKEY_SHOW_SIZE_INFO);
}
void XYWndManager::constructPreferences()
{
IPreferencePage& page = GlobalPreferenceSystem().getPage(_("Settings/Orthoview"));
page.appendCheckBox(_("View chases Mouse Cursor during Drags"), RKEY_CHASE_MOUSE);
page.appendSlider(_("Maximum Chase Mouse Speed"), RKEY_CHASE_MOUSE_CAP, 0, 512, 1, 16);
page.appendCheckBox(_("Update Views on Camera Movement"), RKEY_CAMERA_XY_UPDATE);
page.appendCheckBox(_("Show Crosshairs"), RKEY_SHOW_CROSSHAIRS);
page.appendCheckBox(_("Show Grid"), RKEY_SHOW_GRID);
page.appendCheckBox(_("Show Size Info"), RKEY_SHOW_SIZE_INFO);
page.appendCheckBox(_("Show Entity Angle Arrow"), RKEY_SHOW_ENTITY_ANGLES);
page.appendCheckBox(_("Show Entity Names"), RKEY_SHOW_ENTITY_NAMES);
page.appendCheckBox(_("Show Blocks"), RKEY_SHOW_BLOCKS);
page.appendCheckBox(_("Show Coordinates"), RKEY_SHOW_COORDINATES);
page.appendCheckBox(_("Show Axes"), RKEY_SHOW_AXES);
page.appendCheckBox(_("Show Window Outline"), RKEY_SHOW_OUTLINE);
page.appendCheckBox(_("Show Workzone"), RKEY_SHOW_WORKZONE);
page.appendCheckBox(_("Translate Manipulator always constrained to Axis"), RKEY_TRANSLATE_CONSTRAINED);
page.appendCheckBox(_("Higher Selection Priority for Entities"), RKEY_HIGHER_ENTITY_PRIORITY);
}
// Load/Reload the values from the registry
void XYWndManager::refreshFromRegistry()
{
_chaseMouse = registry::getValue<bool>(RKEY_CHASE_MOUSE);
_chaseMouseCap = registry::getValue<int>(RKEY_CHASE_MOUSE_CAP, DEFAULT_CHASE_MOUSE_CAP);
_camXYUpdate = registry::getValue<bool>(RKEY_CAMERA_XY_UPDATE);
_showCrossHairs = registry::getValue<bool>(RKEY_SHOW_CROSSHAIRS);
_showGrid = registry::getValue<bool>(RKEY_SHOW_GRID);
_showSizeInfo = registry::getValue<bool>(RKEY_SHOW_SIZE_INFO);
_showBlocks = registry::getValue<bool>(RKEY_SHOW_BLOCKS);
_showCoordinates = registry::getValue<bool>(RKEY_SHOW_COORDINATES);
_showOutline = registry::getValue<bool>(RKEY_SHOW_OUTLINE);
_showAxes = registry::getValue<bool>(RKEY_SHOW_AXES);
_showWorkzone = registry::getValue<bool>(RKEY_SHOW_WORKZONE);
_defaultBlockSize = registry::getValue<int>(RKEY_DEFAULT_BLOCKSIZE);
updateAllViews();
}
bool XYWndManager::chaseMouse() const {
return _chaseMouse;
}
int XYWndManager::chaseMouseCap() const
{
return _chaseMouseCap;
}
bool XYWndManager::camXYUpdate() const {
return _camXYUpdate;
}
bool XYWndManager::showCrossHairs() const {
return _showCrossHairs;
}
bool XYWndManager::showBlocks() const {
return _showBlocks;
}
unsigned int XYWndManager::defaultBlockSize() const {
return _defaultBlockSize;
}
bool XYWndManager::showCoordinates() const {
return _showCoordinates;
}
bool XYWndManager::showOutline() const {
return _showOutline;
}
bool XYWndManager::showAxes() const {
return _showAxes;
}
bool XYWndManager::showWorkzone() const {
return _showWorkzone;
}
bool XYWndManager::showGrid() const {
return _showGrid;
}
bool XYWndManager::showSizeInfo() const {
return _showSizeInfo;
}
void XYWndManager::updateAllViews(bool force)
{
for (const XYWndMap::value_type& i : _xyWnds)
{
if (force)
{
i.second->forceRedraw();
}
else
{
i.second->queueDraw();
}
}
}
void XYWndManager::zoomIn(const cmd::ArgumentList& args) {
if (_activeXY != NULL) {
_activeXY->zoomIn();
}
}
void XYWndManager::zoomOut(const cmd::ArgumentList& args) {
if (_activeXY != NULL) {
_activeXY->zoomOut();
}
}
XYWndPtr XYWndManager::getActiveXY() const {
return _activeXY;
}
void XYWndManager::setOrigin(const Vector3& origin) {
// Cycle through the list of views and set the origin
for (XYWndMap::iterator i = _xyWnds.begin();
i != _xyWnds.end();
++i)
{
i->second->setOrigin(origin);
}
}
Vector3 XYWndManager::getActiveViewOrigin()
{
if (!_activeXY)
{
throw std::runtime_error("No active view found");
}
return _activeXY->getOrigin();
}
IOrthoView& XYWndManager::getActiveView()
{
if (!_activeXY)
{
throw std::runtime_error("No active view found");
}
return *_activeXY;
}
// Return the first view matching the given viewType
IOrthoView& XYWndManager::getViewByType(EViewType viewType)
{
for (auto& pair : _xyWnds)
{
if (pair.second->getViewType() == viewType)
{
return *pair.second;
}
}
throw std::runtime_error("No matching view found");
}
void XYWndManager::setScale(float scale) {
for (XYWndMap::iterator i = _xyWnds.begin();
i != _xyWnds.end();
++i)
{
i->second->setScale(scale);
}
}
void XYWndManager::positionAllViews(const Vector3& origin) {
for (XYWndMap::iterator i = _xyWnds.begin();
i != _xyWnds.end();
++i)
{
i->second->positionView(origin);
}
}
void XYWndManager::positionActiveView(const Vector3& origin) {
if (_activeXY != NULL) {
return _activeXY->positionView(origin);
}
}
EViewType XYWndManager::getActiveViewType() const {
if (_activeXY != NULL) {
return _activeXY->getViewType();
}
// Return at least anything
return XY;
}
void XYWndManager::setActiveViewType(EViewType viewType) {
if (_activeXY != NULL) {
return _activeXY->setViewType(viewType);
}
}
void XYWndManager::toggleActiveView(const cmd::ArgumentList& args) {
if (_activeXY != NULL) {
if (_activeXY->getViewType() == XY) {
_activeXY->setViewType(XZ);
}
else if (_activeXY->getViewType() == XZ) {
_activeXY->setViewType(YZ);
}
else {
_activeXY->setViewType(XY);
}
positionActiveView(getFocusPosition());
}
}
void XYWndManager::setActiveViewXY(const cmd::ArgumentList& args) {
setActiveViewType(XY);
positionActiveView(getFocusPosition());
}
void XYWndManager::setActiveViewXZ(const cmd::ArgumentList& args) {
setActiveViewType(XZ);
positionActiveView(getFocusPosition());
}
void XYWndManager::setActiveViewYZ(const cmd::ArgumentList& args) {
setActiveViewType(YZ);
positionActiveView(getFocusPosition());
}
void XYWndManager::splitViewFocus(const cmd::ArgumentList& args) {
positionAllViews(getFocusPosition());
}
void XYWndManager::zoom100(const cmd::ArgumentList& args) {
setScale(1);
}
void XYWndManager::focusActiveView(const cmd::ArgumentList& args) {
positionActiveView(getFocusPosition());
}
XYWndPtr XYWndManager::getView(EViewType viewType)
{
// Cycle through the list of views and get the one matching the type
for (XYWndMap::iterator i = _xyWnds.begin();
i != _xyWnds.end();
++i)
{
// If the view matches, return the pointer
if (i->second->getViewType() == viewType) {
return i->second;
}
}
return XYWndPtr();
}
// Change the active XYWnd
void XYWndManager::setActiveXY(int index) {
// Notify the currently active XYView that is has been deactivated
if (_activeXY != NULL)
{
_activeXY->setActive(false);
}
// Find the ID in the map and update the active pointer
XYWndMap::const_iterator it = _xyWnds.find(index);
if (it != _xyWnds.end())
{
_activeXY = it->second;
}
else
{
throw std::logic_error(
"Cannot set XYWnd with ID " + string::to_string(index) + " as active, "
+ " ID not found in map."
);
}
// Notify the new active XYView about its activation
if (_activeXY != NULL)
{
_activeXY->setActive(true);
}
}
void XYWndManager::destroyXYWnd(int id)
{
XYWndMap::iterator found = _xyWnds.find(id);
if (found != _xyWnds.end())
{
// Remove the shared_ptr from the map
_xyWnds.erase(found);
}
// Also check if the activeXY is holding a strong reference of the XYWnd
// which prevents destruction - release the shared_ptr
if (_activeXY != NULL && _activeXY->getId() == id)
{
_activeXY.reset();
// Set the activeXY to the next possible XYWnd
if (!_xyWnds.empty())
{
_activeXY = _xyWnds.begin()->second;
_activeXY->setActive(true);
}
}
}
int XYWndManager::getUniqueID() const
{
for (int i = 0; i < INT_MAX; ++i)
{
if (_xyWnds.count(i) == 0)
return i;
}
throw std::runtime_error(
"Cannot create unique ID for ortho view: no more IDs."
);
}
// Create a standard (non-floating) ortho view
XYWndPtr XYWndManager::createEmbeddedOrthoView()
{
// Allocate a new window and add it to the map
int id = getUniqueID();
XYWndPtr newWnd = XYWndPtr(new XYWnd(id, GlobalMainFrame().getWxTopLevelWindow()));
std::pair<XYWndMap::iterator, bool> result = _xyWnds.insert(
XYWndMap::value_type(id, newWnd));
// Ensure that the insertion is successful
assert(result.second == true);
// Tag the new view as active, if there is no active view yet
if (_activeXY == NULL)
{
_activeXY = newWnd;
}
return newWnd;
}
XYWndPtr XYWndManager::createEmbeddedOrthoView(EViewType viewType, wxWindow* parent)
{
// Allocate a new window and add it to the map
int id = getUniqueID();
XYWndPtr newWnd = XYWndPtr(new XYWnd(id, parent));
std::pair<XYWndMap::iterator, bool> result = _xyWnds.insert(
XYWndMap::value_type(id, newWnd));
// Ensure that the insertion is successful
assert(result.second == true);
// Tag the new view as active, if there is no active view yet
if (_activeXY == NULL)
{
_activeXY = newWnd;
}
newWnd->setViewType(viewType);
return newWnd;
}
// Create a new floating ortho view
XYWndPtr XYWndManager::createFloatingOrthoView(EViewType viewType)
{
// Create a new XY view
int uniqueId = getUniqueID();
FloatingOrthoViewPtr newWnd(
new FloatingOrthoView(
uniqueId,
XYWnd::getViewTypeTitle(viewType),
GlobalMainFrame().getWxTopLevelWindow()
)
);
std::pair<XYWndMap::iterator, bool> result = _xyWnds.insert(
XYWndMap::value_type(uniqueId, newWnd));
// Ensure that the insertion is successful
assert(result.second == true);
// Tag the new view as active, if there is no active view yet
if (_activeXY == NULL)
{
_activeXY = newWnd;
}
// Set the viewtype and show the window
newWnd->setViewType(viewType);
newWnd->Show();
return newWnd;
}
// Shortcut method for connecting to a GlobalEventManager command
void XYWndManager::createXYFloatingOrthoView(const cmd::ArgumentList& args)
{
createFloatingOrthoView(XY);
}
/* 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 XYWndManager::getFocusPosition()
{
Vector3 position(0,0,0);
if (GlobalSelectionSystem().countSelected() != 0)
{
position = GlobalSelectionSystem().getCurrentSelectionCenter();
}
else {
CamWndPtr cam = GlobalCamera().getActiveCamWnd();
if (cam != NULL) {
position = cam->getCameraOrigin();
}
}
return position;
}
const std::string& XYWndManager::getName() const
{
static std::string _name(MODULE_ORTHOVIEWMANAGER);
return _name;
}
const StringSet& XYWndManager::getDependencies() const
{
static StringSet _dependencies;
if (_dependencies.empty())
{
_dependencies.insert(MODULE_XMLREGISTRY);
_dependencies.insert(MODULE_EVENTMANAGER);
_dependencies.insert(MODULE_RENDERSYSTEM);
_dependencies.insert(MODULE_PREFERENCESYSTEM);
_dependencies.insert(MODULE_COMMANDSYSTEM);
_dependencies.insert(MODULE_UIMANAGER);
_dependencies.insert(MODULE_MOUSETOOLMANAGER);
}
return _dependencies;
}
void XYWndManager::observeKey(const std::string& key)
{
GlobalRegistry().signalForKey(key).connect(
sigc::mem_fun(this, &XYWndManager::refreshFromRegistry)
);
}
void XYWndManager::initialiseModule(const ApplicationContext& ctx)
{
rMessage() << getName() << "::initialiseModule called." << std::endl;
// Connect self to the according registry keys
observeKey(RKEY_CHASE_MOUSE);
observeKey(RKEY_CHASE_MOUSE_CAP);
observeKey(RKEY_CAMERA_XY_UPDATE);
observeKey(RKEY_SHOW_CROSSHAIRS);
observeKey(RKEY_SHOW_GRID);
observeKey(RKEY_SHOW_SIZE_INFO);
observeKey(RKEY_SHOW_ENTITY_ANGLES);
observeKey(RKEY_SHOW_ENTITY_NAMES);
observeKey(RKEY_SHOW_BLOCKS);
observeKey(RKEY_SHOW_COORDINATES);
observeKey(RKEY_SHOW_OUTLINE);
observeKey(RKEY_SHOW_AXES);
observeKey(RKEY_SHOW_WORKZONE);
observeKey(RKEY_DEFAULT_BLOCKSIZE);
// Trigger loading the values of the observed registry keys
refreshFromRegistry();
// Construct the preference settings widgets
constructPreferences();
// Add the commands to the EventManager
registerCommands();
GlobalUIManager().getStatusBarManager().addTextElement(
"XYZPos",
"", // no icon
IStatusBarManager::POS_POSITION,
_("Shows the mouse position in the orthoview")
);
XYWnd::captureStates();
// Add default XY tools
IMouseToolGroup& toolGroup = GlobalMouseToolManager().getGroup(IMouseToolGroup::Type::OrthoView);
toolGroup.registerMouseTool(std::make_shared<BrushCreatorTool>());
toolGroup.registerMouseTool(std::make_shared<ClipperTool>());
toolGroup.registerMouseTool(std::make_shared<ZoomTool>());
toolGroup.registerMouseTool(std::make_shared<CameraAngleTool>());
toolGroup.registerMouseTool(std::make_shared<CameraMoveTool>());
toolGroup.registerMouseTool(std::make_shared<MoveViewTool>());
toolGroup.registerMouseTool(std::make_shared<MeasurementTool>());
}
void XYWndManager::shutdownModule()
{
// Release all owned XYWndPtrs
destroyViews();
XYWnd::releaseStates();
}
MouseToolStack XYWndManager::getMouseToolsForEvent(wxMouseEvent& ev)
{
unsigned int state = wxutil::MouseButton::GetButtonStateChangeForMouseEvent(ev);
return GlobalMouseToolManager().getMouseToolsForEvent(IMouseToolGroup::Type::OrthoView, state);
}
void XYWndManager::foreachMouseTool(const std::function<void(const MouseToolPtr&)>& func)
{
GlobalMouseToolManager().getGroup(IMouseToolGroup::Type::OrthoView).foreachMouseTool(func);
}
// Define the static GlobalXYWnd module
module::StaticModule<XYWndManager> xyWndModule;
} // namespace
// Accessor function returning the reference
ui::XYWndManager& GlobalXYWnd()
{
return *std::static_pointer_cast<ui::XYWndManager>(
module::GlobalModuleRegistry().getModule(MODULE_ORTHOVIEWMANAGER));
}