Mercurial > hg > orthanc-stone
annotate Framework/Scene2D/Internals/CairoInfoPanelRenderer.cpp @ 1069:5d1b0d2f4b15 broker
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 15 Oct 2019 21:11:09 +0200 |
parents | 6e79e8c9021c |
children | 2d8ab34c8c91 |
rev | line source |
---|---|
597 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #include "CairoInfoPanelRenderer.h" | |
23 | |
24 #include "../InfoPanelSceneLayer.h" | |
25 | |
26 namespace OrthancStone | |
27 { | |
28 namespace Internals | |
29 { | |
30 void CairoInfoPanelRenderer::Update(const ISceneLayer& layer) | |
31 { | |
32 const InfoPanelSceneLayer& l = dynamic_cast<const InfoPanelSceneLayer&>(layer); | |
33 | |
34 texture_.Copy(l.GetTexture(), true); | |
35 anchor_ = l.GetAnchor(); | |
36 isLinearInterpolation_ = l.IsLinearInterpolation(); | |
37 } | |
38 | |
39 | |
888
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
597
diff
changeset
|
40 void CairoInfoPanelRenderer::Render(const AffineTransform2D& transform, |
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
597
diff
changeset
|
41 unsigned int canvasWidth, |
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
597
diff
changeset
|
42 unsigned int canvasHeight) |
597 | 43 { |
44 int dx, dy; | |
45 InfoPanelSceneLayer::ComputeAnchorLocation( | |
46 dx, dy, anchor_, texture_.GetWidth(), texture_.GetHeight(), | |
888
6e888cf6a48b
renderers now have access to canvas width/height
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
597
diff
changeset
|
47 canvasWidth, canvasHeight); |
597 | 48 |
49 cairo_t* cr = target_.GetCairoContext(); | |
50 | |
51 cairo_save(cr); | |
52 | |
53 cairo_matrix_t t; | |
54 cairo_matrix_init_identity(&t); | |
55 cairo_matrix_translate(&t, dx, dy); | |
56 cairo_transform(cr, &t); | |
57 | |
58 cairo_set_operator(cr, CAIRO_OPERATOR_OVER); | |
59 cairo_set_source_surface(cr, texture_.GetObject(), 0, 0); | |
60 | |
61 if (isLinearInterpolation_) | |
62 { | |
63 cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_BILINEAR); | |
64 } | |
65 else | |
66 { | |
67 cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_NEAREST); | |
68 } | |
69 | |
70 cairo_paint(cr); | |
71 | |
72 cairo_restore(cr); | |
73 } | |
74 } | |
75 } |