comparison Framework/Radiography/RadiographyScene.cpp @ 1201:ab958fd99b07

RadiographyScene fixes
author Alain Mazy <alain@mazy.be>
date Fri, 29 Nov 2019 16:21:24 +0100
parents 922d2e61aa5d
children b519c1c878f1 9ee6b28f53e8
comparison
equal deleted inserted replaced
1199:922d2e61aa5d 1201:ab958fd99b07
241 assert(found->second != NULL); 241 assert(found->second != NULL);
242 return *found->second; 242 return *found->second;
243 } 243 }
244 } 244 }
245 245
246 RadiographyLayer& RadiographyScene::GetLayer(size_t layerIndex)
247 {
248 Layers::const_iterator found = layers_.find(layerIndex);
249
250 if (found == layers_.end())
251 {
252 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
253 }
254 else
255 {
256 assert(found->second != NULL);
257 return *found->second;
258 }
259 }
260
246 bool RadiographyScene::GetWindowing(float& center, 261 bool RadiographyScene::GetWindowing(float& center,
247 float& width) const 262 float& width) const
248 { 263 {
249 if (hasWindowing_) 264 if (hasWindowing_)
250 { 265 {
276 hasWindowing_ = true; 291 hasWindowing_ = true;
277 windowingCenter_ = center; 292 windowingCenter_ = center;
278 windowingWidth_ = width; 293 windowingWidth_ = width;
279 294
280 BroadcastMessage(RadiographyScene::WindowingChangedMessage(*this)); 295 BroadcastMessage(RadiographyScene::WindowingChangedMessage(*this));
296 }
297
298
299 RadiographyLayer& RadiographyScene::UpdateText(size_t layerIndex,
300 const std::string& utf8,
301 unsigned int fontSize,
302 uint8_t foreground)
303 {
304 RadiographyTextLayer& textLayer = dynamic_cast<RadiographyTextLayer&>(GetLayer(layerIndex));
305 textLayer.SetText(utf8, fontSize, foreground);
306
307 BroadcastMessage(RadiographyScene::ContentChangedMessage(*this, textLayer));
308 BroadcastMessage(RadiographyScene::LayerEditedMessage(*this, textLayer));
309 return textLayer;
281 } 310 }
282 311
283 312
284 RadiographyLayer& RadiographyScene::LoadText(const std::string& utf8, 313 RadiographyLayer& RadiographyScene::LoadText(const std::string& utf8,
285 unsigned int fontSize, 314 unsigned int fontSize,
286 uint8_t foreground, 315 uint8_t foreground,
287 RadiographyLayer::Geometry* geometry) 316 RadiographyLayer::Geometry* geometry)
288 { 317 {
289 std::auto_ptr<RadiographyTextLayer> alpha(new RadiographyTextLayer(IObservable::GetBroker(), *this)); 318 std::auto_ptr<RadiographyTextLayer> alpha(new RadiographyTextLayer(IObservable::GetBroker(), *this));
290 alpha->LoadText(utf8, fontSize, foreground); 319 alpha->SetText(utf8, fontSize, foreground);
291 if (geometry != NULL) 320 if (geometry != NULL)
292 { 321 {
293 alpha->SetGeometry(*geometry); 322 alpha->SetGeometry(*geometry);
294 } 323 }
295 324