Debian Codegraph @

include/iorthoview.h

raw
1 #pragma once
2
3 #include "imodule.h"
4 #include "iinteractiveview.h"
5
6 template<typename Element>
7 class BasicVector3;
8 typedef BasicVector3<double> Vector3;
9
10 constexpr const char* const RKEY_HIGHER_ENTITY_PRIORITY = "user/ui/xyview/higherEntitySelectionPriority";
11
12 // Possible orientations of the orthogonal view window
13 enum class OrthoOrientation
14 {
15 YZ = 0,
16 XZ = 1,
17 XY = 2
18 };
19
20 namespace ui
21 {
22
23 // Common interface used by all orthographic/2D views, i.e. XY/YZ/XZ and Texture Tool
24 class IOrthoViewBase: public IInteractiveView
25 {
26 public:
27 virtual ~IOrthoViewBase() {}
28
29 virtual int getWidth() const = 0;
30 virtual int getHeight() const = 0;
31
32 // Scrolls the view by the specified amount of screen pixels
33 virtual void scrollByPixels(int x, int y) = 0;
34
35 // Increase / decrease zoom factor
36 virtual void zoomIn() = 0;
37 virtual void zoomOut() = 0;
38 };
39
40 /// Interface for a single orthoview window
41 class IOrthoView: public IOrthoViewBase
42 {
43 public:
44 virtual ~IOrthoView() {}
45
46 // The cursor types available on orthoviews
47 enum class CursorType
48 {
49 Pointer,
50 Crosshair,
51 Default = Pointer,
52 };
53
54 virtual const Vector3& getOrigin() const = 0;
55 virtual void setOrigin(const Vector3& origin) = 0;
56
57 // Returns the scale factor of this view
58 virtual float getScale() const = 0;
59
60 // Snaps the given Vector to the XY view's grid
61 // Note that one component of the given vector stays untouched.
62 virtual void snapToGrid(Vector3& point) const = 0;
63
64 /// Get the orientation of this view
65 virtual OrthoOrientation getOrientation() const = 0;
66
67 // Sets the mouse cursor type of this view
68 virtual void setCursorType(CursorType type) = 0;
69 };
70
71 /// Interface for the module which manages all of the ortho/XY views
72 class IOrthoViewManager: public RegisterableModule
73 {
74 public:
75 // Passes a draw call to each allocated view, set force to true
76 // to redraw immediately instead of queueing the draw.
77 virtual void updateAllViews(bool force = false) = 0;
78
79 // Sets the origin of all available views
80 virtual void setOrigin(const Vector3& origin) = 0;
81
82 // Returns the origin of the currently active ortho view
83 // Will throw std::runtime_error if no view is found
84 virtual Vector3 getActiveViewOrigin() = 0;
85
86 // Returns a reference to the currently active view
87 // Will throw std::runtime_error if no view is found
88 virtual IOrthoView& getActiveView() = 0;
89
90 // Return the first view matching the given viewType
91 // Will throw std::runtime_error if no view is found
92 virtual IOrthoView& getViewByType(OrthoOrientation viewType) = 0;
93
94 // Sets the scale of all available views
95 virtual void setScale(float scale) = 0;
96
97 // Positions all available views
98 virtual void positionAllViews(const Vector3& origin) = 0;
99
100 // Positions the active views
101 virtual void positionActiveView(const Vector3& origin) = 0;
102
103 // Returns the view type of the currently active view
104 virtual OrthoOrientation getActiveViewType() const = 0;
105
106 // Sets the viewtype of the active view
107 virtual void setActiveViewType(OrthoOrientation viewType) = 0;
108 };
109
110 } // namespace
111
112 constexpr const char* const MODULE_ORTHOVIEWMANAGER = "OrthoviewManager";
113
114 /// Accessor for the OrthoViewManager module
115 inline ui::IOrthoViewManager& GlobalOrthoViewManager()
116 {
117 static module::InstanceReference<ui::IOrthoViewManager> _reference(MODULE_ORTHOVIEWMANAGER);
118 return _reference;
119 }