public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (opacityFactor <= 0) { return; } int alpha = (int)(opacityFactor * 255); this.selected = selected; using (Pen p = styleHelper.GetPen(alpha, transformer.Scale)) { Rectangle boundingBox = transformer.Transform(center.Box(radius)); canvas.DrawEllipse(p, boundingBox); if (selected) { // Handler: arc in lower right quadrant. p.Color = p.Color.Invert(); canvas.DrawArc(p, boundingBox, 25, 40); } } }
private void DrawComputedPoints(Pen penEdge, Color basePenEdgeColor, SolidBrush brushHandle, Color baseBrushHandleColor, int alpha, double opacity, Graphics canvas, IImageToViewportTransformer transformer) { penEdge.Width = 2; foreach (GenericPostureComputedPoint computedPoint in genericPosture.ComputedPoints) { if (!IsActive(computedPoint.OptionGroup)) { continue; } PointF p = computedPoint.ComputeLocation(genericPosture); PointF p2 = transformer.Transform(p); if (!string.IsNullOrEmpty(computedPoint.Symbol)) { brushHandle.Color = computedPoint.Color == Color.Transparent ? baseBrushHandleColor : Color.FromArgb(alpha, computedPoint.Color); DrawSimpleText(p2, computedPoint.Symbol, canvas, opacity, transformer, brushHandle); } else { penEdge.Color = computedPoint.Color == Color.Transparent ? basePenEdgeColor : Color.FromArgb(alpha, computedPoint.Color); canvas.DrawEllipse(penEdge, p2.Box(3)); } if ((PreferencesManager.PlayerPreferences.EnableCustomToolsDebugMode) && !string.IsNullOrEmpty(computedPoint.Name)) { DrawDebugText(p2, debugOffset, computedPoint.Name, canvas, opacity, transformer); } } brushHandle.Color = baseBrushHandleColor; penEdge.Color = basePenEdgeColor; penEdge.Width = 1; }
/// <summary> /// Creates a timeline entry (TrackFrame) from an existing location. /// Does not perform any tracking. /// Extracts the pattern from the image. /// </summary> private TrackFrame CreateTrackFrame(PointF location, PositionningSource positionningSource) { Rectangle region = location.Box(trackerParameters.BlockWindow).ToRectangle(); Bitmap template = context.Image.ExtractTemplate(region); return(new TrackFrame(context.Time, location, template, positionningSource)); }
public static bool HitTest(PointF target, PointF mouse, IImageToViewportTransformer transformer) { int radius = 10; int boxRadius = Math.Max(1, transformer.Untransform(radius)); return(target.Box(boxRadius).Contains(mouse)); }
private bool IsPointOnArc(GenericPostureCircle circle, PointF point, IImageToViewportTransformer transformer) { using (GraphicsPath path = new GraphicsPath()) { PointF center = circle.Center >= 0 ? genericPosture.PointList[circle.Center] : GetUntransformedComputedPoint(circle.Center); path.AddArc(center.Box(circle.Radius), 0, 360); return(HitTester.HitTest(path, point, circle.Width, false, transformer)); } }
private bool IsPointInsideCircle(GenericPostureCircle circle, PointF point, IImageToViewportTransformer transformer) { using (GraphicsPath path = new GraphicsPath()) { PointF center = circle.Center >= 0 ? genericPosture.PointList[circle.Center] : GetUntransformedComputedPoint(circle.Center); path.AddEllipse(center.Box(circle.Radius)); return(HitTester.HitTest(path, point, 0, true, transformer)); } }
private void UpdateBoundingBox(PointF o, PointF a, PointF b, float radius) { if (radius == 0) { // Special case meaning "biggest as possible" -> up to the small leg. float oa = new Vector(o, a).Norm(); float ob = new Vector(o, b).Norm(); float smallest = Math.Min(oa, ob); radius = smallest > 20 ? smallest - 10 : Math.Min(smallest, 10); } boundingBox = o.Box((int)radius).ToRectangle(); }
private void DrawCircles(Pen penEdge, Color basePenEdgeColor, int alpha, Graphics canvas, IImageToViewportTransformer transformer, List <Point> points) { foreach (GenericPostureCircle circle in genericPosture.Circles) { if (!IsActive(circle.OptionGroup)) { continue; } penEdge.Width = circle.Width; penEdge.DashStyle = Convert(circle.Style); penEdge.Color = circle.Color == Color.Transparent ? basePenEdgeColor : Color.FromArgb(alpha, circle.Color); PointF center = circle.Center >= 0 ? points[circle.Center] : GetComputedPoint(circle.Center, transformer); int radius = transformer.Transform(circle.Radius); canvas.DrawEllipse(penEdge, center.Box(radius)); } penEdge.Color = basePenEdgeColor; }
public int HitTest(PointF point, bool hiddenHandle, int hiddenHandleRadius, IImageToViewportTransformer transformer) { int result = -1; SizeF size = rectangle.Size; RectangleF hitArea = rectangle; if (hiddenHandle && hiddenHandleRadius > 0) { PointF handleCenter = new PointF(hitArea.Right, hitArea.Bottom); if (handleCenter.Box(hiddenHandleRadius).Contains(point)) { result = 1; } } if (result < 0 && hitArea.Contains(point)) { result = 0; } return(result); }
public int HitTest(PointF point, bool hiddenHandle, IImageToViewportTransformer transformer) { int result = -1; SizeF size = rectangle.Size; RectangleF hitArea = rectangle; if (hiddenHandle) { int boxSide = (int)(size.Width / 4); PointF bottomRight = new PointF(hitArea.Right, hitArea.Bottom); if (bottomRight.Box(boxSide).Contains(point)) { result = 1; } } if (result < 0 && hitArea.Contains(point)) { result = 0; } return(result); }
public override RectangleF GetEditRectangle(PointF position) { return(position.Box(searchWindow)); }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (opacityFactor <= 0) { return; } int alpha = (int)(opacityFactor * 255); using (Pen p = styleHelper.GetPen(alpha, transformer.Scale)) { if (styleHelper.PenShape == PenShape.Dash) { p.DashStyle = DashStyle.Dash; } // The center of the original circle is still the correct center even in perspective. PointF circleCenter = transformer.Transform(center); DrawCenter(canvas, p, circleCenter.ToPoint()); if (CalibrationHelper.CalibratorType == CalibratorType.Plane) { // Draw the circle in perspective. PointF ellipseCenter = transformer.Transform(ellipseInImage.Center); float semiMinorAxis = transformer.Transform((int)ellipseInImage.SemiMinorAxis); float semiMajorAxis = transformer.Transform((int)ellipseInImage.SemiMajorAxis); Ellipse ellipse = new Ellipse(ellipseCenter, semiMajorAxis, semiMinorAxis, ellipseInImage.Rotation); RectangleF rect = new RectangleF(-ellipse.SemiMajorAxis, -ellipse.SemiMinorAxis, ellipse.SemiMajorAxis * 2, ellipse.SemiMinorAxis * 2); float angle = (float)(ellipse.Rotation * MathHelper.RadiansToDegrees); canvas.TranslateTransform(ellipse.Center.X, ellipse.Center.Y); canvas.RotateTransform(angle); canvas.DrawEllipse(p, rect); canvas.RotateTransform(-angle); canvas.TranslateTransform(-ellipse.Center.X, -ellipse.Center.Y); } else { Rectangle boundingBox = transformer.Transform(center.Box(radius)); canvas.DrawEllipse(p, boundingBox); } if (trackExtraData != TrackExtraData.None) { // Draw lines from the center to the periphery of the circle to show the radius or diameter. if (trackExtraData == TrackExtraData.Radius) { PointF radiusRight = transformer.Transform(radiusRightInImage); canvas.DrawLine(p, circleCenter, radiusRight); } else if (trackExtraData == TrackExtraData.Diameter) { PointF radiusLeft = transformer.Transform(radiusLeftInImage); PointF radiusRight = transformer.Transform(radiusRightInImage); canvas.DrawLine(p, radiusLeft, radiusRight); } string text = GetExtraDataText(infosFading.ReferenceTimestamp); miniLabel.SetText(text); miniLabel.Draw(canvas, transformer, opacityFactor); } } }