| | |
| | | #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(); |
| | |
| | | memDC.SetStretchBltMode(COLORONCOLOR); |
| | | pOldBitmap = (CBitmap*)memDC.SelectObject(&Bitmap); |
| | | |
| | | DimensionDir eDim = (DimensionDir)m_nSideIdx; |
| | | bool bIsRipSide = (DIMENSION_A_RIP == m_nSideIdx) || (DIMENSION_B_RIP == eDim) || (DIMENSION_C_RIP == eDim) || (DIMENSION_D_RIP == eDim); |
| | | |
| | | // 1. Draw Buffer Image |
| | | UpdateView_Image(&memDC); |
| | |
| | | |
| | | // 7. Draw Exception : MODE_VIEW_EXCEPTION_AREA |
| | | UpdateView_ExceptionArea(&memDC); |
| | | |
| | | |
| | | // 8. Draw Inspect : MODE_VIEW_INSPECT_AREA |
| | | UpdateView_InspectArea(&memDC); |
| | | |
| | |
| | | UpdateView_MousePoint(&memDC); |
| | | |
| | | #if HALCON_VISION_KEY |
| | | //17. 显示vision Rsult |
| | | //17. 显示vision Rsult |
| | | UpdateView_VisionResult(&memDC); |
| | | #endif // HALCON_VISION_KEY |
| | | |
| | | // 18. Side Rip Thickness : MODE_VIEW_MEASURE |
| | | UpdateView_SideRipThickness(&memDC); |
| | | |
| | | pDC->BitBlt(0,0,m_rtWnd.Width(),m_rtWnd.Height(),&memDC,0,0,SRCCOPY); |
| | | memDC.SelectObject(pOldBitmap); |
| | |
| | | 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 |
| | |
| | | memDC->SelectObject(pOldPen); |
| | | } |
| | | |
| | | void CEdgeImageViewer::UpdateView_SideRipThickness(CDC* memDC) |
| | | { |
| | | if (m_pBuffer == NULL || memDC == NULL || m_pGlassData == NULL || m_pRecipe == NULL) { |
| | | return; |
| | | } |
| | | |
| | | DimensionDir eDim = (DimensionDir)m_nSideIdx; |
| | | bool bIsRipSide = (DIMENSION_A_RIP == eDim) || (DIMENSION_B_RIP == eDim) || (DIMENSION_C_RIP == eDim) || (DIMENSION_D_RIP == eDim); |
| | | if (!bIsRipSide) { |
| | | return; |
| | | } |
| | | |
| | | CRIP_THICKNESS_PARM& rip = m_pRecipe->m_SideParam[eDim].m_RipThk; |
| | | if (rip.m_bUseInspect != TRUE) { |
| | | return; |
| | | } |
| | | |
| | | CSide_Data* pSideData = m_pGlassData->GetSideData(eDim); |
| | | if (pSideData == NULL) { |
| | | return; |
| | | } |
| | | |
| | | if (m_MenuStatus[MODE_VIEW_MEASURE] == FALSE) { |
| | | return; |
| | | } |
| | | |
| | | CPen penOK(PS_SOLID, 1, RGB(0, 255, 0)); |
| | | CPen penNG(PS_SOLID, 1, RGB(255, 0, 0)); |
| | | CPen penNone(PS_DOT, 1, RGB(180, 180, 180)); |
| | | |
| | | CBrush brNull; brNull.CreateStockObject(NULL_BRUSH); |
| | | CPen* pOldPen = memDC->SelectObject(&penOK); |
| | | CBrush* pOldBrush = memDC->SelectObject(&brNull); |
| | | |
| | | auto DrawOne = [&](const CPoint(&pts)[RIP_POINT_COUNT], int nStatus, LPCTSTR label, double value_um, int index, int nAnchorX, int dy) { |
| | | if (nStatus == 0) { |
| | | return; |
| | | } |
| | | |
| | | if (nStatus == 1) { |
| | | memDC->SelectObject(&penOK); |
| | | memDC->SetTextColor(RGB(0, 255, 0)); |
| | | } |
| | | else { |
| | | memDC->SelectObject(&penNG); |
| | | memDC->SetTextColor(RGB(255, 0, 0)); |
| | | } |
| | | |
| | | CPoint p0 = GetWndPos(pts[0]); |
| | | CPoint p1 = GetWndPos(pts[1]); |
| | | |
| | | memDC->MoveTo(p0); memDC->LineTo(p1); |
| | | auto Cross = [&](const CPoint& p) { |
| | | memDC->MoveTo(p.x - 3, p.y - 3); memDC->LineTo(p.x + 3, p.y + 3); |
| | | memDC->MoveTo(p.x + 3, p.y - 3); memDC->LineTo(p.x - 3, p.y + 3); |
| | | }; |
| | | Cross(p0); Cross(p1); |
| | | |
| | | CPoint mid{ (p0.x + p1.x) / 2, (p0.y + p1.y) / 2 }; |
| | | CString s; s.Format(_T("%s[%02d]: %.1f um"), label, index + 1, value_um); |
| | | |
| | | memDC->TextOut(nAnchorX, mid.y + dy, s); |
| | | }; |
| | | |
| | | const int DY = 16; |
| | | for (int i = 0; i < MAX_RIP_SAMPLE_COUNT; ++i) { |
| | | CPoint L0 = GetWndPos(pSideData->m_ptSideRip_Left_pxl[i][0]); |
| | | CPoint L1 = GetWndPos(pSideData->m_ptSideRip_Left_pxl[i][1]); |
| | | CPoint R0 = GetWndPos(pSideData->m_ptSideRip_Right_pxl[i][0]); |
| | | CPoint R1 = GetWndPos(pSideData->m_ptSideRip_Right_pxl[i][1]); |
| | | CPoint G0 = GetWndPos(pSideData->m_ptSideRip_Glass_pxl[i][0]); |
| | | CPoint G1 = GetWndPos(pSideData->m_ptSideRip_Glass_pxl[i][1]); |
| | | |
| | | int nAnchorX = max(max(max(L0.x, L1.x), max(R0.x, R1.x)), max(G0.x, G1.x)) + 6; |
| | | if (nAnchorX > DISPLAY_FRAME_WIDTH / 2) { |
| | | nAnchorX = DISPLAY_FRAME_WIDTH / 2 - 100; |
| | | } |
| | | |
| | | // Left |
| | | DrawOne(pSideData->m_ptSideRip_Left_pxl[i], pSideData->m_nSideRip_Left_Status[i], _T("Rip-Left"), pSideData->m_dSideRip_Left_um[i], i, nAnchorX , -DY); |
| | | |
| | | // Glass |
| | | DrawOne(pSideData->m_ptSideRip_Glass_pxl[i], pSideData->m_nSideRip_Glass_Status[i], _T("Rip-Glass"), pSideData->m_dSideRip_Glass_um[i], i, nAnchorX, 0); |
| | | |
| | | // Right |
| | | DrawOne(pSideData->m_ptSideRip_Right_pxl[i], pSideData->m_nSideRip_Right_Status[i], _T("Rip-Right"), pSideData->m_dSideRip_Right_um[i], i, nAnchorX, +DY); |
| | | } |
| | | |
| | | memDC->SelectObject(pOldPen); |
| | | memDC->SelectObject(pOldBrush); |
| | | brNull.DeleteObject(); |
| | | } |
| | | |
| | | CRect CEdgeImageViewer::GetManualMeasureRect() |
| | | { |
| | | bool bManualMeasure = m_MenuStatus[MODE_USER_SELECT]; |
| | |
| | | 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); |