»õ ÆÄÀÏ |
| | |
| | | // DefectListDlg.cpp: 구í íì¼ |
| | | // |
| | | |
| | | #include "stdafx.h" |
| | | #include "ReveiwHistory.h" |
| | | #include "AlignDlg.h" |
| | | #include "afxdialogex.h" |
| | | #include <algorithm> |
| | | #include <functional> |
| | | |
| | | // CFormtListDlg ëí ìì |
| | | |
| | | IMPLEMENT_DYNAMIC(CAlignDlg, CDialog) |
| | | |
| | | enum { FORMLIST_POPUP_FORMALL = 15000, FORMLIST_POPUP_FORMSELECT, FORMLIST_POPUP_End }; |
| | | |
| | | |
| | | CAlignDlg::CAlignDlg(CWnd* pParent /*=nullptr*/) |
| | | : CDialog(IDD_DLG_ALIGN, pParent) |
| | | { |
| | | m_pDefectFormation = NULL; |
| | | m_bAsending = FALSE; |
| | | m_nLastSortCol = 0; |
| | | m_nSelectedCol = 0; |
| | | m_nSelectedRow = 0; |
| | | m_nSelectedFormIdRclick = -1; |
| | | } |
| | | |
| | | CAlignDlg::~CAlignDlg() |
| | | { |
| | | } |
| | | |
| | | void CAlignDlg::DoDataExchange(CDataExchange* pDX) |
| | | { |
| | | CDialog::DoDataExchange(pDX); |
| | | } |
| | | |
| | | BOOL CAlignDlg::Create(CWnd * pParentWnd) |
| | | { |
| | | return CDialog::Create(IDD, pParentWnd); |
| | | } |
| | | |
| | | BOOL CAlignDlg::PreTranslateMessage(MSG * pMsg) |
| | | { |
| | | if (pMsg->message == WM_KEYDOWN) |
| | | { |
| | | if (pMsg->wParam == VK_ESCAPE) |
| | | { |
| | | ShowWindow(SW_HIDE); |
| | | |
| | | return TRUE; |
| | | } |
| | | } |
| | | |
| | | return __super::PreTranslateMessage(pMsg); |
| | | } |
| | | |
| | | void CAlignDlg::OnDestroy() |
| | | { |
| | | CDialog::OnDestroy(); |
| | | } |
| | | |
| | | void CAlignDlg::OnShowWindow(BOOL bShow, UINT nStatus) |
| | | { |
| | | __super::OnShowWindow(bShow, nStatus); |
| | | |
| | | // TODO: ì¬ê¸°ì ë©ìì§ ì²ë¦¬ê¸° ì½ë를 ì¶ê°í©ëë¤. |
| | | if (TRUE == bShow) |
| | | { |
| | | } |
| | | } |
| | | |
| | | |
| | | BEGIN_MESSAGE_MAP(CAlignDlg, CDialog) |
| | | ON_BN_CLICKED(IDOK, &CAlignDlg::OnBnClickedOk) |
| | | ON_CONTROL_RANGE(BN_CLICKED, FORMLIST_POPUP_FORMALL, FORMLIST_POPUP_End, OnPopupMenuFormList) |
| | | ON_WM_SIZE() |
| | | END_MESSAGE_MAP() |
| | | |
| | | |
| | | // CFormtListDlg ë©ìì§ ì²ë¦¬ê¸° |
| | | |
| | | |
| | | void CAlignDlg::OnBnClickedOk() |
| | | { |
| | | // TODO: ì¬ê¸°ì 컨í¸ë¡¤ ì림 ì²ë¦¬ê¸° ì½ë를 ì¶ê°í©ëë¤. |
| | | CDialog::OnOK(); |
| | | } |
| | | |
| | | |
| | | BOOL CAlignDlg::OnInitDialog() |
| | | { |
| | | CDialog::OnInitDialog(); |
| | | |
| | | // TODO: ì¬ê¸°ì ì¶ê° ì´ê¸°í ìì
ì ì¶ê°í©ëë¤. |
| | | |
| | | m_vecStrGridDefectHeader.push_back(" "); |
| | | m_vecStrGridDefectHeader.push_back("1st X Pos"); |
| | | m_vecStrGridDefectHeader.push_back("1st Y Pos"); |
| | | m_vecStrGridDefectHeader.push_back("2nd X Pos"); |
| | | m_vecStrGridDefectHeader.push_back("2nd Y Pos"); |
| | | |
| | | CakGridCtrl* pGrid = &m_gridFormInfo; |
| | | { |
| | | std::vector<CString>* pVecHeader = &m_vecStrGridDefectHeader; |
| | | |
| | | CRect rectGrid; |
| | | GetDlgItem(IDC_STATIC_GRID_ALIGN)->GetWindowRect(&rectGrid); |
| | | ScreenToClient(&rectGrid); |
| | | pGrid->Create(rectGrid, this, IDC_STATIC_GRID_ALIGN); |
| | | |
| | | |
| | | pGrid->GetDefaultCell(TRUE, FALSE)->SetBackClr(GRID_FIX_COLOR); |
| | | pGrid->GetDefaultCell(FALSE, TRUE)->SetBackClr(GRID_FIX_COLOR); |
| | | pGrid->GetDefaultCell(FALSE, FALSE)->SetBackClr(GRID_COLOR); |
| | | pGrid->SetFixedBkColor(GRID_FIX_COLOR); |
| | | pGrid->SetGridLines(GVL_BOTH); |
| | | |
| | | |
| | | pGrid->SetVirtualMode(TRUE); |
| | | pGrid->SetCallbackFunc(NULL, 0); |
| | | pGrid->AllowReorderColumn(FALSE); // implemented now only if m_bCallback |
| | | pGrid->EnableDragRowMode(FALSE); |
| | | |
| | | pGrid->SetColumnCount((int)pVecHeader->size()); |
| | | pGrid->SetDoubleBuffering(TRUE); |
| | | pGrid->SetRowCount(2); |
| | | pGrid->SetFixedRowCount(1); |
| | | pGrid->SetFixedColumnCount(0); |
| | | |
| | | pGrid->SetEditable(FALSE); |
| | | pGrid->EnableSelection(TRUE); |
| | | pGrid->SetFixedRowSelection(TRUE); |
| | | pGrid->SetHeaderSort(FALSE); |
| | | |
| | | // fill it up with stuff |
| | | pGrid->SetEditable(TRUE); |
| | | pGrid->EnableDragAndDrop(TRUE); |
| | | |
| | | |
| | | pGrid->AutoSize(); |
| | | pGrid->Invalidate(); |
| | | } |
| | | |
| | | m_WndArrange.setParentWnd(this); |
| | | m_WndArrange.addChildWnd(&m_gridFormInfo, WA_RESIZE_WIDTH | WA_RESIZE_HEIGHT); |
| | | |
| | | GetDlgItem(IDC_IMG_ALIGN1)->GetWindowRect(m_picture_rect); |
| | | GetDlgItem(IDC_IMG_ALIGN2)->GetWindowRect(m_picture_rect2); |
| | | |
| | | ScreenToClient(m_picture_rect); |
| | | ScreenToClient(m_picture_rect2); |
| | | |
| | | return TRUE; // return TRUE unless you set the focus to a control |
| | | // ìì¸: OCX ìì± íì´ì§ë FALSE를 ë°íí´ì¼ í©ëë¤. |
| | | } |
| | | |
| | | |
| | | BOOL CAlignDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) |
| | | { |
| | | // TODO: ì¬ê¸°ì í¹ìíë ì½ë를 ì¶ê° ë°/ëë 기본 í´ëì¤ë¥¼ í¸ì¶í©ëë¤. |
| | | if (m_gridFormInfo.GetSafeHwnd() && wParam == (WPARAM)m_gridFormInfo.GetDlgCtrlID()) |
| | | { |
| | | *pResult = 1; |
| | | GV_DISPINFO *pDispInfo = (GV_DISPINFO*)lParam; |
| | | if (GVN_GETDISPINFO == pDispInfo->hdr.code) |
| | | { |
| | | getDispInfoDefect(pDispInfo->item.col, pDispInfo->item.row, &pDispInfo->item.strText); |
| | | |
| | | return TRUE; |
| | | } |
| | | else if (NM_CLICK == pDispInfo->hdr.code) |
| | | { |
| | | if (pDispInfo->item.row == 0) |
| | | { |
| | | SortListDefect(pDispInfo->item.col); |
| | | m_gridFormInfo.Refresh(); |
| | | } |
| | | else if (pDispInfo->item.row > 0) |
| | | { |
| | | if (pDispInfo->item.row <= m_vecSortForm.size()) |
| | | { |
| | | int nFormID = m_vecSortForm[pDispInfo->item.row - 1]->m_nFormLabel; |
| | | GetParent()->PostMessage(UM_FORMLIST_FORMSELECT, nFormID); |
| | | } |
| | | |
| | | } |
| | | m_nSelectedCol = pDispInfo->item.col; |
| | | } |
| | | else if (NM_RCLICK == pDispInfo->hdr.code) |
| | | { |
| | | if (pDispInfo->item.row>0 && pDispInfo->item.row <= m_vecSortForm.size()) |
| | | { |
| | | m_nSelectedFormIdRclick = m_vecSortForm[pDispInfo->item.row - 1]->m_nFormLabel; |
| | | } |
| | | else if (pDispInfo->item.row == 0) |
| | | { |
| | | m_nSelectedFormIdRclick = -1; |
| | | } |
| | | else |
| | | { |
| | | m_nSelectedFormIdRclick = -1; |
| | | } |
| | | |
| | | |
| | | // { |
| | | // CString strText; |
| | | // CMenu menu; |
| | | // VERIFY(menu.CreatePopupMenu()); |
| | | // |
| | | // menu.AppendMenu(MF_STRING, FORMLIST_POPUP_FORMALL, (LPCTSTR)"ì 체보기"); |
| | | // |
| | | // if (m_nSelectedFormIdRclick < 0) |
| | | // { |
| | | // |
| | | // } |
| | | // else if (m_nSelectedFormIdRclick >= 0) |
| | | // { |
| | | // strText.Format("Form%d 보기", m_nSelectedFormIdRclick); |
| | | // menu.AppendMenu(MF_STRING, FORMLIST_POPUP_FORMSELECT, (LPCTSTR)strText); |
| | | // } |
| | | // |
| | | // |
| | | // CPoint ptPoint; |
| | | // GetCursorPos(&ptPoint); |
| | | // |
| | | // menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, ptPoint.x, ptPoint.y, this); |
| | | // |
| | | // } |
| | | |
| | | } |
| | | else if (GVN_ODCACHEHINT == pDispInfo->hdr.code) |
| | | { |
| | | GV_CACHEHINT *pCacheHint = (GV_CACHEHINT*)pDispInfo; |
| | | } |
| | | } |
| | | return CDialog::OnNotify(wParam, lParam, pResult); |
| | | } |
| | | |
| | | void CAlignDlg::setFormShow(int nFormID, BOOL bEnsureVisible) |
| | | { |
| | | const int nDefectCol = 1; |
| | | |
| | | if (nFormID >= 0) |
| | | { |
| | | int iRow = m_nSelectedRow;//for (int iRow = 0; iRow < m_gridDefectInfo.GetRowCount(); iRow++) |
| | | { |
| | | for (int iCol = 0; iCol < m_gridFormInfo.GetColumnCount(); iCol++) |
| | | { |
| | | m_gridFormInfo.SetItemState(iRow, iCol, m_gridFormInfo.GetItemState(iRow, iCol) & ~GVIS_SELECTED /*& ~GVIS_FOCUSED*/); |
| | | } |
| | | } |
| | | } |
| | | for (int i = 0; i < m_vecSortForm.size(); i++) |
| | | { |
| | | if (m_vecSortForm[i]->m_nFormLabel == nFormID) |
| | | { |
| | | int iRow = i+1; |
| | | for (int iCol = 0; iCol < m_gridFormInfo.GetColumnCount(); iCol++) |
| | | { |
| | | m_gridFormInfo.SetItemState(iRow, iCol, LVIS_SELECTED); |
| | | } |
| | | m_nSelectedRow = iRow; |
| | | if (bEnsureVisible) |
| | | { |
| | | m_gridFormInfo.EnsureVisible(iRow, m_nSelectedCol); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | m_gridFormInfo.Invalidate(); |
| | | } |
| | | |
| | | void CAlignDlg::getDispInfoDefect(int nCol, int nRow, CString* pStrData) |
| | | { |
| | | if (nRow < 0) return; |
| | | |
| | | if (nRow == 0) //header |
| | | { |
| | | *pStrData = m_vecStrGridDefectHeader[nCol]; |
| | | } |
| | | else |
| | | { |
| | | if (m_pDefectFormation == NULL) return; |
| | | |
| | | int nDataIndex = nRow - 1; |
| | | |
| | | if (nDataIndex >= m_vecSortForm.size()) return; |
| | | |
| | | _akFormation* pForm = m_vecSortForm[nDataIndex]; |
| | | |
| | | if (pForm == NULL) |
| | | return; |
| | | |
| | | CString strItem; |
| | | BOOL bPixel = FALSE; |
| | | |
| | | |
| | | switch (nCol) |
| | | { |
| | | case 0: strItem.Format("%d", nRow); break; |
| | | case 1: strItem.Format("%d", pForm->m_nFormLabel); break; |
| | | case 2: |
| | | { |
| | | if (pForm->m_nFormJudge == 0) strItem = ""; |
| | | else if (pForm->m_nFormJudge == 1) strItem = "ì ê±°"; |
| | | }break; |
| | | case 3: |
| | | { |
| | | if (pForm->m_nFormType == 0) strItem = "ROUND"; |
| | | else if (pForm->m_nFormType == 1) strItem = "LINE"; |
| | | }break; |
| | | case 4: strItem.Format("%d", pForm->m_vecForms.size()); break; |
| | | case 5: strItem.Format("%d", pForm->m_nDefectNumS); break; |
| | | case 6: strItem.Format("%d", pForm->m_nDefectNumM); break; |
| | | case 7: strItem.Format("%d", pForm->m_nDefectNumL); break; |
| | | |
| | | case 8: strItem.Format("%.3lf", pForm->m_dSizeAvg); break; |
| | | case 9: strItem.Format("%.3lf", pForm->m_dSizeStdDev); break; |
| | | |
| | | case 10: strItem.Format("%d", pForm->m_nDefectNum1Px); break; |
| | | case 11: strItem.Format("%d", pForm->m_nDefectNumWhite); break; |
| | | case 12: strItem.Format("%d", pForm->m_nDefectNumBlack); break; |
| | | case 13: strItem.Format("%d", pForm->m_nDefectNum1PxWhite); break; |
| | | |
| | | case 14: strItem.Format("%.0lf", 100.0* ((double)pForm->m_nDefectNum1Px /(double)pForm->m_vecForms.size())); break; |
| | | case 15: strItem.Format("%.0lf", 100.0* ((double)pForm->m_nDefectNumWhite / (double)pForm->m_vecForms.size())); break; |
| | | case 16: strItem.Format("%.0lf", 100.0* ((double)pForm->m_nDefectNumBlack / (double)pForm->m_vecForms.size())); break; |
| | | case 17: strItem.Format("%.0lf", 100.0* ((double)pForm->m_nDefectNum1PxWhite / (double)pForm->m_vecForms.size())); break; |
| | | |
| | | case 18: strItem.Format("%.3lf", pForm->m_dDiffStdDev); break; |
| | | case 19: strItem.Format("%.3lf", pForm->m_dDiffStdDevAbs); break; |
| | | } |
| | | |
| | | |
| | | |
| | | *pStrData = strItem; |
| | | } |
| | | } |
| | | |
| | | void CAlignDlg::updateDefectInfo() |
| | | { |
| | | if (m_pDefectFormation && m_pDefectDisplayOption) |
| | | { |
| | | int nFormType; |
| | | int nFormLabel; |
| | | m_vecSortForm.clear(); |
| | | for (int i = 0; i < m_pDefectFormation->m_vecFormation.size(); i++) |
| | | { |
| | | nFormType = m_pDefectFormation->m_vecFormation[i].m_nFormType; |
| | | nFormLabel = i; |
| | | |
| | | if (nFormLabel >= 0) |
| | | { |
| | | nFormType = m_pDefectFormation->m_vecFormation[i].m_nFormType; |
| | | } |
| | | |
| | | if (m_pDefectDisplayOption->m_bShowDefectNormal == FALSE) |
| | | { |
| | | if (nFormType < 0) continue;; |
| | | } |
| | | if (m_pDefectDisplayOption->m_bShowDefectGroupRound == FALSE) |
| | | { |
| | | if (nFormType == 0) continue;; |
| | | } |
| | | if (m_pDefectDisplayOption->m_bShowDefectGroupLine == FALSE) |
| | | { |
| | | if (nFormType == 1) continue;; |
| | | } |
| | | if (m_pDefectDisplayOption->m_nShowLabel >= 0) |
| | | { |
| | | if (nFormLabel != m_pDefectDisplayOption->m_nShowLabel) continue;; |
| | | } |
| | | |
| | | m_vecSortForm.push_back(&m_pDefectFormation->m_vecFormation[i]); |
| | | } |
| | | if(m_nLastSortCol>0) SortListDefect(m_nLastSortCol); |
| | | m_gridFormInfo.SetRowCount(m_vecSortForm.size()+1); |
| | | m_gridFormInfo.Invalidate(); |
| | | } |
| | | } |
| | | |
| | | |
| | | void CAlignDlg::OnSize(UINT nType, int cx, int cy) |
| | | { |
| | | CDialog::OnSize(nType, cx, cy); |
| | | |
| | | m_WndArrange.process(cx, cy); |
| | | } |
| | | |
| | | void CAlignDlg::OnPopupMenuFormList(UINT nID) |
| | | { |
| | | if (nID == FORMLIST_POPUP_FORMALL) |
| | | { |
| | | GetParent()->PostMessage(UM_FORMLIST_FORMSELECT, -1, 1); |
| | | } |
| | | else if(nID == FORMLIST_POPUP_FORMSELECT) |
| | | { |
| | | GetParent()->PostMessage(UM_FORMLIST_FORMSELECT, m_nSelectedFormIdRclick, 1); |
| | | } |
| | | |
| | | } |
| | | |
| | | void CAlignDlg::SortListDefect(int nCol) |
| | | { |
| | | if (nCol == 0) |
| | | return; |
| | | |
| | | if (m_pDefectFormation == NULL) return; |
| | | |
| | | m_bAsending = !m_bAsending; |
| | | |
| | | { |
| | | _akFormation *pForm; |
| | | std::vector< std::pair<CString, _akFormation*> > vecString; |
| | | std::vector< std::pair<double, _akFormation*> > vecValue; |
| | | CString strValue; |
| | | double dValue; |
| | | |
| | | for (int i = 0; i < m_vecSortForm.size(); i++) |
| | | { |
| | | pForm = m_vecSortForm[i]; |
| | | |
| | | switch (nCol) |
| | | { |
| | | case 1: dValue = pForm->m_nFormLabel; break; |
| | | case 2: dValue = pForm->m_nFormJudge; break; |
| | | case 3: dValue = pForm->m_nFormType; break; |
| | | case 4: dValue = pForm->m_vecForms.size(); break; |
| | | case 5: dValue = pForm->m_nDefectNumS; break; |
| | | case 6: dValue = pForm->m_nDefectNumM; break; |
| | | case 7: dValue = pForm->m_nDefectNumL; break; |
| | | case 8: dValue = pForm->m_dSizeAvg; break; |
| | | case 9: dValue = pForm->m_dSizeStdDev; break; |
| | | case 10: dValue = pForm->m_nDefectNum1Px; break; |
| | | case 11: dValue = pForm->m_nDefectNumWhite; break; |
| | | case 12: dValue = pForm->m_nDefectNumBlack; break; |
| | | case 13: dValue = pForm->m_nDefectNum1PxWhite; break; |
| | | |
| | | case 14: dValue = pForm->m_nDefectNum1Px; break; |
| | | case 15: dValue = pForm->m_nDefectNumWhite ; break; |
| | | case 16: dValue = pForm->m_nDefectNumBlack ; break; |
| | | case 17: dValue = pForm->m_nDefectNum1PxWhite ; break; |
| | | |
| | | case 18: dValue = pForm->m_dDiffStdDev; break; |
| | | case 19: dValue = pForm->m_dDiffStdDevAbs; break; |
| | | |
| | | } |
| | | |
| | | if(strValue.IsEmpty() == FALSE) vecString.push_back(std::make_pair(strValue, pForm)); |
| | | else vecValue.push_back(std::make_pair(dValue, pForm)); |
| | | } |
| | | |
| | | if (!vecString.empty()) |
| | | { |
| | | if (m_bAsending == TRUE) |
| | | std::sort(vecString.begin(), vecString.end(), std::greater< std::pair<CString, _akFormation*> >()); |
| | | else |
| | | std::sort(vecString.begin(), vecString.end(), std::less< std::pair<CString, _akFormation*> >()); |
| | | |
| | | m_vecSortForm.clear(); |
| | | std::vector< std::pair<CString, _akFormation*> >::iterator itVec; |
| | | for (itVec = vecString.begin(); itVec != vecString.end(); ++itVec) |
| | | { |
| | | m_vecSortForm.push_back(itVec->second); |
| | | } |
| | | } |
| | | else//if (!vecString.empty()) |
| | | { |
| | | if (m_bAsending == TRUE) |
| | | std::sort(vecValue.begin(), vecValue.end(), std::greater< std::pair<double, _akFormation*> >()); |
| | | else |
| | | std::sort(vecValue.begin(), vecValue.end(), std::less< std::pair<double, _akFormation*> >()); |
| | | |
| | | m_vecSortForm.clear(); |
| | | std::vector< std::pair<double, _akFormation*> >::iterator itVec; |
| | | for (itVec = vecValue.begin(); itVec != vecValue.end(); ++itVec) |
| | | { |
| | | m_vecSortForm.push_back(itVec->second); |
| | | } |
| | | } |
| | | } |
| | | |
| | | m_nLastSortCol = nCol; |
| | | } |
| | | |
| | | void CAlignDlg::DrawnoImage() |
| | | { |
| | | CPaintDC dc(this); |
| | | |
| | | m_AlignImage.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_AlignImage.Load(strFolderPath); |
| | | m_AlignImage2.Load(strFolderPath); |
| | | |
| | | HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), strFolderPath, |
| | | IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); |
| | | |
| | | InvalidateRect(m_picture_rect, FALSE); |
| | | InvalidateRect(m_picture_rect2, FALSE); |
| | | |
| | | dc.SetStretchBltMode(COLORONCOLOR); |
| | | m_AlignImage.Draw(dc, m_picture_rect); |
| | | m_AlignImage2.Draw(dc, m_picture_rect2); |
| | | } |