changeset 721:af0aa0c149fa

FitContent is now wrapped by the controller (for observability)
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 20 May 2019 12:49:29 +0200
parents f2ee003ba955
children 28b9e3a54200
files Framework/Scene2DViewport/ViewportController.cpp Framework/Scene2DViewport/ViewportController.h Samples/Sdl/BasicScene.cpp Samples/Sdl/TrackerSampleApp.cpp
diffstat 4 files changed, 26 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Scene2DViewport/ViewportController.cpp	Mon May 20 12:37:30 2019 +0200
+++ b/Framework/Scene2DViewport/ViewportController.cpp	Mon May 20 12:49:29 2019 +0200
@@ -44,6 +44,19 @@
     throw StoneException(ErrorCode_NotImplemented);
   }
 
+  std::vector<MeasureToolPtr> ViewportController::HitTestMeasureTools(
+    ScenePoint2D p)
+  {
+    std::vector<MeasureToolPtr> ret;
+    
+
+    //for (size_t i = 0; i < measureTools_.size(); ++i)
+    //{
+
+    //}
+    return ret;
+  }
+
   const OrthancStone::AffineTransform2D& ViewportController::GetCanvasToSceneTransform() const
   {
     return scene_->GetCanvasToSceneTransform();
@@ -61,5 +74,12 @@
     BroadcastMessage(SceneTransformChanged(*this));
   }
 
+  void ViewportController::FitContent(
+    unsigned int canvasWidth, unsigned int canvasHeight)
+  {
+    scene_->FitContent(canvasWidth, canvasHeight);
+    BroadcastMessage(SceneTransformChanged(*this));
+  }
+
 }
 
--- a/Framework/Scene2DViewport/ViewportController.h	Mon May 20 12:37:30 2019 +0200
+++ b/Framework/Scene2DViewport/ViewportController.h	Mon May 20 12:49:29 2019 +0200
@@ -78,6 +78,8 @@
     /** Forwarded to the underlying scene, and broadcasted to the observers */
     void SetSceneToCanvasTransform(const AffineTransform2D& transform);
 
+    /** Forwarded to the underlying scene, and broadcasted to the observers */
+    void FitContent(unsigned int canvasWidth, unsigned int canvasHeight);
 
   private:
     Scene2DPtr                scene_;
--- a/Samples/Sdl/BasicScene.cpp	Mon May 20 12:37:30 2019 +0200
+++ b/Samples/Sdl/BasicScene.cpp	Mon May 20 12:49:29 2019 +0200
@@ -241,7 +241,7 @@
     switch (event.key.keysym.sym)
     {
       case SDLK_s:
-        scene.FitContent(compositor.GetCanvasWidth(), 
+        controller->FitContent(compositor.GetCanvasWidth(), 
                          compositor.GetCanvasHeight());
         break;
               
@@ -280,8 +280,7 @@
 {
   SdlOpenGLWindow window("Hello", 1024, 768);
 
-  controller->GetScene()->FitContent(
-    window.GetCanvasWidth(), window.GetCanvasHeight());
+  controller->FitContent(window.GetCanvasWidth(), window.GetCanvasHeight());
   
   glEnable(GL_DEBUG_OUTPUT);
   glDebugMessageCallback(OpenGLMessageCallback, 0);
--- a/Samples/Sdl/TrackerSampleApp.cpp	Mon May 20 12:37:30 2019 +0200
+++ b/Samples/Sdl/TrackerSampleApp.cpp	Mon May 20 12:49:29 2019 +0200
@@ -252,7 +252,7 @@
         break;
 
       case SDLK_s:
-        GetScene()->FitContent(compositor_->GetCanvasWidth(),
+        controller_->FitContent(compositor_->GetCanvasWidth(),
           compositor_->GetCanvasHeight());
         break;
 
@@ -516,7 +516,7 @@
     // that needs to be scaled
     SdlOpenGLWindow window("Hello", 1024, 1024, false);
 
-    GetScene()->FitContent(window.GetCanvasWidth(), window.GetCanvasHeight());
+    controller_->FitContent(window.GetCanvasWidth(), window.GetCanvasHeight());
 
     glEnable(GL_DEBUG_OUTPUT);
     glDebugMessageCallback(OpenGLMessageCallback, 0);