# HG changeset patch # User Sebastien Jodogne # Date 1541839319 -3600 # Node ID d257ea56b7be596a1df5b7d0d73080cd846f2fe9 # Parent 1d9dd542adfe079f2c76da53e0daec5dc055c476 renamed DicomStructureSetRendererFactory as DicomStructureSetSlicer, VolumeImageSource as VolumeImageMPRSlicer diff -r 1d9dd542adfe -r d257ea56b7be Applications/Samples/LayoutPetCtFusionApplication.h --- 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 @@ -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_); diff -r 1d9dd542adfe -r d257ea56b7be Applications/Samples/SingleVolumeApplication.h --- 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 #include // 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)); diff -r 1d9dd542adfe -r d257ea56b7be Framework/Layers/DicomStructureSetRendererFactory.cpp --- 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 . - **/ - - -#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 > 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 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); - } - } -} diff -r 1d9dd542adfe -r d257ea56b7be Framework/Layers/DicomStructureSetRendererFactory.h --- 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 . - **/ - - -#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& points, - const CoordinateSystem3D& viewportPlane) - { - return false; - } - - virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportPlane); - }; -} diff -r 1d9dd542adfe -r d257ea56b7be Framework/Layers/DicomStructureSetSlicer.cpp --- /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 . + **/ + + +#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 > 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 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); + } + } +} diff -r 1d9dd542adfe -r d257ea56b7be Framework/Layers/DicomStructureSetSlicer.h --- /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 . + **/ + + +#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& points, + const CoordinateSystem3D& viewportPlane) + { + return false; + } + + virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportPlane); + }; +} diff -r 1d9dd542adfe -r d257ea56b7be Framework/dev.h --- 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) { diff -r 1d9dd542adfe -r d257ea56b7be Resources/CMake/OrthancStoneConfiguration.cmake --- 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