Mercurial > hg > orthanc-stone
comparison Framework/Scene2DViewport/ViewportController.h @ 774:66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
hit tests for measure tools and mouse hover.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 24 May 2019 15:59:51 +0200 |
parents | c0fcb2757b0a |
children | e42b491f1fb2 |
comparison
equal
deleted
inserted
replaced
761:07adcffba38c | 774:66ac7a2d1e3a |
---|---|
29 #include <stack> | 29 #include <stack> |
30 | 30 |
31 namespace OrthancStone | 31 namespace OrthancStone |
32 { | 32 { |
33 /** | 33 /** |
34 These constats are used | |
35 | |
36 */ | |
37 const double ARC_RADIUS_CANVAS_COORD = 30.0; | |
38 const double TEXT_CENTER_DISTANCE_CANVAS_COORD = 90; | |
39 | |
40 const double HANDLE_SIDE_LENGTH_CANVAS_COORD = 10.0; | |
41 const double HIT_TEST_MAX_DISTANCE_CANVAS_COORD = 15.0; | |
42 | |
43 const uint8_t TEXT_COLOR_RED = 0; | |
44 const uint8_t TEXT_COLOR_GREEN = 223; | |
45 const uint8_t TEXT_COLOR_BLUE = 81; | |
46 | |
47 const uint8_t TOOL_LINES_COLOR_RED = 0; | |
48 const uint8_t TOOL_LINES_COLOR_GREEN = 223; | |
49 const uint8_t TOOL_LINES_COLOR_BLUE = 21; | |
50 | |
51 | |
52 const uint8_t TEXT_OUTLINE_COLOR_RED = 0; | |
53 const uint8_t TEXT_OUTLINE_COLOR_GREEN = 56; | |
54 const uint8_t TEXT_OUTLINE_COLOR_BLUE = 21; | |
55 | |
56 /** | |
34 This object is responsible for hosting a scene, responding to messages from | 57 This object is responsible for hosting a scene, responding to messages from |
35 the model and updating the scene accordingly. | 58 the model and updating the scene accordingly. |
36 | 59 |
37 It contains the list of active measuring tools as well as the stack | 60 It contains the list of active measuring tools as well as the stack |
38 where measuring tool commands are stored. | 61 where measuring tool commands are stored. |
48 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, \ | 71 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, \ |
49 SceneTransformChanged, ViewportController); | 72 SceneTransformChanged, ViewportController); |
50 | 73 |
51 ViewportController(MessageBroker& broker); | 74 ViewportController(MessageBroker& broker); |
52 | 75 |
53 Scene2DPtr GetScene(); | 76 Scene2DConstPtr GetScene() const; |
77 Scene2DPtr GetScene(); | |
54 | 78 |
55 /** | 79 /** |
56 This method is called by the GUI system and should update/delete the | 80 This method is called by the GUI system and should update/delete the |
57 current tracker | 81 current tracker |
58 */ | 82 */ |
117 void AddMeasureTool(MeasureToolPtr measureTool); | 141 void AddMeasureTool(MeasureToolPtr measureTool); |
118 | 142 |
119 /** Removes a measure tool or throws if it cannot be found */ | 143 /** Removes a measure tool or throws if it cannot be found */ |
120 void RemoveMeasureTool(MeasureToolPtr measureTool); | 144 void RemoveMeasureTool(MeasureToolPtr measureTool); |
121 | 145 |
146 /** | |
147 The square handle side length in *scene* coordinates | |
148 */ | |
149 double GetHandleSideLengthS() const; | |
150 | |
151 /** | |
152 The angle measure too arc radius in *scene* coordinates | |
153 | |
154 Note: you might wonder why this is not part of the AngleMeasureTool itself, | |
155 but we prefer to put all such constants in the same location, to ease | |
156 */ | |
157 double GetAngleToolArcRadiusS() const; | |
158 | |
159 /** | |
160 The hit test maximum distance in *scene* coordinates. | |
161 If a pointer event is less than GetHandleSideLengthS() to a GUI element, | |
162 the hit test for this GUI element is seen as true | |
163 */ | |
164 double GetHitTestMaximumDistanceS() const; | |
165 | |
166 /** | |
167 Distance between the top of the angle measuring tool and the center of | |
168 the label showing the actual measure, in *scene* coordinates | |
169 */ | |
170 double GetAngleTopTextLabelDistanceS() const; | |
171 | |
122 private: | 172 private: |
173 double GetCanvasToSceneFactor() const; | |
174 | |
123 std::vector<TrackerCommandPtr> commandStack_; | 175 std::vector<TrackerCommandPtr> commandStack_; |
124 | 176 |
125 /** | 177 /** |
126 This is always between >= 0 and <= undoStack_.size() and gives the | 178 This is always between >= 0 and <= undoStack_.size() and gives the |
127 position where the controller is in the undo stack. | 179 position where the controller is in the undo stack. |
128 - If numAppliedCommands_ > 0, one can undo | 180 - If numAppliedCommands_ > 0, one can undo |
129 - If numAppliedCommands_ < numAppliedCommands_.size(), one can redo | 181 - If numAppliedCommands_ < numAppliedCommands_.size(), one can redo |
130 */ | 182 */ |
131 size_t numAppliedCommands_; | 183 size_t numAppliedCommands_; |
132 std::vector<MeasureToolPtr> measureTools_; | 184 std::vector<MeasureToolPtr> measureTools_; |
133 Scene2DPtr scene_; | 185 Scene2DPtr scene_; |
134 FlexiblePointerTrackerPtr tracker_; | 186 FlexiblePointerTrackerPtr tracker_; |
187 | |
188 // this is cached | |
189 mutable double canvasToSceneFactor_; | |
135 }; | 190 }; |
136 } | 191 } |