Mercurial > hg > orthanc-stone
comparison Framework/Scene2DViewport/AngleMeasureTool.cpp @ 866:c71ef52602a0 toa2019062501
Added the ability to edit existing measuring tools (demo not updated yet)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 25 Jun 2019 17:54:46 +0200 |
parents | a29c13497557 |
children | 0aff28f15ea2 |
comparison
equal
deleted
inserted
replaced
865:a29c13497557 | 866:c71ef52602a0 |
---|---|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | 19 **/ |
20 | 20 |
21 #include "AngleMeasureTool.h" | 21 #include "AngleMeasureTool.h" |
22 #include "MeasureToolsToolbox.h" | 22 #include "MeasureToolsToolbox.h" |
23 #include "EditAngleMeasureTracker.h" | |
23 #include "LayerHolder.h" | 24 #include "LayerHolder.h" |
24 | 25 |
25 #include <Core/Logging.h> | 26 #include <Core/Logging.h> |
26 | 27 |
27 #include <boost/math/constants/constants.hpp> | 28 #include <boost/math/constants/constants.hpp> |
88 void AngleMeasureTool::ResetHighlightState() | 89 void AngleMeasureTool::ResetHighlightState() |
89 { | 90 { |
90 SetAngleHighlightArea(AngleHighlightArea_None); | 91 SetAngleHighlightArea(AngleHighlightArea_None); |
91 } | 92 } |
92 | 93 |
94 | |
95 boost::shared_ptr<OrthancStone::MeasureToolMemento> AngleMeasureTool::GetMemento() const | |
96 { | |
97 boost::shared_ptr<AngleMeasureToolMemento> memento(new AngleMeasureToolMemento()); | |
98 memento->center_ = center_; | |
99 memento->side1End_ = side1End_; | |
100 memento->side2End_ = side2End_; | |
101 return memento; | |
102 } | |
103 | |
104 void AngleMeasureTool::SetMemento(boost::shared_ptr<MeasureToolMemento> mementoBase) | |
105 { | |
106 boost::shared_ptr<AngleMeasureToolMemento> memento = boost::dynamic_pointer_cast<AngleMeasureToolMemento>(mementoBase); | |
107 ORTHANC_ASSERT(memento.get() != NULL, "Internal error: wrong (or bad) memento"); | |
108 center_ = memento->center_; | |
109 side1End_ = memento->side1End_; | |
110 side2End_ = memento->side2End_; | |
111 RefreshScene(); | |
112 } | |
113 | |
93 void AngleMeasureTool::Highlight(ScenePoint2D p) | 114 void AngleMeasureTool::Highlight(ScenePoint2D p) |
94 { | 115 { |
95 AngleHighlightArea angleHighlightArea = AngleHitTest(p); | 116 AngleHighlightArea angleHighlightArea = AngleHitTest(p); |
96 SetAngleHighlightArea(angleHighlightArea); | 117 SetAngleHighlightArea(angleHighlightArea); |
97 } | 118 } |
136 } | 157 } |
137 | 158 |
138 bool AngleMeasureTool::HitTest(ScenePoint2D p) const | 159 bool AngleMeasureTool::HitTest(ScenePoint2D p) const |
139 { | 160 { |
140 return AngleHitTest(p) != AngleHighlightArea_None; | 161 return AngleHitTest(p) != AngleHighlightArea_None; |
162 } | |
163 | |
164 | |
165 boost::shared_ptr<IFlexiblePointerTracker> AngleMeasureTool::CreateEditionTracker(const PointerEvent& e) | |
166 { | |
167 ScenePoint2D scenePos = e.GetMainPosition().Apply( | |
168 GetScene()->GetCanvasToSceneTransform()); | |
169 | |
170 if (!HitTest(scenePos)) | |
171 return boost::shared_ptr<IFlexiblePointerTracker>(); | |
172 | |
173 /** | |
174 new EditLineMeasureTracker( | |
175 boost::shared_ptr<LineMeasureTool> measureTool; | |
176 MessageBroker & broker, | |
177 boost::weak_ptr<ViewportController> controllerW, | |
178 const PointerEvent & e); | |
179 */ | |
180 boost::shared_ptr<EditAngleMeasureTracker> editAngleMeasureTracker( | |
181 new EditAngleMeasureTracker(shared_from_this(), GetBroker(), GetController(), e)); | |
182 return editAngleMeasureTracker; | |
141 } | 183 } |
142 | 184 |
143 void AngleMeasureTool::SetCenter(ScenePoint2D pt) | 185 void AngleMeasureTool::SetCenter(ScenePoint2D pt) |
144 { | 186 { |
145 center_ = pt; | 187 center_ = pt; |