Mercurial > hg > orthanc-stone
changeset 103:474d85e76499 wasm
mpr
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 31 May 2017 18:05:33 +0200 |
parents | fcec0ab44054 |
children | eccd64f8e297 |
files | Applications/Samples/SingleVolumeApplication.h Framework/Widgets/LayerWidget.cpp Framework/Widgets/LayerWidget.h |
diffstat | 3 files changed, 50 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/Applications/Samples/SingleVolumeApplication.h Wed May 31 17:01:18 2017 +0200 +++ b/Applications/Samples/SingleVolumeApplication.h Wed May 31 18:05:33 2017 +0200 @@ -120,7 +120,7 @@ LayerWidget* widget_; - OrthancVolumeImage* volume_; + const OrthancVolumeImage* volume_; VolumeProjection projection_; std::auto_ptr<VolumeImageGeometry> slices_; size_t slice_;
--- a/Framework/Widgets/LayerWidget.cpp Wed May 31 17:01:18 2017 +0200 +++ b/Framework/Widgets/LayerWidget.cpp Wed May 31 18:05:33 2017 +0200 @@ -375,6 +375,8 @@ ResetPendingScene(); layer->Register(*this); + ResetChangedLayers(); + return index; } @@ -435,7 +437,9 @@ if (LookupLayer(i, source)) { LOG(INFO) << "Geometry ready for layer " << i; - layers_[i]->ScheduleLayerCreation(slice_); + + changedLayers_[i] = true; + //layers_[i]->ScheduleLayerCreation(slice_); } } @@ -451,7 +455,9 @@ for (size_t i = 0; i < layers_.size(); i++) { assert(layers_[i] != NULL); - layers_[i]->ScheduleLayerCreation(slice_); + changedLayers_[i] = true; + + //layers_[i]->ScheduleLayerCreation(slice_); } } @@ -464,7 +470,9 @@ } assert(layers_[layer] != NULL); - layers_[layer]->ScheduleLayerCreation(slice_); + changedLayers_[layer] = true; + + //layers_[layer]->ScheduleLayerCreation(slice_); } @@ -473,7 +481,7 @@ size_t index; if (LookupLayer(index, source)) { - layers_[index]->ScheduleLayerCreation(slice_); + InvalidateLayer(index); } } @@ -486,7 +494,7 @@ size_t index; if (LookupLayer(index, source)) { - layers_[index]->ScheduleLayerCreation(slice_); + InvalidateLayer(index); } } } @@ -521,4 +529,31 @@ } } } + + + void LayerWidget::ResetChangedLayers() + { + changedLayers_.resize(layers_.size()); + + for (size_t i = 0; i < changedLayers_.size(); i++) + { + changedLayers_[i] = false; + } + } + + + void LayerWidget::UpdateContent() + { + assert(changedLayers_.size() <= layers_.size()); + + for (size_t i = 0; i < changedLayers_.size(); i++) + { + if (changedLayers_[i]) + { + layers_[i]->ScheduleLayerCreation(slice_); + } + } + + ResetChangedLayers(); + } }
--- a/Framework/Widgets/LayerWidget.h Wed May 31 17:01:18 2017 +0200 +++ b/Framework/Widgets/LayerWidget.h Wed May 31 18:05:33 2017 +0200 @@ -45,7 +45,7 @@ SliceGeometry slice_; std::auto_ptr<Scene> currentScene_; std::auto_ptr<Scene> pendingScene_; - + std::vector<bool> changedLayers_; bool LookupLayer(size_t& index /* out */, const ILayerSource& layer) const; @@ -67,6 +67,7 @@ const Slice& slice, bool isError); + void ResetChangedLayers(); protected: virtual void GetSceneExtent(double& x1, @@ -108,5 +109,12 @@ { return slice_; } + + virtual bool HasUpdateContent() const + { + return true; + } + + virtual void UpdateContent(); }; }