Mercurial > hg > orthanc-stone
comparison Framework/Layers/DicomSeriesVolumeSlicer.cpp @ 396:ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 10 Nov 2018 09:29:08 +0100 |
parents | Framework/Layers/OrthancFrameLayerSource.cpp@5f13809f3f76 |
children | f1c769b3a5c2 |
comparison
equal
deleted
inserted
replaced
395:5f13809f3f76 | 396:ed7146fa2c98 |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #include "DicomSeriesVolumeSlicer.h" | |
23 | |
24 #include "FrameRenderer.h" | |
25 #include "../Toolbox/DicomFrameConverter.h" | |
26 | |
27 #include <Core/Logging.h> | |
28 #include <Core/OrthancException.h> | |
29 | |
30 #include <boost/lexical_cast.hpp> | |
31 | |
32 namespace OrthancStone | |
33 { | |
34 | |
35 void DicomSeriesVolumeSlicer::OnSliceGeometryReady(const OrthancSlicesLoader::SliceGeometryReadyMessage& message) | |
36 { | |
37 if (message.GetOrigin().GetSliceCount() > 0) | |
38 { | |
39 VolumeSlicerBase::NotifyGeometryReady(); | |
40 } | |
41 else | |
42 { | |
43 VolumeSlicerBase::NotifyGeometryError(); | |
44 } | |
45 } | |
46 | |
47 void DicomSeriesVolumeSlicer::OnSliceGeometryError(const OrthancSlicesLoader::SliceGeometryErrorMessage& message) | |
48 { | |
49 VolumeSlicerBase::NotifyGeometryError(); | |
50 } | |
51 | |
52 | |
53 class DicomSeriesVolumeSlicer::RendererFactory : public LayerReadyMessage::IRendererFactory | |
54 { | |
55 private: | |
56 const OrthancSlicesLoader::SliceImageReadyMessage& message_; | |
57 | |
58 public: | |
59 RendererFactory(const OrthancSlicesLoader::SliceImageReadyMessage& message) : | |
60 message_(message) | |
61 { | |
62 } | |
63 | |
64 virtual ILayerRenderer* CreateRenderer() const | |
65 { | |
66 bool isFull = (message_.GetEffectiveQuality() == SliceImageQuality_FullPng || | |
67 message_.GetEffectiveQuality() == SliceImageQuality_FullPam); | |
68 | |
69 return FrameRenderer::CreateRenderer(message_.GetImage(), message_.GetSlice(), isFull); | |
70 } | |
71 }; | |
72 | |
73 void DicomSeriesVolumeSlicer::OnSliceImageReady(const OrthancSlicesLoader::SliceImageReadyMessage& message) | |
74 { | |
75 // first notify that the pixel data of the frame is ready (targeted to, i.e: an image cache) | |
76 EmitMessage(FrameReadyMessage(*this, message.GetImage(), | |
77 message.GetEffectiveQuality(), message.GetSlice())); | |
78 | |
79 // then notify that the layer is ready for render | |
80 RendererFactory factory(message); | |
81 VolumeSlicerBase::NotifyLayerReady(factory, message.GetSlice().GetGeometry()); | |
82 } | |
83 | |
84 void DicomSeriesVolumeSlicer::OnSliceImageError(const OrthancSlicesLoader::SliceImageErrorMessage& message) | |
85 { | |
86 VolumeSlicerBase::NotifyLayerError(message.GetSlice().GetGeometry()); | |
87 } | |
88 | |
89 | |
90 DicomSeriesVolumeSlicer::DicomSeriesVolumeSlicer(MessageBroker& broker, OrthancApiClient& orthanc) : | |
91 VolumeSlicerBase(broker), | |
92 IObserver(broker), | |
93 loader_(broker, orthanc), | |
94 quality_(SliceImageQuality_FullPng) | |
95 { | |
96 loader_.RegisterObserverCallback(new Callable<DicomSeriesVolumeSlicer, OrthancSlicesLoader::SliceGeometryReadyMessage>(*this, &DicomSeriesVolumeSlicer::OnSliceGeometryReady)); | |
97 loader_.RegisterObserverCallback(new Callable<DicomSeriesVolumeSlicer, OrthancSlicesLoader::SliceGeometryErrorMessage>(*this, &DicomSeriesVolumeSlicer::OnSliceGeometryError)); | |
98 loader_.RegisterObserverCallback(new Callable<DicomSeriesVolumeSlicer, OrthancSlicesLoader::SliceImageReadyMessage>(*this, &DicomSeriesVolumeSlicer::OnSliceImageReady)); | |
99 loader_.RegisterObserverCallback(new Callable<DicomSeriesVolumeSlicer, OrthancSlicesLoader::SliceImageErrorMessage>(*this, &DicomSeriesVolumeSlicer::OnSliceImageError)); | |
100 } | |
101 | |
102 | |
103 void DicomSeriesVolumeSlicer::LoadSeries(const std::string& seriesId) | |
104 { | |
105 loader_.ScheduleLoadSeries(seriesId); | |
106 } | |
107 | |
108 | |
109 void DicomSeriesVolumeSlicer::LoadInstance(const std::string& instanceId) | |
110 { | |
111 loader_.ScheduleLoadInstance(instanceId); | |
112 } | |
113 | |
114 | |
115 void DicomSeriesVolumeSlicer::LoadFrame(const std::string& instanceId, | |
116 unsigned int frame) | |
117 { | |
118 loader_.ScheduleLoadFrame(instanceId, frame); | |
119 } | |
120 | |
121 | |
122 bool DicomSeriesVolumeSlicer::GetExtent(std::vector<Vector>& points, | |
123 const CoordinateSystem3D& viewportSlice) | |
124 { | |
125 size_t index; | |
126 | |
127 if (loader_.IsGeometryReady() && | |
128 loader_.LookupSlice(index, viewportSlice)) | |
129 { | |
130 loader_.GetSlice(index).GetExtent(points); | |
131 return true; | |
132 } | |
133 else | |
134 { | |
135 return false; | |
136 } | |
137 } | |
138 | |
139 | |
140 void DicomSeriesVolumeSlicer::ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice) | |
141 { | |
142 size_t index; | |
143 | |
144 if (loader_.IsGeometryReady() && | |
145 loader_.LookupSlice(index, viewportSlice)) | |
146 { | |
147 loader_.ScheduleLoadSliceImage(index, quality_); | |
148 } | |
149 } | |
150 } |