Mercurial > hg > orthanc-stone
comparison Applications/Samples/SimpleViewerApplicationSingleFile.h @ 1066:b537002f83a9 broker
removing broker from deprecated classes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 15 Oct 2019 15:39:39 +0200 |
parents | be9c1530d40a |
children | d7887f88710f |
comparison
equal
deleted
inserted
replaced
1065:9d42f89b8c3c | 1066:b537002f83a9 |
---|---|
42 { | 42 { |
43 namespace Samples | 43 namespace Samples |
44 { | 44 { |
45 class SimpleViewerApplication : | 45 class SimpleViewerApplication : |
46 public SampleSingleCanvasWithButtonsApplicationBase, | 46 public SampleSingleCanvasWithButtonsApplicationBase, |
47 public IObserver | 47 public ObserverBase<SimpleViewerApplication> |
48 { | 48 { |
49 private: | 49 private: |
50 class ThumbnailInteractor : public Deprecated::IWorldSceneInteractor | 50 class ThumbnailInteractor : public Deprecated::IWorldSceneInteractor |
51 { | 51 { |
52 private: | 52 private: |
197 class SimpleViewerApplicationAdapter : public WasmPlatformApplicationAdapter | 197 class SimpleViewerApplicationAdapter : public WasmPlatformApplicationAdapter |
198 { | 198 { |
199 SimpleViewerApplication& viewerApplication_; | 199 SimpleViewerApplication& viewerApplication_; |
200 | 200 |
201 public: | 201 public: |
202 SimpleViewerApplicationAdapter(MessageBroker& broker, SimpleViewerApplication& application) | 202 SimpleViewerApplicationAdapter(SimpleViewerApplication& application) |
203 : WasmPlatformApplicationAdapter(broker, application), | 203 : WasmPlatformApplicationAdapter(application), |
204 viewerApplication_(application) | 204 viewerApplication_(application) |
205 { | 205 { |
206 } | 206 } |
207 | 207 |
208 virtual void HandleSerializedMessageFromWeb(std::string& output, const std::string& input) | 208 virtual void HandleSerializedMessageFromWeb(std::string& output, const std::string& input) |
256 std::auto_ptr<Deprecated::SmartLoader> smartLoader_; | 256 std::auto_ptr<Deprecated::SmartLoader> smartLoader_; |
257 | 257 |
258 Orthanc::Font font_; | 258 Orthanc::Font font_; |
259 | 259 |
260 public: | 260 public: |
261 SimpleViewerApplication(MessageBroker& broker) : | 261 SimpleViewerApplication() : |
262 IObserver(broker), | |
263 currentTool_(Tool_LineMeasure), | 262 currentTool_(Tool_LineMeasure), |
264 mainLayout_(NULL), | 263 mainLayout_(NULL), |
265 currentInstanceIndex_(0), | 264 currentInstanceIndex_(0), |
266 wasmViewport1_(NULL), | 265 wasmViewport1_(NULL), |
267 wasmViewport2_(NULL) | 266 wasmViewport2_(NULL) |
301 thumbnailsLayout_->SetPadding(10); | 300 thumbnailsLayout_->SetPadding(10); |
302 thumbnailsLayout_->SetBackgroundCleared(true); | 301 thumbnailsLayout_->SetBackgroundCleared(true); |
303 thumbnailsLayout_->SetBackgroundColor(50, 50, 50); | 302 thumbnailsLayout_->SetBackgroundColor(50, 50, 50); |
304 thumbnailsLayout_->SetVertical(); | 303 thumbnailsLayout_->SetVertical(); |
305 | 304 |
306 mainWidget_ = new Deprecated::SliceViewerWidget(GetBroker(), "main-viewport"); | 305 mainWidget_ = new Deprecated::SliceViewerWidget("main-viewport"); |
307 //mainWidget_->RegisterObserver(*this); | 306 //mainWidget_->RegisterObserver(*this); |
308 | 307 |
309 // hierarchy | 308 // hierarchy |
310 mainLayout_->AddWidget(thumbnailsLayout_); | 309 mainLayout_->AddWidget(thumbnailsLayout_); |
311 mainLayout_->AddWidget(mainWidget_); | 310 mainLayout_->AddWidget(mainWidget_); |
312 | 311 |
313 // sources | 312 // sources |
314 smartLoader_.reset(new Deprecated::SmartLoader(GetBroker(), context->GetOrthancApiClient())); | 313 smartLoader_.reset(new Deprecated::SmartLoader(context->GetOrthancApiClient())); |
315 smartLoader_->SetImageQuality(Deprecated::SliceImageQuality_FullPam); | 314 smartLoader_->SetImageQuality(Deprecated::SliceImageQuality_FullPam); |
316 | 315 |
317 mainLayout_->SetTransmitMouseOver(true); | 316 mainLayout_->SetTransmitMouseOver(true); |
318 mainWidgetInteractor_.reset(new MainWidgetInteractor(*this)); | 317 mainWidgetInteractor_.reset(new MainWidgetInteractor(*this)); |
319 mainWidget_->SetInteractor(*mainWidgetInteractor_); | 318 mainWidget_->SetInteractor(*mainWidgetInteractor_); |
328 { | 327 { |
329 LOG(WARNING) << "The study ID is missing, will take the first studyId found in Orthanc"; | 328 LOG(WARNING) << "The study ID is missing, will take the first studyId found in Orthanc"; |
330 context->GetOrthancApiClient().GetJsonAsync( | 329 context->GetOrthancApiClient().GetJsonAsync( |
331 "/studies", | 330 "/studies", |
332 new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage> | 331 new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage> |
333 (*this, &SimpleViewerApplication::OnStudyListReceived)); | 332 (GetSharedObserver(), &SimpleViewerApplication::OnStudyListReceived)); |
334 } | 333 } |
335 else | 334 else |
336 { | 335 { |
337 SelectStudy(parameters["studyId"].as<std::string>()); | 336 SelectStudy(parameters["studyId"].as<std::string>()); |
338 } | 337 } |
358 for (size_t i=0; i < response["Series"].size(); i++) | 357 for (size_t i=0; i < response["Series"].size(); i++) |
359 { | 358 { |
360 context_->GetOrthancApiClient().GetJsonAsync( | 359 context_->GetOrthancApiClient().GetJsonAsync( |
361 "/series/" + response["Series"][(int)i].asString(), | 360 "/series/" + response["Series"][(int)i].asString(), |
362 new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage> | 361 new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage> |
363 (*this, &SimpleViewerApplication::OnSeriesReceived)); | 362 (GetSharedObserver(), &SimpleViewerApplication::OnSeriesReceived)); |
364 } | 363 } |
365 } | 364 } |
366 } | 365 } |
367 | 366 |
368 void OnSeriesReceived(const Deprecated::OrthancApiClient::JsonResponseReadyMessage& message) | 367 void OnSeriesReceived(const Deprecated::OrthancApiClient::JsonResponseReadyMessage& message) |
396 } | 395 } |
397 | 396 |
398 void LoadThumbnailForSeries(const std::string& seriesId, const std::string& instanceId) | 397 void LoadThumbnailForSeries(const std::string& seriesId, const std::string& instanceId) |
399 { | 398 { |
400 LOG(INFO) << "Loading thumbnail for series " << seriesId; | 399 LOG(INFO) << "Loading thumbnail for series " << seriesId; |
401 Deprecated::SliceViewerWidget* thumbnailWidget = new Deprecated::SliceViewerWidget(GetBroker(), "thumbnail-series-" + seriesId); | 400 Deprecated::SliceViewerWidget* thumbnailWidget = new Deprecated::SliceViewerWidget("thumbnail-series-" + seriesId); |
402 thumbnails_.push_back(thumbnailWidget); | 401 thumbnails_.push_back(thumbnailWidget); |
403 thumbnailsLayout_->AddWidget(thumbnailWidget); | 402 thumbnailsLayout_->AddWidget(thumbnailWidget); |
404 thumbnailWidget->RegisterObserverCallback(new Callable<SimpleViewerApplication, Deprecated::SliceViewerWidget::GeometryChangedMessage>(*this, &SimpleViewerApplication::OnWidgetGeometryChanged)); | 403 Register<Deprecated::SliceViewerWidget::GeometryChangedMessage>(*thumbnailWidget, &SimpleViewerApplication::OnWidgetGeometryChanged); |
405 smartLoader_->SetFrameInWidget(*thumbnailWidget, 0, instanceId, 0); | 404 smartLoader_->SetFrameInWidget(*thumbnailWidget, 0, instanceId, 0); |
406 thumbnailWidget->SetInteractor(*thumbnailInteractor_); | 405 thumbnailWidget->SetInteractor(*thumbnailInteractor_); |
407 } | 406 } |
408 | 407 |
409 void SelectStudy(const std::string& studyId) | 408 void SelectStudy(const std::string& studyId) |
410 { | 409 { |
411 LOG(INFO) << "Selecting study: " << studyId; | 410 LOG(INFO) << "Selecting study: " << studyId; |
412 context_->GetOrthancApiClient().GetJsonAsync( | 411 context_->GetOrthancApiClient().GetJsonAsync( |
413 "/studies/" + studyId, new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage> | 412 "/studies/" + studyId, new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage> |
414 (*this, &SimpleViewerApplication::OnStudyReceived)); | 413 (GetSharedObserver(), &SimpleViewerApplication::OnStudyReceived)); |
415 } | 414 } |
416 | 415 |
417 void OnWidgetGeometryChanged(const Deprecated::SliceViewerWidget::GeometryChangedMessage& message) | 416 void OnWidgetGeometryChanged(const Deprecated::SliceViewerWidget::GeometryChangedMessage& message) |
418 { | 417 { |
419 // TODO: The "const_cast" could probably be replaced by "mainWidget" | 418 // TODO: The "const_cast" could probably be replaced by "mainWidget" |