private void bStart_Click(object sender, EventArgs e)
        {
            if (Array == null)
            {
                MessageBox.Show("请先生成量测参数!!!");
                return;
            }

            if (Form_Main.Instance.imageSet.Roi.Count == 0 || Form_Main.Instance.imageSet.Roi[0].Shape.GetType() != typeof(RectangleContour))
            {
                MessageBox.Show("请正确绘制ROI!!!");
                return;
            }

            rx = new double[Array.Length];
            x  = new double[Array.Length];

            double space = (double)this.numSpace.Value;

            double rate = 0;

            if (this.IsX)
            {
                double dist = HardwareOrgHelper.GetDist(Array.Last(), Array[0]);
                double dx   = Array.Last().X - Array[0].X;
                rate = Math.Abs(dx / dist);
            }
            else
            {
                double dist = HardwareOrgHelper.GetDist(Array.Last(), Array[0]);
                double dy   = Array.Last().Y - Array[0].Y;
                rate = Math.Abs(dy / dist);
            }
            short rMin = (short)this.numericUpDown1.Value;
            short rMax = (short)this.numericUpDown2.Value;

            Form_Main.Instance.XYGoPosTillStop(5000, Array[0], Form_Main.VariableSys.VelMode_Current_Manual);

            for (int i = 0; i < Array.Length; ++i)
            {
                Form_Main.Instance.XYGoPosTillStop(5000, Array[i], Form_Main.VariableSys.VelMode_Current_Manual);
                PointF xy = GoAndCheck(rMin, rMax);

                double val = this.IsX ? xy.X : xy.Y;

                // 再计算
                if (i == 0)
                {
                    x[0] = val;
                }
                else
                {
                    x[i]  = x[0] + (val - x[0]) * rate;
                    rx[i] = x[i] - (x[0] + space * i * rate);
                    this.dAxis.Rows[i].Cells[1].Value = (rx[i]).ToString("f3");
                }
            }
        }
 private void bConfig_Click(object sender, EventArgs e)
 {
     Array = HardwareOrgHelper.Expand2AllPoints(this.start, this.start, this.end, this.start, (short)this.numPoint.Value, 1);
     this.dAxis.Rows.Clear();
     this.dAxis.Rows.Add(Array.Length);
     for (int i = 0; i < Array.Length; ++i)
     {
         this.dAxis.Rows[i].Cells[0].Value = $"{Array[i].X:n2},{Array[i].Y:n2}";
         this.dAxis.Rows[i].Cells[1].Value = 0;
     }
 }
Exemple #3
0
        private void bUpdateByCliabed_Click(object sender, EventArgs e)
        {
            var org         = Form_Main.Instance.XYPos;
            var leftTop     = Form_Main.Instance.XYPos;
            var rightBottom = Form_Main.Instance.XYPos;

            double angle = Math.Abs(HardwareOrgHelper.GetAngle(org, rightBottom, org, leftTop));

            tXYAngle.Text = angle.ToString();
            double distX = HardwareOrgHelper.GetDist(rightBottom, org);
            double distY = HardwareOrgHelper.GetDist(leftTop, org);
        }
Exemple #4
0
        private void bUpdate_Click(object sender, EventArgs e)
        {
            HardwareOrgHelper.Instance.HardWare.LeftBottom   = Org;
            HardwareOrgHelper.Instance.HardWare.RightBottom  = RightBottom;
            HardwareOrgHelper.Instance.HardWare.LeftTop      = LeftTop;
            HardwareOrgHelper.Instance.HardWare.RightTop     = RightTop;
            HardwareOrgHelper.Instance.HardWare.XYCroodAngle = (double)this.tXYAngle.Value;
            double deg = (HardwareOrgHelper.Instance.HardWare.XYCroodAngle - 90) / 180.0 * Math.PI;

            HardwareOrgHelper.Instance.HardWare.XRate = Math.Cos(deg);
            HardwareOrgHelper.Instance.HardWare.YRate = Math.Sin(deg);

            HardwareOrgHelper.Save();
        }
        private void bEnable_Click(object sender, EventArgs e)
        {
            if (this.IsX)
            {
                HardwareOrgHelper.Instance.HardWare.X     = x;
                HardwareOrgHelper.Instance.HardWare.RX    = rx;
                HardwareOrgHelper.Instance.HardWare.XPoly = poly;
            }
            else
            {
                HardwareOrgHelper.Instance.HardWare.Y     = x;
                HardwareOrgHelper.Instance.HardWare.RY    = rx;
                HardwareOrgHelper.Instance.HardWare.YPoly = poly;
            }

            HardwareOrgHelper.Save();
            this.bEnable.Enabled = false;
        }