コード例 #1
0
ファイル: clsPCB.cs プロジェクト: chensen/WellsTools
        public bool getPixelPCBImage(Point pt, out byte R, out byte G, out byte B)
        {
            #region 根据物理坐标获取区域像素值

            bool ret = false;
            R = G = B = 100;

            if (m_CameraViewList != null)
            {
                if (m_CameraViewList.Count > 0)
                {
                    if (m_iCurpos >= 0 && m_iCurpos < m_CameraViewList.Count)
                    {
                        clsCameraView pView = m_CameraViewList[m_iCurpos];
                        if (pView != null)
                        {
                            int xDistance = Math.Abs(pView.m_lptCenter.X - pt.X);
                            int yDistance = Math.Abs(pView.m_lptCenter.Y - pt.Y);
                            if (((2 * xDistance) <= m_xStep) && ((2 * yDistance) <= m_yStep))
                            {
                                return(pView.getPixelViewImage(pt, out R, out G, out B));
                            }
                        }
                    }
                }

                for (int igg = 0; igg < m_CameraViewList.Count; igg++)
                {
                    m_iCurpos = igg;
                    clsCameraView pView = m_CameraViewList[igg];
                    if (pView != null)
                    {
                        int xDistance = Math.Abs(pView.m_lptCenter.X - pt.X);
                        int yDistance = Math.Abs(pView.m_lptCenter.Y - pt.Y);
                        if (((2 * xDistance) <= m_xStep) && ((2 * yDistance) <= m_yStep))
                        {
                            return(pView.getPixelViewImage(pt, out R, out G, out B));
                        }
                    }
                }

                m_iCurpos = -1;
            }

            return(ret);

            #endregion
        }
コード例 #2
0
ファイル: VisionInspect.cs プロジェクト: chensen/WellsTools
        public void initialize()
        {
            #region ***** 初始化参数 *****

            if (m_AreaView == null)
            {
                m_AreaView = new clsAreaView();
            }
            m_AreaView.linkToView(this);
            m_AreaView.prepareAreaView(base.ClientRectangle, Point.Empty, true);

            if (m_CameraView == null)
            {
                m_CameraView = new clsCameraView();
            }
            m_CameraView.m_iIndex = -1;
            m_CameraView.linkToView(this);

            #endregion
        }
コード例 #3
0
ファイル: clsPCB.cs プロジェクト: chensen/WellsTools
        public void preparePCBView()
        {
            #region **** 准备PCB的视图分配 *****

            if (m_CameraViewList == null)
            {
                m_CameraViewList = new List <clsCameraView>();
            }
            else
            {
                m_CameraViewList.Clear();
            }

            if ((m_xFovNum != m_xOldFovNum) || (m_yFovNum != m_yOldFovNum))
            {
                #region ***** 完全重新分配 *****

                m_CameraViewList = new List <clsCameraView>();

                for (int y = 0; y < m_yFovNum; y++)
                {
                    Point pt = new Point();
                    pt.Y = m_yStep / 2 + y * m_yStep + m_ptOriginOffset.Y;
                    if (y % 2 == 0)
                    {
                        for (int x = 0; x < m_xFovNum; x++)
                        {
                            pt.X = m_xStep / 2 + x * m_xStep + m_ptOriginOffset.X;
                            clsCameraView pView = new clsCameraView();
                            pView.m_iIndex       = m_CameraViewList.Count;
                            pView.m_lptCenter    = pt;
                            pView.m_image.Width  = m_pFovPixelWidth;
                            pView.m_image.Height = m_pFovPixelHeight;
                            pView.m_image.Color  = m_bColor;
                            pView.linkToView(imageDoc);
                            m_CameraViewList.Add(pView);
                        }
                    }
                    else
                    {
                        for (int x = m_xFovNum - 1; x >= 0; x--)
                        {
                            pt.X = m_xStep / 2 + x * m_xStep + m_ptOriginOffset.X;
                            clsCameraView pView = new clsCameraView();
                            pView.m_iIndex       = m_CameraViewList.Count;
                            pView.m_lptCenter    = pt;
                            pView.m_image.Width  = m_pFovPixelWidth;
                            pView.m_image.Height = m_pFovPixelHeight;
                            pView.m_image.Color  = m_bColor;
                            pView.linkToView(imageDoc);
                            m_CameraViewList.Add(pView);
                        }
                    }
                }

                #endregion
            }
            else
            {
                if (m_CameraViewList.Count == m_xFovNum * m_yFovNum)
                {
                    #region ***** 更新视图分配 *****

                    for (int y = 0; y < m_yFovNum; y++)
                    {
                        Point pt = new Point();
                        pt.Y = m_yStep / 2 + y * m_yStep + m_ptOriginOffset.Y;
                        if (y % 2 == 0)
                        {
                            for (int x = 0; x < m_xFovNum; x++)
                            {
                                pt.X = m_xStep / 2 + x * m_xStep + m_ptOriginOffset.X;
                                int           index = y * m_xFovNum + x;
                                clsCameraView pView = m_CameraViewList[index];
                                pView.m_lptCenter = pt;
                            }
                        }
                        else
                        {
                            for (int x = m_xFovNum - 1; x >= 0; x--)
                            {
                                pt.X = m_xStep / 2 + x * m_xStep + m_ptOriginOffset.X;
                                int           index = y * m_xFovNum + (m_xFovNum - 1 - x);
                                clsCameraView pView = m_CameraViewList[index];
                                pView.m_lptCenter = pt;
                            }
                        }
                    }

                    #endregion
                }
            }

            #endregion
        }