SDC C-Project CF Review 프로그램
LYW
2021-07-08 9cbd9e554f9956b3b945b51602f1d4a3fa0353e1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
// 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<CGlassResult*>(*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<m_nResultCount; i++)
    {
        sprintf_s(m_szResultName[i], MAX_STR_LEN, "Result_%02d", i+1);
    }
    return (nIndex > 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;
}