Mercurial > hg > orthanc-stone
comparison Applications/Samples/SimpleViewerApplication.h @ 251:192e6e349e69 am-2
first usage of new message system (in SDL only)
author | am@osimis.io |
---|---|
date | Mon, 02 Jul 2018 18:13:46 +0200 |
parents | 54c7284b0eff |
children | 8ff70c04c6df |
comparison
equal
deleted
inserted
replaced
250:5e642859267e | 251:192e6e349e69 |
---|---|
24 #include "SampleApplicationBase.h" | 24 #include "SampleApplicationBase.h" |
25 | 25 |
26 #include "../../Framework/Layers/OrthancFrameLayerSource.h" | 26 #include "../../Framework/Layers/OrthancFrameLayerSource.h" |
27 #include "../../Framework/Widgets/LayerWidget.h" | 27 #include "../../Framework/Widgets/LayerWidget.h" |
28 #include "../../Framework/Widgets/LayoutWidget.h" | 28 #include "../../Framework/Widgets/LayoutWidget.h" |
29 #include "../../Framework/Messages/IObserver.h" | |
29 | 30 |
30 #include <Core/Logging.h> | 31 #include <Core/Logging.h> |
31 | 32 |
32 namespace OrthancStone | 33 namespace OrthancStone |
33 { | 34 { |
34 namespace Samples | 35 namespace Samples |
35 { | 36 { |
36 class SimpleViewerApplication : | 37 class SimpleViewerApplication : |
37 public SampleApplicationBase, | 38 public SampleApplicationBase, |
38 private ILayerSource::IObserver | 39 public IObserver |
39 { | 40 { |
40 private: | 41 private: |
41 class Interactor : public IWorldSceneInteractor | 42 class Interactor : public IWorldSceneInteractor |
42 { | 43 { |
43 private: | 44 private: |
170 // widget_->SetSlice(s); | 171 // widget_->SetSlice(s); |
171 //#endif | 172 //#endif |
172 // } | 173 // } |
173 // } | 174 // } |
174 | 175 |
175 | 176 |
176 virtual void NotifyGeometryReady(const ILayerSource& source) | 177 virtual void HandleMessage(IObservable& from, const IMessage& message) { |
177 { | 178 switch (message.GetType()) { |
178 // Once the geometry of the series is downloaded from Orthanc, | 179 case MessageType_GeometryReady: |
179 // display its first slice, and adapt the viewport to fit this | 180 mainLayout_->SetDefaultView(); |
180 // slice | 181 break; |
181 if (source_ == &source) | 182 } |
182 { | |
183 //SetSlice(source_->GetSliceCount() / 2); | |
184 } | |
185 | |
186 mainLayout_->SetDefaultView(); | |
187 } | |
188 | |
189 virtual void NotifyGeometryError(const ILayerSource& source) | |
190 { | |
191 } | |
192 | |
193 virtual void NotifyContentChange(const ILayerSource& source) | |
194 { | |
195 } | |
196 | |
197 virtual void NotifySliceChange(const ILayerSource& source, | |
198 const Slice& slice) | |
199 { | |
200 } | |
201 | |
202 virtual void NotifyLayerReady(std::auto_ptr<ILayerRenderer>& layer, | |
203 const ILayerSource& source, | |
204 const CoordinateSystem3D& slice, | |
205 bool isError) | |
206 { | |
207 } | 183 } |
208 | 184 |
209 std::unique_ptr<Interactor> interactor_; | 185 std::unique_ptr<Interactor> interactor_; |
210 LayoutWidget* mainLayout_; | 186 LayoutWidget* mainLayout_; |
211 LayoutWidget* thumbnailsLayout_; | 187 LayoutWidget* thumbnailsLayout_; |
216 OrthancStone::WidgetViewport* wasmViewport1_; | 192 OrthancStone::WidgetViewport* wasmViewport1_; |
217 OrthancStone::WidgetViewport* wasmViewport2_; | 193 OrthancStone::WidgetViewport* wasmViewport2_; |
218 | 194 |
219 OrthancFrameLayerSource* source_; | 195 OrthancFrameLayerSource* source_; |
220 unsigned int slice_; | 196 unsigned int slice_; |
221 | 197 |
222 public: | 198 public: |
223 SimpleViewerApplication() : | 199 SimpleViewerApplication(MessageBroker& broker) : |
224 mainLayout_(NULL), | 200 mainLayout_(NULL), |
225 currentInstanceIndex_(0), | 201 currentInstanceIndex_(0), |
226 source_(NULL), | 202 source_(NULL), |
227 slice_(0), | 203 slice_(0), |
228 wasmViewport1_(NULL), | 204 wasmViewport1_(NULL), |
229 wasmViewport2_(NULL) | 205 wasmViewport2_(NULL), |
206 IObserver(broker) | |
230 { | 207 { |
231 } | 208 } |
232 | 209 |
233 virtual void Finalize() {} | 210 virtual void Finalize() {} |
234 virtual IWidget* GetCentralWidget() {return mainLayout_;} | 211 virtual IWidget* GetCentralWidget() {return mainLayout_;} |
235 | 212 |
236 virtual void DeclareStartupOptions(boost::program_options::options_description& options) | 213 virtual void DeclareStartupOptions(boost::program_options::options_description& options) |
237 { | 214 { |
280 thumbnailsLayout_->SetPadding(10); | 257 thumbnailsLayout_->SetPadding(10); |
281 thumbnailsLayout_->SetBackgroundCleared(true); | 258 thumbnailsLayout_->SetBackgroundCleared(true); |
282 thumbnailsLayout_->SetBackgroundColor(50, 50, 50); | 259 thumbnailsLayout_->SetBackgroundColor(50, 50, 50); |
283 thumbnailsLayout_->SetVertical(); | 260 thumbnailsLayout_->SetVertical(); |
284 | 261 |
285 mainViewport_ = new LayerWidget(); | 262 mainViewport_ = new LayerWidget(broker_); |
286 thumbnails_.push_back(new LayerWidget()); | 263 thumbnails_.push_back(new LayerWidget(broker_)); |
287 thumbnails_.push_back(new LayerWidget()); | 264 thumbnails_.push_back(new LayerWidget(broker_)); |
288 | 265 |
289 // hierarchy | 266 // hierarchy |
290 mainLayout_->AddWidget(thumbnailsLayout_); | 267 mainLayout_->AddWidget(thumbnailsLayout_); |
291 mainLayout_->AddWidget(mainViewport_); | 268 mainLayout_->AddWidget(mainViewport_); |
292 thumbnailsLayout_->AddWidget(thumbnails_[0]); | 269 thumbnailsLayout_->AddWidget(thumbnails_[0]); |
293 thumbnailsLayout_->AddWidget(thumbnails_[1]); | 270 thumbnailsLayout_->AddWidget(thumbnails_[1]); |
294 | 271 |
295 // sources | 272 // sources |
296 source_ = new OrthancFrameLayerSource(context_->GetWebService()); | 273 source_ = new OrthancFrameLayerSource(broker_, context_->GetWebService()); |
297 source_->LoadFrame(instances_[currentInstanceIndex_], 0); | 274 source_->LoadFrame(instances_[currentInstanceIndex_], 0); |
298 source_->Register(*this); | 275 source_->Register(*this); |
299 | 276 |
300 mainViewport_->AddLayer(source_); | 277 mainViewport_->AddLayer(source_); |
301 | 278 |
302 OrthancFrameLayerSource* thumb0 = new OrthancFrameLayerSource(context_->GetWebService()); | 279 OrthancFrameLayerSource* thumb0 = new OrthancFrameLayerSource(broker_, context_->GetWebService()); |
303 thumb0->LoadFrame(instances_[0], 0); | 280 thumb0->LoadFrame(instances_[0], 0); |
304 OrthancFrameLayerSource* thumb1 = new OrthancFrameLayerSource(context_->GetWebService()); | 281 OrthancFrameLayerSource* thumb1 = new OrthancFrameLayerSource(broker_, context_->GetWebService()); |
305 thumb1->LoadFrame(instances_[1], 0); | 282 thumb1->LoadFrame(instances_[1], 0); |
306 | 283 |
307 thumbnails_[0]->AddLayer(thumb0); | 284 thumbnails_[0]->AddLayer(thumb0); |
308 thumbnails_[1]->AddLayer(thumb1); | 285 thumbnails_[1]->AddLayer(thumb1); |
309 | 286 |
324 assert(context_); | 301 assert(context_); |
325 | 302 |
326 currentInstanceIndex_ = (currentInstanceIndex_ + 1) % instances_.size(); | 303 currentInstanceIndex_ = (currentInstanceIndex_ + 1) % instances_.size(); |
327 | 304 |
328 std::auto_ptr<OrthancFrameLayerSource> layer | 305 std::auto_ptr<OrthancFrameLayerSource> layer |
329 (new OrthancFrameLayerSource(context_->GetWebService())); | 306 (new OrthancFrameLayerSource(broker_, context_->GetWebService())); |
330 layer->LoadFrame(instances_[currentInstanceIndex_], 0); | 307 layer->LoadFrame(instances_[currentInstanceIndex_], 0); |
331 | 308 |
332 mainViewport_->ReplaceLayer(0, layer.release()); | 309 mainViewport_->ReplaceLayer(0, layer.release()); |
333 // source_->LoadFrame("45b7e6bc-168e8ed1-063dc08d-cffd6431-133a276a", 0); | 310 // source_->LoadFrame("45b7e6bc-168e8ed1-063dc08d-cffd6431-133a276a", 0); |
334 } | 311 } |