Mercurial > hg > orthanc-stone
comparison Applications/Samples/SimpleViewerApplicationSingleFile.h @ 1070:d7887f88710f broker
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 15 Oct 2019 21:28:46 +0200 |
parents | b537002f83a9 |
children | 21c2b0eee53c |
comparison
equal
deleted
inserted
replaced
1069:5d1b0d2f4b15 | 1070:d7887f88710f |
---|---|
241 Tool currentTool_; | 241 Tool currentTool_; |
242 std::auto_ptr<MainWidgetInteractor> mainWidgetInteractor_; | 242 std::auto_ptr<MainWidgetInteractor> mainWidgetInteractor_; |
243 std::auto_ptr<ThumbnailInteractor> thumbnailInteractor_; | 243 std::auto_ptr<ThumbnailInteractor> thumbnailInteractor_; |
244 Deprecated::LayoutWidget* mainLayout_; | 244 Deprecated::LayoutWidget* mainLayout_; |
245 Deprecated::LayoutWidget* thumbnailsLayout_; | 245 Deprecated::LayoutWidget* thumbnailsLayout_; |
246 std::vector<Deprecated::SliceViewerWidget*> thumbnails_; | 246 std::vector<boost::shared_ptr<Deprecated::SliceViewerWidget> > thumbnails_; |
247 | 247 |
248 std::map<std::string, std::vector<std::string> > instancesIdsPerSeriesId_; | 248 std::map<std::string, std::vector<std::string> > instancesIdsPerSeriesId_; |
249 std::map<std::string, Json::Value> seriesTags_; | 249 std::map<std::string, Json::Value> seriesTags_; |
250 | 250 |
251 unsigned int currentInstanceIndex_; | 251 unsigned int currentInstanceIndex_; |
294 mainLayout_->SetPadding(10); | 294 mainLayout_->SetPadding(10); |
295 mainLayout_->SetBackgroundCleared(true); | 295 mainLayout_->SetBackgroundCleared(true); |
296 mainLayout_->SetBackgroundColor(0, 0, 0); | 296 mainLayout_->SetBackgroundColor(0, 0, 0); |
297 mainLayout_->SetHorizontal(); | 297 mainLayout_->SetHorizontal(); |
298 | 298 |
299 thumbnailsLayout_ = new Deprecated::LayoutWidget("thumbnail-layout"); | 299 boost::shared_ptr<Deprecated::LayoutWidget> thumbnailsLayout_(new Deprecated::LayoutWidget("thumbnail-layout")); |
300 thumbnailsLayout_->SetPadding(10); | 300 thumbnailsLayout_->SetPadding(10); |
301 thumbnailsLayout_->SetBackgroundCleared(true); | 301 thumbnailsLayout_->SetBackgroundCleared(true); |
302 thumbnailsLayout_->SetBackgroundColor(50, 50, 50); | 302 thumbnailsLayout_->SetBackgroundColor(50, 50, 50); |
303 thumbnailsLayout_->SetVertical(); | 303 thumbnailsLayout_->SetVertical(); |
304 | 304 |
305 mainWidget_ = new Deprecated::SliceViewerWidget("main-viewport"); | 305 boost::shared_ptr<Deprecated::SliceViewerWidget> widget |
306 (new Deprecated::SliceViewerWidget("main-viewport")); | |
307 SetCentralWidget(widget); | |
306 //mainWidget_->RegisterObserver(*this); | 308 //mainWidget_->RegisterObserver(*this); |
307 | 309 |
308 // hierarchy | 310 // hierarchy |
309 mainLayout_->AddWidget(thumbnailsLayout_); | 311 mainLayout_->AddWidget(thumbnailsLayout_); |
310 mainLayout_->AddWidget(mainWidget_); | 312 mainLayout_->AddWidget(widget); |
311 | 313 |
312 // sources | 314 // sources |
313 smartLoader_.reset(new Deprecated::SmartLoader(context->GetOrthancApiClient())); | 315 smartLoader_.reset(new Deprecated::SmartLoader(context->GetOrthancApiClient())); |
314 smartLoader_->SetImageQuality(Deprecated::SliceImageQuality_FullPam); | 316 smartLoader_->SetImageQuality(Deprecated::SliceImageQuality_FullPam); |
315 | 317 |
316 mainLayout_->SetTransmitMouseOver(true); | 318 mainLayout_->SetTransmitMouseOver(true); |
317 mainWidgetInteractor_.reset(new MainWidgetInteractor(*this)); | 319 mainWidgetInteractor_.reset(new MainWidgetInteractor(*this)); |
318 mainWidget_->SetInteractor(*mainWidgetInteractor_); | 320 widget->SetInteractor(*mainWidgetInteractor_); |
319 thumbnailInteractor_.reset(new ThumbnailInteractor(*this)); | 321 thumbnailInteractor_.reset(new ThumbnailInteractor(*this)); |
320 } | 322 } |
321 | 323 |
322 statusBar.SetMessage("Use the key \"s\" to reinitialize the layout"); | 324 statusBar.SetMessage("Use the key \"s\" to reinitialize the layout"); |
323 statusBar.SetMessage("Use the key \"n\" to go to next image in the main viewport"); | 325 statusBar.SetMessage("Use the key \"n\" to go to next image in the main viewport"); |
324 | 326 |
325 | 327 |
326 if (parameters.count("studyId") < 1) | 328 if (parameters.count("studyId") < 1) |
327 { | 329 { |
328 LOG(WARNING) << "The study ID is missing, will take the first studyId found in Orthanc"; | 330 LOG(WARNING) << "The study ID is missing, will take the first studyId found in Orthanc"; |
329 context->GetOrthancApiClient().GetJsonAsync( | 331 context->GetOrthancApiClient()->GetJsonAsync( |
330 "/studies", | 332 "/studies", |
331 new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage> | 333 new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage> |
332 (GetSharedObserver(), &SimpleViewerApplication::OnStudyListReceived)); | 334 (GetSharedObserver(), &SimpleViewerApplication::OnStudyListReceived)); |
333 } | 335 } |
334 else | 336 else |
354 | 356 |
355 if (response.isObject() && response["Series"].isArray()) | 357 if (response.isObject() && response["Series"].isArray()) |
356 { | 358 { |
357 for (size_t i=0; i < response["Series"].size(); i++) | 359 for (size_t i=0; i < response["Series"].size(); i++) |
358 { | 360 { |
359 context_->GetOrthancApiClient().GetJsonAsync( | 361 context_->GetOrthancApiClient()->GetJsonAsync( |
360 "/series/" + response["Series"][(int)i].asString(), | 362 "/series/" + response["Series"][(int)i].asString(), |
361 new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage> | 363 new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage> |
362 (GetSharedObserver(), &SimpleViewerApplication::OnSeriesReceived)); | 364 (GetSharedObserver(), &SimpleViewerApplication::OnSeriesReceived)); |
363 } | 365 } |
364 } | 366 } |
384 | 386 |
385 // load the first instance in the thumbnail | 387 // load the first instance in the thumbnail |
386 LoadThumbnailForSeries(seriesId, instancesIdsPerSeriesId_[seriesId][0]); | 388 LoadThumbnailForSeries(seriesId, instancesIdsPerSeriesId_[seriesId][0]); |
387 | 389 |
388 // if this is the first thumbnail loaded, load the first instance in the mainWidget | 390 // if this is the first thumbnail loaded, load the first instance in the mainWidget |
389 Deprecated::SliceViewerWidget& widget = *dynamic_cast<Deprecated::SliceViewerWidget*>(mainWidget_); | 391 Deprecated::SliceViewerWidget& widget = dynamic_cast<Deprecated::SliceViewerWidget&>(*GetCentralWidget()); |
390 if (widget.GetLayerCount() == 0) | 392 if (widget.GetLayerCount() == 0) |
391 { | 393 { |
392 smartLoader_->SetFrameInWidget(widget, 0, instancesIdsPerSeriesId_[seriesId][0], 0); | 394 smartLoader_->SetFrameInWidget(widget, 0, instancesIdsPerSeriesId_[seriesId][0], 0); |
393 } | 395 } |
394 } | 396 } |
395 } | 397 } |
396 | 398 |
397 void LoadThumbnailForSeries(const std::string& seriesId, const std::string& instanceId) | 399 void LoadThumbnailForSeries(const std::string& seriesId, const std::string& instanceId) |
398 { | 400 { |
399 LOG(INFO) << "Loading thumbnail for series " << seriesId; | 401 LOG(INFO) << "Loading thumbnail for series " << seriesId; |
400 Deprecated::SliceViewerWidget* thumbnailWidget = new Deprecated::SliceViewerWidget("thumbnail-series-" + seriesId); | 402 boost::shared_ptr<Deprecated::SliceViewerWidget> thumbnailWidget(new Deprecated::SliceViewerWidget("thumbnail-series-" + seriesId)); |
401 thumbnails_.push_back(thumbnailWidget); | 403 thumbnails_.push_back(thumbnailWidget); |
402 thumbnailsLayout_->AddWidget(thumbnailWidget); | 404 thumbnailsLayout_->AddWidget(thumbnailWidget); |
403 Register<Deprecated::SliceViewerWidget::GeometryChangedMessage>(*thumbnailWidget, &SimpleViewerApplication::OnWidgetGeometryChanged); | 405 Register<Deprecated::SliceViewerWidget::GeometryChangedMessage>(*thumbnailWidget, &SimpleViewerApplication::OnWidgetGeometryChanged); |
404 smartLoader_->SetFrameInWidget(*thumbnailWidget, 0, instanceId, 0); | 406 smartLoader_->SetFrameInWidget(*thumbnailWidget, 0, instanceId, 0); |
405 thumbnailWidget->SetInteractor(*thumbnailInteractor_); | 407 thumbnailWidget->SetInteractor(*thumbnailInteractor_); |
406 } | 408 } |
407 | 409 |
408 void SelectStudy(const std::string& studyId) | 410 void SelectStudy(const std::string& studyId) |
409 { | 411 { |
410 LOG(INFO) << "Selecting study: " << studyId; | 412 LOG(INFO) << "Selecting study: " << studyId; |
411 context_->GetOrthancApiClient().GetJsonAsync( | 413 context_->GetOrthancApiClient()->GetJsonAsync( |
412 "/studies/" + studyId, new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage> | 414 "/studies/" + studyId, new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage> |
413 (GetSharedObserver(), &SimpleViewerApplication::OnStudyReceived)); | 415 (GetSharedObserver(), &SimpleViewerApplication::OnStudyReceived)); |
414 } | 416 } |
415 | 417 |
416 void OnWidgetGeometryChanged(const Deprecated::SliceViewerWidget::GeometryChangedMessage& message) | 418 void OnWidgetGeometryChanged(const Deprecated::SliceViewerWidget::GeometryChangedMessage& message) |
419 const_cast<Deprecated::SliceViewerWidget&>(message.GetOrigin()).FitContent(); | 421 const_cast<Deprecated::SliceViewerWidget&>(message.GetOrigin()).FitContent(); |
420 } | 422 } |
421 | 423 |
422 void SelectSeriesInMainViewport(const std::string& seriesId) | 424 void SelectSeriesInMainViewport(const std::string& seriesId) |
423 { | 425 { |
424 Deprecated::SliceViewerWidget& widget = *dynamic_cast<Deprecated::SliceViewerWidget*>(mainWidget_); | 426 Deprecated::SliceViewerWidget& widget = dynamic_cast<Deprecated::SliceViewerWidget&>(*GetCentralWidget()); |
425 smartLoader_->SetFrameInWidget(widget, 0, instancesIdsPerSeriesId_[seriesId][0], 0); | 427 smartLoader_->SetFrameInWidget(widget, 0, instancesIdsPerSeriesId_[seriesId][0], 0); |
426 } | 428 } |
427 | 429 |
428 const Orthanc::Font& GetFont() const | 430 const Orthanc::Font& GetFont() const |
429 { | 431 { |
448 | 450 |
449 #if ORTHANC_ENABLE_WASM==1 | 451 #if ORTHANC_ENABLE_WASM==1 |
450 virtual void InitializeWasm() | 452 virtual void InitializeWasm() |
451 { | 453 { |
452 AttachWidgetToWasmViewport("canvas", thumbnailsLayout_); | 454 AttachWidgetToWasmViewport("canvas", thumbnailsLayout_); |
453 AttachWidgetToWasmViewport("canvas2", mainWidget_); | 455 AttachWidgetToWasmViewport("canvas2", widget); |
454 } | 456 } |
455 #endif | 457 #endif |
456 | 458 |
457 }; | 459 }; |
458 } | 460 } |