| | |
| | | #include "stdafx.h" |
| | | #include "stdafx.h" |
| | | #include "EdgeImageViewer.h" |
| | | |
| | | // CEdgeImageViewer |
| | |
| | | { |
| | | CMenu menu; |
| | | CMenu popMenu; |
| | | menu.CreateMenu(); // 弥惑困 焕措 皋春 |
| | | popMenu.CreatePopupMenu(); // 扑诀皋春 |
| | | menu.CreateMenu(); // 弥惑困 焕措 皋春 |
| | | popMenu.CreatePopupMenu(); // 扑诀皋春 |
| | | |
| | | popMenu.AppendMenu(MF_SEPARATOR); |
| | | popMenu.AppendMenu(MF_STRING, ID_MODE_USER_SELECT, _T("User Select (Mark/Manual Measure)")); |
| | |
| | | if(bAllCheck) |
| | | popMenu.CheckMenuItem(ID_MODE_VIEW_DEFECT_ALL,MF_CHECKED); |
| | | |
| | | // 牧咆胶飘 皋春 龋免 |
| | | // 牧咆胶飘 皋春 龋免 |
| | | CRect rect; |
| | | GetWindowRect(rect); |
| | | int nX = rect.left + point.x; |
| | |
| | | void CEdgeImageViewer::OnPaint() |
| | | { |
| | | CPaintDC dc(this); // device context for painting |
| | | // TODO: 咯扁俊 皋矫瘤 贸府扁 内靛甫 眠啊钦聪促. |
| | | // 弊府扁 皋矫瘤俊 措秦辑绰 CStatic::OnPaint()阑(甫) 龋免窍瘤 付绞矫坷. |
| | | // TODO: 咯扁俊 皋矫瘤 贸府扁 内靛甫 眠啊钦聪促. |
| | | // 弊府扁 皋矫瘤俊 措秦辑绰 CStatic::OnPaint()阑(甫) 龋免窍瘤 付绞矫坷. |
| | | UpdateView(); |
| | | } |
| | | |
| | |
| | | // 1. Draw Buffer Image |
| | | UpdateView_Image(&memDC); |
| | | |
| | | //2. 显示视觉效果 |
| | | //2. 显示视觉效果 |
| | | UpdateView_VisionResult(&memDC); |
| | | |
| | | |
| | |
| | | for (int i = 0; i < nCount; i++) { |
| | | DispVisionResult inf = pSideData->m_vDispVisionResult[i]; |
| | | int nType = inf.nType; |
| | | if (0 == nType) { //点 |
| | | if (0 == nType) { //点 |
| | | CRect rtMarkPos_pxl = CRect(inf.pointX-31, inf.pointY-31, inf.pointX + 31, inf.pointY + 31); |
| | | CRect rtMarkPos_wnd = GetWndPos(rtMarkPos_pxl); |
| | | CPoint ptMarkPos_wnd = rtMarkPos_wnd.CenterPoint(); |
| | |
| | | memDC->LineTo(ptMarkPos_wnd.x - 8, ptMarkPos_wnd.y + 8); |
| | | } |
| | | } |
| | | else if (1 == nType) { //矩形 |
| | | else if (1 == nType) { //矩形 |
| | | CRect rtMarkPos_pxl = CRect(inf.rectX1, inf.rectY1, inf.rectX2, inf.rectY2); |
| | | CRect rtMarkSearchPos_wnd = GetWndPos(rtMarkPos_pxl); |
| | | if (4 == inf.eVision) { |
| | |
| | | memDC->Rectangle(rtMarkSearchPos_wnd); |
| | | } |
| | | } |
| | | else if (2 == nType) { //Բ |
| | | else if (2 == nType) { //圆 |
| | | CRect rtMarkPos_pxl = CRect(inf.circleX - inf.circleRadius, inf.circleY - inf.circleRadius, inf.circleX + inf.circleRadius, inf.circleY + inf.circleRadius); |
| | | CRect rtMarkSearchPos_wnd = GetWndPos(rtMarkPos_pxl); |
| | | memDC->SelectObject(&pen); |
| | |
| | | memDC->Ellipse(rtMarkSearchPos_wnd); |
| | | } |
| | | } |
| | | else if (3 == nType) { //直线 |
| | | else if (3 == nType) { //直线 |
| | | CRect rtMarkPos_pxl = CRect(inf.rectX1 - 31, inf.rectY1 - 31, inf.rectX1 + 31, inf.rectY1 + 31); |
| | | CRect rtMarkPos_wnd = GetWndPos(rtMarkPos_pxl); |
| | | CPoint pt0 = rtMarkPos_wnd.CenterPoint(); |
| | |
| | | UpdateView_MousePoint(&memDC); |
| | | |
| | | #if HALCON_VISION_KEY |
| | | //17. 显示vision Rsult |
| | | //17. 显示vision Rsult |
| | | UpdateView_VisionResult(&memDC); |
| | | #endif // HALCON_VISION_KEY |
| | | |
| | |
| | | if(m_ptMousePos_Pxl.y < 0 || m_nTotalHeight <= m_ptMousePos_Pxl.y) |
| | | return; |
| | | |
| | | int nYPos = m_ptMousePos_Pxl.y - m_ptDisplayStart_pxl.y; // Recipe View俊辑 Scroll 且 锭 滚欺 困摹甫 官厕;;; |
| | | int nYPos = m_ptMousePos_Pxl.y - m_ptDisplayStart_pxl.y; // Recipe View俊辑 Scroll 且 锭 滚欺 困摹甫 官厕;;; |
| | | |
| | | int nPos = (nYPos * m_nFrameWidth) + m_ptMousePos_Pxl.x; |
| | | |
| | |
| | | memDC->TextOut(10, m_rtWnd.Height() - 45, strTemp); |
| | | |
| | | #if HALCON_VISION_KEY |
| | | if ((0 != m_ptMouseDown.x || 0 != m_ptMouseDown.y) && BlVision_GetVisionRecipe()->getVisionSetOpen()) { //鼠标改变 |
| | | if ((0 != m_ptMouseDown.x || 0 != m_ptMouseDown.y) && BlVision_GetVisionRecipe()->getVisionSetOpen()) { //鼠标改变 |
| | | strTemp.Format(_T("(%d / %d)"), m_ptMouseDown.x, m_ptMouseDown.y); |
| | | memDC->TextOut(10, m_rtWnd.Height() - 25, strTemp); |
| | | |
| | |
| | | |
| | | void CEdgeImageViewer::UpdateView_InspectArea(CDC* memDC) |
| | | { |
| | | if(m_pBuffer == NULL || memDC == NULL || m_pGlassData == NULL) |
| | | if (m_pBuffer == NULL || memDC == NULL || m_pGlassData == NULL) { |
| | | return; |
| | | } |
| | | |
| | | if(m_MenuStatus[MODE_VIEW_INSPECT_AREA] == FALSE) |
| | | if (m_MenuStatus[MODE_VIEW_INSPECT_AREA] == FALSE) { |
| | | return; |
| | | } |
| | | |
| | | CPen pen_SideLine(PS_DASH, 1, RGB(255,127,39)); |
| | | CPen pen_ChamferLine(PS_DASH, 1, RGB(255,255,0)); |
| | |
| | | |
| | | CRect rcTmp,rtRealPos; |
| | | int nFilterLine; |
| | | int nChamferLine; |
| | | |
| | | for(int nFrameIdx = 0; nFrameIdx < MAX_IMAGE_FRAME; nFrameIdx++) |
| | | { |
| | | for(int nFrameIdx = 0; nFrameIdx < MAX_IMAGE_FRAME; nFrameIdx++) { |
| | | CRect rtArea_Inspect = m_pGlassData->GetSideData((DimensionDir) m_nSideIdx)->m_rtInspectArea[nFrameIdx]; |
| | | int nSideLine = m_pGlassData->GetSideData((DimensionDir) m_nSideIdx)->m_nSideLineFrame[nFrameIdx]; |
| | | int nSideChamferLine = m_pGlassData->GetSideData((DimensionDir) m_nSideIdx)->m_nSide_Chamfer_LineFrame[nFrameIdx]; |
| | | int nSideLine = (int)m_pGlassData->GetSideData((DimensionDir) m_nSideIdx)->m_nSideLineFrame[nFrameIdx]; |
| | | int nSideChamferLine = (int)m_pGlassData->GetSideData((DimensionDir) m_nSideIdx)->m_nSide_Chamfer_LineFrame[nFrameIdx]; |
| | | |
| | | // Side Line |
| | | rtRealPos = rtArea_Inspect; |
| | | nFilterLine = nSideLine; |
| | | |
| | | if(0 < nFilterLine) |
| | | { |
| | | if(0 < nFilterLine) { |
| | | memDC->SelectObject(&pen_SideLine); |
| | | memDC->MoveTo(int((nFilterLine - m_ptDisplayStart_pxl.x ) * m_dZoom) , int((rtRealPos.top - m_ptDisplayStart_pxl.y) * m_dZoom)); |
| | | memDC->LineTo(int((nFilterLine - m_ptDisplayStart_pxl.x ) * m_dZoom) , int((rtRealPos.bottom - m_ptDisplayStart_pxl.y) * m_dZoom)); |
| | | } |
| | | |
| | | if(0 < nSideChamferLine) |
| | | { |
| | | if(0 < nSideChamferLine) { |
| | | memDC->SelectObject(&pen_ChamferLine); |
| | | memDC->MoveTo(int((nSideChamferLine - m_ptDisplayStart_pxl.x ) * m_dZoom) , int((rtRealPos.top - m_ptDisplayStart_pxl.y) * m_dZoom)); |
| | | memDC->LineTo(int((nSideChamferLine - m_ptDisplayStart_pxl.x ) * m_dZoom) , int((rtRealPos.bottom - m_ptDisplayStart_pxl.y) * m_dZoom)); |
| | | } |
| | | |
| | | for(int nInsType = 0; nInsType < MAX_SIDE_INSPECT_TYPE; nInsType++) |
| | | { |
| | | for(int nInsType = 0; nInsType < MAX_SIDE_INSPECT_TYPE; nInsType++) { |
| | | CRect rtArea = m_pGlassData->GetSideData((DimensionDir) m_nSideIdx)->m_rtInspectArea_InsType[nInsType][nFrameIdx]; |
| | | int nFilterLine = m_pGlassData->GetSideData((DimensionDir) m_nSideIdx)->m_nSideFilterLine_InsType[nInsType][nFrameIdx]; |
| | | |
| | | rtRealPos = rtArea; |
| | | nFilterLine = nFilterLine; |
| | | |
| | | if(rtRealPos.IsRectEmpty() != TRUE && rtRealPos.IsRectNull() != TRUE) |
| | | { |
| | | if(rtRealPos.IsRectEmpty() != TRUE && rtRealPos.IsRectNull() != TRUE) { |
| | | rcTmp.left = int((rtRealPos.left - m_ptDisplayStart_pxl.x ) * m_dZoom); |
| | | rcTmp.right = int((rtRealPos.right - m_ptDisplayStart_pxl.x ) * m_dZoom); |
| | | rcTmp.top = int((rtRealPos.top - m_ptDisplayStart_pxl.y) * m_dZoom); |
| | | rcTmp.bottom = int((rtRealPos.bottom - m_ptDisplayStart_pxl.y) * m_dZoom); |
| | | |
| | | if(rcTmp.top < 0 && rcTmp.bottom > 0 || rcTmp.top > 0 && rcTmp.top < m_rtWnd.bottom +1 || rcTmp.bottom > 0 && rcTmp.bottom < m_rtWnd.bottom +1) |
| | | { |
| | | if(rcTmp.top < 0 && rcTmp.bottom > 0 || rcTmp.top > 0 && rcTmp.top < m_rtWnd.bottom +1 || rcTmp.bottom > 0 && rcTmp.bottom < m_rtWnd.bottom +1) { |
| | | memDC->SelectObject(&pen_Green); |
| | | memDC->MoveTo(int((rtRealPos.left - m_ptDisplayStart_pxl.x ) * m_dZoom) , int((rtRealPos.top - m_ptDisplayStart_pxl.y) * m_dZoom)); |
| | | memDC->LineTo(int((rtRealPos.right - m_ptDisplayStart_pxl.x ) * m_dZoom) , int((rtRealPos.top - m_ptDisplayStart_pxl.y) * m_dZoom)); |
| | |
| | | memDC->LineTo(int((rtRealPos.left - m_ptDisplayStart_pxl.x ) * m_dZoom) , int((rtRealPos.top - m_ptDisplayStart_pxl.y) * m_dZoom)); |
| | | } |
| | | |
| | | if(0 < nFilterLine) |
| | | { |
| | | if(0 < nFilterLine) { |
| | | memDC->SelectObject(&pen_FilterLine); |
| | | memDC->MoveTo(int((nFilterLine - m_ptDisplayStart_pxl.x ) * m_dZoom) , int((rtRealPos.top - m_ptDisplayStart_pxl.y) * m_dZoom)); |
| | | memDC->LineTo(int((nFilterLine - m_ptDisplayStart_pxl.x ) * m_dZoom) , int((rtRealPos.bottom - m_ptDisplayStart_pxl.y) * m_dZoom)); |
| | |
| | | rtCircle.bottom = rtCircle.top + (nDistanceY_wnd * 2); |
| | | memDC->Arc(rtCircle, CPoint(rtCircle.left, rtCircle.CenterPoint().y), CPoint(rtCircle.left, rtCircle.CenterPoint().y)); |
| | | |
| | | /* 康开 救狼 1/4 盔父 焊捞绊 酵阑锭.. |
| | | /* 康开 救狼 1/4 盔父 焊捞绊 酵阑锭.. |
| | | if((ptEnd_Wnd.x < ptStart_Wnd.x && ptEnd_Wnd.y < ptStart_Wnd.y) || (ptEnd_Wnd.x > ptStart_Wnd.x && ptEnd_Wnd.y > ptStart_Wnd.y)) |
| | | memDC->Arc(rtCircle, CPoint(rtCircle.CenterPoint().x, ptEnd_Wnd.y), CPoint(ptEnd_Wnd.x, rtCircle.CenterPoint().y)); |
| | | else |
| | |
| | | for(int nX = m_ptMousePos_Pxl.x -8; nX < m_ptMousePos_Pxl.x + 8 ; nX++) |
| | | { |
| | | int nX_pxl = nX; |
| | | int nY_pxl = nY - m_ptDisplayStart_pxl.y; // Recipe View俊辑 Scroll 且 锭 滚欺 困摹甫 官厕;;; |
| | | int nY_pxl = nY - m_ptDisplayStart_pxl.y; // Recipe View俊辑 Scroll 且 锭 滚欺 困摹甫 官厕;;; |
| | | |
| | | if(nX_pxl < 0 || m_nFrameWidth <= nX_pxl) |
| | | continue; |
| | |
| | | for(int nX = m_ptMousePos_Pxl.x -8; nX < m_ptMousePos_Pxl.x + 8 ; nX++) |
| | | { |
| | | int nX_pxl = nX; |
| | | int nY_pxl = nY - m_ptDisplayStart_pxl.y; // Recipe View俊辑 Scroll 且 锭 滚欺 困摹甫 官厕;;; |
| | | int nY_pxl = nY - m_ptDisplayStart_pxl.y; // Recipe View俊辑 Scroll 且 锭 滚欺 困摹甫 官厕;;; |
| | | |
| | | if(nX_pxl < 0 || m_nFrameWidth <= nX_pxl) |
| | | continue; |
| | |
| | | #if HALCON_VISION_KEY |
| | | void CEdgeImageViewer::OnLButtonUp(UINT nFlags, CPoint point) |
| | | { |
| | | // TODO: 在此添加消息处理程序代码和/或调用默认值 |
| | | // TODO: 在此添加消息处理程序代码和/或调用默认值 |
| | | m_isMouseDown = FALSE; |
| | | |
| | | CWnd::OnLButtonUp(nFlags, point); |