annotate OrthancStone/Sources/Scene2D/Internals/CompositorHelper.cpp @ 1652:fa9e6bf84958

integrating pdf.js into Stone Web viewer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 16 Nov 2020 20:47:53 +0100
parents 8563ea5d8ae4
children 9ac2a65d4172
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
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
585
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
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
15 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
16 *
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
18 * License along with this program. If not, see
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
19 * <http://www.gnu.org/licenses/>.
585
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
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "CompositorHelper.h"
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1326
diff changeset
25 #include <OrthancException.h>
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 namespace OrthancStone
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 {
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
29 namespace Internals
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
31 class CompositorHelper::Item : public boost::noncopyable
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
32 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
33 private:
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
34 std::unique_ptr<ILayerRenderer> renderer_;
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
35 const ISceneLayer& layer_;
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
36 uint64_t layerIdentifier_;
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
37 uint64_t lastRevision_;
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
38
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
39 public:
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
40 Item(ILayerRenderer* renderer, // Takes ownership
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
41 const ISceneLayer& layer,
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
42 uint64_t layerIdentifier) :
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
43 renderer_(renderer),
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
44 layer_(layer),
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
45 layerIdentifier_(layerIdentifier),
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
46 lastRevision_(layer.GetRevision())
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
47 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
48 if (renderer == NULL)
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
49 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
50 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
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
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
54 ILayerRenderer& GetRenderer() const
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
55 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
56 assert(renderer_.get() != NULL);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
57 return *renderer_;
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
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
60 const ISceneLayer& GetLayer() const
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
61 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
62 return layer_;
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
63 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
64
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
65 uint64_t GetLayerIdentifier() const
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
66 {
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
67 return layerIdentifier_;
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
68 }
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
69
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
70 uint64_t GetLastRevision() const
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
71 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
72 return lastRevision_;
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
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
75 void UpdateRenderer()
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
76 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
77 assert(renderer_.get() != NULL);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
78 renderer_->Update(layer_);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
79 lastRevision_ = layer_.GetRevision();
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 };
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
82
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
1211
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
84 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
85 const ISceneLayer& layer,
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
86 uint64_t layerIdentifier,
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
87 int depth)
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
89 // "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
90 assert(scene.HasLayer(depth));
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
91
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
92 Content::iterator found = content_.find(depth);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
93
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
94 assert(found == content_.end() ||
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
95 found->second != NULL);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
96
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
97 if (found == content_.end() ||
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
98 found->second->GetLayerIdentifier() != layerIdentifier)
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 {
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
100 // This is the first time this layer is rendered, or the layer
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
101 // is not the same as before
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
102 if (found != content_.end())
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
103 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
104 delete found->second;
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
105 content_.erase(found);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
106 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
107
1326
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
108 // the returned renderer can be NULL in case of an unknown layer
Benjamin Golinvaux <bgo@osimis.io>
parents: 1300
diff changeset
109 // or a NullLayer
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
110 std::unique_ptr<ILayerRenderer> renderer(factory_.Create(layer));
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
111
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
112 if (renderer.get() != NULL)
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
113 {
888
6e888cf6a48b renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 602
diff changeset
114 renderer->Render(sceneTransform_, canvasWidth_, canvasHeight_);
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 593
diff changeset
115 content_[depth] = new Item(renderer.release(), layer, layerIdentifier);
593
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 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
118 else
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
119 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
120 // 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
121 assert(found->second->GetLastRevision() <= layer.GetRevision());
1205
6009c59d8676 fix to sdl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
122
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
123 if (found->second->GetLastRevision() < layer.GetRevision())
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
124 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
125 found->second->UpdateRenderer();
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
126 }
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
127
888
6e888cf6a48b renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 602
diff changeset
128 found->second->GetRenderer().Render(sceneTransform_, canvasWidth_, canvasHeight_);
593
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
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
131 // Check invariants
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
132 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
133 (content_[depth]->GetLayerIdentifier() == layerIdentifier &&
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
134 content_[depth]->GetLastRevision() == layer.GetRevision()));
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
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
138 CompositorHelper::~CompositorHelper()
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
139 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
140 for (Content::iterator it = content_.begin(); it != content_.end(); ++it)
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
141 {
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
142 assert(it->second != NULL);
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
143 delete it->second;
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 }
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 }
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
147
1211
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
148 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
149 unsigned int canvasWidth,
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
150 unsigned int canvasHeight)
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 {
1211
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
152 /**
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
153 * 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
154 * 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
155 * 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
156 * 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
157 **/
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
158 if (lastScene_ != NULL &&
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
159 lastScene_ != &scene)
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
160 {
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
161 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
162 "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
163 }
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
164
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
165 lastScene_ = &scene;
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
166
593
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
167 // Bring coordinate (0,0) to the center of the canvas
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
168 AffineTransform2D offset = AffineTransform2D::CreateOffset(
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
169 static_cast<double>(canvasWidth) / 2.0,
6bf8f881fcb5 OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 585
diff changeset
170 static_cast<double>(canvasHeight) / 2.0);
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171
1211
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
172 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
173 canvasWidth_ = canvasWidth;
6e888cf6a48b renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 602
diff changeset
174 canvasHeight_ = canvasHeight;
1211
d10d2acb8a02 compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1205
diff changeset
175 scene.Apply(*this);
585
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 }
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 }
b9ce24c606ae TextSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }