// D:\RCut_Project_130206\RecipeEditor\Dialog\DlgSettingNotch.cpp : ±¸Çö ÆÄÀÏÀÔ´Ï´Ù. // #include "stdafx.h" #include "ViewSettingNotch.h" #include "NewCellTypes\GridCellCombo.h" #include "NotchCut.h" const int NOTCH_GRID_COLUMN_COUNT = 5;//20140528 const char* NOTCH_GRID_COLUMN_ITEM[NOTCH_GRID_COLUMN_COUNT] = {"No","X Pos(um)","Y Pos(um)","X Pos(Pixel)","Y Pos(Pixel)"};//20140528 const int NOTCH_GRID_COLUMN_WIDTH[NOTCH_GRID_COLUMN_COUNT] = {30,62,62,62,62};//20140528 // CViewSettingNotch ´ëÈ­ »óÀÚÀÔ´Ï´Ù. IMPLEMENT_DYNAMIC(CViewSettingNotch, CDialog) CViewSettingNotch::CViewSettingNotch(CWnd* pParent /*=NULL*/) : CDialog(CViewSettingNotch::IDD, pParent) { m_pHardwareSetting = NULL; m_pGlassRecipe = NULL; m_DlgGlassRecipe.Reset(); m_pMainView = NULL; m_pMasterView = NULL; m_nCutListIdx = 0; m_index = 0; m_nNotchCadCenterX = 0;//20140528 m_nNotchCadCenterY = 0;//20140528 m_nAlignMark2CadCenter = 0;//20140528 } CViewSettingNotch::~CViewSettingNotch() { if(m_pMainView != NULL) { m_pMainView=NULL; } if(m_pMasterView != NULL) { m_pMasterView = NULL; } } void CViewSettingNotch::DoDataExchange(CDataExchange* pDX) { CNOTCH_PARM *pNotch = m_DlgGlassRecipe.m_InspectInfoParm.GetNotchParm(); DDX_Check(pDX,IDC_CHECK_USE_NOTCH_CHIP_INS,pNotch->GetNotchIns(m_index)->bChipIns); DDX_Check(pDX,IDC_CHECK_USE_NOTCH_SIZE_INS,pNotch->GetNotchIns(m_index)->bSizeIns); DDX_Text(pDX,IDC_EDIT_NOTCH_CHIP_DIFF,pNotch->GetNotchIns(m_index)->nChipDiff); DDX_Text(pDX,IDC_EDIT_NOTCH_SIZE_DIFF,pNotch->GetNotchIns(m_index)->nSizeDiff); DDX_Text(pDX,IDC_EDIT_NOTCH_DET_THRES,pNotch->GetNotchIns(m_index)->nDetThres); DDX_Text(pDX,IDC_EDIT_NOTCH_SIZE_THRES,pNotch->GetNotchIns(m_index)->nSizeThres); DDX_Text(pDX,IDC_EDIT_NOTCH_CHIP_THRES,pNotch->GetNotchIns(m_index)->nChipThres); DDX_Text(pDX,IDC_EDIT_NOTCH_BLANK2EDGERATIO,pNotch->GetNotchIns(m_index)->dBlank2EdgeRatio); DDX_Text(pDX,IDC_EDIT_NOTCH_VSTART,pNotch->GetNotchIns(m_index)->nVStart); DDX_Text(pDX,IDC_EDIT_NOTCH_VSIZE,pNotch->GetNotchIns(m_index)->nVSize); DDX_Text(pDX,IDC_EDIT_NOTCH_BASE_THICK,pNotch->GetNotchIns(m_index)->nJudgeBaseWidth); DDX_Text(pDX,IDC_EDIT_NOTCH_THICK_DIFF,pNotch->GetNotchIns(m_index)->nJudgeDiffWidth); DDX_Text(pDX,IDC_EDIT_NOTCH_MARK_XPOS_TOP,pNotch->GetNotchIns(m_index)->nMarkXPos[0]); DDX_Text(pDX,IDC_EDIT_NOTCH_MARK_XSIZE_TOP,pNotch->GetNotchIns(m_index)->nMarkXSize[0]); DDX_Text(pDX,IDC_EDIT_NOTCH_MARK_YPOS_TOP,pNotch->GetNotchIns(m_index)->nMarkYPos[0]); DDX_Text(pDX,IDC_EDIT_NOTCH_MARK_YSIZE_TOP,pNotch->GetNotchIns(m_index)->nMarkYSize[0]); DDX_Text(pDX,IDC_EDIT_NOTCH_MARK_XPOS_BOT,pNotch->GetNotchIns(m_index)->nMarkXPos[1]); DDX_Text(pDX,IDC_EDIT_NOTCH_MARK_XSIZE_BOT,pNotch->GetNotchIns(m_index)->nMarkXSize[1]); DDX_Text(pDX,IDC_EDIT_NOTCH_MARK_YPOS_BOT,pNotch->GetNotchIns(m_index)->nMarkYPos[1]); DDX_Text(pDX,IDC_EDIT_NOTCH_MARK_YSIZE_BOT,pNotch->GetNotchIns(m_index)->nMarkYSize[1]); DDX_Text(pDX,IDC_EDIT_NOTCH_ALIGN2GLASS,pNotch->GetNotchIns(m_index)->nAlign2GlassPos); DDX_Text(pDX,IDC_EDIT_NOTCH_SKIPSIZE,pNotch->GetNotchIns(m_index)->nSkipSize); DDX_Check(pDX,IDC_CHECK_USE_NOTCH_TOPSP_CHIP,pNotch->GetNotchIns(m_index)->bSpChipIns[0]); DDX_Check(pDX,IDC_CHECK_USE_NOTCH_BOTSP_CHIP,pNotch->GetNotchIns(m_index)->bSpChipIns[1]); DDX_Text(pDX,IDC_EDIT_NOTCH_TOPSP_INSSIZE,pNotch->GetNotchIns(m_index)->nSpChipSize[0]); DDX_Text(pDX,IDC_EDIT_NOTCH_BOTSP_INSSIZE,pNotch->GetNotchIns(m_index)->nSpChipSize[1]); DDX_Control(pDX,IDC_NOTCH_LIST,m_ListNotchPos);//20140528 DDX_Check(pDX,IDC_CHK_NOTCH_INS_POINT_JUDGE_DIMENSION_USE,pNotch->GetNotchIns(m_index)->bPointInsDimensionJudge);//20140528 DDX_Check(pDX,IDC_CHK_NOTCH_INS_POINT_JUDGE_CHAMFER_USE,pNotch->GetNotchIns(m_index)->bPointInsChamferJudge);//20140728 DDX_Text(pDX,IDC_EDIT_NOTCH_INS_POINT_AVE_COUNT,pNotch->GetNotchIns(m_index)->nPointInsAveCount);//20140528 CDialog::DoDataExchange(pDX); } BEGIN_EVENTSINK_MAP(CViewSettingNotch, CDialog) ON_EVENT(CViewSettingNotch, IDC_BTN_NOTCH_OK, DISPID_CLICK, CViewSettingNotch::ClickBtnNotchOk, VTS_NONE) ON_EVENT(CViewSettingNotch, IDC_BTN_NOTCH_CANCEL, DISPID_CLICK, CViewSettingNotch::ClickBtnNotchCancel, VTS_NONE) END_EVENTSINK_MAP() BEGIN_MESSAGE_MAP(CViewSettingNotch, CDialog) ON_WM_SHOWWINDOW() ON_WM_PAINT() ON_BN_CLICKED(IDC_BUT_NOTCH_LOAD, &CViewSettingNotch::OnBnClickedButNotchLoad) ON_BN_CLICKED(IDC_BUT_NOTCH_SELECTLINE, &CViewSettingNotch::OnBnClickedButNotchSelectline) ON_BN_CLICKED(IDC_BUT_NOTCH_FINALFIND, &CViewSettingNotch::OnBnClickedButNotchFinalfind) ON_BN_CLICKED(IDC_BUT_NOTCH_SAVE_MASTER, &CViewSettingNotch::OnBnClickedButNotchSaveMaster) ON_BN_CLICKED(IDC_CHECK_USE_NOTCH_CHIP_INS, &CViewSettingNotch::OnBnClickedCheckUseNotchChipIns) ON_BN_CLICKED(IDC_CHECK_USE_NOTCH_SIZE_INS, &CViewSettingNotch::OnBnClickedCheckUseNotchChipIns) ON_BN_CLICKED(IDC_CHECK_USE_NOTCH_TOPSP_CHIP, &CViewSettingNotch::OnBnClickedCheckUseNotchChipIns) ON_BN_CLICKED(IDC_CHECK_USE_NOTCH_BOTSP_CHIP, &CViewSettingNotch::OnBnClickedCheckUseNotchChipIns) ON_BN_CLICKED(IDC_BUT_NOTCH_MARK_LOAD, &CViewSettingNotch::OnBnClickedButNotchMarkLoad) ON_BN_CLICKED(IDC_BUT_NOTCH_MARK_SAVE_MASTER, &CViewSettingNotch::OnBnClickedButNotchMarkSaveMaster) ON_BN_CLICKED(IDC_BUT_NOTCH_POS_ADD, &CViewSettingNotch::OnBnClickedButNotchPosAdd)//20140528 ON_BN_CLICKED(IDC_BUT_NOTCH_POS_DEL, &CViewSettingNotch::OnBnClickedButNotchPosDel)//20140528 ON_BN_CLICKED(IDC_BUT_NOTCH_POS_MOD, &CViewSettingNotch::OnBnClickedButNotchPosMod)//20140528 ON_NOTIFY(NM_CLICK, IDC_NOTCH_LIST, OnListNotchPosClick) //20140528 ON_NOTIFY(GVN_ENDLABELEDIT, IDC_NOTCH_LIST,OnListNotchPosEdit)//20140528 ON_MESSAGE(MSG_SCANVIEW_POS_ADD, OnNotchInsPosAdd)//20140528 ON_MESSAGE(MSG_SCANVIEW_POS_MOD, OnNotchInsPosMod)//20140528 END_MESSAGE_MAP() // CViewSettingNotch ¸Þ½ÃÁö 󸮱âÀÔ´Ï´Ù. BOOL CViewSettingNotch::OnInitDialog() { CDialog::OnInitDialog(); InitImageControl(); SetControl(); Init_Grid();//20140528 return TRUE; // Æ÷Ä¿½º¸¦ ÄÁÆ®·Ñ¿¡ ¼³Á¤ÇÏÁö ¾ÊÀ¸¸é TRUE¸¦ ¹ÝȯÇÕ´Ï´Ù. } BOOL CViewSettingNotch::PreTranslateMessage(MSG* pMsg) { if( pMsg->message == WM_KEYDOWN ) { if(pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE ) { ::TranslateMessage(pMsg); ::DispatchMessage(pMsg); return TRUE; // DO NOT process further } } return CDialog::PreTranslateMessage(pMsg); } void CViewSettingNotch::OnShowWindow(BOOL bShow, UINT nStatus) { if(bShow == TRUE) { FillGrid(TRUE,m_index);//20140528 UpDateNotchData(TRUE); SetEnControl(); } else { UpdateDlgData(); GetParent()->PostMessage(UM_UPDATE_RECIPE,EM_NOTCH_RCP,NULL); } } void CViewSettingNotch::SetRecipe(CHardwareSettings *pHard,CGlassRecipe *pRecipe) { m_pHardwareSetting = pHard; m_pGlassRecipe = pRecipe; if(m_pGlassRecipe != NULL) { m_DlgGlassRecipe = *m_pGlassRecipe; } m_pMainView->ReleaseMemory();//20140528 m_pMainView->SetZoomMode(FALSE);//20140528 m_pMainView->InitGDI(2048,1024,FALSE);//20140528 m_pMainView->SetOrgImgSize(2048,1024);//20140528 m_pMainView->SetZoomMode(TRUE);//20140528 m_pMainView->SetDrawRect(FALSE);//20140528 m_pMainView->Invalidate(FALSE);//20140528 UpdateData(FALSE); FillGrid(TRUE,m_index);//20140528 UpDateNotchData(TRUE);//20140528 SetEnControl(); } void CViewSettingNotch::UpDateNotchData(BOOL bWrite) { CNOTCH_PARM *pNotch = m_DlgGlassRecipe.m_InspectInfoParm.GetNotchParm(); if(bWrite == FALSE) { } else { UpdateData(FALSE); } } void CViewSettingNotch::UpdateDlgData() { UpdateData(TRUE); FillGrid(FALSE,m_index);//20140528 UpDateNotchData(FALSE); if(m_pGlassRecipe != NULL) { m_pGlassRecipe->m_InspectInfoParm.m_NotchParm = m_DlgGlassRecipe.m_InspectInfoParm.m_NotchParm; } } void CViewSettingNotch::SetControl() { m_uiTitle_1.SetItemDefault(this,IDC_NOTCH_TITLE_1); m_uiTitle_1.m_strData.Format(_T("CAD Image Master Processing")); m_uiTitle_1.m_FontOffset = CPoint(4,2); m_uiTitle_2.SetItemDefault(this,IDC_NOTCH_TITLE_2); m_uiTitle_2.m_strData.Format(_T("Mark Image Master Processing")); m_uiTitle_2.m_FontOffset = CPoint(4,2); m_uiTitle_3.SetItemDefault(this,IDC_NOTCH_TITLE_3);//20140528 m_uiTitle_3.m_strData.Format(_T("Pos Setting"));//20140528 m_uiTitle_3.m_FontOffset = CPoint(4,2);//20140528 } void CViewSettingNotch::InitImageControl() { CRect crect; CSize sizeTotal; ((CWnd*)GetDlgItem(IDC_NOTCH_IMAGE))->GetWindowRect(&crect); ScreenToClient(&crect); m_pMainView = new CSlimScrollView; m_pMainView->Create(NULL, NULL, WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL, crect, this, IDC_NOTCH_IMAGE, NULL); sizeTotal = CSize(2048,1024); m_pMainView->SetScrollSizes(MM_TEXT, sizeTotal); m_pMainView->InitGDI(sizeTotal.cx,sizeTotal.cy,FALSE); m_pMainView->SetOrgImgSize(sizeTotal.cx,sizeTotal.cy); m_pMainView->SetHWnd(this); m_pMainView->SetSendMessage(FALSE); m_pMainView->SetDrawRect(FALSE); m_pMainView->SetZoomMode(TRUE); ((CWnd*)GetDlgItem(IDC_NOTCH_MASTER_IMAGE_VIEW))->GetWindowRect(&crect); ScreenToClient(&crect); m_pMasterView = new CSlimScrollView; m_pMasterView->Create(NULL, NULL, WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL, crect, this, IDC_NOTCH_MASTER_IMAGE_VIEW, NULL); sizeTotal = CSize(200,200); m_pMasterView->SetScrollSizes(MM_TEXT, sizeTotal); m_pMasterView->InitGDI(sizeTotal.cx,sizeTotal.cy,FALSE); m_pMasterView->SetOrgImgSize(sizeTotal.cx,sizeTotal.cy); m_pMasterView->SetHWnd(this); m_pMasterView->SetSendMessage(FALSE); m_pMasterView->SetDrawRect(FALSE); m_pMasterView->SetZoomMode(TRUE); } // CViewSettingNotch ¸Þ½ÃÁö 󸮱âÀÔ´Ï´Ù. void CViewSettingNotch::OnBnClickedButNotchLoad() { CString strFileName,strpath; strpath.Format(_T("D:\\Inspection\\Image\\scanimage\\*.bmp")); // file select CFileDialog filedlg( TRUE, _T("*.bmp"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Image file (*.bmp)|*.bmp|"), NULL ); if(IDCANCEL == filedlg.DoModal()) return; strFileName = filedlg.GetPathName(); if(m_ImageMain.ReadFromFile(strFileName) == FALSE) { AfxMessageBox(_T("Image Load Fail!")); return; } ShowMainImage(); } void CViewSettingNotch::ShowMainImage() { if(m_ImageMain.IsValidBuffer() == FALSE || m_pMainView == NULL) { m_pMainView->ReleaseMemory(); m_pMainView->SetZoomMode(FALSE); m_pMainView->InitGDI(2048,1024,FALSE); m_pMainView->SetOrgImgSize(2048,1024); m_pMainView->SetZoomMode(TRUE); m_pMainView->SetDrawRect(FALSE); m_pMainView->Invalidate(FALSE); return; } m_pMainView->ReleaseMemory(); m_pMainView->SetZoomMode(FALSE); m_pMainView->InitGDI(m_ImageMain.GetDataWidth(),m_ImageMain.GetHeight(),FALSE); m_pMainView->SetOrgImgSize(m_ImageMain.GetDataWidth(),m_ImageMain.GetHeight()); m_pMainView->SetDrawRect(FALSE); m_pMainView->SetZoomMode(TRUE); BYTE* pTgtBuf = m_pMainView->GetBuffer(); if(pTgtBuf == NULL) { return; } CopyMemory(pTgtBuf,m_ImageMain.GetDataAddress(0,0),m_ImageMain.GetDataWidth()*m_ImageMain.GetHeight()); m_pMainView->SetScrollSizes(MM_TEXT, CSize(m_ImageMain.GetDataWidth(),m_ImageMain.GetHeight())); m_pMainView->Invalidate(FALSE); } void CViewSettingNotch::OnPaint() { CPaintDC dc(this); // device context for painting CGeneralDraw pDraw; pDraw.DrawPitureControl(m_uiTitle_1); pDraw.DrawPitureControl(m_uiTitle_2); pDraw.DrawPitureControl(m_uiTitle_3);//20140528 } void CViewSettingNotch::OnBnClickedButNotchFindline() { if(m_ImageMain.IsValidBuffer() == FALSE || m_pMainView == NULL) return; BYTE* pTgtBuf = m_pMainView->GetBuffer(); if(pTgtBuf == NULL) { return; } CopyMemory(pTgtBuf,m_ImageMain.GetDataAddress(0,0),m_ImageMain.GetWidth()*m_ImageMain.GetHeight()); LPBYTE lpImg = m_pMainView->GetBuffer(); CSize szImg = m_pMainView->GetOrgImgSize(); CRect rect(0,0,szImg.cx,szImg.cy); if(lpImg == NULL) return; CSPLINE_PARM *pSpline = &m_DlgGlassRecipe.m_InspectInfoParm.m_SplineParm; UpdateData(TRUE); COwnerBuffer pTgt(szImg.cx,szImg.cy); CEdgeProc EdgeProc; // ZeroMemory(pTgt.GetDataAddress(0,0),pTgt.GetDataSize()); // glassFind.ThresholdProcessing(lpImg,szImg,pSpline->m_nLineThres,0); // // CCCLabeling labeling; // CSISBuffer lpOrg(lpImg,szImg.cx,szImg.cy); // labeling.DoPerimeterLine(lpOrg,pTgt); // CopyMemory(lpImg,pTgt.GetDataAddress(0,0),pTgt.GetDataSize()); EdgeProc.CannyEdgeProcessing(lpImg,rect,GM_Sobel,80,pTgt); CopyMemory(lpImg,pTgt.GetDataAddress(0,0),pTgt.GetDataSize()); CString strFile = _T("D:\\Inspection\\Image\\CannyEdge.bmp"); CBufferAttach attach(strFile); CSISBuffer mosis(pTgt.GetDataAddress(0,0),szImg.cx,szImg.cy); attach.AttachToFile(mosis); m_pMainView->SetDrawRect(FALSE); m_pMainView->Invalidate(FALSE); } void CViewSettingNotch::OnBnClickedButNotchSelectline() { m_pMainView->SetDrawRect(TRUE); } void CViewSettingNotch::OnBnClickedButNotchFinalfind() { LPBYTE lpImg = m_pMainView->GetBuffer(); CSize szImg = m_pMainView->GetOrgImgSize(); if(lpImg == NULL) return; CRect rectSel = m_pMainView->GetDrawRect(); if(rectSel.IsRectEmpty() == TRUE) { AfxMessageBox(_T("No Selection Region.!")); return; } CSISBuffer lpOrg(lpImg,szImg.cx,szImg.cy); COwnerBuffer lpBuffer(szImg.cx,szImg.cy); CRect rect(0,0,szImg.cx,szImg.cy); lpBuffer.CopyBtoA(lpBuffer,0,0,lpOrg,rect); int nMaxIdx; CSplineInspect pLabeling(&lpBuffer); if(pLabeling.LabelingProcess() == TRUE) { // m_pLabeling.MakeContourMapImage("D:\\Inspection\\Image\\ContourMap"); pLabeling.LabelingCounting(); pLabeling.LabelFiltering(100); nMaxIdx = pLabeling.GetRectInLabelMaxIndex(rectSel); if(nMaxIdx > 0) { if(pLabeling.GetLabelPosition(nMaxIdx) == TRUE) { std::multimap *pPoint = pLabeling.GetSplinePos(); if(pPoint != NULL) { m_pMainView->SetSplinePosition(pPoint,pLabeling.GetSplineOffset()); //CPoint point; //std::multimap::iterator it; //COwnerBuffer lpImg(szImg.cx, szImg.cy); //ZeroMemory(lpImg.GetDataAddress(0, 0), lpImg.GetDataSize()); //for (it = pPoint->begin(); it != pPoint->end(); it++) //{ // point = it->second.origin; // point.x = (int)((double)point.x); // point.y = (int)((double)point.y); // lpImg.SetPixel(point.x, point.y, 255); //} //CString str = "D:\\Inspection\\Image\\NoChiCut\\Master.bmp"; //CBufferAttach attach(str); //attach.AttachToFile(lpImg); } } } } m_pMainView->Invalidate(FALSE); } void CViewSettingNotch::OnBnClickedButNotchSaveMaster() { CString strFile; std::multimap *pPoint; CPoint pointOffset; pPoint = m_pMainView->GetSplinePos(); pointOffset = m_pMainView->GetSplineOffset(); CString str; str.Format(_T("Notch[%d] Master Data Save?"),m_index); if(pPoint != NULL && (int)pPoint->size() > 0) { if(IDNO == AfxMessageBox(str, MB_YESNO | MB_ICONQUESTION)) return; } else { AfxMessageBox(_T("No Data.")); } CreateDirectory(PATH_NOTCH_IMAGE,NULL); CNotchCut notchCut; strFile.Format(_T("%s\\%s_[%d].notch"),PATH_NOTCH_IMAGE,m_pGlassRecipe->GetRecipeName(),m_index); CString strCut; strCut.Format(_T("[%d]_Notch"),m_index); if(notchCut.WriteModelData(strFile,m_pGlassRecipe->GetRecipeName(),strCut,pPoint) == TRUE) { CString strMsg; strMsg.Format(_T("%s Saved."),strFile); strFile.Format(_T("%s\\%s_[%d]_notch.bmp"),PATH_NOTCH_IMAGE,m_pGlassRecipe->GetRecipeName(),m_index); CBufferAttach attach(strFile); attach.AttachToFile(m_ImageMain); AfxMessageBox(strMsg); } else { AfxMessageBox(_T("No Data.")); } // CCCLabeling pLabeling; // strFile.Format("C:\\EdgeInspector_Led\\NoChi\\%s.nochi",m_pGlassRecipe->GetRecipeName()); // if(pLabeling.WriteModelData(strFile,m_pGlassRecipe->GetRecipeName(),"RCut",pPoint,pointOffset) == TRUE) // { // CString strMsg; // // strMsg.Format("%s¿¡ ÀúÀå µÇ¾ú½À´Ï´Ù.",strFile); // // strFile.Format("C:\\EdgeInspector_Led\\NoChi\\%s_nochi.bmp",m_pGlassRecipe->GetRecipeName()); // CBufferAttach attach(strFile); // attach.AttachToFile(m_ImageMain); // // AfxMessageBox(strMsg); // } // else // { // AfxMessageBox("Data°¡ ¾ø½À´Ï´Ù."); // } LoadNotchCadImage();//20140528 } void CViewSettingNotch::SetEnControl() { CNOTCH_PARM *pNotch = m_DlgGlassRecipe.m_InspectInfoParm.GetNotchParm(); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_CHIP_DIFF))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_CHECK_USE_NOTCH_CHIP_INS))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_CHIP_DIFF))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_SIZE_DIFF))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_DET_THRES))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_SIZE_THRES))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_CHIP_THRES))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_BLANK2EDGERATIO))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_VSTART))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_VSIZE))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_BASE_THICK))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_THICK_DIFF))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_BUT_NOTCH_LOAD))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_BUT_NOTCH_SELECTLINE))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_BUT_NOTCH_FINALFIND))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_BUT_NOTCH_SAVE_MASTER))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_BUT_NOTCH_MARK_LOAD))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_BUT_NOTCH_MARK_SAVE_MASTER))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_MARK_XPOS_TOP))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_MARK_XSIZE_TOP))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_MARK_YPOS_TOP))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_MARK_YSIZE_TOP))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_MARK_XPOS_BOT))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_MARK_XSIZE_BOT))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_MARK_YPOS_BOT))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_MARK_YSIZE_BOT))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_ALIGN2GLASS))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_SKIPSIZE))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_CHECK_USE_NOTCH_TOPSP_CHIP))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_TOPSP_INSSIZE))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_CHECK_USE_NOTCH_BOTSP_CHIP))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_BOTSP_INSSIZE))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns); if(pNotch->GetNotchIns(m_index)->bSizeIns) { ((CWnd*)GetDlgItem(IDC_NOTCH_MASTER_IMAGE_VIEW))->EnableWindow(SW_SHOW); m_pMasterView->ShowWindow(SW_SHOW); ((CWnd*)GetDlgItem(IDC_NOTCH_IMAGE))->EnableWindow(SW_SHOW);//20140528 m_pMainView->ShowWindow(SW_SHOW);//20140528 } else { ((CWnd*)GetDlgItem(IDC_NOTCH_MASTER_IMAGE_VIEW))->EnableWindow(SW_HIDE); m_pMasterView->ShowWindow(SW_HIDE); ((CWnd*)GetDlgItem(IDC_NOTCH_IMAGE))->EnableWindow(SW_HIDE);//20140528 m_pMainView->ShowWindow(SW_HIDE);//20140528 } ((CWnd*)GetDlgItem(IDC_BUT_NOTCH_POS_ADD))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns);//20140528 ((CWnd*)GetDlgItem(IDC_BUT_NOTCH_POS_DEL))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns);//20140528 ((CWnd*)GetDlgItem(IDC_BUT_NOTCH_POS_MOD))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns);//20140528 ((CWnd*)GetDlgItem(IDC_NOTCH_LIST))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns);//20140528 ((CWnd*)GetDlgItem(IDC_CHK_NOTCH_INS_POINT_JUDGE_DIMENSION_USE))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns);//20140528 ((CWnd*)GetDlgItem(IDC_CHK_NOTCH_INS_POINT_JUDGE_CHAMFER_USE))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns);//20140528 ((CWnd*)GetDlgItem(IDC_EDIT_NOTCH_INS_POINT_AVE_COUNT))->EnableWindow(pNotch->GetNotchIns(m_index)->bSizeIns);//20140528 LoadMasterImage(); LoadNotchCadImage();//20140528 } void CViewSettingNotch::OnBnClickedCheckUseNotchChipIns() { UpdateData(TRUE); SetEnControl(); } void CViewSettingNotch::OnBnClickedButNotchMarkLoad() { // TODO: ¿©±â¿¡ ÄÁÆ®·Ñ ¾Ë¸² 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù. CString strFileName; // file select CFileDialog filedlg( TRUE, _T("*.bmp"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Image file (*.bmp)|*.bmp|"), NULL ); if(IDCANCEL == filedlg.DoModal()) return; strFileName = filedlg.GetPathName(); if(m_ImageMain.ReadFromFile(strFileName) == FALSE) { AfxMessageBox(_T("Image Load Fail!")); return; } ShowMainImage(); m_pMainView->SetDrawRect(TRUE); } #define align_4byte(in) ((in + 3)/4)*4 void CViewSettingNotch::OnBnClickedButNotchMarkSaveMaster() { // TODO: ¿©±â¿¡ ÄÁÆ®·Ñ ¾Ë¸² 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù. if(m_pMainView == NULL) return; CString strFile,strRecipe,strMsg,str; //CGLASS_INFO_PARM *pGlass = &m_DlgGlassRecipe.m_GlassParm; switch(m_index) { case DIMENSION_A: strMsg.Format(_T("A Pos")); break; case DIMENSION_B: strMsg.Format(_T("B Pos")); break; case DIMENSION_C: strMsg.Format(_T("C Pos")); break; case DIMENSION_D: strMsg.Format(_T("D Pos")); break; } str.Format(_T("%s Mark Master Image Save?"),strMsg); if (IDNO == AfxMessageBox(str, MB_YESNO | MB_ICONQUESTION)) return; BYTE* pImg = m_pMainView->GetBuffer(); CSize szImg = m_pMainView->GetOrgImgSize(); if(pImg == NULL || szImg.cx <= 0 || szImg.cy <= 0) { AfxMessageBox(_T("No Image.")); return; } CreateDirectory(PATH_NOTCH_IMAGE,NULL); CRect rect = m_pMainView->GetDrawRect(); if(rect.IsRectEmpty() == TRUE) { AfxMessageBox(_T("No Save Region")); return; } int nWidth = align_4byte(rect.Width()); rect.right = rect.left+nWidth; if(rect.right >= szImg.cx) rect.right = szImg.cx-4; strRecipe = m_DlgGlassRecipe.GetRecipeName(); strFile.Format(_T("%s\\%s_Notch_Align_Mark_[%d].bmp"),PATH_NOTCH_IMAGE,strRecipe,m_index); CSISBuffer buffer(pImg,szImg.cx,szImg.cy); int nCropWidth = rect.Width(); int nCropHeight = rect.Height(); if(nCropWidth< 10 || nCropHeight<10) { AfxMessageBox(_T("Reselect Image Region")); return; } else ; nCropWidth = (nCropWidth/2)*2; // Width¸¦ °­Á¦·Î ¦¼öÈ­ nCropHeight = (nCropHeight/2)*2; // Height¸¦ °­Á¦·Î ¦¼öÈ­ rect.right = rect.left + nCropWidth; rect.bottom = rect.top + nCropHeight; int nCropPitch = (rect.Width()+0x3)&~0x3; double dCenterX; double dCenterY; int nYStart = rect.top; int nXStart = rect.left; LPBYTE lpStart = pImg + (nYStart % szImg.cy) * szImg.cx + nXStart; LPBYTE pCopyBuf = new BYTE[rect.Width()*rect.Height()]; for (int i = 0; i < rect.Height(); i++) { memcpy(pCopyBuf + i * rect.Width(), lpStart + i * szImg.cx, rect.Width()); } CSISBuffer bufferTest(pCopyBuf,rect.Width(), rect.Height()); if(TRUE == GetSymmetricPoint(bufferTest.GetDataAddress(), bufferTest.GetWidth(), bufferTest.GetHeight(), nCropPitch, &dCenterX, &dCenterY)) { double dOffsetX = dCenterX-nCropWidth/2.; double dOffsetY = dCenterY-nCropHeight/2.; if(dOffsetX<0) dOffsetX += -0.5; else dOffsetX += 0.5; if(dOffsetY<0) dOffsetY += -0.5; else dOffsetY += 0.5; int nOffsetX = (int)(dOffsetX); int nOffsetY = (int)(dOffsetY); rect.OffsetRect(nOffsetX, nOffsetY); } else { AfxMessageBox(_T("Reselect Image Region")); return; } CRect rectCrop = CRect(rect.CenterPoint().x, rect.CenterPoint().y, rect.CenterPoint().x, rect.CenterPoint().y); rectCrop.InflateRect(nCropWidth/2, nCropHeight/2); CCropBuffer cropBufferCenter(buffer,rectCrop); CBufferAttach attachCenter(strFile); attachCenter.AttachToFile(cropBufferCenter); LoadMasterImage(); } void CViewSettingNotch::LoadMasterImage() { CString strFile; CString strRecipe = m_DlgGlassRecipe.GetRecipeName(); m_ImageMaster[m_index].ReleaseImage(); strFile.Format(_T("%s\\%s_Notch_Align_Mark_[%d].bmp"),PATH_NOTCH_IMAGE,strRecipe,m_index); m_ImageMaster[m_index].ReadFromFile(strFile); ShowMasterImage(); } void CViewSettingNotch::ShowMasterImage() { if(m_ImageMaster[m_index].IsValidBuffer() == FALSE || m_pMasterView == NULL) { m_pMasterView->ReleaseMemory(); m_pMasterView->SetZoomMode(FALSE); m_pMasterView->InitGDI(200,200,FALSE); m_pMasterView->SetOrgImgSize(200,200); m_pMasterView->SetZoomMode(TRUE); m_pMasterView->SetMarkPos(CPoint(0,0),CPoint(0,0)); m_pMasterView->Invalidate(FALSE); return; } m_pMasterView->ReleaseMemory(); m_pMasterView->SetZoomMode(FALSE); m_pMasterView->InitGDI(m_ImageMaster[m_index].GetDataWidth(),m_ImageMaster[m_index].GetHeight(),FALSE); m_pMasterView->SetOrgImgSize(m_ImageMaster[m_index].GetDataWidth(),m_ImageMaster[m_index].GetHeight()); m_pMasterView->SetDrawRect(TRUE); m_pMasterView->SetZoomMode(TRUE); BYTE* pTgtBuf = m_pMasterView->GetBuffer(); if(pTgtBuf == NULL) { return; } CopyMemory(pTgtBuf,m_ImageMaster[m_index].GetDataAddress(0,0),m_ImageMaster[m_index].GetWidth()*m_ImageMaster[m_index].GetHeight()); m_pMasterView->SetScrollSizes(MM_TEXT, CSize(m_ImageMaster[m_index].GetDataWidth(),m_ImageMaster[m_index].GetHeight())); m_pMasterView->SetMarkPos(CPoint(m_ImageMaster[m_index].GetDataWidth()/2,m_ImageMaster[m_index].GetHeight()/2),CPoint(0,0)); m_pMasterView->Invalidate(FALSE); } void CViewSettingNotch::Init_Grid()//20140528 { if(m_ListNotchPos.GetSafeHwnd() == NULL) return; m_ListNotchPos.GetDefaultCell(FALSE, FALSE)->SetBackClr(RGB(0xFF, 0xFF, 0xE0)); m_ListNotchPos.SetGridLines(GVL_BOTH); m_ListNotchPos.SetColumnCount(NOTCH_GRID_COLUMN_COUNT); m_ListNotchPos.SetRowCount(5); m_ListNotchPos.SetFixedRowCount(1); m_ListNotchPos.SetFixedColumnCount(1); m_ListNotchPos.ExpandColumnsToFit(); CFont *pFont = m_ListNotchPos.GetFont(); if (!pFont) return; LOGFONT lf; pFont->GetLogFont(&lf); lf.lfItalic = 0; lf.lfHeight = 14; lf.lfWeight = FW_BOLD; _tcscpy(lf.lfFaceName, _T("Arial")); m_ListNotchPos.GetDefaultCell(TRUE, FALSE)->SetFont(&lf); m_ListNotchPos.GetDefaultCell(FALSE, TRUE)->SetFont(&lf); m_ListNotchPos.GetDefaultCell(TRUE, TRUE)->SetFont(&lf); m_ListNotchPos.SetEditable(TRUE); m_ListNotchPos.EnableSelection(TRUE); Init_GridHeader(); } void CViewSettingNotch::Init_GridHeader() { CString str; GV_ITEM Item; int nCol = 0; int iLoop; Item.mask = GVIF_TEXT; Item.row = 0; for(iLoop=0;iLoop::iterator it; CString str; int nCol = 0, nRow; int iLoop; CPoint stPos; int nStageNo = g_pBase->m_nStageNo; if(nStageNo < 0 || nStageNo > 1) nStageNo = 0; double dScanRes = m_pHardwareSetting->GetCameraSettings(0,0)->m_dScanResolution[nStageNo]; double dConvRes = m_pHardwareSetting->GetCameraSettings(0,0)->m_dConvResolution[nStageNo]; if(bWrite == TRUE) { iLoop = 1; m_ListNotchPos.SetRowCount((int)pParm->m_vecNotchPosition[nCurIdx].size()+1); for(it=pParm->m_vecNotchPosition[nCurIdx].begin();it!=pParm->m_vecNotchPosition[nCurIdx].end();it++,iLoop++) { stPos = *it; nCol = 0; nRow = iLoop; str.Format(_T("%d"),nRow); m_ListNotchPos.SetItemText(nRow,nCol,str); nCol++; str.Format(_T("%d"),(int)(stPos.x*dConvRes)); m_ListNotchPos.SetItemText(nRow,nCol,str); nCol++; str.Format(_T("%d"),(int)(stPos.y*dScanRes)+m_nAlignMark2CadCenter); m_ListNotchPos.SetItemText(nRow,nCol,str); nCol++; str.Format(_T("%d"),stPos.x); m_ListNotchPos.SetItemText(nRow,nCol,str); nCol++; str.Format(_T("%d"),stPos.y); m_ListNotchPos.SetItemText(nRow,nCol,str); } m_ListNotchPos.Invalidate(); DrawNotchInsPos(); } else { pParm->m_vecNotchPosition[nCurIdx].clear(); int nRowCnt = m_ListNotchPos.GetRowCount(); for(iLoop=1;iLoopm_vecNotchPosition[nCurIdx].push_back(stPos); } } } void CViewSettingNotch::OnBnClickedButNotchPosAdd() { int nRowCnt = m_ListNotchPos.GetRowCount(); if(nRowCnt >= MAX_NOTCH_INS_POS_COUNT+1) { AfxMessageBox(_T("Up to 100 can be registered.")); return; } CPoint stPos(0,0); CNOTCH_PARM *pParm = m_DlgGlassRecipe.m_InspectInfoParm.GetNotchParm(); pParm->m_vecNotchPosition[m_index].push_back(stPos); FillGrid(TRUE,m_index); } void CViewSettingNotch::OnBnClickedButNotchPosDel() { if(m_nCutListIdx <= 0 || m_nCutListIdx >= m_ListNotchPos.GetRowCount()) return; if (IDNO == AfxMessageBox(_T("Delete Data?"), MB_YESNO | MB_ICONQUESTION)) return; CPoint stPos; CString str; int nCol = 3; str = m_ListNotchPos.GetItemText(m_nCutListIdx,nCol); stPos.x = _ttoi(str); nCol++; str = m_ListNotchPos.GetItemText(m_nCutListIdx,nCol); stPos.y = _ttoi(str); nCol++; CNOTCH_PARM *pParm = m_DlgGlassRecipe.m_InspectInfoParm.GetNotchParm(); std::vector::iterator it; for(it=pParm->m_vecNotchPosition[m_index].begin();it!=pParm->m_vecNotchPosition[m_index].end();it++) { if(it->x == stPos.x && it->y == stPos.y) { pParm->m_vecNotchPosition[m_index].erase(it); break; } } FillGrid(TRUE,m_index); } void CViewSettingNotch::OnBnClickedButNotchPosMod() { m_pMainView->SetNotchInsPosMod(TRUE); } void CViewSettingNotch::OnListNotchPosClick( NMHDR *pNotifyStruct, LRESULT* pResult ) { NM_GRIDVIEW* pItem = (NM_GRIDVIEW*) pNotifyStruct; if(pItem->iRow <= 0 || pItem->iRow > (int)m_ListNotchPos.GetRowCount()) return; m_nCutListIdx = pItem->iRow; m_pMainView->SetNotchInsListIdx(m_nCutListIdx); Invalidate(FALSE); } void CViewSettingNotch::LoadNotchCadImage() { m_nNotchCadCenterX = m_nNotchCadCenterY = 0; m_nAlignMark2CadCenter = 0; CString strFile; CString strRecipe = m_DlgGlassRecipe.GetRecipeName(); m_ImageMain.ReleaseImage(); strFile.Format(_T("%s\\%s_[%d]_notch.bmp"),PATH_NOTCH_IMAGE,strRecipe,m_index); if(m_ImageMain.ReadFromFile(strFile) == FALSE) return; //strFile = "D:\\Inspection\\Image\\test_cad.bmp"; //CBufferAttach attach(strFile); //attach.AttachToFile(m_ImageMain); CNotchCut notchCut; CNOTCH_PARM *pNotch = m_DlgGlassRecipe.m_InspectInfoParm.GetNotchParm(); int nStageNo = g_pBase->m_nStageNo; if(nStageNo < 0 || nStageNo > 1) nStageNo = 0; double dScanRes = m_pHardwareSetting->GetCameraSettings(0,0)->m_dScanResolution[nStageNo]; double dConvRes = m_pHardwareSetting->GetCameraSettings(0,0)->m_dConvResolution[nStageNo]; notchCut.FindCenterPos(m_ImageMain,m_nNotchCadCenterX,m_nNotchCadCenterY); m_nAlignMark2CadCenter = (int)(pNotch->GetNotchIns(m_index)->nVStart - m_nNotchCadCenterY*dScanRes); ShowMainImage(); DrawNotchInsPos(); } void CViewSettingNotch::DrawNotchInsPos() { int iLoop; int nCol; int nRow; CString str; int nRowCnt = m_ListNotchPos.GetRowCount(); m_NotchInsPoint.clear(); CPoint stPos; for(iLoop=1;iLoopSetNotchInsPosition(&m_NotchInsPoint); m_pMainView->SetDrawNotchInsPos(TRUE); m_pMainView->SetNotchCadCenterPos(m_nNotchCadCenterX,m_nNotchCadCenterY); } LRESULT CViewSettingNotch::OnNotchInsPosAdd( WPARAM wParam, LPARAM lParam ) { int nPosX, nPosY; nPosX = (int)wParam; nPosY = (int)lParam; int nStageNo = g_pBase->m_nStageNo; if(nStageNo < 0 || nStageNo > 1) nStageNo = 0; double dScanRes = m_pHardwareSetting->GetCameraSettings(0,0)->m_dScanResolution[nStageNo]; double dConvRes = m_pHardwareSetting->GetCameraSettings(0,0)->m_dConvResolution[nStageNo]; int nCol = 0; int nRowCnt = m_ListNotchPos.GetRowCount(); if(nRowCnt >= MAX_NOTCH_INS_POS_COUNT+1) { AfxMessageBox(_T("Up to 100 can be registered.")); return -1; } CString str; nPosX = FindNotchInsXPos(nPosY); m_ListNotchPos.SetRowCount(nRowCnt+1); str.Format(_T("%d"),nRowCnt); m_ListNotchPos.SetItemText(nRowCnt,nCol,str); nCol++; str.Format(_T("%d"),(int)(nPosX*dConvRes)); m_ListNotchPos.SetItemText(nRowCnt,nCol,str); nCol++; str.Format(_T("%d"),(int)(nPosY*dScanRes + m_nAlignMark2CadCenter)); m_ListNotchPos.SetItemText(nRowCnt,nCol,str); nCol++; str.Format(_T("%d"),nPosX); m_ListNotchPos.SetItemText(nRowCnt,nCol,str); nCol++; str.Format(_T("%d"),nPosY); m_ListNotchPos.SetItemText(nRowCnt,nCol,str); m_ListNotchPos.Invalidate(); DrawNotchInsPos(); return 0; } LRESULT CViewSettingNotch::OnNotchInsPosMod( WPARAM wParam, LPARAM lParam ) { int nPosX, nPosY; nPosX = (int)wParam; nPosY = (int)lParam; int nStageNo = g_pBase->m_nStageNo; if(nStageNo < 0 || nStageNo > 1) nStageNo = 0; double dScanRes = m_pHardwareSetting->GetCameraSettings(0,0)->m_dScanResolution[nStageNo]; double dConvRes = m_pHardwareSetting->GetCameraSettings(0,0)->m_dConvResolution[nStageNo]; int nCol = 1; CString str; nPosX = FindNotchInsXPos(nPosY); str.Format(_T("%d"),(int)(nPosX*dConvRes)); m_ListNotchPos.SetItemText(m_nCutListIdx,nCol,str); nCol++; str.Format(_T("%d"),(int)(nPosY*dScanRes + m_nAlignMark2CadCenter)); m_ListNotchPos.SetItemText(m_nCutListIdx,nCol,str); nCol++; str.Format(_T("%d"),nPosX); m_ListNotchPos.SetItemText(m_nCutListIdx,nCol,str); nCol++; str.Format(_T("%d"),nPosY); m_ListNotchPos.SetItemText(m_nCutListIdx,nCol,str); m_ListNotchPos.Invalidate(); DrawNotchInsPos(); return 0; } void CViewSettingNotch::OnListNotchPosEdit( NMHDR *pNotifyStruct, LRESULT* pResult ) { NM_GRIDVIEW* pItem = (NM_GRIDVIEW*) pNotifyStruct; if(pItem->iRow <= 0 || pItem->iRow > (int)m_ListNotchPos.GetRowCount()) return; CString str; int nStageNo = g_pBase->m_nStageNo; if(nStageNo < 0 || nStageNo > 1) nStageNo = 0; double dScanRes = m_pHardwareSetting->GetCameraSettings(0,0)->m_dScanResolution[nStageNo]; double dConvRes = m_pHardwareSetting->GetCameraSettings(0,0)->m_dConvResolution[nStageNo]; int nPosX; int nPosY; int nCol; if(pItem->iColumn == 2 || pItem->iColumn == 1) { str = m_ListNotchPos.GetItemText(pItem->iRow,2); nPosY = _ttoi(str); nPosY = (int)((nPosY-m_nAlignMark2CadCenter)/dScanRes); nCol = 1; nPosX = FindNotchInsXPos(nPosY); str.Format(_T("%d"),(int)(nPosX*dConvRes)); m_ListNotchPos.SetItemText(pItem->iRow,nCol,str); nCol++; nCol++; str.Format(_T("%d"),(int)nPosX); m_ListNotchPos.SetItemText(pItem->iRow,nCol,str); nCol++; str.Format(_T("%d"),(int)nPosY); m_ListNotchPos.SetItemText(pItem->iRow,nCol,str); } else if(pItem->iColumn == 4 || pItem->iColumn == 3) { str = m_ListNotchPos.GetItemText(pItem->iRow,4); nPosY = _ttoi(str); nCol = 1; nPosX = FindNotchInsXPos(nPosY); str.Format(_T("%d"),(int)(nPosX*dConvRes)); m_ListNotchPos.SetItemText(pItem->iRow,nCol,str); nCol++; str.Format(_T("%d"),(int)(nPosY*dScanRes) + m_nAlignMark2CadCenter); m_ListNotchPos.SetItemText(pItem->iRow,nCol,str); nCol++; str.Format(_T("%d"),(int)nPosX); m_ListNotchPos.SetItemText(pItem->iRow,nCol,str); nCol++; } m_ListNotchPos.Invalidate(); DrawNotchInsPos(); } int CViewSettingNotch::FindNotchInsXPos(int nPosY) { int iLoop; int nValue; int nPosX = 0; for (iLoop = 0; iLoopnHighMargin) // { // nMinimumMargin = nHighMargin; // } // else // { // nMinimumMargin = nLowMargin; // } // memset(nLow, 0x00, 1000*sizeof(int)); // memset(nHigh, 0x00, 1000*sizeof(int)); for(iIndex=0 ; iIndex dMax) { dMax = *(pData+iIndex); iMaxAddress = iIndex; } } return iMaxAddress; } double CViewSettingNotch::ParabolicInterpolation( double dPrevious, double dCenter,double dNext,int nCenterX )//20140611 { double dE; double dNumerator; double dDenominator; dNumerator = dPrevious - dNext; dDenominator = dPrevious + dNext - 2*dCenter; if(0 == dDenominator) dDenominator = 0.0000001; dE = 0.5*dNumerator/dDenominator; return (double)(nCenterX + dE); } void CViewSettingNotch::ClickBtnNotchOk() { UpdateDlgData(); m_pParent->PostMessage(UM_NOTCH_APPLY_RECIPE,NULL,NULL); CDialog::OnOK(); } void CViewSettingNotch::ClickBtnNotchCancel() { CDialog::OnCancel(); }