Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Scene2D/MacroSceneLayer.cpp @ 1609:5f5c549499ff
new class MacroSceneLayer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 29 Oct 2020 17:01:29 +0100 |
parents | |
children | b7630b1a0253 |
comparison
equal
deleted
inserted
replaced
1608:646e581e115b | 1609:5f5c549499ff |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Lesser General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
18 * License along with this program. If not, see | |
19 * <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
23 #include "MacroSceneLayer.h" | |
24 | |
25 #include <OrthancException.h> | |
26 | |
27 namespace OrthancStone | |
28 { | |
29 void MacroSceneLayer::Clear() | |
30 { | |
31 for (size_t i = 0; i < layers_.size(); i++) | |
32 { | |
33 assert(layers_[i] != NULL); | |
34 delete layers_[i]; | |
35 } | |
36 | |
37 layers_.clear(); | |
38 BumpRevision(); | |
39 } | |
40 | |
41 | |
42 void MacroSceneLayer::AddLayer(ISceneLayer* layer) | |
43 { | |
44 if (layer == NULL) | |
45 { | |
46 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
47 } | |
48 else | |
49 { | |
50 layers_.push_back(layer); | |
51 BumpRevision(); | |
52 } | |
53 } | |
54 | |
55 | |
56 ISceneLayer* MacroSceneLayer::Clone() const | |
57 { | |
58 std::unique_ptr<MacroSceneLayer> copy(new MacroSceneLayer); | |
59 | |
60 copy->Reserve(layers_.size()); | |
61 | |
62 for (size_t i = 0; i < layers_.size(); i++) | |
63 { | |
64 assert(layers_[i] != NULL); | |
65 copy->layers_.push_back(layers_[i]->Clone()); | |
66 } | |
67 | |
68 return copy.release(); | |
69 } | |
70 | |
71 | |
72 bool MacroSceneLayer::GetBoundingBox(Extent2D& target) const | |
73 { | |
74 target.Reset(); | |
75 | |
76 for (size_t i = 0; i < layers_.size(); i++) | |
77 { | |
78 assert(layers_[i] != NULL); | |
79 | |
80 Extent2D subextent; | |
81 if (layers_[i]->GetBoundingBox(subextent)) | |
82 { | |
83 target.Union(subextent); | |
84 } | |
85 } | |
86 | |
87 return true; | |
88 } | |
89 } |