changeset 1213:86a8266b8888 broker

moving the scene from IViewport to ViewportController
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Dec 2019 17:54:10 +0100
parents ab06dfdf3b75
children 741201eab130
files Framework/Scene2DViewport/AngleMeasureTool.cpp Framework/Scene2DViewport/CreateAngleMeasureTracker.cpp Framework/Scene2DViewport/CreateLineMeasureTracker.cpp Framework/Scene2DViewport/EditAngleMeasureTracker.cpp Framework/Scene2DViewport/EditLineMeasureTracker.cpp Framework/Scene2DViewport/LayerHolder.cpp Framework/Scene2DViewport/LineMeasureTool.cpp Framework/Scene2DViewport/MeasureTrackers.cpp Framework/Scene2DViewport/ViewportController.cpp Framework/Scene2DViewport/ViewportController.h Framework/Viewport/IViewport.h Framework/Viewport/SdlViewport.cpp Framework/Viewport/SdlViewport.h Framework/Viewport/ViewportBase.cpp Framework/Viewport/ViewportBase.h
diffstat 15 files changed, 71 insertions(+), 116 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Scene2DViewport/AngleMeasureTool.cpp	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Scene2DViewport/AngleMeasureTool.cpp	Wed Dec 04 17:54:10 2019 +0100
@@ -131,10 +131,8 @@
 
   AngleMeasureTool::AngleHighlightArea AngleMeasureTool::AngleHitTest(ScenePoint2D p) const
   {
-    std::auto_ptr<IViewport::ILock> lock(GetController()->GetViewport().Lock());
-    
-    const double pixelToScene =
-      lock->GetScene().GetCanvasToSceneTransform().ComputeZoom();
+    const double pixelToScene = GetController()->GetScene().GetCanvasToSceneTransform().ComputeZoom();
+
     const double SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD = pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD * pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD;
 
     {
@@ -178,10 +176,8 @@
 
   boost::shared_ptr<IFlexiblePointerTracker> AngleMeasureTool::CreateEditionTracker(const PointerEvent& e)
   {
-    std::auto_ptr<IViewport::ILock> lock(GetController()->GetViewport().Lock());
-    
     ScenePoint2D scenePos = e.GetMainPosition().Apply(
-      lock->GetScene().GetCanvasToSceneTransform());
+      GetController()->GetScene().GetCanvasToSceneTransform());
 
     if (!HitTest(scenePos))
       return boost::shared_ptr<IFlexiblePointerTracker>();
@@ -212,8 +208,6 @@
       boost::shared_ptr<ViewportController> controller = GetController();
       if (IsEnabled())
       {
-        std::auto_ptr<IViewport::ILock> lock(GetController()->GetViewport().Lock());
-    
         layerHolder_->CreateLayersIfNeeded();
 
         {
@@ -254,7 +248,7 @@
               {
                 PolylineSceneLayer::Chain chain;
                 //TODO: take DPI into account
-                AddSquare(chain, lock->GetScene(), side1End_, 
+                AddSquare(chain, controller->GetScene(), side1End_, 
                           GetController()->GetHandleSideLengthS());
               
                 if (angleHighlightArea_ == AngleHighlightArea_Side1End)
@@ -266,7 +260,7 @@
               {
                 PolylineSceneLayer::Chain chain;
                 //TODO: take DPI into account
-                AddSquare(chain, lock->GetScene(), side2End_, 
+                AddSquare(chain, controller->GetScene(), side2End_, 
                           GetController()->GetHandleSideLengthS());
 
                 if (angleHighlightArea_ == AngleHighlightArea_Side2End)
@@ -317,10 +311,10 @@
 
 #if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1
           SetTextLayerOutlineProperties(
-            lock->GetScene(), layerHolder_, buf, ScenePoint2D(pointX, pointY), 0);
+            controller->GetScene(), layerHolder_, buf, ScenePoint2D(pointX, pointY), 0);
 #else
           SetTextLayerProperties(
-            lock->GetScene(), layerHolder_, buf, ScenePoint2D(pointX, pointY) , 0);
+            controller->GetScene(), layerHolder_, buf, ScenePoint2D(pointX, pointY) , 0);
 #endif
 
 #if 0
--- a/Framework/Scene2DViewport/CreateAngleMeasureTracker.cpp	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Scene2DViewport/CreateAngleMeasureTracker.cpp	Wed Dec 04 17:54:10 2019 +0100
@@ -37,8 +37,7 @@
       boost::shared_ptr<ViewportController> controller = controllerW.lock();
       if (controller)
       {
-        std::auto_ptr<IViewport::ILock> lock(controller->GetViewport().Lock());
-        point = e.GetMainPosition().Apply(lock->GetScene().GetCanvasToSceneTransform());
+        point = e.GetMainPosition().Apply(controller->GetScene().GetCanvasToSceneTransform());
       }
     }
     
@@ -61,9 +60,8 @@
     boost::shared_ptr<ViewportController> controller = controllerW_.lock();
     if (controller)
     {
-      std::auto_ptr<IViewport::ILock> lock(controller->GetViewport().Lock());
       ScenePoint2D scenePos = event.GetMainPosition().Apply(
-        lock->GetScene().GetCanvasToSceneTransform());
+        controller->GetScene().GetCanvasToSceneTransform());
 
       switch (state_)
       {
--- a/Framework/Scene2DViewport/CreateLineMeasureTracker.cpp	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Scene2DViewport/CreateLineMeasureTracker.cpp	Wed Dec 04 17:54:10 2019 +0100
@@ -36,8 +36,7 @@
       boost::shared_ptr<ViewportController> controller = controllerW.lock();
       if (controller)
       {
-        std::auto_ptr<IViewport::ILock> lock(controller->GetViewport().Lock());
-        point = e.GetMainPosition().Apply(lock->GetScene().GetCanvasToSceneTransform());
+        point = e.GetMainPosition().Apply(controller->GetScene().GetCanvasToSceneTransform());
       }
     }
 
@@ -61,9 +60,8 @@
     boost::shared_ptr<ViewportController> controller = controllerW_.lock();
     if (controller)
     {
-      std::auto_ptr<IViewport::ILock> lock(controller->GetViewport().Lock());
       ScenePoint2D scenePos = event.GetMainPosition().Apply(
-        lock->GetScene().GetCanvasToSceneTransform());
+        controller->GetScene().GetCanvasToSceneTransform());
       
       //LOG(TRACE) << "scenePos.GetX() = " << scenePos.GetX() << "     " <<
       //  "scenePos.GetY() = " << scenePos.GetY();
@@ -95,5 +93,4 @@
   {
     return boost::dynamic_pointer_cast<CreateLineMeasureCommand>(command_);
   }
-
 }
--- a/Framework/Scene2DViewport/EditAngleMeasureTracker.cpp	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Scene2DViewport/EditAngleMeasureTracker.cpp	Wed Dec 04 17:54:10 2019 +0100
@@ -36,8 +36,7 @@
     boost::shared_ptr<ViewportController> controller = controllerW_.lock();
     if (controller)
     {
-      std::auto_ptr<IViewport::ILock> lock(controller->GetViewport().Lock());
-      scenePos = e.GetMainPosition().Apply(lock->GetScene().GetCanvasToSceneTransform());
+      scenePos = e.GetMainPosition().Apply(controller->GetScene().GetCanvasToSceneTransform());
     }
 
     modifiedZone_ = dynamic_cast<AngleMeasureTool&>(*measureTool).AngleHitTest(scenePos);
@@ -55,9 +54,8 @@
     boost::shared_ptr<ViewportController> controller = controllerW_.lock();
     if (controller)
     {
-      std::auto_ptr<IViewport::ILock> lock(controller->GetViewport().Lock());
       ScenePoint2D scenePos = e.GetMainPosition().Apply(
-        lock->GetScene().GetCanvasToSceneTransform());
+        controller->GetScene().GetCanvasToSceneTransform());
 
       ScenePoint2D delta = scenePos - GetOriginalClickPosition();
 
--- a/Framework/Scene2DViewport/EditLineMeasureTracker.cpp	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Scene2DViewport/EditLineMeasureTracker.cpp	Wed Dec 04 17:54:10 2019 +0100
@@ -38,8 +38,7 @@
       boost::shared_ptr<ViewportController> controller = controllerW.lock();
       if (controller)
       {
-        std::auto_ptr<IViewport::ILock> lock(controller->GetViewport().Lock());
-        scenePos = e.GetMainPosition().Apply(lock->GetScene().GetCanvasToSceneTransform());
+        scenePos = e.GetMainPosition().Apply(controller->GetScene().GetCanvasToSceneTransform());
       }
     }
 
@@ -58,10 +57,9 @@
     boost::shared_ptr<ViewportController> controller = controllerW_.lock();
     if (controller)
     {
-      std::auto_ptr<IViewport::ILock> lock(controller->GetViewport().Lock());
       ScenePoint2D scenePos = e.GetMainPosition().Apply(
-        lock->GetScene().GetCanvasToSceneTransform());
-
+        controller->GetScene().GetCanvasToSceneTransform());
+      
       ScenePoint2D delta = scenePos - GetOriginalClickPosition();
 
       boost::shared_ptr<LineMeasureToolMemento> memento =
--- a/Framework/Scene2DViewport/LayerHolder.cpp	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Scene2DViewport/LayerHolder.cpp	Wed Dec 04 17:54:10 2019 +0100
@@ -47,22 +47,20 @@
 
     if (controller)
     {
-      std::auto_ptr<IViewport::ILock> lock(controller->GetViewport().Lock());
-    
       assert(baseLayerIndex_ == -1);
 
-      baseLayerIndex_ = lock->GetScene().GetMaxDepth() + 100;
+      baseLayerIndex_ = controller->GetScene().GetMaxDepth() + 100;
 
       for (int i = 0; i < polylineLayerCount_; ++i)
       {
         std::auto_ptr<PolylineSceneLayer> layer(new PolylineSceneLayer());
-        lock->GetScene().SetLayer(baseLayerIndex_ + i, layer.release());
+        controller->GetScene().SetLayer(baseLayerIndex_ + i, layer.release());
       }
 
       for (int i = 0; i < textLayerCount_; ++i)
       {
         std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer());
-        lock->GetScene().SetLayer(
+        controller->GetScene().SetLayer(
           baseLayerIndex_ + polylineLayerCount_ + i,
           layer.release());
       }
@@ -92,12 +90,10 @@
 
     if (controller)
     {
-      std::auto_ptr<IViewport::ILock> lock(controller->GetViewport().Lock());
-    
       for (int i = 0; i < textLayerCount_ + polylineLayerCount_; ++i)
       {
-        ORTHANC_ASSERT(lock->GetScene().HasLayer(baseLayerIndex_ + i), "No layer");
-        lock->GetScene().DeleteLayer(baseLayerIndex_ + i);
+        ORTHANC_ASSERT(controller->GetScene().HasLayer(baseLayerIndex_ + i), "No layer");
+        controller->GetScene().DeleteLayer(baseLayerIndex_ + i);
       }
       baseLayerIndex_ = -1;
     }
@@ -109,13 +105,11 @@
 
     if (controller)
     {
-      std::auto_ptr<IViewport::ILock> lock(controller->GetViewport().Lock());
-
       using namespace Orthanc;
       ORTHANC_ASSERT(baseLayerIndex_ != -1);
-      ORTHANC_ASSERT(lock->GetScene().HasLayer(GetPolylineLayerIndex(index)));
+      ORTHANC_ASSERT(controller->GetScene().HasLayer(GetPolylineLayerIndex(index)));
       ISceneLayer* layer =
-        &(lock->GetScene().GetLayer(GetPolylineLayerIndex(index)));
+        &(controller->GetScene().GetLayer(GetPolylineLayerIndex(index)));
       
       PolylineSceneLayer* concreteLayer =
         dynamic_cast<PolylineSceneLayer*>(layer);
@@ -135,13 +129,11 @@
 
     if (controller)
     {
-      std::auto_ptr<IViewport::ILock> lock(controller->GetViewport().Lock());
-
       using namespace Orthanc;
       ORTHANC_ASSERT(baseLayerIndex_ != -1);
-      ORTHANC_ASSERT(lock->GetScene().HasLayer(GetTextLayerIndex(index)));
+      ORTHANC_ASSERT(controller->GetScene().HasLayer(GetTextLayerIndex(index)));
       ISceneLayer* layer =
-        &(lock->GetScene().GetLayer(GetTextLayerIndex(index)));
+        &(controller->GetScene().GetLayer(GetTextLayerIndex(index)));
       
       TextSceneLayer* concreteLayer =
         dynamic_cast<TextSceneLayer*>(layer);
--- a/Framework/Scene2DViewport/LineMeasureTool.cpp	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Scene2DViewport/LineMeasureTool.cpp	Wed Dec 04 17:54:10 2019 +0100
@@ -108,10 +108,8 @@
 
   LineMeasureTool::LineHighlightArea LineMeasureTool::LineHitTest(ScenePoint2D p) const
   {
-    std::auto_ptr<IViewport::ILock> lock(GetController()->GetViewport().Lock());
-    
     const double pixelToScene =
-      lock->GetScene().GetCanvasToSceneTransform().ComputeZoom();
+      GetController()->GetScene().GetCanvasToSceneTransform().ComputeZoom();
     const double SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD = pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD * pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD;
 
     const double sqDistanceFromStart = ScenePoint2D::SquaredDistancePtPt(p, start_);
@@ -136,10 +134,8 @@
 
   boost::shared_ptr<IFlexiblePointerTracker> LineMeasureTool::CreateEditionTracker(const PointerEvent& e)
   {
-    std::auto_ptr<IViewport::ILock> lock(GetController()->GetViewport().Lock());
-    
     ScenePoint2D scenePos = e.GetMainPosition().Apply(
-      lock->GetScene().GetCanvasToSceneTransform());
+      GetController()->GetScene().GetCanvasToSceneTransform());
 
     if (!HitTest(scenePos))
       return boost::shared_ptr<IFlexiblePointerTracker>();
@@ -180,8 +176,6 @@
     {
       if (IsEnabled())
       {
-        std::auto_ptr<IViewport::ILock> lock(GetController()->GetViewport().Lock());
-    
         layerHolder_->CreateLayersIfNeeded();
 
         {
@@ -216,7 +210,7 @@
                 PolylineSceneLayer::Chain chain;
               
                 //TODO: take DPI into account
-                AddSquare(chain, lock->GetScene(), start_, 
+                AddSquare(chain, GetController()->GetScene(), start_, 
                           GetController()->GetHandleSideLengthS());
               
                 if (lineHighlightArea_ == LineHighlightArea_Start)
@@ -229,7 +223,7 @@
                 PolylineSceneLayer::Chain chain;
               
                 //TODO: take DPI into account
-                AddSquare(chain, lock->GetScene(), end_, 
+                AddSquare(chain, GetController()->GetScene(), end_, 
                           GetController()->GetHandleSideLengthS());
               
                 if (lineHighlightArea_ == LineHighlightArea_End)
@@ -256,10 +250,10 @@
 
 #if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1
           SetTextLayerOutlineProperties(
-            lock->GetScene(), layerHolder_, buf, ScenePoint2D(midX, midY), 0);
+            GetController()->GetScene(), layerHolder_, buf, ScenePoint2D(midX, midY), 0);
 #else
           SetTextLayerProperties(
-            lock->GetScene(), layerHolder_, buf, ScenePoint2D(midX, midY), 0);
+            GetController()->GetScene(), layerHolder_, buf, ScenePoint2D(midX, midY), 0);
 #endif
         }
       }
--- a/Framework/Scene2DViewport/MeasureTrackers.cpp	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Scene2DViewport/MeasureTrackers.cpp	Wed Dec 04 17:54:10 2019 +0100
@@ -62,8 +62,7 @@
 
     if (controller)
     {
-      std::auto_ptr<IViewport::ILock> lock(controller->GetViewport().Lock());
-      originalClickPosition_ = e.GetMainPosition().Apply(lock->GetScene().GetCanvasToSceneTransform());
+      originalClickPosition_ = e.GetMainPosition().Apply(controller->GetScene().GetCanvasToSceneTransform());
     }
   }
 
--- a/Framework/Scene2DViewport/ViewportController.cpp	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Scene2DViewport/ViewportController.cpp	Wed Dec 04 17:54:10 2019 +0100
@@ -169,24 +169,19 @@
 
   OrthancStone::AffineTransform2D ViewportController::GetCanvasToSceneTransform() const
   {
-    std::auto_ptr<IViewport::ILock> lock(viewport_->Lock());
-    return lock->GetScene().GetCanvasToSceneTransform();
+    return scene_.GetCanvasToSceneTransform();
   }
 
   OrthancStone::AffineTransform2D ViewportController::GetSceneToCanvasTransform() const
   {
-    std::auto_ptr<IViewport::ILock> lock(viewport_->Lock());
-    return lock->GetScene().GetSceneToCanvasTransform();
+    return scene_.GetSceneToCanvasTransform();
   }
 
   void ViewportController::SetSceneToCanvasTransform(const AffineTransform2D& transform)
   {
-    {
-      std::auto_ptr<IViewport::ILock> lock(viewport_->Lock());
-      lock->GetScene().SetSceneToCanvasTransform(transform);
-      canvasToSceneFactor_ = lock->GetScene().GetCanvasToSceneTransform().ComputeZoom();
-    }
-    
+    scene_.SetSceneToCanvasTransform(transform);
+
+    canvasToSceneFactor_ = scene_.GetCanvasToSceneTransform().ComputeZoom();
     BroadcastMessage(SceneTransformChanged(*this));
   }
 
@@ -194,10 +189,10 @@
   {
     {
       std::auto_ptr<IViewport::ILock> lock(viewport_->Lock());
-      lock->FitContent();
-      canvasToSceneFactor_ = lock->GetScene().GetCanvasToSceneTransform().ComputeZoom();
+      lock->FitContent(scene_);
     }
 
+    canvasToSceneFactor_ = scene_.GetCanvasToSceneTransform().ComputeZoom();
     BroadcastMessage(SceneTransformChanged(*this));
   }
 
--- a/Framework/Scene2DViewport/ViewportController.h	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Scene2DViewport/ViewportController.h	Wed Dec 04 17:54:10 2019 +0100
@@ -204,6 +204,16 @@
     // Must be expressed in canvas coordinates
     void HandleMouseRelease(const PointerEvent& event);
 
+    const Scene2D& GetScene() const
+    {
+      return scene_;
+    }
+
+    Scene2D& GetScene()
+    {
+      return scene_;
+    }
+
   private:
     double GetCanvasToSceneFactor() const;
 
@@ -211,7 +221,9 @@
     boost::shared_ptr<IViewport>                  viewport_;
     std::vector<boost::shared_ptr<MeasureTool> >  measureTools_;
     boost::shared_ptr<IFlexiblePointerTracker>    activeTracker_;  // TODO - Can't this be a "std::auto_ptr"?
-    
+
+    Scene2D   scene_;
+
     // this is cached
     double  canvasToSceneFactor_;    
   };
--- a/Framework/Viewport/IViewport.h	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Viewport/IViewport.h	Wed Dec 04 17:54:10 2019 +0100
@@ -47,8 +47,6 @@
       {
       }
 
-      virtual Scene2D& GetScene() = 0;
-
       // Get the center of the given pixel, in canvas coordinates
       virtual ScenePoint2D GetPixelCenterCoordinates(int x, int y) = 0;
 
@@ -56,7 +54,7 @@
 
       virtual ICompositor& GetCompositor() = 0;
 
-      virtual void FitContent() = 0;
+      virtual void FitContent(Scene2D& scene) = 0;
     };   
     
     virtual ~IViewport()
@@ -68,7 +66,7 @@
     virtual void Invalidate() = 0;
 
     // Must be invoked from the main (GUI) thread
-    virtual void Paint() = 0;
+    virtual void Paint(const Scene2D& scene) = 0;
 
     virtual void UpdateSize(unsigned int width,
                             unsigned int height) = 0;
--- a/Framework/Viewport/SdlViewport.cpp	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Viewport/SdlViewport.cpp	Wed Dec 04 17:54:10 2019 +0100
@@ -58,10 +58,10 @@
     SendRefreshEvent();
   }
 
-  void SdlOpenGLViewport::Paint()
+  void SdlOpenGLViewport::Paint(const Scene2D& scene)
   {
     boost::mutex::scoped_lock lock(mutex_);
-    compositor_->Refresh(GetScene());
+    compositor_->Refresh(scene);
   }
 
 
@@ -83,15 +83,12 @@
     }
   }
   
-  void SdlCairoViewport::InvalidateInternal()  // Assumes that the mutex is locked
-  {
-    compositor_.Refresh(GetScene());
-    CreateSdlSurfaceFromCompositor();
-  }
-
-  void SdlCairoViewport::Paint()
+  void SdlCairoViewport::Paint(const Scene2D& scene)
   {
     boost::mutex::scoped_lock lock(mutex_);
+
+    compositor_.Refresh(scene);
+    CreateSdlSurfaceFromCompositor();
     
     if (sdlSurface_ != NULL)
     {
@@ -101,20 +98,18 @@
 
   void SdlCairoViewport::Invalidate()
   {
-    {
-      boost::mutex::scoped_lock lock(mutex_);
-      InvalidateInternal();
-    }
-
     SendRefreshEvent();
   }
 
   void SdlCairoViewport::UpdateSize(unsigned int width,
                                     unsigned int height)
   {
-    boost::mutex::scoped_lock lock(mutex_);
-    compositor_.UpdateSize(width, height);
-    InvalidateInternal();
+    {
+      boost::mutex::scoped_lock lock(mutex_);
+      compositor_.UpdateSize(width, height);
+    }
+
+    Invalidate();
   }
   
   void SdlCairoViewport::CreateSdlSurfaceFromCompositor()  // Assumes that the mutex is locked
--- a/Framework/Viewport/SdlViewport.h	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Viewport/SdlViewport.h	Wed Dec 04 17:54:10 2019 +0100
@@ -108,7 +108,7 @@
 
     virtual void Invalidate() ORTHANC_OVERRIDE;
 
-    virtual void Paint() ORTHANC_OVERRIDE;
+    virtual void Paint(const Scene2D& scene) ORTHANC_OVERRIDE;
 
     virtual ILock* Lock() ORTHANC_OVERRIDE
     {
@@ -161,8 +161,6 @@
     CairoCompositor   compositor_;
     SDL_Surface*      sdlSurface_;
 
-    void InvalidateInternal();
-    
     void CreateSdlSurfaceFromCompositor();
 
   public:
@@ -175,7 +173,7 @@
 
     virtual void Invalidate() ORTHANC_OVERRIDE;
 
-    virtual void Paint() ORTHANC_OVERRIDE;
+    virtual void Paint(const Scene2D& scene) ORTHANC_OVERRIDE;
 
     virtual ILock* Lock() ORTHANC_OVERRIDE
     {
--- a/Framework/Viewport/ViewportBase.cpp	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Viewport/ViewportBase.cpp	Wed Dec 04 17:54:10 2019 +0100
@@ -42,12 +42,12 @@
   }
 
 
-  void ViewportBase::LockBase::FitContent()
+  void ViewportBase::LockBase::FitContent(Scene2D& scene)
   {
     if (HasCompositor())
     {
       ICompositor& compositor = GetCompositor();
-      GetScene().FitContent(compositor.GetCanvasWidth(), compositor.GetCanvasHeight());
+      scene.FitContent(compositor.GetCanvasWidth(), compositor.GetCanvasHeight());
     }
   }
 }
--- a/Framework/Viewport/ViewportBase.h	Wed Dec 04 16:54:24 2019 +0100
+++ b/Framework/Viewport/ViewportBase.h	Wed Dec 04 17:54:10 2019 +0100
@@ -28,9 +28,6 @@
 {
   class ViewportBase : public IViewport
   {
-  private:
-    Scene2D  scene_;
-
   protected:
     class LockBase : public ILock
     {
@@ -43,19 +40,9 @@
       {
       }
 
-      virtual Scene2D& GetScene() ORTHANC_OVERRIDE
-      {
-        return that_.scene_;
-      }
-
       virtual ScenePoint2D GetPixelCenterCoordinates(int x, int y) ORTHANC_OVERRIDE;
 
-      virtual void FitContent() ORTHANC_OVERRIDE;
+      virtual void FitContent(Scene2D& scene) ORTHANC_OVERRIDE;
     };
-
-    Scene2D& GetScene()
-    {
-      return scene_;
-    }
   };
 }