From f6faaf9e513c25abe51855c9a798af0afb2cc9dd Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期五, 08 八月 2025 11:13:07 +0800
Subject: [PATCH] 1. 封装目录测试函数,方便本地测试

---
 EdgeInspector_App/View/ViewMain_ScanImage.cpp |   72 +++++++++++++++++------------------
 1 files changed, 35 insertions(+), 37 deletions(-)

diff --git a/EdgeInspector_App/View/ViewMain_ScanImage.cpp b/EdgeInspector_App/View/ViewMain_ScanImage.cpp
index 7587647..1e953b6 100644
--- a/EdgeInspector_App/View/ViewMain_ScanImage.cpp
+++ b/EdgeInspector_App/View/ViewMain_ScanImage.cpp
@@ -10,7 +10,8 @@
 
 enum TYPE_MANUAL_CMD
 {
-	M_CMD_PROC_SHORT_START = 0,
+	M_CMD_PROC_RIP_START = 0,
+	M_CMD_PROC_SHORT_START,
 	M_CMD_PROC_LONG_START,
 	M_CMD_PROC_ALL_START,
 	M_CMD_IMG_LOAD_ALL,
@@ -263,12 +264,10 @@
 
 void CViewMain_ScanImage::OnShowWindow(BOOL bShow, UINT nStatus)
 {
-	if(bShow == TRUE)
-	{
+	if(bShow == TRUE) {
 		int nSide;		
 		CString	strTitle;
-		for(int i = 0 ; i < MAX_PANEL_SIDE * UPDN_TYPE; i++)
-		{
+		for(int i = 0 ; i < MAX_PANEL_SIDE * UPDN_TYPE; i++) {
 			nSide = GetSideIdx(i);
 			m_frameImg[i].SetSideIdx(nSide);			
 			m_frameImg[i].SetGlassData(m_pGlassData);
@@ -278,15 +277,15 @@
 			m_frameImg[i].Invalidate();
 
 			if(m_pHardware != NULL) {
-				CCameraSettings *pCamera = LiveGetSideIdx(i);
+				CCameraSettings *pCamera = GetCameraSettingsByViewIndex(i);
 				if(pCamera != NULL) {
 					double dPixelSizeX = pCamera->m_dConvResolution[0];
 					double dPixelSizeY = pCamera->m_dScanResolution[0];
 					m_frameImg[i].SetPixelSize(dPixelSizeX, dPixelSizeY);
+
+					strTitle.Format(_T("BORD[%d]  CHANNEL[%d]"), pCamera->m_iCamera, 0);
+					m_staticCamInfo[i].SetWindowText(strTitle);
 				}
-				
-				strTitle.Format(_T("BORD[%d]  CHANNEL[%d]"),pCamera->m_iCamera, 0);
-				m_staticCamInfo[i].SetWindowText(strTitle);
 			}			
 		}
 
@@ -1189,8 +1188,9 @@
 	CViewMain_ScanImage *pDlg = (CViewMain_ScanImage*)pParam;
 	int i =0;
 	if(pDlg->m_nThreadCmd == M_CMD_PROC_ALL_START
+		|| pDlg->m_nThreadCmd == M_CMD_PROC_LONG_START
 		|| pDlg->m_nThreadCmd == M_CMD_PROC_SHORT_START
-		|| pDlg->m_nThreadCmd == M_CMD_PROC_LONG_START)
+		|| pDlg->m_nThreadCmd == M_CMD_PROC_RIP_START)
 	{
 		pDlg->m_IV2M->IV2M_InspectionProcessAll(pDlg->m_nThreadCmd);
 	}
@@ -1303,9 +1303,9 @@
 		ManualThreadStart(M_CMD_PROC_SHORT_START);  
 		break;
 
-	//case 3:
-	//	ManualThreadStart(M_CMD_PROC_RIP_START);
-	//	break;
+	case 3:
+		ManualThreadStart(M_CMD_PROC_RIP_START);
+		break;
 	}
 }
 
@@ -1364,32 +1364,30 @@
 	}
 }
 
-CCameraSettings* CViewMain_ScanImage::LiveGetSideIdx(int nViewIndex)
+CCameraSettings* CViewMain_ScanImage::GetCameraSettingsByViewIndex(int nViewIndex)
 {
 	CCameraSettings* pCamera = NULL;
-	if (m_pHardware != nullptr) {
-		int nSide = GetSideIdx(nViewIndex);
-		int nCamera = m_pHardware->GetCameraIndexToDimension((DimensionDir)nSide);
-		if (nViewIndex < MAX_PANEL_SIDE) {
-			// Long side
-			pCamera = m_pHardware->GetCameraSettings(nCamera, 0);
-		}
-		else if (nViewIndex < 2 * MAX_PANEL_SIDE) {
-			// Short side
-			pCamera = m_pHardware->GetCameraSettings(nCamera, 1);
-		}
-		else {
-			// Rip side
-			int nRipIndex = nViewIndex - 2 * MAX_PANEL_SIDE;
-			int nRipCamera = nRipIndex / 2 + MAX_PANEL_SIDE;
-			if (nRipIndex % 2 != 0) {
-				pCamera = m_pHardware->GetCameraSettings(nCamera, 0);
-			}
-			else {
-				pCamera = m_pHardware->GetCameraSettings(nCamera, 1);
-			}
-		}
+	if (nullptr != m_pHardware) {
+		return pCamera;
 	}
 
-	return pCamera;
+	// ViewIndex -> DimensionDir
+	static const DimensionDir SIDE_MAP[] = {
+		DIMENSION_C, DIMENSION_C_DN,
+		DIMENSION_A, DIMENSION_A_DN,
+		DIMENSION_D, DIMENSION_D_DN,
+		DIMENSION_B, DIMENSION_B_DN,
+		DIMENSION_A_RIP, DIMENSION_B_RIP,
+		DIMENSION_C_RIP, DIMENSION_D_RIP
+	};
+
+	if (nViewIndex < 0 || nViewIndex >= _countof(SIDE_MAP)) {
+		AfxMessageBox(_T("GetCameraSettingsByViewIndex: Invalid view index"));
+		return nullptr;
+	}
+
+	DimensionDir eSide = SIDE_MAP[nViewIndex];
+	int nScan = m_pHardware->GetScanToDimension(eSide);
+	int nCamera = m_pHardware->GetCameraIndexToDimension(eSide);
+	return pCamera = m_pHardware->GetCameraSettings(nCamera, nScan);
 }
\ No newline at end of file

--
Gitblit v1.9.3