Mercurial > hg > orthanc-stone
changeset 219:26e3bfe30e66 am
ReplaceLayer()
author | am@osimis.io |
---|---|
date | Fri, 08 Jun 2018 14:41:45 +0200 |
parents | c2f0077bb5b8 |
children | d7b2590744f8 |
files | Framework/Widgets/LayerWidget.cpp Framework/Widgets/LayerWidget.h |
diffstat | 2 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Widgets/LayerWidget.cpp Thu Jun 07 17:03:47 2018 +0200 +++ b/Framework/Widgets/LayerWidget.cpp Fri Jun 08 14:41:45 2018 +0200 @@ -395,7 +395,29 @@ return index; } - + void LayerWidget::ReplaceLayer(size_t index, ILayerSource* layer) // Takes ownership + { + if (layer == NULL) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); + } + + if (index >= layers_.size()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + } + + delete layers_[index]; + layers_[index] = layer; + layersIndex_[layer] = index; + + ResetPendingScene(); + layer->Register(*this); + + InvalidateLayer(index); + } + + const RenderStyle& LayerWidget::GetLayerStyle(size_t layer) const { if (layer >= layers_.size())
--- a/Framework/Widgets/LayerWidget.h Thu Jun 07 17:03:47 2018 +0200 +++ b/Framework/Widgets/LayerWidget.h Fri Jun 08 14:41:45 2018 +0200 @@ -93,6 +93,8 @@ size_t AddLayer(ILayerSource* layer); // Takes ownership + void ReplaceLayer(size_t layerIndex, ILayerSource* layer); // Takes ownership + size_t GetLayerCount() const { return layers_.size();