# HG changeset patch # User Benjamin Golinvaux # Date 1575470774 -3600 # Node ID b5dec783ba0864c481cfe8dde98076f26ce9afd0 # Parent c93a6218f0cd4bbc0796080a3c1065f3f0604424 Fixed the style configurator to only set inversion on the image if it has been explicitely asked by the user + Fixed AddCircle in the measuring toolbox + dummy change (reindent) diff -r c93a6218f0cd -r b5dec783ba08 Framework/Scene2D/GrayscaleStyleConfigurator.cpp --- a/Framework/Scene2D/GrayscaleStyleConfigurator.cpp Tue Dec 03 09:51:00 2019 +0100 +++ b/Framework/Scene2D/GrayscaleStyleConfigurator.cpp Wed Dec 04 15:46:14 2019 +0100 @@ -29,7 +29,7 @@ { void GrayscaleStyleConfigurator::SetWindowing(ImageWindowing windowing) { - hasWindowing_ = true; + hasWindowingOverride_ = true; windowing_ = windowing; revision_++; } @@ -49,6 +49,7 @@ void GrayscaleStyleConfigurator::SetInverted(bool inverted) { + hasInversionOverride_ = true; inverted_ = inverted; revision_++; } @@ -88,7 +89,7 @@ l.SetLinearInterpolation(linearInterpolation_); - if (hasWindowing_) + if (hasWindowingOverride_) { if (windowing_ != ImageWindowing_Custom) { @@ -99,6 +100,9 @@ l.SetCustomWindowing(customWindowCenter_, customWindowWidth_); } } - l.SetInverted(inverted_); + if (hasInversionOverride_) + { + l.SetInverted(inverted_); + } } } diff -r c93a6218f0cd -r b5dec783ba08 Framework/Scene2D/GrayscaleStyleConfigurator.h --- a/Framework/Scene2D/GrayscaleStyleConfigurator.h Tue Dec 03 09:51:00 2019 +0100 +++ b/Framework/Scene2D/GrayscaleStyleConfigurator.h Wed Dec 04 15:46:14 2019 +0100 @@ -34,19 +34,21 @@ private: uint64_t revision_; bool linearInterpolation_; - bool hasWindowing_; + bool hasWindowingOverride_; ImageWindowing windowing_; float customWindowWidth_; float customWindowCenter_; + bool hasInversionOverride_; bool inverted_; public: GrayscaleStyleConfigurator() : revision_(0), linearInterpolation_(false), - hasWindowing_(false), + hasWindowingOverride_(false), customWindowWidth_(0), customWindowCenter_(0), + hasInversionOverride_(false), inverted_(false) { } diff -r c93a6218f0cd -r b5dec783ba08 Framework/Scene2DViewport/MeasureToolsToolbox.cpp --- a/Framework/Scene2DViewport/MeasureToolsToolbox.cpp Tue Dec 03 09:51:00 2019 +0100 +++ b/Framework/Scene2DViewport/MeasureToolsToolbox.cpp Wed Dec 04 15:46:14 2019 +0100 @@ -65,6 +65,11 @@ const ScenePoint2D& centerS, const double& sideLengthS) { + /* + The scene is required here because we need to draw the square with its + sides parallel to the SCREEN axis, not the SCENE axis + */ + // get the scaling factor const double sceneToCanvas = scene.GetSceneToCanvasTransform().ComputeZoom(); @@ -204,9 +209,9 @@ #endif void AddCircle(PolylineSceneLayer::Chain& chain, - const ScenePoint2D& centerS, - const double& radiusS, - const int numSubdivisions) + const ScenePoint2D& centerS, + const double& radiusS, + const int numSubdivisions) { //ScenePoint2D centerC = centerS.Apply(scene.GetSceneToCanvasTransform()); //TODO: take DPI into account diff -r c93a6218f0cd -r b5dec783ba08 Framework/Scene2DViewport/MeasureToolsToolbox.h --- a/Framework/Scene2DViewport/MeasureToolsToolbox.h Tue Dec 03 09:51:00 2019 +0100 +++ b/Framework/Scene2DViewport/MeasureToolsToolbox.h Wed Dec 04 15:46:14 2019 +0100 @@ -31,9 +31,9 @@ square sides are parallel to the canvas boundaries. */ void AddSquare(PolylineSceneLayer::Chain& chain, - const Scene2D& scene, - const ScenePoint2D& centerS, - const double& sideLengthS); + const Scene2D& scene, + const ScenePoint2D& centerS, + const double& sideLengthS); /** Creates an arc centered on c that goes @@ -123,10 +123,9 @@ Warning: the existing chain content will be wiped out. */ void AddCircle(PolylineSceneLayer::Chain& chain, - const Scene2D& scene, - const ScenePoint2D& centerS, - const double& radiusS, - const int numSubdivisions = 63); + const ScenePoint2D& centerS, + const double& radiusS, + const int numSubdivisions = 63); /** Adds or subtracts 2*pi as many times as need to shift the specified @@ -146,9 +145,7 @@ */ double MeasureAngle( - const ScenePoint2D& p1 - , const ScenePoint2D& c - , const ScenePoint2D& p2); + const ScenePoint2D& p1, const ScenePoint2D& c, const ScenePoint2D& p2); /** RadiansToDegrees diff -r c93a6218f0cd -r b5dec783ba08 Framework/Toolbox/AffineTransform2D.h --- a/Framework/Toolbox/AffineTransform2D.h Tue Dec 03 09:51:00 2019 +0100 +++ b/Framework/Toolbox/AffineTransform2D.h Wed Dec 04 15:46:14 2019 +0100 @@ -77,7 +77,8 @@ const AffineTransform2D& c, const AffineTransform2D& d); - // transformations are applied right to left: e is the first transfo applied, a is the last one + // transformations are applied right to left: + // `e` is the first transformation applied and `a` is the last one static AffineTransform2D Combine(const AffineTransform2D& a, const AffineTransform2D& b, const AffineTransform2D& c,