Mercurial > hg > orthanc-stone
changeset 398:d257ea56b7be
renamed DicomStructureSetRendererFactory as DicomStructureSetSlicer, VolumeImageSource as VolumeImageMPRSlicer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 10 Nov 2018 09:41:59 +0100 |
parents | 1d9dd542adfe |
children | 885e1ebd315c |
files | Applications/Samples/LayoutPetCtFusionApplication.h Applications/Samples/SingleVolumeApplication.h Framework/Layers/DicomStructureSetRendererFactory.cpp Framework/Layers/DicomStructureSetRendererFactory.h Framework/Layers/DicomStructureSetSlicer.cpp Framework/Layers/DicomStructureSetSlicer.h Framework/dev.h Resources/CMake/OrthancStoneConfiguration.cmake |
diffstat | 8 files changed, 241 insertions(+), 240 deletions(-) [+] |
line wrap: on
line diff
--- a/Applications/Samples/LayoutPetCtFusionApplication.h Sat Nov 10 09:33:50 2018 +0100 +++ b/Applications/Samples/LayoutPetCtFusionApplication.h Sat Nov 10 09:41:59 2018 +0100 @@ -24,7 +24,7 @@ #include "SampleInteractor.h" #include "../../Framework/Layers/ReferenceLineFactory.h" -#include "../../Framework/Layers/DicomStructureSetRendererFactory.h" +#include "../../Framework/Layers/DicomStructureSetSlicer.h" #include "../../Framework/Widgets/LayoutWidget.h" #include <Core/Logging.h> @@ -331,9 +331,9 @@ Vector p = rtStruct.GetStructureCenter(0); interactorAxial_->GetCursor().LookupSliceContainingPoint(p); - ctAxial_->AddLayer(new DicomStructureSetRendererFactory(rtStruct)); - petAxial_->AddLayer(new DicomStructureSetRendererFactory(rtStruct)); - fusionAxial_->AddLayer(new DicomStructureSetRendererFactory(rtStruct)); + ctAxial_->AddLayer(new DicomStructureSetSlicer(rtStruct)); + petAxial_->AddLayer(new DicomStructureSetSlicer(rtStruct)); + fusionAxial_->AddLayer(new DicomStructureSetSlicer(rtStruct)); } ConnectSiblingLocations(*ctAxial_, *ctCoronal_, *ctSagittal_);
--- a/Applications/Samples/SingleVolumeApplication.h Sat Nov 10 09:33:50 2018 +0100 +++ b/Applications/Samples/SingleVolumeApplication.h Sat Nov 10 09:41:59 2018 +0100 @@ -30,7 +30,7 @@ #include <Core/Logging.h> #include <Plugins/Samples/Common/OrthancHttpConnection.h> // TODO REMOVE -#include "../../Framework/Layers/DicomStructureSetRendererFactory.h" // TODO REMOVE +#include "../../Framework/Layers/DicomStructureSetSlicer.h" // TODO REMOVE #include "../../Framework/Toolbox/MessagingToolbox.h" // TODO REMOVE namespace OrthancStone @@ -183,7 +183,7 @@ volume->ScheduleLoadSeries(series); } - widget->AddLayer(new VolumeImageSource(*volume)); + widget->AddLayer(new VolumeImageMPRSlicer(*volume)); context_->AddInteractor(new Interactor(*volume, *widget, projection, 0)); context_->AddSlicedVolume(volume.release()); @@ -229,9 +229,9 @@ //rtStruct->ScheduleLoadInstance("17cd032b-ad92a438-ca05f06a-f9e96668-7e3e9e20"); // 0522c0001 TCIA rtStruct->ScheduleLoadInstance("96c889ab-29fe5c54-dda6e66c-3949e4da-58f90d75"); // Captain - widget->AddLayer(new VolumeImageSource(*ct)); - widget->AddLayer(new VolumeImageSource(*pet)); - widget->AddLayer(new DicomStructureSetRendererFactory(*rtStruct)); + widget->AddLayer(new VolumeImageMPRSlicer(*ct)); + widget->AddLayer(new VolumeImageMPRSlicer(*pet)); + widget->AddLayer(new DicomStructureSetSlicer(*rtStruct)); context_->AddInteractor(new Interactor(*pet, *widget, projection, 1)); //context_->AddInteractor(new VolumeImageInteractor(*ct, *widget, projection));
--- a/Framework/Layers/DicomStructureSetRendererFactory.cpp Sat Nov 10 09:33:50 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,158 +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 <http://www.gnu.org/licenses/>. - **/ - - -#include "DicomStructureSetRendererFactory.h" - -namespace OrthancStone -{ - class DicomStructureSetRendererFactory::Renderer : public ILayerRenderer - { - private: - class Structure - { - private: - bool visible_; - uint8_t red_; - uint8_t green_; - uint8_t blue_; - std::string name_; - std::vector< std::vector<DicomStructureSet::PolygonPoint> > polygons_; - - public: - Structure(DicomStructureSet& structureSet, - const CoordinateSystem3D& plane, - size_t index) : - name_(structureSet.GetStructureName(index)) - { - structureSet.GetStructureColor(red_, green_, blue_, index); - visible_ = structureSet.ProjectStructure(polygons_, index, plane); - } - - void Render(CairoContext& context) - { - if (visible_) - { - cairo_t* cr = context.GetObject(); - - context.SetSourceColor(red_, green_, blue_); - - for (size_t i = 0; i < polygons_.size(); i++) - { - cairo_move_to(cr, polygons_[i][0].first, polygons_[i][0].second); - - for (size_t j = 1; j < polygons_[i].size(); j++) - { - cairo_line_to(cr, polygons_[i][j].first, polygons_[i][j].second); - } - - cairo_line_to(cr, polygons_[i][0].first, polygons_[i][0].second); - cairo_stroke(cr); - } - } - } - }; - - typedef std::list<Structure*> Structures; - - CoordinateSystem3D plane_; - Structures structures_; - - public: - Renderer(DicomStructureSet& structureSet, - const CoordinateSystem3D& plane) : - plane_(plane) - { - for (size_t k = 0; k < structureSet.GetStructureCount(); k++) - { - structures_.push_back(new Structure(structureSet, plane, k)); - } - } - - virtual ~Renderer() - { - for (Structures::iterator it = structures_.begin(); - it != structures_.end(); ++it) - { - delete *it; - } - } - - virtual bool RenderLayer(CairoContext& context, - const ViewportGeometry& view) - { - cairo_set_line_width(context.GetObject(), 2.0f / view.GetZoom()); - - for (Structures::const_iterator it = structures_.begin(); - it != structures_.end(); ++it) - { - assert(*it != NULL); - (*it)->Render(context); - } - - return true; - } - - virtual const CoordinateSystem3D& GetLayerPlane() - { - return plane_; - } - - virtual void SetLayerStyle(const RenderStyle& style) - { - } - - virtual bool IsFullQuality() - { - return true; - } - }; - - - class DicomStructureSetRendererFactory::RendererFactory : public LayerReadyMessage::IRendererFactory - { - private: - DicomStructureSet& structureSet_; - const CoordinateSystem3D& plane_; - - public: - RendererFactory(DicomStructureSet& structureSet, - const CoordinateSystem3D& plane) : - structureSet_(structureSet), - plane_(plane) - { - } - - virtual ILayerRenderer* CreateRenderer() const - { - return new Renderer(structureSet_, plane_); - } - }; - - - void DicomStructureSetRendererFactory::ScheduleLayerCreation(const CoordinateSystem3D& viewportPlane) - { - if (loader_.HasStructureSet()) - { - RendererFactory factory(loader_.GetStructureSet(), viewportPlane); - NotifyLayerReady(factory, viewportPlane); - } - } -}
--- a/Framework/Layers/DicomStructureSetRendererFactory.h Sat Nov 10 09:33:50 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +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 <http://www.gnu.org/licenses/>. - **/ - - -#pragma once - -#include "VolumeSlicerBase.h" -#include "../Volumes/StructureSetLoader.h" - -namespace OrthancStone -{ - class DicomStructureSetRendererFactory : - public VolumeSlicerBase, - private IVolumeLoader::IObserver - { - private: - class Renderer; - class RendererFactory; - - virtual void NotifyGeometryReady(const IVolumeLoader& loader) - { - VolumeSlicerBase::NotifyGeometryReady(); - } - - virtual void NotifyGeometryError(const IVolumeLoader& loader) - { - VolumeSlicerBase::NotifyGeometryError(); - } - - virtual void NotifyContentChange(const IVolumeLoader& loader) - { - VolumeSlicerBase::NotifyContentChange(); - } - - StructureSetLoader& loader_; - - public: - DicomStructureSetRendererFactory(MessageBroker& broker, StructureSetLoader& loader) : - VolumeSlicerBase(broker), - loader_(loader) - { - loader_.Register(*this); - } - - virtual bool GetExtent(std::vector<Vector>& points, - const CoordinateSystem3D& viewportPlane) - { - return false; - } - - virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportPlane); - }; -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Framework/Layers/DicomStructureSetSlicer.cpp Sat Nov 10 09:41:59 2018 +0100 @@ -0,0 +1,158 @@ +/** + * 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 <http://www.gnu.org/licenses/>. + **/ + + +#include "DicomStructureSetSlicer.h" + +namespace OrthancStone +{ + class DicomStructureSetSlicer::Renderer : public ILayerRenderer + { + private: + class Structure + { + private: + bool visible_; + uint8_t red_; + uint8_t green_; + uint8_t blue_; + std::string name_; + std::vector< std::vector<DicomStructureSet::PolygonPoint> > polygons_; + + public: + Structure(DicomStructureSet& structureSet, + const CoordinateSystem3D& plane, + size_t index) : + name_(structureSet.GetStructureName(index)) + { + structureSet.GetStructureColor(red_, green_, blue_, index); + visible_ = structureSet.ProjectStructure(polygons_, index, plane); + } + + void Render(CairoContext& context) + { + if (visible_) + { + cairo_t* cr = context.GetObject(); + + context.SetSourceColor(red_, green_, blue_); + + for (size_t i = 0; i < polygons_.size(); i++) + { + cairo_move_to(cr, polygons_[i][0].first, polygons_[i][0].second); + + for (size_t j = 1; j < polygons_[i].size(); j++) + { + cairo_line_to(cr, polygons_[i][j].first, polygons_[i][j].second); + } + + cairo_line_to(cr, polygons_[i][0].first, polygons_[i][0].second); + cairo_stroke(cr); + } + } + } + }; + + typedef std::list<Structure*> Structures; + + CoordinateSystem3D plane_; + Structures structures_; + + public: + Renderer(DicomStructureSet& structureSet, + const CoordinateSystem3D& plane) : + plane_(plane) + { + for (size_t k = 0; k < structureSet.GetStructureCount(); k++) + { + structures_.push_back(new Structure(structureSet, plane, k)); + } + } + + virtual ~Renderer() + { + for (Structures::iterator it = structures_.begin(); + it != structures_.end(); ++it) + { + delete *it; + } + } + + virtual bool RenderLayer(CairoContext& context, + const ViewportGeometry& view) + { + cairo_set_line_width(context.GetObject(), 2.0f / view.GetZoom()); + + for (Structures::const_iterator it = structures_.begin(); + it != structures_.end(); ++it) + { + assert(*it != NULL); + (*it)->Render(context); + } + + return true; + } + + virtual const CoordinateSystem3D& GetLayerPlane() + { + return plane_; + } + + virtual void SetLayerStyle(const RenderStyle& style) + { + } + + virtual bool IsFullQuality() + { + return true; + } + }; + + + class DicomStructureSetSlicer::RendererFactory : public LayerReadyMessage::IRendererFactory + { + private: + DicomStructureSet& structureSet_; + const CoordinateSystem3D& plane_; + + public: + RendererFactory(DicomStructureSet& structureSet, + const CoordinateSystem3D& plane) : + structureSet_(structureSet), + plane_(plane) + { + } + + virtual ILayerRenderer* CreateRenderer() const + { + return new Renderer(structureSet_, plane_); + } + }; + + + void DicomStructureSetSlicer::ScheduleLayerCreation(const CoordinateSystem3D& viewportPlane) + { + if (loader_.HasStructureSet()) + { + RendererFactory factory(loader_.GetStructureSet(), viewportPlane); + NotifyLayerReady(factory, viewportPlane); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Framework/Layers/DicomStructureSetSlicer.h Sat Nov 10 09:41:59 2018 +0100 @@ -0,0 +1,70 @@ +/** + * 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 <http://www.gnu.org/licenses/>. + **/ + + +#pragma once + +#include "VolumeSlicerBase.h" +#include "../Volumes/StructureSetLoader.h" + +namespace OrthancStone +{ + class DicomStructureSetSlicer : + public VolumeSlicerBase, + private IVolumeLoader::IObserver + { + private: + class Renderer; + class RendererFactory; + + virtual void NotifyGeometryReady(const IVolumeLoader& loader) + { + VolumeSlicerBase::NotifyGeometryReady(); + } + + virtual void NotifyGeometryError(const IVolumeLoader& loader) + { + VolumeSlicerBase::NotifyGeometryError(); + } + + virtual void NotifyContentChange(const IVolumeLoader& loader) + { + VolumeSlicerBase::NotifyContentChange(); + } + + StructureSetLoader& loader_; + + public: + DicomStructureSetSlicer(MessageBroker& broker, StructureSetLoader& loader) : + VolumeSlicerBase(broker), + loader_(loader) + { + loader_.Register(*this); + } + + virtual bool GetExtent(std::vector<Vector>& points, + const CoordinateSystem3D& viewportPlane) + { + return false; + } + + virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportPlane); + }; +}
--- a/Framework/dev.h Sat Nov 10 09:33:50 2018 +0100 +++ b/Framework/dev.h Sat Nov 10 09:41:59 2018 +0100 @@ -494,7 +494,7 @@ - class VolumeImageSource : + class VolumeImageMPRSlicer : public VolumeSlicerBase, private ISlicedVolume::IObserver { @@ -627,7 +627,8 @@ public: - VolumeImageSource(MessageBroker& broker, OrthancVolumeImage& volume) : + VolumeImageMPRSlicer(MessageBroker& broker, + OrthancVolumeImage& volume) : VolumeSlicerBase(broker), volume_(volume) {
--- a/Resources/CMake/OrthancStoneConfiguration.cmake Sat Nov 10 09:33:50 2018 +0100 +++ b/Resources/CMake/OrthancStoneConfiguration.cmake Sat Nov 10 09:41:59 2018 +0100 @@ -237,7 +237,7 @@ ${ORTHANC_STONE_ROOT}/Framework/Layers/CircleMeasureTracker.cpp ${ORTHANC_STONE_ROOT}/Framework/Layers/ColorFrameRenderer.cpp - ${ORTHANC_STONE_ROOT}/Framework/Layers/DicomStructureSetRendererFactory.cpp + ${ORTHANC_STONE_ROOT}/Framework/Layers/DicomStructureSetSlicer.cpp ${ORTHANC_STONE_ROOT}/Framework/Layers/FrameRenderer.cpp ${ORTHANC_STONE_ROOT}/Framework/Layers/GrayscaleFrameRenderer.cpp ${ORTHANC_STONE_ROOT}/Framework/Layers/IVolumeSlicer.h