Mercurial > hg > orthanc-stone
comparison Framework/Scene2DViewport/ViewportController.cpp @ 1215:9efa66d8d3f8 broker
removed ViewportBase, and removed dependency of ViewportController on IViewport
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 04 Dec 2019 20:12:15 +0100 |
parents | 741201eab130 |
children | 5147277850cf |
comparison
equal
deleted
inserted
replaced
1214:741201eab130 | 1215:9efa66d8d3f8 |
---|---|
32 | 32 |
33 namespace OrthancStone | 33 namespace OrthancStone |
34 { | 34 { |
35 IFlexiblePointerTracker* DefaultViewportInteractor::CreateTracker( | 35 IFlexiblePointerTracker* DefaultViewportInteractor::CreateTracker( |
36 boost::shared_ptr<ViewportController> controller, | 36 boost::shared_ptr<ViewportController> controller, |
37 IViewport& viewport, | 37 const PointerEvent& event, |
38 const PointerEvent& event) | 38 unsigned int viewportWidth, |
39 unsigned int viewportHeight) | |
39 { | 40 { |
40 switch (event.GetMouseButton()) | 41 switch (event.GetMouseButton()) |
41 { | 42 { |
42 case MouseButton_Left: | 43 case MouseButton_Left: |
43 return new RotateSceneTracker(controller, event); | 44 return new RotateSceneTracker(controller, event); |
45 case MouseButton_Middle: | 46 case MouseButton_Middle: |
46 return new PanSceneTracker(controller, event); | 47 return new PanSceneTracker(controller, event); |
47 | 48 |
48 case MouseButton_Right: | 49 case MouseButton_Right: |
49 { | 50 { |
50 std::auto_ptr<IViewport::ILock> lock(viewport.Lock()); | 51 if (viewportWidth != 0) |
51 if (lock->HasCompositor()) | |
52 { | 52 { |
53 return new ZoomSceneTracker(controller, event, lock->GetCompositor().GetCanvasWidth()); | 53 return new ZoomSceneTracker(controller, event, viewportWidth); |
54 } | 54 } |
55 else | 55 else |
56 { | 56 { |
57 return NULL; | 57 return NULL; |
58 } | 58 } |
179 | 179 |
180 canvasToSceneFactor_ = scene_.GetCanvasToSceneTransform().ComputeZoom(); | 180 canvasToSceneFactor_ = scene_.GetCanvasToSceneTransform().ComputeZoom(); |
181 BroadcastMessage(SceneTransformChanged(*this)); | 181 BroadcastMessage(SceneTransformChanged(*this)); |
182 } | 182 } |
183 | 183 |
184 void ViewportController::FitContent(IViewport& viewport) | 184 void ViewportController::FitContent(unsigned int viewportWidth, |
185 { | 185 unsigned int viewportHeight) |
186 { | 186 { |
187 std::auto_ptr<IViewport::ILock> lock(viewport.Lock()); | 187 scene_.FitContent(viewportWidth, viewportHeight); |
188 lock->FitContent(scene_); | |
189 } | |
190 | |
191 canvasToSceneFactor_ = scene_.GetCanvasToSceneTransform().ComputeZoom(); | 188 canvasToSceneFactor_ = scene_.GetCanvasToSceneTransform().ComputeZoom(); |
192 BroadcastMessage(SceneTransformChanged(*this)); | 189 BroadcastMessage(SceneTransformChanged(*this)); |
193 } | 190 } |
194 | 191 |
195 void ViewportController::AddMeasureTool(boost::shared_ptr<MeasureTool> measureTool) | 192 void ViewportController::AddMeasureTool(boost::shared_ptr<MeasureTool> measureTool) |
232 { | 229 { |
233 return TEXT_CENTER_DISTANCE_CANVAS_COORD * GetCanvasToSceneFactor(); | 230 return TEXT_CENTER_DISTANCE_CANVAS_COORD * GetCanvasToSceneFactor(); |
234 } | 231 } |
235 | 232 |
236 | 233 |
237 void ViewportController::HandleMousePress(IViewport& viewport, | 234 void ViewportController::HandleMousePress(OrthancStone::IViewportInteractor& interactor, |
238 IViewportInteractor& interactor, | 235 const PointerEvent& event, |
239 const PointerEvent& event) | 236 unsigned int viewportWidth, |
237 unsigned int viewportHeight) | |
240 { | 238 { |
241 if (activeTracker_) | 239 if (activeTracker_) |
242 { | 240 { |
243 // We are dealing with a multi-stage tracker (that is made of several interactions) | 241 // We are dealing with a multi-stage tracker (that is made of several interactions) |
244 activeTracker_->PointerDown(event); | 242 activeTracker_->PointerDown(event); |
259 return; | 257 return; |
260 } | 258 } |
261 } | 259 } |
262 | 260 |
263 // No measure tool, create new tracker from the interactor | 261 // No measure tool, create new tracker from the interactor |
264 activeTracker_.reset(interactor.CreateTracker(shared_from_this(), viewport, event)); | 262 activeTracker_.reset(interactor.CreateTracker(shared_from_this(), event, viewportWidth, viewportHeight)); |
265 } | 263 } |
266 } | 264 } |
267 | 265 |
268 void ViewportController::HandleMouseMove(const PointerEvent& event) | 266 void ViewportController::HandleMouseMove(const PointerEvent& event) |
269 { | 267 { |