// DlgDefectInfo.cpp: 구현 파일
|
//
|
|
#include "stdafx.h"
|
#include "ReviewSystem.h"
|
#include "DlgDefectInfo.h"
|
#include "MainFrm.h"
|
#include <algorithm>
|
|
|
// CDlgDefectInfo 대화 상자
|
|
IMPLEMENT_DYNAMIC(CDlgDefectInfo, CDialog)
|
|
CDlgDefectInfo::CDlgDefectInfo(CWnd* pParent /*=nullptr*/)
|
: CDialog(IDD_DLG_TAB_DEFECT_INFO, pParent)
|
, m_DefectIdx(0)
|
, m_dDefectReviewPosX(0)
|
, m_dDefectReviewPosY(0)
|
, m_dDefectAoiPosX(0)
|
, m_dDefectAoiPosY(0)
|
, m_dDefectSizeType(_T(""))
|
, m_dDefectArea(0)
|
, m_dDefectSacnIdx(0)
|
, m_dDefectCamIdx(0)
|
, m_dDefectAOIFileName(_T(""))
|
{
|
|
}
|
|
CDlgDefectInfo::~CDlgDefectInfo()
|
{
|
|
}
|
|
void CDlgDefectInfo::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialog::DoDataExchange(pDX);
|
DDX_Text(pDX, IDC_EDIT1, m_DefectIdx);
|
DDX_Text(pDX, IDC_EDIT5, m_dDefectReviewPosX);
|
DDX_Text(pDX, IDC_EDIT6, m_dDefectReviewPosY);
|
DDX_Text(pDX, IDC_EDIT7, m_dDefectAoiPosX);
|
DDX_Text(pDX, IDC_EDIT8, m_dDefectAoiPosY);
|
DDX_Text(pDX, IDC_EDIT10, m_dDefectSizeType);
|
DDX_Text(pDX, IDC_EDIT11, m_dDefectArea);
|
DDX_Text(pDX, IDC_EDIT14, m_dDefectSacnIdx);
|
DDX_Text(pDX, IDC_EDIT12, m_dDefectCamIdx);
|
DDX_Text(pDX, IDC_EDIT13, m_dDefectAOIFileName);
|
DDX_Control(pDX, IDC_PICTURECTRL, m_PictureControl_AOI);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CDlgDefectInfo, CDialog)
|
ON_WM_TIMER()
|
END_MESSAGE_MAP()
|
|
|
// CDlgDefectInfo 메시지 처리기
|
BOOL CDlgDefectInfo::OnInitDialog()
|
{
|
CDialog::OnInitDialog();
|
GetDlgItem(IDC_PICTURECTRL)->GetWindowRect(m_picture_rect);
|
|
ScreenToClient(m_picture_rect);
|
SetIcon(m_hIcon, TRUE);
|
SetIcon(m_hIcon, FALSE);
|
|
//SetTimer(1000, 10, NULL);
|
return TRUE;
|
|
}
|
|
|
HCURSOR CDlgDefectInfo::OnQueryDragIcon()
|
{
|
return static_cast<HCURSOR>(m_hIcon);
|
}
|
|
void CDlgDefectInfo::SetDefectImage(int nIndex)
|
{
|
//Defect index 넘버에 따라서 다른 이미지를 불러 온다.
|
Invalidate(TRUE);
|
CPaintDC dc(this);
|
|
m_DefectImage.Destroy();
|
|
if (pDefectInfo != NULL)
|
{
|
return;
|
}
|
|
CString DeftectPath;
|
CFileStatus FileOn;
|
TCHAR chFilePath[256] = { 0, };
|
GetModuleFileName(NULL, chFilePath, 256);
|
CString strFolderPath(chFilePath);
|
strFolderPath = strFolderPath.Left(strFolderPath.ReverseFind('\\'));
|
|
if(!pDefectInfo->strInspectImgFileName)
|
{
|
return;
|
}
|
if (!pDefectInfo->strGlassID)
|
{
|
return;
|
}
|
|
DeftectPath.Format(_T("\\\\126.100.100.1\\D\\Image\\Defect\\%s\\%s"), pDefectInfo->strGlassID, pDefectInfo->strInspectImgFileName);
|
|
if (CFile::GetStatus(DeftectPath, FileOn) && pDefectInfo->strInspectImgFileName != "") //파일이 있을 때
|
{
|
|
m_DefectImage.Load(DeftectPath);
|
HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), strFolderPath,
|
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
|
|
|
InvalidateRect(m_picture_rect, FALSE);
|
dc.SetStretchBltMode(COLORONCOLOR);
|
m_DefectImage.Draw(dc, m_picture_rect);
|
|
}
|
else //파일이 없을 때.. 노 이미지 파일로 보여준다
|
{
|
strFolderPath = strFolderPath + "\\no-image.png";
|
m_DefectImage.Load(strFolderPath);
|
HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), strFolderPath,
|
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
|
|
|
InvalidateRect(m_picture_rect, FALSE);
|
dc.SetStretchBltMode(COLORONCOLOR);
|
m_DefectImage.Draw(dc, m_picture_rect);
|
|
}
|
|
if (pDefectInfo != NULL)
|
{
|
|
m_DefectIdx = pDefectInfo->nDefectIdx;
|
m_dDefectReviewPosX = pDefectInfo->nUMOriginX;
|
m_dDefectReviewPosY = pDefectInfo->nUMOriginY;
|
m_dDefectAoiPosX = pDefectInfo->dUMCenterOriginX;
|
m_dDefectAoiPosY = pDefectInfo->dUMCenterOriginY;
|
m_dDefectSizeType = pDefectInfo->strSizeType;
|
m_dDefectArea = pDefectInfo->nAOIArea;
|
m_dDefectSacnIdx = pDefectInfo->nAOIScanIdx;
|
m_dDefectCamIdx = pDefectInfo->nAOICameraIdx;
|
m_dDefectAOIFileName = pDefectInfo->strInspectImgFileName;
|
|
}
|
|
UpdateData(FALSE);
|
/* Invalidate(FALSE);*/
|
}
|
|
void CDlgDefectInfo::UpdateSelectDefectMap(CDefectResult* pDefectResult)
|
{
|
SetDefectIndexInfo(pDefectResult->nDefectIdx);
|
pDefectInfo = pDefectResult;
|
SetDefectImage(GetDefectIndex());
|
Invalidate(FALSE);
|
}
|
|
void CDlgDefectInfo::SetDefectIndexInfo(int nIndex)
|
{
|
m_nDefectIndex = nIndex;
|
}
|
|
void CDlgDefectInfo::DrawnoImage()
|
{
|
CPaintDC dc(this);
|
|
m_DefectImage.Destroy();
|
|
CString DeftectPath;
|
CFileStatus FileOn;
|
TCHAR chFilePath[256] = { 0, };
|
GetModuleFileName(NULL, chFilePath, 256);
|
CString strFolderPath(chFilePath);
|
//strFolderPath = chFilePath;
|
strFolderPath = strFolderPath.Left(strFolderPath.ReverseFind('\\'));
|
|
strFolderPath = strFolderPath + "\\no-image.png";
|
//strFolderPath = strFolderPath + "\\1.bmp";
|
m_DefectImage.Load(strFolderPath);
|
//m_DefectImage.Draw(dc, 30, 80, m_DefectImage.GetWidth(), m_DefectImage.GetHeight());
|
HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), strFolderPath,
|
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
|
|
|
InvalidateRect(m_picture_rect, FALSE);
|
dc.SetStretchBltMode(COLORONCOLOR);
|
m_DefectImage.Draw(dc, m_picture_rect);
|
|
}
|
|
void CDlgDefectInfo::OnTimer(UINT_PTR nIDEvent)
|
{
|
Invalidate(TRUE);
|
if(nIDEvent){
|
if (pDefectInfo != NULL)
|
{
|
KillTimer(nIDEvent);
|
//SetDefectImage(pDefectInfo->nDefectIdx);
|
//SetTimer(nIDEvent, 500, NULL);
|
}
|
else
|
{
|
KillTimer(nIDEvent);
|
//DrawnoImage();
|
//SetTimer(nIDEvent, 500, NULL);
|
|
}
|
}
|
}
|