예제 #1
0
 public void FindMarkAndChangeXY(object sender, EventArgs args)
 {
     if (MessageBox.Show("侦测Mark点并 修改Mark点坐标 Y/N", "警告", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         try
         {
             var param = (this.programTree.SelectedNode.Tag as MarkParam);
             var rtn   = DetectUI?.Invoke(param.VisionName, param.ROI, this.Module);
             if (rtn.State == Vision.VisionResultState.OK)
             {
                 var cur = SystemEntiy.Instance[this.Module].XYPos;
                 var pt  = new PointF();
                 SystemEntiy.Instance[this.Module].WroldPt(Camera.Top, cur, rtn.Point, out pt);
                 SystemEntiy.Instance[this.Module].XYGoPos(pt);
                 param.Pos        = pt;
                 param.IsDetected = true;
                 this.proGridStep.Refresh();
             }
             else
             {
                 MessageBox.Show("侦测失败!!");
             }
         }
         catch (Exception)
         {
         }
     }
 }
예제 #2
0
        private void toolDetect_Click(object sender, EventArgs e)
        {
            if (this.programTree.SelectedNode == null)
            {
                return;
            }
            var node = this.programTree.SelectedNode.Tag as NodeParamPt;

            DetectUI?.Invoke(node.VisionName, node.ROI, this.Module);
        }
예제 #3
0
        public void FindMark(object sender, EventArgs args)
        {
            var param = (this.programTree.SelectedNode.Tag as NodeParamPt);
            var rtn   = DetectUI?.Invoke(param.VisionName, param.ROI, this.Module);

            if (rtn.State == Vision.VisionResultState.OK)
            {
                var cur = SystemEntiy.Instance[this.Module].XYPos;
                var pt  = new PointF();
                SystemEntiy.Instance[this.Module].WroldPt(Camera.Top, cur, rtn.Point, out pt);
                SystemEntiy.Instance[this.Module].XYGoPos(pt);
            }
            else
            {
                MessageBox.Show("侦测失败!!");
            }
        }
예제 #4
0
        public void AdjustXY(object sender, EventArgs args)
        {
            if (MessageBox.Show("是否进行Mark点 修正 Y/N", "警告", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                var param = this.programTree.SelectedNode.Tag as PCSParam;

                #region Mark点重新校正
                // 遍历树改变所有 点位坐标
                List <MarkParam> markList    = new List <MarkParam>();
                PasteListNode    pasteList   = null;
                BadmarkListNode  badmarkList = null;
                ReadCodeListNode codeList    = null;
                param.GetParamList(out markList, out pasteList, out badmarkList, out codeList);

                List <VisionResult> markResults = new List <VisionResult>();

                try
                {
                    for (int i = 0; i < markList.Count; ++i)
                    {
                        SystemEntiy.Instance[this.Module].XYGoPosUI(markList[i].Pos);
                        Thread.Sleep(500);
                        markResults.Add(DetectUI?.Invoke(markList[i].VisionName, markList[i].ROI, this.Module));
                    }

                    PointF[] pL = null;
                    PointF[] bL = null;
                    PointF[] cL = null;

                    if (pasteList != null && pasteList.Nodes.Count > 0)
                    {
                        pL = new PointF[pasteList.Nodes.Count];
                        for (int pi = 0; pi < pasteList.Nodes.Count; ++pi)
                        {
                            pL[pi] = (pasteList.Nodes[pi] as NodeParamPt).Pos;
                        }
                    }

                    if (badmarkList != null && badmarkList.Nodes.Count > 0)
                    {
                        bL = new PointF[badmarkList.Nodes.Count];
                        for (int pi = 0; pi < badmarkList.Nodes.Count; ++pi)
                        {
                            bL[pi] = (badmarkList.Nodes[pi] as NodeParamPt).Pos;
                        }
                    }

                    if (codeList != null && codeList.Nodes.Count > 0)
                    {
                        bL = new PointF[codeList.Nodes.Count];
                        for (int pi = 0; pi < codeList.Nodes.Count; ++pi)
                        {
                            bL[pi] = (codeList.Nodes[pi] as NodeParamPt).Pos;
                        }
                    }

                    if (markList.Count == 1 && markResults[0].State == VisionResultState.OK)
                    {
                        //MathHelper.TransformPointsForm1Mark1Angle()
                    }
                    else if (markList.Count == 2 &&
                             markResults[0].State == markResults[1].State &&
                             markResults[0].State == VisionResultState.OK)
                    {
                        PointF newMark1 = new PointF();
                        PointF newMark2 = new PointF();

                        SystemEntiy.Instance[this.Module].WroldPt(Camera.Top, markList[0].Pos, markResults[0].Point, out newMark1);
                        SystemEntiy.Instance[this.Module].WroldPt(Camera.Top, markList[1].Pos, markResults[1].Point, out newMark2);
                        double upAngle = 0;

                        if (pL != null)
                        {
                            pL = MathHelper.TransformPointsForm2Mark(pL, markList[0].Pos, markList[1].Pos, newMark1, newMark2, ref upAngle);
                            for (int pi = 0; pi < pL.Length; ++pi)
                            {
                                (pasteList.Nodes[pi] as NodeParamPt).Pos = pL[pi];
                            }
                        }

                        if (bL != null)
                        {
                            bL = MathHelper.TransformPointsForm2Mark(bL, markList[0].Pos, markList[1].Pos, newMark1, newMark2, ref upAngle);
                            for (int bi = 0; bi < bL.Length; ++bi)
                            {
                                (badmarkList.Nodes[bi] as NodeParamPt).Pos = bL[bi];
                            }
                        }


                        if (cL != null)
                        {
                            cL = MathHelper.TransformPointsForm2Mark(cL, markList[0].Pos, markList[1].Pos, newMark1, newMark2, ref upAngle);
                            for (int ci = 0; ci < bL.Length; ++ci)
                            {
                                (codeList.Nodes[ci] as NodeParamPt).Pos = cL[ci];
                            }
                        }

                        param.BaseAngle += upAngle;
                    }
                }
                catch { }
                #endregion
            }
        }