// KDistSetDlg.cpp : ʵÏÖÎļþ
|
//
|
|
#include "stdafx.h"
|
#include "BlVisionPro.h"
|
#include "KDistSetDlg.h"
|
#include "afxdialogex.h"
|
#include "VisionRecipe.h"
|
#include "VisionSetDlg.h"
|
#include "VisionBufferPro.h"
|
#include "SoftVisionApp.h"
|
|
|
// CKDistSetDlg ¶Ô»°¿ò
|
|
IMPLEMENT_DYNAMIC(CKDistSetDlg, CDialogEx)
|
|
CKDistSetDlg::CKDistSetDlg(CWnd* pParent /*=NULL*/)
|
: CDialogEx(IDD_DIALOG_DIST_SET, pParent)
|
{
|
m_dot = NULL;
|
m_eDir = DIMENSION_NONE;
|
}
|
|
CKDistSetDlg::~CKDistSetDlg()
|
{
|
/* code */
|
}
|
|
void CKDistSetDlg::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialogEx::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_PANEL_CUT_INFO, m_PanelKeyDist);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CKDistSetDlg, CDialogEx)
|
ON_WM_CLOSE()
|
ON_BN_CLICKED(IDC_BUTTON_PROCESS_KDIST, &CKDistSetDlg::OnBnClickedButtonProcessKdist)
|
ON_BN_CLICKED(IDC_BUTTON_SAVE_KDIST, &CKDistSetDlg::OnBnClickedButtonSaveKdist)
|
END_MESSAGE_MAP()
|
|
|
// CKDistSetDlg ÏûÏ¢´¦Àí³ÌÐò
|
|
|
BOOL CKDistSetDlg::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 CKDistSetDlg::OnClose()
|
{
|
// TODO: ÔÚ´ËÌí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂëºÍ/»òµ÷ÓÃĬÈÏÖµ
|
|
CDialogEx::OnClose();
|
}
|
|
|
BOOL CKDistSetDlg::OnInitDialog()
|
{
|
CDialogEx::OnInitDialog();
|
|
// TODO: ÔÚ´ËÌí¼Ó¶îÍâµÄ³õʼ»¯
|
InitPanel();
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
// Òì³£: OCX ÊôÐÔÒ³Ó¦·µ»Ø FALSE
|
}
|
|
void CKDistSetDlg::InitPanel(void) {
|
/* code */
|
m_vParams.clear();
|
|
CString strText;
|
//1. ID
|
strText = _T("ID.");
|
m_vParams.push_back(strText);
|
//2. useName
|
strText = _T("Name");
|
m_vParams.push_back(strText);
|
//3. useName
|
strText = _T("use");
|
m_vParams.push_back(strText);
|
//4. Pos Type
|
strText = _T("Pos Type");
|
m_vParams.push_back(strText);
|
//5. Key X
|
strText = _T("Key X(um)");
|
m_vParams.push_back(strText);
|
//6. Key Y
|
strText = _T("Key Y(um)");
|
m_vParams.push_back(strText);
|
//7. Pos X
|
strText = _T("Pos X(um)");
|
m_vParams.push_back(strText);
|
//8. Pos Y
|
strText = _T("Pos Y(um)");
|
m_vParams.push_back(strText);
|
//9. End Type
|
strText = _T("Edge Thres");
|
m_vParams.push_back(strText);
|
//10. ROI Width
|
strText = _T("Std(um)");
|
m_vParams.push_back(strText);
|
// 11. Inc
|
strText = _T("Inc(um)");
|
m_vParams.push_back(strText);
|
// 12.Min
|
strText = _T("Min(um)");
|
m_vParams.push_back(strText);
|
// 13.MAX
|
strText = _T("Max(um)");
|
m_vParams.push_back(strText);
|
// 14.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_PanelKeyDist.DeleteAllItems();
|
m_PanelKeyDist.SetVirtualMode(FALSE);
|
m_PanelKeyDist.GetDefaultCell(TRUE, FALSE)->SetBackClr(_gGridFixCellColor);
|
m_PanelKeyDist.GetDefaultCell(FALSE, TRUE)->SetBackClr(_gGridFixCellColor);
|
m_PanelKeyDist.GetDefaultCell(FALSE, FALSE)->SetBackClr(_gGridCellColor);
|
m_PanelKeyDist.SetFixedTextColor(_gGridFixFontColor);
|
|
m_PanelKeyDist.SetRowCount(nRows);
|
m_PanelKeyDist.SetColumnCount(nCols);
|
m_PanelKeyDist.SetFixedRowCount(nFixRows);
|
m_PanelKeyDist.SetFixedColumnCount(nFixCols);
|
|
CFont *pFont = m_PanelKeyDist.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_PanelKeyDist.GetDefaultCell(FALSE, TRUE)->SetFont(&lf);
|
m_PanelKeyDist.GetDefaultCell(TRUE, FALSE)->SetFont(&lf);
|
m_PanelKeyDist.GetDefaultCell(FALSE, FALSE)->SetFont(&lf);
|
m_PanelKeyDist.GetDefaultCell(TRUE, TRUE)->SetFont(&lf);
|
}
|
|
// Col
|
for (int i = 0; i < nCols; i++) {
|
if (1 == i) {
|
m_PanelKeyDist.SetColumnWidth(nColIdx, 115);
|
}
|
else if (0 == i) {
|
m_PanelKeyDist.SetColumnWidth(nColIdx, 50);
|
}
|
else {
|
m_PanelKeyDist.SetColumnWidth(nColIdx, 75);
|
}
|
strText = m_vParams[i];
|
m_PanelKeyDist.SetItemText(nRowIdx, nColIdx++, strText);
|
}
|
|
for (int i = 1; i < nRows; i++){
|
m_PanelKeyDist.GetCell(i, 0)->SetState(GVIS_READONLY);
|
}
|
}
|
|
void CKDistSetDlg::setDimensionDir(DimensionDir eDir) {
|
/* code */
|
ChangeVisionType(eDir);
|
}
|
|
void CKDistSetDlg::ChangeVisionType(DimensionDir eDir) {
|
/* code */
|
SaveKDistParam();
|
|
m_eDir = eDir;
|
m_dot = CVisionRecipe::getInstance()->getKDistProcess(eDir);
|
|
ShowKDistParam();
|
}
|
|
void CKDistSetDlg::SaveKDistParam(void) {
|
/* code */
|
if (DIMENSION_NONE == m_eDir) return;
|
if (NULL == m_dot) return;
|
|
UpdateData(TRUE);
|
|
|
{
|
CButton *pBtnUse = (CButton*)(GetDlgItem(IDC_CHECK_USE_KDIST));
|
int iUse = pBtnUse->GetCheck();
|
m_dot->m_isUse = (1 == iUse);
|
|
int nValue = GetDlgItemInt(IDC_EDIT_ROI_LENGTH_SIZE_DIST);
|
m_dot->m_nRoiSize = nValue;
|
}
|
|
CString strText;
|
for (int i = 0; i < 50; i++) {
|
CKeyDistDotProcess *dot = m_dot->m_dots[i];
|
if (NULL == dot) continue;
|
|
//1. ID
|
int idRow = dot->getID();
|
int idx = 0;
|
strText = m_PanelKeyDist.GetItemText(idRow, idx);
|
idx += 1;
|
|
//2. Name
|
strText = m_PanelKeyDist.GetItemText(idRow, idx);
|
dot->m_strName = strText;
|
idx += 1;
|
|
//3. Use
|
strText = m_PanelKeyDist.GetItemText(idRow, idx);
|
dot->m_nUse = _wtoi(strText);
|
idx += 1;
|
|
//4.Pos Type
|
strText = m_PanelKeyDist.GetItemText(idRow, idx);
|
dot->m_poseType = _wtoi(strText);
|
idx += 1;
|
|
//5. Key X
|
strText = m_PanelKeyDist.GetItemText(idRow, idx);
|
dot->m_keyPoseX = _wtoi(strText);
|
idx += 1;
|
|
//6. Key Y
|
strText = m_PanelKeyDist.GetItemText(idRow, idx);
|
dot->m_keyPoseY = _wtoi(strText);
|
idx += 1;
|
|
//7. Pos X
|
strText = m_PanelKeyDist.GetItemText(idRow, idx);
|
dot->m_nPosX = _wtoi(strText);
|
idx += 1;
|
|
//8. Pos Y
|
strText = m_PanelKeyDist.GetItemText(idRow, idx);
|
dot->m_nPosY = _wtoi(strText);
|
idx += 1;
|
|
//9. End Type
|
strText = m_PanelKeyDist.GetItemText(idRow, idx);
|
dot->m_nEndThres = _wtoi(strText);
|
idx += 1;
|
|
//10. ROI Width
|
strText = m_PanelKeyDist.GetItemText(idRow, idx);
|
dot->m_nStdDist = _wtoi(strText);
|
idx += 1;
|
|
//11. Inc
|
strText = m_PanelKeyDist.GetItemText(idRow, idx);
|
dot->m_nInc = _wtoi(strText);
|
idx += 1;
|
|
//12. Min
|
strText = m_PanelKeyDist.GetItemText(idRow, idx);
|
dot->m_nMin = _wtoi(strText);
|
idx += 1;
|
|
//13. Max
|
strText = m_PanelKeyDist.GetItemText(idRow, idx);
|
dot->m_nMax = _wtoi(strText);
|
idx += 1;
|
}
|
}
|
|
void CKDistSetDlg::ShowKDistParam(void) {
|
/* code */
|
if (DIMENSION_NONE == m_eDir) return;
|
if (NULL == m_dot) return;
|
|
{
|
CButton *pBtnUse = (CButton*)(GetDlgItem(IDC_CHECK_USE_KDIST));
|
int iUse = 0;
|
if (m_dot->m_isUse) iUse = 1;
|
pBtnUse->SetCheck(iUse);
|
|
SetDlgItemInt(IDC_EDIT_ROI_LENGTH_SIZE_DIST, m_dot->m_nRoiSize);
|
}
|
|
CString strText;
|
for (int i = 0; i < 50; i++) {
|
CKeyDistDotProcess *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_PanelKeyDist.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//2. Name
|
strText = dot->m_strName;
|
m_PanelKeyDist.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//3. USE
|
strText.Format(_T("%d"), dot->m_nUse);
|
m_PanelKeyDist.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//4. Pos Type
|
strText.Format(_T("%d"), dot->m_poseType);
|
m_PanelKeyDist.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//5. Key X
|
strText.Format(_T("%d"), dot->m_keyPoseX);
|
m_PanelKeyDist.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//6. Key Y
|
strText.Format(_T("%d"), dot->m_keyPoseY);
|
m_PanelKeyDist.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//7. Pos X
|
strText.Format(_T("%d"), dot->m_nPosX);
|
m_PanelKeyDist.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//8. Pos Y
|
strText.Format(_T("%d"), dot->m_nPosY);
|
m_PanelKeyDist.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//9. End Type
|
strText.Format(_T("%d"), dot->m_nEndThres);
|
m_PanelKeyDist.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//10. Std
|
strText.Format(_T("%d"), dot->m_nStdDist);
|
m_PanelKeyDist.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//11. Inc
|
strText.Format(_T("%d"), dot->m_nInc);
|
m_PanelKeyDist.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//12. Min
|
strText.Format(_T("%d"), dot->m_nMin);
|
m_PanelKeyDist.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//13. Max
|
strText.Format(_T("%d"), dot->m_nMax);
|
m_PanelKeyDist.SetItemText(idRow, idx, strText);
|
idx += 1;
|
|
//14. Result
|
strText.Format(_T("%.1f"), dot->m_distResult);
|
m_PanelKeyDist.SetItemText(idRow, idx, strText);
|
idx += 1;
|
}
|
|
UpdateData(FALSE);
|
}
|
|
|
void CKDistSetDlg::OnBnClickedButtonProcessKdist()
|
{
|
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
|
CBlSideData *pSideData = CVisionRecipe::getInstance()->getSideData(m_eDir);
|
if (nullptr != pSideData) {
|
pSideData->m_vDispVisionResult.clear();
|
}
|
|
SaveKDistParam();
|
|
if (NULL == m_dot) return;
|
|
CLocProcess *pLoc = CVisionRecipe::getInstance()->getLocProcess(m_eDir);
|
if (NULL != pLoc) {
|
pLoc->execute(m_eDir);
|
}
|
|
m_dot->Execute(m_eDir);
|
|
DispAllResult();
|
|
}
|
|
void CKDistSetDlg::DispAllResult(void) {
|
/* code */
|
int nCount = 50;
|
for (int i = 0; i < 50; i++) {
|
CKeyDistDotProcess *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_PanelKeyDist.SetItemText(id, 13, _T("NAN"));
|
}
|
else{ //ÏÔʾ½á¹û
|
CString strResult;
|
strResult.Format(_T("%.1f"), dot->m_distResult);
|
int id = dot->getID();
|
m_PanelKeyDist.SetItemText(id, 13, strResult);
|
}
|
}
|
CSoftVisionApp::getInstance()->sendMessage(2, m_eDir);
|
|
m_PanelKeyDist.Invalidate(FALSE);
|
}
|
|
void CKDistSetDlg::OnBnClickedButtonSaveKdist()
|
{
|
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
|
SaveKDistParam();
|
}
|