comparison Framework/Scene2D/Internals/CairoPolylineRenderer.cpp @ 595:6e471e6cf09b

CairoPolylineRenderer, SdlOpenGLWindow
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 26 Apr 2019 15:11:11 +0200
parents
children 61ba4b504e9a
comparison
equal deleted inserted replaced
594:9807ed3d3e03 595:6e471e6cf09b
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 "CairoPolylineRenderer.h"
23
24 #include "../PolylineSceneLayer.h"
25
26 namespace OrthancStone
27 {
28 namespace Internals
29 {
30 void CairoPolylineRenderer::Render(const AffineTransform2D& transform)
31 {
32 const PolylineSceneLayer& layer = GetLayer<PolylineSceneLayer>();
33
34 cairo_t* cr = GetCairoContext();
35
36 cairo_set_source_rgb(cr, layer.GetRedAsFloat(), layer.GetGreenAsFloat(), layer.GetBlueAsFloat());
37 cairo_set_line_width(cr, layer.GetThickness());
38
39 for (size_t i = 0; i < layer.GetChainsCount(); i++)
40 {
41 const PolylineSceneLayer::Chain& chain = layer.GetChain(i);
42
43 if (!chain.empty())
44 {
45 for (size_t j = 0; j < chain.size(); j++)
46 {
47 ScenePoint2D p = chain[j].Apply(transform);
48
49 if (j == 0)
50 {
51 cairo_move_to(cr, p.GetX(), p.GetY());
52 }
53 else
54 {
55 cairo_line_to(cr, p.GetX(), p.GetY());
56 }
57 }
58
59 if (layer.IsClosedChain(i))
60 {
61 ScenePoint2D p = chain[0].Apply(transform);
62 cairo_line_to(cr, p.GetX(), p.GetY());
63 }
64 }
65 }
66
67 cairo_stroke(cr);
68 }
69 }
70 }