annotate OrthancStone/Sources/Scene2D/MacroSceneLayer.cpp @ 1760:e38b9875a969

adaptation to change in API of Orthanc::HttpClient
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 04 May 2021 11:02:24 +0200
parents 9ac2a65d4172
children c5e6379b9cd0
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
1739
9ac2a65d4172 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * 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
9 * as published by the Free Software Foundation, either version 3 of
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * 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
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Lesser General Public License for more details.
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * 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
18 * License along with this program. If not, see
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * <http://www.gnu.org/licenses/>.
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
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 #include "MacroSceneLayer.h"
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include <OrthancException.h>
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
1624
59f95b9ea858 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1611
diff changeset
27 #include <cassert>
59f95b9ea858 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1611
diff changeset
28
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 namespace OrthancStone
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 void MacroSceneLayer::Clear()
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 for (size_t i = 0; i < layers_.size(); i++)
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 assert(layers_[i] != NULL);
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 delete layers_[i];
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 layers_.clear();
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 BumpRevision();
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 void MacroSceneLayer::AddLayer(ISceneLayer* layer)
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 if (layer == NULL)
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 else
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 layers_.push_back(layer);
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 BumpRevision();
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
1611
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
58 const ISceneLayer& MacroSceneLayer::GetLayer(size_t i) const
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
59 {
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
60 if (i >= layers_.size())
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
61 {
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
62 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
63 }
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
64 else
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
65 {
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
66 assert(layers_[i] != NULL);
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
67 return *layers_[i];
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
68 }
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
69 }
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
70
787db80a5a1b new class MacroLayerRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1610
diff changeset
71
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 ISceneLayer* MacroSceneLayer::Clone() const
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 std::unique_ptr<MacroSceneLayer> copy(new MacroSceneLayer);
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 copy->Reserve(layers_.size());
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 for (size_t i = 0; i < layers_.size(); i++)
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 {
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 assert(layers_[i] != NULL);
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 copy->layers_.push_back(layers_[i]->Clone());
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
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 return copy.release();
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
1610
b7630b1a0253 ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
88 void MacroSceneLayer::GetBoundingBox(Extent2D& target) const
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
1610
b7630b1a0253 ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
90 target.Clear();
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 for (size_t i = 0; i < layers_.size(); i++)
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 {
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 assert(layers_[i] != NULL);
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 Extent2D subextent;
1610
b7630b1a0253 ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
97 layers_[i]->GetBoundingBox(subextent);
b7630b1a0253 ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
98 target.Union(subextent);
1609
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 }
5f5c549499ff new class MacroSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 }