annotate OrthancStone/Sources/Scene2D/Internals/CompositorHelper.cpp @ 1512:244ad1e4e76a

reorganization of folders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 16:21:02 +0200
parents Framework/Scene2D/Internals/CompositorHelper.cpp@30deba7bc8e2
children 4fb8fdf03314
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1270
2d8ab34c8c91 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "CompositorHelper.h"
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1326
diff changeset
24 #include <OrthancException.h>
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 namespace OrthancStone
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 {
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
28 namespace Internals
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 {
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
30 class CompositorHelper::Item : public boost::noncopyable
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
31 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
32 private:
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
33 std::unique_ptr<ILayerRenderer> renderer_;
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
34 const ISceneLayer& layer_;
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
35 uint64_t layerIdentifier_;
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
36 uint64_t lastRevision_;
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
37
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
38 public:
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
39 Item(ILayerRenderer* renderer, // Takes ownership
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
40 const ISceneLayer& layer,
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
41 uint64_t layerIdentifier) :
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
42 renderer_(renderer),
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
43 layer_(layer),
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
44 layerIdentifier_(layerIdentifier),
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
45 lastRevision_(layer.GetRevision())
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
46 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
47 if (renderer == NULL)
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
48 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
49 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
50 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
51 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
52
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
53 ILayerRenderer& GetRenderer() const
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
54 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
55 assert(renderer_.get() != NULL);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
56 return *renderer_;
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
57 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
58
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
59 const ISceneLayer& GetLayer() const
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
60 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
61 return layer_;
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
62 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
63
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
64 uint64_t GetLayerIdentifier() const
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
65 {
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
66 return layerIdentifier_;
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
67 }
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
68
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
69 uint64_t GetLastRevision() const
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
70 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
71 return lastRevision_;
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
72 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
73
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
74 void UpdateRenderer()
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
75 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
76 assert(renderer_.get() != NULL);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
77 renderer_->Update(layer_);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
78 lastRevision_ = layer_.GetRevision();
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
79 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
80 };
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
81
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
1211
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
83 void CompositorHelper::Visit(const Scene2D& scene,
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
84 const ISceneLayer& layer,
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
85 uint64_t layerIdentifier,
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
86 int depth)
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
88 // "Visit()" is only applied to layers existing in the scene
1211
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
89 assert(scene.HasLayer(depth));
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
90
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
91 Content::iterator found = content_.find(depth);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
92
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
93 assert(found == content_.end() ||
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
94 found->second != NULL);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
95
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
96 if (found == content_.end() ||
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
97 found->second->GetLayerIdentifier() != layerIdentifier)
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 {
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
99 // This is the first time this layer is rendered, or the layer
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
100 // is not the same as before
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
101 if (found != content_.end())
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
102 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
103 delete found->second;
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
104 content_.erase(found);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
105 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
106
1326
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
107 // the returned renderer can be NULL in case of an unknown layer
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
108 // or a NullLayer
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
109 std::unique_ptr<ILayerRenderer> renderer(factory_.Create(layer));
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
110
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
111 if (renderer.get() != NULL)
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
112 {
888
6e888cf6a48b renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 602
diff changeset
113 renderer->Render(sceneTransform_, canvasWidth_, canvasHeight_);
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
114 content_[depth] = new Item(renderer.release(), layer, layerIdentifier);
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
115 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
116 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
117 else
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
118 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
119 // This layer has already been rendered
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
120 assert(found->second->GetLastRevision() <= layer.GetRevision());
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
121
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
122 if (found->second->GetLastRevision() < layer.GetRevision())
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
123 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
124 found->second->UpdateRenderer();
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
125 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
126
888
6e888cf6a48b renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 602
diff changeset
127 found->second->GetRenderer().Render(sceneTransform_, canvasWidth_, canvasHeight_);
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
128 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
129
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
130 // Check invariants
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
131 assert(content_.find(depth) == content_.end() ||
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
132 (content_[depth]->GetLayerIdentifier() == layerIdentifier &&
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
133 content_[depth]->GetLastRevision() == layer.GetRevision()));
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
134 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
135
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
136
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
137 CompositorHelper::~CompositorHelper()
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
138 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
139 for (Content::iterator it = content_.begin(); it != content_.end(); ++it)
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
140 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
141 assert(it->second != NULL);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
142 delete it->second;
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 }
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 }
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
146
1211
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
147 void CompositorHelper::Refresh(const Scene2D& scene,
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
148 unsigned int canvasWidth,
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
149 unsigned int canvasHeight)
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 {
1211
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
151 /**
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
152 * Safeguard mechanism to enforce the fact that the same scene
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
153 * is always used with the compositor. Note that the safeguard
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
154 * is not 100% bullet-proof, as a new scene might reuse the same
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
155 * address as a previous scene.
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
156 **/
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
157 if (lastScene_ != NULL &&
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
158 lastScene_ != &scene)
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
159 {
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
160 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls,
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
161 "ICompositor::ResetScene() should have been called");
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
162 }
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
163
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
164 lastScene_ = &scene;
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
165
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
166 // Bring coordinate (0,0) to the center of the canvas
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
167 AffineTransform2D offset = AffineTransform2D::CreateOffset(
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
168 static_cast<double>(canvasWidth) / 2.0,
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
169 static_cast<double>(canvasHeight) / 2.0);
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170
1211
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
171 sceneTransform_ = AffineTransform2D::Combine(offset, scene.GetSceneToCanvasTransform());
888
6e888cf6a48b renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 602
diff changeset
172 canvasWidth_ = canvasWidth;
6e888cf6a48b renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 602
diff changeset
173 canvasHeight_ = canvasHeight;
1211
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
174 scene.Apply(*this);
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 }
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 }
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 }