Mercurial > hg > orthanc-stone
annotate Applications/Samples/SimpleViewerApplication.h @ 279:8f5d7495076d am-2
SimpleViewer sample working in SDL, Qt and WASM
author | am@osimis.io |
---|---|
date | Mon, 27 Aug 2018 15:40:13 +0200 |
parents | dc1beee33134 |
children | 300d8b8c48b3 |
rev | line source |
---|---|
235 | 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-2018 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. | |
249 | 16 * |
235 | 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 "SampleApplicationBase.h" | |
25 | |
26 #include "../../Framework/Layers/OrthancFrameLayerSource.h" | |
27 #include "../../Framework/Widgets/LayerWidget.h" | |
28 #include "../../Framework/Widgets/LayoutWidget.h" | |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
249
diff
changeset
|
29 #include "../../Framework/Messages/IObserver.h" |
258 | 30 #include "../../Framework/SmartLoader.h" |
235 | 31 |
32 #include <Core/Logging.h> | |
33 | |
34 namespace OrthancStone | |
35 { | |
36 namespace Samples | |
37 { | |
38 class SimpleViewerApplication : | |
249 | 39 public SampleApplicationBase, |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
249
diff
changeset
|
40 public IObserver |
235 | 41 { |
42 private: | |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
43 class ThumbnailInteractor : public IWorldSceneInteractor |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
44 { |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
45 private: |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
46 SimpleViewerApplication& application_; |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
47 public: |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
48 ThumbnailInteractor(SimpleViewerApplication& application) : |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
49 application_(application) |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
50 { |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
51 } |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
52 |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
53 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
54 const ViewportGeometry& view, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
55 MouseButton button, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
56 double x, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
57 double y, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
58 IStatusBar* statusBar) |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
59 { |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
60 if (button == MouseButton_Left) |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
61 { |
279
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
62 statusBar->SetMessage("selected thumbnail " + widget.GetName()); |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
63 std::string seriesId = widget.GetName().substr(strlen("thumbnail-series-")); |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
64 application_.SelectSeriesInMainViewport(seriesId); |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
65 } |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
66 return NULL; |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
67 } |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
68 virtual void MouseOver(CairoContext& context, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
69 WorldSceneWidget& widget, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
70 const ViewportGeometry& view, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
71 double x, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
72 double y, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
73 IStatusBar* statusBar) |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
74 {} |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
75 |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
76 virtual void MouseWheel(WorldSceneWidget& widget, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
77 MouseWheelDirection direction, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
78 KeyboardModifiers modifiers, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
79 IStatusBar* statusBar) |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
80 {} |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
81 |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
82 virtual void KeyPressed(WorldSceneWidget& widget, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
83 char key, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
84 KeyboardModifiers modifiers, |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
85 IStatusBar* statusBar) |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
86 {}; |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
87 |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
88 }; |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
89 |
235 | 90 class Interactor : public IWorldSceneInteractor |
91 { | |
92 private: | |
93 SimpleViewerApplication& application_; | |
94 | |
95 public: | |
96 Interactor(SimpleViewerApplication& application) : | |
97 application_(application) | |
98 { | |
99 } | |
100 | |
101 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget, | |
102 const ViewportGeometry& view, | |
103 MouseButton button, | |
104 double x, | |
105 double y, | |
106 IStatusBar* statusBar) | |
107 { | |
108 return NULL; | |
109 } | |
110 | |
111 virtual void MouseOver(CairoContext& context, | |
112 WorldSceneWidget& widget, | |
113 const ViewportGeometry& view, | |
114 double x, | |
115 double y, | |
116 IStatusBar* statusBar) | |
117 { | |
118 if (statusBar != NULL) | |
119 { | |
120 Vector p = dynamic_cast<LayerWidget&>(widget).GetSlice().MapSliceToWorldCoordinates(x, y); | |
121 | |
122 char buf[64]; | |
249 | 123 sprintf(buf, "X = %.02f Y = %.02f Z = %.02f (in cm)", |
235 | 124 p[0] / 10.0, p[1] / 10.0, p[2] / 10.0); |
125 statusBar->SetMessage(buf); | |
126 } | |
127 } | |
128 | |
129 virtual void MouseWheel(WorldSceneWidget& widget, | |
130 MouseWheelDirection direction, | |
131 KeyboardModifiers modifiers, | |
132 IStatusBar* statusBar) | |
133 { | |
249 | 134 // int scale = (modifiers & KeyboardModifiers_Control ? 10 : 1); |
235 | 135 |
249 | 136 // switch (direction) |
137 // { | |
138 // case MouseWheelDirection_Up: | |
139 // application_.OffsetSlice(-scale); | |
140 // break; | |
235 | 141 |
249 | 142 // case MouseWheelDirection_Down: |
143 // application_.OffsetSlice(scale); | |
144 // break; | |
235 | 145 |
249 | 146 // default: |
147 // break; | |
148 // } | |
235 | 149 } |
150 | |
151 virtual void KeyPressed(WorldSceneWidget& widget, | |
152 char key, | |
153 KeyboardModifiers modifiers, | |
154 IStatusBar* statusBar) | |
155 { | |
156 switch (key) | |
157 { | |
249 | 158 case 's': |
159 widget.SetDefaultView(); | |
160 break; | |
235 | 161 |
249 | 162 default: |
163 break; | |
235 | 164 } |
165 } | |
166 }; | |
167 | |
168 | |
242 | 169 std::unique_ptr<Interactor> interactor_; |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
170 std::unique_ptr<ThumbnailInteractor> thumbnailInteractor_; |
235 | 171 LayoutWidget* mainLayout_; |
172 LayoutWidget* thumbnailsLayout_; | |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
173 LayerWidget* mainWidget_; |
235 | 174 std::vector<LayerWidget*> thumbnails_; |
279
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
175 std::map<std::string, std::vector<std::string>> instancesIdsPerSeriesId_; |
270 | 176 |
235 | 177 unsigned int currentInstanceIndex_; |
270 | 178 OrthancStone::WidgetViewport* wasmViewport1_; |
179 OrthancStone::WidgetViewport* wasmViewport2_; | |
235 | 180 |
254 | 181 IStatusBar* statusBar_; |
235 | 182 unsigned int slice_; |
258 | 183 std::unique_ptr<SmartLoader> smartLoader_; |
270 | 184 std::unique_ptr<OrthancApiClient> orthancApiClient_; |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
249
diff
changeset
|
185 |
235 | 186 public: |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
249
diff
changeset
|
187 SimpleViewerApplication(MessageBroker& broker) : |
258 | 188 IObserver(broker), |
235 | 189 mainLayout_(NULL), |
190 currentInstanceIndex_(0), | |
242 | 191 wasmViewport1_(NULL), |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
249
diff
changeset
|
192 wasmViewport2_(NULL), |
258 | 193 slice_(0) |
235 | 194 { |
267 | 195 DeclareIgnoredMessage(MessageType_Widget_ContentChanged); |
196 DeclareHandledMessage(MessageType_Widget_GeometryChanged); | |
270 | 197 |
198 DeclareHandledMessage(MessageType_OrthancApi_GetStudyIds_Ready); | |
199 DeclareHandledMessage(MessageType_OrthancApi_GetStudy_Ready); | |
200 DeclareHandledMessage(MessageType_OrthancApi_GetSeries_Ready); | |
235 | 201 } |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
249
diff
changeset
|
202 |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
235
diff
changeset
|
203 virtual void Finalize() {} |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
235
diff
changeset
|
204 virtual IWidget* GetCentralWidget() {return mainLayout_;} |
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
235
diff
changeset
|
205 |
235 | 206 virtual void DeclareStartupOptions(boost::program_options::options_description& options) |
207 { | |
208 boost::program_options::options_description generic("Sample options"); | |
209 generic.add_options() | |
270 | 210 ("studyId", boost::program_options::value<std::string>(), |
211 "Orthanc ID of the study") | |
249 | 212 ; |
235 | 213 |
249 | 214 options.add(generic); |
235 | 215 } |
216 | |
242 | 217 virtual void Initialize(BasicApplicationContext* context, |
218 IStatusBar& statusBar, | |
235 | 219 const boost::program_options::variables_map& parameters) |
220 { | |
221 using namespace OrthancStone; | |
222 | |
242 | 223 context_ = context; |
254 | 224 statusBar_ = &statusBar; |
270 | 225 |
226 {// initialize viewports and layout | |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
227 mainLayout_ = new LayoutWidget("main-layout"); |
270 | 228 mainLayout_->SetPadding(10); |
229 mainLayout_->SetBackgroundCleared(true); | |
230 mainLayout_->SetBackgroundColor(0, 0, 0); | |
231 mainLayout_->SetHorizontal(); | |
232 | |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
233 thumbnailsLayout_ = new LayoutWidget("thumbnail-layout"); |
270 | 234 thumbnailsLayout_->SetPadding(10); |
235 thumbnailsLayout_->SetBackgroundCleared(true); | |
236 thumbnailsLayout_->SetBackgroundColor(50, 50, 50); | |
237 thumbnailsLayout_->SetVertical(); | |
238 | |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
239 mainWidget_ = new LayerWidget(broker_, "main-viewport"); |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
240 mainWidget_->RegisterObserver(*this); |
270 | 241 |
242 // hierarchy | |
243 mainLayout_->AddWidget(thumbnailsLayout_); | |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
244 mainLayout_->AddWidget(mainWidget_); |
270 | 245 |
246 // sources | |
247 smartLoader_.reset(new SmartLoader(broker_, context_->GetWebService())); | |
248 smartLoader_->SetImageQuality(SliceImageQuality_FullPam); | |
249 | |
250 mainLayout_->SetTransmitMouseOver(true); | |
251 interactor_.reset(new Interactor(*this)); | |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
252 mainWidget_->SetInteractor(*interactor_); |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
271
diff
changeset
|
253 thumbnailInteractor_.reset(new ThumbnailInteractor(*this)); |
270 | 254 } |
255 | |
235 | 256 statusBar.SetMessage("Use the key \"s\" to reinitialize the layout"); |
254 | 257 statusBar.SetMessage("Use the key \"n\" to go to next image in the main viewport"); |
235 | 258 |
270 | 259 orthancApiClient_.reset(new OrthancApiClient(broker_, context_->GetWebService())); |
260 | |
261 if (parameters.count("studyId") < 1) | |
235 | 262 { |
270 | 263 LOG(WARNING) << "The study ID is missing, will take the first studyId found in Orthanc"; |
264 orthancApiClient_->ScheduleGetStudyIds(*this); | |
235 | 265 } |
270 | 266 else |
235 | 267 { |
270 | 268 SelectStudy(parameters["studyId"].as<std::string>()); |
235 | 269 } |
270 | 270 } |
235 | 271 |
270 | 272 void OnStudyListReceived(const Json::Value& response) |
273 { | |
274 if (response.isArray() && response.size() > 1) | |
275 { | |
276 SelectStudy(response[0].asString()); | |
277 } | |
278 } | |
279 void OnStudyReceived(const Json::Value& response) | |
280 { | |
281 if (response.isObject() && response["Series"].isArray()) | |
282 { | |
283 for (size_t i=0; i < response["Series"].size(); i++) | |
284 { | |
285 orthancApiClient_->ScheduleGetSeries(*this, response["Series"][(int)i].asString()); | |
286 } | |
287 } | |
288 } | |
235 | 289 |
270 | 290 void OnSeriesReceived(const Json::Value& response) |
291 { | |
292 if (response.isObject() && response["Instances"].isArray() && response["Instances"].size() > 0) | |
293 { | |
279
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
294 // keep track of all instances IDs |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
295 const std::string& seriesId = response["ID"].asString(); |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
296 instancesIdsPerSeriesId_[seriesId] = std::vector<std::string>(); |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
297 for (size_t i = 0; i < response["Instances"].size(); i++) |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
298 { |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
299 const std::string& instanceId = response["Instances"][static_cast<int>(i)].asString(); |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
300 instancesIdsPerSeriesId_[seriesId].push_back(instanceId); |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
301 } |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
302 |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
303 // load the first instance in the thumbnail |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
304 LoadThumbnailForSeries(seriesId, instancesIdsPerSeriesId_[seriesId][0]); |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
305 |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
306 // if this is the first thumbnail loaded, load the first instance in the mainWidget |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
307 if (mainWidget_->GetLayerCount() == 0) |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
308 { |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
309 mainWidget_->AddLayer(smartLoader_->GetFrame(instancesIdsPerSeriesId_[seriesId][0], 0)); |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
310 } |
270 | 311 } |
312 } | |
313 | |
314 void LoadThumbnailForSeries(const std::string& seriesId, const std::string& instanceId) | |
315 { | |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
270
diff
changeset
|
316 LOG(INFO) << "Loading thumbnail for series " << seriesId; |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
270
diff
changeset
|
317 LayerWidget* thumbnailWidget = new LayerWidget(broker_, "thumbnail-series-" + seriesId); |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
270
diff
changeset
|
318 thumbnails_.push_back(thumbnailWidget); |
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
270
diff
changeset
|
319 thumbnailsLayout_->AddWidget(thumbnailWidget); |
270 | 320 thumbnailWidget->RegisterObserver(*this); |
321 thumbnailWidget->AddLayer(smartLoader_->GetFrame(instanceId, 0)); | |
279
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
322 thumbnailWidget->SetInteractor(*thumbnailInteractor_); |
270 | 323 } |
235 | 324 |
270 | 325 void SelectStudy(const std::string& studyId) |
326 { | |
327 orthancApiClient_->ScheduleGetStudy(*this, studyId); | |
328 } | |
329 | |
330 virtual void HandleMessage(IObservable& from, const IMessage& message) { | |
331 switch (message.GetType()) { | |
332 case MessageType_Widget_GeometryChanged: | |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
270
diff
changeset
|
333 LOG(INFO) << "Widget geometry ready: " << dynamic_cast<LayerWidget&>(from).GetName(); |
270 | 334 dynamic_cast<LayerWidget&>(from).SetDefaultView(); |
335 break; | |
336 case MessageType_OrthancApi_GetStudyIds_Ready: | |
337 OnStudyListReceived(dynamic_cast<const OrthancApiClient::GetJsonResponseReadyMessage&>(message).response_); | |
338 break; | |
339 case MessageType_OrthancApi_GetSeries_Ready: | |
340 OnSeriesReceived(dynamic_cast<const OrthancApiClient::GetJsonResponseReadyMessage&>(message).response_); | |
341 break; | |
342 case MessageType_OrthancApi_GetStudy_Ready: | |
343 OnStudyReceived(dynamic_cast<const OrthancApiClient::GetJsonResponseReadyMessage&>(message).response_); | |
344 break; | |
345 default: | |
346 VLOG("unhandled message type" << message.GetType()); | |
347 } | |
242 | 348 } |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
235
diff
changeset
|
349 |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
273
diff
changeset
|
350 #if ORTHANC_ENABLE_WASM==1 |
242 | 351 virtual void InitializeWasm() { |
352 | |
353 AttachWidgetToWasmViewport("canvas", thumbnailsLayout_); | |
274
dc1beee33134
split SdlApplication into NativeApplication and SdlApplication
am@osimis.io
parents:
273
diff
changeset
|
354 AttachWidgetToWasmViewport("canvas2", mainWidget_); |
242 | 355 } |
237
b4642964c355
SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
235
diff
changeset
|
356 #endif |
249 | 357 |
279
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
358 void SelectSeriesInMainViewport(const std::string& seriesId) |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
359 { |
8f5d7495076d
SimpleViewer sample working in SDL, Qt and WASM
am@osimis.io
parents:
274
diff
changeset
|
360 mainWidget_->ReplaceLayer(0, smartLoader_->GetFrame(instancesIdsPerSeriesId_[seriesId][0], 0)); |
249 | 361 } |
235 | 362 }; |
249 | 363 |
364 | |
235 | 365 } |
366 } |