Mercurial > hg > orthanc-stone
annotate Deprecated/Samples/WebAssembly/BasicMPR.cpp @ 1452:ce167e076be4 loader-injection-feature
Work is done
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 02 Jun 2020 17:10:40 +0200 |
parents | 65e1e4b08302 |
children |
rev | line source |
---|---|
820 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
835
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
820 | 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 | |
826 | 23 #include "dev.h" |
24 | |
820 | 25 #include <emscripten.h> |
26 | |
27 #include "../../Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h" | |
824
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
28 #include "../../Framework/Oracle/SleepOracleCommand.h" |
825 | 29 #include "../../Framework/Oracle/WebAssemblyOracle.h" |
820 | 30 #include "../../Framework/Scene2D/GrayscaleStyleConfigurator.h" |
31 #include "../../Framework/StoneInitialization.h" | |
32 #include "../../Framework/Volumes/VolumeSceneLayerSource.h" | |
33 | |
34 | |
35 namespace OrthancStone | |
36 { | |
826 | 37 class VolumeSlicerWidget : public IObserver |
820 | 38 { |
39 private: | |
40 OrthancStone::WebAssemblyViewport viewport_; | |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
41 std::unique_ptr<VolumeSceneLayerSource> source_; |
820 | 42 VolumeProjection projection_; |
43 std::vector<CoordinateSystem3D> planes_; | |
44 size_t currentPlane_; | |
45 | |
46 void Handle(const DicomVolumeImage::GeometryReadyMessage& message) | |
47 { | |
48 LOG(INFO) << "Geometry is available"; | |
49 | |
50 const VolumeImageGeometry& geometry = message.GetOrigin().GetGeometry(); | |
51 | |
52 const unsigned int depth = geometry.GetProjectionDepth(projection_); | |
53 currentPlane_ = depth / 2; | |
54 | |
55 planes_.resize(depth); | |
56 | |
57 for (unsigned int z = 0; z < depth; z++) | |
58 { | |
59 planes_[z] = geometry.GetProjectionSlice(projection_, z); | |
60 } | |
822 | 61 |
62 Refresh(); | |
63 | |
64 viewport_.FitContent(); | |
820 | 65 } |
66 | |
67 public: | |
826 | 68 VolumeSlicerWidget(MessageBroker& broker, |
820 | 69 const std::string& canvas, |
70 VolumeProjection projection) : | |
71 IObserver(broker), | |
72 viewport_(broker, canvas), | |
73 projection_(projection), | |
74 currentPlane_(0) | |
75 { | |
76 } | |
77 | |
78 void UpdateSize() | |
79 { | |
80 viewport_.UpdateSize(); | |
81 } | |
82 | |
83 void SetSlicer(int layerDepth, | |
84 const boost::shared_ptr<IVolumeSlicer>& slicer, | |
85 IObservable& loader, | |
86 ILayerStyleConfigurator* configurator) | |
87 { | |
88 if (source_.get() != NULL) | |
89 { | |
90 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls, | |
91 "Only one slicer can be registered"); | |
92 } | |
93 | |
94 loader.RegisterObserverCallback( | |
826 | 95 new Callable<VolumeSlicerWidget, DicomVolumeImage::GeometryReadyMessage> |
96 (*this, &VolumeSlicerWidget::Handle)); | |
820 | 97 |
98 source_.reset(new VolumeSceneLayerSource(viewport_.GetScene(), layerDepth, slicer)); | |
99 | |
100 if (configurator != NULL) | |
101 { | |
102 source_->SetConfigurator(configurator); | |
103 } | |
104 } | |
105 | |
106 void Refresh() | |
107 { | |
108 if (source_.get() != NULL && | |
109 currentPlane_ < planes_.size()) | |
110 { | |
111 source_->Update(planes_[currentPlane_]); | |
822 | 112 viewport_.Refresh(); |
820 | 113 } |
114 } | |
823 | 115 |
826 | 116 size_t GetSlicesCount() const |
117 { | |
118 return planes_.size(); | |
119 } | |
120 | |
823 | 121 void Scroll(int delta) |
122 { | |
123 if (!planes_.empty()) | |
124 { | |
125 int tmp = static_cast<int>(currentPlane_) + delta; | |
126 unsigned int next; | |
127 | |
128 if (tmp < 0) | |
129 { | |
130 next = 0; | |
131 } | |
132 else if (tmp >= static_cast<int>(planes_.size())) | |
133 { | |
134 next = planes_.size() - 1; | |
135 } | |
136 else | |
137 { | |
138 next = static_cast<size_t>(tmp); | |
139 } | |
140 | |
141 if (next != currentPlane_) | |
142 { | |
143 currentPlane_ = next; | |
144 Refresh(); | |
145 } | |
146 } | |
147 } | |
820 | 148 }; |
149 } | |
150 | |
151 | |
152 | |
153 | |
154 boost::shared_ptr<OrthancStone::DicomVolumeImage> ct_(new OrthancStone::DicomVolumeImage); | |
155 | |
156 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> loader_; | |
157 | |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
158 std::unique_ptr<OrthancStone::VolumeSlicerWidget> widget1_; |
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
159 std::unique_ptr<OrthancStone::VolumeSlicerWidget> widget2_; |
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
160 std::unique_ptr<OrthancStone::VolumeSlicerWidget> widget3_; |
820 | 161 |
162 OrthancStone::MessageBroker broker_; | |
163 OrthancStone::WebAssemblyOracle oracle_(broker_); | |
164 | |
165 | |
166 EM_BOOL OnWindowResize(int eventType, const EmscriptenUiEvent *uiEvent, void *userData) | |
167 { | |
168 try | |
169 { | |
826 | 170 if (widget1_.get() != NULL) |
820 | 171 { |
826 | 172 widget1_->UpdateSize(); |
820 | 173 } |
174 | |
826 | 175 if (widget2_.get() != NULL) |
820 | 176 { |
826 | 177 widget2_->UpdateSize(); |
820 | 178 } |
179 | |
826 | 180 if (widget3_.get() != NULL) |
820 | 181 { |
826 | 182 widget3_->UpdateSize(); |
820 | 183 } |
184 } | |
185 catch (Orthanc::OrthancException& e) | |
186 { | |
187 LOG(ERROR) << "Exception while updating canvas size: " << e.What(); | |
188 } | |
189 | |
190 return true; | |
191 } | |
192 | |
193 | |
194 | |
195 | |
196 EM_BOOL OnAnimationFrame(double time, void *userData) | |
197 { | |
198 try | |
199 { | |
826 | 200 if (widget1_.get() != NULL) |
820 | 201 { |
826 | 202 widget1_->Refresh(); |
820 | 203 } |
204 | |
826 | 205 if (widget2_.get() != NULL) |
820 | 206 { |
826 | 207 widget2_->Refresh(); |
820 | 208 } |
209 | |
826 | 210 if (widget3_.get() != NULL) |
820 | 211 { |
826 | 212 widget3_->Refresh(); |
820 | 213 } |
214 | |
215 return true; | |
216 } | |
217 catch (Orthanc::OrthancException& e) | |
218 { | |
219 LOG(ERROR) << "Exception in the animation loop, stopping now: " << e.What(); | |
220 return false; | |
221 } | |
222 } | |
223 | |
224 | |
823 | 225 static bool ctrlDown_ = false; |
226 | |
227 | |
228 EM_BOOL OnMouseWheel(int eventType, | |
229 const EmscriptenWheelEvent *wheelEvent, | |
230 void *userData) | |
231 { | |
232 try | |
233 { | |
234 if (userData != NULL) | |
235 { | |
236 int delta = 0; | |
237 | |
238 if (wheelEvent->deltaY < 0) | |
239 { | |
240 delta = -1; | |
241 } | |
242 | |
243 if (wheelEvent->deltaY > 0) | |
244 { | |
245 delta = 1; | |
246 } | |
247 | |
826 | 248 OrthancStone::VolumeSlicerWidget& widget = |
249 *reinterpret_cast<OrthancStone::VolumeSlicerWidget*>(userData); | |
250 | |
823 | 251 if (ctrlDown_) |
252 { | |
826 | 253 delta *= static_cast<int>(widget.GetSlicesCount() / 10); |
823 | 254 } |
826 | 255 |
256 widget.Scroll(delta); | |
823 | 257 } |
258 } | |
259 catch (Orthanc::OrthancException& e) | |
260 { | |
261 LOG(ERROR) << "Exception in the wheel event: " << e.What(); | |
262 } | |
263 | |
264 return true; | |
265 } | |
266 | |
267 | |
826 | 268 EM_BOOL OnKeyDown(int eventType, |
269 const EmscriptenKeyboardEvent *keyEvent, | |
270 void *userData) | |
823 | 271 { |
272 ctrlDown_ = keyEvent->ctrlKey; | |
273 return false; | |
274 } | |
275 | |
276 | |
826 | 277 EM_BOOL OnKeyUp(int eventType, |
278 const EmscriptenKeyboardEvent *keyEvent, | |
279 void *userData) | |
280 { | |
281 ctrlDown_ = false; | |
282 return false; | |
283 } | |
284 | |
285 | |
823 | 286 |
287 | |
824
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
288 namespace OrthancStone |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
289 { |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
290 class TestSleep : public IObserver |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
291 { |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
292 private: |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
293 WebAssemblyOracle& oracle_; |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
294 |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
295 void Schedule() |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
296 { |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
297 oracle_.Schedule(*this, new OrthancStone::SleepOracleCommand(2000)); |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
298 } |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
299 |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
300 void Handle(const SleepOracleCommand::TimeoutMessage& message) |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
301 { |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
302 LOG(INFO) << "TIMEOUT"; |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
303 Schedule(); |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
304 } |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
305 |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
306 public: |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
307 TestSleep(MessageBroker& broker, |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
308 WebAssemblyOracle& oracle) : |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
309 IObserver(broker), |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
310 oracle_(oracle) |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
311 { |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
312 oracle.RegisterObserverCallback( |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
313 new Callable<TestSleep, SleepOracleCommand::TimeoutMessage> |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
314 (*this, &TestSleep::Handle)); |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
315 |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
316 LOG(INFO) << "STARTING"; |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
317 Schedule(); |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
318 } |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
319 }; |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
320 |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
321 //static TestSleep testSleep(broker_, oracle_); |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
322 } |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
323 |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
324 |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
325 |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
326 static std::map<std::string, std::string> arguments_; |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
327 |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
328 static bool GetArgument(std::string& value, |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
329 const std::string& key) |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
330 { |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
331 std::map<std::string, std::string>::const_iterator found = arguments_.find(key); |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
332 |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
333 if (found == arguments_.end()) |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
334 { |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
335 return false; |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
336 } |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
337 else |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
338 { |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
339 value = found->second; |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
340 return true; |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
341 } |
824
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
342 } |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
343 |
15d493101c1e
support of SleepOracleCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
823
diff
changeset
|
344 |
820 | 345 extern "C" |
346 { | |
347 int main(int argc, char const *argv[]) | |
348 { | |
349 OrthancStone::StoneInitialize(); | |
350 Orthanc::Logging::EnableInfoLevel(true); | |
351 // Orthanc::Logging::EnableTraceLevel(true); | |
352 EM_ASM(window.dispatchEvent(new CustomEvent("WebAssemblyLoaded"));); | |
353 } | |
354 | |
355 EMSCRIPTEN_KEEPALIVE | |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
356 void SetArgument(const char* key, const char* value) |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
357 { |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
358 // This is called for each GET argument (cf. "app.js") |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
359 LOG(INFO) << "Received GET argument: [" << key << "] = [" << value << "]"; |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
360 arguments_[key] = value; |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
361 } |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
362 |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
363 EMSCRIPTEN_KEEPALIVE |
820 | 364 void Initialize() |
365 { | |
366 try | |
367 { | |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
368 oracle_.SetOrthancRoot(".."); |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
369 |
820 | 370 loader_.reset(new OrthancStone::OrthancSeriesVolumeProgressiveLoader(ct_, oracle_, oracle_)); |
371 | |
826 | 372 widget1_.reset(new OrthancStone::VolumeSlicerWidget(broker_, "mycanvas1", OrthancStone::VolumeProjection_Axial)); |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
373 { |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
374 std::unique_ptr<OrthancStone::GrayscaleStyleConfigurator> style(new OrthancStone::GrayscaleStyleConfigurator); |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
375 style->SetLinearInterpolation(true); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
376 style->SetWindowing(OrthancStone::ImageWindowing_Bone); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
377 widget1_->SetSlicer(0, loader_, *loader_, style.release()); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
378 } |
826 | 379 widget1_->UpdateSize(); |
820 | 380 |
826 | 381 widget2_.reset(new OrthancStone::VolumeSlicerWidget(broker_, "mycanvas2", OrthancStone::VolumeProjection_Coronal)); |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
382 { |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
383 std::unique_ptr<OrthancStone::GrayscaleStyleConfigurator> style(new OrthancStone::GrayscaleStyleConfigurator); |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
384 style->SetLinearInterpolation(true); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
385 style->SetWindowing(OrthancStone::ImageWindowing_Bone); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
386 widget2_->SetSlicer(0, loader_, *loader_, style.release()); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
387 } |
826 | 388 widget2_->UpdateSize(); |
820 | 389 |
826 | 390 widget3_.reset(new OrthancStone::VolumeSlicerWidget(broker_, "mycanvas3", OrthancStone::VolumeProjection_Sagittal)); |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
391 { |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
392 std::unique_ptr<OrthancStone::GrayscaleStyleConfigurator> style(new OrthancStone::GrayscaleStyleConfigurator); |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
393 style->SetLinearInterpolation(true); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
394 style->SetWindowing(OrthancStone::ImageWindowing_Bone); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
395 widget3_->SetSlicer(0, loader_, *loader_, style.release()); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
396 } |
826 | 397 widget3_->UpdateSize(); |
820 | 398 |
1370
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1348
diff
changeset
|
399 emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, false, OnWindowResize); // DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 !! |
823 | 400 |
1370
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1348
diff
changeset
|
401 emscripten_set_wheel_callback("#mycanvas1", widget1_.get(), false, OnMouseWheel); |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1348
diff
changeset
|
402 emscripten_set_wheel_callback("#mycanvas2", widget2_.get(), false, OnMouseWheel); |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1348
diff
changeset
|
403 emscripten_set_wheel_callback("#mycanvas3", widget3_.get(), false, OnMouseWheel); |
823 | 404 |
1370
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1348
diff
changeset
|
405 emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, false, OnKeyDown); |
28eb7106ef44
Changes to GuiAdapter to allow it to work correctly with both new and old
Benjamin Golinvaux <bgo@osimis.io>
parents:
1348
diff
changeset
|
406 emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, false, OnKeyUp); |
820 | 407 |
408 emscripten_request_animation_frame_loop(OnAnimationFrame, NULL); | |
409 | |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
410 |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
411 std::string ct; |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
412 if (GetArgument(ct, "ct")) |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
413 { |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
414 //loader_->LoadSeries("a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa"); |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
415 loader_->LoadSeries(ct); |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
416 } |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
417 else |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
418 { |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
419 LOG(ERROR) << "No Orthanc identifier for the CT series was provided"; |
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
826
diff
changeset
|
420 } |
820 | 421 } |
422 catch (Orthanc::OrthancException& e) | |
423 { | |
424 LOG(ERROR) << "Exception during Initialize(): " << e.What(); | |
425 } | |
426 } | |
427 } |