comparison Framework/Widgets/LayerWidget.cpp @ 89:f244018a4e4b wasm

BUGGY- trying to remove IVolumeSlicesObserver
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 26 May 2017 18:27:59 +0200
parents 4a541cd4fa83
children 64e60018943f
comparison
equal deleted inserted replaced
88:90bf4116a23c 89:f244018a4e4b
92 bool IsComplete() const 92 bool IsComplete() const
93 { 93 {
94 return countMissing_ == 0; 94 return countMissing_ == 0;
95 } 95 }
96 96
97 unsigned int GetCountMissing() const
98 {
99 return countMissing_;
100 }
101
97 bool RenderScene(CairoContext& context, 102 bool RenderScene(CairoContext& context,
98 const ViewportGeometry& view) 103 const ViewportGeometry& view)
99 { 104 {
100 bool fullQuality = true; 105 bool fullQuality = true;
101 106
102 for (size_t i = 0; i < renderers_.size(); i++) 107 for (size_t i = 0; i < renderers_.size(); i++)
103 { 108 {
109 if (renderers_[i] != NULL)
110 {
111 LOG(ERROR) << "...............";
112 }
113
104 if (renderers_[i] != NULL && 114 if (renderers_[i] != NULL &&
105 !renderers_[i]->RenderLayer(context, view, slice_)) 115 !renderers_[i]->RenderLayer(context, view, slice_))
106 { 116 {
107 return false; 117 return false;
108 } 118 }
300 slice.ContainsPlane(pendingScene_->GetSlice())) 310 slice.ContainsPlane(pendingScene_->GetSlice()))
301 { 311 {
302 pendingScene_->SetLayer(index, tmp.release()); 312 pendingScene_->SetLayer(index, tmp.release());
303 313
304 if (currentScene_.get() == NULL || 314 if (currentScene_.get() == NULL ||
315 !currentScene_->IsComplete() ||
305 pendingScene_->IsComplete()) 316 pendingScene_->IsComplete())
306 { 317 {
307 currentScene_ = pendingScene_; 318 currentScene_ = pendingScene_;
308 NotifyChange(); 319 NotifyChange();
309 } 320 }
338 layers_.push_back(layer); 349 layers_.push_back(layer);
339 styles_.push_back(RenderStyle()); 350 styles_.push_back(RenderStyle());
340 layersIndex_[layer] = index; 351 layersIndex_[layer] = index;
341 352
342 ResetPendingScene(); 353 ResetPendingScene();
354 LOG(ERROR) << "*****************************";
343 layer->SetObserver(*this); 355 layer->SetObserver(*this);
344 356
345 return index; 357 return index;
346 } 358 }
347 359
371 } 383 }
372 384
373 385
374 void LayerWidget::SetSlice(const SliceGeometry& slice) 386 void LayerWidget::SetSlice(const SliceGeometry& slice)
375 { 387 {
376 if (!slice_.IsSamePlane(slice, THIN_SLICE_THICKNESS)) 388 if (currentScene_.get() == NULL ||
377 { 389 (pendingScene_.get() != NULL &&
378 if (currentScene_.get() == NULL || 390 pendingScene_->IsComplete()))
379 (pendingScene_.get() != NULL && 391 {
380 pendingScene_->IsComplete())) 392 currentScene_ = pendingScene_;
381 { 393 }
382 currentScene_ = pendingScene_; 394
383 } 395 slice_ = slice;
384 396 ResetPendingScene();
385 slice_ = slice; 397 }
386 ResetPendingScene(); 398
387 399
388 for (size_t i = 0; i < layers_.size(); i++) 400 void LayerWidget::InvalidateAllLayers()
389 { 401 {
390 assert(layers_[i] != NULL); 402 for (size_t i = 0; i < layers_.size(); i++)
391 layers_[i]->ScheduleLayerCreation(slice_); 403 {
392 } 404 assert(layers_[i] != NULL);
393 }
394 }
395
396
397 void LayerWidget::NotifyGeometryReady(const ILayerSource& source)
398 {
399 size_t i;
400 if (LookupLayer(i, source))
401 {
402 LOG(INFO) << "Geometry ready for layer " << i;
403 layers_[i]->ScheduleLayerCreation(slice_); 405 layers_[i]->ScheduleLayerCreation(slice_);
404 } 406 }
405 } 407 }
406 408
407 409
408 void LayerWidget::NotifyGeometryError(const ILayerSource& source) 410 void LayerWidget::InvalidateLayer(size_t layer)
409 { 411 {
410 LOG(ERROR) << "Cannot get geometry"; 412 if (layer >= layers_.size())
411 } 413 {
412 414 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
415 }
416
417 assert(layers_[layer] != NULL);
418 layers_[layer]->ScheduleLayerCreation(slice_);
419 }
420
413 421
414 void LayerWidget::NotifyContentChange(const ILayerSource& source) 422 void LayerWidget::NotifyContentChange(const ILayerSource& source)
415 { 423 {
416 size_t index; 424 size_t index;
417 if (LookupLayer(index, source)) 425 if (LookupLayer(index, source))
432 layers_[index]->ScheduleLayerCreation(slice_); 440 layers_[index]->ScheduleLayerCreation(slice_);
433 } 441 }
434 } 442 }
435 } 443 }
436 444
437 445
438 void LayerWidget::NotifyLayerReady(ILayerRenderer* renderer, 446 void LayerWidget::NotifyLayerReady(ILayerRenderer* renderer,
439 const ILayerSource& source, 447 const ILayerSource& source,
440 const Slice& slice) 448 const Slice& slice)
441 { 449 {
442 std::auto_ptr<ILayerRenderer> tmp(renderer); 450 std::auto_ptr<ILayerRenderer> tmp(renderer);
454 void LayerWidget::NotifyLayerError(const ILayerSource& source, 462 void LayerWidget::NotifyLayerError(const ILayerSource& source,
455 const SliceGeometry& slice) 463 const SliceGeometry& slice)
456 { 464 {
457 size_t index; 465 size_t index;
458 466
467 Slice expected(slice_, THIN_SLICE_THICKNESS);
468
459 if (LookupLayer(index, source) && 469 if (LookupLayer(index, source) &&
460 slice.IsSamePlane(slice_, THIN_SLICE_THICKNESS)) // Whether the slice comes from an older request 470 expected.ContainsPlane(slice)) // Whether the slice comes from an older request
461 { 471 {
462 LOG(INFO) << "Unable to load a slice from layer " << index; 472 LOG(INFO) << "Unable to load a slice from layer " << index;
463 473
464 double x1, y1, x2, y2; 474 double x1, y1, x2, y2;
465 if (GetAndFixExtent(x1, y1, x2, y2, *layers_[index])) 475 if (GetAndFixExtent(x1, y1, x2, y2, *layers_[index]))