/// <summary>
        /// 仿射变化后的图像上的圆弧上各点 转换成机械点
        /// </summary>
        /// <param name="ItemName">轨迹中圆弧元素名称</param>
        /// <param name="SnapPoint">拍照位置的机械点</param>
        /// <param name="StatrtVPonit">仿射变化后的图像上的圆弧的起始点</param>
        /// <param name="CenterVPonit">仿射变化后的图像上的圆弧的圆心点</param>
        /// <param name="StatrtEPonit">仿射变化后的图像上的圆弧的终止点</param>
        /// <param name="OffsetX">最后的统一补偿X</param>
        /// <param name="OffsetY">最后的统一补偿Y</param>
        /// <param name="OffsetZ">最后的统一补偿Z</param>
        /// <param name="DispTraceName">轨迹名称</param>
        /// <summary>

        public void TransArc(string ItemName, XYUPoint SnapPoint, XYUPoint StatrtVPonit, XYUPoint CenterVPonit, XYUPoint StatrtEPonit, double OffsetX, double OffsetY, double OffsetZ, string DispTraceName = "FiristTrace")
        {
            if (dispTraces.ContainsKey(DispTraceName))
            {
                int index = dispTraces[DispTraceName].FindIndex((t) => t.ItemName == ItemName);
                if (index == -1)
                {
                    return;
                }
                DispTraceBaseElement tem = null;
                tem = dispTraces[DispTraceName][index];

                if (tem.GetType() == typeof(DispTraceBaseElementDelay) || tem.GetType() == typeof(DispTraceBaseElementIo) || tem.GetType() == typeof(DispTraceBaseElementEnd))
                {
                    return;
                }
                ((DispTraceBaseElementArc)tem).cStartPoint.dMz  = ((DispTraceBaseElementArc)tem).cStartPoint.dMz + OffsetZ;
                ((DispTraceBaseElementArc)tem).cCenterPoint.dMz = ((DispTraceBaseElementArc)tem).cCenterPoint.dMz + OffsetZ;
                ((DispTraceBaseElementArc)tem).cEndPoint.dMz    = ((DispTraceBaseElementArc)tem).cEndPoint.dMz + OffsetZ;
                if (!tem.bIsAllPointMachine)
                {
                    if (tem.GetType() == typeof(DispTraceBaseElementArc))
                    {
                        ((DispTraceBaseElementArc)tem).cStartPoint.dMx  = XYUR_Pin.GetDstPonit(StatrtVPonit, SnapPoint).x + OffsetX;
                        ((DispTraceBaseElementArc)tem).cStartPoint.dMy  = XYUR_Pin.GetDstPonit(StatrtVPonit, SnapPoint).y + OffsetY;
                        ((DispTraceBaseElementArc)tem).cCenterPoint.dMx = XYUR_Pin.GetDstPonit(CenterVPonit, SnapPoint).x + OffsetX;
                        ((DispTraceBaseElementArc)tem).cCenterPoint.dMy = XYUR_Pin.GetDstPonit(CenterVPonit, SnapPoint).y + OffsetY;
                        ((DispTraceBaseElementArc)tem).cEndPoint.dMx    = XYUR_Pin.GetDstPonit(StatrtEPonit, SnapPoint).x + OffsetX;
                        ((DispTraceBaseElementArc)tem).cEndPoint.dMy    = XYUR_Pin.GetDstPonit(StatrtEPonit, SnapPoint).y + OffsetY;
                    }
                }
            }
        }
        /// <summary>
        /// 仿射变化后的图像上的点 转换成机械点
        /// </summary>
        /// <param name="ItemName">轨迹中点元素名称</param>
        /// <param name="SnapPoint">拍照位置的机械点</param>
        /// <param name="visionPoint">仿射变化后的图像上的点</param>
        /// <param name="OffsetX">最后的统一补偿X</param>
        /// <param name="OffsetY">最后的统一补偿Y</param>
        /// <param name="OffsetZ">最后的统一补偿Z</param>
        /// <param name="DispTraceName">轨迹名称</param>
        public void TransPoint(string ItemName, XYUPoint SnapPoint, XYUPoint visionPoint, double OffsetX, double OffsetY, double OffsetZ, string DispTraceName = "FiristTrace")
        {
            if (dispTraces.ContainsKey(DispTraceName))
            {
                int index = dispTraces[DispTraceName].FindIndex((t) => t.ItemName == ItemName);
                if (index == -1)
                {
                    return;
                }
                DispTraceBaseElement tem = null;
                tem = dispTraces[DispTraceName][index];

                if (tem.GetType() == typeof(DispTraceBaseElementDelay) || tem.GetType() == typeof(DispTraceBaseElementIo) || tem.GetType() == typeof(DispTraceBaseElementEnd))
                {
                    return;
                }
                if (!tem.bIsAllPointMachine)
                {
                    if (tem.GetType() == typeof(DispTraceBaseElementPoint))
                    {
                        ((DispTraceBaseElementPoint)tem).PointCoordinate.dMx = XYUR_Pin.GetDstPonit(visionPoint, SnapPoint).x + OffsetX;
                        ((DispTraceBaseElementPoint)tem).PointCoordinate.dMy = XYUR_Pin.GetDstPonit(visionPoint, SnapPoint).y + OffsetY;
                    }
                }
            }
        }
 public void SetItem(int nIndex, DispTraceBaseElement dispTraceBaseElement, string DispTraceName = "FiristTrace")
 {
     if (dispTraces.ContainsKey(DispTraceName))
     {
         if (dispTraces[DispTraceName].Count > nIndex)
         {
             dispTraces[DispTraceName][nIndex] = dispTraceBaseElement;
         }
     }
 }
Beispiel #4
0
 public void FlushToDlg(DispTraceBaseElement dispTraceBaseElement, VisionControl visionControl, bool bIsModfiy)
 {
     if (visionControl != null)
     {
         vc = visionControl;
     }
     PonitElement = dispTraceBaseElement as DispTraceBaseElementPoint;
     comPartSet1.UpdataParam(PonitElement, PonitElement.TraceMoveParam);
     pointValSet.UpDataParam(PonitElement.bIsAllPointMachine, PonitElement.PointCoordinate, visionControl, bIsModfiy);
     bModify = bIsModfiy;
 }
        public DispTraceBaseElement GetItem(int index, string DispTraceName = "FiristTrace")
        {
            DispTraceBaseElement dispTraceBaseElement = null;

            if (dispTraces.ContainsKey(DispTraceName))
            {
                if (dispTraces[DispTraceName].Count > index)
                {
                    return(dispTraces[DispTraceName][index]);
                }
            }
            return(dispTraceBaseElement);
        }
        public DispTraceBaseElement GetItem(string ItemName, string DispTraceName = "FiristTrace")
        {
            DispTraceBaseElement dispTraceBaseElement = null;

            if (dispTraces.ContainsKey(DispTraceName))
            {
                int index = dispTraces[DispTraceName].FindIndex((t) => t.ItemName == ItemName);
                if (index == -1)
                {
                    return(null);
                }
                return(dispTraces[DispTraceName][index]);
            }
            return(dispTraceBaseElement);
        }
        //VisionControl vc;

        public void FlushToDlg(DispTraceBaseElement DispTraceElement, VisionControl visionControl, bool bIsModfiy)
        {
            if (visionControl != null)
            {
                vc = visionControl;
            }
            elementLine = DispTraceElement as DispTraceBaseElementLine;
            if (elementLine == null)
            {
                MessageBox.Show("点胶路径元素的类型不对", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            comPartSet1.UpdataParam(elementLine, elementLine.TraceMoveParam);
            pointValSetStartPoint.UpDataParam(elementLine.bIsAllPointMachine, elementLine.cStartPoint, visionControl, bIsModfiy);
            pointValSetEndPoint.UpDataParam(elementLine.bIsAllPointMachine, elementLine.cEndPoint, visionControl, bIsModfiy);
            bModify = bIsModfiy;
        }
 public void AddItemToList(DispTraceBaseElement dispTraceBaseElement, string DispTraceName = "FiristTrace")
 {
     //  dispTraceBaseElements.Add(dispTraceBaseElement);
     if (dispTraces.ContainsKey(DispTraceName))
     {
         dispTraces[DispTraceName].Add(dispTraceBaseElement);
         if (eventUpdataGridView != null)
         {
             eventUpdataGridView("Add", dispTraceBaseElement);
         }
     }
     else
     {
         dispTraces.Add(DispTraceName, new List <DispTraceBaseElement>()
         {
             dispTraceBaseElement
         });
     }
 }
Beispiel #9
0
        public void UpdateData(DispTraceBaseElement dispTraceBaseElement, bool bShow = false)
        {
            if (dispTraceBaseElement == null)
            {
                return;
            }
            baseElement = dispTraceBaseElement;

            foreach (Control tem in panelForElementCtrl.Controls)
            {
                tem.Visible = false;
            }
            if (dispTraceBaseElement.strType.Contains("Line"))
            {
                traceElementLine.Visible = true;
                ctrSel = traceElementLine;
            }
            if (dispTraceBaseElement.strType.Contains("Point"))
            {
                traceElementPoint.Visible = true;
                ctrSel = traceElementPoint;
            }
            if (dispTraceBaseElement.strType.Contains("Arc"))
            {
                traceElemementArc.Visible = true;
                ctrSel = traceElemementArc;
            }
            ctrSel.FlushToDlg(baseElement, this.visionControl1, bShow);

            bModify       = bShow;
            this.TopLevel = true;
            this.Show();
            //if(visionControl1!=null && visionControl1.isOpen() && visionControl1.Img!=null && visionControl1.Img.IsInitialized())
            //{
            //    visionControl1.DispImageFull(visionControl1.Img);
            //}
            if (bShow)
            {
                ctrSel.ShowObj();
            }
            this.Focus();
        }
 public void FlushToDlg(DispTraceBaseElement TraceElement, VisionControl visionControl, bool bIsModfiy)
 {
     if (visionControl != null)
     {
         vc = visionControl;
     }
     cDispTraceElementArc = TraceElement as DispTraceBaseElementArc;
     if (cDispTraceElementArc == null)
     {
         MessageBox.Show("点胶路径元素的类型不对", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     comPartSet1.UpdataParam(cDispTraceElementArc, cDispTraceElementArc.TraceMoveParam);
     //点位设置  圆心 起点 终点
     pointValSetArcCenterPoint.UpDataParam(cDispTraceElementArc.bIsAllPointMachine, cDispTraceElementArc.cCenterPoint, visionControl, bIsModfiy);
     pointValSetArcStartPoint.UpDataParam(cDispTraceElementArc.bIsAllPointMachine, cDispTraceElementArc.cStartPoint, visionControl, bIsModfiy);
     pointValSetArcEndPoint.UpDataParam(cDispTraceElementArc.bIsAllPointMachine, cDispTraceElementArc.cEndPoint, visionControl, bIsModfiy);
     this.bIsArc    = cDispTraceElementArc.bIsArc;
     this.bIsArcDir = cDispTraceElementArc.bIsArcDir;
     bModify        = bIsModfiy;
 }
        private void ParsejsonToTraces(string jsonString, Dictionary <string, List <DispTraceBaseElement> > DispTraces)
        {
            Dictionary <string, List <object> > ds = JsonConvert.DeserializeObject <Dictionary <string, List <object> > >(jsonString);

            //Dictionary<string, List<DispTraceBaseElement>> DispTraces = new Dictionary<string, List<DispTraceBaseElement>>();
            dispTraces.Clear();
            foreach (var tem in ds)
            {
                List <DispTraceBaseElement> TraceElements = new List <DispTraceBaseElement>();
                foreach (var tem1 in tem.Value)
                {
                    string   strItemElement = tem1.ToString().Trim('\r', '\n');
                    string   TypeElement    = (JsonConvert.DeserializeObject <DispTraceBaseElement>(strItemElement) as DispTraceBaseElement).strType;
                    Assembly assembly       = Assembly.GetAssembly(typeof(DispTraceBaseElement));
                    Type     type           = assembly.GetType(TypeElement);

                    DispTraceBaseElement dispTraceBaseElement = JsonConvert.DeserializeObject(strItemElement, type) as DispTraceBaseElement;
                    // TraceElements.Add(Activator.CreateInstance(type, null) as DispTraceBaseElement);
                    TraceElements.Add(dispTraceBaseElement);
                }
                DispTraces.Add(tem.Key, TraceElements);
            }
        }
Beispiel #12
0
 public void UpdataParam(DispTraceBaseElement element, DispEveryTraceMoveParam dispmoveparam)
 {
     TraceElement = element;
     MoveParam    = dispmoveparam;
 }