annotate Framework/Scene2D/CairoCompositor.cpp @ 920:5ca418d6579e refactor-viewport-controller

Close branch refactor-viewport-controller.
author Alain Mazy <am@osimis.io>
date Fri, 19 Jul 2019 14:15:49 +0000
parents 6129b1e5ba42
children 55411e7da2f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
597
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "CairoCompositor.h"
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "Internals/CairoColorTextureRenderer.h"
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "Internals/CairoFloatTextureRenderer.h"
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "Internals/CairoInfoPanelRenderer.h"
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "Internals/CairoPolylineRenderer.h"
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include "Internals/CairoTextRenderer.h"
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include <Core/OrthancException.h>
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 namespace OrthancStone
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 cairo_t* CairoCompositor::GetCairoContext()
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 if (context_.get() == NULL)
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 else
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 return context_->GetObject();
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 Internals::CompositorHelper::ILayerRenderer* CairoCompositor::Create(const ISceneLayer& layer)
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 switch (layer.GetType())
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 case ISceneLayer::Type_Polyline:
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 return new Internals::CairoPolylineRenderer(*this, layer);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 case ISceneLayer::Type_InfoPanel:
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 return new Internals::CairoInfoPanelRenderer(*this, layer);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 case ISceneLayer::Type_ColorTexture:
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 return new Internals::CairoColorTextureRenderer(*this, layer);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 case ISceneLayer::Type_FloatTexture:
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 return new Internals::CairoFloatTextureRenderer(*this, layer);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 case ISceneLayer::Type_Text:
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 const TextSceneLayer& l = dynamic_cast<const TextSceneLayer&>(layer);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 Fonts::const_iterator found = fonts_.find(l.GetFontIndex());
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 if (found == fonts_.end())
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 return NULL;
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 else
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 assert(found->second != NULL);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 return new Internals::CairoTextRenderer(*this, *found->second, l);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 default:
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 return NULL;
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
600
6129b1e5ba42 BasicScene SDL sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 598
diff changeset
85 CairoCompositor::CairoCompositor(const Scene2D& scene,
597
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 unsigned int canvasWidth,
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 unsigned int canvasHeight) :
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 helper_(scene, *this)
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 canvas_.SetSize(canvasWidth, canvasHeight, false);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 CairoCompositor::~CairoCompositor()
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 for (Fonts::iterator it = fonts_.begin(); it != fonts_.end(); ++it)
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 assert(it->second != NULL);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 delete it->second;
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 void CairoCompositor::SetFont(size_t index,
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 GlyphBitmapAlphabet* dict) // Takes ownership
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 if (dict == NULL)
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 else
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 std::auto_ptr<GlyphBitmapAlphabet> protection(dict);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 Fonts::iterator found = fonts_.find(index);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 if (found == fonts_.end())
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 fonts_[index] = protection.release();
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 else
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 assert(found->second != NULL);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 delete found->second;
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 found->second = protection.release();
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 #if ORTHANC_ENABLE_LOCALE == 1
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 void CairoCompositor::SetFont(size_t index,
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 Orthanc::EmbeddedResources::FileResourceId resource,
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 unsigned int fontSize,
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 Orthanc::Encoding codepage)
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 FontRenderer renderer;
598
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 597
diff changeset
139 renderer.LoadFont(resource, fontSize);
597
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 std::auto_ptr<GlyphBitmapAlphabet> alphabet(new GlyphBitmapAlphabet);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 alphabet->LoadCodepage(renderer, codepage);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 SetFont(index, alphabet.release());
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 #endif
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 void CairoCompositor::Refresh()
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 context_.reset(new CairoContext(canvas_));
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 // https://www.cairographics.org/FAQ/#clear_a_surface
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 cairo_set_source_rgba(context_->GetObject(), 0, 0, 0, 255);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 cairo_paint(context_->GetObject());
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 helper_.Refresh(canvas_.GetWidth(), canvas_.GetHeight());
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 context_.reset();
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 Orthanc::ImageAccessor* CairoCompositor::RenderText(size_t fontIndex,
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 const std::string& utf8) const
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 Fonts::const_iterator found = fonts_.find(fontIndex);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 if (found == fonts_.end())
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 return NULL;
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 else
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 {
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 assert(found->second != NULL);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 return found->second->RenderText(utf8);
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 }
9e51fb773bbd CairoCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 }