// ViewInsInformation.cpp : ±¸Çö ÆÄÀÏÀÔ´Ï´Ù. // #include "stdafx.h" #include "ViewInsInformation.h" #include "afxdialogex.h" #include "Transfer_Data.h" #include #include using namespace Gdiplus; #define GRID_FIX_COLOR RGB(144,200,246) #define GRID_COLOR RGB(242,242,242) #define GRID_TEXT_COLOR RGB(255,255,255) #define GRID_LINE_COLOR GRID_FIX_COLOR // CViewInsInformation ´ëÈ­ »óÀÚÀÔ´Ï´Ù. IMPLEMENT_DYNAMIC(CViewInsInformation, CDialogEx) CViewInsInformation::CViewInsInformation(CWnd* pParent /*=NULL*/) : CDialogEx(CViewInsInformation::IDD, pParent) { m_pV2M = NULL; m_pGlassRecipe = NULL; m_pHardwareSetting = NULL; m_bInitView = TRUE; m_pGlassData = NULL; m_pTransData = NULL; DWORD bufsize = sizeof(BITMAPINFOHEADER)+ 256*sizeof(RGBQUAD); m_pBMI = (BITMAPINFO *)new BYTE[bufsize]; // Set Bitmap information m_pBMI->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); m_pBMI->bmiHeader.biPlanes=1; m_pBMI->bmiHeader.biBitCount=8; m_pBMI->bmiHeader.biCompression=0; //BI_RGB; m_pBMI->bmiHeader.biXPelsPerMeter=0; m_pBMI->bmiHeader.biYPelsPerMeter=0; m_pBMI->bmiHeader.biClrUsed=256; m_pBMI->bmiHeader.biClrImportant=0; // Set Palette int i; for(i=0 ; i< 256 ; i++) { m_pBMI->bmiColors[i].rgbRed = (BYTE)i; m_pBMI->bmiColors[i].rgbGreen = (BYTE)i; m_pBMI->bmiColors[i].rgbBlue = (BYTE)i; m_pBMI->bmiColors[i].rgbReserved = 0; } for(i=0;i<4;i++) { m_pSplineImg[i] = NULL; m_szSplineImg[i] = CSize(0,0); } m_pNotchImg = NULL; m_szNotchImg = CSize(0,0); m_HistoryData.Reset(); } CViewInsInformation::~CViewInsInformation() { if(m_pBMI) { delete[] m_pBMI,m_pBMI = NULL; } for(int i=0;i<4;i++) { if(m_pSplineImg[i] != NULL) delete[] m_pSplineImg[i]; m_pSplineImg[i]=NULL; } if(m_pNotchImg != NULL) delete[] m_pNotchImg; m_pNotchImg = NULL; } void CViewInsInformation::DoDataExchange(CDataExchange* pDX) { DDX_Control(pDX,IDC_STATIC_MAP_UP,m_GlassMapCF); DDX_Control(pDX,IDC_STATIC_MAP_DW,m_GlassMapTFT); DDX_Control(pDX,IDC_STATIC_RECIPE_TITLE,m_btnRecipeName); DDX_Control(pDX,IDC_STATIC_GLASSID_TITLE,m_btnGlassID); DDX_Control(pDX,IDC_STATIC_GLASSINFO_TITLE,m_btnRecipeInfo); DDX_Control(pDX,IDC_STATIC_INSINFO_EQPNO,m_btnEQPNo); DDX_Control(pDX,IDC_STATIC_INSINFO_UNITNO,m_btnUnitNo); DDX_Control(pDX,IDC_STATIC_INSINFO_ISGRIND,m_btnIsGrind); DDX_Control(pDX,IDC_STATIC_INSINFO_STAGENO,m_btnStageNo); DDX_Control(pDX,IDC_STATIC_INSINFO_ROUGHPANLAYER,m_btnRoughPadLayer); DDX_Control(pDX,IDC_STATIC_INSINFO_ROUGHPADCOUNT,m_btnRoughPadCount); DDX_Control(pDX,IDC_STATIC_INSINFO_ROUGHNPADLAYER,m_btnRoughNPadLayer); DDX_Control(pDX,IDC_STATIC_INSINFO_ROUGHNPADCOUNT,m_btnRoughNPadCount); DDX_Control(pDX,IDC_STATIC_INSINFO_ROUGHPANLAYER_2,m_btnRoughPadLayer2); DDX_Control(pDX,IDC_STATIC_INSINFO_ROUGHPADCOUNT_2,m_btnRoughPadCount2); DDX_Control(pDX,IDC_STATIC_INSINFO_ROUGHNPADLAYER_2,m_btnRoughNPadLayer2); DDX_Control(pDX,IDC_STATIC_INSINFO_ROUGHNPADCOUNT_2,m_btnRoughNPadCount2); DDX_Control(pDX,IDC_GRD_MEASURE_RESULT_A,m_GrdMeasureLine[DIMENSION_A]); DDX_Control(pDX,IDC_GRD_MEASURE_RESULT_B,m_GrdMeasureLine[DIMENSION_B]); DDX_Control(pDX,IDC_GRD_MEASURE_RESULT_C,m_GrdMeasureLine[DIMENSION_C]); DDX_Control(pDX,IDC_GRD_MEASURE_RESULT_D,m_GrdMeasureLine[DIMENSION_D]); DDX_Control(pDX,IDC_GRD_MEASURE_RESULT_A_INLINE,m_GrdMeasureLine[DIMENSION_D+1]); DDX_Control(pDX,IDC_GRD_MEASURE_RESULT_RCUT_A,m_GrdMeasureLine[DIMENSION_D+2]); DDX_Control(pDX,IDC_GRD_MEASURE_RESULT_RCUT_C,m_GrdMeasureLine[DIMENSION_D+3]); CDialogEx::DoDataExchange(pDX); } BEGIN_EVENTSINK_MAP(CViewInsInformation, CDialogEx) ON_EVENT(CViewInsInformation, IDC_BTN_INSINFO_MAPSETTINGS, DISPID_CLICK, CViewInsInformation::OnBnClickedMapSettings, VTS_NONE) END_EVENTSINK_MAP() BEGIN_MESSAGE_MAP(CViewInsInformation, CDialogEx) ON_WM_SHOWWINDOW() ON_WM_PAINT() ON_MESSAGE(UM_MAP_SELECTDEFECT, OnMapDefectSelected) ON_BN_CLICKED(IDC_STATIC_INSINFO_GRP_2, &CViewInsInformation::OnBnClickedStaticInsinfoGrp2) END_MESSAGE_MAP() BOOL CViewInsInformation::OnInitDialog(void) { CDialogEx::OnInitDialog(); Init_MeasureGrid(); Init_GlassMap(); SetControlData(); m_bNotchInspect = FALSE; ResetView(); CViewMapSettings DlgMap; DlgMap.LoadMapSettings(m_MapSettingIndex); SetGlassMapIndex(); return TRUE; } void CViewInsInformation::AddHistoryData(HISTORY_RESULT Data) { m_HistoryData = Data; Fill_MeasureGrid(); } int nGridColumnCnt[] = {PROFILE_INSPECT_SIZE_A_C,PROFILE_INSPECT_SIZE_B_D,PROFILE_INSPECT_SIZE_A_C,PROFILE_INSPECT_SIZE_B_D,PROFILE_INSPECT_SIZE_A_C,PROFILE_INSPECT_SIZE_B_D,PROFILE_INSPECT_SIZE_B_D}; TCHAR *strGrindString[]={_T("A"),_T("B"),_T("C"),_T("D"),_T("A"),_T("A"),_T("C")}; UINT eViewProfileIndex[] = {PROFILE_INSPECT_INDEX_A,PROFILE_INSPECT_INDEX_B,PROFILE_INSPECT_INDEX_C,PROFILE_INSPECT_INDEX_D,PROFILE_INSPECT_INDEX_CF,PROFILE_RCUT_INSPECT_INDEX_A,PROFILE_RCUT_INSPECT_INDEX_C}; void CViewInsInformation::Fill_MeasureGrid() { int i,index,nProfileIndex; COLORREF colorRef[] = {RGB(200,0,0),RGB(0,0,200)}; COLORREF color; CString str; int nRowIdx,iCol; CGridCellBase *pCell; LOGFONT lf; BOOL bUseColor = TRUE; if(m_pHardwareSetting != NULL) bUseColor = m_pHardwareSetting->m_bUseColorVisual; for(i=0;iGetLogFont(&lf); lf.lfItalic = 0; lf.lfHeight = 16; lf.lfWeight = FW_NORMAL; _tcscpy(lf.lfFaceName, _T("Arial")); for(index=0;indexSetTextClr(color); pCell->SetFont(&lf); } str.Format(_T("%.3f"),(double)m_HistoryData.nProfileDiff[nProfileIndex] / 1000.); m_GrdMeasureLine[i].SetItemText(nRowIdx,iCol,str); nRowIdx = 2; if(bUseColor == TRUE) color = colorRef[m_HistoryData.bChamferJudgeUp[nProfileIndex]]; else color = colorRef[1]; pCell = m_GrdMeasureLine[i].GetCell(nRowIdx,iCol); if(pCell != NULL) { pCell->SetTextClr(color); pCell->SetFont(&lf); } str.Format(_T("%.3f"),(double)m_HistoryData.nChamferThickUp[nProfileIndex]/1000.); m_GrdMeasureLine[i].SetItemText(nRowIdx,iCol,str); nRowIdx = 3; if(bUseColor == TRUE) color = colorRef[m_HistoryData.bChamferJudgeDn[nProfileIndex]]; else color = colorRef[1]; pCell = m_GrdMeasureLine[i].GetCell(nRowIdx,iCol); if(pCell != NULL) { pCell->SetTextClr(color); pCell->SetFont(&lf); } str.Format(_T("%.3f"),(double)m_HistoryData.nChamferThickDn[nProfileIndex] / 1000.); m_GrdMeasureLine[i].SetItemText(nRowIdx,iCol,str); if (i > MAX_VIEWINFO_GRD_CNT - 3 && (68 == nProfileIndex || 78 == nProfileIndex)) { color = RGB(0, 225, 0); for (int j = 1; j < 4; j++) { pCell = m_GrdMeasureLine[i].GetCell(j, iCol + 2); if (pCell != NULL) { pCell->SetTextClr(color); pCell->SetFont(&lf); } } str.Format(_T("%.3f"), m_HistoryData.nAVGProfileDiff[i + 2] / 1000.); m_GrdMeasureLine[i].SetItemText(1, iCol + 2, str); str.Format(_T("%.3f"), m_HistoryData.nAVGChamferThickUp[i + 2] / 1000.); m_GrdMeasureLine[i].SetItemText(2, iCol + 2, str); str.Format(_T("%.3f"), m_HistoryData.nAVGChamferThickDn[i + 2] / 1000.); m_GrdMeasureLine[i].SetItemText(3, iCol + 2, str); } } iCol++; color = RGB(0, 225, 0); for (int j = 1; j < 4; j++) { pCell = m_GrdMeasureLine[i].GetCell(j, iCol); if (pCell != NULL) { pCell->SetTextClr(color); pCell->SetFont(&lf); } } str.Format(_T("%.3f"), m_HistoryData.nAVGProfileDiff[i] / 1000.); m_GrdMeasureLine[i].SetItemText(1, iCol, str); str.Format(_T("%.3f"), m_HistoryData.nAVGChamferThickUp[i] / 1000.); m_GrdMeasureLine[i].SetItemText(2, iCol, str); str.Format(_T("%.3f"), m_HistoryData.nAVGChamferThickDn[i] / 1000.); m_GrdMeasureLine[i].SetItemText(3, iCol, str); } for(i=0;iSetBackClr(GRID_FIX_COLOR); // m_GrdMeasureLine[i].GetDefaultCell(FALSE, TRUE)->SetBackClr(GRID_FIX_COLOR); // m_GrdMeasureLine[i].GetDefaultCell(FALSE, FALSE)->SetBackClr(GRID_COLOR); // m_GrdMeasureLine[i].SetFixedBkColor(GRID_FIX_COLOR); m_GrdMeasureLine[i].SetGridLines(GVL_BOTH); if (i > MAX_VIEWINFO_GRD_CNT - 3) { m_GrdMeasureLine[i].SetColumnCount(nGridColumnCnt[i] + 1 + 1 + 1); } else { m_GrdMeasureLine[i].SetColumnCount(nGridColumnCnt[i] + 1 + 1); } m_GrdMeasureLine[i].SetRowCount(4); m_GrdMeasureLine[i].SetFixedRowCount(1); m_GrdMeasureLine[i].SetFixedColumnCount(1); m_GrdMeasureLine[i].ExpandToFit(); CFont *pFont = m_GrdMeasureLine[i].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_GrdMeasureLine[i].GetDefaultCell(TRUE, FALSE)->SetFont(&lf); m_GrdMeasureLine[i].GetDefaultCell(FALSE, TRUE)->SetFont(&lf); m_GrdMeasureLine[i].GetDefaultCell(TRUE, TRUE)->SetFont(&lf); m_GrdMeasureLine[i].SetEditable(FALSE); m_GrdMeasureLine[i].EnableSelection(TRUE); Init_MeasureGridHeader(&m_GrdMeasureLine[i], (nGridColumnCnt[i] + 1 + 1), strGrindString[i], eViewProfileIndex[i]); if (i > MAX_VIEWINFO_GRD_CNT - 3) { GV_ITEM Item; Item.mask = GVIF_TEXT; Item.row = 0; Item.col = nGridColumnCnt[i] + 1 + 1; Item.strText.Format(_T("AVG")); m_GrdMeasureLine[i].SetItem(&Item); m_GrdMeasureLine[i].SetColumnWidth(Item.col, 80); } } } void CViewInsInformation::Init_MeasureGridHeader(CGridCtrl *pGrid,int nCount,CString strTitle,int nLineIndex) { CString str; GV_ITEM Item; int iLoop; Item.mask = GVIF_TEXT; Item.row = 0; Item.col = 0; pGrid->SetColumnWidth(Item.col,90); for(iLoop=1;iLoopSetItem(&Item); pGrid->SetColumnWidth(Item.col,80); } Item.col = 0; Item.row = 1; Item.strText = _T("PROFILE"); pGrid->SetItem(&Item); Item.row = 2; Item.strText = _T("CHAMFER_UP"); pGrid->SetItem(&Item); Item.row = 3; Item.strText = _T("CHAMFER_DN"); pGrid->SetItem(&Item); pGrid->Invalidate(); } BOOL CViewInsInformation::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 CDialogEx::PreTranslateMessage(pMsg); } void CViewInsInformation::OnShowWindow(BOOL bShow, UINT nStatus) { if(bShow == TRUE) { //ResetView(); Invalidate(FALSE); } } void CViewInsInformation::OnPaint() { CPaintDC dc(this); // device context for painting //DrawUIControl(); int i; for(i=0;i<4;i++) { ((CWnd*)GetDlgItem(IDC_STATIC_IMG_RCUT_LEFT+i))->ShowWindow(TRUE); if(m_pSplineImg[i] == NULL || m_szSplineImg[i].cx <= 0 || m_szSplineImg[i].cy <= 0) continue; CRect crect; ((CWnd*)GetDlgItem(IDC_STATIC_IMG_RCUT_LEFT+i))->GetWindowRect(&crect); this->ScreenToClient(&crect); CControlMemDC memDC(&dc,&crect); m_pBMI->bmiHeader.biWidth=(LONG)m_szSplineImg[i].cx; m_pBMI->bmiHeader.biHeight=-(LONG)m_szSplineImg[i].cy; //::SetDIBitsToDevice(memDC.GetSafeHdc(), crect.left, crect.top, m_szSplineImg[i].cx, m_szSplineImg[i].cy, 0, 0, 0, m_szSplineImg[i].cy, m_pSplineImg[i], m_pBMI, DIB_RGB_COLORS); ::StretchDIBits(memDC.GetSafeHdc(), crect.left, crect.top, crect.Width(),crect.Height(),0, 0,m_szSplineImg[i].cx, m_szSplineImg[i].cy, (LPBYTE)m_pSplineImg[i], m_pBMI, DIB_RGB_COLORS,SRCCOPY); } } void CViewInsInformation::SetRecipe(CHardwareSettings *pHard,CGlassRecipe *pRecipe) { m_pHardwareSetting = pHard; m_pGlassRecipe = pRecipe; Refresh(); } void CViewInsInformation::Refresh() { if(m_pGlassRecipe != NULL) { m_GlassMapCF.InitGlass(this,m_pGlassRecipe->m_GlassParm.m_nGlassSizeX,m_pGlassRecipe->m_GlassParm.m_nGlassSizeY,0); m_GlassMapCF.ReCalRectDraw(); m_GlassMapCF.SetGlassRecipe(m_pHardwareSetting,m_pGlassRecipe,FALSE); m_GlassMapTFT.InitGlass(this,m_pGlassRecipe->m_GlassParm.m_nGlassSizeX,m_pGlassRecipe->m_GlassParm.m_nGlassSizeY,0); m_GlassMapTFT.ReCalRectDraw(); m_GlassMapTFT.SetGlassRecipe(m_pHardwareSetting,m_pGlassRecipe,TRUE); } DrawUIControl(); Invalidate(FALSE); } void CViewInsInformation::DrawUITitle() { CString str; if(m_pGlassRecipe != NULL) { str.Format(_T("%s"),m_pGlassRecipe->GetRecipeName()); m_btnRecipeName.SetCaption(str); str.Format(_T("%s"),m_pGlassRecipe->m_GlassParm.m_strDisp); m_btnRecipeInfo.SetCaption(str); } str.Format(_T("%s"),g_pBase->m_strHPanelID); m_btnGlassID.SetCaption(str); } void CViewInsInformation::OnBnClickedMapSettings() { CViewMapSettings DlgMapSettings; if(DlgMapSettings.DoModal() == IDOK) { m_MapSettingIndex = *DlgMapSettings.GetMapData(); SetGlassMapIndex(); m_GlassMapCF.Invalidate(); m_GlassMapTFT.Invalidate(); } } void CViewInsInformation::DrawUIControl() { DrawUITitle(); UpdateTransferData(); } void CViewInsInformation::UpdateTransferData() { if(m_pTransData == NULL) return; CTransfer_Data *pTrans = m_pTransData; CString str; str.Format(_T("%d"),pTrans->m_nEqpNo); m_btnEQPNo.SetCaption(str); str.Format(_T("%d"),pTrans->m_nUnitNo); m_btnUnitNo.SetCaption(str); str.Format(_T("%d"),pTrans->m_nisGrind); m_btnIsGrind.SetCaption(str); str.Format(_T("%d"),pTrans->m_nHandNumber); m_btnStageNo.SetCaption(str); str.Format(_T("%d"),pTrans->m_nRoughPadLayer); m_btnRoughPadLayer.SetCaption(str); str.Format(_T("%d"),pTrans->m_nRoughPadCount); m_btnRoughPadCount.SetCaption(str); str.Format(_T("%d"),pTrans->m_nRoughNonPadLayer); m_btnRoughNPadLayer.SetCaption(str); str.Format(_T("%d"),pTrans->m_nRoughNonPadCount); m_btnRoughNPadCount.SetCaption(str); str.Format(_T("%d"),pTrans->m_nPrePadLayer); m_btnRoughPadLayer2.SetCaption(str); str.Format(_T("%d"),pTrans->m_nPrePadCount); m_btnRoughPadCount2.SetCaption(str); str.Format(_T("%d"),pTrans->m_nPreNonPadLayer); m_btnRoughNPadLayer2.SetCaption(str); str.Format(_T("%d"),pTrans->m_nPreNonPadCount); m_btnRoughNPadCount2.SetCaption(str); // g_pBase¿¡´Â ÀÌÀü ±Û¶ó½º µ¥ÀÌÅͰ¡ µé¾îÀÖ³×.. ±×·¡¼­ ÃÖ±Ù ¹°·ùµ¥ÀÌÅÍ ¹ÞÀº°É·Î ¹Ù²Þ str.Format(_T("%s"),pTrans->m_strHPANELID); m_btnGlassID.SetCaption(str); } CGlassMap *CViewInsInformation::GetDefectMap(BOOL bTFT) { if(bTFT ==TRUE) return &m_GlassMapTFT; else return &m_GlassMapCF; } void CViewInsInformation::SetGlassMapIndex() { m_GlassMapCF.SetMapIndex(m_MapSettingIndex.m_nMapIndex[0]); m_GlassMapTFT.SetMapIndex(m_MapSettingIndex.m_nMapIndex[1]); } void CViewInsInformation::Init_GlassMap() { m_GlassMapTFT.InitGlass(GetParent(),0,0,0); m_GlassMapCF.InitGlass(GetParent(),0,0,0); m_GlassMapCF.SetOtherGlassMapPtr(&m_GlassMapTFT); m_GlassMapTFT.SetOtherGlassMapPtr(&m_GlassMapCF); } void CViewInsInformation::ResetView() { m_GlassMapTFT.SetGlasssize(0,0.); m_GlassMapTFT.SetGlasssize(1,0.); m_GlassMapCF.SetGlasssize(0,0.); m_GlassMapCF.SetGlasssize(1,0.); SetSplineImg(NULL,CSize(0,0),INSPECTSPLINE_BUFFER::SPLINE_TOPLEFT); SetSplineImg(NULL,CSize(0,0),INSPECTSPLINE_BUFFER::SPLINE_TOPRIGHT); SetSplineImg(NULL,CSize(0,0),INSPECTSPLINE_BUFFER::SPLINE_BOTTOMLEFT); SetSplineImg(NULL,CSize(0,0),INSPECTSPLINE_BUFFER::SPLINE_BOTTOMRIGHT); m_bInitView = TRUE; DrawUIControl(); m_HistoryData.Reset(); Fill_MeasureGrid(); } void CViewInsInformation::DrawMapRefresh() { m_GlassMapTFT.SetDrawMapRefresh(); m_GlassMapCF.SetDrawMapRefresh(); } void CViewInsInformation::SetTransferData(CTransfer_Data *pTrans) { m_pTransData = pTrans; UpdateTransferData(); } void CViewInsInformation::SetGlassSize(int nIdx,double dValue) { m_GlassMapTFT.SetGlasssize(nIdx,dValue); m_GlassMapCF.SetGlasssize(nIdx,dValue); } void CViewInsInformation::SetDefect(MapDefect* pMapDefect) { m_GlassMapTFT.DrawDefects(pMapDefect,m_pGlassData); m_GlassMapCF.DrawDefects(pMapDefect,m_pGlassData); m_bInitView = FALSE; Invalidate(FALSE); } void CViewInsInformation::SetControlData() { m_FontControl.SetFont(this,IDC_STATIC_INSINFO_GRP_1,CFontControl::EN_SUBFONT); m_FontControl.SetFont(this,IDC_STATIC_INSINFO_GRP_2,CFontControl::EN_SUBFONT); } void CViewInsInformation::SetCutAreaPointData(CAMERA_DIR Camdir,DimensionDir emDir,double *dValue,double dAvgVal) { if(Camdir == CAMDIR_TOP) { m_GlassMapCF.SetPointCutData(emDir,dValue,dAvgVal); } else { m_GlassMapTFT.SetPointCutData(emDir,dValue,dAvgVal); } } void CViewInsInformation::SetDimenPointData(CAMERA_DIR Camdir,DimensionDir emDir ,double *dValue,double dAvgVal) { m_GlassMapCF.SetPointDimenData(emDir,dValue,dAvgVal); m_GlassMapTFT.SetPointDimenData(emDir,dValue,dAvgVal); } void CViewInsInformation::SetSplineData(Disp_SplineLocation enDir,double dValue) { m_GlassMapTFT.SetSplineData(enDir,dValue); m_GlassMapCF.SetSplineData(enDir,dValue); } void CViewInsInformation::SetCornerXData(Disp_SplineLocation enDir,double dValue) { m_GlassMapTFT.SetCornerXData(enDir,dValue); m_GlassMapCF.SetCornerXData(enDir,dValue); } void CViewInsInformation::SetCornerYData(Disp_SplineLocation enDir,double dValue) { m_GlassMapTFT.SetCornerYData(enDir,dValue); m_GlassMapCF.SetCornerYData(enDir,dValue); } LRESULT CViewInsInformation::OnMapDefectSelected(WPARAM wParam, LPARAM lParam) { int iDefect = static_cast(wParam); BOOL bTFT = static_cast(lParam); if(bTFT == TRUE) m_GlassMapTFT.SetSelectDefect(iDefect); else m_GlassMapCF.SetSelectDefect(iDefect); return 0; } BOOL CViewInsInformation::SetSplineImg(LPBYTE pImg,CSize szImg,int iPosition) { BYTE **pSplineImg = NULL; CSize *szSpline; BOOL bFlip=FALSE; BOOL bLeftRight = FALSE; int nIndex = 0; nIndex = iPosition; switch (iPosition) { case INSPECTSPLINE_BUFFER::SPLINE_TOPLEFT: break; case INSPECTSPLINE_BUFFER::SPLINE_TOPRIGHT: bLeftRight = TRUE; bFlip = TRUE; break; case INSPECTSPLINE_BUFFER::SPLINE_BOTTOMLEFT: bFlip = FALSE; break; case INSPECTSPLINE_BUFFER::SPLINE_BOTTOMRIGHT: bFlip = TRUE; bLeftRight = TRUE; break; default: return FALSE; } pSplineImg = &m_pSplineImg[nIndex]; szSpline = &m_szSplineImg[nIndex]; if(*pSplineImg != NULL) delete[] *pSplineImg,*pSplineImg=NULL; CRect crect; ((CWnd*)GetDlgItem(IDC_STATIC_IMG_RCUT_LEFT))->GetWindowRect(&crect); if(pImg == NULL || szImg.cx <= 0 || szImg.cy <= 0) { *pSplineImg = new BYTE[crect.Width()*crect.Height()]; *szSpline = CSize(crect.Width(),crect.Height()); ZeroMemory(*pSplineImg,sizeof(BYTE)*crect.Width()*crect.Height()); return FALSE; } double dScale; CSize szScale; int nSize = min(szImg.cx,szImg.cy); dScale = (double)crect.Width()/(double)nSize; szScale.cx = szScale.cy = align_4byte((int)((double)nSize*dScale)); if(szScale.cx <= 0 || szScale.cy <= 0) { *pSplineImg = new BYTE[crect.Width()*crect.Height()]; *szSpline = CSize(crect.Width(),crect.Height()); ZeroMemory(*pSplineImg,sizeof(BYTE)*crect.Width()*crect.Height()); return FALSE; } if(dScale > 0 && dScale < 1) { *pSplineImg = new BYTE[szScale.cx*szScale.cy]; ZeroMemory(*pSplineImg,sizeof(BYTE)*szScale.cx*szScale.cy); *szSpline = szScale; ShrinkImage(pImg,szImg.cx,szImg.cy,*pSplineImg,szScale.cx,szScale.cy,dScale); } else if(dScale >= 1) { *pSplineImg = new BYTE[szImg.cx*szImg.cy]; CopyMemory(*pSplineImg,pImg,sizeof(BYTE)*szImg.cx*szImg.cy); *szSpline=szImg; // 22.06.13 bug.... szScale = szImg; } if(bFlip == TRUE) FlipImage(*pSplineImg,szScale); if(bLeftRight == TRUE) ChangeLeftRight(*pSplineImg,szScale); return TRUE; } BOOL CViewInsInformation::FlipImage(LPBYTE pImg,CSize szImg) { if(pImg == NULL || szImg.cx <= 0 || szImg.cy <= 0) return FALSE; LPBYTE pTgt = new BYTE[szImg.cx*szImg.cy]; int v,iPos; iPos = 0; for(v=szImg.cy-1;v>=0;v--,iPos++) { CopyMemory(&pTgt[iPos*szImg.cx], &pImg[v*szImg.cx], szImg.cx); } CopyMemory(pImg,pTgt, szImg.cx*szImg.cy); delete[] pTgt,pTgt=NULL; return TRUE; } BOOL CViewInsInformation::ChangeLeftRight(LPBYTE pImg,CSize szImg) { if(pImg == NULL || szImg.cx <= 0 || szImg.cy <= 0) return FALSE; LPBYTE pTgt = new BYTE[szImg.cx*szImg.cy]; int v,u,iPos; for(v=0;v=0;u--,iPos++) pTgt[v*szImg.cx+iPos] = pImg[v*szImg.cx+u]; } CopyMemory(pImg,pTgt,szImg.cx*szImg.cy); delete[] pTgt,pTgt=NULL; return TRUE; } BOOL CViewInsInformation::RotateImage(LPBYTE pImg,CSize szImg) { if(pImg == NULL || szImg.cx <= 0 || szImg.cy <= 0) return FALSE; if(szImg.cx != szImg.cy) return TRUE; LPBYTE pTgt = new BYTE[szImg.cx*szImg.cy]; int v,u; for(u=0;u= 1 || scale <= 0) return; double dFactor = 1 / scale; double dXEnd = -dFactor / 2; int nXStart, nXEnd = -1; for (int nX = 0; nX < wDestWidth; nX++) { int nYStart, nYEnd = -1; double dYEnd = -dFactor / 2; nXStart = nXEnd + 1; dXEnd += dFactor; nXEnd = CHKMIN(wSrcWidth - 1, (int)dXEnd + 1); if (nXStart > nXEnd || nXEnd >= wSrcWidth) continue; for (int nY = 0; nY < wDestHeight; nY++) { nYStart = nYEnd + 1; dYEnd += dFactor; nYEnd = CHKMIN(wSrcHeight - 1, (int)dYEnd + 1); if (nYStart > nYEnd || nYEnd >= wSrcHeight) continue; int nCount = 0, nVal = 0; // average the pixels over the range for (int nXSub = nXStart; nXSub <= nXEnd; nXSub++) { for (int nYSub = nYStart; nYSub <= nYEnd; nYSub++) { nVal += pInBuff[nYSub * wSrcWidth + nXSub]; nCount++; } } if(nCount > 0) pOutBuff[nY * wDestWidth + nX] = nVal/nCount; } } return; } BOOL CViewInsInformation::SetNotchImg( LPBYTE pImg,CSize szImg,int bPosDir) { return TRUE; } void CViewInsInformation::OnBnClickedStaticInsinfoGrp2() { // TODO: ¿©±â¿¡ ÄÁÆ®·Ñ ¾Ë¸² 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù. }