// GlassMap.cpp: implementation of the CGlassMap class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "GlassMap.h" #include #include "Global_Define.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CGlassMap::CGlassMap() { m_nMinDefectSize = 3; m_nBlinkColor = 0; m_pRecipe = NULL; m_pHardwareSetting = NULL; m_bSetZoomMode = FALSE; m_bZoomDrag = FALSE; m_bZoomInMode = FALSE; m_rectZoomDrag.SetRect(0,0,0,0); m_rectZoomWindow.SetRect(0,0,0,0); m_dZoomRatioH = m_dZoomRatioV = 1; m_pMapDefect = NULL; m_pSelDefect = NULL; m_pGlassData = NULL; //iskang Add notch iamge view m_bNotch = TRUE; m_nNotchDir = NotchDir_Non; m_BrushDefect[0].CreateSolidBrush(COLOR_0); m_BrushDefect[1].CreateSolidBrush(COLOR_4); m_BrushDefect[2].CreateSolidBrush(COLOR_2); m_BrushDefect[3].CreateSolidBrush(COLOR_1); m_BrushDefect[4].CreateSolidBrush(COLOR_4); ZeroMemory(m_dGlasssize,sizeof(double)*2); m_bTFTArea = FALSE; int i; for(i=0;i<4;i++) { ZeroMemory(m_nCutAreaSize[i],sizeof(int)*MAX_POINT_VALUE_CNT); ZeroMemory(m_nDimensionSize[i],sizeof(int)*MAX_POINT_VALUE_CNT); } ZeroMemory(m_dSplineSize,sizeof(double)*4); ZeroMemory(m_nCutAreaAVG,sizeof(int)*4); ZeroMemory(m_nDimensionAVG,sizeof(int)*4); ZeroMemory(m_dCornerSize_X,sizeof(double)*4); ZeroMemory(m_dCornerSize_Y,sizeof(double)*4); m_ptrOtherSideClass = NULL; } CGlassMap::~CGlassMap() { int i; for(i=0;im_InspectInfoParm.GetNotchSizeUse(DIMENSION_NONE)) { m_bNotch = TRUE; //int ScanIndex=0; DimensionDir enDir = DIMENSION_NONE; for(int j=0;jm_InspectInfoParm.GetNotchSizeUse((DimensionDir)j)) enDir = (DimensionDir)j; } //DimensionDir enDir = m_pRecipe->m_GlassParm.GetScanToDimension(ScanIndex); switch(enDir) { case DIMENSION_A: m_nNotchDir=NotchDir_A; break; case DIMENSION_B: m_nNotchDir=NotchDir_B; break; case DIMENSION_C: m_nNotchDir=NotchDir_C; break; case DIMENSION_D: m_nNotchDir=NotchDir_D; break; case DIMENSION_NONE: m_nNotchDir=NotchDir_Non; break; } } else m_bNotch =FALSE , m_nNotchDir = NotchDir_Non; GlassDirection GD = m_pRecipe->m_OriginDirection; if (GD == GD_LeftTop) m_OriginDir = OD_LeftTop; else if (GD == GD_LeftBottom) m_OriginDir = OD_LeftBottom; else if (GD == GD_RightTop) m_OriginDir = OD_RightTop; else if (GD == GD_RightBottom) m_OriginDir = OD_RightBottom; m_nCCutSize = m_nUnitSize * 20; switch(GD) { case GD_LeftTop: m_PointCCut[0] = CPoint(m_RectMap.left, m_RectMap.top); m_PointCCut[1] = CPoint(m_RectMap.left + m_nCCutSize, m_RectMap.top); m_PointCCut[2] = CPoint(m_RectMap.left, m_nCCutSize + m_RectMap.top); break; case GD_LeftBottom: m_PointCCut[0] = CPoint(m_RectMap.left, m_nMapHeight + m_RectMap.top); m_PointCCut[1] = CPoint(m_RectMap.left + m_nCCutSize, m_nMapHeight + m_RectMap.top); m_PointCCut[2] = CPoint(m_RectMap.left, m_nMapHeight - m_nCCutSize + m_RectMap.top); break; case GD_RightTop: m_PointCCut[0] = CPoint(m_RectMap.left + m_nMapWidth, m_RectMap.top); m_PointCCut[1] = CPoint(m_RectMap.left + m_nMapWidth - m_nCCutSize, m_RectMap.top); m_PointCCut[2] = CPoint(m_RectMap.left + m_nMapWidth, m_nCCutSize + m_RectMap.top); break; case GD_RightBottom: m_PointCCut[0] = CPoint(m_RectMap.left + m_nMapWidth, m_nMapHeight + m_RectMap.top); m_PointCCut[1] = CPoint(m_RectMap.left + m_nMapWidth - m_nCCutSize, m_nMapHeight + m_RectMap.top); m_PointCCut[2] = CPoint(m_RectMap.left + m_nMapWidth, m_nMapHeight - m_nCCutSize + m_RectMap.top); break; } ZeroMemory(m_dGlasssize,sizeof(double)*2); int i; for(i=0;i<4;i++) { ZeroMemory(m_nCutAreaSize[i],sizeof(int)*MAX_POINT_VALUE_CNT); ZeroMemory(m_nDimensionSize[i],sizeof(int)*MAX_POINT_VALUE_CNT); } ZeroMemory(m_dSplineSize,sizeof(double)*4); ZeroMemory(m_nCutAreaAVG,sizeof(int)*4); ZeroMemory(m_nDimensionAVG,sizeof(int)*4); ZeroMemory(m_dCornerSize_X,sizeof(double)*4); ZeroMemory(m_dCornerSize_Y,sizeof(double)*4); Invalidate(); } int CGlassMap::GetSmallSize() { int nUnit = static_cast(m_nUnitSize / m_dRatio); if (nUnit == 0) nUnit = 1; return static_cast(m_nMinDefectSize * nUnit); } int CGlassMap::GetMidSize() { int nUnit = static_cast(m_nUnitSize / m_dRatio); if (nUnit == 0) nUnit = 1; return static_cast(m_nMinDefectSize * nUnit); } int CGlassMap::GetLargeSize() { int nUnit = static_cast(m_nUnitSize / m_dRatio); if (nUnit == 0) nUnit = 1; return static_cast(m_nMinDefectSize * nUnit); } int CGlassMap::GetHugeSize() { int nUnit = static_cast(m_nUnitSize / m_dRatio); if (nUnit == 0) nUnit = 1; return static_cast(m_nMinDefectSize * nUnit); } void CGlassMap::CalDefectRect(CPoint &point,BOOL bRet,BOOL bDirOpt) { if(m_pRecipe == NULL) return; GlassDirection GD = m_pRecipe->m_OriginDirection; switch(GD) { case GD_LeftTop: break; case GD_LeftBottom: if(bRet==FALSE) point.y = m_RectMap.bottom-point.y; else point.y = m_rectGlass.Height()-point.y; break; case GD_RightTop: if(bRet==FALSE) point.x = m_RectMap.right-point.x; else point.x = m_rectGlass.Width()-point.x; break; case GD_RightBottom: if(bRet==FALSE) { point.x = m_RectMap.right-point.x; point.y = m_RectMap.bottom-point.y; } else { point.x = m_rectGlass.Width()-point.x; point.y = m_rectGlass.Height()-point.y; } break; } } void CGlassMap::CalDefectRect(CRect &rect,BOOL bRet,BOOL bDirOpt) { if(m_pRecipe == NULL) return; GlassDirection GD = m_pRecipe->m_OriginDirection; switch(GD) { case GD_LeftTop: break; case GD_LeftBottom: if(bRet==FALSE) { rect.top = m_RectMap.bottom-rect.top; rect.bottom = m_RectMap.bottom-rect.bottom; } else { rect.top = m_rectGlass.Height()-rect.top; rect.bottom = m_rectGlass.Height()-rect.bottom; } break; case GD_RightTop: if(bRet==FALSE) { rect.left = m_RectMap.right-rect.left; rect.right = m_RectMap.right-rect.right; } else { rect.left = m_rectGlass.Width()-rect.left; rect.right = m_rectGlass.Width()-rect.right; } break; case GD_RightBottom: if(bRet==FALSE) { rect.left = m_RectMap.right-rect.left; rect.right = m_RectMap.right-rect.right; rect.top = m_RectMap.bottom-rect.top; rect.bottom = m_RectMap.bottom-rect.bottom; } else { rect.left = m_rectGlass.Width()-rect.left; rect.right = m_rectGlass.Width()-rect.right; rect.top = m_rectGlass.Height()-rect.top; rect.bottom = m_rectGlass.Height()-rect.bottom; } break; } rect.NormalizeRect(); } void CGlassMap::DrawZoonInMode(CDC *pDC,CControlMemDC *memDC) { CDC BackDC; CBitmap BackBmp; CRect rt; BackDC.CreateCompatibleDC(pDC); GetClientRect(&rt); BackBmp.CreateCompatibleBitmap(pDC, rt.right, rt.bottom); BackDC.SelectObject(BackBmp); pDC->BitBlt(m_RectWnd.left, m_RectWnd.top, m_RectWnd.Width(), m_RectWnd.Height(), memDC, m_RectWnd.left, m_RectWnd.top, SRCCOPY); BackDC.StretchBlt(0, 0, rt.right, rt.bottom, pDC, 0, 0, rt.right, rt.bottom, SRCCOPY); CBrush brushGlass( RGB(0,0,0) ); memDC->FillRect( &rt, &brushGlass ); memDC->StretchBlt(0, 0, rt.right, rt.bottom, &BackDC, m_rectZoomWindow.left, m_rectZoomWindow.top, m_rectZoomWindow.Width(), m_rectZoomWindow.Height(), SRCCOPY); BackBmp.DeleteObject(); BackDC.DeleteDC(); brushGlass.DeleteObject(); } CString CGlassMap::GetPositionString(DimensionDir dir) { CString str; int nAddSide = 0; if(m_bTFTArea == TRUE) nAddSide = 4; dir = (DimensionDir)(dir+nAddSide); switch(dir) { case DIMENSION_A: str = "A T Pos"; break; case DIMENSION_B: str = "B T Pos"; break; case DIMENSION_C: str = "C T Pos"; break; case DIMENSION_D: str = "D T Pos"; break; case DIMENSION_A_DN: str = "A B Pos"; break; case DIMENSION_B_DN: str = "B B Pos"; break; case DIMENSION_C_DN: str = "C B Pos"; break; case DIMENSION_D_DN: str = "D B Pos"; break; } return str; } #define COLOR_PATTERN RGB(20,20,20) #define COLOR_BM RGB(185,205,230) #define COLOR_GLASS_BRUSH RGB(0,0,0) #define COLOR_GLASS_LINE_BRUSH RGB(200,200,200) #define COLOR_GLASS_PEN RGB(255,255,255) #define COLOR_GLASS_LINE_PEN RGB(0,255,0) #define COLOR_GLASS_SIZE_PEN RGB(255,255,0) void CGlassMap::DrawDefects(MapDefect* pMapDefect,CGlass_Data *pGlassData) { if (!pMapDefect) { m_pMapDefect = NULL; m_pGlassData = NULL; } else { m_pMapDefect = pMapDefect; m_pGlassData = pGlassData; } m_pSelDefect = NULL; KillTimer(ID_TIMER_BLINK); } BOOL CGlassMap::SetSelectDefect(int nGlassDefectIdx) { m_pSelDefect = NULL; KillTimer(ID_TIMER_BLINK); Invalidate(FALSE); if (!m_pMapDefect) return FALSE; BOOL bFind = FALSE; CInspectDefect* pDefect; for (MapDefectIt it = m_pMapDefect->begin(); it != m_pMapDefect->end(); it++) { pDefect = static_cast(it->second); // Ãß¿ø±¹ UI º¯°æ /* if(pDefect == NULL || m_bTFTArea == TRUE && pDefect->m_nCameraID == 0) continue; else if(m_bTFTArea == FALSE && pDefect->m_nCameraID == 1) continue; */ if (pDefect && pDefect->m_nGlassDefectIdx == nGlassDefectIdx) { m_pSelDefect = pDefect; Invalidate(FALSE); SetTimer(ID_TIMER_BLINK, 100, NULL); bFind = TRUE; break; } } //for (MapDefectIt it = m_pMapDefect->begin(); it != m_pMapDefect->end(); it++) for (MapDefectIt it = m_ptrOtherSideClass->m_pMapDefect->begin(); it != m_ptrOtherSideClass->m_pMapDefect->end(); it++) { pDefect = static_cast(it->second); // Ãß¿ø±¹ UI º¯°æ /* if(pDefect == NULL || m_bTFTArea == TRUE && pDefect->m_nCameraID == 0) continue; else if(m_bTFTArea == FALSE && pDefect->m_nCameraID == 1) continue; */ if (pDefect && pDefect->m_nGlassDefectIdx == nGlassDefectIdx) { m_pSelDefect = pDefect; Invalidate(FALSE); SetTimer(ID_TIMER_BLINK, 100, NULL); bFind = TRUE; break; } } return bFind; } void CGlassMap::SetGlasssize(int nIdx,double dValue) { m_dGlasssize[nIdx] = dValue; Invalidate(FALSE); } void CGlassMap::SetPointCutData(DimensionDir enDir,double *pCutArea,double dAvgVal) { if(enDir < DIMENSION_A || enDir > DIMENSION_D) return; for(int i=0;i DIMENSION_D) return; for(int i=0;i Disp_Spline_TopLeft) return; m_dSplineSize[enDir] = dValue; } void CGlassMap::SetCornerXData(Disp_SplineLocation enDir,double dValue) { if(enDir < Disp_Spline_BotRight || enDir > Disp_Spline_TopLeft) return; m_dCornerSize_X[enDir] = dValue; } void CGlassMap::SetCornerYData(Disp_SplineLocation enDir,double dValue) { if(enDir < Disp_Spline_BotRight || enDir > Disp_Spline_TopLeft) return; m_dCornerSize_Y[enDir] = dValue; } void CGlassMap::DrawGlassPosition(HDC hDC) { if(m_pRecipe == NULL) return; HFONT font,pOldFont; font = ::CreateFont(14, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DECORATIVE, _T("Arial")); pOldFont = (HFONT) ::SelectObject(hDC, font); if(::GetTextColor(hDC) != COLOR_GLASS_BRUSH) ::SetTextColor(hDC, COLOR_GLASS_BRUSH); ::SetBkMode(hDC, TRANSPARENT); CBrush BrushCCut( RGB(160,255,160) ); HBRUSH pOldBrush = (HBRUSH)::SelectObject(hDC,(HBRUSH)BrushCCut); CString str; CRect rect; int nOffset = 2; int nHSize = 60,nVSize = 16; int nBoxSize = 20; // D rect = m_rectGlass; rect.left = rect.left + nHSize/2; rect.right = rect.left + nHSize; rect.top = m_rectGlass.top + m_rectGlass.Height()/2 - nVSize/2; rect.bottom = rect.top + nVSize; //rect.OffsetRect(0,-1*nBoxSize); str = GetPositionString(DIMENSION_D); if(m_pRecipe->GetInspectInfo()->GetCutAreaUse(DIMENSION_NONE) == TRUE || m_pRecipe->GetInspectInfo()->GetDimenUse(DIMENSION_NONE) == TRUE ) { ::FillRect(hDC,&rect,BrushCCut); ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); } rect.OffsetRect(0,nVSize); //DrawPointValue(hDC,rect,CPoint(0,0),&m_nCutAreaAVG[DIMENSION_D], &m_nDimensionAVG[DIMENSION_D],1); //DrawPointValue(hDC,rect,CPoint(0,0),&m_nCutAreaAVG[DIMENSION_D],&(m_ptrOtherSideClass->m_nCutAreaAVG[DIMENSION_D]), &m_nDimensionAVG[DIMENSION_D],1); // B rect = m_rectGlass; rect.right = rect.right - nHSize/2; rect.left = rect.right - nHSize; rect.top = m_rectGlass.top + m_rectGlass.Height()/2 - nVSize/2; rect.bottom = rect.top + nVSize; //rect.OffsetRect(0,-1*nBoxSize); str = GetPositionString(DIMENSION_B); if(m_pRecipe->m_InspectInfoParm.GetCutAreaUse(DIMENSION_NONE) == TRUE || m_pRecipe->m_InspectInfoParm.GetDimenUse(DIMENSION_NONE) == TRUE ) { ::FillRect(hDC,&rect,BrushCCut); ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); } rect.OffsetRect(0,nVSize); //DrawPointValue(hDC,rect,CPoint(0,0),&m_nCutAreaAVG[DIMENSION_B],&m_nDimensionAVG[DIMENSION_B],1); //DrawPointValue(hDC,rect,CPoint(0,0),&m_nCutAreaAVG[DIMENSION_B],&(m_ptrOtherSideClass->m_nCutAreaAVG[DIMENSION_B]), &m_nDimensionAVG[DIMENSION_B],1); // A rect = m_rectGlass; rect.left = m_rectGlass.left + m_rectGlass.Width()/2 - nHSize/2; rect.right = rect.left + nHSize; rect.top = rect.top + nVSize*2; rect.bottom = rect.top + nVSize; //rect.OffsetRect(0,nOffset/2); str = GetPositionString(DIMENSION_A); if(m_pRecipe->m_InspectInfoParm.GetCutAreaUse(DIMENSION_NONE) == TRUE || m_pRecipe->m_InspectInfoParm.GetDimenUse(DIMENSION_NONE) == TRUE ) { ::FillRect(hDC,&rect,BrushCCut); ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); } rect.OffsetRect(0,nVSize); //DrawPointValue(hDC,rect,CPoint(0,0),&m_nCutAreaAVG[DIMENSION_A],&m_nDimensionAVG[DIMENSION_A],1); //DrawPointValue(hDC,rect,CPoint(0,0),&m_nCutAreaAVG[DIMENSION_A],&(m_ptrOtherSideClass->m_nCutAreaAVG[DIMENSION_A]), &m_nDimensionAVG[DIMENSION_A],1); // C rect = m_rectGlass; rect.left = m_rectGlass.left + m_rectGlass.Width()/2 - nHSize/2; rect.right = rect.left + nHSize; rect.top = m_rectGlass.bottom - nVSize*2; rect.bottom = rect.top + nVSize; //rect.OffsetRect(0,-1*nOffset -10); str = GetPositionString(DIMENSION_C); if(m_pRecipe->m_InspectInfoParm.GetCutAreaUse(DIMENSION_NONE) == TRUE || m_pRecipe->m_InspectInfoParm.GetDimenUse(DIMENSION_NONE) == TRUE ) { ::FillRect(hDC,&rect,BrushCCut); ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); } rect.OffsetRect(0,nVSize); //DrawPointValue(hDC,rect,CPoint(0,0),&m_nCutAreaAVG[DIMENSION_C],&m_nDimensionAVG[DIMENSION_C],1); //DrawPointValue(hDC,rect,CPoint(0,0),&m_nCutAreaAVG[DIMENSION_C],&(m_ptrOtherSideClass->m_nCutAreaAVG[DIMENSION_C]), &m_nDimensionAVG[DIMENSION_C],1); ::DeleteObject(::SelectObject(hDC, (HFONT)pOldFont)); ::DeleteObject(font); if(pOldBrush) ::SelectObject(hDC,(HBRUSH)pOldBrush); } static int compPoly(const void *a,const void *b) { return *(int*)a - *(int*)b; } void CGlassMap::FillPolygon(HDC hDC,POINT *poly,int npoly,DWORD color,int nTop,int nBottom) { int *nodeX = new int[npoly]; int i,j,x,y,nodes; for(y=nTop;y= y || poly[j].y < y && poly[i].y >= y) { nodeX[nodes++] = (int)(poly[i].x + double(y-poly[i].y)*double(poly[j].x-poly[i].x)/double(poly[j].y-poly[i].y) + .5); } } qsort(nodeX,nodes,sizeof(int),compPoly); for(i=0;i= m_rectGlass.Width()) // break; if(nodeX[i+1] > 0) { if(nodeX[i] < 0) nodeX[i] = 0; // if(nodeX[i+1] > m_rectGlass.Width()) nodeX[i+1] = m_rectGlass.Width(); for(x=nodeX[i];xGetProfileInspectData(); if(nMapIndex >= 0 && nMapIndex < MAX_PROFILE_SETTING_COUNT) { str.Format(_T("%.3f"),(double)pProfile->ProfileData[nMapIndex].nProfileDiff/1000.); } else { str.Format(_T("0")); } } rect.OffsetRect(0,rect.Height()); pOldBrush = (CBrush*)::SelectObject(hDC,(HBRUSH)BrushCutArea2); ::FillRect(hDC,&rect, (HBRUSH)BrushCutArea2); ::Rectangle(hDC,rect.left,rect.top,rect.right,rect.bottom); ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); } else { rect.OffsetRect(0,-(rect.Height()*2)); pOldBrush = (CBrush*)::SelectObject(hDC,(HBRUSH)BrushCutArea); ::FillRect(hDC,&rect, (HBRUSH)BrushCutArea); ::Rectangle(hDC,rect.left,rect.top,rect.right,rect.bottom); str.Format(_T("%d"),nMapIndex); ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); nMapIndex--; if(m_pGlassData == NULL) str.Format(_T("0")); else { PROFILECHAMFER_RESULT_DATA *pProfile = m_pGlassData->GetProfileInspectData(); if(nMapIndex >= 0 && nMapIndex < MAX_PROFILE_SETTING_COUNT) { str.Format(_T("%.3f"),(double)pProfile->ResultChamfer[nMapIndex][0].nChamferCalThick/1000.); } else { str.Format(_T("0")); } } rect.OffsetRect(0,rect.Height()); pOldBrush = (CBrush*)::SelectObject(hDC,(HBRUSH)BrushCutArea2); ::FillRect(hDC,&rect, (HBRUSH)BrushCutArea2); ::Rectangle(hDC,rect.left,rect.top,rect.right,rect.bottom); ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); if(m_pGlassData == NULL) str.Format(_T("0")); else { PROFILECHAMFER_RESULT_DATA *pProfile = m_pGlassData->GetProfileInspectData(); if(nMapIndex >= 0 && nMapIndex < MAX_PROFILE_SETTING_COUNT) { str.Format(_T("%.3f"),(double)pProfile->ResultChamfer[nMapIndex][1].nChamferCalThick/1000.); } else { str.Format(_T("0")); } } rect.OffsetRect(0,rect.Height()); pOldBrush = (CBrush*)::SelectObject(hDC,(HBRUSH)BrushSpline); ::FillRect(hDC,&rect, (HBRUSH)BrushSpline); ::Rectangle(hDC,rect.left,rect.top,rect.right,rect.bottom); ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); } } ::DeleteObject(::SelectObject(hDC, (HFONT)pOldFont)); ::DeleteObject(font); ::SelectObject(hDC , (HBRUSH)pOldBrush); BrushSpline.DeleteObject(); BrushCutArea.DeleteObject(); BrushCutArea2.DeleteObject(); } void CGlassMap::DrawCornerXValue( HDC hDC ) { if(m_pRecipe->m_InspectInfoParm.m_CornerParm.m_bUse == FALSE) return ; Disp_SplineLocation enDir; int i; CRect rect; CBrush BrushSpline,*pOldBrush; CPen Penouter; const int nHSize = 40,nVSize = 14,nSkipSize = 5; CString str; BrushSpline.CreateSolidBrush(RGB(100,255,20)); pOldBrush = (CBrush*)::SelectObject(hDC,(HBRUSH)BrushSpline); Penouter.CreatePen(PS_SOLID, 1, RGB(255,255,255)); HPEN OldPen = (HPEN)::SelectObject(hDC,Penouter); HFONT font,pOldFont; font = ::CreateFont(14, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DECORATIVE, _T("Arial")); pOldFont = (HFONT) ::SelectObject(hDC, font); if(::GetTextColor(hDC) != COLOR_GLASS_BRUSH) ::SetTextColor(hDC, COLOR_GLASS_BRUSH); ::SetBkMode(hDC, TRANSPARENT); for(i=0;i<4;i++) { enDir = (Disp_SplineLocation)i; switch(enDir) { case Disp_Spline_BotRight: rect.top = m_rectGlass.bottom + nSkipSize; rect.bottom = rect.top + nVSize; rect.right = m_rectGlass.right - nSkipSize; rect.left = rect.right - nHSize; //rect.OffsetRect(-nSkipSize,-nSkipSize); break; case Disp_Spline_BotLeft: rect.top = m_rectGlass.bottom + nSkipSize; rect.bottom = rect.top + nVSize; rect.left = m_rectGlass.left + nSkipSize; rect.right = rect.left + nHSize; //rect.OffsetRect(nSkipSize,-nSkipSize); break; case Disp_Spline_TopRight: rect.bottom = m_rectGlass.top - nSkipSize; rect.top = rect.bottom - nVSize; rect.right = m_rectGlass.right - nSkipSize; rect.left = rect.right - nHSize; //rect.OffsetRect(-nSkipSize,nSkipSize); break; case Disp_Spline_TopLeft: rect.bottom = m_rectGlass.top - nSkipSize; rect.top = rect.bottom - nVSize; rect.left = m_rectGlass.left + nSkipSize; rect.right = rect.left + nHSize; //rect.OffsetRect(nSkipSize,nSkipSize); break; } ::FillRect(hDC,&rect, (HBRUSH)BrushSpline); ::Rectangle(hDC,rect.left,rect.top,rect.right,rect.bottom); str.Format(_T("%.0f"),m_dCornerSize_X[i]); ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); } ::DeleteObject(::SelectObject(hDC, (HFONT)pOldFont)); ::DeleteObject(font); ::SelectObject(hDC , (HBRUSH)pOldBrush); BrushSpline.DeleteObject(); } void CGlassMap::DrawCornerYValue( HDC hDC ) { if(m_pRecipe->m_InspectInfoParm.GetCornerParm()->m_bUse == FALSE) return ; Disp_SplineLocation enDir; int i; CRect rect; CBrush BrushSpline,*pOldBrush; CPen Penouter; const int nHSize = 40,nVSize = 14,nSkipSize = 5; CString str; BrushSpline.CreateSolidBrush(RGB(100,255,20)); pOldBrush = (CBrush*)::SelectObject(hDC,(HBRUSH)BrushSpline); Penouter.CreatePen(PS_SOLID, 1, RGB(255,255,255)); HPEN OldPen = (HPEN)::SelectObject(hDC,Penouter); HFONT font,pOldFont; font = ::CreateFont(14, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DECORATIVE, _T("Arial")); pOldFont = (HFONT) ::SelectObject(hDC, font); if(::GetTextColor(hDC) != COLOR_GLASS_BRUSH) ::SetTextColor(hDC, COLOR_GLASS_BRUSH); ::SetBkMode(hDC, TRANSPARENT); for(i=0;i<4;i++) { enDir = (Disp_SplineLocation)i; switch(enDir) { case Disp_Spline_BotRight: rect.bottom = m_rectGlass.bottom - nSkipSize; rect.top = rect.bottom - nVSize; rect.left = m_rectGlass.right + nSkipSize; rect.right = rect.left + nHSize; //rect.OffsetRect(-nSkipSize,-nSkipSize); break; case Disp_Spline_BotLeft: rect.bottom = m_rectGlass.bottom - nSkipSize; rect.top = rect.bottom - nVSize; rect.right = m_rectGlass.left - nSkipSize; rect.left = rect.right - nHSize; //rect.OffsetRect(nSkipSize,-nSkipSize); break; case Disp_Spline_TopRight: rect.top = m_rectGlass.top + nSkipSize; rect.bottom = rect.top + nVSize; rect.left = m_rectGlass.right + nSkipSize; rect.right = rect.left + nHSize; //rect.OffsetRect(-nSkipSize,nSkipSize); break; case Disp_Spline_TopLeft: rect.top = m_rectGlass.top + nSkipSize; rect.bottom = rect.top + nVSize; rect.right = m_rectGlass.left - nSkipSize; rect.left = rect.right - nHSize; //rect.OffsetRect(nSkipSize,nSkipSize); break; } ::FillRect(hDC,&rect, (HBRUSH)BrushSpline); ::Rectangle(hDC,rect.left,rect.top,rect.right,rect.bottom); str.Format(_T("%.0f"),m_dCornerSize_Y[i]); ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); } ::DeleteObject(::SelectObject(hDC, (HFONT)pOldFont)); ::DeleteObject(font); ::SelectObject(hDC , (HBRUSH)pOldBrush); BrushSpline.DeleteObject(); } void CGlassMap::DrawPointValue(HDC hDC,CRect rectBase,CPoint pointSkip,int *pCurValue,int *pDimenValue,int nLoopCnt) { CBrush BrushCutArea,BrushDimension,BrushSpline,*pOldBrush; CPen Penouter; CRect rect; int i; CString str; HFONT font,pOldFont; font = ::CreateFont(14, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DECORATIVE, _T("Arial")); pOldFont = (HFONT) ::SelectObject(hDC, font); if(::GetTextColor(hDC) != COLOR_GLASS_BRUSH) ::SetTextColor(hDC, COLOR_GLASS_BRUSH); ::SetBkMode(hDC, TRANSPARENT); BrushCutArea.CreateSolidBrush(RGB(100,100,255)); BrushDimension.CreateSolidBrush(RGB(255,100,0)); BrushSpline.CreateSolidBrush(RGB(255,60,200)); Penouter.CreatePen(PS_SOLID, 1, RGB(255,255,255)); HPEN OldPen = (HPEN)::SelectObject(hDC,Penouter); for(i=0;iGetProfileInspectData(); if(nMapIndex >= 0 && nMapIndex < MAX_PROFILE_SETTING_COUNT) { str.Format(_T("%.3f"),(double)pProfile->ProfileData[nMapIndex].nProfileDiff/1000.); } else { str.Format(_T("0")); } } ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); } else { //Cut Top bFirst = FALSE; int nMapIndex = m_MapIndex.m_nIndex[nIndex][i]; pOldBrush = (CBrush*)::SelectObject(hDC,(HBRUSH)BrushCutArea); ::FillRect(hDC,&rect, (HBRUSH)BrushCutArea); ::Rectangle(hDC,rect.left,rect.top,rect.right,rect.bottom); str.Format(_T("%d"),nMapIndex); ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); // Chamfer Up rect.OffsetRect(0,rectBase.Height()); pOldBrush = (CBrush*)::SelectObject(hDC,(HBRUSH)BrushCutArea2); ::FillRect(hDC,&rect, (HBRUSH)BrushCutArea2); ::Rectangle(hDC,rect.left,rect.top,rect.right,rect.bottom); nMapIndex--; if(m_pGlassData == NULL) str.Format(_T("0")); else { PROFILECHAMFER_RESULT_DATA *pProfile = m_pGlassData->GetProfileInspectData(); if(nMapIndex >= 0 && nMapIndex < MAX_PROFILE_SETTING_COUNT) { str.Format(_T("%.3f"),(double)pProfile->ResultChamfer[nMapIndex][0].nChamferCalThick/1000.); } else { str.Format(_T("0")); } } ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); // Chamfer Down rect.OffsetRect(0,rectBase.Height()); pOldBrush = (CBrush*)::SelectObject(hDC,(HBRUSH)BrushDimension); ::FillRect(hDC,&rect, (HBRUSH)BrushDimension); ::Rectangle(hDC,rect.left,rect.top,rect.right,rect.bottom); if(m_pGlassData == NULL) str.Format(_T("0")); else { PROFILECHAMFER_RESULT_DATA *pProfile = m_pGlassData->GetProfileInspectData(); if(nMapIndex >= 0 && nMapIndex < MAX_PROFILE_SETTING_COUNT) { str.Format(_T("%.3f"),(double)pProfile->ResultChamfer[nMapIndex][1].nChamferCalThick/1000.); } else { str.Format(_T("0")); } } ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE); } } ::DeleteObject(::SelectObject(hDC, (HFONT)pOldFont)); ::DeleteObject(font); ::SelectObject(hDC, (HPEN)OldPen); ::SelectObject(hDC , (HBRUSH)pOldBrush); BrushCutArea.DeleteObject(); BrushDimension.DeleteObject(); BrushSpline.DeleteObject(); } void CGlassMap::DrawPointValue(HDC hDC) { CRect rect; int nHSize = 45,nVSize = 14,nSkipSize = 10,nFirstSkip = 40,nFirstSkipH = 20; int nDivSkip=(m_rectGlass.right-m_rectGlass.left-nFirstSkip*2-nHSize)/3; ////////////////////////////////////////////////////////////////////////// // C rect = m_rectGlass; rect.top = m_rectGlass.bottom; rect.bottom = rect.top + nVSize; rect.right = rect.left + nHSize; rect.OffsetRect(nFirstSkip,nSkipSize); DrawPointValue(hDC,rect,CPoint(nDivSkip,0),m_nCutAreaSize[DIMENSION_C], m_ptrOtherSideClass->m_nCutAreaSize[DIMENSION_C], m_nDimensionSize[DIMENSION_C],DIMENSION_C,4); ////////////////////////////////////////////////////////////////////////// // A rect = m_rectGlass; rect.top = m_rectGlass.top - nVSize - 10; rect.bottom = rect.top + nVSize; rect.left = m_rectGlass.right; rect.right = rect.left - nHSize; rect.OffsetRect(-1*nFirstSkip,-1*(nSkipSize+nVSize)); DrawPointValue(hDC,rect,CPoint(-1*nDivSkip,0),m_nCutAreaSize[DIMENSION_A],m_ptrOtherSideClass->m_nCutAreaSize[DIMENSION_A], m_nDimensionSize[DIMENSION_A],DIMENSION_A,4); nDivSkip = (m_rectGlass.bottom-m_rectGlass.top-nSkipSize*3-nVSize*4)/2; nFirstSkip = 60; ////////////////////////////////////////////////////////////////////////// // B rect = m_rectGlass; rect.bottom = rect.top + nVSize; rect.left = m_rectGlass.right; rect.right = rect.left + nHSize; rect.OffsetRect(nSkipSize,nFirstSkipH); DrawPointValue(hDC,rect,CPoint(0,nDivSkip),m_nCutAreaSize[DIMENSION_B],m_ptrOtherSideClass->m_nCutAreaSize[DIMENSION_B], m_nDimensionSize[DIMENSION_B],DIMENSION_B); ////////////////////////////////////////////////////////////////////////// // D rect = m_rectGlass; rect.bottom = rect.top + nVSize; rect.right = m_rectGlass.left; rect.left = rect.right - nHSize; rect.OffsetRect(-1*nSkipSize,nFirstSkipH); DrawPointValue(hDC,rect,CPoint(0,nDivSkip),m_nCutAreaSize[DIMENSION_D],m_ptrOtherSideClass->m_nCutAreaSize[DIMENSION_D],m_nDimensionSize[DIMENSION_D],DIMENSION_D); } void CGlassMap::DrawGlassBackGround(HDC hDC) { CBrush BrushGlass,*pOldBrush,PolyBrush,PolySmallBrush,NotchBrush; CPen PenGlass,PenInner,PenRemove; CRect rect,PieRect; int CirclePie = 30; BrushGlass.CreateSolidBrush(COLOR_GLASS_BRUSH); pOldBrush = (CBrush*)::SelectObject(hDC,(HBRUSH)BrushGlass); ::FillRect(hDC,&m_RectWnd, (HBRUSH)BrushGlass); PenGlass.CreatePen(PS_SOLID, 4, COLOR_GLASS_LINE_BRUSH); DrawRect(hDC,PenGlass,m_RectWnd); PenRemove.CreatePen(PS_SOLID, 2, COLOR_GLASS_BRUSH); PenInner.CreatePen(PS_SOLID, 2, RGB(150,150,150)); rect = m_rectGlass; const int nOffset = 15; const int nLineOffset = 20; const int nPolyCnt = 6; int i; HPEN hOldPen = (HPEN)::SelectObject(hDC ,PenInner); POINT pPolyPointSmall[nPolyCnt]; EM_GLASSTYPE_COMP emComp = GLASSTYPE_RCUT; // m_pRecipe->m_GlassParm.m_emGlassType; if(emComp == GLASSTYPE_RCUT) { POINT pPolyPoint[18]; PolyBrush.CreateSolidBrush(RGB(0,0,90)); pOldBrush = (CBrush*)::SelectObject(hDC ,(HBRUSH)PolyBrush); // Å«³Ñ ±×¸®±â pPolyPoint[0].x = rect.left, pPolyPoint[0].y = rect.top+nLineOffset; pPolyPoint[1].x = rect.left,pPolyPoint[1].y = rect.bottom-nOffset; pPolyPoint[2].x = rect.left, pPolyPoint[2].y = rect.bottom-nOffset+2; pPolyPoint[3].x = rect.left+3, pPolyPoint[3].y = rect.bottom-nOffset+8; pPolyPoint[4].x = rect.left+6, pPolyPoint[4].y = rect.bottom-nOffset+11; pPolyPoint[5].x = rect.left+12, pPolyPoint[5].y = rect.bottom-nOffset+14; pPolyPoint[6].x = rect.left+14, pPolyPoint[6].y = rect.bottom-nOffset+15; pPolyPoint[7].x = rect.left+nOffset, pPolyPoint[7].y = rect.bottom; pPolyPoint[8].x = rect.right-nOffset, pPolyPoint[8].y = rect.bottom; pPolyPoint[9].x = rect.right-nOffset+1, pPolyPoint[9].y = rect.bottom; pPolyPoint[10].x = rect.right-nOffset+3,pPolyPoint[10].y = rect.bottom-1; pPolyPoint[11].x = rect.right-nOffset+9,pPolyPoint[11].y = rect.bottom-4; pPolyPoint[12].x = rect.right-nOffset+12,pPolyPoint[12].y = rect.bottom-7; pPolyPoint[13].x = rect.right, pPolyPoint[13].y = rect.bottom-13; pPolyPoint[14].x = rect.right, pPolyPoint[14].y = rect.bottom-nOffset; pPolyPoint[15].x = rect.right, pPolyPoint[15].y = rect.top+nLineOffset; pPolyPoint[16].x = rect.right-nOffset, pPolyPoint[16].y = rect.top+nLineOffset; pPolyPoint[17].x = rect.left+nOffset, pPolyPoint[17].y = rect.top+nLineOffset; ::BeginPath(hDC); ::MoveToEx(hDC,pPolyPoint[0].x,pPolyPoint[0].y,NULL); for(i=1;i<18;i++) { ::LineTo(hDC,pPolyPoint[i].x,pPolyPoint[i].y); } ::LineTo(hDC,pPolyPoint[0].x,pPolyPoint[0].y); ::EndPath(hDC); ::StrokeAndFillPath(hDC); } else if(emComp == GLASSTYPE_CCUT || emComp == GLASSTYPE_NCUT) { POINT pPolyPoint[nPolyCnt]; PolyBrush.CreateSolidBrush(RGB(0,0,90)); pOldBrush = (CBrush*)::SelectObject(hDC ,(HBRUSH)PolyBrush); // Å«³Ñ ±×¸®±â pPolyPoint[0].x = rect.left, pPolyPoint[0].y = rect.top+nLineOffset; pPolyPoint[1].x = rect.left, pPolyPoint[1].y = rect.bottom-nOffset; pPolyPoint[2].x = rect.left+nOffset, pPolyPoint[2].y = rect.bottom; pPolyPoint[3].x = rect.right-nOffset, pPolyPoint[3].y = rect.bottom; pPolyPoint[4].x = rect.right, pPolyPoint[4].y = rect.bottom-nOffset; pPolyPoint[5].x = rect.right, pPolyPoint[5].y = rect.top+nLineOffset; ::BeginPath(hDC); ::MoveToEx(hDC,pPolyPoint[0].x,pPolyPoint[0].y,NULL); for(i=1;im_SideParam[0].m_nSidePanelSize_um; int nGlassSizeY = m_pRecipe->m_SideParam[1].m_nSidePanelSize_um; str.Format(_T("%.3fmm X %.3fmm"),(double)nGlassSizeX/1000.,(double)nGlassSizeY/1000.); rect.top = rect.top+rect.Height()/2-10; rect.bottom = rect.top+20; ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER); /* rect.top = rect.bottom + 10; rect.bottom = rect.top+20; if(::GetTextColor(hDC) != RGB(255,255,0)) ::SetTextColor(hDC, RGB(255,255,0)); int x,y; y = (int)m_dGlasssize[1]; x = (int)m_dGlasssize[0]; str.Format(_T("%.3fmm X %.3fmm"),(double)x/1000,(double)y/1000); ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER); */ ::DeleteObject(::SelectObject(hDC, (HFONT)pOldFont)); ::DeleteObject(font); } const int nHSize = 40,nVSize = 14,nSkipSize = 5; if(m_pHardwareSetting != NULL && m_pRecipe != NULL && (emComp == GLASSTYPE_CCUT || emComp == GLASSTYPE_NCUT)) { rect = m_rectGlass; HFONT font,pOldFont; font = ::CreateFont(18, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DECORATIVE, _T("Arial")); pOldFont = (HFONT) ::SelectObject(hDC, font); if(::GetTextColor(hDC) != RGB(0,200,0)) ::SetTextColor(hDC, RGB(255,255,0)); ::SetBkMode(hDC, TRANSPARENT); CString str; str.Format(_T("2")); rect.bottom = m_rectGlass.top - nSkipSize; rect.top = rect.bottom - nVSize; rect.right = m_rectGlass.left - nSkipSize; rect.left = rect.right - nHSize; ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_BOTTOM); str.Format(_T("4")); rect.bottom = m_rectGlass.top - nSkipSize; rect.top = rect.bottom - nVSize; rect.left = m_rectGlass.right + nSkipSize; rect.right = rect.left + nHSize; ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_BOTTOM); str.Format(_T("1")); rect.top = m_rectGlass.bottom + nSkipSize; rect.bottom = rect.top + nVSize; rect.right = m_rectGlass.left - nSkipSize; rect.left = rect.right - nHSize; ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_TOP); str.Format(_T("3")); rect.top = m_rectGlass.bottom + nSkipSize; rect.bottom = rect.top + nVSize; rect.left = m_rectGlass.right + nSkipSize; rect.right = rect.left + nHSize; ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_TOP); ::DeleteObject(::SelectObject(hDC, (HFONT)pOldFont)); ::DeleteObject(font); } ::SelectObject(hDC , (HPEN)hOldPen); ::SelectObject(hDC , (HBRUSH)pOldBrush); BrushGlass.DeleteObject(); PenGlass.DeleteObject(); PenInner.DeleteObject(); PenRemove.DeleteObject(); PolyBrush.DeleteObject(); PolySmallBrush.DeleteObject(); NotchBrush.DeleteObject(); } void CGlassMap::DrawGlassBackGroundRev(HDC hDC) { CBrush BrushGlass,*pOldBrush,PolyBrush,PolySmallBrush,NotchBrush; CPen PenGlass,PenInner,PenRemove; CRect rect,PieRect; int CirclePie = 30; BrushGlass.CreateSolidBrush(COLOR_GLASS_BRUSH); pOldBrush = (CBrush*)::SelectObject(hDC,(HBRUSH)BrushGlass); ::FillRect(hDC,&m_RectWnd, (HBRUSH)BrushGlass); PenGlass.CreatePen(PS_SOLID, 4, COLOR_GLASS_LINE_BRUSH); DrawRect(hDC,PenGlass,m_RectWnd); PenRemove.CreatePen(PS_SOLID, 2, COLOR_GLASS_BRUSH); PenInner.CreatePen(PS_SOLID, 2, RGB(150,150,150)); rect = m_rectGlass; const int nOffset = 15; const int nLineOffset = 20; const int nPolyCnt = 6; int i; HPEN hOldPen = (HPEN)::SelectObject(hDC ,PenInner); POINT pPolyPointSmall[nPolyCnt]; EM_GLASSTYPE_COMP emComp = GLASSTYPE_RCUT; //m_pRecipe->m_GlassParm.m_emGlassType; if(emComp == GLASSTYPE_RCUT) { POINT pPolyPoint[18]; PolyBrush.CreateSolidBrush(RGB(0,0,90)); pOldBrush = (CBrush*)::SelectObject(hDC ,(HBRUSH)PolyBrush); // Å«³Ñ ±×¸®±â pPolyPoint[0].x = rect.left, pPolyPoint[0].y = rect.top+nLineOffset; pPolyPoint[1].x = rect.left,pPolyPoint[1].y = rect.bottom-nOffset; pPolyPoint[2].x = rect.left, pPolyPoint[2].y = rect.bottom-nOffset+2; pPolyPoint[3].x = rect.left+3, pPolyPoint[3].y = rect.bottom-nOffset+8; pPolyPoint[4].x = rect.left+6, pPolyPoint[4].y = rect.bottom-nOffset+11; pPolyPoint[5].x = rect.left+12, pPolyPoint[5].y = rect.bottom-nOffset+14; pPolyPoint[6].x = rect.left+14, pPolyPoint[6].y = rect.bottom-nOffset+15; pPolyPoint[7].x = rect.left+nOffset, pPolyPoint[7].y = rect.bottom; pPolyPoint[8].x = rect.right-nOffset, pPolyPoint[8].y = rect.bottom; pPolyPoint[9].x = rect.right-nOffset+1, pPolyPoint[9].y = rect.bottom; pPolyPoint[10].x = rect.right-nOffset+3,pPolyPoint[10].y = rect.bottom-1; pPolyPoint[11].x = rect.right-nOffset+9,pPolyPoint[11].y = rect.bottom-4; pPolyPoint[12].x = rect.right-nOffset+12,pPolyPoint[12].y = rect.bottom-7; pPolyPoint[13].x = rect.right, pPolyPoint[13].y = rect.bottom-13; pPolyPoint[14].x = rect.right, pPolyPoint[14].y = rect.bottom-nOffset; pPolyPoint[15].x = rect.right, pPolyPoint[15].y = rect.top+nLineOffset; pPolyPoint[16].x = rect.right-nOffset, pPolyPoint[16].y = rect.top+nLineOffset; pPolyPoint[17].x = rect.left+nOffset, pPolyPoint[17].y = rect.top+nLineOffset; ::BeginPath(hDC); ::MoveToEx(hDC,pPolyPoint[0].x,pPolyPoint[0].y,NULL); for(i=1;i<18;i++) { ::LineTo(hDC,pPolyPoint[i].x,pPolyPoint[i].y); } ::LineTo(hDC,pPolyPoint[0].x,pPolyPoint[0].y); ::EndPath(hDC); ::StrokeAndFillPath(hDC); } else if(emComp == GLASSTYPE_CCUT || emComp == GLASSTYPE_NCUT) { POINT pPolyPoint[nPolyCnt]; PolyBrush.CreateSolidBrush(RGB(0,0,90)); pOldBrush = (CBrush*)::SelectObject(hDC ,(HBRUSH)PolyBrush); // Å«³Ñ ±×¸®±â pPolyPoint[0].x = rect.left, pPolyPoint[0].y = rect.bottom-nLineOffset; pPolyPoint[1].x = rect.left, pPolyPoint[1].y = rect.top+nOffset; pPolyPoint[2].x = rect.left+nOffset, pPolyPoint[2].y = rect.top; pPolyPoint[3].x = rect.right-nOffset, pPolyPoint[3].y = rect.top; pPolyPoint[4].x = rect.right, pPolyPoint[4].y = rect.top+nOffset; pPolyPoint[5].x = rect.right, pPolyPoint[5].y = rect.bottom-nLineOffset; ::BeginPath(hDC); ::MoveToEx(hDC,pPolyPoint[0].x,pPolyPoint[0].y,NULL); for(i=1;im_SideParam[0].m_nSidePanelSize_um; int nGlassSizeY = m_pRecipe->m_SideParam[1].m_nSidePanelSize_um; str.Format(_T("%.3fmm X %.3fmm"),(double)nGlassSizeX/1000.,(double)nGlassSizeY/1000.); rect.top = rect.top+rect.Height()/2-10; rect.bottom = rect.top+20; ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER); /* rect.top = rect.bottom + 10; rect.bottom = rect.top+20; if(::GetTextColor(hDC) != RGB(255,255,0)) ::SetTextColor(hDC, RGB(255,255,0)); int x,y; y = (int)m_dGlasssize[1]; x = (int)m_dGlasssize[0]; str.Format(_T("%.3fmm X %.3fmm"),(double)x/1000,(double)y/1000); ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER); */ ::DeleteObject(::SelectObject(hDC, (HFONT)pOldFont)); ::DeleteObject(font); } const int nHSize = 40,nVSize = 14,nSkipSize = 5; if(m_pHardwareSetting != NULL && m_pRecipe != NULL && (emComp == GLASSTYPE_CCUT || emComp == GLASSTYPE_NCUT)) { rect = m_rectGlass; HFONT font,pOldFont; font = ::CreateFont(18, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DECORATIVE, _T("Arial")); pOldFont = (HFONT) ::SelectObject(hDC, font); if(::GetTextColor(hDC) != RGB(0,200,0)) ::SetTextColor(hDC, RGB(255,255,0)); ::SetBkMode(hDC, TRANSPARENT); CString str; str.Format(_T("4")); rect.bottom = m_rectGlass.top - nSkipSize; rect.top = rect.bottom - nVSize; rect.right = m_rectGlass.left - nSkipSize; rect.left = rect.right - nHSize; ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_BOTTOM); str.Format(_T("2")); rect.bottom = m_rectGlass.top - nSkipSize; rect.top = rect.bottom - nVSize; rect.left = m_rectGlass.right + nSkipSize; rect.right = rect.left + nHSize; ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_BOTTOM); str.Format(_T("3")); rect.top = m_rectGlass.bottom + nSkipSize; rect.bottom = rect.top + nVSize; rect.right = m_rectGlass.left - nSkipSize; rect.left = rect.right - nHSize; ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_TOP); str.Format(_T("1")); rect.top = m_rectGlass.bottom + nSkipSize; rect.bottom = rect.top + nVSize; rect.left = m_rectGlass.right + nSkipSize; rect.right = rect.left + nHSize; ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_TOP); ::DeleteObject(::SelectObject(hDC, (HFONT)pOldFont)); ::DeleteObject(font); } ::SelectObject(hDC , (HPEN)hOldPen); ::SelectObject(hDC , (HBRUSH)pOldBrush); BrushGlass.DeleteObject(); PenGlass.DeleteObject(); PenInner.DeleteObject(); PenRemove.DeleteObject(); PolyBrush.DeleteObject(); PolySmallBrush.DeleteObject(); NotchBrush.DeleteObject(); } void CGlassMap::ReCalRectDraw() { m_rectGlass = m_RectWnd; int nMarginWidth = 70; int nMarginHeight = 70; m_rectGlass.left += nMarginWidth; m_rectGlass.top += nMarginHeight; m_rectGlass.right -= nMarginWidth; m_rectGlass.bottom -= nMarginHeight; m_nUnitSize = m_nMapWidth / m_rectGlass.Width(); m_dWidthRatio = static_cast(m_rectGlass.Width())/static_cast(m_nMapWidth); m_dHeightRatio = static_cast(m_rectGlass.Height())/static_cast(m_nMapHeight); } /////////////////// void CGlassMap::DrawTriangle(HDC hDC, HPEN hPen, CPoint ptCenter, int nRadius) { // ASSERT(hDC); HPEN hOldPen= NULL; HBRUSH hOldBrush = NULL; if(hPen) hOldPen = (HPEN)::SelectObject(hDC ,hPen); int nShortY = nRadius/2; int nShortX = nRadius*866/1000; ::MoveToEx(hDC, ptCenter.x, ptCenter.y-nRadius, NULL); ::LineTo(hDC, ptCenter.x-nShortX, ptCenter.y+nShortY); ::LineTo(hDC, ptCenter.x+nShortX, ptCenter.y+nShortY); ::LineTo(hDC, ptCenter.x, ptCenter.y-nRadius); if(hPen) ::SelectObject(hDC , (HPEN)hOldPen); } /////////////////// void CGlassMap::DrawCircle(HDC hDC, HPEN hPen, CPoint ptCenter, int nRadius) { // ASSERT(hDC); HPEN hOldPen= NULL; HBRUSH hOldBrush = NULL; if(hPen) hOldPen = (HPEN)::SelectObject(hDC ,hPen); ::Arc(hDC, ptCenter.x-nRadius, ptCenter.y-nRadius, ptCenter.x+nRadius, ptCenter.y+nRadius, ptCenter.x-nRadius, ptCenter.y-nRadius, ptCenter.x-nRadius, ptCenter.y-nRadius); //Bottom if(hPen) ::SelectObject(hDC , (HPEN)hOldPen); } void CGlassMap::DrawCross(HDC hDC, HPEN hPen, CPoint ptCenter, int nRadius) { HPEN hOldPen= NULL; HBRUSH hOldBrush = NULL; if(hPen) hOldPen = (HPEN)::SelectObject(hDC ,hPen); ::MoveToEx(hDC, ptCenter.x-nRadius, ptCenter.y-nRadius, NULL); ::LineTo(hDC, ptCenter.x+nRadius, ptCenter.y+nRadius); ::MoveToEx(hDC, ptCenter.x+nRadius, ptCenter.y-nRadius, NULL); ::LineTo(hDC, ptCenter.x-nRadius, ptCenter.y+nRadius); if(hPen) ::SelectObject(hDC , (HPEN)hOldPen); } void CGlassMap::DrawRightAngleCross(HDC hDC, HPEN hPen, CPoint ptCenter, int nRadius) { HPEN hOldPen= NULL; HBRUSH hOldBrush = NULL; if(hPen) hOldPen = (HPEN)::SelectObject(hDC ,hPen); ::MoveToEx(hDC, ptCenter.x-nRadius, ptCenter.y, NULL); ::LineTo(hDC, ptCenter.x+nRadius, ptCenter.y); ::MoveToEx(hDC, ptCenter.x, ptCenter.y-nRadius, NULL); ::LineTo(hDC, ptCenter.x, ptCenter.y+nRadius); if(hPen) ::SelectObject(hDC , (HPEN)hOldPen); } void CGlassMap::DrawRect(HDC hDC, HPEN hPen, CRect rect) { HPEN hOldPen= NULL; HBRUSH hOldBrush = NULL; if(hPen) hOldPen = (HPEN)::SelectObject(hDC ,hPen); ::MoveToEx(hDC, rect.left, rect.top, NULL); ::LineTo(hDC, rect.right, rect.top); ::LineTo(hDC, rect.right, rect.bottom); ::LineTo(hDC, rect.left, rect.bottom); ::LineTo(hDC, rect.left, rect.top); if(hPen) ::SelectObject(hDC , (HPEN)hOldPen); } void CGlassMap::DrawGlassArea(HDC hDC) { // CornerCut ±×¸®±â. CBrush BrushCCut( RGB(150,100,255) ); // ¼¿ ¿Ü°û(BMºÎ) HBRUSH pOldBrush = (HBRUSH)::SelectObject(hDC,(HBRUSH)BrushCCut); HFONT font,pOldFont; CString str; CRect rect = m_RectWnd; rect.OffsetRect(2,2); rect.right = rect.left + 100; rect.bottom = rect.top + 20; ::FillRect(hDC,&rect,BrushCCut); font = ::CreateFont(16, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DECORATIVE, _T("±¼¸²Ã¼")); pOldFont = (HFONT) ::SelectObject(hDC, font); if(::GetTextColor(hDC) != COLOR_GLASS_PEN) ::SetTextColor(hDC, COLOR_GLASS_PEN); ::SetBkMode(hDC, TRANSPARENT); rect.OffsetRect(2,2); if(m_bTFTArea == TRUE) { str.Format(_T("Map 2")); } else { str.Format(_T("Map 1")); } ::DrawText(hDC, str, str.GetLength(), &rect, DT_CENTER | DT_VCENTER); if(pOldBrush) ::SelectObject(hDC,(HBRUSH)pOldBrush); ::DeleteObject(::SelectObject(hDC, (HFONT)pOldFont)); ::DeleteObject(font); } void CGlassMap::DrawGlass(CDC* pDC) { GetClientRect(&m_RectWnd); if (!m_pRecipe) { pDC->Rectangle(&m_RectWnd); return; } CControlMemDC memDC(pDC,&m_RectWnd); HDC hDC = memDC.GetSafeHdc(); if(m_pHardwareSetting->m_bInsDirReverse == FALSE) DrawGlassBackGround(hDC); else DrawGlassBackGroundRev(hDC); DrawGlassArea(hDC); DrawGlassPosition(hDC); DrawPointValue(hDC); DrawSplineValue(hDC); //DrawCornerXValue(hDC); //DrawCornerYValue(hDC); DrawGlassDefect(hDC); } void CGlassMap::ConvertOriginToView(int iSide,CRect &RectDefect) { CRect rect; int nSize; DimensionDir enDir = (DimensionDir)iSide; rect = RectDefect; switch(enDir) { case DIMENSION_A: case DIMENSION_A_DN: nSize = RectDefect.Height()/2; rect.top = m_rectGlass.top-nSize; rect.bottom = m_rectGlass.top+nSize; rect.left = m_rectGlass.Width()-rect.right; rect.right = rect.left+RectDefect.Width(); rect.OffsetRect(m_rectGlass.left,0); break; case DIMENSION_C: case DIMENSION_C_DN: nSize = RectDefect.Height()/2; rect.top = m_rectGlass.bottom-nSize; rect.bottom = m_rectGlass.bottom+nSize; rect.left = m_rectGlass.Width()-rect.right; rect.right = rect.left+RectDefect.Width(); rect.OffsetRect(m_rectGlass.left,0); break; case DIMENSION_B: case DIMENSION_B_DN: nSize = RectDefect.Width()/2; rect.left = m_rectGlass.right-nSize; rect.right = m_rectGlass.right+nSize; rect.top = RectDefect.top; rect.bottom = rect.top + RectDefect.Height(); rect.OffsetRect(0,m_rectGlass.top); break; case DIMENSION_D: case DIMENSION_D_DN: nSize = RectDefect.Width()/2; rect.left = m_rectGlass.left-nSize; rect.right = m_rectGlass.left+nSize; rect.top = RectDefect.top; rect.bottom = rect.top + RectDefect.Height(); rect.OffsetRect(0,m_rectGlass.top); break; } RectDefect = rect; } void CGlassMap::ConvertOriginToViewRev(int iSide,CRect &RectDefect) { CRect rect; int nSize; DimensionDir enDir = (DimensionDir)iSide; rect = RectDefect; switch(enDir) { case DIMENSION_A: case DIMENSION_A_DN: nSize = RectDefect.Height()/2; rect.top = m_rectGlass.top-nSize; rect.bottom = m_rectGlass.top+nSize; rect.left = m_rectGlass.Width()-rect.right; rect.right = rect.left+nSize; rect.OffsetRect(m_rectGlass.left,0); break; case DIMENSION_C: case DIMENSION_C_DN: nSize = RectDefect.Height()/2; rect.top = m_rectGlass.bottom-nSize; rect.bottom = m_rectGlass.bottom+nSize; rect.left = m_rectGlass.Width()-rect.right; rect.right = rect.left+nSize; rect.OffsetRect(m_rectGlass.left,0); break; case DIMENSION_B: case DIMENSION_B_DN: nSize = RectDefect.Width()/2; rect.left = m_rectGlass.left-nSize; rect.right = m_rectGlass.left+nSize; rect.top = m_rectGlass.Height() - RectDefect.right; rect.bottom = rect.top + nSize; rect.OffsetRect(0,m_rectGlass.top); break; case DIMENSION_D: case DIMENSION_D_DN: nSize = RectDefect.Width()/2; rect.left = m_rectGlass.right-nSize; rect.right = m_rectGlass.right+nSize; rect.top = m_rectGlass.Height() - RectDefect.right; rect.bottom = rect.top + nSize; rect.OffsetRect(0,m_rectGlass.top); break; } RectDefect = rect; } void CGlassMap::DrawGlassPreDefect(HDC hDC,MapDefect *pMapDefect,int iPre) { if(pMapDefect == NULL) return; ::SetBkMode(hDC,TRANSPARENT); CPen PenDefect, *pOldPen; PenDefect.CreatePen(PS_SOLID, 1, RGB(0,0,0)); pOldPen = (CPen*)::SelectObject(hDC,(HPEN)PenDefect); int nUnit = static_cast(m_nUnitSize / m_dRatio); if (nUnit == 0) nUnit = 1; int nDrawSize = 0; int nMidSize = static_cast((m_nMinDefectSize + 3) * nUnit); int nX, nY,nDefectIdx=0; // °áÇÔ ±×¸®±â. CRect RectDefect,rect; CInspectDefect* pDefect; MapDefectIt it; for (it = pMapDefect->begin(); it != pMapDefect->end(); it++,nDefectIdx++) { pDefect = static_cast(it->second); if (!pDefect) continue; // if(m_bTFTArea == TRUE && pDefect->m_nCameraID == 0) // continue; // else if(m_bTFTArea == FALSE && pDefect->m_nCameraID == 1) // continue; nX = pDefect->m_nUMOriginX; //scan nY = pDefect->m_nUMOriginY; nDrawSize = nMidSize; switch(pDefect->m_nSideLoc) { case DIMENSION_A: case DIMENSION_A_DN: case DIMENSION_C: case DIMENSION_C_DN: RectDefect.SetRect(nX - nDrawSize, nY - nDrawSize, nX + nDrawSize, nY + nDrawSize); break; case DIMENSION_B: case DIMENSION_B_DN: case DIMENSION_D: case DIMENSION_D_DN: RectDefect.SetRect(nY - nDrawSize, nX - nDrawSize, nY + nDrawSize, nX + nDrawSize); break; } //RectDefect.SetRect(nX - nDrawSize, nY - nDrawSize, nX + nDrawSize, nY + nDrawSize); ConvertGlassToView(RectDefect); if(m_pHardwareSetting->m_bInsDirReverse) ConvertOriginToViewRev(pDefect->m_sDefectLoc,RectDefect); else ConvertOriginToView(pDefect->m_sDefectLoc,RectDefect); ::SelectObject(hDC,(HBRUSH)m_BrushDefect[iPre]); ::Rectangle(hDC,RectDefect.left,RectDefect.top,RectDefect.right,RectDefect.bottom); } ::DeleteObject(::SelectObject(hDC, (HPEN)pOldPen)); ::SetBkMode(hDC,OPAQUE); } void CGlassMap::DrawGlassDefect(HDC hDC) { if(m_pMapDefect == NULL) return; ::SetBkMode(hDC,TRANSPARENT); CPen PenDefect, *pOldPen; PenDefect.CreatePen(PS_SOLID, 1, RGB(0,0,0)); pOldPen = (CPen*)::SelectObject(hDC,(HPEN)PenDefect); int nUnit = static_cast(m_nUnitSize / m_dRatio); if (nUnit == 0) nUnit = 1; int nDrawSize = 0; int nMidSize = static_cast((m_nMinDefectSize + 3) * nUnit); int nX, nY,nDefectIdx=0; // °áÇÔ ±×¸®±â. CRect RectDefect,rect; CInspectDefect* pDefect; MapDefectIt it; for (it = m_pMapDefect->begin(); it != m_pMapDefect->end(); it++,nDefectIdx++) { pDefect = static_cast(it->second); if (!pDefect) continue; if(pDefect->m_bJudgeDefect == FALSE) continue; if(m_bTFTArea == TRUE) { if((CAMERA_DIR)pDefect->m_nDir == CAMDIR_TOP) continue; } else { if((CAMERA_DIR)pDefect->m_nDir == CAMDIR_BOTTOM) continue; } if(m_pSelDefect == pDefect) continue; nX = pDefect->m_nUMOriginX; //scan nY = pDefect->m_nUMOriginY; nDrawSize = nMidSize; switch(pDefect->m_nSideLoc) { case DIMENSION_A: case DIMENSION_A_DN: case DIMENSION_C: case DIMENSION_C_DN: RectDefect.SetRect(nX - nDrawSize, nY - nDrawSize, nX + nDrawSize, nY + nDrawSize); break; case DIMENSION_B: case DIMENSION_B_DN: case DIMENSION_D: case DIMENSION_D_DN: RectDefect.SetRect(nY - nDrawSize, nX - nDrawSize, nY + nDrawSize, nX + nDrawSize); break; } ConvertGlassToView(RectDefect); if(m_pHardwareSetting->m_bInsDirReverse) ConvertOriginToViewRev(pDefect->m_nSideLoc,RectDefect); else ConvertOriginToView(pDefect->m_nSideLoc,RectDefect); switch(pDefect->m_sDefectLoc) { case DefectLoc_Crack: ::SelectObject(hDC,(HBRUSH)m_BrushDefect[0]); break; case DefectLoc_Broken: ::SelectObject(hDC,(HBRUSH)m_BrushDefect[0]); break; case DefectLoc_Chip: ::SelectObject(hDC,(HBRUSH)m_BrushDefect[0]); break; case DefectLoc_Chamfer: ::SelectObject(hDC,(HBRUSH)m_BrushDefect[3]); break; case DefectLoc_Burr: SelectObject(hDC,(HBRUSH)m_BrushDefect[0]); break; case DefectLoc_Profile: SelectObject(hDC,(HBRUSH)m_BrushDefect[2]); break; default: ::SelectObject(hDC,(HBRUSH)m_BrushDefect[0]); break; } ::Rectangle(hDC,RectDefect.left,RectDefect.top,RectDefect.right,RectDefect.bottom); } ::DeleteObject(::SelectObject(hDC, (HPEN)pOldPen)); // ¼±ÅÃµÈ °áÇÔ ±×¸®±â. for (it = m_pMapDefect->begin(); it != m_pMapDefect->end(); it++) { pDefect = static_cast(it->second); if (pDefect && m_pSelDefect && pDefect->m_nGlassDefectIdx == m_pSelDefect->m_nGlassDefectIdx) { if(pDefect->m_bJudgeDefect == FALSE) continue; int nUnit = static_cast(m_nUnitSize / m_dRatio); int nSize = static_cast((m_nMinDefectSize + 6) * nUnit); int nX, nY; CRect rt; nX = pDefect->m_nUMOriginX; //scan nY = pDefect->m_nUMOriginY; switch(pDefect->m_nSideLoc) { case DIMENSION_A: case DIMENSION_A_DN: case DIMENSION_C: case DIMENSION_C_DN: rt.SetRect(nX - nSize, nY - nSize, nX + nSize, nY + nSize); break; case DIMENSION_B: case DIMENSION_B_DN: case DIMENSION_D: case DIMENSION_D_DN: rt.SetRect(nY - nSize, nX - nSize, nY + nSize, nX + nSize); break; } CBrush pBrushBlink(RGB(0, m_nBlinkColor, 255)); ConvertGlassToView(rt); if(m_pHardwareSetting->m_bInsDirReverse) ConvertOriginToViewRev(pDefect->m_nSideLoc,rt); else ConvertOriginToView(pDefect->m_nSideLoc,rt); ::SelectObject(hDC,(HBRUSH)pBrushBlink); ::Rectangle(hDC,rt.left,rt.top,rt.right,rt.bottom); m_nBlinkColor += 20; if (m_nBlinkColor > 255) m_nBlinkColor = 0; } } ::SetBkMode(hDC,OPAQUE); } void CGlassMap::DrawRectangle(HDC hDC, CRect rectDrag, COLORREF pencolor, COLORREF brushcolor) { CPen pen,*pOldPen; CBrush brush,*pOldBrush; brush.CreateSolidBrush(brushcolor); pOldBrush = (CBrush*)::SelectObject(hDC,(HBRUSH)brush); pen.CreatePen(PS_SOLID,1,pencolor); pOldPen = (CPen*)::SelectObject(hDC,(HPEN)pen); ::SetROP2(hDC,R2_XORPEN); rectDrag.NormalizeRect(); ::Rectangle(hDC,rectDrag.left,rectDrag.top,rectDrag.right,rectDrag.bottom); if(pOldPen) ::SelectObject(hDC,(HPEN)pOldPen); if(pOldBrush) ::SelectObject(hDC,(HBRUSH)pOldBrush); ::SetROP2(hDC,R2_COPYPEN); brush.DeleteObject(); pen.DeleteObject(); } void CGlassMap::MouseLBtnMove(CPoint& point) { if(m_bZoomDrag == TRUE && m_bZoomInMode == FALSE && m_bSetZoomMode == TRUE) { m_rectZoomWindow.right = point.x; m_rectZoomWindow.bottom = point.y; Invalidate(); } } void CGlassMap::MouseLBtnUp(CPoint& point) { if(m_bZoomDrag == TRUE && m_bSetZoomMode == TRUE) { m_rectZoomWindow.right = point.x; m_rectZoomWindow.bottom = point.y; m_rectZoomWindow.NormalizeRect(); CRect rect = m_rectZoomWindow; if(abs(rect.left-rect.right) <= 1 || abs(rect.top-rect.bottom) <= 1) { m_bZoomInMode = FALSE; m_bZoomDrag = FALSE; return; } ConvertViewToGlass(rect); CalDefectRect(rect); m_rectZoomDrag = rect; double dRatio; if(abs(m_rectZoomDrag.Width()) > abs(m_rectZoomDrag.Height())) dRatio = static_cast(m_RectWnd.Width())/static_cast(m_rectZoomDrag.Width()); else dRatio = static_cast(m_RectWnd.Width())/static_cast(m_rectZoomDrag.Height()); m_dZoomRatioH = static_cast(m_RectWnd.Width())/static_cast(m_rectZoomDrag.Width()); m_dZoomRatioV = static_cast(m_RectWnd.Height())/static_cast(m_rectZoomDrag.Height()); // m_dRatio = dRatio; m_bZoomInMode = TRUE; m_bZoomDrag = FALSE; Invalidate(); } ReleaseCapture(); } void CGlassMap::MouseLBtnDwn(CPoint& point) { SetCapture(); if(m_bZoomInMode == FALSE && m_bSetZoomMode == TRUE) { m_rectZoomWindow.left = point.x; m_rectZoomWindow.top = point.y; m_bZoomDrag = TRUE; } m_pSelDefect = NULL; KillTimer(ID_TIMER_BLINK); Invalidate(FALSE); m_pSelDefect = FindSelDefect(point); if (m_pSelDefect) { if (m_pParentWnd) m_pParentWnd->PostMessage(UM_MAP_SELECTDEFECT, m_pSelDefect->m_nGlassDefectIdx, m_bTFTArea); SetTimer(ID_TIMER_BLINK, 100, NULL); } } void CGlassMap::MouseRBtnDwn(CPoint& point) { if(m_bZoomInMode == TRUE) { if (IDYES == AfxMessageBox(_T("Do you want to return to original size?"), MB_YESNO | MB_ICONQUESTION)) { ResetRatio(); m_bZoomInMode = FALSE; } } } void CGlassMap::MouseLBtnDblClk(CPoint& point) { // m_pSelDefect = NULL; // KillTimer(ID_TIMER_BLINK); // Invalidate(FALSE); // // m_pSelDefect = FindSelDefect(point); // if (m_pSelDefect) // { // if (m_pParentWnd) // m_pParentWnd->PostMessage(UM_MAP_SELECTDEFECT, m_pSelDefect->m_nGlassDefectIdx, 0); // // SetTimer(ID_TIMER_BLINK, 100, NULL); // } } CInspectDefect* CGlassMap::FindSelDefect(CPoint pt) { if (!m_pMapDefect) return NULL; int nUnit = static_cast(m_nUnitSize / m_dRatio); if (nUnit == 0) nUnit = 1; int nMidSize = static_cast((m_nMinDefectSize + 3) * nUnit); int nX, nY; CRect RectDefect,rect; int nDrawSize; CInspectDefect* pDefect; for (MapDefectIt it = m_pMapDefect->begin(); it != m_pMapDefect->end(); it++) { pDefect = static_cast(it->second); if (!pDefect) continue; // if(m_bTFTArea == TRUE && pDefect->m_nCameraID == 0) // continue; // else if(m_bTFTArea == FALSE && pDefect->m_nCameraID == 1) // continue; if(m_pSelDefect == pDefect) continue; nX = pDefect->m_nUMOriginX; //scan nY = pDefect->m_nUMOriginY; nDrawSize = nMidSize; switch(pDefect->m_nSideLoc) { case DIMENSION_A: case DIMENSION_A_DN: case DIMENSION_C: case DIMENSION_C_DN: RectDefect.SetRect(nX - nDrawSize, nY - nDrawSize, nX + nDrawSize, nY + nDrawSize); break; case DIMENSION_B: case DIMENSION_B_DN: case DIMENSION_D: case DIMENSION_D_DN: RectDefect.SetRect(nY - nDrawSize, nX - nDrawSize, nY + nDrawSize, nX + nDrawSize); break; } //RectDefect.SetRect(nX - nDrawSize, nY - nDrawSize, nX + nDrawSize, nY + nDrawSize); ConvertGlassToView(RectDefect); ConvertOriginToView(pDefect->m_sDefectLoc,RectDefect); // ¿µ¿ª ¾ÈÀÎÁö È®ÀÎ. if (pt.x >= RectDefect.left && pt.x <= RectDefect.right && pt.y >= RectDefect.top && pt.y <= RectDefect.bottom) return pDefect; } return NULL; } void CGlassMap::ZoomInDefectMap() { if (!m_bIsMiniMap && m_bSetZoomMode == TRUE) { CPoint nPoint = m_rectZoomWindow.TopLeft(); //nPoint.x -= (m_RectMap.left/m_nUnitSize); //nPoint.y -= m_RectMap.top/m_nUnitSize; if (m_OriginDir == OD_LeftTop) { m_PointWindowStart.x = static_cast(nPoint.x * m_dRatio)*-1; m_PointWindowStart.y = static_cast(nPoint.y * m_dRatio)*-1; } else if (m_OriginDir == OD_LeftBottom) { m_PointWindowStart.x = static_cast(nPoint.x * m_dRatio )*-1; m_PointWindowStart.y = static_cast((m_rectGlass.bottom-nPoint.y) * m_dRatio - m_rectGlass.Height())*-1; } else if (m_OriginDir == OD_RightTop) { m_PointWindowStart.x = static_cast((m_rectGlass.right-nPoint.x) * m_dRatio - m_rectGlass.Width())*-1; m_PointWindowStart.y = static_cast(nPoint.y * m_dRatio)*-1; } else if (m_OriginDir == OD_RightBottom) { m_PointWindowStart.x = static_cast((m_rectGlass.right-nPoint.x) * m_dRatio - m_rectGlass.Width())*-1; m_PointWindowStart.y = static_cast((m_rectGlass.bottom-nPoint.y) * m_dRatio - m_rectGlass.Height())*-1; } // ¿µ¿ªÀÌ ¹þ¾î³ªÁö ¾Êµµ·Ï ¿¹¿Üó¸®. if (m_PointWindowStart.x > 0) m_PointWindowStart.x = 0; else if (m_PointWindowStart.x < m_rectGlass.right * m_dRatio * -1 + m_rectGlass.Width()) m_PointWindowStart.x = static_cast(m_rectGlass.right * m_dRatio) * -1 + m_rectGlass.Width(); if (m_PointWindowStart.y > 0) m_PointWindowStart.y = 0; else if (m_PointWindowStart.y < m_rectGlass.bottom * m_dRatio * -1 + m_rectGlass.Height()) m_PointWindowStart.y = static_cast(m_rectGlass.bottom * m_dRatio) * -1 + m_rectGlass.Height(); m_PointGlassStart = ConvertViewToGlass(CPoint(0, 0)); m_PointGlassEnd = ConvertViewToGlass(CPoint(m_rectGlass.right, m_rectGlass.bottom)); if (m_pParentWnd) m_pParentWnd->PostMessage(UM_MAP_CHANGED, 0, 0); Invalidate(); } } void CGlassMap::Timer(UINT nIDEvent) { // if (nIDEvent == ID_TIMER_BLINK && m_pSelDefect) // { // int nUnit = static_cast(m_nUnitSize / m_dRatio); // if (nUnit == 0) // nUnit = 1; // int nSize = static_cast((m_nMinDefectSize + 5) * nUnit); // // int nX, nY; // CRect rt; // nX = m_pSelDefect->m_nUMOriginX; // nY = m_pSelDefect->m_nUMOriginY; // // rt.SetRect(nX - nSize, nY - nSize, nX + nSize, nY + nSize); // // ConvertGlassToView(rt); // ConvertOriginToView(m_pSelDefect->m_nScanIdx,rt); // // InvalidateRect(&rt, TRUE); // } } //////////////////////////////////////////////////////////////////////////