Пример #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            Random a = new Random();

            for (int i = 0; i < 3; i++)
            {
                p[i].X = a.Next(pictureBox1.Width);
                p[i].Y = a.Next(pictureBox1.Height);
            }
            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.Clear(pictureBox1.BackColor);
                g.SmoothingMode   = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                drawPen.Color     = Color.Blue;
                drawPen.DashStyle = DashStyle.Solid;
                g.DrawPolygon(drawPen, p);
                drawPen.DashStyle  = DashStyle.Dash;
                drawPen1.DashStyle = DashStyle.Dash;
                drawPen.Color      = Color.Green;

                g.DrawLine(drawPen, new Point(0, (int)p[1].Y), new Point(pictureBox1.Width, (int)p[1].Y));
                g.DrawLine(drawPen, new Point((int)p[1].X, 0), new Point((int)p[1].X, pictureBox1.Height));

                g.DrawString("A", this.Font, drawBrush, p[0]);
                g.DrawString("B", this.Font, drawBrush, p[1]);
                g.DrawString("C", this.Font, drawBrush, p[2]);
                angle = Math.Atan((p[0].Y - p[2].Y) / (p[0].X - p[2].X));
                p[0]  = RotateMath.PointRotate(p[1], p[0], angle);
                p[2]  = RotateMath.PointRotate(p[1], p[2], angle);
                PointF p1 = new PointF((p[0].X + p[2].X) / 2, (p[0].Y + p[2].Y) / 2);
                g.DrawString("M'", this.Font, drawBrush, p1);
                g.DrawString("A'", this.Font, drawBrush, p[0]);
                g.DrawString("C'", this.Font, drawBrush, p[2]);
                angle *= -180;
                angle /= Math.PI;
                g.DrawString("当前应旋转角度为:" + angle.ToString(), this.Font, drawBrush, new PointF(10, 10));
                g.DrawString("X轴移动距离为:" + (p1.X - p[1].X).ToString(), this.Font, drawBrush, new PointF(10, 30));
                g.DrawString("Y轴移动距离为:" + (p1.Y - p[1].Y).ToString(), this.Font, drawBrush, new PointF(10, 50));
                drawPen.Color     = Color.Cyan;
                drawPen.DashStyle = DashStyle.Dash;

                g.DrawPolygon(drawPen, p);
                g.DrawLine(drawPen, p[1], p1);
            }
            pictureBox1.Image = bmp;
        }
Пример #2
0
 public static PointF AlignT(PointF p1, PointF p2, PointF center, out float angle)
 {
     angle = (float)RotateMath.GetPointsAngle(p1, p2);
     try
     {
         if (!Globals.IsInit)
         {
             Common.ReportCmdKeyProgress(CmdKey.A0005);
             return(p1);
         }
         //PointF p = Com.RotateMath.PointRotate(center, new PointF((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2), a);
         PointF p = RotateMath.PointRotate(center, p1, angle);
         T_Axis.AxisJogIncWork(angle);
         X_Axis.JogAbs(Globals.MacData.TAdjSpeed, Globals.MacData.TAdjAcc, p.X);
         Y_Axis.AxisJogAbsWork(p.Y);
         return(p);
     }
     catch
     {
         Common.ReportCmdKeyProgress(CmdKey.S0091);
         return(p1);
     }
 }
Пример #3
0
        private void InitCutChannelData(CutChannel c, bool create, bool res = true)
        {
            if (c.Enable)
            {
                if (c.Fixed)
                {
                    if (res)//长度宽度反转
                    {
                        c.Length = length;
                        c.Width  = width;
                    }
                    else
                    {
                        c.Length = width;
                        c.Width  = length;
                    }
                }
                else
                {
                    c.Length = length;
                    c.Width  = length;
                }
                c.PreWidth  = PreWidth;//设置预划切宽度
                c.BackSpeed = backSpeed;
                switch (CutMode)
                {
                case CutMode.StandOnce:
                case CutMode.Stand:
                {
                    c.StandMode = true;
                    c.ReDepth   = ReDepth;          //划切预留一
                    c.ReDepth2  = ReDepth2;         //配置预留二
                }
                break;

                case CutMode.AnyChannel:    //任意通道
                {
                    c.StandMode = true;
                }
                break;

                case CutMode.AnyStep:
                {
                    c.StandMode = false;
                }
                break;

                default:
                {
                    c.StandMode = false;
                }
                break;
                }

                float angle = c.TRoatePos + c.TPosAdj;
                if (Center != Globals.TabCenter)
                {
                    c.Center = RotateMath.PointRotate(Globals.TabCenter, Center, -angle);
                }
                else
                {
                    c.Center = Center;
                }
                c.Fixed     = this.Fixed;                                                         //圆片还是方片
                c.BackSpeed = backSpeed;
                c.SelfPos   = Globals.TestHeightValue + filmHeight + workerHeight + SelfTickness; //当前测高值+工件厚度+膜厚 + 安全预留
                switch (cutDir)
                {
                case CutDir.Positive:
                {
                    c.SinDir = true;
                    c.Dir    = true;
                }
                break;

                case CutDir.Negative:
                {
                    c.SinDir = true;
                    c.Dir    = false;
                }
                break;

                case CutDir.TwoWay:
                {
                    c.SinDir = false;
                    c.Dir    = true;
                }
                break;

                default:
                    break;
                }
                c.InitCutRunData(create);
            }
        }