Mercurial > hg > orthanc-stone
annotate Framework/Widgets/CairoWidget.cpp @ 254:abc1c6231947 am-2
cleanup
author | am@osimis.io |
---|---|
date | Tue, 03 Jul 2018 11:49:02 +0200 |
parents | 5412adf19980 |
children | f21ba2468570 ce48c3b3b0e9 |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
134
4cff7b1ed31d
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 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. | |
0 | 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 | |
47 | 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 | |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
22 #include "CairoWidget.h" | |
23 | |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
24 #include <Core/Images/ImageProcessing.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
25 #include <Core/OrthancException.h> |
0 | 26 |
27 namespace OrthancStone | |
28 { | |
29 static bool IsAligned(const Orthanc::ImageAccessor& target) | |
30 { | |
31 // TODO | |
32 return true; | |
33 } | |
34 | |
35 | |
36 void CairoWidget::SetSize(unsigned int width, | |
37 unsigned int height) | |
38 { | |
39 surface_.SetSize(width, height); | |
40 } | |
41 | |
42 | |
43 bool CairoWidget::Render(Orthanc::ImageAccessor& target) | |
44 { | |
45 // Don't call the base class here, as | |
46 // "ClearBackgroundCairo()" is a faster alternative | |
47 | |
48 if (IsAligned(target)) | |
49 { | |
50 CairoSurface surface(target); | |
51 CairoContext context(surface); | |
52 ClearBackgroundCairo(context); | |
53 return RenderCairo(context); | |
54 } | |
55 else | |
56 { | |
57 CairoContext context(surface_); | |
58 ClearBackgroundCairo(context); | |
59 | |
60 if (RenderCairo(context)) | |
61 { | |
62 Orthanc::ImageProcessing::Copy(target, surface_.GetAccessor()); | |
63 return true; | |
64 } | |
65 else | |
66 { | |
67 return false; | |
68 } | |
69 } | |
70 } | |
71 | |
72 | |
73 void CairoWidget::RenderMouseOver(Orthanc::ImageAccessor& target, | |
74 int x, | |
75 int y) | |
76 { | |
77 if (IsAligned(target)) | |
78 { | |
79 CairoSurface surface(target); | |
80 CairoContext context(surface); | |
81 RenderMouseOverCairo(context, x, y); | |
82 } | |
83 else | |
84 { | |
85 Orthanc::ImageAccessor accessor = surface_.GetAccessor(); | |
86 Orthanc::ImageProcessing::Copy(accessor, target); | |
87 | |
88 CairoContext context(surface_); | |
89 RenderMouseOverCairo(context, x, y); | |
90 | |
91 Orthanc::ImageProcessing::Copy(target, accessor); | |
92 } | |
93 } | |
94 } |