Mercurial > hg > orthanc-stone
comparison Framework/Layers/MissingLayerRenderer.h @ 88:90bf4116a23c wasm
ISlicedVolume
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 26 May 2017 16:11:52 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
87:4a541cd4fa83 | 88:90bf4116a23c |
---|---|
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 Osimis, 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 #pragma once | |
23 | |
24 #include "ILayerRenderer.h" | |
25 | |
26 namespace OrthancStone | |
27 { | |
28 class MissingLayerRenderer : public ILayerRenderer | |
29 { | |
30 private: | |
31 double x1_; | |
32 double y1_; | |
33 double x2_; | |
34 double y2_; | |
35 RenderStyle style_; | |
36 | |
37 public: | |
38 MissingLayerRenderer(double x1, | |
39 double y1, | |
40 double x2, | |
41 double y2) : | |
42 x1_(x1), | |
43 y1_(y1), | |
44 x2_(x2), | |
45 y2_(y2) | |
46 { | |
47 if (x1_ > x2_) | |
48 { | |
49 std::swap(x1_, x2_); | |
50 } | |
51 | |
52 if (y1_ > y2_) | |
53 { | |
54 std::swap(y1_, y2_); | |
55 } | |
56 } | |
57 | |
58 virtual bool RenderLayer(CairoContext& context, | |
59 const ViewportGeometry& view, | |
60 const SliceGeometry& viewportSlice) | |
61 { | |
62 if (style_.visible_) | |
63 { | |
64 view.ApplyTransform(context); | |
65 context.SetSourceColor(style_.drawColor_); | |
66 | |
67 cairo_t *cr = context.GetObject(); | |
68 cairo_set_line_width(cr, 1.0 / view.GetZoom()); | |
69 cairo_rectangle(cr, x1_, y1_, x2_ - x1_, y2_ - y1_); | |
70 | |
71 double handleSize = 10.0f / view.GetZoom(); | |
72 cairo_move_to(cr, x1_ + handleSize, y1_); | |
73 cairo_line_to(cr, x1_, y1_ + handleSize); | |
74 | |
75 cairo_stroke(cr); | |
76 } | |
77 | |
78 return true; | |
79 } | |
80 | |
81 virtual void SetLayerStyle(const RenderStyle& style) | |
82 { | |
83 style_ = style; | |
84 } | |
85 | |
86 virtual bool IsFullQuality() | |
87 { | |
88 return true; | |
89 } | |
90 }; | |
91 } |