# HG changeset patch # User Alain Mazy # Date 1557220557 -7200 # Node ID fd9b9d993fc7eee39fae4da20662db5b168bb4cd # Parent 8432926e9db90d6fac9f18d8c86cb33118afcb33 added flip to RadiographyLayer diff -r 8432926e9db9 -r fd9b9d993fc7 Framework/Radiography/RadiographyLayer.cpp --- a/Framework/Radiography/RadiographyLayer.cpp Mon Apr 29 12:01:55 2019 +0200 +++ b/Framework/Radiography/RadiographyLayer.cpp Tue May 07 11:15:57 2019 +0200 @@ -34,6 +34,8 @@ RadiographyLayer::Geometry::Geometry() : hasCrop_(false), + verticalFlip_(false), + horizontalFlip_(false), panX_(0), panY_(0), angle_(0), @@ -57,7 +59,7 @@ void RadiographyLayer::UpdateTransform() { - transform_ = AffineTransform2D::CreateScaling(geometry_.GetPixelSpacingX(), geometry_.GetPixelSpacingY()); + transform_ = AffineTransform2D::CreateScaling(geometry_.GetScalingX(), geometry_.GetScalingY()); double centerX, centerY; GetCenter(centerX, centerY); @@ -204,6 +206,21 @@ EmitMessage(RadiographyLayer::LayerEditedMessage(*this)); } + void RadiographyLayer::SetVerticalFlip(bool flip) + { + geometry_.SetVerticalFlip(flip); + UpdateTransform(); + + EmitMessage(RadiographyLayer::LayerEditedMessage(*this)); + } + + void RadiographyLayer::SetHorizontalFlip(bool flip) + { + geometry_.SetHorizontalFlip(flip); + UpdateTransform(); + + EmitMessage(RadiographyLayer::LayerEditedMessage(*this)); + } void RadiographyLayer::SetSize(unsigned int width, unsigned int height) diff -r 8432926e9db9 -r fd9b9d993fc7 Framework/Radiography/RadiographyLayer.h --- a/Framework/Radiography/RadiographyLayer.h Mon Apr 29 12:01:55 2019 +0200 +++ b/Framework/Radiography/RadiographyLayer.h Tue May 07 11:15:57 2019 +0200 @@ -75,6 +75,8 @@ unsigned int cropY_; unsigned int cropWidth_; unsigned int cropHeight_; + bool verticalFlip_; + bool horizontalFlip_; double panX_; double panY_; double angle_; @@ -166,6 +168,35 @@ return pixelSpacingY_; } + void SetVerticalFlip(bool flip) // mirrors image around an horizontal axis (note: flip is applied before the rotation !) + { + verticalFlip_ = flip; + } + + void SetHorizontalFlip(bool flip) // mirrors image around a vertical axis (note: flip is applied before the rotation !) + { + horizontalFlip_ = flip; + } + + bool GetVerticalFlip() const + { + return verticalFlip_; + } + + bool GetHorizontalFlip() const + { + return horizontalFlip_; + } + + double GetScalingX() const + { + return (horizontalFlip_ ? - pixelSpacingX_: pixelSpacingX_); + } + + double GetScalingY() const + { + return (verticalFlip_ ? - pixelSpacingY_: pixelSpacingY_); + } }; private: @@ -251,6 +282,10 @@ void SetPan(double x, double y); + void SetVerticalFlip(bool flip); // mirrors image around an horizontal axis (note: flip is applied before the rotation !) + + void SetHorizontalFlip(bool flip); // mirrors image around a vertical axis (note: flip is applied before the rotation !) + void SetResizeable(bool resizeable) { geometry_.SetResizeable(resizeable); diff -r 8432926e9db9 -r fd9b9d993fc7 Framework/Radiography/RadiographyScene.h --- a/Framework/Radiography/RadiographyScene.h Mon Apr 29 12:01:55 2019 +0200 +++ b/Framework/Radiography/RadiographyScene.h Tue May 07 11:15:57 2019 +0200 @@ -156,7 +156,7 @@ void OnTagsReceived(const OrthancApiClient::BinaryResponseReadyMessage& message); - void OnFrameReceived(const OrthancApiClient::BinaryResponseReadyMessage& message); + virtual void OnFrameReceived(const OrthancApiClient::BinaryResponseReadyMessage& message); void OnDicomExported(const OrthancApiClient::JsonResponseReadyMessage& message); diff -r 8432926e9db9 -r fd9b9d993fc7 Framework/Radiography/RadiographySceneReader.cpp --- a/Framework/Radiography/RadiographySceneReader.cpp Mon Apr 29 12:01:55 2019 +0200 +++ b/Framework/Radiography/RadiographySceneReader.cpp Tue May 07 11:15:57 2019 +0200 @@ -234,5 +234,16 @@ geometry.SetResizeable(jsonLayer["isResizable"].asBool()); geometry.SetPan(jsonLayer["pan"]["x"].asDouble(), jsonLayer["pan"]["y"].asDouble()); geometry.SetPixelSpacing(jsonLayer["pixelSpacing"]["x"].asDouble(), jsonLayer["pixelSpacing"]["y"].asDouble()); + + // these fields were introduced later -> they might not exist + if (jsonLayer.isMember("verticalFlip")) + { + geometry.SetVerticalFlip(jsonLayer["verticalFlip"].asBool()); + } + if (jsonLayer.isMember("horizontalFlip")) + { + geometry.SetHorizontalFlip(jsonLayer["horizontalFlip"].asBool()); + } + } } diff -r 8432926e9db9 -r fd9b9d993fc7 Framework/Radiography/RadiographySceneWriter.cpp --- a/Framework/Radiography/RadiographySceneWriter.cpp Mon Apr 29 12:01:55 2019 +0200 +++ b/Framework/Radiography/RadiographySceneWriter.cpp Tue May 07 11:15:57 2019 +0200 @@ -132,6 +132,9 @@ output["pixelSpacing"] = pan; } + output["verticalFlip"] = geometry.GetVerticalFlip(); + output["horizontalFlip"] = geometry.GetHorizontalFlip(); + if (dynamic_cast(&layer) != NULL) { WriteLayer(output, dynamic_cast(layer));