// DlgAlignHistory.cpp: 구현 파일 // #include "stdafx.h" #include "ReviewSystem.h" #include "DlgAlignHistory.h" // CDlgAlignHistory 대화 상자 IMPLEMENT_DYNAMIC(CDlgAlignHistory, CDialogEx) CDlgAlignHistory::CDlgAlignHistory(CWnd* pParent /*=nullptr*/) : CDialogEx(IDD_DLG_ALIGN_TAB, pParent) { m_strFirstImage.Empty(); m_strSecondImage.Empty(); } CDlgAlignHistory::~CDlgAlignHistory() { } BEGIN_MESSAGE_MAP(CDlgAlignHistory, CDialogEx) ON_WM_TIMER() ON_WM_TIMER() END_MESSAGE_MAP() // CDlgAlignHistory 메시지 처리기 void CDlgAlignHistory::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_ALIGN_GRID_ORIGIN_INFO, m_ctrlOriginInfo); DDX_Control(pDX, IDC_ALIGN_GRID_ALIGN_INFO, m_ctrlAlignInfo); DDX_Control(pDX, IDC_PICTURECTRL, m_PictureControl_Align1); DDX_Control(pDX, IDC_PICTURECTRL2, m_PictureControl_Align2); } BOOL CDlgAlignHistory::OnInitDialog() { CDialog::OnInitDialog(); InitGridOriginInfo(); InitGridAlignInfo(); GetDlgItem(IDC_PICTURECTRL)->GetWindowRect(m_picture_AlignRect); GetDlgItem(IDC_PICTURECTRL2)->GetWindowRect(m_picture_AlignRect2); ScreenToClient(m_picture_AlignRect); ScreenToClient(m_picture_AlignRect2); return TRUE; } void CDlgAlignHistory::UpdateProcess(const CGlassResult* pGlassResult) { if (pGlassResult == NULL) return; CString strValue = _T(""); // glass pos int nRowIdx = 1; int nColIdx = 1; m_strFirstImage.Empty(); m_strSecondImage.Empty(); nRowIdx = 1; nColIdx = 1; strValue.Format(_T("%.3lf"), pGlassResult->GetAlignResult()->nResultCode); m_ctrlOriginInfo.SetItemText(nRowIdx, nColIdx++, strValue); strValue.Format(_T("%.3lf"), pGlassResult->GetAlignResult()->dFindScore[0]); m_ctrlOriginInfo.SetItemText(nRowIdx, nColIdx++, strValue); strValue.Format(_T("%.3lf"), pGlassResult->GetAlignResult()->dFindScore[1]); m_ctrlOriginInfo.SetItemText(nRowIdx, nColIdx++, strValue); // find camera pos nRowIdx = 1; nColIdx = 1; strValue.Format(_T("%.3lf"), pGlassResult->GetAlignResult()->dFindPixelX[0]); m_ctrlAlignInfo.SetItemText(nRowIdx, nColIdx++, strValue); strValue.Format(_T("%.3lf"), pGlassResult->GetAlignResult()->dFindPixelY[0]); m_ctrlAlignInfo.SetItemText(nRowIdx, nColIdx++, strValue); strValue.Format(_T("%.3lf"), pGlassResult->GetAlignResult()->dFindPixelX[1]); m_ctrlAlignInfo.SetItemText(nRowIdx, nColIdx++, strValue); strValue.Format(_T("%.3lf"), pGlassResult->GetAlignResult()->dFindPixelY[1]); m_ctrlAlignInfo.SetItemText(nRowIdx, nColIdx++, strValue); // find motor pos nRowIdx = 2; nColIdx = 1; strValue.Format(_T("%.3lf"), pGlassResult->GetAlignResult()->dFindPositionX[0]); m_ctrlAlignInfo.SetItemText(nRowIdx, nColIdx++, strValue); strValue.Format(_T("%.3lf"), pGlassResult->GetAlignResult()->dFindPositionY[0]); m_ctrlAlignInfo.SetItemText(nRowIdx, nColIdx++, strValue); strValue.Format(_T("%.3lf"), pGlassResult->GetAlignResult()->dFindPositionX[1]); m_ctrlAlignInfo.SetItemText(nRowIdx, nColIdx++, strValue); strValue.Format(_T("%.3lf"), pGlassResult->GetAlignResult()->dFindPositionY[1]); m_ctrlAlignInfo.SetItemText(nRowIdx, nColIdx++, strValue); m_ctrlAlignInfo.Invalidate(FALSE); m_strFirstImage = pGlassResult->GetAlignResult()->strAlignFirest; //image file name m_strSecondImage = pGlassResult->GetAlignResult()->strAlignSecond; DrawImage(pGlassResult->m_AlignRecipe.strFirstImageFile, pGlassResult->m_AlignRecipe.strSecondImageFile, pGlassResult); } void CDlgAlignHistory::DrawImage2(const CGlassResult * pGlassResult) { DrawImage(m_strFirstImage, m_strSecondImage, pGlassResult); } void CDlgAlignHistory::DrawImage(CString strFirstImage, CString strSecondImage, const CGlassResult * pGlassResult) { //KillTimer(1050); //Defect index 넘버에 따라서 다른 이미지를 불러 온다. /* Invalidate(TRUE);*/ CPaintDC dc(this); if (pGlassResult == NULL) return; m_AlignImage1.Destroy(); m_AlignImage2.Destroy(); CString DeftectPath, DeftectPath2; CFileStatus FileOn; TCHAR chFilePath[256] = { 0, }; GetModuleFileName(NULL, chFilePath, 256); CString strFolderPath(chFilePath); strFolderPath = strFolderPath.Left(strFolderPath.ReverseFind('\\')); bool bSkip = false; DeftectPath.Format(_T("D:\\ResultData\\Align\\%s\\%s"), pGlassResult->GetJobID(), strFirstImage); //taek 210316 둘중에 하나 DeftectPath2.Format(_T("D:\\ResultData\\Align\\%s\\%s"), pGlassResult->GetGlassID(), strSecondImage); //taek 210316 둘중에 하나 if (CFile::GetStatus(DeftectPath, FileOn) && strFirstImage != "") //파일이 있을 때 { m_AlignImage1.Load(DeftectPath); HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), strFolderPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); InvalidateRect(m_picture_AlignRect, FALSE); dc.SetStretchBltMode(COLORONCOLOR); m_AlignImage1.Draw(dc, m_picture_AlignRect); } else //파일이 없을 때.. 노 이미지 파일로 보여준다 { bSkip = true; } if (CFile::GetStatus(DeftectPath2, FileOn) && strSecondImage != "") //파일이 있을 때 { m_AlignImage2.Load(DeftectPath2); HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), strFolderPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); InvalidateRect(m_picture_AlignRect2, FALSE); dc.SetStretchBltMode(COLORONCOLOR); m_AlignImage2.Draw(dc, m_picture_AlignRect2); } else //파일이 없을 때.. 노 이미지 파일로 보여준다 { if (bSkip) { DrawnoImage(); } else { strFolderPath = strFolderPath + "\\no-image.png"; m_AlignImage2.Load(strFolderPath); HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), strFolderPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); InvalidateRect(m_picture_AlignRect2, FALSE); dc.SetStretchBltMode(COLORONCOLOR); m_AlignImage2.Draw(dc, m_picture_AlignRect2); } } } void CDlgAlignHistory::DrawnoImage() { CPaintDC dc(this); m_AlignImage1.Destroy(); m_AlignImage2.Destroy(); CString DeftectPath; CFileStatus FileOn; TCHAR chFilePath[256] = { 0, }; GetModuleFileName(NULL, chFilePath, 256); CString strFolderPath(chFilePath); strFolderPath = strFolderPath.Left(strFolderPath.ReverseFind('\\')); strFolderPath = strFolderPath + "\\no-image.png"; m_AlignImage1.Load(strFolderPath); m_AlignImage2.Load(strFolderPath); HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), strFolderPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); InvalidateRect(m_picture_AlignRect, FALSE); InvalidateRect(m_picture_AlignRect2, FALSE); dc.SetStretchBltMode(COLORONCOLOR); m_AlignImage1.Draw(dc, m_picture_AlignRect); m_AlignImage2.Draw(dc, m_picture_AlignRect2); ////////////////////////////////////////////////////////////////////////////////// // //Invalidate(TRUE); // CPaintDC dc(this); // // CDC memDC; // CDC* pDC = this->GetDC(); // // m_AlignImage1.Destroy(); // m_AlignImage2.Destroy(); // // CString DeftectPath; // CFileStatus FileOn; // TCHAR chFilePath[256] = { 0, }; // GetModuleFileName(NULL, chFilePath, 256); // CString strFolderPath(chFilePath); // strFolderPath = strFolderPath.Left(strFolderPath.ReverseFind('\\')); // // strFolderPath = strFolderPath + "\\no-image.png"; // m_AlignImage1.Load(strFolderPath); // m_AlignImage2.Load(strFolderPath); // // memDC.CreateCompatibleDC(pDC); // // InvalidateRect(m_picture_AlignRect, FALSE); // InvalidateRect(m_picture_AlignRect2, FALSE); // // HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), strFolderPath, // IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); // // m_AlignImage1.Draw(pDC->m_hDC, 0, 0, m_picture_AlignRect.Width(), m_picture_AlignRect.Height()); // // pDC->StretchBlt(0, 0, m_picture_AlignRect.Width(), m_picture_AlignRect.Height(), &memDC, 0, 0, m_picture_AlignRect.Width(), m_picture_AlignRect.Height(), SRCCOPY); // // m_PictureControl_Align1.ReleaseDC(pDC); // pDC->DeleteDC(); // pDC = NULL; //dc.SetStretchBltMode(COLORONCOLOR); //m_AlignImage1.Draw(dc, m_picture_AlignRect); //m_AlignImage2.Draw(dc, m_picture_AlignRect2); ///////////////////////////////////////////////////////////////////////////////////////// // CDC memDC; // CDC* pDC = this->GetDC(); /* CBitmap bmp, *pOldBmp;*/ /* BITMAP bm;*/ // //1.이미지 로딩하기 // //bmp.m_hObject = (HBITMAP)LoadImage(NULL, _T(strFolderPath), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE); // HBITMAP hBmp2 = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), strFolderPath,IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); // if (bmp.m_hObject == NULL) return; // // bmp.GetBitmap(&bm); // memDC.CreateCompatibleDC(pDC); // // pOldBmp = memDC.SelectObject(&bmp); // // int nX = m_picture_AlignRect.left + (m_picture_AlignRect.Width() - bm.bmWidth) / 2; // int nY = m_picture_AlignRect.top + (m_picture_AlignRect.Height() - bm.bmHeight) / 2; // // pDC->BitBlt(nX, nY, bm.bmWidth, bm.bmHeight, &memDC, 0, 0,SRCCOPY); // // memDC.SelectObject(pOldBmp); // // this->ReleaseDC(pDC); } void CDlgAlignHistory::InitGridOriginInfo() { int nRowIdx, nColIdx, nRows, nCols, nFixRows, nFixCols; CString strTemp; CRect rt; nRows = 2; nCols = 4; nFixRows = 1; nFixCols = 1; nRowIdx = 0; nColIdx = 0; m_ctrlOriginInfo.GetClientRect(&rt); m_ctrlOriginInfo.GetDefaultCell(TRUE, FALSE)->SetBackClr(RGB(180, 210, 247)); m_ctrlOriginInfo.GetDefaultCell(FALSE, TRUE)->SetBackClr(RGB(180, 210, 247)); m_ctrlOriginInfo.GetDefaultCell(FALSE, FALSE)->SetBackClr(RGB(255, 255, 255)); m_ctrlOriginInfo.SetRowCount(nRows); m_ctrlOriginInfo.SetColumnCount(nCols); m_ctrlOriginInfo.SetFixedRowCount(nFixRows); m_ctrlOriginInfo.SetFixedColumnCount(nFixCols); m_ctrlOriginInfo.SetColumnWidth(0, 60); m_ctrlOriginInfo.SetColumnWidth(1, 95); m_ctrlOriginInfo.SetColumnWidth(2, 95); m_ctrlOriginInfo.SetColumnWidth(3, 95); GV_ITEM Item; nRowIdx = 0; nColIdx = 1; Item.mask = GVIF_TEXT; Item.row = nRowIdx++; Item.col = nColIdx; strTemp.Format(_T("")); Item.strText = strTemp; m_ctrlOriginInfo.SetItem(&Item); // row Item.mask = GVIF_TEXT; Item.row = nRowIdx++; Item.col = nColIdx; strTemp.Format(_T("")); Item.strText = strTemp; m_ctrlOriginInfo.SetItem(&Item); // col nRowIdx = 0; nColIdx = 1; Item.row = nRowIdx; Item.col = nColIdx++; strTemp.Format(_T("Result")); Item.strText = strTemp; m_ctrlOriginInfo.SetItem(&Item); Item.col = nColIdx++; strTemp.Format(_T("Find Socore 1")); Item.strText = strTemp; m_ctrlOriginInfo.SetItem(&Item); Item.col = nColIdx++; strTemp.Format(_T("Find Socore 2")); Item.strText = strTemp; m_ctrlOriginInfo.SetItem(&Item); m_ctrlOriginInfo.SetEditable(FALSE); } void CDlgAlignHistory::InitGridAlignInfo() { int nRowIdx, nColIdx, nRows, nCols, nFixRows, nFixCols; CString strTemp; CRect rt; nRows = 3; nCols = 5; nFixRows = 1; nFixCols = 1; nRowIdx = 0; nColIdx = 0; m_ctrlAlignInfo.GetClientRect(&rt); m_ctrlAlignInfo.GetDefaultCell(TRUE, FALSE)->SetBackClr(RGB(180, 210, 247)); m_ctrlAlignInfo.GetDefaultCell(FALSE, TRUE)->SetBackClr(RGB(180, 210, 247)); m_ctrlAlignInfo.GetDefaultCell(FALSE, FALSE)->SetBackClr(RGB(255, 255, 255)); m_ctrlAlignInfo.SetRowCount(nRows); m_ctrlAlignInfo.SetColumnCount(nCols); m_ctrlAlignInfo.SetFixedRowCount(nFixRows); m_ctrlAlignInfo.SetFixedColumnCount(nFixCols); m_ctrlAlignInfo.SetColumnWidth(0, 95); m_ctrlAlignInfo.SetColumnWidth(1, 70); m_ctrlAlignInfo.SetColumnWidth(2, 70); m_ctrlAlignInfo.SetColumnWidth(3, 70); m_ctrlAlignInfo.SetColumnWidth(4, 70); GV_ITEM Item; nRowIdx = 0; nColIdx = 0; Item.mask = GVIF_TEXT; Item.row = nRowIdx++; Item.col = nColIdx; strTemp.Format(_T("")); Item.strText = strTemp; m_ctrlAlignInfo.SetItem(&Item); // row Item.mask = GVIF_TEXT; Item.row = nRowIdx++; Item.col = nColIdx; strTemp.Format(_T("Pixel")); Item.strText = strTemp; m_ctrlAlignInfo.SetItem(&Item); Item.mask = GVIF_TEXT; Item.row = nRowIdx++; Item.col = nColIdx; strTemp.Format(_T("Position")); Item.strText = strTemp; m_ctrlAlignInfo.SetItem(&Item); // col nRowIdx = 0; nColIdx = 1; Item.row = nRowIdx; Item.col = nColIdx++; strTemp.Format(_T("1st X_Pos")); Item.strText = strTemp; m_ctrlAlignInfo.SetItem(&Item); Item.col = nColIdx++; strTemp.Format(_T("1st Y_Pos")); Item.strText = strTemp; m_ctrlAlignInfo.SetItem(&Item); Item.row = nRowIdx; Item.col = nColIdx++; strTemp.Format(_T("2nd X_Pos")); Item.strText = strTemp; m_ctrlAlignInfo.SetItem(&Item); Item.col = nColIdx++; strTemp.Format(_T("2nd Y_Pos")); Item.strText = strTemp; m_ctrlAlignInfo.SetItem(&Item); m_ctrlAlignInfo.SetEditable(FALSE); } void CDlgAlignHistory::OnTimer(UINT_PTR nIDEvent) { // TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다. }