// CutSetDlg.cpp : ʵÏÖÎļþ
|
//
|
|
#include "stdafx.h"
|
#include "BlVisionPro.h"
|
#include "CutSetDlg.h"
|
#include "afxdialogex.h"
|
#include "VisionRecipe.h"
|
#include "VisionSetDlg.h"
|
#include "VisionBufferPro.h"
|
#include "SoftVisionApp.h"
|
|
|
// CCutSetDlg ¶Ô»°¿ò
|
|
IMPLEMENT_DYNAMIC(CCutSetDlg, CDialogEx)
|
|
CCutSetDlg::CCutSetDlg(CWnd* pParent /*=NULL*/)
|
: CDialogEx(IDD_DIALOG_CUTLINE_SET, pParent)
|
{
|
/* code */
|
m_dot = NULL;
|
m_eDir = DIMENSION_NONE;
|
}
|
|
CCutSetDlg::~CCutSetDlg(){
|
/* code */
|
m_vParams.clear();
|
}
|
|
void CCutSetDlg::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialogEx::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_PANEL_CUTLINE_INFO_CUT, m_PanelCutLine);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CCutSetDlg, CDialogEx)
|
ON_WM_CLOSE()
|
ON_BN_CLICKED(IDC_BUTTON_PROCESS_CUT, &CCutSetDlg::OnBnClickedButtonProcessCut)
|
ON_BN_CLICKED(IDC_BUTTON_SAVE_CUT, &CCutSetDlg::OnBnClickedButtonSaveCut)
|
END_MESSAGE_MAP()
|
|
|
// CCutSetDlg ÏûÏ¢´¦Àí³ÌÐò
|
|
|
BOOL CCutSetDlg::OnInitDialog()
|
{
|
CDialogEx::OnInitDialog();
|
|
// TODO: ÔÚ´ËÌí¼Ó¶îÍâµÄ³õʼ»¯
|
InitPanel();
|
|
m_eDir = DIMENSION_NONE;
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
// Òì³£: OCX ÊôÐÔÒ³Ó¦·µ»Ø FALSE
|
}
|
|
void CCutSetDlg::InitPanel(void) {
|
/* code */
|
m_vParams.clear();
|
|
CString strText;
|
//1. ID
|
strText = _T("ID.");
|
m_vParams.push_back(strText);
|
//2. Name
|
strText = _T("Name");
|
m_vParams.push_back(strText);
|
//3. Use
|
strText = _T("use");
|
m_vParams.push_back(strText);
|
//4. Pos Type
|
strText = _T("Pos Type");
|
m_vParams.push_back(strText);
|
//5. line thres
|
strText = _T("line thres");
|
m_vParams.push_back(strText);
|
//6. Pos Y
|
strText = _T("Top Y(um)");
|
m_vParams.push_back(strText);
|
//7. Pos X
|
strText = _T("Std Dist(um)");
|
m_vParams.push_back(strText);
|
// 8.Inc
|
strText = _T("Inc(um)");
|
m_vParams.push_back(strText);
|
// 9.Min
|
strText = _T("Min(um)");
|
m_vParams.push_back(strText);
|
// 10.Max
|
strText = _T("Max(um)");
|
m_vParams.push_back(strText);
|
// 11.Result
|
strText = _T("Result(um)");
|
m_vParams.push_back(strText);
|
|
int nRows = 51;
|
int nCols = (int)(m_vParams.size());
|
int nFixRows = 1;
|
int nFixCols = 0;
|
int nRowIdx = 0;
|
int nColIdx = 0;
|
|
m_PanelCutLine.DeleteAllItems();
|
m_PanelCutLine.SetVirtualMode(FALSE);
|
m_PanelCutLine.GetDefaultCell(TRUE, FALSE)->SetBackClr(_gGridFixCellColor);
|
m_PanelCutLine.GetDefaultCell(FALSE, TRUE)->SetBackClr(_gGridFixCellColor);
|
m_PanelCutLine.GetDefaultCell(FALSE, FALSE)->SetBackClr(_gGridCellColor);
|
m_PanelCutLine.SetFixedTextColor(_gGridFixFontColor);
|
|
m_PanelCutLine.SetRowCount(nRows);
|
m_PanelCutLine.SetColumnCount(nCols);
|
m_PanelCutLine.SetFixedRowCount(nFixRows);
|
m_PanelCutLine.SetFixedColumnCount(nFixCols);
|
|
CFont *pFont = m_PanelCutLine.GetFont();
|
if (pFont){
|
LOGFONT lf;
|
pFont->GetLogFont(&lf);
|
lf.lfItalic = 0;
|
lf.lfHeight = 14;
|
lf.lfWeight = FW_BOLD;
|
_tcscpy_s(lf.lfFaceName, _T("Malgun Gothic"));
|
|
m_PanelCutLine.GetDefaultCell(FALSE, TRUE)->SetFont(&lf);
|
m_PanelCutLine.GetDefaultCell(TRUE, FALSE)->SetFont(&lf);
|
m_PanelCutLine.GetDefaultCell(FALSE, FALSE)->SetFont(&lf);
|
m_PanelCutLine.GetDefaultCell(TRUE, TRUE)->SetFont(&lf);
|
}
|
|
// Col
|
for (int i = 0; i < nCols; i++) {
|
if (1 == i) {
|
m_PanelCutLine.SetColumnWidth(nColIdx, 115);
|
}
|
else if (0 == i) {
|
m_PanelCutLine.SetColumnWidth(nColIdx, 50);
|
}
|
else {
|
m_PanelCutLine.SetColumnWidth(nColIdx, 75);
|
}
|
strText = m_vParams[i];
|
m_PanelCutLine.SetItemText(nRowIdx, nColIdx++, strText);
|
}
|
|
for (int i = 1; i < nRows; i++)
|
{
|
m_PanelCutLine.GetCell(i, 0)->SetState(GVIS_READONLY);
|
}
|
}
|
|
|
void CCutSetDlg::OnClose()
|
{
|
// TODO: ÔÚ´ËÌí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂëºÍ/»òµ÷ÓÃĬÈÏÖµ
|
|
CDialogEx::OnClose();
|
}
|
|
|
BOOL CCutSetDlg::PreTranslateMessage(MSG* pMsg)
|
{
|
// TODO: ÔÚ´ËÌí¼ÓרÓôúÂëºÍ/»òµ÷ÓûùÀà
|
if (pMsg->message == WM_KEYDOWN) {
|
if ((pMsg->wParam == VK_RETURN) || (pMsg->wParam == VK_ESCAPE)) {
|
return TRUE;
|
}
|
}
|
|
return CDialogEx::PreTranslateMessage(pMsg);
|
}
|
|
void CCutSetDlg::ChangeVisionType(DimensionDir eDir) {
|
/* code */
|
SaveCutLineParam();
|
|
m_eDir = eDir;
|
m_dot = CVisionRecipe::getInstance()->getCutProcess(eDir);
|
|
ShowCutLineParam();
|
}
|
|
void CCutSetDlg::setDimensionDir(DimensionDir eDir) {
|
/* code */
|
ChangeVisionType(eDir);
|
}
|
|
|
void CCutSetDlg::OnBnClickedButtonProcessCut()
|
{
|
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
|
CBlSideData *pSideData = CVisionRecipe::getInstance()->getSideData(m_eDir);
|
if (nullptr != pSideData) {
|
pSideData->m_vDispVisionResult.clear();
|
}
|
|
SaveCutLineParam();
|
|
if (NULL == m_dot) return;
|
|
m_dot->Execute(m_eDir);
|
|
DispAllResult();
|
}
|
|
void CCutSetDlg::DispAllResult(void) {
|
/* code */
|
int nCount = 50;
|
for (int i = 0; i < 50; i++) {
|
CCutDotProcess *dot = m_dot->m_dots[i];
|
if (NULL == dot) continue;
|
bool isDo = true;
|
if (1 != dot->m_nUse) isDo = false;
|
if (!isDo) {
|
int id = dot->getID();
|
m_PanelCutLine.SetItemText(id, 10, _T("NAN"));
|
}
|
else{ //ÏÔʾ½á¹û
|
CString strResult;
|
strResult.Format(_T("%.1f"), dot->m_distResult);
|
int id = dot->getID();
|
m_PanelCutLine.SetItemText(id, 10, strResult);
|
}
|
}
|
CSoftVisionApp::getInstance()->sendMessage(2, m_eDir);
|
|
m_PanelCutLine.Invalidate(FALSE);
|
}
|
|
void CCutSetDlg::SaveCutLineParam(void) {
|
/* code */
|
if (DIMENSION_NONE == m_eDir) return;
|
if (NULL == m_dot) return;
|
|
UpdateData(TRUE);
|
|
{
|
CButton *pBtnUse = (CButton*)(GetDlgItem(IDC_CHECK_USE_CUT));
|
int iUse = pBtnUse->GetCheck();
|
m_dot->m_isUse = (1 == iUse);
|
}
|
|
CString strText;
|
for (int i = 0; i < 50; i++) {
|
CCutDotProcess *dot = m_dot->m_dots[i];
|
if (NULL == dot) continue;
|
|
//1. ID
|
int idRow = dot->getID();
|
int idx = 0;
|
strText = m_PanelCutLine.GetItemText(idRow, idx);
|
idx += 1;
|
|
//2. Use Name
|
strText = m_PanelCutLine.GetItemText(idRow, idx);
|
dot->m_strName = strText;
|
idx += 1;
|
|
//3. ID
|
strText = m_PanelCutLine.GetItemText(idRow, idx);
|
dot->m_nUse = _wtoi(strText);
|
idx += 1;
|
|
//4. Pos Type
|
strText = m_PanelCutLine.GetItemText(idRow, idx);
|
dot->m_poseType = _wtoi(strText);
|
idx += 1;
|
|
//5. line thres
|
strText = m_PanelCutLine.GetItemText(idRow, idx);
|
dot->m_nEdgeThres = _wtoi(strText);
|
idx += 1;
|
|
//6. Pos Y
|
strText = m_PanelCutLine.GetItemText(idRow, idx);
|
dot->m_nPosY = _wtoi(strText);
|
idx += 1;
|
|
//7. Pos X
|
strText = m_PanelCutLine.GetItemText(idRow, idx);
|
dot->m_nPosX = _wtoi(strText);
|
idx += 1;
|
|
//8. Inc
|
strText = m_PanelCutLine.GetItemText(idRow, idx);
|
dot->m_nInc = _wtoi(strText);
|
idx += 1;
|
|
//9. Min
|
strText = m_PanelCutLine.GetItemText(idRow, idx);
|
dot->m_nMin = _wtoi(strText);
|
idx += 1;
|
|
//10. Max
|
strText = m_PanelCutLine.GetItemText(idRow, idx);
|
dot->m_nMax = _wtoi(strText);
|
idx += 1;
|
}
|
}
|
|
void CCutSetDlg::ShowCutLineParam(void) {
|
/* code */
|
if (DIMENSION_NONE == m_eDir) return;
|
if (NULL == m_dot) return;
|
|
{
|
CButton *pBtnUse = (CButton*)(GetDlgItem(IDC_CHECK_USE_CUT));
|
int iUse = 0;
|
if (m_dot->m_isUse) iUse = 1;
|
pBtnUse->SetCheck(iUse);
|
}
|
|
CString strText;
|
for (int i = 0; i < 50; i++) {
|
CCutDotProcess *dot = m_dot->m_dots[i];
|
if (NULL == dot) continue;
|
|
//1. ID
|
int idRow = dot->getID();
|
int idx = 0;
|
strText.Format(_T("%d"), dot->getID());
|
m_PanelCutLine.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//2. Name
|
strText = dot->m_strName;
|
m_PanelCutLine.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//3. USE
|
strText.Format(_T("%d"), dot->m_nUse);
|
m_PanelCutLine.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//4. Pose Type
|
strText.Format(_T("%d"), dot->m_poseType);
|
m_PanelCutLine.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//5. line thres
|
strText.Format(_T("%d"), dot->m_nEdgeThres);
|
m_PanelCutLine.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//6. Pos Y
|
strText.Format(_T("%d"), dot->m_nPosY);
|
m_PanelCutLine.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//7. Pos X
|
strText.Format(_T("%d"), dot->m_nPosX);
|
m_PanelCutLine.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//8. Inc
|
strText.Format(_T("%d"), dot->m_nInc);
|
m_PanelCutLine.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//9. Min
|
strText.Format(_T("%d"), dot->m_nMin);
|
m_PanelCutLine.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//10. Max
|
strText.Format(_T("%d"), dot->m_nMax);
|
m_PanelCutLine.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//11. Result
|
strText.Format(_T("%.1f"), dot->m_distResult);
|
m_PanelCutLine.SetItemText(idRow, idx, strText);
|
idx += 1;
|
}
|
|
UpdateData(FALSE);
|
}
|
|
void CCutSetDlg::OnBnClickedButtonSaveCut()
|
{
|
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
|
SaveCutLineParam();
|
}
|