comparison Framework/Widgets/LayerWidget.cpp @ 87:4a541cd4fa83 wasm

OrthancVolumeImageLoader
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 26 May 2017 15:31:58 +0200
parents 02c3a7a4938f
children f244018a4e4b
comparison
equal deleted inserted replaced
86:02c3a7a4938f 87:4a541cd4fa83
142 } 142 }
143 }; 143 };
144 144
145 145
146 bool LayerWidget::LookupLayer(size_t& index /* out */, 146 bool LayerWidget::LookupLayer(size_t& index /* out */,
147 ILayerSource& layer) const 147 const ILayerSource& layer) const
148 { 148 {
149 LayersIndex::const_iterator found = layersIndex_.find(&layer); 149 LayersIndex::const_iterator found = layersIndex_.find(&layer);
150 150
151 if (found == layersIndex_.end()) 151 if (found == layersIndex_.end())
152 { 152 {
392 } 392 }
393 } 393 }
394 } 394 }
395 395
396 396
397 void LayerWidget::NotifyGeometryReady(ILayerSource& source) 397 void LayerWidget::NotifyGeometryReady(const ILayerSource& source)
398 { 398 {
399 size_t i; 399 size_t i;
400 if (LookupLayer(i, source)) 400 if (LookupLayer(i, source))
401 { 401 {
402 LOG(INFO) << "Geometry ready for layer " << i; 402 LOG(INFO) << "Geometry ready for layer " << i;
403 layers_[i]->ScheduleLayerCreation(slice_); 403 layers_[i]->ScheduleLayerCreation(slice_);
404 } 404 }
405 } 405 }
406 406
407 407
408 void LayerWidget::NotifyGeometryError(ILayerSource& source) 408 void LayerWidget::NotifyGeometryError(const ILayerSource& source)
409 { 409 {
410 LOG(ERROR) << "Cannot get geometry"; 410 LOG(ERROR) << "Cannot get geometry";
411 } 411 }
412 412
413 413
414 void LayerWidget::NotifySourceChange(ILayerSource& source) 414 void LayerWidget::NotifyContentChange(const ILayerSource& source)
415 { 415 {
416 source.ScheduleLayerCreation(slice_); 416 size_t index;
417 } 417 if (LookupLayer(index, source))
418 418 {
419 419 layers_[index]->ScheduleLayerCreation(slice_);
420 void LayerWidget::NotifySliceChange(ILayerSource& source, 420 }
421 }
422
423
424 void LayerWidget::NotifySliceChange(const ILayerSource& source,
421 const Slice& slice) 425 const Slice& slice)
422 { 426 {
423 if (slice.ContainsPlane(slice_)) 427 if (slice.ContainsPlane(slice_))
424 { 428 {
425 source.ScheduleLayerCreation(slice_); 429 size_t index;
430 if (LookupLayer(index, source))
431 {
432 layers_[index]->ScheduleLayerCreation(slice_);
433 }
426 } 434 }
427 } 435 }
428 436
429 437
430 void LayerWidget::NotifyLayerReady(ILayerRenderer* renderer, 438 void LayerWidget::NotifyLayerReady(ILayerRenderer* renderer,
431 ILayerSource& source, 439 const ILayerSource& source,
432 const Slice& slice) 440 const Slice& slice)
433 { 441 {
434 std::auto_ptr<ILayerRenderer> tmp(renderer); 442 std::auto_ptr<ILayerRenderer> tmp(renderer);
435 443
436 size_t index; 444 size_t index;
441 UpdateLayer(index, tmp.release(), slice); 449 UpdateLayer(index, tmp.release(), slice);
442 } 450 }
443 } 451 }
444 452
445 453
446 void LayerWidget::NotifyLayerError(ILayerSource& source, 454 void LayerWidget::NotifyLayerError(const ILayerSource& source,
447 const SliceGeometry& slice) 455 const SliceGeometry& slice)
448 { 456 {
449 size_t index; 457 size_t index;
450 458
451 if (LookupLayer(index, source) && 459 if (LookupLayer(index, source) &&
452 slice.IsSamePlane(slice_, THIN_SLICE_THICKNESS)) // Whether the slice comes from an older request 460 slice.IsSamePlane(slice_, THIN_SLICE_THICKNESS)) // Whether the slice comes from an older request
453 { 461 {
454 LOG(INFO) << "Unable to load a slice from layer " << index; 462 LOG(INFO) << "Unable to load a slice from layer " << index;
455 463
456 double x1, y1, x2, y2; 464 double x1, y1, x2, y2;
457 if (GetAndFixExtent(x1, y1, x2, y2, source)) 465 if (GetAndFixExtent(x1, y1, x2, y2, *layers_[index]))
458 { 466 {
459 UpdateLayer(index, new MissingLayerRenderer(x1, y1, x2, y2), Slice(slice, THIN_SLICE_THICKNESS)); 467 UpdateLayer(index, new MissingLayerRenderer(x1, y1, x2, y2), Slice(slice, THIN_SLICE_THICKNESS));
460 } 468 }
461 } 469 }
462 } 470 }