// D:\01.WORK\Project\02. 2012\05. Edge Grinding\Source\RCut_Project\RecipeEditor\Dialog\DlgSettingGlass.cpp : ±¸Çö ÆÄÀÏÀÔ´Ï´Ù.
|
//
|
|
#include "stdafx.h"
|
#include "ViewSettingSpline.h"
|
|
|
const int SPLINE_COLUMN_COUNT = 9;
|
const char* SPLINE_COLUMN_ITEM[SPLINE_COLUMN_COUNT] = {"No","Use","Ins.Dir","Start X","End X","Line Thres","Defect Thres","Skip Dist","Ins.Range"};
|
const int SPLINE_COLUMN_WIDTH[SPLINE_COLUMN_COUNT] = {60,74,74,74,74,74,84,74,74};
|
|
// CViewSettingSpline ´ëÈ »óÀÚÀÔ´Ï´Ù.
|
|
IMPLEMENT_DYNAMIC(CViewSettingSpline, CDialog)
|
|
CViewSettingSpline::CViewSettingSpline(CWnd* pParent /*=NULL*/)
|
: CDialog(CViewSettingSpline::IDD, pParent)
|
{
|
m_pHardwareSetting = NULL;
|
m_pGlassRecipe = NULL;
|
m_DlgGlassRecipe.Reset();
|
m_pMainView = NULL;
|
m_nCutListIdx = 0;
|
m_index = 0;
|
}
|
|
CViewSettingSpline::~CViewSettingSpline()
|
{
|
if(m_pMainView != NULL)
|
{
|
m_pMainView=NULL;
|
}
|
}
|
|
void CViewSettingSpline::DoDataExchange(CDataExchange* pDX)
|
{
|
CSPLINE_PARM *pSpline = m_DlgGlassRecipe.m_InspectInfoParm.GetSplineParm();
|
|
//STU_SPLINE_INS_PARM
|
DDX_Check(pDX,IDC_CHECK_USE_SPLINE,pSpline->GetSplineIns(m_index)->m_bSpline);
|
|
DDX_Text(pDX,IDC_EDIT_SPLINE_START_CORNER_R_RADIUS, pSpline->GetSplineIns(m_index)->m_nStartCornerRadius_um);
|
DDX_Text(pDX,IDC_EDIT_SPLINE_START_CORNER_R_SIZE_Y, pSpline->GetSplineIns(m_index)->m_nStartCornerSize_Y);
|
DDX_Text(pDX,IDC_EDIT_SPLINE_END_CORNER_R_RADIUS, pSpline->GetSplineIns(m_index)->m_nEndCornerRadius_um);
|
DDX_Text(pDX,IDC_EDIT_SPLINE_END_CORNER_R_SIZE_Y, pSpline->GetSplineIns(m_index)->m_nEndCornerSize_Y);
|
|
DDX_Text(pDX,IDC_EDIT_START_CHAMFER_SIZE,pSpline->GetSplineIns(m_index)->m_nStartChamferSize);
|
DDX_Text(pDX,IDC_EDIT_END_CHAMFER_SIZE,pSpline->GetSplineIns(m_index)->m_nEndChamferSize);
|
|
DDX_Text(pDX,IDC_EDIT_SPLINE_JUDGE_DIST,pSpline->GetSplineIns(m_index)->m_DetMinDist);
|
DDX_Text(pDX,IDC_EDIT_SPLINE_LINE_THRES,pSpline->GetSplineIns(m_index)->m_nLineThres);
|
DDX_Control(pDX, IDC_CBO_SPLINE_TYPE, m_cboComp);
|
|
DDX_Control(pDX,IDC_SPLINE_LIST,m_ListSplinePos);
|
|
DDX_Check(pDX,IDC_CHECK_USE_SPLINE2,pSpline->GetSplineIns(m_index)->m_bSplineCorner);
|
|
DDX_Check(pDX,IDC_CHECK_USE_SPLINECHIP,pSpline->GetSplineChipIns(m_index)->m_bSplineChip);
|
DDX_Text(pDX,IDC_EDIT_SPLINE_CHIPSIZE_Y,pSpline->GetSplineChipIns(m_index)->m_nChipSize_Y);
|
DDX_Text(pDX,IDC_EDIT_SPLINE_CHIPSIZE_X,pSpline->GetSplineChipIns(m_index)->m_nChipSize_X);
|
DDX_Text(pDX,IDC_EDIT_SPLINE_CHIPINSAREA,pSpline->GetSplineChipIns(m_index)->m_nChipInsArea);
|
DDX_Text(pDX,IDC_EDIT_SPLINE_CHIPTHRES_TOP,pSpline->GetSplineChipIns(m_index)->m_nChipThres);
|
DDX_Check(pDX,IDC_CHECK_USE_SP_COR_USE,pSpline->GetSplineChipIns(m_index)->m_bCornerUse);
|
DDX_Text(pDX,IDC_EDIT_SPLINE_COR_THRES,pSpline->GetSplineChipIns(m_index)->m_nCornerThres);
|
DDX_Text(pDX,IDC_EDIT_SPLINE_COR_RANGE,pSpline->GetSplineChipIns(m_index)->m_nCornerRange);
|
DDX_Text(pDX,IDC_EDIT_SPLINE_CHIP_START_THETA,pSpline->GetSplineChipIns(m_index)->m_dChipStartTheta);
|
DDX_Text(pDX,IDC_EDIT_SPLINE_CHIP_END_THETA,pSpline->GetSplineChipIns(m_index)->m_dChipEndTheta);
|
DDX_Text(pDX,IDC_EDIT_SPLINE_CHIP_DIST_THETA,pSpline->GetSplineChipIns(m_index)->m_dChipDistTheta);
|
|
DDX_Control(pDX, IDC_CHECK_SPLINE_CHIP_AND, m_ctrlJudgeAnd);
|
|
CDialog::DoDataExchange(pDX);
|
}
|
|
BEGIN_MESSAGE_MAP(CViewSettingSpline, CDialog)
|
ON_WM_SHOWWINDOW()
|
ON_CONTROL_RANGE(BN_CLICKED,IDC_BUT_SPLINE_IMAGE_MINUS,IDC_BUT_SPLINE_IMAGE_PLUS,OnBnClickZoomMode)
|
ON_WM_PAINT()
|
ON_BN_CLICKED(IDC_BUT_SPLINE_FINDLINE, &CViewSettingSpline::OnBnClickedButSplineFindline)
|
ON_BN_CLICKED(IDC_BUT_SPLINE_ORGIMAGE, &CViewSettingSpline::OnBnClickedButSplineOrgimage)
|
ON_BN_CLICKED(IDC_CHECK_USE_SPLINE,OnClickUseSpline)
|
ON_BN_CLICKED(IDC_CHECK_USE_SPLINE2,OnClickUseSpline2)
|
ON_BN_CLICKED(IDC_BUT_ADD_SPLINE_CHIP, &CViewSettingSpline::OnBnClickedButAddSplineChip)
|
ON_BN_CLICKED(IDC_BUT_DEL_SPLINE_CHIP, &CViewSettingSpline::OnBnClickedButDelSplineChip)
|
ON_BN_CLICKED(IDC_BUT_SPLINE_LOAD, &CViewSettingSpline::OnBnClickedButSplineLoad)
|
ON_BN_CLICKED(IDC_BUT_SPLINE_SELECTLINE, &CViewSettingSpline::OnBnClickedButSplineSelectline)
|
ON_BN_CLICKED(IDC_BUT_SPLINE_FINALFIND, &CViewSettingSpline::OnBnClickedButSplineFinalfind)
|
ON_BN_CLICKED(IDC_BUT_SPLINE_SAVE_RCUT_MASTER, &CViewSettingSpline::OnBnClickedButSplineSaveRcutMaster)
|
ON_BN_CLICKED(IDC_BUT_SPLINE_READ_MASTER, &CViewSettingSpline::OnBnClickedButSplineReadMaster)
|
ON_BN_CLICKED(IDC_BUT_SPLINE_INSPECTION, &CViewSettingSpline::OnBnClickedButSplineInspection)
|
ON_BN_CLICKED(IDC_BUT_SPLINE_READ_MASTER_C, &CViewSettingSpline::OnBnClickedButSplineReadMasterC)
|
ON_NOTIFY(NM_CLICK, IDC_SPLINE_LIST, OnListSplineClick)
|
ON_BN_CLICKED(IDC_CHECK_USE_SPLINECHIP, &CViewSettingSpline::OnBnClickedCheckUseSplinechip)
|
ON_BN_CLICKED(IDC_CHECK_USE_SP_COR_USE, &CViewSettingSpline::OnBnClickedCheckUseSplinechip)
|
END_MESSAGE_MAP()
|
|
BEGIN_EVENTSINK_MAP(CViewSettingSpline, CDialog)
|
ON_EVENT(CViewSettingSpline, IDC_CHECK_SPLINE_CHIP_AND, DISPID_CLICK, CViewSettingSpline::ClickChkJudgeAndButton, VTS_NONE)
|
ON_EVENT(CViewSettingSpline, IDC_BTN_SPLINE_OK, DISPID_CLICK, CViewSettingSpline::ClickBtnSplineOk, VTS_NONE)
|
ON_EVENT(CViewSettingSpline, IDC_BTN_SPLINE_CANCEL, DISPID_CLICK, CViewSettingSpline::ClickBtnSplineCancel, VTS_NONE)
|
END_EVENTSINK_MAP()
|
|
BOOL CViewSettingSpline::OnInitDialog()
|
{
|
CDialog::OnInitDialog();
|
|
InitImageControl();
|
|
SetControl();
|
|
Init_Grid();
|
|
return TRUE; // Æ÷Ä¿½º¸¦ ÄÁÆ®·Ñ¿¡ ¼³Á¤ÇÏÁö ¾ÊÀ¸¸é TRUE¸¦ ¹ÝȯÇÕ´Ï´Ù.
|
}
|
|
BOOL CViewSettingSpline::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 CDialog::PreTranslateMessage(pMsg);
|
}
|
|
void CViewSettingSpline::OnShowWindow(BOOL bShow, UINT nStatus)
|
{
|
if(bShow == TRUE)
|
{
|
UpDateSplineData(TRUE);
|
FillGrid(TRUE);
|
SetEnControl();
|
}
|
else
|
{
|
UpdateDlgData();
|
GetParent()->PostMessage(UM_UPDATE_RECIPE,EM_SPLINE_RCP,NULL);
|
}
|
}
|
|
void CViewSettingSpline::SetRecipe(CHardwareSettings *pHard,CGlassRecipe *pRecipe)
|
{
|
m_pHardwareSetting = pHard;
|
m_pGlassRecipe = pRecipe;
|
|
if(m_pGlassRecipe != NULL)
|
{
|
m_DlgGlassRecipe = *m_pGlassRecipe;
|
}
|
|
UpDateSplineData(TRUE);
|
UpdateData(FALSE);
|
SetEnControl();
|
FillGrid(TRUE);
|
|
CSPLINE_PARM *pSpline = m_DlgGlassRecipe.m_InspectInfoParm.GetSplineParm();
|
|
m_ctrlJudgeAnd.SetValue(!pSpline->GetSplineChipIns(m_index)->m_bChipJudgeAnd);
|
}
|
|
void CViewSettingSpline::ClickChkJudgeAndButton()
|
{
|
UINT nID = GetFocus()->GetDlgCtrlID();
|
|
if (m_ctrlJudgeAnd.GetEnabled() != FALSE) {
|
m_ctrlJudgeAnd.SetEnabled(FALSE);
|
}
|
|
CSPLINE_PARM *pSpline = m_DlgGlassRecipe.m_InspectInfoParm.GetSplineParm();
|
|
pSpline->GetSplineChipIns(m_index)->m_bChipJudgeAnd = !m_ctrlJudgeAnd.GetValue();
|
|
if (m_ctrlJudgeAnd.GetEnabled() != TRUE) {
|
m_ctrlJudgeAnd.SetEnabled(TRUE);
|
}
|
}
|
|
void CViewSettingSpline::UpDateSplineData(BOOL bWrite)
|
{
|
CSPLINE_PARM *pSpline = m_DlgGlassRecipe.m_InspectInfoParm.GetSplineParm();
|
|
if(bWrite == FALSE)
|
{
|
// if(pSpline->GetSplineIns(m_index)->m_bSpline == TRUE)
|
// m_pGlassRecipe->m_GlassParm.m_GlassInsSetting[m_index].emSplineInsType = SP_INS_RCUT;
|
// else if(pSpline->GetSplineIns(m_index)->m_bSplineCorner= TRUE)
|
// m_pGlassRecipe->m_GlassParm.m_GlassInsSetting[m_index].emSplineInsType = SP_INS_CORNER;
|
|
//pSpline->GetSplineIns(m_index)->m_emSPType = (EM_SPLINE_TYPE)m_cboComp.GetCurSel();
|
pSpline->GetSplineIns(m_index)->m_emSPType = EM_SP_RCUT;
|
}
|
else
|
{
|
// if(m_pGlassRecipe->m_GlassParm.m_GlassInsSetting[m_index].emSplineInsType == SP_INS_RCUT)
|
// pSpline->GetSplineIns(m_index)->m_bSpline = TRUE;
|
// else if(m_pGlassRecipe->m_GlassParm.m_GlassInsSetting[m_index].emSplineInsType == SP_INS_CORNER)
|
// pSpline->GetSplineIns(m_index)->m_bSplineCorner = TRUE;
|
|
m_cboComp.SetCurSel((int)pSpline->GetSplineIns(m_index)->m_emSPType);
|
UpdateData(FALSE);
|
}
|
}
|
|
void CViewSettingSpline::UpdateDlgData()
|
{
|
UpdateData(TRUE);
|
UpDateSplineData(FALSE);
|
FillGrid(FALSE);
|
|
if(m_pGlassRecipe != NULL)
|
{
|
m_pGlassRecipe->m_InspectInfoParm.m_SplineParm.m_SP_InsParm[m_index] = m_DlgGlassRecipe.m_InspectInfoParm.m_SplineParm.m_SP_InsParm[m_index];
|
m_pGlassRecipe->m_InspectInfoParm.m_SplineParm.m_vecSplineChip[m_index] = m_DlgGlassRecipe.m_InspectInfoParm.m_SplineParm.m_vecSplineChip[m_index];
|
m_pGlassRecipe->m_InspectInfoParm.m_SplineParm.m_SP_ChipParm[m_index] = m_DlgGlassRecipe.m_InspectInfoParm.m_SplineParm.m_SP_ChipParm[m_index];
|
}
|
}
|
|
void CViewSettingSpline::SetControl()
|
{
|
|
}
|
|
void CViewSettingSpline::InitImageControl()
|
{
|
CRect crect;
|
CSize sizeTotal;
|
((CWnd*)GetDlgItem(IDC_SPLINE_IMAGE))->GetWindowRect(&crect);
|
ScreenToClient(&crect);
|
|
m_pMainView = new CSlimScrollView;
|
m_pMainView->Create(NULL, NULL, WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL, crect, this, IDC_SPLINE_IMAGE, NULL);
|
sizeTotal = CSize(2048,1024);
|
m_pMainView->SetScrollSizes(MM_TEXT, sizeTotal);
|
m_pMainView->InitGDI(sizeTotal.cx,sizeTotal.cy,FALSE);
|
m_pMainView->SetOrgImgSize(sizeTotal.cx,sizeTotal.cy);
|
m_pMainView->SetHWnd(this);
|
m_pMainView->SetSendMessage(FALSE);
|
m_pMainView->SetDrawRect(FALSE);
|
m_pMainView->SetZoomMode(TRUE);
|
}
|
|
// CViewSettingSpline ¸Þ½ÃÁö 󸮱âÀÔ´Ï´Ù.
|
|
void CViewSettingSpline::OnBnClickedButSplineLoad()
|
{
|
CString strFileName,strpath;
|
|
strpath.Format(_T("D:\\Image\\scanimage\\*.bmp"));
|
|
// file select
|
CFileDialog filedlg( TRUE, _T("*.bmp"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Image file (*.bmp)|*.bmp|"), NULL );
|
if(IDCANCEL == filedlg.DoModal())
|
return;
|
|
strFileName = filedlg.GetPathName();
|
if(m_ImageMain.ReadFromFile(strFileName) == FALSE)
|
{
|
AfxMessageBox(_T("À̹ÌÁö ÆÄÀÏ ÀÐ±â ½ÇÆÐ!"));
|
return;
|
}
|
/*
|
strFileName = _T("D:\\Image\\test.bmp");
|
CBufferAttach attach(strFileName);
|
attach.AttachToFile(m_ImageMain);
|
*/
|
|
ShowMainImage();
|
}
|
|
void CViewSettingSpline::ShowMainImage()
|
{
|
if(m_ImageMain.IsValidBuffer() == FALSE || m_pMainView == NULL)
|
{
|
m_pMainView->ReleaseMemory();
|
m_pMainView->SetZoomMode(FALSE);
|
m_pMainView->InitGDI(2048,1024,FALSE);
|
m_pMainView->SetOrgImgSize(2048,1024);
|
m_pMainView->SetZoomMode(TRUE);
|
m_pMainView->SetDrawRect(FALSE);
|
m_pMainView->Invalidate(FALSE);
|
return;
|
}
|
|
m_pMainView->ReleaseMemory();
|
m_pMainView->SetZoomMode(FALSE);
|
m_pMainView->InitGDI(m_ImageMain.GetDataWidth(),m_ImageMain.GetHeight(),FALSE);
|
m_pMainView->SetOrgImgSize(m_ImageMain.GetDataWidth(),m_ImageMain.GetHeight());
|
m_pMainView->SetDrawRect(FALSE);
|
m_pMainView->SetZoomMode(TRUE);
|
|
BYTE* pTgtBuf = m_pMainView->GetBuffer();
|
if(pTgtBuf == NULL)
|
{
|
return;
|
}
|
CopyMemory(pTgtBuf,m_ImageMain.GetDataAddress(0,0),m_ImageMain.GetDataWidth()*m_ImageMain.GetHeight());
|
|
m_pMainView->SetScrollSizes(MM_TEXT, CSize(m_ImageMain.GetDataWidth(),m_ImageMain.GetHeight()));
|
m_pMainView->Invalidate(FALSE);
|
}
|
|
void CViewSettingSpline::OnBnClickZoomMode(UINT nID)
|
{
|
if(m_pMainView == NULL)
|
return;
|
|
int nCommand = nID-IDC_BUT_SPLINE_IMAGE_MINUS;
|
|
m_pMainView->SetZoomMode(TRUE);
|
switch(nCommand)
|
{
|
case 0: m_pMainView->SetMode(SLIM_MODE_ZOOMOUT); break;
|
case 1: m_pMainView->SetMode(SLIM_MODE_NORMAL); break;
|
case 2: m_pMainView->SetMode(SLIM_MODE_ZOOMIN); break;
|
}
|
}
|
void CViewSettingSpline::OnPaint()
|
{
|
CPaintDC dc(this); // device context for painting
|
|
CGeneralDraw pDraw;
|
|
CUIPictureControl uiTitle_1;
|
|
uiTitle_1.SetItemDefault(this,IDC_SPLINE_TITLE_1);
|
uiTitle_1.m_strData.Format(_T("Image Master Processing"));
|
uiTitle_1.m_FontOffset = CPoint(4,2);
|
pDraw.DrawPitureControl(uiTitle_1);
|
}
|
|
void CViewSettingSpline::OnBnClickedButSplineFindline()
|
{
|
if(m_ImageMain.IsValidBuffer() == FALSE || m_pMainView == NULL)
|
return;
|
|
BYTE* pTgtBuf = m_pMainView->GetBuffer();
|
if(pTgtBuf == NULL)
|
{
|
return;
|
}
|
CopyMemory(pTgtBuf,m_ImageMain.GetDataAddress(0,0),m_ImageMain.GetWidth()*m_ImageMain.GetHeight());
|
|
LPBYTE lpImg = m_pMainView->GetBuffer();
|
CSize szImg = m_pMainView->GetOrgImgSize();
|
CRect rect(0,0,szImg.cx,szImg.cy);
|
|
if(lpImg == NULL)
|
return;
|
|
CSPLINE_PARM *pSpline = m_DlgGlassRecipe.m_InspectInfoParm.GetSplineParm();
|
|
UpdateData(TRUE);
|
|
// CGlassFind glassFind;
|
// glassFind.CannyEdgeProcessing(lpImg,rect,GM_Sobel,pSpline->m_FindThres[0]);
|
// glassFind.ThresholdProcessing(lpImg,szImg,85,0);
|
|
/*CString strFile = "D:\\Image\\CannyEdge.bmp";
|
CBufferAttach attach(strFile);
|
CSISBuffer mosis(lpImg,szImg.cx,szImg.cy);
|
attach.AttachToFile(mosis);*/
|
|
m_pMainView->SetDrawRect(FALSE);
|
m_pMainView->Invalidate(FALSE);
|
}
|
|
void CViewSettingSpline::OnBnClickedButSplineSelectline()
|
{
|
m_pMainView->SetDrawRect(TRUE);
|
}
|
|
void CViewSettingSpline::OnBnClickedButSplineFinalfind()
|
{
|
LPBYTE lpImg = m_pMainView->GetBuffer();
|
CSize szImg = m_pMainView->GetOrgImgSize();
|
|
if(lpImg == NULL)
|
return;
|
|
const int nOffset = 2;
|
CSISBuffer lpOrg(lpImg,szImg.cx,szImg.cy);
|
CRect rect(nOffset,nOffset,szImg.cx-nOffset,szImg.cy-nOffset);
|
|
int nWidth = align_4byte(rect.Width());
|
rect.right = rect.left + nWidth;
|
|
COwnerBuffer lpBuffer(rect.Width(),rect.Height());
|
|
lpBuffer.CopyBtoA(lpBuffer,0,0,lpOrg,rect);
|
|
CSplineInspect pLabeling(&lpBuffer);
|
|
if(pLabeling.FindCADLine() == TRUE)
|
{
|
std::multimap<int, CSplinePoint> *pPoint = pLabeling.GetSplinePos();
|
if(pPoint != NULL)
|
{
|
m_pMainView->SetSplinePosition(pPoint,pLabeling.GetSplineOffset());
|
}
|
}
|
|
m_pMainView->Invalidate(FALSE);
|
}
|
|
void CViewSettingSpline::OnBnClickedButSplineSaveRcutMaster()
|
{
|
CString strFile;
|
std::multimap<int, CSplinePoint> *pPoint;
|
CPoint pointOffset;
|
|
CString strSplineType;
|
CString strFileExtension;
|
CString strCutName;
|
CString strSide;
|
|
switch((DimensionDir)m_index)
|
{
|
case DIMENSION_A:
|
case DIMENSION_A_DN:
|
strSide = _T("A");
|
break;
|
case DIMENSION_B:
|
case DIMENSION_B_DN:
|
strSide = _T("B");
|
break;
|
case DIMENSION_C:
|
case DIMENSION_C_DN:
|
strSide = _T("C");
|
break;
|
case DIMENSION_D:
|
case DIMENSION_D_DN:
|
strSide = _T("D");
|
break;
|
}
|
|
// switch(m_cboComp.GetCurSel())
|
// {
|
// case 0: strSplineType = _T("CCUT"); strFileExtension = _T("ccut"); strCutName = _T("CCut"); break;
|
// case 1: strSplineType = _T("RCUT"); strFileExtension = _T("rcut"); strCutName = _T("RCut"); break;
|
// }
|
|
strSplineType = _T("RCUT");
|
strFileExtension = _T("rcut");
|
strCutName = _T("RCut");
|
|
CString strTemp;
|
strTemp.Format(_T("%s Save as Master Data?"),strSplineType);
|
|
pPoint = m_pMainView->GetSplinePos();
|
pointOffset = m_pMainView->GetSplineOffset();
|
|
if(pPoint != NULL && (int)pPoint->size() > 0)
|
{
|
if(IDNO == AfxMessageBox(strTemp, MB_YESNO | MB_ICONQUESTION))
|
return;
|
}
|
else
|
{
|
AfxMessageBox(_T("No Data."));
|
}
|
|
CSplineInspect pLabeling;
|
strFile.Format(_T("C:\\RCutProject\\Spline\\%s_%s_%s.%s"),m_pGlassRecipe->GetRecipeName(),strSplineType,strSide,strFileExtension);
|
/*
|
if(pLabeling.WriteModelData(strFile,m_pGlassRecipe->GetRecipeName(),strCutName,pPoint,pointOffset) == TRUE)
|
{
|
CString strMsg;
|
|
strMsg.Format(_T("%s Save Success."),strFile);
|
|
strFile.Format(_T("C:\\RCutProject\\Spline\\%s_%s_%s.bmp"),m_pGlassRecipe->GetRecipeName(),strSplineType,strSide);
|
CBufferAttach attach(strFile);
|
attach.AttachToFile(m_ImageMain);
|
|
AfxMessageBox(strMsg);
|
}
|
else
|
{
|
AfxMessageBox(_T("No Data."));
|
}
|
*/
|
}
|
|
void CViewSettingSpline::OnBnClickedButSplineSaveCcutMaster()
|
{
|
CString strFile;
|
std::multimap<int, CSplinePoint> *pPoint;
|
CPoint pointOffset;
|
|
pPoint = m_pMainView->GetSplinePos();
|
pointOffset = m_pMainView->GetSplineOffset();
|
|
if(pPoint != NULL && (int)pPoint->size() > 0)
|
{
|
if(IDNO == AfxMessageBox(_T("C-Cut Save as Master Data?"), MB_YESNO | MB_ICONQUESTION))
|
return;
|
}
|
else
|
{
|
AfxMessageBox(_T("No Data."));
|
}
|
|
CSplineInspect pLabeling;
|
strFile.Format(_T("C:\\RCutProject\\Spline\\%s_CCUT.ccut"),m_pGlassRecipe->GetRecipeName());
|
/*
|
if(pLabeling.WriteModelData(strFile,m_pGlassRecipe->GetRecipeName(),_T("CCut"),pPoint,pointOffset) == TRUE)
|
{
|
CString strMsg;
|
|
strMsg.Format(_T("%s Save Success."),strFile);
|
|
strFile.Format(_T("C:\\RCutProject\\Spline\\%s_CCUT.bmp"),m_pGlassRecipe->GetRecipeName());
|
CBufferAttach attach(strFile);
|
attach.AttachToFile(m_ImageMain);
|
|
AfxMessageBox(strMsg);
|
}
|
else
|
{
|
AfxMessageBox(_T("No Data."));
|
}
|
*/
|
}
|
|
void CViewSettingSpline::OnBnClickedButSplineOrgimage()
|
{
|
ShowMainImage();
|
}
|
|
void CViewSettingSpline::OnClickUseSpline()
|
{
|
UpdateData(TRUE);
|
|
CSPLINE_PARM *pSpline = m_DlgGlassRecipe.m_InspectInfoParm.GetSplineParm();
|
|
pSpline->GetSplineIns(m_index)->m_bSplineCorner = FALSE;
|
|
UpdateData(FALSE);
|
|
SetEnControl();
|
}
|
|
void CViewSettingSpline::OnClickUseSpline2()
|
{
|
UpdateData(TRUE);
|
|
CSPLINE_PARM *pSpline = m_DlgGlassRecipe.m_InspectInfoParm.GetSplineParm();
|
|
pSpline->GetSplineIns(m_index)->m_bSpline = FALSE;
|
|
UpdateData(FALSE);
|
|
SetEnControl();
|
}
|
|
void CViewSettingSpline::SetEnControl()
|
{
|
return;
|
|
CSPLINE_PARM *pSpline = m_DlgGlassRecipe.m_InspectInfoParm.GetSplineParm();
|
|
((CWnd*)GetDlgItem(IDC_EDIT_SPLINE_YPOS))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline);
|
((CWnd*)GetDlgItem(IDC_EDIT_SPLINE_JUDGE_DIST))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline);
|
((CWnd*)GetDlgItem(IDC_EDIT_SPLINE_LINE_THRES))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline);
|
((CWnd*)GetDlgItem(IDC_SPLINE_LIST))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline);
|
((CWnd*)GetDlgItem(IDC_CBO_SPLINE_TYPE))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline);
|
|
((CWnd*)GetDlgItem(IDC_BUT_ADD_SPLINE_CHIP))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline);
|
((CWnd*)GetDlgItem(IDC_BUT_DEL_SPLINE_CHIP))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline);
|
((CWnd*)GetDlgItem(IDC_BUT_SPLINE_LOAD))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline);
|
((CWnd*)GetDlgItem(IDC_BUT_SPLINE_SELECTLINE))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline);
|
((CWnd*)GetDlgItem(IDC_BUT_SPLINE_FINALFIND))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline);
|
((CWnd*)GetDlgItem(IDC_BUT_SPLINE_SAVE_RCUT_MASTER))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline);
|
|
if(pSpline->GetSplineIns(m_index)->m_bSpline == FALSE)
|
{
|
pSpline->GetSplineChipIns(m_index)->m_bSplineChip = FALSE;
|
pSpline->GetSplineChipIns(m_index)->m_bCornerUse = FALSE;
|
}
|
|
if(pSpline->GetSplineChipIns(m_index)->m_bSplineChip == FALSE)
|
{
|
pSpline->GetSplineChipIns(m_index)->m_bCornerUse = FALSE;
|
}
|
|
((CWnd*)GetDlgItem(IDC_CHECK_USE_SPLINECHIP))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline);
|
//((CWnd*)GetDlgItem(IDC_EDIT_SPLINE_CHIPSIZE))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline&&pSpline->GetSplineChipIns(m_index)->m_bSplineChip);
|
((CWnd*)GetDlgItem(IDC_EDIT_SPLINE_CHIPINSAREA))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline&&pSpline->GetSplineChipIns(m_index)->m_bSplineChip);
|
((CWnd*)GetDlgItem(IDC_EDIT_SPLINE_CHIPTHRES_TOP))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline&&pSpline->GetSplineChipIns(m_index)->m_bSplineChip);
|
((CWnd*)GetDlgItem(IDC_CHECK_USE_SP_COR_USE))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline&&pSpline->GetSplineChipIns(m_index)->m_bSplineChip);
|
((CWnd*)GetDlgItem(IDC_EDIT_SPLINE_COR_THRES))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline&&pSpline->GetSplineChipIns(m_index)->m_bSplineChip&&pSpline->GetSplineChipIns(m_index)->m_bCornerUse);
|
((CWnd*)GetDlgItem(IDC_EDIT_SPLINE_COR_RANGE))->EnableWindow(pSpline->GetSplineIns(m_index)->m_bSpline&&pSpline->GetSplineChipIns(m_index)->m_bSplineChip&&pSpline->GetSplineChipIns(m_index)->m_bCornerUse);
|
UpdateData(FALSE);
|
}
|
|
void CViewSettingSpline::OnBnClickedButSplineReadMaster()
|
{
|
CString strFile;
|
|
strFile.Format(_T("C:\\RCutProject\\Spline\\%s_RCUT.rcut"),m_pGlassRecipe->GetRecipeName());
|
// if(m_pProcessLabel.ReadModelData(strFile,m_pGlassRecipe->GetRecipeName()) == TRUE)
|
// AfxMessageBox(_T("Read Success"));
|
}
|
|
void CViewSettingSpline::OnBnClickedButSplineInspection()
|
{
|
/*
|
UpdateData(TRUE);
|
|
CGlassFind glassfind;
|
CSPLINE_PARM *pSpline = &m_DlgGlassRecipe.m_SplineParm;
|
CETC_PARM *pEtc = &m_DlgGlassRecipe.m_ETCParm;
|
CCUTAREA_PARM *pCut = &m_DlgGlassRecipe.m_CutAreaParm;
|
CRect rect;
|
int nLeftLine;
|
|
rect.left = 0;
|
rect.right = rect.left + pEtc->m_nGlassFindWidth_Left;
|
rect.top = m_ImageMain.GetHeight()-100;
|
rect.bottom = m_ImageMain.GetHeight();
|
nLeftLine = (int)glassfind.FindGlassHorizontalLine(m_ImageMain.GetDataAddress(0,0),CSize(m_ImageMain.GetDataWidth(),m_ImageMain.GetHeight()),rect,pEtc->m_nGlassFindthres_Left,TRUE);
|
if(nLeftLine <= 0)
|
return;
|
|
double dResult[3];
|
SPLINE_ERR_MSG enMsg;
|
COwnerBuffer pOrg,pBin,pRes;
|
enMsg = m_pProcessLabel.InspectSpline("HpanelID","Cut",0,0,0,m_ImageMain,pSpline->m_FindThres[0],pSpline->m_DetMinDist,nLeftLine,0,dResult,pCut->m_bChipping
|
,pCut->m_nChippingInsArea,pCut->m_nChippingThres,pOrg,pBin,pRes,0);
|
|
int nVCnt;
|
CSISBuffer *pInspectImg = m_pProcessLabel.GetInspectImage(nVCnt);
|
|
glassfind.SetGlassScanRecipe(CSize(pInspectImg->GetDataWidth(),nVCnt),pCut->m_bCutArea,FALSE,50,pCut->m_nCutAreaDiff/10,pCut->m_nCutAreaDiff/10
|
,10,10,0,0,10);
|
|
rect = CRect(0,0,pInspectImg->GetDataWidth(),nVCnt);
|
|
COwnerBuffer pInsOrg,pInsBin,pInsRes,pChipLeft,pChipRight;
|
glassfind.Inspection(pInspectImg->GetDataAddress(0,0),rect,0,0,pInsOrg,pInsBin,pInsRes,pChipLeft,pChipRight,*pInspectImg,FALSE,20,pCut->m_nChippingThres,FALSE);
|
|
std::vector<CChipBlob> *pResult = glassfind.GetBlobResult();
|
if((int)pResult->size() > 0)
|
{
|
|
}
|
|
CString strFile,strFolder;
|
|
strFolder.Format("D:\\Image\\Spline");
|
CreateDirectory(strFolder,NULL);
|
|
strFile.Format("%s\\Spline_Org[%.3f].bmp",strFolder,dResult[2]);
|
CBufferAttach attachOrg(strFile);
|
attachOrg.AttachToFile(pOrg);
|
|
strFile.Format("%s\\Spline_Tgt[%.3f].bmp",strFolder,dResult[2]);
|
CBufferAttach attachBin(strFile);
|
attachBin.AttachToFile(pBin);
|
|
strFile.Format("%s\\Spline_Res[%.3f].bmp",strFolder,dResult[2]);
|
CBufferAttach attachRes(strFile);
|
attachRes.AttachToFile(pRes);
|
|
strFile.Format("%s\\Spline_InsOrg.bmp",strFolder);
|
CBufferAttach attach1(strFile);
|
attach1.AttachToFile(pInsOrg);
|
|
strFile.Format("%s\\Spline_InsBin.bmp",strFolder);
|
CBufferAttach attach2(strFile);
|
attach2.AttachToFile(pInsBin);
|
|
strFile.Format("%s\\Spline_InsRes.bmp",strFolder);
|
CBufferAttach attach3(strFile);
|
attach3.AttachToFile(pInsRes);
|
|
strFile.Format("%s\\Spline_ChipLeft.bmp",strFolder);
|
CBufferAttach attach4(strFile);
|
attach4.AttachToFile(pChipLeft);
|
|
strFile.Format("%s\\Spline_ChipRight.bmp",strFolder);
|
CBufferAttach attach5(strFile);
|
attach5.AttachToFile(pChipRight);
|
|
CString str;
|
if(enMsg == SPLINE_INS_SUCESS)
|
{
|
str.Format("¼º°ø : min[%.2f],max[%.2f],avg[%.2f],avgThick[%.3f]",dResult[0],dResult[1],dResult[2],glassfind.GetAvgThick());
|
AfxMessageBox(str);
|
}
|
else
|
{
|
switch(enMsg)
|
{
|
case ERR_SPLINE_EMPTYMASTER: str = "Master ¾øÀ½"; break;
|
case ERR_SPLINE_EDGEPROCESS: str = "Edge ¿¡·¯"; break;
|
case ERR_SPLINE_LABELPROCESS: str = "Label ¿¡·¯"; break;
|
case ERR_SPLINE_LABELCOUNT: str = "Label Count ¿¡·¯"; break;
|
case ERR_SPLINE_INDEXFIND: str = "Max Index Find ¿¡·¯"; break;
|
case ERR_SPLINE_LABELPOSITION: str = "Label Position ¿¡·¯"; break;
|
case ERR_SPLINE_POSITIONNULL: str = "Position Null"; break;
|
case ERR_SPLINE_INS_CNT_SHORT: str = "line Count ºÎÁ·"; break;
|
default: str = "Error"; break;
|
}
|
|
AfxMessageBox(str);
|
}
|
*/
|
}
|
|
void CViewSettingSpline::OnBnClickedButSplineReadMasterC()
|
{
|
CString strFile;
|
|
strFile.Format(_T("C:\\RCutProject\\Spline\\%s_CCUT.ccut"),m_pGlassRecipe->GetRecipeName());
|
// if(m_pProcessLabel.ReadModelData(strFile,m_pGlassRecipe->GetRecipeName()) == TRUE)
|
// AfxMessageBox(_T("Read Success"));
|
}
|
|
|
void CViewSettingSpline::Init_Grid()
|
{
|
if(m_ListSplinePos.GetSafeHwnd() == NULL)
|
return;
|
|
m_ListSplinePos.GetDefaultCell(FALSE, FALSE)->SetBackClr(RGB(0xFF, 0xFF, 0xE0));
|
m_ListSplinePos.SetGridLines(GVL_BOTH);
|
|
m_ListSplinePos.SetColumnCount(SPLINE_COLUMN_COUNT);
|
m_ListSplinePos.SetRowCount(10);
|
m_ListSplinePos.SetFixedRowCount(1);
|
m_ListSplinePos.SetFixedColumnCount(0);
|
//m_ListSplinePos.ExpandColumnsToFit();
|
|
CFont *pFont = m_ListSplinePos.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_ListSplinePos.GetDefaultCell(TRUE, FALSE)->SetFont(&lf);
|
m_ListSplinePos.GetDefaultCell(FALSE, TRUE)->SetFont(&lf);
|
m_ListSplinePos.GetDefaultCell(TRUE, TRUE)->SetFont(&lf);
|
m_ListSplinePos.SetEditable(TRUE);
|
m_ListSplinePos.EnableSelection(TRUE);
|
|
Init_GridHeader();
|
}
|
|
void CViewSettingSpline::Init_GridHeader()
|
{
|
CString str;
|
GV_ITEM Item;
|
int nCol = 0;
|
int iLoop;
|
|
Item.mask = GVIF_TEXT;
|
Item.row = 0;
|
for(iLoop=0;iLoop<SPLINE_COLUMN_COUNT;iLoop++)
|
{
|
Item.col = nCol++;
|
Item.strText = SPLINE_COLUMN_ITEM[iLoop];
|
m_ListSplinePos.SetItem(&Item);
|
m_ListSplinePos.SetColumnWidth(Item.col,SPLINE_COLUMN_WIDTH[iLoop]);
|
}
|
|
m_ListSplinePos.Invalidate();
|
}
|
|
void CViewSettingSpline::FillGrid(BOOL bWrite)
|
{
|
CSPLINE_PARM *pParm = m_DlgGlassRecipe.m_InspectInfoParm.GetSplineParm();
|
std::vector<STU_SPLINE_CHIP_POS>::iterator it;
|
CString str;
|
int nCol = 0, nRow;
|
int iLoop;
|
STU_SPLINE_CHIP_POS stPos;
|
const TCHAR* SET_USE_TYPE[2] = {_T("No Use"),_T("Use")};
|
const TCHAR* SET_INS_DIR[3] = {_T("X"),_T("Y"),_T("None")};
|
CStringArray optUse,optIns;
|
CGridCellCombo *pCell;
|
|
for(iLoop=0;iLoop<2;iLoop++)
|
{
|
optUse.Add(SET_USE_TYPE[iLoop]);
|
}
|
|
for(iLoop=0;iLoop<3;iLoop++)
|
{
|
optIns.Add(SET_INS_DIR[iLoop]);
|
}
|
|
if(bWrite == TRUE)
|
{
|
iLoop = 1;
|
m_ListSplinePos.SetRowCount((int)pParm->m_vecSplineChip[m_index].size()+1);
|
for(it=pParm->m_vecSplineChip[m_index].begin();it!=pParm->m_vecSplineChip[m_index].end();it++,iLoop++)
|
{
|
stPos = *it;
|
|
nCol = 0;
|
nRow = iLoop;
|
str.Format(_T("%d"),nRow);
|
m_ListSplinePos.SetItemText(nRow,nCol,str);
|
nCol++;
|
|
if (!m_ListSplinePos.SetCellType(nRow,nCol, RUNTIME_CLASS(CGridCellCombo)))
|
continue;
|
|
if(stPos.bUse == TRUE)
|
str.Format(_T("%s"),SET_USE_TYPE[1]);
|
else
|
str.Format(_T("%s"),SET_USE_TYPE[0]);
|
m_ListSplinePos.SetItemText(nRow,nCol,str);
|
|
pCell = (CGridCellCombo*) m_ListSplinePos.GetCell(nRow,nCol);
|
pCell->SetOptions(optUse);
|
pCell->SetStyle(CBS_DROPDOWN);
|
nCol++;
|
|
if (!m_ListSplinePos.SetCellType(nRow,nCol, RUNTIME_CLASS(CGridCellCombo)))
|
continue;
|
|
str.Format(_T("%s"),SET_INS_DIR[stPos.emDir]);
|
m_ListSplinePos.SetItemText(nRow,nCol,str);
|
|
pCell = (CGridCellCombo*) m_ListSplinePos.GetCell(nRow,nCol);
|
pCell->SetOptions(optIns);
|
pCell->SetStyle(CBS_DROPDOWN);
|
nCol++;
|
|
str.Format(_T("%d"),stPos.nStartX);
|
m_ListSplinePos.SetItemText(nRow,nCol,str);
|
nCol++;
|
|
str.Format(_T("%d"),stPos.nEndX);
|
m_ListSplinePos.SetItemText(nRow,nCol,str);
|
nCol++;
|
|
str.Format(_T("%d"),stPos.nThres);
|
m_ListSplinePos.SetItemText(nRow,nCol,str);
|
nCol++;
|
|
str.Format(_T("%d"),stPos.nFindThres);
|
m_ListSplinePos.SetItemText(nRow,nCol,str);
|
nCol++;
|
|
str.Format(_T("%d"),stPos.nSkipDist);
|
m_ListSplinePos.SetItemText(nRow,nCol,str);
|
nCol++;
|
|
str.Format(_T("%d"),stPos.nInsRange);
|
m_ListSplinePos.SetItemText(nRow,nCol,str);
|
nCol++;
|
|
}
|
m_ListSplinePos.Invalidate();
|
}
|
else
|
{
|
pParm->m_vecSplineChip[m_index].clear();
|
int nRowCnt = m_ListSplinePos.GetRowCount();
|
for(iLoop=1;iLoop<nRowCnt;iLoop++)
|
{
|
nCol = 1;
|
nRow = iLoop;
|
|
stPos.emPos = STU_SPLINE_CHIP_POS::MAKE_IMAGE_POS_RCUT;
|
|
str = m_ListSplinePos.GetItemText(nRow,nCol);
|
stPos.bUse = FALSE;
|
for(int i=0;i<optUse.GetCount();i++)
|
{
|
if(str.CollateNoCase(optUse.GetAt(i)) == 0)
|
{
|
stPos.bUse = (BOOL)i;
|
break;
|
}
|
}
|
nCol++;
|
|
str = m_ListSplinePos.GetItemText(nRow,nCol);
|
stPos.emDir = STU_SPLINE_CHIP_POS::SPLINE_INS_DIRECTION_NONE;
|
for(int i=0;i<optIns.GetCount();i++)
|
{
|
if(str.CollateNoCase(optIns.GetAt(i)) == 0)
|
{
|
stPos.emDir = (STU_SPLINE_CHIP_POS::SPLINE_INS_DIRECTION)i;
|
break;
|
}
|
}
|
nCol++;
|
|
str = m_ListSplinePos.GetItemText(nRow,nCol);
|
stPos.nStartX = _ttoi(str);
|
nCol++;
|
|
str = m_ListSplinePos.GetItemText(nRow,nCol);
|
stPos.nEndX = _ttoi(str);
|
nCol++;
|
|
str = m_ListSplinePos.GetItemText(nRow,nCol);
|
stPos.nThres = _ttoi(str);
|
nCol++;
|
|
str = m_ListSplinePos.GetItemText(nRow,nCol);
|
stPos.nFindThres = _ttoi(str);
|
nCol++;
|
|
str = m_ListSplinePos.GetItemText(nRow,nCol);
|
stPos.nSkipDist = _ttoi(str);
|
nCol++;
|
|
str = m_ListSplinePos.GetItemText(nRow,nCol);
|
stPos.nInsRange = _ttoi(str);
|
nCol++;
|
|
stPos.emMethod = STU_SPLINE_CHIP_POS::MAKE_METHOD_REGRESSION;
|
|
pParm->m_vecSplineChip[m_index].push_back(stPos);
|
}
|
}
|
}
|
void CViewSettingSpline::OnBnClickedButAddSplineChip()
|
{
|
STU_SPLINE_CHIP_POS stPos;
|
CSPLINE_PARM *pParm = m_DlgGlassRecipe.m_InspectInfoParm.GetSplineParm();;
|
|
pParm->m_vecSplineChip[m_index].push_back(stPos);
|
FillGrid(TRUE);
|
}
|
|
void CViewSettingSpline::OnBnClickedButDelSplineChip()
|
{
|
if(m_nCutListIdx <= 0 || m_nCutListIdx >= m_ListSplinePos.GetRowCount())
|
return;
|
|
if (IDNO == AfxMessageBox(_T("Delete Data?"), MB_YESNO | MB_ICONQUESTION))
|
return;
|
|
int nCnt;
|
CSPLINE_PARM *pParm = m_DlgGlassRecipe.m_InspectInfoParm.GetSplineParm();;
|
std::vector<STU_SPLINE_CHIP_POS>::iterator it;
|
|
nCnt = 1;
|
for(it=pParm->m_vecSplineChip[m_index].begin();it!=pParm->m_vecSplineChip[m_index].end();it++,nCnt++)
|
{
|
if(nCnt == m_nCutListIdx)
|
{
|
pParm->m_vecSplineChip[m_index].erase(it);
|
break;
|
}
|
}
|
|
FillGrid(TRUE);
|
}
|
|
void CViewSettingSpline::OnListSplineClick(NMHDR *pNotifyStruct, LRESULT* pResult)
|
{
|
NM_GRIDVIEW* pItem = (NM_GRIDVIEW*) pNotifyStruct;
|
|
if(pItem->iRow <= 0 || pItem->iRow > (int)m_ListSplinePos.GetRowCount())
|
return;
|
|
m_nCutListIdx = pItem->iRow;
|
|
Invalidate(FALSE);
|
}
|
|
void CViewSettingSpline::OnBnClickedCheckUseSplinechip()
|
{
|
UpdateData(TRUE);
|
|
SetEnControl();
|
}
|
|
void CViewSettingSpline::ClickBtnSplineOk()
|
{
|
UpdateDlgData();
|
m_pParent->PostMessage(UM_SPLINE_APPLY_RECIPE,NULL,NULL);
|
CDialog::OnOK();
|
}
|
|
|
void CViewSettingSpline::ClickBtnSplineCancel()
|
{
|
CDialog::OnCancel();
|
}
|