private void DrawDistanceText(PointF a, PointF b, string label, Graphics canvas, double opacity, IImageToViewportTransformer transformer, SolidBrush brushFill)
        {
            PointF middle = GeometryHelper.GetMiddlePoint(a, b);
            PointF offset = new PointF(0, 15);

            DrawTextOnBackground(middle, offset, label, canvas, opacity, transformer, brushFill);
        }
Example #2
0
 private void ResetAttachPoint()
 {
     if (trackExtraData == TrackExtraData.Name ||
         trackExtraData == TrackExtraData.Center ||
         trackExtraData == TrackExtraData.Diameter)
     {
         miniLabel.SetAttach(center, true);
     }
     else if (trackExtraData == TrackExtraData.Radius)
     {
         miniLabel.SetAttach(GeometryHelper.GetMiddlePoint(center, radiusRightInImage), true);
     }
     else if (trackExtraData == TrackExtraData.Circumference)
     {
         miniLabel.SetAttach(radiusRightInImage, true);
     }
 }
Example #3
0
        private void DrawIndicator(Graphics canvas, string label, PointF a, PointF b)
        {
            PointF middle = GeometryHelper.GetMiddlePoint(a, b);

            Font  tempFont  = new Font("Arial", 9, FontStyle.Regular);
            SizeF labelSize = canvas.MeasureString(label, tempFont);

            PointF textOrigin = new PointF(middle.X - labelSize.Width / 2, middle.Y - labelSize.Height / 2);

            SolidBrush brushBack = new SolidBrush(pnlQuadrilateral.BackColor);

            canvas.FillRectangle(brushBack, textOrigin.X, textOrigin.Y, labelSize.Width, labelSize.Height);

            SolidBrush brushFont = new SolidBrush(pnlQuadrilateral.ForeColor);

            canvas.DrawString(label, tempFont, brushFont, textOrigin);

            tempFont.Dispose();
            brushBack.Dispose();
            brushFont.Dispose();
        }
Example #4
0
        private static void SegmentCenter(GenericPosture posture, CalibrationHelper calibrationHelper, GenericPostureImpactSegmentCenter impact)
        {
            // The point is moved so that it stays at the center of the specified segment.
            // This should take perspective into account.

            if (impact == null)
            {
                return;
            }

            PointF p1 = posture.PointList[impact.Point1];
            PointF p2 = posture.PointList[impact.Point2];

            PointF p1Plane = calibrationHelper.GetPoint(p1);
            PointF p2Plane = calibrationHelper.GetPoint(p2);

            PointF resultPlane = GeometryHelper.GetMiddlePoint(p1Plane, p2Plane);

            PointF result = calibrationHelper.GetImagePoint(resultPlane);

            posture.PointList[impact.PointToMove] = result;
        }
        private void DrawDebug(double opacity, Graphics canvas, IImageToViewportTransformer transformer, List <Point> points)
        {
            // Note: some of the labels are drawn during the normal method with an extra test there.
            PointF offset = new PointF(10, 10);

            // Points id.
            for (int i = 0; i < genericPosture.PointList.Count; i++)
            {
                string label = string.Format("P{0}", i);
                PointF p     = points[i];
                DrawDebugText(p, offset, label, canvas, opacity, transformer);
            }

            // Segments id and name.
            for (int i = 0; i < genericPosture.Segments.Count; i++)
            {
                GenericPostureSegment segment = genericPosture.Segments[i];
                if (segment.Start < 0 || segment.End < 0)
                {
                    continue;
                }

                PointF start  = points[segment.Start];
                PointF end    = points[segment.End];
                PointF middle = GeometryHelper.GetMiddlePoint(start, end);

                string label = "";
                if (!string.IsNullOrEmpty(segment.Name))
                {
                    label = string.Format("S{0} [P{1}, P{2}]: {3}", i, segment.Start, segment.End, segment.Name);
                }
                else
                {
                    label = string.Format("S{0} [P{1}, P{2}]", i, segment.Start, segment.End);
                }

                DrawDebugText(middle, offset, label, canvas, opacity, transformer);
            }
        }
Example #6
0
 private PointF GetMiddlePoint()
 {
     // Used only to attach the measure.
     return(GeometryHelper.GetMiddlePoint(points["a"], points["b"]));
 }