# HG changeset patch # User Sebastien Jodogne # Date 1541781454 -3600 # Node ID 0cb925325470c83aa6fda8c08aab7bfdb0e2d021 # Parent 3e6e10a5a6c80e6c55fcdece9df6fdd3110a3f79 renamed SiblingSliceLocation as ReferenceLine diff -r 3e6e10a5a6c8 -r 0cb925325470 Applications/Samples/LayoutPetCtFusionApplication.h --- a/Applications/Samples/LayoutPetCtFusionApplication.h Fri Nov 09 17:28:32 2018 +0100 +++ b/Applications/Samples/LayoutPetCtFusionApplication.h Fri Nov 09 17:37:34 2018 +0100 @@ -23,7 +23,7 @@ #include "SampleInteractor.h" -#include "../../Framework/Layers/SiblingSliceLocationFactory.h" +#include "../../Framework/Layers/ReferenceLineFactory.h" #include "../../Framework/Layers/DicomStructureSetRendererFactory.h" #include "../../Framework/Widgets/LayoutWidget.h" @@ -144,9 +144,9 @@ LayeredSceneWidget& coronal, LayeredSceneWidget& sagittal) { - SiblingSliceLocationFactory::Configure(axial, coronal); - SiblingSliceLocationFactory::Configure(axial, sagittal); - SiblingSliceLocationFactory::Configure(coronal, sagittal); + ReferenceLineFactory::Configure(axial, coronal); + ReferenceLineFactory::Configure(axial, sagittal); + ReferenceLineFactory::Configure(coronal, sagittal); } diff -r 3e6e10a5a6c8 -r 0cb925325470 Applications/Samples/SynchronizedSeriesApplication.h --- a/Applications/Samples/SynchronizedSeriesApplication.h Fri Nov 09 17:28:32 2018 +0100 +++ b/Applications/Samples/SynchronizedSeriesApplication.h Fri Nov 09 17:37:34 2018 +0100 @@ -25,7 +25,7 @@ #include "../../Framework/Toolbox/OrthancSeriesLoader.h" #include "../../Framework/Layers/SeriesFrameRendererFactory.h" -#include "../../Framework/Layers/SiblingSliceLocationFactory.h" +#include "../../Framework/Layers/ReferenceLineFactory.h" #include "../../Framework/Widgets/LayoutWidget.h" #include @@ -87,9 +87,9 @@ std::auto_ptr b(CreateSeriesWidget(context, parameters["b"].as())); std::auto_ptr c(CreateSeriesWidget(context, parameters["c"].as())); - SiblingSliceLocationFactory::Configure(*a, *b); - SiblingSliceLocationFactory::Configure(*a, *c); - SiblingSliceLocationFactory::Configure(*b, *c); + ReferenceLineFactory::Configure(*a, *b); + ReferenceLineFactory::Configure(*a, *c); + ReferenceLineFactory::Configure(*b, *c); std::auto_ptr layout(new LayoutWidget); layout->SetPadding(5); diff -r 3e6e10a5a6c8 -r 0cb925325470 Framework/Layers/ReferenceLineFactory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Framework/Layers/ReferenceLineFactory.cpp Fri Nov 09 17:37:34 2018 +0100 @@ -0,0 +1,137 @@ +/** + * Stone of Orthanc + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2018 Osimis S.A., Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + **/ + + +#include "ReferenceLineFactory.h" + +#include "LineLayerRenderer.h" + +namespace OrthancStone +{ + ReferenceLineFactory::ReferenceLineFactory(LayeredSceneWidget& owner, + LayeredSceneWidget& sibling) : + owner_(owner), + sibling_(sibling), + hasLayerIndex_(false) + { + style_.SetColor(0, 255, 0); + slice_ = sibling.GetSlice(); + sibling_.Register(*this); + } + + + void ReferenceLineFactory::NotifySliceChange(const LayeredSceneWidget& source, + const SliceGeometry& slice) + { + if (&source == &sibling_) + { + SetSlice(slice); + } + } + + + void ReferenceLineFactory::SetLayerIndex(size_t layerIndex) + { + hasLayerIndex_ = true; + layerIndex_ = layerIndex; + } + + + void ReferenceLineFactory::SetStyle(const RenderStyle& style) + { + style_ = style; + } + + + RenderStyle ReferenceLineFactory::GetRenderStyle() + { + return style_; + } + + + void ReferenceLineFactory::SetSlice(const SliceGeometry& slice) + { + slice_ = slice; + + if (hasLayerIndex_) + { + owner_.InvalidateLayer(layerIndex_); + } + } + + + ILayerRenderer* ReferenceLineFactory::CreateLayerRenderer(const SliceGeometry& viewportSlice) + { + Vector p, d; + + // Compute the line of intersection between the two slices + if (!GeometryToolbox::IntersectTwoPlanes(p, d, + slice_.GetOrigin(), slice_.GetNormal(), + viewportSlice.GetOrigin(), viewportSlice.GetNormal())) + { + // The two slice are parallel, don't try and display the intersection + return NULL; + } + + double x1, y1, x2, y2; + viewportSlice.ProjectPoint(x1, y1, p); + viewportSlice.ProjectPoint(x2, y2, p + 1000.0 * d); + + double sx1, sy1, sx2, sy2; + owner_.GetView().GetSceneExtent(sx1, sy1, sx2, sy2); + + if (GeometryToolbox::ClipLineToRectangle(x1, y1, x2, y2, + x1, y1, x2, y2, + sx1, sy1, sx2, sy2)) + { + std::auto_ptr layer(new LineLayerRenderer(x1, y1, x2, y2)); + layer->SetLayerStyle(style_); + return layer.release(); + } + else + { + // Parallel slices + return NULL; + } + } + + + ISliceableVolume& ReferenceLineFactory::GetSourceVolume() const + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + } + + + void ReferenceLineFactory::Configure(LayeredSceneWidget& a, + LayeredSceneWidget& b) + { + { + size_t layerIndex; + ILayerRendererFactory& factory = a.AddLayer(layerIndex, new ReferenceLineFactory(a, b)); + dynamic_cast(factory).SetLayerIndex(layerIndex); + } + + { + size_t layerIndex; + ILayerRendererFactory& factory = b.AddLayer(layerIndex, new ReferenceLineFactory(b, a)); + dynamic_cast(factory).SetLayerIndex(layerIndex); + } + } +} diff -r 3e6e10a5a6c8 -r 0cb925325470 Framework/Layers/ReferenceLineFactory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Framework/Layers/ReferenceLineFactory.h Fri Nov 09 17:37:34 2018 +0100 @@ -0,0 +1,77 @@ +/** + * Stone of Orthanc + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2018 Osimis S.A., Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + **/ + + +#pragma once + +#include "../Widgets/LayeredSceneWidget.h" + +namespace OrthancStone +{ + class ReferenceLineFactory : + public ILayerRendererFactory, + public LayeredSceneWidget::ISliceObserver + { + private: + LayeredSceneWidget& owner_; + LayeredSceneWidget& sibling_; + SliceGeometry slice_; + RenderStyle style_; + bool hasLayerIndex_; + size_t layerIndex_; + + + public: + ReferenceLineFactory(LayeredSceneWidget& owner, + LayeredSceneWidget& sibling); + + virtual void NotifySliceChange(const LayeredSceneWidget& source, + const SliceGeometry& slice); + + void SetLayerIndex(size_t layerIndex); + + void SetStyle(const RenderStyle& style); + + RenderStyle GetRenderStyle(); + + void SetSlice(const SliceGeometry& slice); + + virtual bool GetExtent(double& x1, + double& y1, + double& x2, + double& y2, + const SliceGeometry& viewportSlice) + { + return false; + } + + virtual ILayerRenderer* CreateLayerRenderer(const SliceGeometry& viewportSlice); + + virtual bool HasSourceVolume() const + { + return false; + } + + virtual ISliceableVolume& GetSourceVolume() const; + + static void Configure(LayeredSceneWidget& a, + LayeredSceneWidget& b); + }; +} diff -r 3e6e10a5a6c8 -r 0cb925325470 Framework/Layers/SiblingSliceLocationFactory.cpp --- a/Framework/Layers/SiblingSliceLocationFactory.cpp Fri Nov 09 17:28:32 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,137 +0,0 @@ -/** - * Stone of Orthanc - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * Copyright (C) 2017-2018 Osimis S.A., Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -#include "SiblingSliceLocationFactory.h" - -#include "LineLayerRenderer.h" - -namespace OrthancStone -{ - SiblingSliceLocationFactory::SiblingSliceLocationFactory(LayeredSceneWidget& owner, - LayeredSceneWidget& sibling) : - owner_(owner), - sibling_(sibling), - hasLayerIndex_(false) - { - style_.SetColor(0, 255, 0); - slice_ = sibling.GetSlice(); - sibling_.Register(*this); - } - - - void SiblingSliceLocationFactory::NotifySliceChange(const LayeredSceneWidget& source, - const SliceGeometry& slice) - { - if (&source == &sibling_) - { - SetSlice(slice); - } - } - - - void SiblingSliceLocationFactory::SetLayerIndex(size_t layerIndex) - { - hasLayerIndex_ = true; - layerIndex_ = layerIndex; - } - - - void SiblingSliceLocationFactory::SetStyle(const RenderStyle& style) - { - style_ = style; - } - - - RenderStyle SiblingSliceLocationFactory::GetRenderStyle() - { - return style_; - } - - - void SiblingSliceLocationFactory::SetSlice(const SliceGeometry& slice) - { - slice_ = slice; - - if (hasLayerIndex_) - { - owner_.InvalidateLayer(layerIndex_); - } - } - - - ILayerRenderer* SiblingSliceLocationFactory::CreateLayerRenderer(const SliceGeometry& viewportSlice) - { - Vector p, d; - - // Compute the line of intersection between the two slices - if (!GeometryToolbox::IntersectTwoPlanes(p, d, - slice_.GetOrigin(), slice_.GetNormal(), - viewportSlice.GetOrigin(), viewportSlice.GetNormal())) - { - // The two slice are parallel, don't try and display the intersection - return NULL; - } - - double x1, y1, x2, y2; - viewportSlice.ProjectPoint(x1, y1, p); - viewportSlice.ProjectPoint(x2, y2, p + 1000.0 * d); - - double sx1, sy1, sx2, sy2; - owner_.GetView().GetSceneExtent(sx1, sy1, sx2, sy2); - - if (GeometryToolbox::ClipLineToRectangle(x1, y1, x2, y2, - x1, y1, x2, y2, - sx1, sy1, sx2, sy2)) - { - std::auto_ptr layer(new LineLayerRenderer(x1, y1, x2, y2)); - layer->SetLayerStyle(style_); - return layer.release(); - } - else - { - // Parallel slices - return NULL; - } - } - - - ISliceableVolume& SiblingSliceLocationFactory::GetSourceVolume() const - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); - } - - - void SiblingSliceLocationFactory::Configure(LayeredSceneWidget& a, - LayeredSceneWidget& b) - { - { - size_t layerIndex; - ILayerRendererFactory& factory = a.AddLayer(layerIndex, new SiblingSliceLocationFactory(a, b)); - dynamic_cast(factory).SetLayerIndex(layerIndex); - } - - { - size_t layerIndex; - ILayerRendererFactory& factory = b.AddLayer(layerIndex, new SiblingSliceLocationFactory(b, a)); - dynamic_cast(factory).SetLayerIndex(layerIndex); - } - } -} diff -r 3e6e10a5a6c8 -r 0cb925325470 Framework/Layers/SiblingSliceLocationFactory.h --- a/Framework/Layers/SiblingSliceLocationFactory.h Fri Nov 09 17:28:32 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/** - * Stone of Orthanc - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * Copyright (C) 2017-2018 Osimis S.A., Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -#pragma once - -#include "../Widgets/LayeredSceneWidget.h" - -namespace OrthancStone -{ - class SiblingSliceLocationFactory : - public ILayerRendererFactory, - public LayeredSceneWidget::ISliceObserver - { - private: - LayeredSceneWidget& owner_; - LayeredSceneWidget& sibling_; - SliceGeometry slice_; - RenderStyle style_; - bool hasLayerIndex_; - size_t layerIndex_; - - - public: - SiblingSliceLocationFactory(LayeredSceneWidget& owner, - LayeredSceneWidget& sibling); - - virtual void NotifySliceChange(const LayeredSceneWidget& source, - const SliceGeometry& slice); - - void SetLayerIndex(size_t layerIndex); - - void SetStyle(const RenderStyle& style); - - RenderStyle GetRenderStyle(); - - void SetSlice(const SliceGeometry& slice); - - virtual bool GetExtent(double& x1, - double& y1, - double& x2, - double& y2, - const SliceGeometry& viewportSlice) - { - return false; - } - - virtual ILayerRenderer* CreateLayerRenderer(const SliceGeometry& viewportSlice); - - virtual bool HasSourceVolume() const - { - return false; - } - - virtual ISliceableVolume& GetSourceVolume() const; - - static void Configure(LayeredSceneWidget& a, - LayeredSceneWidget& b); - }; -} diff -r 3e6e10a5a6c8 -r 0cb925325470 Framework/dev.h --- a/Framework/dev.h Fri Nov 09 17:28:32 2018 +0100 +++ b/Framework/dev.h Fri Nov 09 17:37:34 2018 +0100 @@ -862,7 +862,7 @@ - class SliceLocationSource : public LayerSourceBase + class ReferenceLineSource : public LayerSourceBase { private: class RendererFactory : public LayerReadyMessage::IRendererFactory @@ -897,7 +897,8 @@ SliceViewerWidget& otherPlane_; public: - SliceLocationSource(MessageBroker& broker, SliceViewerWidget& otherPlane) : + ReferenceLineSource(MessageBroker& broker, + SliceViewerWidget& otherPlane) : LayerSourceBase(broker), otherPlane_(otherPlane) { diff -r 3e6e10a5a6c8 -r 0cb925325470 Resources/CMake/OrthancStoneConfiguration.cmake --- a/Resources/CMake/OrthancStoneConfiguration.cmake Fri Nov 09 17:28:32 2018 +0100 +++ b/Resources/CMake/OrthancStoneConfiguration.cmake Fri Nov 09 17:37:34 2018 +0100 @@ -233,7 +233,7 @@ list(APPEND ORTHANC_STONE_SOURCES #${ORTHANC_STONE_ROOT}/Framework/Layers/SeriesFrameRendererFactory.cpp - #${ORTHANC_STONE_ROOT}/Framework/Layers/SiblingSliceLocationFactory.cpp + #${ORTHANC_STONE_ROOT}/Framework/Layers/ReferenceLineFactory.cpp #${ORTHANC_STONE_ROOT}/Framework/Layers/SingleFrameRendererFactory.cpp ${ORTHANC_STONE_ROOT}/Framework/Layers/CircleMeasureTracker.cpp