annotate Framework/Radiography/RadiographyWidget.cpp @ 418:c23df8b3433b

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 15 Nov 2018 18:32:48 +0100
parents 18b707fb8620
children 751fb354149e b70e9be013e4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "RadiographyWidget.h"
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include <Core/Images/Image.h>
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 namespace OrthancStone
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 bool RadiographyWidget::RenderInternal(unsigned int width,
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 unsigned int height,
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 ImageInterpolation interpolation)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 float windowCenter, windowWidth;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 scene_.GetWindowingWithDefault(windowCenter, windowWidth);
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 float x0 = windowCenter - windowWidth / 2.0f;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 float x1 = windowCenter + windowWidth / 2.0f;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 if (windowWidth <= 0.001f) // Avoid division by zero at (*)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 return false;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 else
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 if (floatBuffer_.get() == NULL ||
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 floatBuffer_->GetWidth() != width ||
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 floatBuffer_->GetHeight() != height)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 floatBuffer_.reset(new Orthanc::Image(Orthanc::PixelFormat_Float32, width, height, false));
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 if (cairoBuffer_.get() == NULL ||
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 cairoBuffer_->GetWidth() != width ||
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 cairoBuffer_->GetHeight() != height)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 cairoBuffer_.reset(new CairoSurface(width, height));
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 scene_.Render(*floatBuffer_, GetView().GetMatrix(), interpolation);
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 // Conversion from Float32 to BGRA32 (cairo). Very similar to
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 // GrayscaleFrameRenderer => TODO MERGE?
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 Orthanc::ImageAccessor target;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 cairoBuffer_->GetWriteableAccessor(target);
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 float scaling = 255.0f / (x1 - x0);
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 for (unsigned int y = 0; y < height; y++)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 const float* p = reinterpret_cast<const float*>(floatBuffer_->GetConstRow(y));
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y));
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 for (unsigned int x = 0; x < width; x++, p++, q += 4)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 uint8_t v = 0;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 if (*p >= x1)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 v = 255;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 else if (*p <= x0)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 v = 0;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 else
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 // https://en.wikipedia.org/wiki/Linear_interpolation
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 v = static_cast<uint8_t>(scaling * (*p - x0)); // (*)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 if (invert_)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 v = 255 - v;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 q[0] = v;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 q[1] = v;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 q[2] = v;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 q[3] = 255;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 return true;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 bool RadiographyWidget::RenderScene(CairoContext& context,
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 const ViewportGeometry& view)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 cairo_t* cr = context.GetObject();
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 if (RenderInternal(context.GetWidth(), context.GetHeight(), interpolation_))
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 // https://www.cairographics.org/FAQ/#paint_from_a_surface
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 cairo_save(cr);
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 cairo_identity_matrix(cr);
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 cairo_set_source_surface(cr, cairoBuffer_->GetObject(), 0, 0);
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 cairo_paint(cr);
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 cairo_restore(cr);
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 else
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 // https://www.cairographics.org/FAQ/#clear_a_surface
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 context.SetSourceColor(0, 0, 0);
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 cairo_paint(cr);
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 if (hasSelection_)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 scene_.DrawBorder(context, selectedLayer_, view.GetZoom());
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 return true;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 RadiographyWidget::RadiographyWidget(MessageBroker& broker,
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 RadiographyScene& scene,
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 const std::string& name) :
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 WorldSceneWidget(name),
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 IObserver(broker),
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 scene_(scene),
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 invert_(false),
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 interpolation_(ImageInterpolation_Nearest),
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 hasSelection_(false),
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 selectedLayer_(0) // Dummy initialization
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 scene.RegisterObserverCallback(
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 new Callable<RadiographyWidget, RadiographyScene::GeometryChangedMessage>
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 (*this, &RadiographyWidget::OnGeometryChanged));
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 scene.RegisterObserverCallback(
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 new Callable<RadiographyWidget, RadiographyScene::ContentChangedMessage>
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 (*this, &RadiographyWidget::OnContentChanged));
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 void RadiographyWidget::Select(size_t layer)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 hasSelection_ = true;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 selectedLayer_ = layer;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 bool RadiographyWidget::LookupSelectedLayer(size_t& layer)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 if (hasSelection_)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 layer = selectedLayer_;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 return true;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 else
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 return false;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 void RadiographyWidget::OnGeometryChanged(const RadiographyScene::GeometryChangedMessage& message)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 LOG(INFO) << "Geometry has changed";
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 FitContent();
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 void RadiographyWidget::OnContentChanged(const RadiographyScene::ContentChangedMessage& message)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 LOG(INFO) << "Content has changed";
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 NotifyContentChanged();
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 void RadiographyWidget::SetInvert(bool invert)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 if (invert_ != invert)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 invert_ = invert;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 NotifyContentChanged();
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 void RadiographyWidget::SwitchInvert()
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 invert_ = !invert_;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 NotifyContentChanged();
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 void RadiographyWidget::SetInterpolation(ImageInterpolation interpolation)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 if (interpolation_ != interpolation)
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 {
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 interpolation_ = interpolation;
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 NotifyContentChanged();
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 }
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 }