changeset 2374:07e20eaa0e90 refactoring

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 08 Oct 2026 20:35:08 +0200
parents 8ec75d7efdee
children 2788f73cb1a4
files OrthancStone/Sources/Scene2DViewport/AngleMeasureTool.cpp OrthancStone/Sources/Scene2DViewport/AngleMeasureTool.h OrthancStone/Sources/Scene2DViewport/LineMeasureTool.cpp OrthancStone/Sources/Scene2DViewport/MeasureTool.cpp OrthancStone/Sources/Scene2DViewport/MeasureTool.h OrthancStone/Sources/Scene2DViewport/ViewportController.cpp OrthancStone/Sources/Scene2DViewport/ViewportController.h
diffstat 7 files changed, 50 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancStone/Sources/Scene2DViewport/AngleMeasureTool.cpp	Thu Oct 08 20:20:08 2026 +0200
+++ b/OrthancStone/Sources/Scene2DViewport/AngleMeasureTool.cpp	Thu Oct 08 20:35:08 2026 +0200
@@ -34,6 +34,10 @@
 #include <boost/make_shared.hpp>
 
 
+static const double ARC_RADIUS_CANVAS_COORD = 30.0;
+static const double TEXT_CENTER_DISTANCE_CANVAS_COORD = 90;
+
+
 namespace OrthancStone
 {
   class AngleMeasureTool::Tracker : public IFlexiblePointerTracker
@@ -419,8 +423,7 @@
               {
                 PolylineSceneLayer::Chain chain;
                 //TODO: take DPI into account
-                AddSquare(chain, controller.GetScene(), side1End_, 
-                          controller.GetHandleSideLengthS());
+                AddSquare(chain, controller.GetScene(), side1End_, GetHandleSideLengthS(controller.GetScene()));
               
                 if (angleHighlightArea_ == AngleHighlightArea_Side1End)
                   polylineLayer->AddChain(chain, true, highlightColor);
@@ -431,8 +434,7 @@
               {
                 PolylineSceneLayer::Chain chain;
                 //TODO: take DPI into account
-                AddSquare(chain, controller.GetScene(), side2End_, 
-                          controller.GetHandleSideLengthS());
+                AddSquare(chain, controller.GetScene(), side2End_, GetHandleSideLengthS(controller.GetScene()));
 
                 if (angleHighlightArea_ == AngleHighlightArea_Side2End)
                   polylineLayer->AddChain(chain, true, highlightColor);
@@ -445,8 +447,7 @@
             {
               PolylineSceneLayer::Chain chain;
 
-              AddShortestArc(chain, side1End_, center_, side2End_,
-                             controller.GetAngleToolArcRadiusS());
+              AddShortestArc(chain, side1End_, center_, side2End_, GetAngleToolArcRadiusS(controller.GetScene()));
               if (angleHighlightArea_ == AngleHighlightArea_Center)
                 polylineLayer->AddChain(chain, false, highlightColor);
               else
@@ -468,8 +469,8 @@
           double delta = NormalizeAngle(p2cAngle - p1cAngle);
           double theta = p1cAngle + delta / 2;
 
-          double ox = controller.GetAngleTopTextLabelDistanceS() * cos(theta);
-          double oy = controller.GetAngleTopTextLabelDistanceS() * sin(theta);
+          double ox = GetAngleTopTextLabelDistanceS(controller.GetScene()) * cos(theta);
+          double oy = GetAngleTopTextLabelDistanceS(controller.GetScene()) * sin(theta);
 
           double pointX = center_.GetX() + ox;
           double pointY = center_.GetY() + oy;
@@ -548,4 +549,16 @@
       lock->Invalidate();
     }
   }
+
+
+  double AngleMeasureTool::GetAngleToolArcRadiusS(const Scene2D& scene)
+  {
+    return ARC_RADIUS_CANVAS_COORD * scene.GetCanvasToSceneTransform().ComputeZoom();
+  }
+
+
+  double AngleMeasureTool::GetAngleTopTextLabelDistanceS(const Scene2D& scene)
+  {
+    return TEXT_CENTER_DISTANCE_CANVAS_COORD * scene.GetCanvasToSceneTransform().ComputeZoom();
+  }
 }
--- a/OrthancStone/Sources/Scene2DViewport/AngleMeasureTool.h	Thu Oct 08 20:20:08 2026 +0200
+++ b/OrthancStone/Sources/Scene2DViewport/AngleMeasureTool.h	Thu Oct 08 20:35:08 2026 +0200
@@ -111,6 +111,22 @@
     void                RemoveFromScene();
     void                SetAngleHighlightArea(AngleHighlightArea area);
 
+    /**
+    The angle measure too arc  radius in *scene* coordinates
+
+    Note: you might wonder why this is not part of the AngleMeasureTool itself,
+    but we prefer to put all such constants in the same location, to ease 
+    */
+    static double GetAngleToolArcRadiusS(const Scene2D& scene);
+
+    /**
+       TODO Refactoring - Remove this?
+
+    Distance between the top of the angle measuring tool and the center of 
+    the label showing the actual measure, in *scene* coordinates
+    */
+    static double GetAngleTopTextLabelDistanceS(const Scene2D& scene);
+
   private:
     ScenePoint2D                    side1End_;
     ScenePoint2D                    side2End_;
--- a/OrthancStone/Sources/Scene2DViewport/LineMeasureTool.cpp	Thu Oct 08 20:20:08 2026 +0200
+++ b/OrthancStone/Sources/Scene2DViewport/LineMeasureTool.cpp	Thu Oct 08 20:35:08 2026 +0200
@@ -357,8 +357,7 @@
                 PolylineSceneLayer::Chain chain;
               
                 //TODO: take DPI into account
-                AddSquare(chain, controller.GetScene(), start_, 
-                          controller.GetHandleSideLengthS());
+                AddSquare(chain, controller.GetScene(), start_, GetHandleSideLengthS(controller.GetScene()));
               
                 if (lineHighlightArea_ == LineHighlightArea_Start)
                   polylineLayer->AddChain(chain, true, highlightColor);
@@ -370,8 +369,7 @@
                 PolylineSceneLayer::Chain chain;
               
                 //TODO: take DPI into account
-                AddSquare(chain, controller.GetScene(), end_, 
-                          controller.GetHandleSideLengthS());
+                AddSquare(chain, controller.GetScene(), end_, GetHandleSideLengthS(controller.GetScene()));
               
                 if (lineHighlightArea_ == LineHighlightArea_End)
                   polylineLayer->AddChain(chain, true, highlightColor);
--- a/OrthancStone/Sources/Scene2DViewport/MeasureTool.cpp	Thu Oct 08 20:20:08 2026 +0200
+++ b/OrthancStone/Sources/Scene2DViewport/MeasureTool.cpp	Thu Oct 08 20:35:08 2026 +0200
@@ -31,6 +31,10 @@
 
 #include <boost/shared_ptr.hpp>
 
+
+static const double HANDLE_SIDE_LENGTH_CANVAS_COORD = 10.0;
+
+
 namespace OrthancStone
 {
   void MeasureTool::Enable()
@@ -68,6 +72,11 @@
       return NULL;
   }
 
+  double MeasureTool::GetHandleSideLengthS(const Scene2D& scene)
+  {
+    return HANDLE_SIDE_LENGTH_CANVAS_COORD * scene.GetCanvasToSceneTransform().ComputeZoom();
+  }
+
   MeasureTool::MeasureTool(boost::weak_ptr<IViewport> viewport) :
     enabled_(true),
     viewport_(viewport)
--- a/OrthancStone/Sources/Scene2DViewport/MeasureTool.h	Thu Oct 08 20:20:08 2026 +0200
+++ b/OrthancStone/Sources/Scene2DViewport/MeasureTool.h	Thu Oct 08 20:35:08 2026 +0200
@@ -87,6 +87,8 @@
     IViewport::ILock* GetViewportLock();
     IViewport::ILock* GetViewportLock() const;
 
+    static double GetHandleSideLengthS(const Scene2D& scene);
+
   public:
     virtual ~MeasureTool()
     {
--- a/OrthancStone/Sources/Scene2DViewport/ViewportController.cpp	Thu Oct 08 20:20:08 2026 +0200
+++ b/OrthancStone/Sources/Scene2DViewport/ViewportController.cpp	Thu Oct 08 20:35:08 2026 +0200
@@ -191,30 +191,6 @@
   }
 
 
-  double ViewportController::GetHandleSideLengthS() const
-  {
-    return HANDLE_SIDE_LENGTH_CANVAS_COORD * scene_->GetCanvasToSceneTransform().ComputeZoom();
-  }
-
-
-  double ViewportController::GetAngleToolArcRadiusS() const
-  {
-    return ARC_RADIUS_CANVAS_COORD * scene_->GetCanvasToSceneTransform().ComputeZoom();
-  }
-
-
-  double ViewportController::GetHitTestMaximumDistanceS() const
-  {
-    return HIT_TEST_MAX_DISTANCE_CANVAS_COORD * scene_->GetCanvasToSceneTransform().ComputeZoom();
-  }
-
-
-  double ViewportController::GetAngleTopTextLabelDistanceS() const
-  {
-    return TEXT_CENTER_DISTANCE_CANVAS_COORD * scene_->GetCanvasToSceneTransform().ComputeZoom();
-  }
-
-
   void ViewportController::InvalidateViewport()
   {
     boost::shared_ptr<IViewport> sharedViewport(viewport_.lock());
--- a/OrthancStone/Sources/Scene2DViewport/ViewportController.h	Thu Oct 08 20:20:08 2026 +0200
+++ b/OrthancStone/Sources/Scene2DViewport/ViewportController.h	Thu Oct 08 20:35:08 2026 +0200
@@ -38,10 +38,6 @@
 {
   class MeasureTool;
 
-  const double ARC_RADIUS_CANVAS_COORD = 30.0;
-  const double TEXT_CENTER_DISTANCE_CANVAS_COORD = 90;
-
-  const double HANDLE_SIDE_LENGTH_CANVAS_COORD = 10.0;
   const double HIT_TEST_MAX_DISTANCE_CANVAS_COORD = 15.0;
 
   const uint8_t TOOL_ANGLE_LINES_COLOR_RED = 0;
@@ -126,40 +122,6 @@
 
     IFlexiblePointerTracker* CreateAngleMeasure(const PointerEvent& event);
 
-    /**
-       TODO Refactoring - Remove this?
-
-    The square handle side length in *scene* coordinates
-    */
-    double GetHandleSideLengthS() const;
-
-    /**
-       TODO Refactoring - Remove this?
-
-    The angle measure too arc  radius in *scene* coordinates
-
-    Note: you might wonder why this is not part of the AngleMeasureTool itself,
-    but we prefer to put all such constants in the same location, to ease 
-    */
-    double GetAngleToolArcRadiusS() const;
-
-    /**
-       TODO Refactoring - Remove this?
-
-    The hit test maximum distance in *scene* coordinates.
-    If a pointer event is less than GetHandleSideLengthS() to a GUI element,
-    the hit test for this GUI element is seen as true
-    */
-    double GetHitTestMaximumDistanceS() const;
-
-    /**
-       TODO Refactoring - Remove this?
-
-    Distance between the top of the angle measuring tool and the center of 
-    the label showing the actual measure, in *scene* coordinates
-    */
-    double GetAngleTopTextLabelDistanceS() const;
-
 
     /** forwarded to the UndoStack */
     void PushCommand(const boost::shared_ptr<UndoStack::ICommand>& command);