comparison Framework/Scene2DViewport/LineMeasureTool.cpp @ 891:0aff28f15ea2

new abstraction: IViewport
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jul 2019 18:18:42 +0200
parents c71ef52602a0
children 52b1c6ff10c5
comparison
equal deleted inserted replaced
890:77c96ba899f9 891:0aff28f15ea2
95 } 95 }
96 96
97 LineMeasureTool::LineHighlightArea LineMeasureTool::LineHitTest(ScenePoint2D p) const 97 LineMeasureTool::LineHighlightArea LineMeasureTool::LineHitTest(ScenePoint2D p) const
98 { 98 {
99 const double pixelToScene = 99 const double pixelToScene =
100 GetScene()->GetCanvasToSceneTransform().ComputeZoom(); 100 GetController()->GetScene().GetCanvasToSceneTransform().ComputeZoom();
101 const double SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD = pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD * pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD; 101 const double SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD = pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD * pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD;
102 102
103 const double sqDistanceFromStart = ScenePoint2D::SquaredDistancePtPt(p, start_); 103 const double sqDistanceFromStart = ScenePoint2D::SquaredDistancePtPt(p, start_);
104 if (sqDistanceFromStart <= SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD) 104 if (sqDistanceFromStart <= SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD)
105 return LineHighlightArea_Start; 105 return LineHighlightArea_Start;
121 } 121 }
122 122
123 boost::shared_ptr<IFlexiblePointerTracker> LineMeasureTool::CreateEditionTracker(const PointerEvent& e) 123 boost::shared_ptr<IFlexiblePointerTracker> LineMeasureTool::CreateEditionTracker(const PointerEvent& e)
124 { 124 {
125 ScenePoint2D scenePos = e.GetMainPosition().Apply( 125 ScenePoint2D scenePos = e.GetMainPosition().Apply(
126 GetScene()->GetCanvasToSceneTransform()); 126 GetController()->GetScene().GetCanvasToSceneTransform());
127 127
128 if (!HitTest(scenePos)) 128 if (!HitTest(scenePos))
129 return boost::shared_ptr<IFlexiblePointerTracker>(); 129 return boost::shared_ptr<IFlexiblePointerTracker>();
130 130
131 /** 131 /**
194 { 194 {
195 { 195 {
196 PolylineSceneLayer::Chain chain; 196 PolylineSceneLayer::Chain chain;
197 197
198 //TODO: take DPI into account 198 //TODO: take DPI into account
199 AddSquare(chain, GetScene(), start_, 199 AddSquare(chain, GetController()->GetScene(), start_,
200 GetController()->GetHandleSideLengthS()); 200 GetController()->GetHandleSideLengthS());
201 201
202 if (lineHighlightArea_ == LineHighlightArea_Start) 202 if (lineHighlightArea_ == LineHighlightArea_Start)
203 polylineLayer->AddChain(chain, true, highlightColor); 203 polylineLayer->AddChain(chain, true, highlightColor);
204 else 204 else
207 207
208 { 208 {
209 PolylineSceneLayer::Chain chain; 209 PolylineSceneLayer::Chain chain;
210 210
211 //TODO: take DPI into account 211 //TODO: take DPI into account
212 AddSquare(chain, GetScene(), end_, 212 AddSquare(chain, GetController()->GetScene(), end_,
213 GetController()->GetHandleSideLengthS()); 213 GetController()->GetHandleSideLengthS());
214 214
215 if (lineHighlightArea_ == LineHighlightArea_End) 215 if (lineHighlightArea_ == LineHighlightArea_End)
216 polylineLayer->AddChain(chain, true, highlightColor); 216 polylineLayer->AddChain(chain, true, highlightColor);
217 else 217 else
233 // of the measuring segment 233 // of the measuring segment
234 double midX = 0.5 * (end_.GetX() + start_.GetX()); 234 double midX = 0.5 * (end_.GetX() + start_.GetX());
235 double midY = 0.5 * (end_.GetY() + start_.GetY()); 235 double midY = 0.5 * (end_.GetY() + start_.GetY());
236 236
237 SetTextLayerOutlineProperties( 237 SetTextLayerOutlineProperties(
238 GetScene(), layerHolder_, buf, ScenePoint2D(midX, midY)); 238 GetController()->GetScene(), layerHolder_, buf, ScenePoint2D(midX, midY));
239 } 239 }
240 } 240 }
241 else 241 else
242 { 242 {
243 RemoveFromScene(); 243 RemoveFromScene();