diff 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
line wrap: on
line diff
--- a/Framework/Scene2DViewport/ViewportController.cpp	Wed Dec 04 19:12:08 2019 +0100
+++ b/Framework/Scene2DViewport/ViewportController.cpp	Wed Dec 04 20:12:15 2019 +0100
@@ -34,8 +34,9 @@
 {
   IFlexiblePointerTracker* DefaultViewportInteractor::CreateTracker(
     boost::shared_ptr<ViewportController> controller,
-    IViewport& viewport,
-    const PointerEvent& event)
+    const PointerEvent& event,
+    unsigned int viewportWidth,
+    unsigned int viewportHeight)
   {
     switch (event.GetMouseButton())
     {
@@ -47,10 +48,9 @@
       
       case MouseButton_Right:
       {
-        std::auto_ptr<IViewport::ILock> lock(viewport.Lock());
-        if (lock->HasCompositor())
+        if (viewportWidth != 0)
         {
-          return new ZoomSceneTracker(controller, event, lock->GetCompositor().GetCanvasWidth());
+          return new ZoomSceneTracker(controller, event, viewportWidth);
         }
         else
         {
@@ -181,13 +181,10 @@
     BroadcastMessage(SceneTransformChanged(*this));
   }
 
-  void ViewportController::FitContent(IViewport& viewport)
+  void ViewportController::FitContent(unsigned int viewportWidth,
+                                      unsigned int viewportHeight)
   {
-    {
-      std::auto_ptr<IViewport::ILock> lock(viewport.Lock());
-      lock->FitContent(scene_);
-    }
-
+    scene_.FitContent(viewportWidth, viewportHeight);
     canvasToSceneFactor_ = scene_.GetCanvasToSceneTransform().ComputeZoom();
     BroadcastMessage(SceneTransformChanged(*this));
   }
@@ -234,9 +231,10 @@
   }
 
 
-  void ViewportController::HandleMousePress(IViewport& viewport,
-                                            IViewportInteractor& interactor,
-                                            const PointerEvent& event)
+  void ViewportController::HandleMousePress(OrthancStone::IViewportInteractor& interactor,
+                                            const PointerEvent& event,
+                                            unsigned int viewportWidth,
+                                            unsigned int viewportHeight)
   {
     if (activeTracker_)
     {
@@ -261,7 +259,7 @@
       }
 
       // No measure tool, create new tracker from the interactor
-      activeTracker_.reset(interactor.CreateTracker(shared_from_this(), viewport, event));
+      activeTracker_.reset(interactor.CreateTracker(shared_from_this(), event, viewportWidth, viewportHeight));
     }
   }