diff Framework/Scene2DViewport/MeasureCommands.h @ 700:059e1fd05fd6 refactor-viewport-controller

Introduced the ViewportController that sits between the application and the Scene2D to handle the trackers and measuring tools. This is a work in progress. The Scene2D is no longer an observable. Message sending is managed by the ViewportController. Move some refs to shared and weak to prevent lifetime issues.
author Benjamin Golinvaux <bgo@osimis.io>
date Sun, 19 May 2019 16:26:17 +0200
parents 8b6adfb62a2f
children 28b9e3a54200
line wrap: on
line diff
--- a/Framework/Scene2DViewport/MeasureCommands.h	Fri May 17 09:20:46 2019 +0200
+++ b/Framework/Scene2DViewport/MeasureCommands.h	Sun May 19 16:26:17 2019 +0200
@@ -34,25 +34,23 @@
   class TrackerCommand : public boost::noncopyable
   {
   public:
-    TrackerCommand(Scene2DWPtr sceneW) : scene_(sceneW)
+    TrackerCommand(ViewportControllerWPtr controllerW) 
+      : controllerW_(controllerW)
     {
 
     }
     virtual void Undo() = 0;
     virtual void Redo() = 0;
-    Scene2DPtr GetScene()
-    {
-      return scene_.lock();
-    }
 
   protected:
-    Scene2DWPtr scene_;
+    ViewportControllerWPtr controllerW_;
   };
 
   class CreateMeasureCommand : public TrackerCommand
   {
   public:
-    CreateMeasureCommand(Scene2DWPtr sceneW, MeasureToolList& measureTools);
+    CreateMeasureCommand(
+      ViewportControllerWPtr controllerW, MeasureToolList& measureTools);
     ~CreateMeasureCommand();
     virtual void Undo() ORTHANC_OVERRIDE;
     virtual void Redo() ORTHANC_OVERRIDE;
@@ -62,16 +60,15 @@
     /** Must be implemented by the subclasses that create the actual tool */
     virtual MeasureToolPtr GetMeasureTool() = 0;
   };
-
-
+  
   class CreateLineMeasureCommand : public CreateMeasureCommand
   {
   public:
     CreateLineMeasureCommand(
-      MessageBroker&   broker, 
-      Scene2DWPtr      scene, 
-      MeasureToolList& measureTools, 
-      ScenePoint2D     point);
+      MessageBroker&         broker, 
+      ViewportControllerWPtr controllerW,
+      MeasureToolList&       measureTools, 
+      ScenePoint2D           point);
     
     // the starting position is set in the ctor
     void SetEnd(ScenePoint2D scenePos);
@@ -90,10 +87,10 @@
   public:
     /** Ctor sets end of side 1*/
     CreateAngleMeasureCommand(
-      MessageBroker&   broker, 
-      Scene2DWPtr      scene, 
-      MeasureToolList& measureTools, 
-      ScenePoint2D     point);
+      MessageBroker&         broker, 
+      ViewportControllerWPtr controllerW,
+      MeasureToolList&       measureTools, 
+      ScenePoint2D           point);
 
     /** This method sets center*/
     void SetCenter(ScenePoint2D scenePos);