Mercurial > hg > orthanc-stone
annotate Framework/Deprecated/Toolbox/OrthancSlicesLoader.h @ 886:5cfb479fdbde am-dev
fix BasicScene WASM sample
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Tue, 09 Jul 2019 17:36:47 +0200 |
parents | be9c1530d40a |
children | b537002f83a9 2d8ab34c8c91 |
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 | |
732
c35e98d22764
move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
726
diff
changeset
|
24 #include "../../Messages/IObservable.h" |
c35e98d22764
move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
726
diff
changeset
|
25 #include "../../StoneEnumerations.h" |
736
c0fcb2757b0a
enforce relative includes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
26 #include "../../Toolbox/SlicesSorter.h" |
378 | 27 #include "IWebService.h" |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
28 #include "OrthancApiClient.h" |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
643
diff
changeset
|
29 #include "Slice.h" |
378 | 30 |
31 #include <Core/Images/Image.h> | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
32 |
73 | 33 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
34 namespace Deprecated |
73 | 35 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
36 class OrthancSlicesLoader : public OrthancStone::IObservable, public OrthancStone::IObserver |
73 | 37 { |
38 public: | |
643
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
39 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, SliceGeometryReadyMessage, OrthancSlicesLoader); |
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
40 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, SliceGeometryErrorMessage, OrthancSlicesLoader); |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
268
diff
changeset
|
41 |
643
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
42 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
43 class SliceImageReadyMessage : public OrthancStone::OriginMessage<OrthancSlicesLoader> |
252 | 44 { |
643
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
45 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); |
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
46 |
378 | 47 private: |
48 unsigned int sliceIndex_; | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
49 const Slice& slice_; |
378 | 50 const Orthanc::ImageAccessor& image_; |
739
be9c1530d40a
deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
736
diff
changeset
|
51 SliceImageQuality effectiveQuality_; |
252 | 52 |
378 | 53 public: |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
54 SliceImageReadyMessage(const OrthancSlicesLoader& origin, |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
55 unsigned int sliceIndex, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
56 const Slice& slice, |
378 | 57 const Orthanc::ImageAccessor& image, |
739
be9c1530d40a
deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
736
diff
changeset
|
58 SliceImageQuality effectiveQuality) : |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
59 OriginMessage(origin), |
378 | 60 sliceIndex_(sliceIndex), |
61 slice_(slice), | |
62 image_(image), | |
63 effectiveQuality_(effectiveQuality) | |
252 | 64 { |
65 } | |
378 | 66 |
67 unsigned int GetSliceIndex() const | |
68 { | |
69 return sliceIndex_; | |
70 } | |
71 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
72 const Slice& GetSlice() const |
378 | 73 { |
74 return slice_; | |
75 } | |
252 | 76 |
378 | 77 const Orthanc::ImageAccessor& GetImage() const |
78 { | |
79 return image_; | |
80 } | |
81 | |
739
be9c1530d40a
deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
736
diff
changeset
|
82 SliceImageQuality GetEffectiveQuality() const |
378 | 83 { |
84 return effectiveQuality_; | |
85 } | |
86 }; | |
87 | |
88 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
89 class SliceImageErrorMessage : public OrthancStone::OriginMessage<OrthancSlicesLoader> |
252 | 90 { |
643
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
91 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); |
f0008c55e5f7
getting rid of MessageType enumeration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
92 |
378 | 93 private: |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
94 const Slice& slice_; |
378 | 95 unsigned int sliceIndex_; |
739
be9c1530d40a
deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
736
diff
changeset
|
96 SliceImageQuality effectiveQuality_; |
252 | 97 |
378 | 98 public: |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
99 SliceImageErrorMessage(const OrthancSlicesLoader& origin, |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
100 unsigned int sliceIndex, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
101 const Slice& slice, |
739
be9c1530d40a
deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
736
diff
changeset
|
102 SliceImageQuality effectiveQuality) : |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
382
diff
changeset
|
103 OriginMessage(origin), |
378 | 104 slice_(slice), |
105 sliceIndex_(sliceIndex), | |
106 effectiveQuality_(effectiveQuality) | |
252 | 107 { |
108 } | |
378 | 109 unsigned int GetSliceIndex() const |
110 { | |
111 return sliceIndex_; | |
112 } | |
113 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
114 const Slice& GetSlice() const |
378 | 115 { |
116 return slice_; | |
117 } | |
118 | |
739
be9c1530d40a
deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
736
diff
changeset
|
119 SliceImageQuality GetEffectiveQuality() const |
378 | 120 { |
121 return effectiveQuality_; | |
122 } | |
252 | 123 }; |
73 | 124 |
125 private: | |
126 enum State | |
127 { | |
128 State_Error, | |
129 State_Initialization, | |
130 State_LoadingGeometry, | |
131 State_GeometryReady | |
132 }; | |
133 | |
134 enum Mode | |
135 { | |
136 Mode_SeriesGeometry, | |
137 Mode_InstanceGeometry, | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
138 Mode_FrameGeometry, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
139 Mode_LoadImage, |
257 | 140 Mode_LoadRawImage, |
141 Mode_LoadDicomFile | |
73 | 142 }; |
143 | |
144 class Operation; | |
145 | |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
146 OrthancApiClient& orthanc_; |
73 | 147 State state_; |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
148 OrthancStone::SlicesSorter slices_; |
73 | 149 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
150 void NotifySliceImageSuccess(const Operation& operation, |
378 | 151 const Orthanc::ImageAccessor& image); |
152 | |
268
5bd4161bf11b
removed constness of the observable when emitting a message
am@osimis.io
parents:
267
diff
changeset
|
153 void NotifySliceImageError(const Operation& operation); |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
154 |
382
dd4c7e82b4be
removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
155 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
|
156 |
dd4c7e82b4be
removed class OrthancApiClient::HttpErrorMessage, redundant with IWebService::HttpRequestErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
157 void OnSliceImageError(const IWebService::HttpRequestErrorMessage& message); |
73 | 158 |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
159 void ParseSeriesGeometry(const OrthancApiClient::JsonResponseReadyMessage& message); |
73 | 160 |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
161 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
|
162 |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
163 void ParseFrameGeometry(const OrthancApiClient::JsonResponseReadyMessage& message); |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
164 |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
165 void ParseSliceImagePng(const OrthancApiClient::BinaryResponseReadyMessage& message); |
257 | 166 |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
167 void ParseSliceImagePam(const OrthancApiClient::BinaryResponseReadyMessage& message); |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
168 |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
169 void ParseSliceImageJpeg(const OrthancApiClient::JsonResponseReadyMessage& message); |
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
170 |
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
171 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
|
172 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
173 void ScheduleSliceImagePng(const Slice& slice, |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
174 size_t index); |
257 | 175 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
176 void ScheduleSliceImagePam(const Slice& slice, |
257 | 177 size_t index); |
178 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
179 void ScheduleSliceImageJpeg(const Slice& slice, |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
180 size_t index, |
739
be9c1530d40a
deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
736
diff
changeset
|
181 SliceImageQuality quality); |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
182 |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
183 void SortAndFinalizeSlices(); |
73 | 184 |
185 public: | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
186 OrthancSlicesLoader(OrthancStone::MessageBroker& broker, |
266
c9cf95b49a86
removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents:
262
diff
changeset
|
187 //ISliceLoaderObserver& callback, |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
188 OrthancApiClient& orthancApi); |
73 | 189 |
190 void ScheduleLoadSeries(const std::string& seriesId); | |
191 | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
192 void ScheduleLoadInstance(const std::string& instanceId); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
193 |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
194 void ScheduleLoadFrame(const std::string& instanceId, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
195 unsigned int frame); |
73 | 196 |
77 | 197 bool IsGeometryReady() const; |
198 | |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
643
diff
changeset
|
199 size_t GetSlicesCount() const; |
73 | 200 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
201 const Slice& GetSlice(size_t index) const; |
73 | 202 |
77 | 203 bool LookupSlice(size_t& index, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
204 const OrthancStone::CoordinateSystem3D& plane) const; |
77 | 205 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
206 void ScheduleLoadSliceImage(size_t index, |
739
be9c1530d40a
deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
736
diff
changeset
|
207 SliceImageQuality requestedQuality); |
73 | 208 }; |
209 } |