Ejemplo n.º 1
0
        private void InitializeValues()
        {
            if (calibrationHelper.IsCalibrated && calibrationHelper.CalibratorType == CalibratorType.Plane)
            {
                SizeF size = calibrationHelper.CalibrationByPlane_GetRectangleSize();
                tbA.Text = String.Format("{0:0.00}", size.Height);
                tbB.Text = String.Format("{0:0.00}", size.Width);

                cbUnit.SelectedIndex = (int)calibrationHelper.LengthUnit;
            }
            else
            {
                tbA.Text             = "100";
                tbB.Text             = "100";
                cbUnit.SelectedIndex = (int)LengthUnit.Centimeters;
            }

            // Prepare drawing.
            RectangleF bbox        = quadrilateral.GetBoundingBox();
            SizeF      usableSize  = new SizeF(pnlQuadrilateral.Width * 0.9f, pnlQuadrilateral.Height * 0.9f);
            float      ratioWidth  = bbox.Width / usableSize.Width;
            float      ratioHeight = bbox.Height / usableSize.Height;
            float      ratio       = Math.Max(ratioWidth, ratioHeight);

            float width  = bbox.Width / ratio;
            float height = bbox.Height / ratio;
            float top    = (pnlQuadrilateral.Height - height) / 2;
            float left   = (pnlQuadrilateral.Width - width) / 2;

            miniQuadrilateral = new QuadrilateralF();
            for (int i = 0; i < 4; i++)
            {
                PointF p = quadrilateral[i].Translate(-bbox.Left, -bbox.Top);
                p = p.Scale(1 / ratio, 1 / ratio);
                p = p.Translate(left, top);
                miniQuadrilateral[i] = p;
            }
        }
Ejemplo n.º 2
0
 public override PointF GetCopyPoint()
 {
     return(quadImage.GetBoundingBox().Center());
 }