Mercurial > hg > orthanc-stone
comparison Framework/Scene2D/Scene2D.cpp @ 606:d9c0a66304cb
Scene2D::ReleaseLayer()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 29 Apr 2019 15:29:53 +0200 |
parents | 03c4b998fcd0 |
children | 500c3f70b6c2 |
comparison
equal
deleted
inserted
replaced
605:7a7e36c52d62 | 606:d9c0a66304cb |
---|---|
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 ISceneLayer& GetLayer() const | 47 ISceneLayer& GetLayer() const |
48 { | 48 { |
49 assert(layer_.get() != NULL); | 49 if (layer_.get() == NULL) |
50 return *layer_; | 50 { |
51 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
52 } | |
53 else | |
54 { | |
55 return *layer_; | |
56 } | |
57 } | |
58 | |
59 ISceneLayer* ReleaseLayer() | |
60 { | |
61 if (layer_.get() == NULL) | |
62 { | |
63 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
64 } | |
65 else | |
66 { | |
67 return layer_.release(); | |
68 } | |
51 } | 69 } |
52 | 70 |
53 uint64_t GetIdentifier() const | 71 uint64_t GetIdentifier() const |
54 { | 72 { |
55 return identifier_; | 73 return identifier_; |
129 { | 147 { |
130 Content::const_iterator found = content_.find(depth); | 148 Content::const_iterator found = content_.find(depth); |
131 | 149 |
132 if (found == content_.end()) | 150 if (found == content_.end()) |
133 { | 151 { |
134 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | 152 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
135 } | 153 } |
136 else | 154 else |
137 { | 155 { |
138 assert(found->second != NULL); | 156 assert(found->second != NULL); |
139 return found->second->GetLayer(); | 157 return found->second->GetLayer(); |
140 } | 158 } |
141 } | 159 } |
142 | 160 |
161 | |
162 ISceneLayer* Scene2D::ReleaseLayer(int depth) | |
163 { | |
164 Content::iterator found = content_.find(depth); | |
165 | |
166 if (found == content_.end()) | |
167 { | |
168 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
169 } | |
170 else | |
171 { | |
172 assert(found->second != NULL); | |
173 | |
174 std::auto_ptr<ISceneLayer> layer(found->second->ReleaseLayer()); | |
175 assert(layer.get() != NULL); | |
176 | |
177 content_.erase(found); | |
178 | |
179 return layer.release(); | |
180 } | |
181 } | |
182 | |
143 | 183 |
144 void Scene2D::Apply(IVisitor& visitor) const | 184 void Scene2D::Apply(IVisitor& visitor) const |
145 { | 185 { |
146 for (Content::const_iterator it = content_.begin(); | 186 for (Content::const_iterator it = content_.begin(); |
147 it != content_.end(); ++it) | 187 it != content_.end(); ++it) |