annotate OrthancStone/Sources/Scene2D/MacroSceneLayer.cpp @ 1928:c73e696967b0 StoneWebViewer-2.3

StoneWebViewer-2.3
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 24 Mar 2022 09:08:51 +0100
parents 7053b8a0aaec
children 07964689cb0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1871
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * the License, or (at your option) any later version.
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * Lesser General Public License for more details.
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * License along with this program. If not, see
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * <http://www.gnu.org/licenses/>.
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "MacroSceneLayer.h"
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include <OrthancException.h>
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
28 #include <cassert>
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
29
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 namespace OrthancStone
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
32 void MacroSceneLayer::CheckInvariant() const
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
33 {
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
34 #if !defined(NDEBUG)
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
35 // Only run the sanity check in debug mode
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
36 size_t countRecycled = 0;
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
37
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
38 for (size_t i = 0; i < layers_.size(); i++)
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
39 {
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
40 if (layers_[i] == NULL)
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
41 {
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
42 assert(recycledLayers_.find(i) != recycledLayers_.end());
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
43 countRecycled++;
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
44 }
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
45 else
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
46 {
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
47 assert(recycledLayers_.find(i) == recycledLayers_.end());
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
48 }
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
49 }
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
50
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
51 assert(countRecycled == recycledLayers_.size());
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
52 #endif
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
53 }
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
54
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
55
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 void MacroSceneLayer::Clear()
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
58 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
59
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 for (size_t i = 0; i < layers_.size(); i++)
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
62 if (layers_[i] != NULL)
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
63 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
64 delete layers_[i];
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
65 }
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 layers_.clear();
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
69 recycledLayers_.clear();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
70
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 BumpRevision();
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
1793
c5e6379b9cd0 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
75 size_t MacroSceneLayer::AddLayer(ISceneLayer* layer)
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
77 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
78
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 if (layer == NULL)
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 {
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 else
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
85 size_t index;
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
86
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
87 if (recycledLayers_.empty())
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
88 {
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
89 index = layers_.size();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
90 layers_.push_back(layer);
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
91 }
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
92 else
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
93 {
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
94 index = *recycledLayers_.begin();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
95 assert(layers_[index] == NULL);
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
96 layers_[index] = layer;
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
97 recycledLayers_.erase(index);
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
98 }
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
99
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 BumpRevision();
1793
c5e6379b9cd0 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
101 return index;
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105
1796
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
106 void MacroSceneLayer::UpdateLayer(size_t index,
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
107 ISceneLayer* layer)
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
108 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
109 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
110
1796
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
111 if (layer == NULL)
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
112 {
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
113 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
114 }
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
115 else if (index >= layers_.size())
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
116 {
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
117 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
118 }
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
119 else
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
120 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
121 if (layers_[index] == NULL)
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
122 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
123 assert(recycledLayers_.find(index) != recycledLayers_.end());
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
124 recycledLayers_.erase(index);
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
125 }
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
126 else
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
127 {
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
128 assert(recycledLayers_.find(index) == recycledLayers_.end());
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
129 delete layers_[index];
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
130 }
1796
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
131
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
132 layers_[index] = layer;
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
133 BumpRevision();
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
134 }
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
135 }
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
136
20a0aba0ede5 creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1793
diff changeset
137
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
138 bool MacroSceneLayer::HasLayer(size_t index) const
1611
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
139 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
140 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
141
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
142 if (index >= layers_.size())
1611
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
143 {
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
144 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
145 }
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
146 else
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
147 {
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
148 return (layers_[index] != NULL);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
149 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
150 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
151
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
152
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
153 void MacroSceneLayer::DeleteLayer(size_t index)
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
154 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
155 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
156
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
157 if (index >= layers_.size())
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
158 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
159 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
160 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
161 else if (layers_[index] == NULL)
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
162 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
163 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentItem);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
164 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
165 else
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
166 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
167 delete layers_[index];
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
168 layers_[index] = NULL;
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
169
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
170 assert(recycledLayers_.find(index) == recycledLayers_.end());
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
171 recycledLayers_.insert(index);
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
172 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
173 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
174
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
175
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
176 const ISceneLayer& MacroSceneLayer::GetLayer(size_t index) const
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
177 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
178 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
179
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
180 if (index >= layers_.size())
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
181 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
182 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
183 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
184 else if (layers_[index] == NULL)
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
185 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
186 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentItem);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
187 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
188 else
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
189 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
190 return *layers_[index];
1611
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
191 }
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
192 }
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
193
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
194
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 ISceneLayer* MacroSceneLayer::Clone() const
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
197 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
198
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 std::unique_ptr<MacroSceneLayer> copy(new MacroSceneLayer);
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 for (size_t i = 0; i < layers_.size(); i++)
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 {
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
203 if (layers_[i] == NULL)
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
204 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
205 copy->layers_.push_back(NULL);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
206 }
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
207 else
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
208 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
209 copy->layers_.push_back(layers_[i]->Clone());
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
210 }
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
213 copy->recycledLayers_ = recycledLayers_;
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
214
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 return copy.release();
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218
1610
b7630b1a0253 ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
219 void MacroSceneLayer::GetBoundingBox(Extent2D& target) const
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 {
1802
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
221 CheckInvariant();
757987cb5a68 recycling of layers in MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
222
1610
b7630b1a0253 ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
223 target.Clear();
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 for (size_t i = 0; i < layers_.size(); i++)
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 {
1797
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
227 if (layers_[i] != NULL)
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
228 {
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
229 Extent2D subextent;
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
230 layers_[i]->GetBoundingBox(subextent);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
231 target.Union(subextent);
013dec434a84 creation of segment or circle measures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1796
diff changeset
232 }
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 }