www.pudn.com > Imagepro.rar > ParDlg.cpp


// ****************************************************************************** 
// *        图象处理算法库调用以及OPENGL图象操作示例 
// * ---------------------------------------------------------------------------- 
// CParDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "ImgPro.h" 
#include "ParDlg.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CParDlg dialog 
 
 
CParDlg::CParDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CParDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CParDlg) 
	mv_mask = 5; 
	mv_sigma = 10.0; 
	mv_percent = 2.f; 
	mv_threshold1 = 50; 
	mv_threshold2 = 150; 
	mv_pixels = 2; 
	//}}AFX_DATA_INIT 
} 
 
 
void CParDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CParDlg) 
	DDX_Control(pDX, IDC_EDIT_THRESHOLD2, m_threshold2); 
	DDX_Control(pDX, IDC_EDIT_THRESHOLD1, m_threshold1); 
	DDX_Control(pDX, IDC_EDIT_SIGMA, m_sigma); 
	DDX_Control(pDX, IDC_EDIT_PIXELS, m_pixels); 
	DDX_Control(pDX, IDC_EDIT_PERCENT, m_percent); 
	DDX_Control(pDX, IDC_EDIT_MASK, m_mask); 
	DDX_Text(pDX, IDC_EDIT_MASK, mv_mask); 
	DDV_MinMaxInt(pDX, mv_mask, 1, 32); 
	DDX_Text(pDX, IDC_EDIT_SIGMA, mv_sigma); 
	DDV_MinMaxDouble(pDX, mv_sigma, 1.e-003, 20.); 
	DDX_Text(pDX, IDC_EDIT_PERCENT, mv_percent); 
	DDV_MinMaxFloat(pDX, mv_percent, 1.e-003f, 100.f); 
	DDX_Text(pDX, IDC_EDIT_THRESHOLD1, mv_threshold1); 
	DDV_MinMaxInt(pDX, mv_threshold1, 0, 255); 
	DDX_Text(pDX, IDC_EDIT_THRESHOLD2, mv_threshold2); 
	DDV_MinMaxInt(pDX, mv_threshold2, 0, 255); 
	DDX_Text(pDX, IDC_EDIT_PIXELS, mv_pixels); 
	DDV_MinMaxInt(pDX, mv_pixels, 1, 20); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CParDlg, CDialog) 
	//{{AFX_MSG_MAP(CParDlg) 
	ON_EN_SETFOCUS(IDC_EDIT_MASK, OnSetfocusEditMask) 
	ON_EN_SETFOCUS(IDC_EDIT_SIGMA, OnSetfocusEditSigma) 
	ON_EN_SETFOCUS(IDC_EDIT_THRESHOLD1, OnSetfocusEditThreshold1) 
	ON_EN_SETFOCUS(IDC_EDIT_THRESHOLD2, OnSetfocusEditThreshold2) 
	ON_EN_SETFOCUS(IDC_EDIT_PERCENT, OnSetfocusEditPercent) 
	ON_EN_SETFOCUS(IDC_EDIT_PIXELS, OnSetfocusEditPixels) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CParDlg message handlers 
void CParDlg::OnSetfocusEditMask()  
{ 
	ImgOperationCase(); 
} 
void CParDlg::OnSetfocusEditSigma()  
{ 
	ImgOperationCase(); 
} 
 
void CParDlg::OnSetfocusEditThreshold1()  
{ 
	ImgOperationCase(); 
} 
 
void CParDlg::OnSetfocusEditThreshold2()  
{ 
	ImgOperationCase(); 
} 
 
void CParDlg::OnSetfocusEditPercent()  
{ 
	ImgOperationCase(); 
} 
 
void CParDlg::OnSetfocusEditPixels()  
{ 
	ImgOperationCase(); 
} 
void CParDlg::ImgOperationCase() 
{ 
	switch(eImgOpr) 
	{ 
	case eSMOOTH: 
	case eCANNY: 
		m_mask.EnableWindow(TRUE); 
		m_sigma.EnableWindow(TRUE); 
		m_threshold1.EnableWindow(FALSE);		 
		m_threshold2.EnableWindow(FALSE);		 
		m_percent.EnableWindow(FALSE);		 
		m_pixels.EnableWindow(FALSE);	 
		break; 
	case eSIMPLETHRESHOLD1: 
		m_mask.EnableWindow(FALSE); 
		m_sigma.EnableWindow(FALSE); 
		m_threshold1.EnableWindow(TRUE);		 
		m_threshold2.EnableWindow(FALSE);		 
		m_percent.EnableWindow(FALSE);		 
		m_pixels.EnableWindow(FALSE);	 
		break; 
	case eSIMPLETHRESHOLD2: 
		m_mask.EnableWindow(FALSE); 
		m_sigma.EnableWindow(FALSE); 
		m_threshold1.EnableWindow(TRUE);		 
		m_threshold2.EnableWindow(TRUE);		 
		m_percent.EnableWindow(FALSE);		 
		m_pixels.EnableWindow(FALSE);	 
		break; 
	case eGLOBALTHRESHOLD: 
	case eLINEFITTING: 
		m_mask.EnableWindow(FALSE); 
		m_sigma.EnableWindow(FALSE); 
		m_threshold1.EnableWindow(FALSE);		 
		m_threshold2.EnableWindow(FALSE);		 
		m_percent.EnableWindow(TRUE);		 
		m_pixels.EnableWindow(FALSE);	 
		break; 
	case eHOUGHTRANSFORM: 
		m_mask.EnableWindow(FALSE); 
		m_sigma.EnableWindow(FALSE); 
		m_threshold1.EnableWindow(FALSE);		 
		m_threshold2.EnableWindow(FALSE);		 
		m_percent.EnableWindow(FALSE);		 
		m_pixels.EnableWindow(TRUE);	 
		break; 
	default: break; 
	} 
 
}