Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Scene2DViewport/MeasureTool.h @ 1571:85e117739eca
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 21 Sep 2020 17:46:39 +0200 |
parents | 244ad1e4e76a |
children | 92fca2b3ba3d |
comparison
equal
deleted
inserted
replaced
1570:9a04f42098a3 | 1571:85e117739eca |
---|---|
38 class IFlexiblePointerTracker; | 38 class IFlexiblePointerTracker; |
39 class MeasureToolMemento; | 39 class MeasureToolMemento; |
40 | 40 |
41 class MeasureTool : public ObserverBase<MeasureTool> | 41 class MeasureTool : public ObserverBase<MeasureTool> |
42 { | 42 { |
43 private: | |
44 bool enabled_; | |
45 | |
43 public: | 46 public: |
44 virtual ~MeasureTool() | 47 virtual ~MeasureTool() |
45 { | 48 { |
46 } | 49 } |
47 | 50 |
48 /** | 51 /** |
49 Enabled tools are rendered in the scene. | 52 Enabled tools are rendered in the scene. |
50 */ | 53 */ |
51 void Enable(); | 54 void Enable(); |
52 | 55 |
53 /** | 56 /** |
54 Disabled tools are not rendered in the scene. This is useful to be able | 57 Disabled tools are not rendered in the scene. This is useful to be able |
55 to use them as their own memento in command stacks (when a measure tool | 58 to use them as their own memento in command stacks (when a measure tool |
56 creation command has been undone, the measure remains alive in the | 59 creation command has been undone, the measure remains alive in the |
57 command object but is disabled so that it can be redone later on easily) | 60 command object but is disabled so that it can be redone later on easily) |
58 */ | 61 */ |
59 void Disable(); | 62 void Disable(); |
60 | 63 |
61 /** | 64 /** |
62 This method is called when the scene transform changes. It allows to | 65 This method is called when the scene transform changes. It allows to |
63 recompute the visual elements whose content depend upon the scene transform | 66 recompute the visual elements whose content depend upon the scene transform |
64 */ | 67 */ |
65 void OnSceneTransformChanged( | 68 void OnSceneTransformChanged( |
66 const ViewportController::SceneTransformChanged& message); | 69 const ViewportController::SceneTransformChanged& message); |
67 | 70 |
68 /** | 71 /** |
69 This function must be implemented by the measuring tool to return whether | 72 This function must be implemented by the measuring tool to return whether |
70 a given point in scene coords is close to the measuring tool. | 73 a given point in scene coords is close to the measuring tool. |
71 | 74 |
72 This is used for mouse hover highlighting. | 75 This is used for mouse hover highlighting. |
73 | 76 |
74 It is assumed that if the pointer position leads to this function returning | 77 It is assumed that if the pointer position leads to this function returning |
75 true, then a click at that position will return a tracker to edit the | 78 true, then a click at that position will return a tracker to edit the |
76 measuring tool | 79 measuring tool |
77 */ | 80 */ |
78 virtual bool HitTest(ScenePoint2D p) = 0; | 81 virtual bool HitTest(ScenePoint2D p) = 0; |
79 | 82 |
80 /** | 83 /** |
81 This method must return a memento the captures the tool state (not including | 84 This method must return a memento the captures the tool state (not including |
82 the highlighting state | 85 the highlighting state |
83 */ | 86 */ |
84 virtual boost::shared_ptr<MeasureToolMemento> GetMemento() const = 0; | 87 virtual boost::shared_ptr<MeasureToolMemento> GetMemento() const = 0; |
85 | 88 |
86 /** | 89 /** |
87 This method must apply the supplied memento (this requires RTTI to check | 90 This method must apply the supplied memento (this requires RTTI to check |
88 the type) | 91 the type) |
89 */ | 92 */ |
90 virtual void SetMemento(boost::shared_ptr<MeasureToolMemento>) = 0; | 93 virtual void SetMemento(boost::shared_ptr<MeasureToolMemento>) = 0; |
91 | 94 |
92 /** | 95 /** |
93 This must create an edition tracker suitable for the supplied click position, | 96 This must create an edition tracker suitable for the supplied click position, |
94 or an empty pointer if no hit test (although this should have been checked | 97 or an empty pointer if no hit test (although this should have been checked |
95 first) | 98 first) |
96 */ | 99 */ |
97 virtual boost::shared_ptr<IFlexiblePointerTracker> CreateEditionTracker(const PointerEvent& e) = 0; | 100 virtual boost::shared_ptr<IFlexiblePointerTracker> CreateEditionTracker(const PointerEvent& e) = 0; |
98 | 101 |
99 /** | 102 /** |
100 Will change the measuring tool to provide visual feedback on the GUI | 103 Will change the measuring tool to provide visual feedback on the GUI |
101 element that is in the pointer hit zone | 104 element that is in the pointer hit zone |
102 */ | 105 */ |
103 virtual void Highlight(ScenePoint2D p) = 0; | 106 virtual void Highlight(ScenePoint2D p) = 0; |
104 | 107 |
105 /** | 108 /** |
106 This function must reset the visual highlighted hot zone feedback | 109 This function must reset the visual highlighted hot zone feedback |
107 */ | 110 */ |
108 virtual void ResetHighlightState() = 0; | 111 virtual void ResetHighlightState() = 0; |
109 | 112 |
110 /** | 113 /** |
111 A description of the measuring tool, useful in debug logs | 114 A description of the measuring tool, useful in debug logs |
112 */ | 115 */ |
113 virtual std::string GetDescription() = 0; | 116 virtual std::string GetDescription() = 0; |
114 | 117 |
115 protected: | 118 protected: |
116 MeasureTool(boost::shared_ptr<IViewport> viewport); | 119 explicit MeasureTool(boost::shared_ptr<IViewport> viewport); |
117 | 120 |
118 void PostConstructor(); | 121 void PostConstructor(); |
119 | 122 |
120 /** | 123 /** |
121 The measuring tool may exist in a standalone fashion, without any available | 124 The measuring tool may exist in a standalone fashion, without any available |
122 scene (because the controller is dead or dying). This call allows to check | 125 scene (because the controller is dead or dying). This call allows to check |
123 before accessing the scene. | 126 before accessing the scene. |
124 */ | 127 */ |
125 bool IsSceneAlive() const; | 128 bool IsSceneAlive() const; |
126 | 129 |
127 /** | 130 /** |
128 This is the meat of the tool: this method must [create (if needed) and] | 131 This is the meat of the tool: this method must [create (if needed) and] |
129 update the layers and their data according to the measure tool kind and | 132 update the layers and their data according to the measure tool kind and |
130 current state. This is repeatedly called during user interaction | 133 current state. This is repeatedly called during user interaction |
131 */ | 134 */ |
132 virtual void RefreshScene() = 0; | 135 virtual void RefreshScene() = 0; |
133 | 136 |
134 /** | 137 /** |
135 enabled_ is not accessible by subclasses because there is a state machine | 138 enabled_ is not accessible by subclasses because there is a state machine |
136 that we do not wanna mess with | 139 that we do not wanna mess with |
137 */ | 140 */ |
138 bool IsEnabled() const; | 141 bool IsEnabled() const; |
139 | 142 |
140 /** | 143 /** |
141 Protected to allow sub-classes to use this weak pointer in factory methods | 144 Protected to allow sub-classes to use this weak pointer in factory methods |
142 (pass them to created objects) | 145 (pass them to created objects) |
143 */ | 146 */ |
144 boost::shared_ptr<IViewport> viewport_; | 147 boost::shared_ptr<IViewport> viewport_; |
145 | |
146 | |
147 private: | |
148 bool enabled_; | |
149 }; | 148 }; |
150 | 149 |
151 class MeasureToolMemento | 150 class MeasureToolMemento |
152 { | 151 { |
153 public: | 152 public: |
154 virtual ~MeasureToolMemento() {}; | 153 virtual ~MeasureToolMemento() |
154 { | |
155 } | |
155 }; | 156 }; |
156 | 157 |
157 } | 158 } |
158 | 159 |
159 //extern void TrackerSample_SetInfoDisplayMessage( | 160 //extern void TrackerSample_SetInfoDisplayMessage( |
160 // std::string key, std::string value); | 161 // std::string key, std::string value); |