comparison Framework/Radiography/RadiographyLayer.cpp @ 480:2f6ecb5037ea am-touch-events

added mouse tracker for Layer Mask. Everything seems ok
author am@osimis.io
date Thu, 14 Feb 2019 10:18:02 +0100
parents a95090305dd4
children 77e0eb83ff63
comparison
equal deleted inserted replaced
479:e3d316ba34ba 480:2f6ecb5037ea
303 303
304 304
305 305
306 size_t RadiographyLayer::GetControlPointCount() const {return 4;} 306 size_t RadiographyLayer::GetControlPointCount() const {return 4;}
307 307
308 void RadiographyLayer::GetControlPointInternal(ControlPoint& controlPoint, 308 void RadiographyLayer::GetControlPoint(ControlPoint& cpScene /* out in scene coordinates */,
309 size_t index) const 309 size_t index) const
310 { 310 {
311 unsigned int cropX, cropY, cropWidth, cropHeight; 311 unsigned int cropX, cropY, cropWidth, cropHeight;
312 GetCrop(cropX, cropY, cropWidth, cropHeight); 312 GetCrop(cropX, cropY, cropWidth, cropHeight);
313 313
314 ControlPoint cp;
314 switch (index) 315 switch (index)
315 { 316 {
316 case ControlPoint_TopLeftCorner: 317 case ControlPoint_TopLeftCorner:
317 controlPoint = ControlPoint(cropX, cropY, ControlPoint_TopLeftCorner); 318 cp = ControlPoint(cropX, cropY, ControlPoint_TopLeftCorner);
318 break; 319 break;
319 320
320 case ControlPoint_TopRightCorner: 321 case ControlPoint_TopRightCorner:
321 controlPoint = ControlPoint(cropX + cropWidth, cropY, ControlPoint_TopRightCorner); 322 cp = ControlPoint(cropX + cropWidth, cropY, ControlPoint_TopRightCorner);
322 break; 323 break;
323 324
324 case ControlPoint_BottomLeftCorner: 325 case ControlPoint_BottomLeftCorner:
325 controlPoint = ControlPoint(cropX, cropY + cropHeight, ControlPoint_BottomLeftCorner); 326 cp = ControlPoint(cropX, cropY + cropHeight, ControlPoint_BottomLeftCorner);
326 break; 327 break;
327 328
328 case ControlPoint_BottomRightCorner: 329 case ControlPoint_BottomRightCorner:
329 controlPoint = ControlPoint(cropX + cropWidth, cropY + cropHeight, ControlPoint_BottomRightCorner); 330 cp = ControlPoint(cropX + cropWidth, cropY + cropHeight, ControlPoint_BottomRightCorner);
330 break; 331 break;
331 332
332 default: 333 default:
333 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 334 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
334 } 335 }
335 336
336 } 337 // transforms image coordinates into scene coordinates
337 338 GetTransform().Apply(cp.x, cp.y);
338 339 cpScene = cp;
339 340 }
340 void RadiographyLayer::GetControlPoint(ControlPoint& controlPoint /* out */, 341
341 size_t index) const 342 bool RadiographyLayer::LookupControlPoint(ControlPoint& cpScene /* out */,
342 {
343 GetControlPointInternal(controlPoint, index);
344 GetTransform().Apply(controlPoint.x, controlPoint.y);
345 }
346
347
348 bool RadiographyLayer::LookupControlPoint(ControlPoint& controlPoint /* out */,
349 double x, 343 double x,
350 double y, 344 double y,
351 double zoom, 345 double zoom,
352 double viewportDistance) const 346 double viewportDistance) const
353 { 347 {
360 354
361 double d = Square(cp.x - x) + Square(cp.y - y); 355 double d = Square(cp.x - x) + Square(cp.y - y);
362 356
363 if (d <= threshold) 357 if (d <= threshold)
364 { 358 {
365 controlPoint = cp; 359 cpScene = cp;
366 return true; 360 return true;
367 } 361 }
368 } 362 }
369 363
370 return false; 364 return false;