Mercurial > hg > orthanc-stone
changeset 606:d9c0a66304cb
Scene2D::ReleaseLayer()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 29 Apr 2019 15:29:53 +0200 |
parents | 7a7e36c52d62 |
children | f4b37a991dac |
files | Framework/Scene2D/Scene2D.cpp Framework/Scene2D/Scene2D.h |
diffstat | 2 files changed, 45 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Scene2D/Scene2D.cpp Mon Apr 29 15:24:59 2019 +0200 +++ b/Framework/Scene2D/Scene2D.cpp Mon Apr 29 15:29:53 2019 +0200 @@ -46,8 +46,26 @@ ISceneLayer& GetLayer() const { - assert(layer_.get() != NULL); - return *layer_; + if (layer_.get() == NULL) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); + } + else + { + return *layer_; + } + } + + ISceneLayer* ReleaseLayer() + { + if (layer_.get() == NULL) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); + } + else + { + return layer_.release(); + } } uint64_t GetIdentifier() const @@ -131,7 +149,7 @@ if (found == content_.end()) { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } else { @@ -141,6 +159,28 @@ } + ISceneLayer* Scene2D::ReleaseLayer(int depth) + { + Content::iterator found = content_.find(depth); + + if (found == content_.end()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + } + else + { + assert(found->second != NULL); + + std::auto_ptr<ISceneLayer> layer(found->second->ReleaseLayer()); + assert(layer.get() != NULL); + + content_.erase(found); + + return layer.release(); + } + } + + void Scene2D::Apply(IVisitor& visitor) const { for (Content::const_iterator it = content_.begin();
--- a/Framework/Scene2D/Scene2D.h Mon Apr 29 15:24:59 2019 +0200 +++ b/Framework/Scene2D/Scene2D.h Mon Apr 29 15:29:53 2019 +0200 @@ -77,6 +77,8 @@ ISceneLayer& GetLayer(int depth) const; + ISceneLayer* ReleaseLayer(int depth); + void Apply(IVisitor& visitor) const; const AffineTransform2D& GetSceneToCanvasTransform() const