From 5e802e47375cb399b91f0abdc95420d6cce0b18b Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期六, 16 八月 2025 15:26:02 +0800
Subject: [PATCH] 1. 添加一个线程类,保存全图使用队列一个一个保存
---
EdgeInspector_App/View/EdgeImageViewer.cpp | 167 +++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 129 insertions(+), 38 deletions(-)
diff --git a/EdgeInspector_App/View/EdgeImageViewer.cpp b/EdgeInspector_App/View/EdgeImageViewer.cpp
index dc5ab95..c0bacd7 100644
--- a/EdgeInspector_App/View/EdgeImageViewer.cpp
+++ b/EdgeInspector_App/View/EdgeImageViewer.cpp
@@ -1,4 +1,4 @@
-#include "stdafx.h"
+锘�#include "stdafx.h"
#include "EdgeImageViewer.h"
// CEdgeImageViewer
@@ -136,8 +136,8 @@
{
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)"));
@@ -230,7 +230,7 @@
if(bAllCheck)
popMenu.CheckMenuItem(ID_MODE_VIEW_DEFECT_ALL,MF_CHECKED);
- // 牧咆胶飘 皋春 龋免
+ // 鐗у拞鑳堕 鐨嬫槬 榫嬪厤
CRect rect;
GetWindowRect(rect);
int nX = rect.left + point.x;
@@ -498,8 +498,8 @@
void CEdgeImageViewer::OnPaint()
{
CPaintDC dc(this); // device context for painting
- // TODO: 咯扁俊 皋矫瘤 贸府扁 内靛甫 眠啊钦聪促.
- // 弊府扁 皋矫瘤俊 措秦辑绰 CStatic::OnPaint()阑(甫) 龋免窍瘤 付绞矫坷.
+ // TODO: 鍜墎淇� 鐨嬬煫鐦� 璐稿簻鎵� 鍐呴潧鐢� 鐪犲晩閽﹁仾淇�.
+ // 寮婂簻鎵� 鐨嬬煫鐦や繆 鎺Е杈戠话 CStatic::OnPaint()闃�(鐢�) 榫嬪厤绐嶇槫 浠樼粸鐭澐.
UpdateView();
}
@@ -529,7 +529,7 @@
// 1. Draw Buffer Image
UpdateView_Image(&memDC);
- //2. 显示视觉效果
+ //2. 鏄剧ず瑙嗚鏁堟灉
UpdateView_VisionResult(&memDC);
@@ -568,7 +568,7 @@
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();
@@ -582,7 +582,7 @@
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) {
@@ -598,7 +598,7 @@
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);
@@ -609,7 +609,7 @@
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();
@@ -667,6 +667,8 @@
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);
@@ -688,7 +690,7 @@
// 7. Draw Exception : MODE_VIEW_EXCEPTION_AREA
UpdateView_ExceptionArea(&memDC);
-
+
// 8. Draw Inspect : MODE_VIEW_INSPECT_AREA
UpdateView_InspectArea(&memDC);
@@ -718,10 +720,12 @@
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);
@@ -861,7 +865,7 @@
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;
@@ -872,7 +876,7 @@
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);
@@ -897,11 +901,13 @@
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));
@@ -916,49 +922,42 @@
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));
@@ -967,8 +966,7 @@
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));
@@ -1933,7 +1931,7 @@
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
@@ -2166,6 +2164,99 @@
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];
@@ -2240,7 +2331,7 @@
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;
@@ -2263,7 +2354,7 @@
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;
@@ -2349,7 +2440,7 @@
#if HALCON_VISION_KEY
void CEdgeImageViewer::OnLButtonUp(UINT nFlags, CPoint point)
{
- // TODO: 在此添加消息处理程序代码和/或调用默认值
+ // TODO: 鍦ㄦ娣诲姞娑堟伅澶勭悊绋嬪簭浠g爜鍜�/鎴栬皟鐢ㄩ粯璁ゅ��
m_isMouseDown = FALSE;
CWnd::OnLButtonUp(nFlags, point);
--
Gitblit v1.9.3