Mercurial > hg > orthanc-stone
annotate Framework/Toolbox/OrthancSlicesLoader.h @ 254:abc1c6231947 am-2
cleanup
author | am@osimis.io |
---|---|
date | Tue, 03 Jul 2018 11:49:02 +0200 |
parents | 40b21c1f8b8d |
children | 9afafb192180 |
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 | |
135
e2fe9352f240
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
120
diff
changeset
|
5 * Copyright (C) 2017-2018 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. | |
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 #pragma once | |
23 | |
24 #include "IWebService.h" | |
25 #include "SlicesSorter.h" | |
194
7a031ac16b2d
rename Enumerations.h to StoneEnumerations.h to avoid clashes with Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
26 #include "../StoneEnumerations.h" |
73 | 27 |
28 #include <boost/shared_ptr.hpp> | |
29 | |
30 namespace OrthancStone | |
31 { | |
32 class OrthancSlicesLoader : public boost::noncopyable | |
33 { | |
34 public: | |
252 | 35 struct SliceImageReadyMessage : public IMessage |
36 { | |
37 unsigned int sliceIndex_; | |
38 const Slice& slice_; | |
39 std::auto_ptr<Orthanc::ImageAccessor>& image_; | |
40 SliceImageQuality effectiveQuality_; | |
41 | |
42 SliceImageReadyMessage(unsigned int sliceIndex, | |
43 const Slice& slice, | |
44 std::auto_ptr<Orthanc::ImageAccessor>& image, | |
45 SliceImageQuality effectiveQuality) | |
46 : IMessage(MessageType_SliceImageReady), | |
47 sliceIndex_(sliceIndex), | |
48 slice_(slice), | |
49 image_(image), | |
50 effectiveQuality_(effectiveQuality) | |
51 { | |
52 } | |
53 }; | |
54 | |
55 struct SliceImageErrorMessage : public IMessage | |
56 { | |
57 const Slice& slice_; | |
58 unsigned int sliceIndex_; | |
59 SliceImageQuality effectiveQuality_; | |
60 | |
61 SliceImageErrorMessage(unsigned int sliceIndex, | |
62 const Slice& slice, | |
63 SliceImageQuality effectiveQuality) | |
64 : IMessage(MessageType_SliceImageError), | |
65 slice_(slice), | |
66 sliceIndex_(sliceIndex), | |
67 effectiveQuality_(effectiveQuality) | |
68 { | |
69 } | |
70 }; | |
71 | |
72 public: | |
73 class ISliceLoaderObserver : public IObserver | |
73 | 74 { |
75 public: | |
252 | 76 |
77 ISliceLoaderObserver(MessageBroker& broker) | |
78 : IObserver(broker) | |
73 | 79 { |
80 } | |
81 | |
252 | 82 virtual ~ISliceLoaderObserver() |
83 { | |
84 } | |
85 | |
86 virtual void HandleMessage(IObservable& from, const IMessage& message); | |
73 | 87 |
252 | 88 virtual void OnSliceGeometryReady(const OrthancSlicesLoader& loader) = 0; |
73 | 89 |
252 | 90 virtual void OnSliceGeometryError(const OrthancSlicesLoader& loader) = 0; |
91 | |
92 virtual void OnSliceImageReady(const OrthancSlicesLoader& loader, | |
73 | 93 unsigned int sliceIndex, |
94 const Slice& slice, | |
99 | 95 std::auto_ptr<Orthanc::ImageAccessor>& image, |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
96 SliceImageQuality effectiveQuality) = 0; |
73 | 97 |
252 | 98 virtual void OnSliceImageError(const OrthancSlicesLoader& loader, |
73 | 99 unsigned int sliceIndex, |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
100 const Slice& slice, |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
101 SliceImageQuality quality) = 0; |
73 | 102 }; |
103 | |
104 private: | |
105 enum State | |
106 { | |
107 State_Error, | |
108 State_Initialization, | |
109 State_LoadingGeometry, | |
110 State_GeometryReady | |
111 }; | |
112 | |
113 enum Mode | |
114 { | |
115 Mode_SeriesGeometry, | |
116 Mode_InstanceGeometry, | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
117 Mode_FrameGeometry, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
118 Mode_LoadImage, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
119 Mode_LoadRawImage |
73 | 120 }; |
121 | |
122 class Operation; | |
123 class WebCallback; | |
124 | |
125 boost::shared_ptr<WebCallback> webCallback_; // This is a PImpl pattern | |
126 | |
252 | 127 ISliceLoaderObserver& userCallback_; |
73 | 128 IWebService& orthanc_; |
129 State state_; | |
130 SlicesSorter slices_; | |
131 | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
132 void NotifySliceImageSuccess(const Operation& operation, |
99 | 133 std::auto_ptr<Orthanc::ImageAccessor>& image) const; |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
134 |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
135 void NotifySliceImageError(const Operation& operation) const; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
136 |
73 | 137 void ParseSeriesGeometry(const void* answer, |
138 size_t size); | |
139 | |
140 void ParseInstanceGeometry(const std::string& instanceId, | |
141 const void* answer, | |
142 size_t size); | |
143 | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
144 void ParseFrameGeometry(const std::string& instanceId, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
145 unsigned int frame, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
146 const void* answer, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
147 size_t size); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
148 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
149 void ParseSliceImagePng(const Operation& operation, |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
150 const void* answer, |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
151 size_t size); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
152 |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
153 void ParseSliceImageJpeg(const Operation& operation, |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
154 const void* answer, |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
155 size_t size); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
156 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
157 void ParseSliceRawImage(const Operation& operation, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
158 const void* answer, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
159 size_t size); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
160 |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
161 void ScheduleSliceImagePng(const Slice& slice, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
162 size_t index); |
73 | 163 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
164 void ScheduleSliceImageJpeg(const Slice& slice, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
165 size_t index, |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
166 SliceImageQuality quality); |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
167 |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
168 void SortAndFinalizeSlices(); |
73 | 169 |
170 public: | |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
194
diff
changeset
|
171 OrthancSlicesLoader(MessageBroker& broker, |
252 | 172 ISliceLoaderObserver& callback, |
73 | 173 IWebService& orthanc); |
174 | |
175 void ScheduleLoadSeries(const std::string& seriesId); | |
176 | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
177 void ScheduleLoadInstance(const std::string& instanceId); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
178 |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
179 void ScheduleLoadFrame(const std::string& instanceId, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
180 unsigned int frame); |
73 | 181 |
77 | 182 bool IsGeometryReady() const; |
183 | |
73 | 184 size_t GetSliceCount() const; |
185 | |
186 const Slice& GetSlice(size_t index) const; | |
187 | |
77 | 188 bool LookupSlice(size_t& index, |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
189 const CoordinateSystem3D& plane) const; |
77 | 190 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
191 void ScheduleLoadSliceImage(size_t index, |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
192 SliceImageQuality requestedQuality); |
73 | 193 }; |
194 } |