public AbstractDrawing IsOnExtraDrawing(PointF point, long timestamp) { // Check if the mouse is on one of the drawings not attached to any key image. // Returns the drawing on which we stand (or null if none), and select it on the way. // the caller will then check its type and decide which action to perform. AbstractDrawing result = null; foreach (DrawingChrono chrono in chronoManager.Drawings) { int hit = chrono.HitTest(point, timestamp, calibrationHelper.DistortionHelper, imageTransform, imageTransform.Zooming); if (hit < 0) { continue; } result = chrono; hitDrawing = chrono; break; } if (result != null) { return(result); } foreach (DrawingTrack track in trackManager.Drawings) { int hit = track.HitTest(point, timestamp, calibrationHelper.DistortionHelper, imageTransform, imageTransform.Zooming); if (hit < 0) { continue; } result = track; hitDrawing = track; break; } if (result != null) { return(result); } for (int i = extraDrawings.Count - 1; i >= 0; i--) { AbstractDrawing candidate = extraDrawings[i]; int hitRes = candidate.HitTest(point, timestamp, calibrationHelper.DistortionHelper, imageTransform, imageTransform.Zooming); if (hitRes < 0) { continue; } result = candidate; hitDrawing = candidate; break; } return(result); }
private bool DrawingsHitTest(int keyFrameIndex, PointF mouseLocation, long timestamp) { // Look for a hit in all drawings of a particular Key Frame. // Important side effect : the drawing being hit becomes Selected. This is then used for right click menu. if (keyframes.Count == 0) { return(false); } bool isOnDrawing = false; Keyframe keyframe = keyframes[keyFrameIndex]; UnselectAll(); int currentDrawing = 0; int hitResult = -1; while (hitResult < 0 && currentDrawing < keyframe.Drawings.Count) { AbstractDrawing drawing = keyframe.Drawings[currentDrawing]; hitResult = drawing.HitTest(mouseLocation, timestamp, calibrationHelper.DistortionHelper, imageTransform, imageTransform.Zooming); if (hitResult < 0) { currentDrawing++; continue; } isOnDrawing = true; SelectDrawing(drawing); SelectKeyframe(keyframe); } return(isOnDrawing); }