// DlgDefectMap.cpp : 구현 파일입니다.
|
//
|
|
#include "stdafx.h"
|
#include "ReviewSystem.h"
|
#include "DlgDefectMap.h"
|
#include "CHReviewSetting/SystemInfo.h"
|
|
#define ID_TIMER_SELECT_DEFECT 1500
|
//#define UM_REFRESH_DEFECT_FILTER (WM_USER + 6000)
|
|
// CDlgDefectMap 대화 상자입니다.
|
|
IMPLEMENT_DYNAMIC(CDlgDefectMap, CDialog)
|
|
#define MAX_MODULE_COUNT 4
|
|
CDlgDefectMap::CDlgDefectMap(CWnd* pParent /*=NULL*/)
|
: CDialog(CDlgDefectMap::IDD, pParent)
|
{
|
m_nProcessStatus = 0;
|
m_pDDM2P = NULL;
|
m_pDefectMap = NULL;
|
m_pDefectFilter = NULL;
|
m_pGlassResult = NULL;
|
m_bTimerColor = FALSE;
|
m_pSelectDefectResult = NULL;
|
m_nSelectedIndex = -1;
|
}
|
|
CDlgDefectMap::~CDlgDefectMap()
|
{
|
if (m_pDefectMap)
|
{
|
delete m_pDefectMap;
|
}
|
m_pDefectMap = NULL;
|
}
|
|
void CDlgDefectMap::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialog::DoDataExchange(pDX);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CDlgDefectMap, CDialog)
|
ON_MESSAGE(UM_DEFECT_FILTER_UPDATE, &CDlgDefectMap::OnDefectFilterUpdate)
|
ON_MESSAGE(UM_MOTOR_POSITION_UPDATE, &CDlgDefectMap::OnMotorPositionUpdate)
|
ON_MESSAGE(UM_PROCESS_STATUS_UPDATE, &CDlgDefectMap::OnProcessStatusUpdate)
|
ON_MESSAGE(UM_REVIEW_RESULT_UPDATE, &CDlgDefectMap::OnReviewResultUpdate)
|
ON_MESSAGE(UM_WSI_RESULT_UPDATE, &CDefectMap::OnReviewResultUpdate)//1218
|
ON_MESSAGE(UM_DBLCLK_DEFECT_MAP, &CDlgDefectMap::OnDBLCLKDefectMap)
|
ON_MESSAGE(UM_DBRCLK_DEFECT_MAP, &CDlgDefectMap::OnDBRCLKDefectMap)
|
ON_MESSAGE(UM_LBDOWN_DEFECT_MAP, &CDlgDefectMap::OnLBDOWNDefectMap)
|
ON_WM_TIMER()
|
ON_WM_ERASEBKGND()
|
ON_WM_CTLCOLOR()
|
END_MESSAGE_MAP()
|
|
|
// CDlgDefectMap 메시지 처리기입니다.
|
|
|
BOOL CDlgDefectMap::OnInitDialog()
|
{
|
CDialog::OnInitDialog();
|
|
// TODO: 여기에 추가 초기화 작업을 추가합니다.
|
CRect rect;
|
GetClientRect(rect);
|
rect.left = 0;
|
rect.top = 0;
|
rect.right = rect.left + MAP_WINDOW_SIZE_X-5;
|
rect.bottom = rect.top + MAP_WINDOW_SIZE_Y-5;
|
|
m_pDefectMap = new CDefectMap(this);
|
if (m_pDefectMap)
|
{
|
m_pDefectMap->Create(NULL, NULL, WS_CHILD | WS_VISIBLE | LBS_NOTIFY , rect, this, 0);
|
m_pDefectMap->SetGlassInfo(800000, 920000, GLASS_CORNERCUT_LEFT_TOP, GlassOriginDir_LeftTop);
|
m_pDefectMap->ShowWindow(SW_SHOW);
|
}
|
|
SMotorPosition sMotorPosition;
|
m_vecMotorPos.push_back(sMotorPosition);
|
m_vecMotorPos.resize(MAX_MODULE_COUNT);
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
}
|
|
BOOL CDlgDefectMap::PreTranslateMessage(MSG* pMsg)
|
{
|
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
|
if( pMsg->message == WM_KEYDOWN )
|
{
|
if(pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE )
|
{
|
::TranslateMessage(pMsg);
|
::DispatchMessage(pMsg);
|
return TRUE;
|
}
|
}
|
|
return CDialog::PreTranslateMessage(pMsg);
|
}
|
|
|
|
void CDlgDefectMap::UpdateProcessStatus(int nLineType, int nMachineType, int nProcessStatus, const CGlassResult* pGlassResult)
|
{
|
if (pGlassResult==NULL) return;
|
|
m_nProcessStatus = nProcessStatus;
|
|
KillTimer(ID_TIMER_SELECT_DEFECT);
|
m_pSelectDefectResult = NULL;
|
if (m_pDefectMap)
|
{
|
m_pDefectMap->SetGlassResult(pGlassResult);
|
m_pDefectMap->PostMessage(UM_UPDATE_DEFECT_MAP, NULL, NULL);
|
this->SendMessage(UM_PROCESS_STATUS_UPDATE);
|
g_pLog->DisplayMessage(_T("[DlgDefectMap] Update Defect Map!"));
|
}
|
}
|
|
LRESULT CDlgDefectMap::OnProcessStatusUpdate(WPARAM wParam, LPARAM lParam)
|
{
|
return 1;
|
}
|
|
|
void CDlgDefectMap::UpdateMotorPosition(int nModuleIndex, BOOL bSelected, const SMotorPosition* pMotorPosition)
|
{
|
if (pMotorPosition==NULL) return;
|
|
if (m_pDefectFilter==NULL) return;
|
|
if (m_pDefectFilter->pDraw[MapDrawCameraPosition]==FALSE) return;
|
|
if (nModuleIndex<0 || nModuleIndex>=m_vecMotorPos.size()) return;
|
|
/* if(m_vecMotorPos.size()-1 < nModuleIndex)
|
{
|
//m_vecMotorPos.resize(nModuleIndex+1);
|
for(int nIdx = 0; nIdx < nModuleIndex - m_vecMotorPos.size() + 1; nIdx++)
|
{
|
SMotorPosition sMotorPosition;
|
m_vecMotorPos.push_back(sMotorPosition);
|
}
|
}*/
|
|
double dDiffX = m_pDefectMap->GetScaleX() * fabs(m_vecMotorPos[nModuleIndex].dGlassPosX-pMotorPosition->dGlassPosX);
|
double dDiffY = m_pDefectMap->GetScaleY() * fabs(m_vecMotorPos[nModuleIndex].dGlassPosY-pMotorPosition->dGlassPosY);
|
|
if (bSelected)
|
m_nSelectedIndex = nModuleIndex;
|
|
m_vecMotorPos[nModuleIndex] = *pMotorPosition;
|
|
if (dDiffX>=1.0 || dDiffY>=1.0)
|
this->PostMessage(UM_MOTOR_POSITION_UPDATE, nModuleIndex);
|
}
|
|
void CDlgDefectMap::UpdateDefectFilter(const SDefectFilter* pDefectFilter)
|
{
|
if (pDefectFilter==NULL) return;
|
|
m_pDefectFilter = pDefectFilter;
|
|
this->PostMessage(UM_DEFECT_FILTER_UPDATE);
|
}
|
|
LRESULT CDlgDefectMap::OnDefectFilterUpdate(WPARAM wParam, LPARAM lParam)
|
{
|
if(m_pDefectMap && m_pDefectFilter)
|
{
|
m_pDefectMap->SetDefectFilter(m_pDefectFilter);
|
|
m_pDefectMap->PostMessage(UM_UPDATE_DEFECT_MAP, NULL, NULL);
|
}
|
|
return 0;
|
}
|
|
void CDlgDefectMap::UpdateReviewResult(int nModuleIndex, const CGlassResult* pGlassResult,int nPlanIdex)
|
{
|
if (pGlassResult==NULL) return;
|
|
m_pGlassResult = pGlassResult;
|
|
this->PostMessage(UM_REVIEW_RESULT_UPDATE, (WPARAM)nModuleIndex);
|
|
}
|
|
LRESULT CDlgDefectMap::OnReviewResultUpdate(WPARAM wParam, LPARAM lParam)
|
{
|
if(m_pDefectMap && m_pGlassResult)
|
{
|
m_pDefectMap->SetGlassResult(m_pGlassResult);
|
|
m_pDefectMap->PostMessage(UM_UPDATE_DEFECT_MAP, NULL, NULL);
|
}
|
|
return 1;
|
}
|
|
BOOL CDlgDefectMap::DestroyWindow()
|
{
|
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
|
if (m_pDefectMap)
|
{
|
m_pDefectMap->DestroyWindow();
|
}
|
|
return __super::DestroyWindow();
|
}
|
|
LRESULT CDlgDefectMap::OnMotorPositionUpdate(WPARAM wParam, LPARAM lParam)
|
{
|
int i, nCount, nPosX, nPosY;;
|
VectorInteger vectorType, vectorPosX, vectorPosY;
|
|
nCount = (int)m_vecMotorPos.size();
|
for(i = 0; i < nCount; i++)
|
{
|
nPosX = (int)(m_vecMotorPos[i].dGlassPosX*1000.);
|
nPosY = (int)(m_vecMotorPos[i].dGlassPosY*1000.);
|
vectorType.push_back(0);
|
vectorPosX.push_back(nPosX);
|
vectorPosY.push_back(nPosY);
|
|
nPosX = (int)(m_vecMotorPos[i].dWSIPosX*1000.);
|
nPosY = (int)(m_vecMotorPos[i].dWSIPosY*1000.);
|
vectorType.push_back(1);
|
vectorPosX.push_back(nPosX);
|
vectorPosY.push_back(nPosY);
|
}
|
|
m_pDefectMap->SetSelectedCameraIndex(m_nSelectedIndex);
|
m_pDefectMap->DrawCamera(vectorType, vectorPosX, vectorPosY);
|
|
return 0;
|
}
|
|
LRESULT CDlgDefectMap::OnDBLCLKDefectMap(WPARAM wParam, LPARAM lParam)
|
{
|
int nDefectPosX, nDefectPosY;
|
nDefectPosX = static_cast<int>(wParam);
|
nDefectPosY = static_cast<int>(lParam);
|
|
int nDefectMarginX = int(DEFECT_SIZE * m_pDefectMap->GetScaleX());
|
int nDefectMarginY = int(DEFECT_SIZE * m_pDefectMap->GetScaleY());
|
|
|
if(m_pDDM2P)
|
{
|
m_pDDM2P->DDM2P_SelectDefect(nDefectPosX, nDefectPosY, nDefectMarginX, nDefectMarginY);
|
}
|
|
return 0;
|
}
|
|
|
LRESULT CDlgDefectMap::OnDBRCLKDefectMap(WPARAM wParam, LPARAM lParam)
|
{
|
int nGlassPosX = static_cast<int>(wParam);
|
int nGlassPosY = static_cast<int>(lParam);
|
|
double dPosX = 0.;
|
double dPosY = 0.;
|
if(m_pDDM2P)
|
{
|
m_pDDM2P->DDM2P_MoveGlassPos(dPosX, dPosY);
|
}
|
|
return 0;
|
}
|
|
LRESULT CDlgDefectMap::OnLBDOWNDefectMap(WPARAM wParam, LPARAM lParam)
|
{
|
if (m_pDefectMap)
|
m_pDefectMap->PostMessage(UM_UPDATE_DEFECT_MAP_DEFAULT, NULL, NULL);
|
|
return 0;
|
}
|
|
void CDlgDefectMap::UpdateSelectDefectMap(CDefectResult* pDefectResult)
|
{
|
KillTimer(ID_TIMER_SELECT_DEFECT);
|
|
if(m_pSelectDefectResult)
|
{
|
// 원래 색으로 원복
|
COLORREF color;
|
|
if(m_pSelectDefectResult->bMeasurePoint)
|
{
|
color = RGB(0,0,0);
|
}
|
else
|
{
|
color = RGB(255,0,0);
|
}
|
|
m_pDefectMap->DrawDefectPoint(m_pSelectDefectResult->nUMOriginX, m_pSelectDefectResult->nUMOriginY, color);
|
}
|
|
if(pDefectResult->bMeasurePoint)
|
{
|
m_measurePoint = *pDefectResult;
|
m_pSelectDefectResult = &m_measurePoint;
|
}
|
else
|
{
|
m_pSelectDefectResult = pDefectResult;
|
}
|
|
SetTimer(ID_TIMER_SELECT_DEFECT, 100, NULL);
|
}
|
|
void CDlgDefectMap::OnTimer(UINT_PTR nIDEvent)
|
{
|
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
|
switch(nIDEvent)
|
{
|
case ID_TIMER_SELECT_DEFECT:
|
COLORREF color;
|
|
if((m_pGlassResult->GetDefectResultCount() != 0) && m_pSelectDefectResult)
|
{
|
if(m_bTimerColor)
|
{
|
color = RGB(255, 255, 255);
|
}
|
else
|
{
|
color = RGB(0, 0, 0);
|
}
|
|
m_pDefectMap->DrawDefectPoint(m_pSelectDefectResult->nUMOriginX, m_pSelectDefectResult->nUMOriginY, color);
|
m_bTimerColor = !m_bTimerColor;
|
}
|
break;
|
}
|
|
__super::OnTimer(nIDEvent);
|
}
|
|
void CDlgDefectMap::SetDefaultGlassType(const CGlassResult* pGlassResult)
|
{
|
if (m_pDefectMap)
|
{
|
m_pDefectMap->SetGlassResult(pGlassResult);
|
m_pDefectMap->PostMessage(UM_UPDATE_DEFECT_MAP, NULL, NULL);
|
}
|
}
|
|
//181203
|
BOOL CDlgDefectMap::SaveDefectMap(const CString& strPath)
|
{
|
if (m_pDefectMap==NULL || strPath.IsEmpty()) return FALSE;
|
|
return m_pDefectMap->SaveImage(strPath);
|
}
|
|
BOOL CDlgDefectMap::OnEraseBkgnd(CDC* pDC)
|
{
|
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
|
CRect rect;
|
GetClientRect(&rect);
|
__super::OnEraseBkgnd(pDC);
|
pDC->FillSolidRect(rect, RGB(38,38,38) );
|
|
return TRUE;
|
}
|
|
|
HBRUSH CDlgDefectMap::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
{
|
HBRUSH hbr = __super::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
CRect rect;
|
CString strClass = _T("");
|
UINT nID = pWnd->GetDlgCtrlID();
|
|
if(nCtlColor == CTLCOLOR_STATIC)
|
{
|
pDC->SetTextColor(RGB(255,255,255));
|
pDC->SetBkColor(RGB(38,38,38));
|
hbr = (HBRUSH)GetStockObject(NULL_BRUSH);
|
}
|
|
|
// TODO: 기본값이 적당하지 않으면 다른 브러시를 반환합니다.
|
return hbr;
|
|
|
}
|