comparison Framework/Radiography/RadiographyLayer.cpp @ 503:77e0eb83ff63 am-touch-events

layers are now Observable and emitting LayerEdited messages
author amazy
date Tue, 26 Feb 2019 12:58:03 +0100
parents 2f6ecb5037ea
children fd9b9d993fc7 42dadae61fa9
comparison
equal deleted inserted replaced
502:3ae7563b4fe1 503:77e0eb83ff63
115 cairo_close_path(cr); 115 cairo_close_path(cr);
116 cairo_stroke(cr); 116 cairo_stroke(cr);
117 } 117 }
118 118
119 119
120 RadiographyLayer::RadiographyLayer() : 120 RadiographyLayer::RadiographyLayer(MessageBroker& broker, const RadiographyScene& scene) :
121 IObservable(broker),
121 index_(0), 122 index_(0),
122 hasSize_(false), 123 hasSize_(false),
123 width_(0), 124 width_(0),
124 height_(0), 125 height_(0),
125 prefferedPhotometricDisplayMode_(PhotometricDisplayMode_Default) 126 prefferedPhotometricDisplayMode_(PhotometricDisplayMode_Default),
127 scene_(scene)
126 { 128 {
127 UpdateTransform(); 129 UpdateTransform();
128 } 130 }
129 131
130 void RadiographyLayer::ResetCrop() 132 void RadiographyLayer::ResetCrop()
131 { 133 {
132 geometry_.ResetCrop(); 134 geometry_.ResetCrop();
133 UpdateTransform(); 135 UpdateTransform();
136 }
137
138 void RadiographyLayer::SetPreferredPhotomotricDisplayMode(PhotometricDisplayMode prefferedPhotometricDisplayMode)
139 {
140 prefferedPhotometricDisplayMode_ = prefferedPhotometricDisplayMode;
141
142 EmitMessage(RadiographyLayer::LayerEditedMessage(*this));
134 } 143 }
135 144
136 void RadiographyLayer::SetCrop(unsigned int x, 145 void RadiographyLayer::SetCrop(unsigned int x,
137 unsigned int y, 146 unsigned int y,
138 unsigned int width, 147 unsigned int width,
149 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 158 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
150 } 159 }
151 160
152 geometry_.SetCrop(x, y, width, height); 161 geometry_.SetCrop(x, y, width, height);
153 UpdateTransform(); 162 UpdateTransform();
163
164 EmitMessage(RadiographyLayer::LayerEditedMessage(*this));
154 } 165 }
155 166
156 void RadiographyLayer::SetGeometry(const Geometry& geometry) 167 void RadiographyLayer::SetGeometry(const Geometry& geometry)
157 { 168 {
158 geometry_ = geometry; 169 geometry_ = geometry;
159 170
160 if (hasSize_) 171 if (hasSize_)
161 { 172 {
162 UpdateTransform(); 173 UpdateTransform();
163 } 174 }
175
176 EmitMessage(RadiographyLayer::LayerEditedMessage(*this));
164 } 177 }
165 178
166 179
167 void RadiographyLayer::GetCrop(unsigned int& x, 180 void RadiographyLayer::GetCrop(unsigned int& x,
168 unsigned int& y, 181 unsigned int& y,
185 198
186 void RadiographyLayer::SetAngle(double angle) 199 void RadiographyLayer::SetAngle(double angle)
187 { 200 {
188 geometry_.SetAngle(angle); 201 geometry_.SetAngle(angle);
189 UpdateTransform(); 202 UpdateTransform();
203
204 EmitMessage(RadiographyLayer::LayerEditedMessage(*this));
190 } 205 }
191 206
192 207
193 void RadiographyLayer::SetSize(unsigned int width, 208 void RadiographyLayer::SetSize(unsigned int width,
194 unsigned int height) 209 unsigned int height)
203 hasSize_ = true; 218 hasSize_ = true;
204 width_ = width; 219 width_ = width;
205 height_ = height; 220 height_ = height;
206 221
207 UpdateTransform(); 222 UpdateTransform();
223 EmitMessage(RadiographyLayer::LayerEditedMessage(*this));
208 } 224 }
209 225
210 226
211 Extent2D RadiographyLayer::GetExtent() const 227 Extent2D RadiographyLayer::GetExtent() const
212 { 228 {
280 void RadiographyLayer::SetPan(double x, 296 void RadiographyLayer::SetPan(double x,
281 double y) 297 double y)
282 { 298 {
283 geometry_.SetPan(x, y); 299 geometry_.SetPan(x, y);
284 UpdateTransform(); 300 UpdateTransform();
301 EmitMessage(RadiographyLayer::LayerEditedMessage(*this));
285 } 302 }
286 303
287 304
288 void RadiographyLayer::SetPixelSpacing(double x, 305 void RadiographyLayer::SetPixelSpacing(double x,
289 double y) 306 double y)
290 { 307 {
291 geometry_.SetPixelSpacing(x, y); 308 geometry_.SetPixelSpacing(x, y);
292 UpdateTransform(); 309 UpdateTransform();
310 EmitMessage(RadiographyLayer::LayerEditedMessage(*this));
293 } 311 }
294 312
295 313
296 void RadiographyLayer::GetCenter(double& centerX, 314 void RadiographyLayer::GetCenter(double& centerX,
297 double& centerY) const 315 double& centerY) const