annotate Framework/Layers/SliceOutlineRenderer.cpp @ 585:b9ce24c606ae

TextSceneLayer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 19 Apr 2019 17:57:58 +0200
parents b70e9be013e4
children 4f2416d519b4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
133
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
439
b70e9be013e4 preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
133
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "SliceOutlineRenderer.h"
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 namespace OrthancStone
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 {
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 bool SliceOutlineRenderer::RenderLayer(CairoContext& context,
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 const ViewportGeometry& view)
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 {
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 if (style_.visible_)
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 cairo_t *cr = context.GetObject();
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 cairo_save(cr);
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 context.SetSourceColor(style_.drawColor_);
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 double x1 = -0.5 * pixelSpacingX_;
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 double y1 = -0.5 * pixelSpacingY_;
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 cairo_set_line_width(cr, 1.0 / view.GetZoom());
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 cairo_rectangle(cr, x1, y1,
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 static_cast<double>(width_) * pixelSpacingX_,
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 static_cast<double>(height_) * pixelSpacingY_);
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 double handleSize = 10.0f / view.GetZoom();
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 cairo_move_to(cr, x1 + handleSize, y1);
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 cairo_line_to(cr, x1, y1 + handleSize);
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 cairo_stroke(cr);
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 cairo_restore(cr);
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 }
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 return true;
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 }
94d254b9d83d missing file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }