| | |
| | | m_pView->SetTransferData(&m_TransferData); |
| | | } |
| | | |
| | | CString CMainFrame::GetGlassIDFromFolder(const CString& strFolderPath) |
| | | { |
| | | // 查找图像文件 |
| | | CFileFind finder; |
| | | BOOL bWorking = finder.FindFile(strFolderPath + _T("\\*.jpg")); |
| | | if (!bWorking) { |
| | | g_pLog->DisplayMessage(_T("No image files found in folder!")); |
| | | return _T(""); |
| | | } |
| | | |
| | | // 找到第一个有效文件 |
| | | CString strGlassID; |
| | | while (bWorking) { |
| | | bWorking = finder.FindNextFile(); |
| | | if (!finder.IsDots()) { |
| | | CString strFileName = finder.GetFileName(); |
| | | int nPos = strFileName.Find(_T("__")); |
| | | if (nPos > 0) |
| | | { |
| | | strGlassID = strFileName.Left(nPos); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (strGlassID.IsEmpty()) { |
| | | g_pLog->DisplayMessage(_T("No valid image files found!")); |
| | | } |
| | | |
| | | return strGlassID; |
| | | } |
| | | |
| | | void CMainFrame::LoadImageSetFromFolder(const CString& strFolderPath, const CString& strGlsID, int iSide, CGlass_Data* pGlassData, std::function<void(BYTE)> _Func) |
| | | { |
| | | char str_filename[200]; |
| | | int nStartY = 0, nHeight = 0; |
| | | for (int j = 0; j < 6; j++) { |
| | | CString strPath; |
| | | strPath.Format(_T("%s\\%s__%s_%d.jpg"), strFolderPath, strGlsID, PANEL_SIDE[iSide], j); |
| | | |
| | | USES_CONVERSION; |
| | | sprintf_s(str_filename, "%s", W2A(strPath)); |
| | | if (access(str_filename, 0) == 0) { |
| | | nHeight = LoadFullImage(strPath, iSide, nStartY); |
| | | if (nHeight == -1) { |
| | | break; |
| | | } |
| | | nStartY += nHeight; |
| | | } |
| | | else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (pGlassData != NULL) { |
| | | INS_EDGE_RESULT_INFO* pResInfo = pGlassData->GetEdgeResultInfo((DimensionDir)iSide); |
| | | if (pResInfo != NULL) { |
| | | pResInfo->nGlassStartLine = 0; |
| | | pResInfo->nGlassEndLine = nStartY; |
| | | } |
| | | } |
| | | |
| | | if (_Func != nullptr) { |
| | | _Func(iSide); |
| | | } |
| | | } |
| | | |
| | | BOOL CMainFrame::IV2M_RecipeChange(CString strRecipe) |
| | | { |
| | | m_strReserveRecipe.Empty(); |
| | |
| | | CString strGlsID, strTmp , strExt; |
| | | |
| | | strExt = dlg.GetFileExt(); |
| | | strGlsID =dlg.GetFileName(); |
| | | strGlsID = dlg.GetFileName(); |
| | | strGlsID = strGlsID.Left(strGlsID.Find(_T("__"))); |
| | | g_pBase->m_strHPanelID = strGlsID; |
| | | |
| | |
| | | g_pLog->DisplayMessage(_T("Loading Full Image Completed")); |
| | | } |
| | | |
| | | void CMainFrame::IV2M_LoadImageFromFolder(int iSide, const CString& strFolderPath, CGlass_Data* pGlassData, std::function<void(BYTE)> _Func) |
| | | { |
| | | if (IsScanNow()) { |
| | | g_pLog->DisplayMessage(_T("Doing Inspection")); |
| | | return; |
| | | } |
| | | |
| | | if (m_bManualProcessStart == TRUE) { |
| | | g_pLog->DisplayMessage(_T("Doing Manual Process")); |
| | | return; |
| | | } |
| | | |
| | | CFileFind finder; |
| | | BOOL bWorking = finder.FindFile(strFolderPath + _T("\\*.jpg")); |
| | | if (!bWorking) { |
| | | g_pLog->DisplayMessage(_T("No image files found in folder!")); |
| | | return; |
| | | } |
| | | |
| | | m_bManualProcessStart = TRUE; |
| | | SetSlashText(GLOBAL_DEFINE::emShow, _T(""), RGB(0, 0, 0)); |
| | | SetSlashText(GLOBAL_DEFINE::emText, _T("Image Loading Start"), RGB(0, 0, 0)); |
| | | |
| | | // 提取产品ID |
| | | CString strGlsID = GetGlassIDFromFolder(strFolderPath); |
| | | g_pBase->m_strHPanelID = strGlsID; |
| | | |
| | | if (iSide > -1) { |
| | | // 单侧加载 |
| | | LoadImageSetFromFolder(strFolderPath, strGlsID, iSide, pGlassData, _Func); |
| | | } |
| | | else { |
| | | // 全侧加载 |
| | | for (int i = 0; i < MAX_PANEL_SIDE * UPDN_TYPE; i++) { |
| | | LoadImageSetFromFolder(strFolderPath, strGlsID, i, pGlassData, _Func); |
| | | } |
| | | } |
| | | |
| | | SetSlashText(GLOBAL_DEFINE::emHide, _T("Loading Full Image Completed"), RGB(0, 0, 0)); |
| | | |
| | | m_bManualProcessStart = FALSE; |
| | | g_pLog->DisplayMessage(_T("Loading Full Image Completed")); |
| | | } |
| | | |
| | | void CMainFrame::DisplayMessage(TCHAR* str) |
| | | { |
| | | WriteLogManager(str); |