// DlgGraph.cpp : 구현 파일입니다. // #include "stdafx.h" #include "ReviewSystem.h" #include "DlgGraph.h" // CDlgGraph 대화 상자입니다. IMPLEMENT_DYNAMIC(CDlgGraph, CDialog) CDlgGraph::CDlgGraph(CWnd* pParent /*=NULL*/) : CDialog(CDlgGraph::IDD, pParent) { m_pDG2P = NULL; m_nProcessStatus = 0; m_nGraphMode = 0; m_listGlassResult.clear(); } CDlgGraph::~CDlgGraph() { } void CDlgGraph::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_STATIC_MEASURE_GRAPH, m_ctrlMeasureGraph); } BEGIN_MESSAGE_MAP(CDlgGraph, CDialog) ON_BN_CLICKED(IDOK, &CDlgGraph::OnBnClickedOk) ON_BN_CLICKED(IDCANCEL, &CDlgGraph::OnBnClickedCancel) ON_MESSAGE(UM_PROCESS_STATUS_UPDATE, &CDlgGraph::OnProcessStatusUpdate) END_MESSAGE_MAP() // CDlgGraph 메시지 처리기입니다. void CDlgGraph::OnBnClickedOk() { // TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다. //OnOK(); } void CDlgGraph::OnBnClickedCancel() { // TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다. //OnCancel(); } BOOL CDlgGraph::OnInitDialog() { CDialog::OnInitDialog(); // TODO: 여기에 추가 초기화 작업을 추가합니다. WINDOWPLACEMENT placement; placement.rcNormalPosition.left = 1; placement.rcNormalPosition.top = 2; placement.rcNormalPosition.right = 640; placement.rcNormalPosition.bottom = 250; m_ctrlMeasureGraph.SetWindowPlacement(&placement); InitGlassGraph(); return TRUE; // return TRUE unless you set the focus to a control // 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다. } void CDlgGraph::InitGlassGraph() { CChartGlassData::Reset(); CRect rect; m_ctrlMeasureGraph.GetClientRect(rect); XYChart* pChart = new XYChart(rect.Width(), rect.Height(), 0xf8daa9, 0x000000, 1); if (pChart != NULL) { CRect rtGraphGab(50,30,20,70); // gab CRect areaRect(rtGraphGab.left, rtGraphGab.top, rect.Width()-rtGraphGab.right, rect.Height()-rtGraphGab.bottom); pChart->setPlotArea(areaRect.left, areaRect.top, areaRect.Width(), areaRect.Height(), 0xffffff, -1, -1, 0xcccccc, 0xcccccc); pChart->addLegend(areaRect.left, 2, false, "arialbd.ttf", 9)->setBackground(Chart::Transparent); int nLineWidthX = 2; int nLineWidthY = 2; char strValue[MAX_STR_LEN]; switch(m_nGraphMode) { case 0: sprintf_s(strValue, MAX_STR_LEN, "Defect Count(ea)"); break; case 1: sprintf_s(strValue, MAX_STR_LEN, "Measure Result(um)"); break; } pChart->yAxis()->setAutoScale(); pChart->yAxis()->setLabelFormat("{value}"); pChart->yAxis()->setTitle(strValue, "arialbd.ttf", 9); pChart->yAxis()->setWidth(nLineWidthY); pChart->xAxis()->setAutoScale(); pChart->xAxis()->setTitle("Glass ID", "arialbd.ttf", 9); pChart->xAxis()->setDateScale(0, double(m_nGlassCount)); pChart->xAxis()->setLabelStep(5); pChart->xAxis()->setWidth(nLineWidthX); m_ctrlMeasureGraph.setChart(pChart); delete pChart; } } void CDlgGraph::SetGraphMode(int nMode) { m_nGraphMode = nMode; } void CDlgGraph::UpdateGlassData(const CGlassResult* pGlassResult) { if (pGlassResult == NULL) return; CChartGlassData::Reset(); int nListCnt = (int)m_listGlassResult.size(); g_pLog->DisplayMessage(_T("Chart UpdateGlassData Process1")); if(nListCnt < MAX_GLASS_COUNT) { m_listGlassResult.push_back(pGlassResult); m_nGlassCount = nListCnt + 1; } else { m_listGlassResult.erase(m_listGlassResult.begin()); m_listGlassResult.push_back(pGlassResult); } g_pLog->DisplayMessage(_T("Chart UpdateGlassData Process2[%d]"), m_nGraphMode); switch(m_nGraphMode) { case 0: sprintf_s(m_szResultName[TOTAL_DEFECT], MAX_STR_LEN, "Total Defect"); sprintf_s(m_szResultName[REVIEW_DEFECT], MAX_STR_LEN, "Review Defect"); m_nResultCount = 2; break; case 1: m_nResultCount = 4; for (int i = 0; i < m_nResultCount; i++) { sprintf_s(m_szResultName[i], MAX_STR_LEN, "Result_%02d", i+1); } break; } g_pLog->DisplayMessage(_T("Chart UpdateGlassData Process3")); int nIndex = 0; if(m_listGlassResult.size() < 0 ) return; CString strLog; strLog.Format(_T("Chart UpdateGlassData Process::SetChartGlassData() before ListCnt = %d"), (int)m_listGlassResult.size()); g_pLog->DisplayMessage(strLog); for (ListGlassResultIt it=m_listGlassResult.begin(); it!=m_listGlassResult.end(); it++) { strLog.Format(_T("Chart UpdateGlassData Process::SetChartGlassData() IndexCnt = %d"), nIndex); g_pLog->DisplayMessage(strLog); SetChartGlassData(m_nGraphMode, nIndex, (*it)); nIndex++; } g_pLog->DisplayMessage(_T("Chart UpdateGlassData Process4")); } void CDlgGraph::UpdateGlassGraph() { // graph update CRect rect; m_ctrlMeasureGraph.GetClientRect(rect); const char *imageMap = 0; int nListCnt = (int)m_listGlassResult.size(); BaseChart *chart = CreateChart(m_nGraphMode, nListCnt, &imageMap, rect,1); if (chart!=NULL) { m_ctrlMeasureGraph.setChart(chart); m_ctrlMeasureGraph.setImageMap(imageMap); } delete chart; } /* Defect Map 으로 부터 Measure Point 를 클릭했을 경우, 현재 열려 있는 Recipe ID 를 기준으로 Graph 에 클릭한 Point에 대한 측정 값 흐름을 나타낸다.*/ BOOL CDlgGraph::SetMeasPoint(CString strRcpID, double dPosX, double dPosY) { if(m_listGlassResult.size() < 1) return FALSE; int nIndex = 0; int nMargin = 5000; SReviewResult* pSResult = NULL; int nReviewResultCnt = 0; double dCompX = 0, dCompY = 0; /* for (ListGlassResultIt it=m_listGlassResult.begin(); it!=m_listGlassResult.end(); it++) // Unload 시 Glass Result 값이 쌓임. { for(int i = 0; i < (*it)->m_vecReviewResult.size(); i++) { if((*it)->m_strRecipeID == strRcpID) // 클릭한 Recipe 명과 List 내에 있는 Recipe 명이 같을 경우만 검색 { nReviewResultCnt = (*it)->m_vecReviewResult[i].GetSReviewResultCount(); for(int j = 0; j < nReviewResultCnt; j++) { pSResult = const_cast(*it)->m_vecReviewResult[i].GetSReviewResult(j); dCompX = abs((double)pSResult->nUMOriginX - dPosX); dCompY = abs((double)pSResult->nUMOriginY - dPosY); if (dCompX < nMargin && dCompY < nMargin) // 유저가 Measure Defect 을 클릭한 것과 List 내의 Point 위치와 같을 경우 { CChartGlassData::SetChartGlassData(m_nGraphMode, nIndex, (*it)); nIndex++; } } } } } */ m_nResultCount = 4; for (int i=0; i 0) ? TRUE : FALSE; } void CDlgGraph::UpdateProcessStatus(int nLineType, int nMachineType, int nProcessStatus, const CGlassResult* pGlassResult) { if (pGlassResult==NULL) return; m_nProcessStatus = nProcessStatus; switch(m_nProcessStatus) { case ProcessUnloading: break; } this->PostMessage(UM_PROCESS_STATUS_UPDATE); } LRESULT CDlgGraph::OnProcessStatusUpdate(WPARAM wParam, LPARAM lParam) { return 1; }