📄 setdialog.cpp
字号:
// SetDialog.cpp : implementation file
//
#include "stdafx.h"
#include "convexHull.h"
#include "SetDialog.h"
#include "iostream.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
COLORREF lineColor, nodeColor;
int nodeType, N, xMin, xMax, yMin, yMax;
CString pDataFileName;
BOOL selectFileFlag;
/////////////////////////////////////////////////////////////////////////////
// CSetDialog dialog
CSetDialog::CSetDialog(CWnd* pParent /*=NULL*/)
: CDialog(CSetDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CSetDialog)
m_num = 0;
m_xmin = 0;
m_xmax = 0;
m_ymin = 0;
m_ymax = 0;
m_filepath = _T("");
//}}AFX_DATA_INIT
N = 0;
xMin = 0;
xMax = 0;
yMin = 0;
yMax = 0;
m_num = 3;
m_xmin = 10;
m_ymin = 10;
m_xmax = 900;
m_ymax = 500;
nodeType = 0;
pDataFileName = "";
selectFileFlag = false;
lineColor = RGB(255,0,0);
nodeColor = RGB(0,0,0);
}
void CSetDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSetDialog)
DDX_Text(pDX, IDC_EDIT_NUM, m_num);
DDV_MinMaxInt(pDX, m_num, 1, 1000000);
DDX_Text(pDX, IDC_EDIT_XMIN, m_xmin);
DDV_MinMaxInt(pDX, m_xmin, 0, 1000);
DDX_Text(pDX, IDC_EDIT_XMAX, m_xmax);
DDV_MinMaxInt(pDX, m_xmax, 0, 1000);
DDX_Text(pDX, IDC_EDIT_YMIN, m_ymin);
DDV_MinMaxInt(pDX, m_ymin, 0, 1000);
DDX_Text(pDX, IDC_EDIT_YMAX, m_ymax);
DDV_MinMaxInt(pDX, m_ymax, 0, 1000);
DDX_Text(pDX, IDC_EDIT_FILEPATH, m_filepath);
DDV_MaxChars(pDX, m_filepath, 5000);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSetDialog, CDialog)
//{{AFX_MSG_MAP(CSetDialog)
ON_BN_CLICKED(IDC_BUTTON_POINTCLR, OnButtonPoint)
ON_BN_CLICKED(IDC_BUTTON_LINECLR, OnButtonLine)
ON_EN_CHANGE(IDC_EDIT_NUM, OnChangeEditNum)
ON_EN_CHANGE(IDC_EDIT_XMIN, OnChangeEditXmin)
ON_EN_CHANGE(IDC_EDIT_XMAX, OnChangeEditXmax)
ON_EN_CHANGE(IDC_EDIT_YMIN, OnChangeEditYmin)
ON_EN_CHANGE(IDC_EDIT_YMAX, OnChangeEditYmax)
ON_BN_CLICKED(IDC_RADIO_CIRCLE, OnRadioCircle)
ON_BN_CLICKED(IDC_RADIO_CROSS, OnRadioCross)
ON_BN_CLICKED(IDC_BUTTON_SELECTFILE, OnButtonSelectFile)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSetDialog message handlers
void CSetDialog::OnButtonPoint()
{
// TODO: Add your control notification handler code here
CColorDialog dlg;
dlg.m_cc.Flags |= CC_FULLOPEN | CC_RGBINIT;
dlg.m_cc.rgbResult = RGB(0,0,0);
if(IDOK == dlg.DoModal())
{
nodeColor = dlg.GetColor();
// this->GetDlgItem(IDC_EDIT_POINTCLR)->SetColor(nodeColor);
}
}
void CSetDialog::OnButtonLine()
{
// TODO: Add your control notification handler code here
CColorDialog dlg;
dlg.m_cc.Flags |= CC_FULLOPEN | CC_RGBINIT;
dlg.m_cc.rgbResult = RGB(255,0,0);
if(IDOK == dlg.DoModal())
{
lineColor = dlg.GetColor();
// this->GetDlgItem(IDC_EDIT_POINTCLR)->SetSel(0,-1);
}
}
void CSetDialog::OnOK()
{
// TODO: Add extra validation here
if(!selectFileFlag) MessageBox("请选择数据文件将要保存的路径! ^-^");
N = m_num;
xMin = m_xmin;
xMax = m_xmax;
yMin = m_ymin;
yMax = m_ymax;
CDialog::OnOK();
}
void CSetDialog::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CSetDialog::OnChangeEditNum()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CSetDialog::OnChangeEditXmin()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CSetDialog::OnChangeEditXmax()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CSetDialog::OnChangeEditYmin()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CSetDialog::OnChangeEditYmax()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CSetDialog::OnRadioCircle()
{
// TODO: Add your control notification handler code here
nodeType = 0;
}
void CSetDialog::OnRadioCross()
{
// TODO: Add your control notification handler code here
nodeType = 1;
}
void CSetDialog::OnButtonSelectFile()
{
// TODO: Add your control notification handler code here
char szFileFilter[] = "text files(*.txt)";
CFileDialog dlg(
FALSE, //Save对话框(false为保存对话框)
"txt", //缺省扩展名
".txt",
OFN_OVERWRITEPROMPT|OFN_EXPLORER|OFN_LONGNAMES, //文件标志
szFileFilter
);
if(dlg.DoModal()==IDOK)
{
strcpy(pDataFileName.GetBuffer(128),dlg.GetPathName());
UpdateData();
m_filepath = pDataFileName;
UpdateData(FALSE);
selectFileFlag = true;
}
else return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -