Files
envi-code/SourceCode/Code2026/tg_shs/shs_siteplan/DrawRoadDlg.cpp
T
2026-09-28 15:28:50 +08:00

188 lines
4.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "stdafx.h"
#include "DrawRoadDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// 初始化全局变量
double CDrawRoadDlg::m_dLeftWidthMM = 2000.0; // 左宽
double CDrawRoadDlg::m_dRightWidthMM = 2000.0; // 右宽
double CDrawRoadDlg::m_dChamferRadiusMM = 5000.0; // 倒角半径
BOOL CDrawRoadDlg::m_bChamfer = TRUE;
BOOL CDrawRoadDlg::m_bDrawCenLine = TRUE;
int CDrawRoadDlg::m_iPositionLineStyle = 0;
int CDrawRoadDlg::m_iFilletStyle = 0;
CDrawRoadDlg::CDrawRoadDlg(CWnd* pParent /*=NULL*/)
: CModelessDialog(CDrawRoadDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDrawRoadDlg)
m_dLeftWidth = _AS_SYS_UNIT(m_dLeftWidthMM);
m_dRightWidth = _AS_SYS_UNIT(m_dRightWidthMM);
m_dChamferRadius = _AS_SYS_UNIT(m_dChamferRadiusMM);
//}}AFX_DATA_INIT
m_nCmdNum = 1;
}
CDrawRoadDlg::~CDrawRoadDlg()
{
}
void CDrawRoadDlg::DoDataExchange(CDataExchange* pDX)
{
CModelessDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDrawRoadDlg)
DDX_Radio(pDX, IDC_RAD_BASELINE, m_iPositionLineStyle);
DDX_Text(pDX, IDC_EDT_LEFTWIDTH, m_dLeftWidth);
DDX_Text(pDX, IDC_EDT_RIGHTWIDTH, m_dRightWidth);
DDX_Text(pDX, IDC_EDT_CHAMFER_RADIUS, m_dChamferRadius);
DDX_Check(pDX, IDC_CHK_CENTRELINE, m_bDrawCenLine);
DDX_Check(pDX, IDC_CHK_CHARMFER, m_bChamfer);
DDX_Radio(pDX, IDC_RAD_SAME_CENTER, m_iFilletStyle);
//}}AFX_DATA_MAP
m_dLeftWidthMM = _AS_MM(m_dLeftWidth);
m_dRightWidthMM = _AS_MM(m_dRightWidth);
m_dChamferRadiusMM = _AS_MM(m_dChamferRadius);
}
BEGIN_MESSAGE_MAP(CDrawRoadDlg, CModelessDialog)
//{{AFX_MSG_MAP(CDrawRoadDlg)
ON_WM_CLOSE()
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_CHK_CHARMFER, OnBnClickedChkCharmfer)
ON_EN_KILLFOCUS(IDC_EDT_CHAMFER_RADIUS, OnEnKillfocusEdtChamferRadius)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CDrawRoadDlg::SetCharmerBtnState(BOOL bEnable)
{
GetDlgItem(IDC_RAD_SAME_CENTER)->EnableWindow(bEnable);
GetDlgItem(IDC_RAD_SAME_RADIUS)->EnableWindow(bEnable);
GetDlgItem(IDC_EDT_CHAMFER_RADIUS)->EnableWindow(bEnable);
}
BOOL CDrawRoadDlg::OnInitDialog()
{
CModelessDialog::OnInitDialog();
// 获取当前的绘图单位 bIsMetre=true:M;bIsMetre=false:mm
BOOL bIsMetre = DocGetMeterUnitDraw();
// 对话框标题设置
if(bIsMetre)
{
this->SetWindowText(_T("道路绘制(单位:M)"));
}
else
{
this->SetWindowText(_T("道路绘制(单位:mm)"));
}
SetCharmerBtnState(m_bChamfer);
return TRUE;
}
void CDrawRoadDlg::OnClose()
{
CModelessDialog::OnClose();
if (m_nCmdNum > 1)
{
acedPostCommand(_T("\33"));
}
if (m_nCmdNum == 2)
{
acedPostCommand(_T("\33"));
}
}
void CDrawRoadDlg::OnDestroy()
{
CModelessDialog::OnDestroy();
}
double CDrawRoadDlg::GetLeftWidthMM()
{
UpdateData(TRUE);
return m_dLeftWidthMM;
}
double CDrawRoadDlg::GetRightWidthMM()
{
UpdateData(TRUE);
return m_dRightWidthMM;
}
double CDrawRoadDlg::GetCharmRadiusMM()
{
UpdateData(TRUE);
return m_dChamferRadiusMM;
}
double CDrawRoadDlg::GetLeftWidthSys()
{
return _AS_SYS_UNIT(GetLeftWidthMM());
}
double CDrawRoadDlg::GetRightWidthSys()
{
return _AS_SYS_UNIT(GetRightWidthMM());
}
double CDrawRoadDlg::GetCharmRadiusSys()
{
return _AS_SYS_UNIT(GetCharmRadiusMM());
}
// 是否倒角
void CDrawRoadDlg::OnBnClickedChkCharmfer()
{
// UpdateData(true); // 设置关于倒角方式的几个按钮。
CButton *pcheck = (CButton*)GetDlgItem(IDC_CHK_CHARMFER);
UINT uStat = pcheck->GetCheck();
SetCharmerBtnState(uStat);
}
CDrawRoadDlg::EPositionLineType CDrawRoadDlg::PositionLineStyle()
{
UpdateData(TRUE);
return EPositionLineType(m_iPositionLineStyle);// 转换为枚举。
}
EFilletStyle CDrawRoadDlg::FilletStyle()
{
UpdateData(TRUE);
if (m_iFilletStyle == 0)
return eSameCenter;
else if (m_iFilletStyle == 1)
return eSameRadius;
return EFilletStyle(m_iFilletStyle) ;
}
//axc add 2015-10-19 当倒角半径为空时防止UpdateData更新数据时不断弹出错误提示
void CDrawRoadDlg::OnEnKillfocusEdtChamferRadius()
{
CString sValue = _T("");
GetDlgItem(IDC_EDT_CHAMFER_RADIUS)->GetWindowText(sValue);
if (sValue.IsEmpty())
{
sValue = _T("1000");
GetDlgItem(IDC_EDT_CHAMFER_RADIUS)->SetWindowText(sValue);
}
UpdateData(TRUE);
}