comparison Framework/Deprecated/Toolbox/OrthancSlicesLoader.h @ 732:c35e98d22764

move Deprecated classes to a separate folder
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 21 May 2019 14:27:35 +0200
parents Framework/Toolbox/OrthancSlicesLoader.h@4f2416d519b4
children c0fcb2757b0a
comparison
equal deleted inserted replaced
729:529189f399ec 732:c35e98d22764
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-2019 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 #pragma once
23
24 #include "../../Messages/IObservable.h"
25 #include "../../StoneEnumerations.h"
26 #include "IWebService.h"
27 #include "OrthancApiClient.h"
28 #include "../../Toolbox/SlicesSorter.h"
29 #include "Slice.h"
30
31 #include <Core/Images/Image.h>
32
33
34 namespace Deprecated
35 {
36 class OrthancSlicesLoader : public OrthancStone::IObservable, public OrthancStone::IObserver
37 {
38 public:
39 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, SliceGeometryReadyMessage, OrthancSlicesLoader);
40 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, SliceGeometryErrorMessage, OrthancSlicesLoader);
41
42
43 class SliceImageReadyMessage : public OrthancStone::OriginMessage<OrthancSlicesLoader>
44 {
45 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__);
46
47 private:
48 unsigned int sliceIndex_;
49 const Slice& slice_;
50 const Orthanc::ImageAccessor& image_;
51 OrthancStone::SliceImageQuality effectiveQuality_;
52
53 public:
54 SliceImageReadyMessage(const OrthancSlicesLoader& origin,
55 unsigned int sliceIndex,
56 const Slice& slice,
57 const Orthanc::ImageAccessor& image,
58 OrthancStone::SliceImageQuality effectiveQuality) :
59 OriginMessage(origin),
60 sliceIndex_(sliceIndex),
61 slice_(slice),
62 image_(image),
63 effectiveQuality_(effectiveQuality)
64 {
65 }
66
67 unsigned int GetSliceIndex() const
68 {
69 return sliceIndex_;
70 }
71
72 const Slice& GetSlice() const
73 {
74 return slice_;
75 }
76
77 const Orthanc::ImageAccessor& GetImage() const
78 {
79 return image_;
80 }
81
82 OrthancStone::SliceImageQuality GetEffectiveQuality() const
83 {
84 return effectiveQuality_;
85 }
86 };
87
88
89 class SliceImageErrorMessage : public OrthancStone::OriginMessage<OrthancSlicesLoader>
90 {
91 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__);
92
93 private:
94 const Slice& slice_;
95 unsigned int sliceIndex_;
96 OrthancStone::SliceImageQuality effectiveQuality_;
97
98 public:
99 SliceImageErrorMessage(const OrthancSlicesLoader& origin,
100 unsigned int sliceIndex,
101 const Slice& slice,
102 OrthancStone::SliceImageQuality effectiveQuality) :
103 OriginMessage(origin),
104 slice_(slice),
105 sliceIndex_(sliceIndex),
106 effectiveQuality_(effectiveQuality)
107 {
108 }
109 unsigned int GetSliceIndex() const
110 {
111 return sliceIndex_;
112 }
113
114 const Slice& GetSlice() const
115 {
116 return slice_;
117 }
118
119 OrthancStone::SliceImageQuality GetEffectiveQuality() const
120 {
121 return effectiveQuality_;
122 }
123 };
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,
138 Mode_FrameGeometry,
139 Mode_LoadImage,
140 Mode_LoadRawImage,
141 Mode_LoadDicomFile
142 };
143
144 class Operation;
145
146 OrthancApiClient& orthanc_;
147 State state_;
148 OrthancStone::SlicesSorter slices_;
149
150 void NotifySliceImageSuccess(const Operation& operation,
151 const Orthanc::ImageAccessor& image);
152
153 void NotifySliceImageError(const Operation& operation);
154
155 void OnGeometryError(const IWebService::HttpRequestErrorMessage& message);
156
157 void OnSliceImageError(const IWebService::HttpRequestErrorMessage& message);
158
159 void ParseSeriesGeometry(const OrthancApiClient::JsonResponseReadyMessage& message);
160
161 void ParseInstanceGeometry(const OrthancApiClient::JsonResponseReadyMessage& message);
162
163 void ParseFrameGeometry(const OrthancApiClient::JsonResponseReadyMessage& message);
164
165 void ParseSliceImagePng(const OrthancApiClient::BinaryResponseReadyMessage& message);
166
167 void ParseSliceImagePam(const OrthancApiClient::BinaryResponseReadyMessage& message);
168
169 void ParseSliceImageJpeg(const OrthancApiClient::JsonResponseReadyMessage& message);
170
171 void ParseSliceRawImage(const OrthancApiClient::BinaryResponseReadyMessage& message);
172
173 void ScheduleSliceImagePng(const Slice& slice,
174 size_t index);
175
176 void ScheduleSliceImagePam(const Slice& slice,
177 size_t index);
178
179 void ScheduleSliceImageJpeg(const Slice& slice,
180 size_t index,
181 OrthancStone::SliceImageQuality quality);
182
183 void SortAndFinalizeSlices();
184
185 public:
186 OrthancSlicesLoader(OrthancStone::MessageBroker& broker,
187 //ISliceLoaderObserver& callback,
188 OrthancApiClient& orthancApi);
189
190 void ScheduleLoadSeries(const std::string& seriesId);
191
192 void ScheduleLoadInstance(const std::string& instanceId);
193
194 void ScheduleLoadFrame(const std::string& instanceId,
195 unsigned int frame);
196
197 bool IsGeometryReady() const;
198
199 size_t GetSlicesCount() const;
200
201 const Slice& GetSlice(size_t index) const;
202
203 bool LookupSlice(size_t& index,
204 const OrthancStone::CoordinateSystem3D& plane) const;
205
206 void ScheduleLoadSliceImage(size_t index,
207 OrthancStone::SliceImageQuality requestedQuality);
208 };
209 }