public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityTrackable(trackingTimestamps, currentTimestamp); if (opacityFactor <= 0) { return; } Point start = transformer.Transform(points["a"]); Point end = transformer.Transform(points["b"]); using (Pen penEdges = styleHelper.GetPen(opacityFactor, transformer.Scale)) using (Brush brush = styleHelper.GetBrush(opacityFactor)) { if (distorter != null && distorter.Initialized) { DrawDistorted(canvas, distorter, transformer, penEdges, brush, start, end); } else { DrawStraight(canvas, transformer, penEdges, brush, start, end); } } if (trackExtraData != TrackExtraData.None) { string text = GetExtraDataText(); miniLabel.SetText(text); miniLabel.Draw(canvas, transformer, opacityFactor); } }
public double AddSpot(long timestamp, GraphicsPath path, IImageToViewportTransformer transformer) { // Add the shape of this spotlight to the global mask for the frame. // The dim rectangle is added separately in Spotlights class. double opacityFactor = infosFading.GetOpacityFactor(timestamp); if (tracking) { opacityFactor = 1.0; } if (opacityFactor <= 0) { return(0); } //RescaleCoordinates(_fStretchFactor, _DirectZoomTopLeft); Point center = transformer.Transform(points["o"]); int r = transformer.Transform(radius); rescaledRect = center.Box(r); path.AddEllipse(rescaledRect); // Return the opacity factor at this spot so the spotlights manager is able to compute the global dim value. return(opacityFactor); }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (tracking) { opacityFactor = 1.0; } if (opacityFactor <= 0) { return; } ComputeValues(transformer); Point pointO = transformer.Transform(points["o"]); Point pointA = transformer.Transform(points["a"]); Point pointB = transformer.Transform(points["b"]); Rectangle boundingBox = transformer.Transform(angleHelper.SweepAngle.BoundingBox); if (boundingBox.Size == Size.Empty) { return; } using (Pen penEdges = styleHelper.GetBackgroundPen((int)(opacityFactor * 255))) using (SolidBrush brushEdges = styleHelper.GetBackgroundBrush((int)(opacityFactor * 255))) using (SolidBrush brushFill = styleHelper.GetBackgroundBrush((int)(opacityFactor * defaultBackgroundAlpha))) { penEdges.Width = 2; // Disk section canvas.FillPie(brushFill, boundingBox, angleHelper.SweepAngle.Start, angleHelper.SweepAngle.Sweep); canvas.DrawArc(penEdges, boundingBox, angleHelper.SweepAngle.Start, angleHelper.SweepAngle.Sweep); // Edges penEdges.DashStyle = DashStyle.Dash; canvas.DrawLine(penEdges, pointO, pointA); penEdges.DashStyle = DashStyle.Solid; canvas.DrawLine(penEdges, pointO, pointB); // Handlers canvas.DrawEllipse(penEdges, pointO.Box(3)); canvas.FillEllipse(brushEdges, pointA.Box(3)); canvas.FillEllipse(brushEdges, pointB.Box(3)); angleHelper.DrawText(canvas, opacityFactor, brushFill, pointO, transformer, CalibrationHelper, styleHelper); } }
public override void Draw(Graphics canvas, AbstractTrackPoint point, IImageToViewportTransformer transformer, Color color, double opacityFactor) { // Draw the search and template boxes around the point. Point p = transformer.Transform(point.Point); Rectangle search = p.Box(transformer.Transform(searchWindow)); using (Pen pen = new Pen(Color.FromArgb((int)(opacityFactor * 192), color))) { canvas.DrawRectangle(pen, search); canvas.DrawRectangle(pen, p.Box(transformer.Transform(blockWindow))); //DrawDebugInfo(canvas, point, search); } }
private void DrawGridLine(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, Pen penLine, PointF a, PointF b) { if (distorter != null && distorter.Initialized) { List <PointF> curve = distorter.DistortRectifiedLine(a, b); List <Point> transformed = transformer.Transform(curve); canvas.DrawCurve(penLine, transformed.ToArray()); } else { PointF p1 = transformer.Transform(a); PointF p2 = transformer.Transform(b); canvas.DrawLine(penLine, p1, p2); } }
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); } } }
public void Draw(Graphics canvas, IImageToViewportTransformer transformer, long timestamp, StyleHelper styleHelper) { double opacityFactor = infosFading.GetOpacityFactor(timestamp); if (opacityFactor <= 0) { return; } using (SolidBrush brushBack = styleHelper.GetBackgroundBrush((int)(opacityFactor * 255))) using (SolidBrush brushText = styleHelper.GetForegroundBrush((int)(opacityFactor * 255))) using (Font fontText = styleHelper.GetFont((float)transformer.Scale)) using (Pen penContour = styleHelper.GetForegroundPen((int)(opacityFactor * 255))) { // Note: recompute background size in case the font floored. string text = value.ToString(); SizeF textSize = canvas.MeasureString(text, fontText); Point bgLocation = transformer.Transform(background.Rectangle.Location); Size bgSize = new Size((int)textSize.Width, (int)textSize.Height); SizeF untransformed = transformer.Untransform(textSize); background.Rectangle = new RectangleF(background.Rectangle.Location, untransformed); penContour.Width = 2; Rectangle rect = new Rectangle(bgLocation, bgSize); RoundedRectangle.Draw(canvas, rect, brushBack, fontText.Height / 4, false, true, penContour); canvas.DrawString(text, fontText, brushText, rect.Location); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (opacityFactor <= 0 || !loaded) { return; } Rectangle rect = transformer.Transform(boundingBox.Rectangle); if (finishedResizing) { finishedResizing = false; RenderAtNewScale(rect.Size, transformer.Scale); } if (svgRendered == null) { return; } fadingColorMatrix.Matrix33 = (float)opacityFactor; fadingImgAttr.SetColorMatrix(fadingColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); canvas.DrawImage(svgRendered, rect, 0, 0, svgRendered.Width, svgRendered.Height, GraphicsUnit.Pixel, fadingImgAttr); if (selected) { boundingBox.Draw(canvas, rect, penBoundingBox, brushBoundingBox, 4); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { if (!valid) { return; } double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (opacityFactor <= 0) { return; } Rectangle rect = transformer.Transform(boundingBox.Rectangle); fadingColorMatrix.Matrix33 = (float)opacityFactor; fadingImgAttr.SetColorMatrix(fadingColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); canvas.DrawImage(bitmap, rect, 0, 0, bitmap.Width, bitmap.Height, GraphicsUnit.Pixel, fadingImgAttr); if (selected) { boundingBox.Draw(canvas, rect, penBoundingBox, brushBoundingBox, 4); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (opacityFactor <= 0) { return; } using (Pen penLine = styleHelper.GetPen(opacityFactor, transformer.Scale)) { Point[] points = transformer.Transform(pointList).ToArray(); if (!initializing) { penLine.EndCap = LineCap.Round; penLine.StartCap = LineCap.Round; if (styleHelper.PenShape == PenShape.Dash) { penLine.DashStyle = DashStyle.Dash; } canvas.DrawCurve(penLine, points, 0.5f); } else { penLine.Width = 1.0f; canvas.DrawLines(penLine, points); } } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (opacityFactor <= 0 || editing) { return; } using (SolidBrush brushBack = styleHelper.GetBackgroundBrush((int)(opacityFactor * 128))) using (SolidBrush brushText = styleHelper.GetForegroundBrush((int)(opacityFactor * 255))) using (Font fontText = styleHelper.GetFont((float)transformer.Scale)) { // Note: recompute background size in case the font floored. SizeF textSize = canvas.MeasureString(text, fontText); Point bgLocation = transformer.Transform(background.Rectangle.Location); Size bgSize = new Size((int)textSize.Width, (int)textSize.Height); SizeF untransformed = transformer.Untransform(textSize); background.Rectangle = new RectangleF(background.Rectangle.Location, untransformed); Rectangle rect = new Rectangle(bgLocation, bgSize); RoundedRectangle.Draw(canvas, rect, brushBack, fontText.Height / 4, false, false, null); canvas.DrawString(text, fontText, brushText, rect.Location); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (tracking) { opacityFactor = 1.0; } if (opacityFactor <= 0) { return; } int iAlpha = (int)(opacityFactor * 255); Point c = transformer.Transform(points["0"]); using (Pen p = styleHelper.GetPen(iAlpha)) using (SolidBrush b = styleHelper.GetBrush((int)(opacityFactor * defaultBackgroundAlpha))) { canvas.DrawLine(p, c.X - defaultRadius, c.Y, c.X + defaultRadius, c.Y); canvas.DrawLine(p, c.X, c.Y - defaultRadius, c.X, c.Y + defaultRadius); canvas.FillEllipse(b, c.Box(defaultRadius + 1)); } if (trackExtraData != TrackExtraData.None) { string text = GetExtraDataText(infosFading.ReferenceTimestamp); miniLabel.SetText(text); miniLabel.Draw(canvas, transformer, opacityFactor); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (tracking) { opacityFactor = 1.0; } if (opacityFactor <= 0) { return; } int iAlpha = (int)(opacityFactor * 255); Point c = transformer.Transform(points["0"]); using (Pen p = styleHelper.GetPen(iAlpha)) using (SolidBrush b = styleHelper.GetBrush((int)(opacityFactor * defaultBackgroundAlpha))) { canvas.DrawLine(p, c.X - defaultRadius, c.Y, c.X + defaultRadius, c.Y); canvas.DrawLine(p, c.X, c.Y - defaultRadius, c.X, c.Y + defaultRadius); canvas.FillEllipse(b, c.Box(defaultRadius + 1)); } if (ShowMeasurableInfo) { labelCoordinates.SetText(CalibrationHelper.GetPointText(new PointF(points["0"].X, points["0"].Y), true, true, infosFading.ReferenceTimestamp)); labelCoordinates.Draw(canvas, transformer, opacityFactor); } }
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; }
private void DrawDistorted(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, Pen penEdges, Brush brush, Point start, Point end) { List <PointF> curve = distorter.DistortLine(points["a"], points["b"]); List <Point> transformedCurve = transformer.Transform(curve); if (styleHelper.LineShape == LineShape.Squiggle) { canvas.DrawSquigglyLine(penEdges, start, end); } else if (styleHelper.LineShape == LineShape.Dash) { DashStyle oldDashStyle = penEdges.DashStyle; penEdges.DashStyle = DashStyle.Dash; canvas.DrawCurve(penEdges, transformedCurve.ToArray()); penEdges.DashStyle = oldDashStyle; } else { canvas.DrawCurve(penEdges, transformedCurve.ToArray()); } miniLabel.SetAttach(curve[curve.Count / 2], true); if (styleHelper.LineEnding == LineEnding.StartArrow || styleHelper.LineEnding == LineEnding.DoubleArrow) { ArrowHelper.Draw(canvas, penEdges, start, end); } if (styleHelper.LineEnding == LineEnding.EndArrow || styleHelper.LineEnding == LineEnding.DoubleArrow) { ArrowHelper.Draw(canvas, penEdges, end, start); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (opacityFactor <= 0) { return; } QuadrilateralF quad = transformer.Transform(quadImage); int alpha = (int)(opacityFactor * 255); using (Pen p = styleHelper.GetPen(alpha, transformer.Scale)) { p.EndCap = LineCap.Square; if (styleHelper.PenShape == PenShape.Dash) { p.DashStyle = DashStyle.Dash; } canvas.DrawLine(p, quad.A, quad.B); canvas.DrawLine(p, quad.B, quad.C); canvas.DrawLine(p, quad.C, quad.D); canvas.DrawLine(p, quad.D, quad.A); } }
public void RelocateEditbox() { if (imageToViewportTransformer != null && host != null) { Rectangle rect = imageToViewportTransformer.Transform(background.Rectangle); textBox.Location = rect.Location.Translate(host.Left, host.Top); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacity = infosFading.GetOpacityFactor(currentTimestamp); if (opacity <= 0) { return; } //int backgroundOpacity = editing ? 255 : 192; int backgroundOpacity = 255; using (SolidBrush brushBack = styleHelper.GetBackgroundBrush((int)(opacity * backgroundOpacity))) using (SolidBrush brushText = styleHelper.GetForegroundBrush((int)(opacity * 255))) using (Pen pen = styleHelper.GetPen(backgroundOpacity)) using (Font fontText = styleHelper.GetFont((float)transformer.Scale)) { SizeF textSize = canvas.MeasureString(text, fontText); Point bgLocation = transformer.Transform(background.Rectangle.Location); Size bgSize = new Size((int)textSize.Width, (int)textSize.Height); SizeF untransformed = transformer.Untransform(textSize); background.Rectangle = new RectangleF(background.Rectangle.Location, untransformed); Rectangle rect = new Rectangle(bgLocation, bgSize); int roundingRadius = fontText.Height / 4; if (showArrow) { pen.Color = brushBack.Color; pen.Width = fontText.Height / 4; Point arrowStartInScreen = rect.Center(); Point arrowEndInScreen = transformer.Transform(arrowEnd); canvas.DrawLine(pen, arrowStartInScreen, arrowEndInScreen); ArrowHelper.Draw(canvas, pen, arrowEndInScreen, arrowStartInScreen); } RoundedRectangle.Draw(canvas, rect, brushBack, roundingRadius, false, false, null); if (!editing) { canvas.DrawString(text, fontText, brushText, rect.Location); } } }
private void DrawCenteredCircle(Graphics canvas, IImageToViewportTransformer transformer, Pen pen, float radiusX, float radiusY) { PointF a = Map(new PointF(-radiusX, radiusY)); PointF b = Map(new PointF(radiusX, radiusY)); PointF c = Map(new PointF(radiusX, -radiusY)); RectangleF rect = new RectangleF(a.X, a.Y, b.X - a.X, c.Y - a.Y); canvas.DrawEllipse(pen, transformer.Transform(rect)); }
private void DrawDistortedLine(Graphics canvas, Pen pen, PointF a, PointF b, ProjectiveMapping projectiveMapping, DistortionHelper distorter, IImageToViewportTransformer transformer) { a = projectiveMapping.Forward(a); b = projectiveMapping.Forward(b); if (distorter != null && distorter.Initialized) { a = distorter.Distort(a); b = distorter.Distort(b); List <PointF> curve = distorter.DistortLine(a, b); List <Point> transformed = transformer.Transform(curve); canvas.DrawCurve(penEdges, transformed.ToArray()); } else { canvas.DrawLine(pen, transformer.Transform(a), transformer.Transform(b)); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { if (currentTimestamp < visibleTimestamp) { return; } double opacityFactor = 1.0; if (currentTimestamp > invisibleTimestamp) { opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); } if (opacityFactor <= 0) { return; } timecode = GetTimecode(currentTimestamp); string text = timecode; using (SolidBrush brushBack = styleHelper.GetBackgroundBrush((int)(opacityFactor * 128))) using (SolidBrush brushText = styleHelper.GetForegroundBrush((int)(opacityFactor * 255))) using (Font fontText = styleHelper.GetFont((float)transformer.Scale)) { SizeF textSize = canvas.MeasureString(text, fontText); Point bgLocation = transformer.Transform(mainBackground.Rectangle.Location); Size bgSize = new Size((int)textSize.Width, (int)textSize.Height); SizeF untransformed = transformer.Untransform(textSize); mainBackground.Rectangle = new RectangleF(mainBackground.Rectangle.Location, untransformed); Rectangle rect = new Rectangle(bgLocation, bgSize); int roundingRadius = fontText.Height / 4; RoundedRectangle.Draw(canvas, rect, brushBack, roundingRadius, false, false, null); canvas.DrawString(text, fontText, brushText, rect.Location); if (showLabel && name.Length > 0) { using (Font fontLabel = styleHelper.GetFont((float)transformer.Scale * 0.5f)) { // Note: the alignment here assumes fixed margins of the rounded rectangle class. SizeF lblTextSize = canvas.MeasureString(name, fontLabel); int labelRoundingRadius = fontLabel.Height / 3; int top = rect.Location.Y - (int)lblTextSize.Height - roundingRadius - labelRoundingRadius; Rectangle lblRect = new Rectangle(rect.Location.X, top, (int)lblTextSize.Width, (int)lblTextSize.Height); RoundedRectangle.Draw(canvas, lblRect, brushBack, labelRoundingRadius, true, false, null); canvas.DrawString(name, fontLabel, brushText, lblRect.Location); } } } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (opacityFactor <= 0) { return; } List <Point> screenPoints = transformer.Transform(points); using (penEdges = styleHelper.GetPen(opacityFactor, 1.0)) using (SolidBrush br = styleHelper.GetBrush(opacityFactor)) { int rows = subdivisions + 1; int cols = rows; // Rows for (int i = 0; i < rows; i++) { int row = i; List <Point> line = new List <Point>(); for (int j = 0; j < cols; j++) { int index = row * cols + j; line.Add(screenPoints[index]); } canvas.DrawCurve(penEdges, line.ToArray()); } // Columns for (int i = 0; i < cols; i++) { int col = i; List <Point> line = new List <Point>(); for (int j = 0; j < rows; j++) { int index = j * cols + col; line.Add(screenPoints[index]); } canvas.DrawCurve(penEdges, line.ToArray()); } // Handles foreach (PointF p in screenPoints) { canvas.FillEllipse(br, p.Box(4)); } } }
private PointF GetComputedPoint(int index, IImageToViewportTransformer transformer) { PointF result = PointF.Empty; int computedPointIndex = -index - 1; if (computedPointIndex < genericPosture.ComputedPoints.Count) { result = genericPosture.ComputedPoints[computedPointIndex].LastPoint; } return(transformer.Transform(result)); }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (tracking) { opacityFactor = 1.0; } if (opacityFactor <= 0) { return; } Point start = transformer.Transform(points["a"]); Point end = transformer.Transform(points["b"]); using (Pen penEdges = styleHelper.GetPen((int)(opacityFactor * 255), transformer.Scale)) { if (distorter != null && distorter.Initialized) { DrawDistorted(canvas, distorter, transformer, penEdges, start, end); } else { DrawStraight(canvas, transformer, penEdges, start, end); } } if (ShowMeasurableInfo) { // Text of the measure. (The helpers knows the unit) PointF a = new PointF(points["a"].X, points["a"].Y); PointF b = new PointF(points["b"].X, points["b"].Y); labelMeasure.SetText(CalibrationHelper.GetLengthText(a, b, true, true)); labelMeasure.Draw(canvas, transformer, opacityFactor); } }
public void Draw(Graphics canvas, IImageToViewportTransformer transformer, double opacityFactor) { using (SolidBrush fillBrush = styleHelper.GetBackgroundBrush((int)(opacityFactor * 255))) using (Pen p = styleHelper.GetBackgroundPen((int)(opacityFactor * 64))) using (Font f = styleHelper.GetFont((float)transformer.Scale)) using (SolidBrush fontBrush = styleHelper.GetForegroundBrush((int)(opacityFactor * 255))) { SizeF textSize = canvas.MeasureString(text, f); Point location = transformer.Transform(background.Rectangle.Location); Size size = new Size((int)textSize.Width, (int)textSize.Height); SizeF untransformed = transformer.Untransform(textSize); background.Rectangle = new RectangleF(background.Rectangle.Location, untransformed); Point attch = transformer.Transform(attachLocation); Point center = transformer.Transform(background.Center); canvas.FillEllipse(fillBrush, attch.Box(2)); canvas.DrawLine(p, attch, center); Rectangle rect = new Rectangle(location, size); RoundedRectangle.Draw(canvas, rect, fillBrush, f.Height / 4, false, false, null); canvas.DrawString(text, f, fontBrush, rect.Location); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double fOpacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (fOpacityFactor <= 0) { return; } using (Pen penLine = styleHelper.GetPen(fOpacityFactor, transformer.Scale)) { Point[] points = transformer.Transform(pointList).ToArray(); canvas.DrawCurve(penLine, points, 0.5f); } }
private void DrawAngleText(Graphics canvas, double opacity, IImageToViewportTransformer transformer, AngleHelper angle, SolidBrush brushFill) { //------------------------------------------------- // FIXME: function duplicated. Move to AngleHelper. // This version is already more generic. //------------------------------------------------- double value = CalibrationHelper.ConvertAngleFromDegrees(angle.CalibratedAngle.Sweep); if (value < 0) { value = -value; } string label = ""; if (angle.Tenth) { label = String.Format("{0:0.0} {1}", value, CalibrationHelper.GetAngleAbbreviation()); } else { label = String.Format("{0} {1}", (int)Math.Round(value), CalibrationHelper.GetAngleAbbreviation()); } if (!string.IsNullOrEmpty(angle.Symbol)) { label = string.Format("{0} = {1}", angle.Symbol, label); } SolidBrush fontBrush = styleHelper.GetForegroundBrush((int)(opacity * 255)); Font tempFont = styleHelper.GetFont(Math.Max((float)transformer.Scale, 1.0F)); SizeF labelSize = canvas.MeasureString(label, tempFont); // Background float shiftx = (float)(transformer.Scale * angle.TextPosition.X); float shifty = (float)(transformer.Scale * angle.TextPosition.Y); Point origin = transformer.Transform(angle.Origin); PointF textOrigin = new PointF(shiftx + origin.X - labelSize.Width / 2, shifty + origin.Y - labelSize.Height / 2); RectangleF backRectangle = new RectangleF(textOrigin, labelSize); RoundedRectangle.Draw(canvas, backRectangle, brushFill, tempFont.Height / 4, false, false, null); // Text canvas.DrawString(label, tempFont, fontBrush, backRectangle.Location); tempFont.Dispose(); fontBrush.Dispose(); }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacity = infosFading.GetOpacityFactor(currentTimestamp); if (tracking) { opacity = 1.0; } if (opacity <= 0) { return; } List <Point> points = transformer.Transform(genericPosture.PointList); int alpha = (int)(opacity * 255); alpha = Math.Max(0, Math.Min(255, alpha)); int alphaBackground = (int)(opacity * defaultBackgroundAlpha); alphaBackground = Math.Max(0, Math.Min(255, alphaBackground)); using (Pen penEdge = styleHelper.GetBackgroundPen(alpha)) using (SolidBrush brushHandle = styleHelper.GetBackgroundBrush(alpha)) using (SolidBrush brushFill = styleHelper.GetBackgroundBrush(alphaBackground)) { Color basePenEdgeColor = penEdge.Color; Color baseBrushHandleColor = brushHandle.Color; Color baseBrushFillColor = brushFill.Color; DrawSegments(penEdge, basePenEdgeColor, alpha, canvas, transformer, points); DrawCircles(penEdge, basePenEdgeColor, alpha, canvas, transformer, points); DrawAngles(penEdge, basePenEdgeColor, brushFill, baseBrushFillColor, alpha, alphaBackground, opacity, canvas, transformer, points); DrawPoints(brushHandle, baseBrushHandleColor, alpha, canvas, transformer, points); DrawComputedPoints(penEdge, basePenEdgeColor, brushHandle, baseBrushHandleColor, alpha, opacity, canvas, transformer); DrawDistances(brushFill, baseBrushFillColor, alphaBackground, opacity, canvas, transformer, points); DrawPositions(brushFill, baseBrushFillColor, alphaBackground, opacity, canvas, transformer, points); if (PreferencesManager.PlayerPreferences.EnableCustomToolsDebugMode) { DrawDebug(opacity, canvas, transformer, points); } } }
public void Draw(Graphics canvas, IImageToViewportTransformer transformer, long timestamp, StyleHelper styleHelper) { double fOpacityFactor = infosFading.GetOpacityFactor(timestamp); if (fOpacityFactor <= 0) { return; } int alpha = (int)(255 * fOpacityFactor); //SetText(styleHelper); using (SolidBrush brushBack = styleHelper.GetBackgroundBrush((int)(fOpacityFactor * 255))) using (SolidBrush brushFront = styleHelper.GetForegroundBrush((int)(fOpacityFactor * 255))) using (Pen penContour = styleHelper.GetForegroundPen((int)(fOpacityFactor * 255))) using (Font f = styleHelper.GetFont((float)transformer.Scale)) { // Note: recompute the background size each time in case font floored. string text = value.ToString(); penContour.Width = 2; SizeF textSize = canvas.MeasureString(text, f); Point bgLocation = transformer.Transform(background.Rectangle.Location); SizeF untransformed = transformer.Untransform(textSize); background.Rectangle = new RectangleF(background.Rectangle.Location, untransformed); Size bgSize; if (value < 10) { bgSize = new Size((int)textSize.Height, (int)textSize.Height); Rectangle rect = new Rectangle(bgLocation, bgSize); canvas.FillEllipse(brushBack, rect); canvas.DrawEllipse(penContour, rect); } else { bgSize = new Size((int)textSize.Width, (int)textSize.Height); Rectangle rect = new Rectangle(bgLocation, bgSize); RoundedRectangle.Draw(canvas, rect, brushBack, f.Height / 4, false, true, penContour); } int verticalShift = (int)(textSize.Height / 10); Point textLocation = new Point(bgLocation.X + (int)((bgSize.Width - textSize.Width) / 2), bgLocation.Y + verticalShift); canvas.DrawString(text, f, brushFront, textLocation); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityTrackable(trackingTimestamps, currentTimestamp); if (opacityFactor <= 0) { return; } QuadrilateralF quad = transformer.Transform(quadImage); bool drawEdgesOnly = !planeIsConvex || (!styleHelper.Perspective && !quadImage.IsAxisAlignedRectangle); using (penEdges = styleHelper.GetPen(opacityFactor, 1.0)) using (SolidBrush br = styleHelper.GetBrush(opacityFactor)) { foreach (PointF p in quad) { canvas.FillEllipse(br, p.Box(4)); } if (!drawEdgesOnly) { if (distorter != null && distorter.Initialized) { QuadrilateralF undistortedQuadImage = distorter.Undistort(quadImage); projectiveMapping.Update(quadPlane, undistortedQuadImage); } else { projectiveMapping.Update(quadPlane, quadImage); } DrawGrid(canvas, penEdges, projectiveMapping, distorter, transformer); } else { // Non convex quadrilateral or non rectangle 2d grid: only draw the edges. canvas.DrawLine(penEdges, quad.A, quad.B); canvas.DrawLine(penEdges, quad.B, quad.C); canvas.DrawLine(penEdges, quad.C, quad.D); canvas.DrawLine(penEdges, quad.D, quad.A); } } }