// DlgSideExceptoinSetting.cpp : 备泅 颇老涝聪促.
|
//
|
|
#include "stdafx.h"
|
#include "EdgeInspector_App.h"
|
#include "DlgSideExceptoinSetting.h"
|
#include "afxdialogex.h"
|
|
|
// CDlgSideDimensionSetting 措拳 惑磊涝聪促.
|
|
IMPLEMENT_DYNAMIC(CDlgSideExceptoinSetting, CDialogEx)
|
|
CDlgSideExceptoinSetting::CDlgSideExceptoinSetting(CWnd* pParent /*=NULL*/)
|
: CDialogEx(CDlgSideExceptoinSetting::IDD, pParent)
|
{
|
m_pDlgRecipe = NULL;
|
m_pGlassData = NULL;
|
m_pSelectSideIdx = NULL;
|
m_pRecipeImageViewer = NULL;
|
}
|
|
CDlgSideExceptoinSetting::~CDlgSideExceptoinSetting()
|
{
|
}
|
|
void CDlgSideExceptoinSetting::DoDataExchange(CDataExchange* pDX)
|
{
|
DDX_Control(pDX, IDC_SIDE_EXCEPTION_SETTING_LIST, m_SideExceptionSetting);
|
CDialogEx::DoDataExchange(pDX);
|
}
|
|
BEGIN_MESSAGE_MAP(CDlgSideExceptoinSetting, CDialogEx)
|
END_MESSAGE_MAP()
|
|
BOOL CDlgSideExceptoinSetting::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 CDlgSideExceptoinSetting::SetDlgRecipe(CGlassRecipe* pDlgRecipe)
|
{
|
m_pDlgRecipe = pDlgRecipe;
|
|
UpdateRecipe(FALSE);
|
}
|
|
void CDlgSideExceptoinSetting::UpdateRecipe(BOOL bGetData)
|
{
|
// Title
|
if(m_pSelectSideIdx != NULL)
|
{
|
CString strTemp;
|
strTemp.Format(_T("[%s] Exception Setting"), g_SideName[(int) *(m_pSelectSideIdx)]);
|
SetDlgItemText(IDC_STATIC_TITLE, strTemp);
|
}
|
|
if(bGetData == FALSE)
|
{
|
Fill_SideExceptionSetting(bGetData);
|
}
|
else
|
{
|
Fill_SideExceptionSetting(bGetData);
|
}
|
}
|
|
void CDlgSideExceptoinSetting::Init_SideExceptionSetting()
|
{
|
if (m_SideExceptionSetting.GetSafeHwnd() == NULL)
|
return;
|
|
int nRows = 1;
|
int nCols = 5;
|
|
int nFixRows = 1;
|
int nFixCols = 0;
|
int nRowIdx = 0;
|
int nColIdx = 0;
|
|
m_SideExceptionSetting.DeleteAllItems();
|
m_SideExceptionSetting.SetVirtualMode(FALSE);
|
m_SideExceptionSetting.GetDefaultCell(TRUE, FALSE)->SetBackClr(g_nGridFixCellColor);
|
m_SideExceptionSetting.GetDefaultCell(FALSE, TRUE)->SetBackClr(g_nGridFixCellColor);
|
m_SideExceptionSetting.GetDefaultCell(FALSE, FALSE)->SetBackClr(g_nGridCellColor);
|
m_SideExceptionSetting.SetFixedTextColor(g_nGridFixFontColor);
|
|
m_SideExceptionSetting.SetRowCount(nRows);
|
m_SideExceptionSetting.SetColumnCount(nCols);
|
m_SideExceptionSetting.SetFixedRowCount(nFixRows);
|
m_SideExceptionSetting.SetFixedColumnCount(nFixCols);
|
|
CFont *pFont = m_SideExceptionSetting.GetFont();
|
if (pFont)
|
{
|
LOGFONT lf;
|
pFont->GetLogFont(&lf);
|
lf.lfItalic = 0;
|
lf.lfHeight = 14;
|
lf.lfWeight = FW_BOLD;
|
_tcscpy_s(lf.lfFaceName, _T("Arial"));
|
|
m_SideExceptionSetting.GetDefaultCell(FALSE, TRUE)->SetFont(&lf);
|
m_SideExceptionSetting.GetDefaultCell(TRUE, FALSE)->SetFont(&lf);
|
m_SideExceptionSetting.GetDefaultCell(FALSE, FALSE)->SetFont(&lf);
|
m_SideExceptionSetting.GetDefaultCell(TRUE, TRUE)->SetFont(&lf);
|
}
|
|
// Col
|
m_SideExceptionSetting.SetColumnWidth(nColIdx, 80);
|
m_SideExceptionSetting.SetItemText(nRowIdx, nColIdx++, _T("No."));
|
/*
|
m_SideExceptionSetting.SetColumnWidth(nColIdx, 120);
|
m_SideExceptionSetting.SetItemText(nRowIdx, nColIdx++, _T("Top Mark Pos(pxl)"));
|
m_SideExceptionSetting.SetColumnWidth(nColIdx, 120);
|
m_SideExceptionSetting.SetItemText(nRowIdx, nColIdx++, _T("Bot Mark Pos(pxl)"));
|
m_SideExceptionSetting.SetColumnWidth(nColIdx, 120);
|
m_SideExceptionSetting.SetItemText(nRowIdx, nColIdx++, _T("Mark To Area(pxl)"));
|
*/
|
|
m_SideExceptionSetting.SetColumnWidth(nColIdx, 180);
|
m_SideExceptionSetting.SetItemText(nRowIdx, nColIdx++, _T("Use (0:Off/1:Inter/2:Full)"));
|
m_SideExceptionSetting.SetColumnWidth(nColIdx, 120);
|
m_SideExceptionSetting.SetItemText(nRowIdx, nColIdx++, _T("Min Size X"));
|
m_SideExceptionSetting.SetColumnWidth(nColIdx, 120);
|
m_SideExceptionSetting.SetItemText(nRowIdx, nColIdx++, _T("Min Size Y"));
|
m_SideExceptionSetting.SetColumnWidth(nColIdx, 180);
|
m_SideExceptionSetting.SetItemText(nRowIdx, nColIdx++, _T("Size And (0:OR/1:AND)"));
|
|
m_SideExceptionSetting.SetFixedRowSelection(FALSE);
|
m_SideExceptionSetting.SetFixedColumnSelection(FALSE);
|
m_SideExceptionSetting.EnableSelection(TRUE);
|
m_SideExceptionSetting.SetEditable(TRUE);
|
m_SideExceptionSetting.SetRowResize(FALSE);
|
m_SideExceptionSetting.SetColumnResize(FALSE);
|
m_SideExceptionSetting.ExpandColumnsToFit(TRUE);
|
}
|
|
void CDlgSideExceptoinSetting::Fill_SideExceptionSetting(BOOL bGetData)
|
{
|
if(m_SideExceptionSetting.GetSafeHwnd() == NULL)
|
return;
|
|
if(m_pDlgRecipe == NULL || m_pSelectSideIdx == NULL)
|
return;
|
|
int nSideIdx = *(m_pSelectSideIdx);
|
|
if(nSideIdx < 0 || eRcp_SideRD_End <= nSideIdx)
|
return;
|
|
CSIDE_PARM* pParam = &m_pDlgRecipe->m_SideParam[nSideIdx];
|
|
CString strTemp;
|
int nRow = 0;
|
int nCol = 0;
|
|
if(bGetData == FALSE)
|
{
|
int nExceptionCount = pParam->m_nExptionCount;
|
|
m_SideExceptionSetting.SetRowCount(nExceptionCount + 1);
|
|
for(int i=0; i<nExceptionCount; i++)
|
{
|
nRow = i + 1;
|
nCol = 0;
|
|
// 1. No.
|
strTemp.Format(_T("%d"), i + 1);
|
m_SideExceptionSetting.GetCell(nRow, nCol)->SetState(GVIS_READONLY);
|
m_SideExceptionSetting.SetItemText(nRow, nCol++, strTemp);
|
|
/*
|
// 2. Top Mark Pos
|
strTemp.Format(_T("%d,%d"), pParam->m_ExpAreaPrm[i].m_ptTopMarkPos.x, pParam->m_ExpAreaPrm[i].m_ptTopMarkPos.y);
|
m_SideExceptionSetting.GetCell(nRow, nCol)->SetState(GVIS_READONLY);
|
m_SideExceptionSetting.SetItemText(nRow, nCol++, strTemp);
|
|
// 3. Bot Mark Pos
|
strTemp.Format(_T("%d,%d"), pParam->m_ExpAreaPrm[i].m_ptBotMarkPos.x, pParam->m_ExpAreaPrm[i].m_ptBotMarkPos.y);
|
m_SideExceptionSetting.GetCell(nRow, nCol)->SetState(GVIS_READONLY);
|
m_SideExceptionSetting.SetItemText(nRow, nCol++, strTemp);
|
|
// 4. Area
|
strTemp.Format(_T("%d,%d,%d,%d"), pParam->m_ExpAreaPrm[i].m_rtExceptionArea.left, pParam->m_ExpAreaPrm[i].m_rtExceptionArea.top, pParam->m_ExpAreaPrm[i].m_rtExceptionArea.right, pParam->m_ExpAreaPrm[i].m_rtExceptionArea.bottom);
|
m_SideExceptionSetting.GetCell(nRow, nCol)->SetState(GVIS_READONLY);
|
m_SideExceptionSetting.SetItemText(nRow, nCol++, strTemp);
|
*/
|
|
// 5. Filter Type
|
strTemp.Format(_T("%d"), pParam->m_ExpAreaPrm[i].m_nFilterType);
|
m_SideExceptionSetting.SetItemText(nRow, nCol++, strTemp);
|
|
// 6. Filter Size X
|
strTemp.Format(_T("%d"), pParam->m_ExpAreaPrm[i].m_nFilterSizeX);
|
m_SideExceptionSetting.SetItemText(nRow, nCol++, strTemp);
|
|
// 7. Filter Size Y
|
strTemp.Format(_T("%d"), pParam->m_ExpAreaPrm[i].m_nFilterSizeY);
|
m_SideExceptionSetting.SetItemText(nRow, nCol++, strTemp);
|
|
// 8. Filter And
|
strTemp.Format(_T("%d"), pParam->m_ExpAreaPrm[i].m_bFilterAnd);
|
m_SideExceptionSetting.SetItemText(nRow, nCol++, strTemp);
|
}
|
|
m_SideExceptionSetting.Invalidate();
|
}
|
else
|
{
|
int nExceptionCount = m_SideExceptionSetting.GetRowCount() - 1;
|
|
pParam->m_nExptionCount = nExceptionCount;
|
|
for(int i=0; i<nExceptionCount; i++)
|
{
|
nRow = i + 1;
|
nCol = 0;
|
|
// 1. No.
|
strTemp = m_SideExceptionSetting.GetItemText(nRow, nCol++);
|
|
/*
|
// 2. Top Mark Pos
|
strTemp = m_SideExceptionSetting.GetItemText(nRow, nCol++);
|
|
// 3. Bot Mark Pos
|
strTemp = m_SideExceptionSetting.GetItemText(nRow, nCol++);
|
|
// 4. Area
|
strTemp = m_SideExceptionSetting.GetItemText(nRow, nCol++);
|
*/
|
|
// 5. Filter Type
|
strTemp = m_SideExceptionSetting.GetItemText(nRow, nCol++);
|
pParam->m_ExpAreaPrm[i].m_nFilterType = _wtoi(strTemp);
|
|
// 6. Filter Size X
|
strTemp = m_SideExceptionSetting.GetItemText(nRow, nCol++);
|
pParam->m_ExpAreaPrm[i].m_nFilterSizeX = _wtoi(strTemp);
|
|
// 7. Filter Size Y
|
strTemp = m_SideExceptionSetting.GetItemText(nRow, nCol++);
|
pParam->m_ExpAreaPrm[i].m_nFilterSizeY = _wtoi(strTemp);
|
|
// 8. Filter And
|
strTemp = m_SideExceptionSetting.GetItemText(nRow, nCol++);
|
pParam->m_ExpAreaPrm[i].m_bFilterAnd = (BOOL) _wtoi(strTemp);
|
|
}
|
}
|
}
|
|
BOOL CDlgSideExceptoinSetting::OnInitDialog()
|
{
|
CDialogEx::OnInitDialog();
|
|
Init_SideExceptionSetting();
|
|
return TRUE;
|
}
|
|
BEGIN_EVENTSINK_MAP(CDlgSideExceptoinSetting, CDialogEx)
|
ON_EVENT(CDlgSideExceptoinSetting, IDC_BUTTON_ADD, DISPID_CLICK, CDlgSideExceptoinSetting::ClickButtonAdd, VTS_NONE)
|
ON_EVENT(CDlgSideExceptoinSetting, IDC_BUTTON_MODIFY, DISPID_CLICK, CDlgSideExceptoinSetting::ClickButtonModify, VTS_NONE)
|
ON_EVENT(CDlgSideExceptoinSetting, IDC_BUTTON_DEL, DISPID_CLICK, CDlgSideExceptoinSetting::ClickButtonDel, VTS_NONE)
|
END_EVENTSINK_MAP()
|
|
|
void CDlgSideExceptoinSetting::ClickButtonAdd()
|
{
|
if(m_pDlgRecipe == NULL || m_pSelectSideIdx == NULL)
|
return;
|
|
int nSideIdx = *(m_pSelectSideIdx);
|
|
if(nSideIdx < 0 || eRcp_SideRD_End <= nSideIdx)
|
return;
|
|
CSIDE_PARM* pParam = &m_pDlgRecipe->m_SideParam[nSideIdx];
|
|
int nAddIdx = pParam->m_nExptionCount;
|
|
if(nAddIdx < 0 || MAX_SIDE_EXCEPTION_AREA_COUNT <= nAddIdx)
|
{
|
CString strMsg;
|
strMsg.Format(_T("Max Exception Count : %d ea"), MAX_SIDE_EXCEPTION_AREA_COUNT);
|
AfxMessageBox(strMsg);
|
return;
|
}
|
|
if(m_pGlassData == NULL || m_pRecipeImageViewer == NULL)
|
return;
|
|
CSide_Data* pSideData = m_pGlassData->GetSideData((DimensionDir) nSideIdx);
|
|
if(pSideData == NULL)
|
return;
|
|
if(pSideData->m_bTopMark_Find == FALSE || pSideData->m_bBotMark_Find == FALSE)
|
{
|
AfxMessageBox(_T("Check Mark Find.."));
|
return;
|
}
|
|
pParam->m_ExpAreaPrm[nAddIdx].Reset();
|
pParam->m_ExpAreaPrm[nAddIdx].m_ptTopMarkPos = pSideData->m_ptTopMark_FindResult;
|
pParam->m_ExpAreaPrm[nAddIdx].m_ptBotMarkPos = pSideData->m_ptBotMark_FindResult;
|
pParam->m_ExpAreaPrm[nAddIdx].m_rtExceptionArea = m_pRecipeImageViewer->GetManualMeasureRect();
|
pParam->m_ExpAreaPrm[nAddIdx].m_nFilterType = 2;
|
pParam->m_ExpAreaPrm[nAddIdx].m_nFilterSizeX = 9999;
|
pParam->m_ExpAreaPrm[nAddIdx].m_nFilterSizeY = 9999;
|
pParam->m_ExpAreaPrm[nAddIdx].m_bFilterAnd = FALSE;
|
|
pParam->m_nExptionCount = nAddIdx + 1;
|
|
// Draw Exception
|
pSideData->m_rtExceptionArea_pxl[nAddIdx] = pParam->m_ExpAreaPrm[nAddIdx].m_rtExceptionArea;
|
pSideData->m_nExceptionAreaCount++;
|
m_pRecipeImageViewer->Invalidate();
|
|
UpdateRecipe(FALSE);
|
}
|
|
void CDlgSideExceptoinSetting::ClickButtonModify()
|
{
|
if(m_pDlgRecipe == NULL || m_pSelectSideIdx == NULL)
|
return;
|
|
int nSideIdx = *(m_pSelectSideIdx);
|
|
if(nSideIdx < 0 || eRcp_SideRD_End <= nSideIdx)
|
return;
|
|
CSIDE_PARM* pParam = &m_pDlgRecipe->m_SideParam[nSideIdx];
|
|
int nExptionCount = pParam->m_nExptionCount;
|
|
CCellID FocusedID = m_SideExceptionSetting.GetFocusCell();
|
int nModifyIdx = FocusedID.row - 1;
|
|
if(nModifyIdx < 0 || nExptionCount <= nModifyIdx)
|
{
|
AfxMessageBox(_T("Select Error"));
|
return;
|
}
|
|
CString strTemp;
|
strTemp.Format(_T("Modify [%d] Exception Area ?"), nModifyIdx+1);
|
if(IDYES != AfxMessageBox(strTemp, MB_YESNO))
|
return;
|
|
if(m_pGlassData == NULL || m_pRecipeImageViewer == NULL)
|
return;
|
|
CSide_Data* pSideData = m_pGlassData->GetSideData((DimensionDir) nSideIdx);
|
|
if(pSideData == NULL)
|
return;
|
|
if(pSideData->m_bTopMark_Find == FALSE || pSideData->m_bBotMark_Find == FALSE)
|
{
|
AfxMessageBox(_T("Check Mark Find.."));
|
return;
|
}
|
|
pParam->m_ExpAreaPrm[nModifyIdx].m_ptTopMarkPos = pSideData->m_ptTopMark_FindResult;
|
pParam->m_ExpAreaPrm[nModifyIdx].m_ptBotMarkPos = pSideData->m_ptBotMark_FindResult;
|
pParam->m_ExpAreaPrm[nModifyIdx].m_rtExceptionArea = m_pRecipeImageViewer->GetManualMeasureRect();
|
|
// Draw Exception
|
pSideData->m_rtExceptionArea_pxl[nModifyIdx] = pParam->m_ExpAreaPrm[nModifyIdx].m_rtExceptionArea;
|
m_pRecipeImageViewer->Invalidate();
|
|
UpdateRecipe(FALSE);
|
}
|
|
void CDlgSideExceptoinSetting::ClickButtonDel()
|
{
|
if(m_pDlgRecipe == NULL || m_pSelectSideIdx == NULL)
|
return;
|
|
int nSideIdx = *(m_pSelectSideIdx);
|
|
if(nSideIdx < 0 || eRcp_SideRD_End <= nSideIdx)
|
return;
|
|
CSIDE_PARM* pParam = &m_pDlgRecipe->m_SideParam[nSideIdx];
|
|
int nExptionCount = pParam->m_nExptionCount;
|
|
CCellID FocusedID = m_SideExceptionSetting.GetFocusCell();
|
int nDelIdx = FocusedID.row - 1;
|
|
if(nDelIdx < 0 || nExptionCount <= nDelIdx)
|
{
|
AfxMessageBox(_T("Select Error"));
|
return;
|
}
|
|
CString strTemp;
|
strTemp.Format(_T("Delete [%d] Exception Area ?"), nDelIdx+1);
|
if(IDYES != AfxMessageBox(strTemp, MB_YESNO))
|
return;
|
|
int nPosIdx = 0;
|
for(int i=0; i<MAX_SIDE_EXCEPTION_AREA_COUNT; i++)
|
{
|
if(i == nDelIdx)
|
continue;
|
|
pParam->m_ExpAreaPrm[nPosIdx] = pParam->m_ExpAreaPrm[i];
|
nPosIdx++;
|
}
|
pParam->m_nExptionCount = nExptionCount - 1;
|
|
UpdateRecipe(FALSE);
|
}
|