changeset 1210:644baa70373d broker

removing interactor from the ViewportController members
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Dec 2019 16:13:10 +0100
parents 00e6bff9ea39
children d10d2acb8a02
files Framework/Scene2DViewport/ViewportController.cpp Framework/Scene2DViewport/ViewportController.h
diffstat 2 files changed, 5 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Scene2DViewport/ViewportController.cpp	Tue Dec 03 18:51:03 2019 +0100
+++ b/Framework/Scene2DViewport/ViewportController.cpp	Wed Dec 04 16:13:10 2019 +0100
@@ -72,20 +72,12 @@
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
     }
-
-    interactor_.reset(new DefaultViewportInteractor);
   }
  
   ViewportController::~ViewportController()
   {
   }
 
-  void ViewportController::SetInteractor(boost::shared_ptr<IViewportInteractor> interactor)
-  {
-    activeTracker_.reset();
-    interactor_ = interactor;
-  }
-
   void ViewportController::PushCommand(boost::shared_ptr<MeasureCommand> command)
   {
     boost::shared_ptr<UndoStack> undoStack = undoStackW_.lock();
@@ -251,7 +243,8 @@
   }
 
 
-  void ViewportController::HandleMousePress(const PointerEvent& event)
+  void ViewportController::HandleMousePress(IViewportInteractor& interactor,
+                                            const PointerEvent& event)
   {
     if (activeTracker_)
     {
@@ -276,14 +269,7 @@
       }
 
       // No measure tool, create new tracker from the interactor
-      if (interactor_)
-      {
-        activeTracker_.reset(interactor_->CreateTracker(shared_from_this(), event));
-      }
-      else
-      {
-        activeTracker_.reset();
-      }
+      activeTracker_.reset(interactor.CreateTracker(shared_from_this(), event));
     }
   }
 
--- a/Framework/Scene2DViewport/ViewportController.h	Tue Dec 03 18:51:03 2019 +0100
+++ b/Framework/Scene2DViewport/ViewportController.h	Wed Dec 04 16:13:10 2019 +0100
@@ -109,8 +109,6 @@
 
     ~ViewportController();
 
-    void SetInteractor(boost::shared_ptr<IViewportInteractor> interactor);
-
     /**
     This method returns the list of measure tools containing the supplied point
     (in scene coords). A tracker can then be requested from the chosen 
@@ -197,7 +195,8 @@
 
 
     // Must be expressed in canvas coordinates
-    void HandleMousePress(const PointerEvent& event);
+    void HandleMousePress(IViewportInteractor& interactor,
+                          const PointerEvent& event);
 
     // Must be expressed in canvas coordinates
     void HandleMouseMove(const PointerEvent& event);
@@ -210,7 +209,6 @@
 
     boost::weak_ptr<UndoStack>                    undoStackW_;  // Global stack, possibly shared by all viewports
     boost::shared_ptr<IViewport>                  viewport_;
-    boost::shared_ptr<IViewportInteractor>        interactor_;   // Application-specific factory of trackers
     std::vector<boost::shared_ptr<MeasureTool> >  measureTools_;
     boost::shared_ptr<IFlexiblePointerTracker>    activeTracker_;  // TODO - Can't this be a "std::auto_ptr"?