Mercurial > hg > orthanc-stone
annotate Framework/Toolbox/OrthancSlicesLoader.h @ 627:b7fd0471281c am-dev
fix CodeGeneration unit tests
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Wed, 08 May 2019 10:51:41 +0200 |
parents | b70e9be013e4 |
children | f0008c55e5f7 |
rev | line source |
---|---|
73 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
73 | 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. | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
16 * |
73 | 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 #pragma once | |
23 | |
378 | 24 #include "../Messages/IObservable.h" |
194
7a031ac16b2d
rename Enumerations.h to StoneEnumerations.h to avoid clashes with Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
25 #include "../StoneEnumerations.h" |
378 | 26 #include "IWebService.h" |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
27 #include "OrthancApiClient.h" |
378 | 28 #include "SlicesSorter.h" |
29 | |
30 #include <Core/Images/Image.h> | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
31 |
73 | 32 |
33 namespace OrthancStone | |
34 { | |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
35 class OrthancSlicesLoader : public IObservable, public IObserver |
73 | 36 { |
37 public: | |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
268
diff
changeset
|
38 |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
268
diff
changeset
|
39 typedef OriginMessage<MessageType_SliceLoader_GeometryReady, OrthancSlicesLoader> SliceGeometryReadyMessage; |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
268
diff
changeset
|
40 typedef OriginMessage<MessageType_SliceLoader_GeometryError, OrthancSlicesLoader> SliceGeometryErrorMessage; |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
268
diff
changeset
|
41 |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
42 class SliceImageReadyMessage : |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
43 public OriginMessage<MessageType_SliceLoader_ImageReady, OrthancSlicesLoader> |
252 | 44 { |
378 | 45 private: |
46 unsigned int sliceIndex_; | |
47 const Slice& slice_; | |
48 const Orthanc::ImageAccessor& image_; | |
49 SliceImageQuality effectiveQuality_; | |
252 | 50 |
378 | 51 public: |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
52 SliceImageReadyMessage(const OrthancSlicesLoader& origin, |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
53 unsigned int sliceIndex, |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
54 const Slice& slice, |
378 | 55 const Orthanc::ImageAccessor& image, |
56 SliceImageQuality effectiveQuality) : | |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
57 OriginMessage(origin), |
378 | 58 sliceIndex_(sliceIndex), |
59 slice_(slice), | |
60 image_(image), | |
61 effectiveQuality_(effectiveQuality) | |
252 | 62 { |
63 } | |
378 | 64 |
65 unsigned int GetSliceIndex() const | |
66 { | |
67 return sliceIndex_; | |
68 } | |
69 | |
70 const Slice& GetSlice() const | |
71 { | |
72 return slice_; | |
73 } | |
252 | 74 |
378 | 75 const Orthanc::ImageAccessor& GetImage() const |
76 { | |
77 return image_; | |
78 } | |
79 | |
80 SliceImageQuality GetEffectiveQuality() const | |
81 { | |
82 return effectiveQuality_; | |
83 } | |
84 }; | |
85 | |
86 | |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
87 class SliceImageErrorMessage : |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
88 public OriginMessage<MessageType_SliceLoader_ImageError, OrthancSlicesLoader> |
252 | 89 { |
378 | 90 private: |
91 const Slice& slice_; | |
92 unsigned int sliceIndex_; | |
93 SliceImageQuality effectiveQuality_; | |
252 | 94 |
378 | 95 public: |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
96 SliceImageErrorMessage(const OrthancSlicesLoader& origin, |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
97 unsigned int sliceIndex, |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
98 const Slice& slice, |
378 | 99 SliceImageQuality effectiveQuality) : |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
100 OriginMessage(origin), |
378 | 101 slice_(slice), |
102 sliceIndex_(sliceIndex), | |
103 effectiveQuality_(effectiveQuality) | |
252 | 104 { |
105 } | |
378 | 106 unsigned int GetSliceIndex() const |
107 { | |
108 return sliceIndex_; | |
109 } | |
110 | |
111 const Slice& GetSlice() const | |
112 { | |
113 return slice_; | |
114 } | |
115 | |
116 SliceImageQuality GetEffectiveQuality() const | |
117 { | |
118 return effectiveQuality_; | |
119 } | |
252 | 120 }; |
73 | 121 |
122 private: | |
123 enum State | |
124 { | |
125 State_Error, | |
126 State_Initialization, | |
127 State_LoadingGeometry, | |
128 State_GeometryReady | |
129 }; | |
130 | |
131 enum Mode | |
132 { | |
133 Mode_SeriesGeometry, | |
134 Mode_InstanceGeometry, | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
135 Mode_FrameGeometry, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
136 Mode_LoadImage, |
257 | 137 Mode_LoadRawImage, |
138 Mode_LoadDicomFile | |
73 | 139 }; |
140 | |
141 class Operation; | |
142 | |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
143 OrthancApiClient& orthanc_; |
73 | 144 State state_; |
145 SlicesSorter slices_; | |
146 | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
147 void NotifySliceImageSuccess(const Operation& operation, |
378 | 148 const Orthanc::ImageAccessor& image); |
149 | |
268
5bd4161bf11b
removed constness of the observable when emitting a message
am@osimis.io
parents:
267
diff
changeset
|
150 void NotifySliceImageError(const Operation& operation); |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
151 |
382
dd4c7e82b4be
removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
152 void OnGeometryError(const IWebService::HttpRequestErrorMessage& message); |
dd4c7e82b4be
removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
153 |
dd4c7e82b4be
removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
154 void OnSliceImageError(const IWebService::HttpRequestErrorMessage& message); |
73 | 155 |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
156 void ParseSeriesGeometry(const OrthancApiClient::JsonResponseReadyMessage& message); |
73 | 157 |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
158 void ParseInstanceGeometry(const OrthancApiClient::JsonResponseReadyMessage& message); |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
159 |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
160 void ParseFrameGeometry(const OrthancApiClient::JsonResponseReadyMessage& message); |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
161 |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
162 void ParseSliceImagePng(const OrthancApiClient::BinaryResponseReadyMessage& message); |
257 | 163 |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
164 void ParseSliceImagePam(const OrthancApiClient::BinaryResponseReadyMessage& message); |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
165 |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
166 void ParseSliceImageJpeg(const OrthancApiClient::JsonResponseReadyMessage& message); |
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
167 |
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
168 void ParseSliceRawImage(const OrthancApiClient::BinaryResponseReadyMessage& message); |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
169 |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
170 void ScheduleSliceImagePng(const Slice& slice, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
171 size_t index); |
257 | 172 |
173 void ScheduleSliceImagePam(const Slice& slice, | |
174 size_t index); | |
175 | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
176 void ScheduleSliceImageJpeg(const Slice& slice, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
177 size_t index, |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
178 SliceImageQuality quality); |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
179 |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
180 void SortAndFinalizeSlices(); |
73 | 181 |
182 public: | |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
194
diff
changeset
|
183 OrthancSlicesLoader(MessageBroker& broker, |
266
c9cf95b49a86
removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents:
262
diff
changeset
|
184 //ISliceLoaderObserver& callback, |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
185 OrthancApiClient& orthancApi); |
73 | 186 |
187 void ScheduleLoadSeries(const std::string& seriesId); | |
188 | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
189 void ScheduleLoadInstance(const std::string& instanceId); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
190 |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
191 void ScheduleLoadFrame(const std::string& instanceId, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
192 unsigned int frame); |
73 | 193 |
77 | 194 bool IsGeometryReady() const; |
195 | |
73 | 196 size_t GetSliceCount() const; |
197 | |
198 const Slice& GetSlice(size_t index) const; | |
199 | |
77 | 200 bool LookupSlice(size_t& index, |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
201 const CoordinateSystem3D& plane) const; |
77 | 202 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
203 void ScheduleLoadSliceImage(size_t index, |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
204 SliceImageQuality requestedQuality); |
73 | 205 }; |
206 } |