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");
                }
            }
        }
示例#2
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);
        }