397 lines
9.7 KiB
C++
397 lines
9.7 KiB
C++
// AscentDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "Resource.h"
|
|
#include "AscentDlg.h"
|
|
#include "AscentCreateDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CAscentCreateDlg dialog
|
|
CString CAscentCreateDlg::m_strAscentElev = _T("0");
|
|
CString CAscentCreateDlg::m_strAscentHeight = _T("450");
|
|
CString CAscentCreateDlg::m_strAscentIndent = _T("300");
|
|
CString CAscentCreateDlg::m_strAscentLen = _T("2100");
|
|
CString CAscentCreateDlg::m_strAscentWidth = _T("3000");
|
|
BOOL CAscentCreateDlg::m_bNeedAntiskid = TRUE;
|
|
BOOL CAscentCreateDlg::m_bLeftAlign = FALSE;
|
|
BOOL CAscentCreateDlg::m_bRightAlign = FALSE;
|
|
BOOL CAscentCreateDlg::m_bError=FALSE;
|
|
BOOL CAscentCreateDlg::m_bUpdateEdit=FALSE;
|
|
//初始化
|
|
//BOOL CAscentCreateDlg::m_bgroup2Status=TRUE;
|
|
//BOOL CAscentCreateDlg::m_bgroup1Status=FALSE;
|
|
// [9/20/2007 nsh]
|
|
CAscentCreateDlg *CAscentCreateDlg::m_bpSelfCAC=NULL;
|
|
IMPLEMENT_DYNAMIC(CAscentCreateDlg, CObjPreviewDlg)
|
|
CAscentCreateDlg::CAscentCreateDlg(CWnd* pParent /*=NULL*/)
|
|
: CObjPreviewDlg(CAscentCreateDlg::IDD, pParent)//,m_group1(WG_ST_HORZ),m_group2(WG_ST_HORZ)
|
|
{
|
|
//{{AFX_DATA_INIT(CAscentCreateDlg)
|
|
//}}AFX_DATA_INIT
|
|
//SetNeedCapBtn(TRUE);
|
|
}
|
|
|
|
|
|
void CAscentCreateDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CObjPreviewDlg::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CAscentCreateDlg)
|
|
DDX_Text(pDX, IDC_ASCENT_ELEV, m_strAscentElev); //坡顶标高
|
|
DDX_Text(pDX, IDC_ASCENT_HEIGHT, m_strAscentHeight);//坡道高度
|
|
DDX_Text(pDX, IDC_ASCENT_INDENT, m_strAscentIndent);//边坡高度
|
|
DDX_Text(pDX, IDC_ASCENT_LEN, m_strAscentLen);//坡道长度
|
|
DDX_Text(pDX, IDC_ASCENT_WIDTH, m_strAscentWidth);//坡道宽度
|
|
DDX_Check(pDX, IDC_NEEDANTISKID, m_bNeedAntiskid);//
|
|
DDX_Check(pDX, IDC_LEFT_ALIGN, m_bLeftAlign);
|
|
DDX_Check(pDX, IDC_RIGHT_ALIGN, m_bRightAlign);
|
|
//DDX_Control(pDX,IDC_GROUP1,m_group1);
|
|
//DDX_Control(pDX,IDC_GROUP2,m_group2);
|
|
//DDX_GroupStatus(pDX,IDC_GROUP1,m_bgroup1Status);
|
|
//DDX_GroupStatus(pDX,IDC_GROUP2,m_bgroup2Status);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CAscentCreateDlg, CObjPreviewDlg)
|
|
//{{AFX_MSG_MAP(CAscentCreateDlg)
|
|
ON_EN_KILLFOCUS(IDC_ASCENT_HEIGHT, OnKFAscHei)
|
|
ON_EN_KILLFOCUS(IDC_ASCENT_INDENT, OnKFAscInd)
|
|
ON_EN_KILLFOCUS(IDC_ASCENT_LEN, OnKFAscLen)
|
|
ON_EN_KILLFOCUS(IDC_ASCENT_WIDTH, OnKFAscWid)
|
|
ON_EN_KILLFOCUS(IDC_ASCENT_ELEV,OnKFAscEle)
|
|
ON_EN_CHANGE(IDC_ASCENT_HEIGHT,OnChangeAscHei)
|
|
ON_EN_CHANGE(IDC_ASCENT_INDENT,OnChangeAscInd)
|
|
ON_EN_CHANGE(IDC_ASCENT_LEN,OnChangeAscLen)
|
|
ON_EN_CHANGE(IDC_ASCENT_WIDTH,OnChangeAscWid)
|
|
ON_EN_CHANGE(IDC_ASCENT_ELEV,OnChangeAscEle)
|
|
ON_WM_NCDESTROY()
|
|
//}}AFX_MSG_MAP
|
|
ON_BN_CLICKED(IDC_LEFT_ALIGN, CAscentCreateDlg::OnBnClickedLeftAlign)
|
|
ON_BN_CLICKED(IDC_RIGHT_ALIGN, CAscentCreateDlg::OnBnClickedRightAlign)
|
|
ON_BN_CLICKED(IDC_NEEDANTISKID, CAscentCreateDlg::OnBnClickedNeedantiskid)
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CAscentCreateDlg message handlers
|
|
|
|
void CAscentCreateDlg::Dlg2Obj(AcDbEntity *pObj) // 公共部分
|
|
{
|
|
TDbAscent *pStep=TDbAscent::cast(pObj);
|
|
ASSERT(pStep);
|
|
pStep->SetWidth(_tstof(m_strAscentWidth));
|
|
pStep->SetHeight(_tstof(m_strAscentHeight));
|
|
pStep->SetLength(_tstof(m_strAscentLen));
|
|
pStep->SetIdent(_tstof(m_strAscentIndent));
|
|
pStep->SetSlant(m_bNeedAntiskid);
|
|
pStep->SetAlignment(OFFSET_LEFT, m_bLeftAlign);
|
|
pStep->SetAlignment(OFFSET_RIGHT, m_bRightAlign);
|
|
pStep->SetElevation(_tstof(m_strAscentElev));
|
|
return;
|
|
}
|
|
|
|
|
|
void CAscentCreateDlg::Obj2Dlg(const AcDbEntity *pObj)// 公共部分
|
|
{
|
|
TDbAscent *pStep=TDbAscent::cast(pObj);
|
|
ASSERT(pStep);
|
|
|
|
m_strAscentWidth = (const TCHAR *)Dist2Str(pStep->GetWidth());
|
|
m_strAscentHeight = (const TCHAR *)Dist2Str(pStep->GetHeight());
|
|
m_strAscentLen = (const TCHAR *)Dist2Str(pStep->GetLength());
|
|
m_strAscentIndent = (const TCHAR *)Dist2Str(pStep->GetIdent());
|
|
m_strAscentElev = (const TCHAR *)Dist2Str(pStep->GetElevation());
|
|
m_bNeedAntiskid = pStep->HasSlant();
|
|
m_bLeftAlign = pStep->IsAligned(OFFSET_LEFT);
|
|
m_bRightAlign = pStep->IsAligned(OFFSET_RIGHT);
|
|
return;
|
|
}
|
|
|
|
AcDbEntity * CAscentCreateDlg::NewObject()
|
|
{
|
|
TDbAscent *pEnt=new TDbAscent;
|
|
pEnt->setLayer(InitLayer(LAY_STAIR));
|
|
return pEnt;
|
|
}
|
|
|
|
BOOL CAscentCreateDlg::OnInitDialog()
|
|
{
|
|
CObjPreviewDlg::OnInitDialog();
|
|
AddTip(IDC_ASCENT_INDENT_TEXT);
|
|
UpdateImage();
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CAscentCreateDlg::OnClose()
|
|
{
|
|
acedPostCommand(_T("\33"));
|
|
CObjPreviewDlg::OnClose();
|
|
}
|
|
void CAscentCreateDlg::PostNcDestroy()
|
|
{
|
|
delete this;
|
|
}
|
|
bool CAscentCreateDlg::UpdateEdit(UINT ctrlID,bool bReportError)
|
|
{
|
|
if (GetSafeHwnd()==NULL)
|
|
{
|
|
return false;
|
|
}
|
|
CString temp;
|
|
this->GetDlgItemText(ctrlID,temp);
|
|
CDataExchange dOut(this,false);
|
|
switch(ctrlID)
|
|
{
|
|
case IDC_ASCENT_LEN:
|
|
{//坡道长度
|
|
CString ss=m_strAscentLen;
|
|
this->UpdateData();
|
|
TDbEntity *pStep=TDbEntity::cast(NewObject());
|
|
this->Dlg2Obj(pStep);
|
|
if (!pStep->IsValid())
|
|
{
|
|
CAscentCreateDlg::m_bError=TRUE;
|
|
this->MessageBox(_T("输入的坡道长度不正确,请正确填写"),_T("AutoCAD"),MB_OK);
|
|
m_strAscentLen=ss;
|
|
DDX_Text(&dOut,IDC_ASCENT_LEN,m_strAscentLen);
|
|
delete pStep;
|
|
}
|
|
else
|
|
{
|
|
this->UpdateData();
|
|
m_strAscentLen=temp;
|
|
this->UpdateData(FALSE);
|
|
this->UpdateImage();
|
|
delete pStep;
|
|
}
|
|
|
|
break;
|
|
}
|
|
case IDC_ASCENT_WIDTH:
|
|
{//坡道宽度
|
|
CString ss=m_strAscentWidth;
|
|
this->UpdateData();
|
|
TDbEntity *pStep=TDbEntity::cast(NewObject());
|
|
this->Dlg2Obj(pStep);
|
|
if (!pStep->IsValid())
|
|
{
|
|
CAscentCreateDlg::m_bError=TRUE;
|
|
this->MessageBox(_T("输入的坡道宽度不正确,请正确填写"),_T("AutoCAD"),MB_OK);
|
|
m_strAscentWidth=ss;
|
|
DDX_Text(&dOut,IDC_ASCENT_WIDTH,m_strAscentWidth);
|
|
delete pStep;
|
|
}
|
|
else
|
|
{
|
|
this->UpdateData();
|
|
m_strAscentWidth=temp;
|
|
this->UpdateData(FALSE);
|
|
this->UpdateImage();
|
|
delete pStep;
|
|
}
|
|
break;
|
|
}
|
|
case IDC_ASCENT_HEIGHT:
|
|
{//坡道高度
|
|
CString ss=m_strAscentHeight;
|
|
this->UpdateData();
|
|
TDbEntity *pStep=TDbEntity::cast(NewObject());
|
|
this->Dlg2Obj(pStep);
|
|
if (!pStep->IsValid())
|
|
{
|
|
CAscentCreateDlg::m_bError=TRUE;
|
|
this->MessageBox(_T("输入的坡道高度不正确,请正确填写"),_T("AutoCAD"),MB_OK);
|
|
m_strAscentHeight=ss;
|
|
DDX_Text(&dOut,IDC_ASCENT_HEIGHT,m_strAscentHeight);
|
|
delete pStep;
|
|
}
|
|
else
|
|
{
|
|
this->UpdateData();
|
|
m_strAscentHeight=temp;
|
|
this->UpdateData(FALSE);
|
|
this->UpdateImage();
|
|
delete pStep;
|
|
}
|
|
break;
|
|
}
|
|
case IDC_ASCENT_INDENT:
|
|
{//边坡宽度
|
|
CString ss=m_strAscentIndent;
|
|
this->UpdateData();
|
|
TDbEntity *pStep=TDbEntity::cast(NewObject());//判断数据是否具有有效性
|
|
this->Dlg2Obj(pStep);
|
|
if (!pStep->IsValid())
|
|
{
|
|
CAscentCreateDlg::m_bError=TRUE;
|
|
this->MessageBox(_T("输入的边坡宽度不正确,请正确填写"),_T("AutoCAD"),MB_OK);
|
|
m_strAscentIndent=ss;
|
|
DDX_Text(&dOut,IDC_ASCENT_INDENT,m_strAscentIndent);
|
|
delete pStep;
|
|
}
|
|
else
|
|
{
|
|
this->UpdateData();
|
|
m_strAscentIndent=temp;
|
|
this->UpdateData(FALSE);
|
|
this->UpdateImage();
|
|
delete pStep;
|
|
}
|
|
break;
|
|
}
|
|
case IDC_ASCENT_ELEV:
|
|
{//坡顶标高
|
|
CString ss=m_strAscentElev;
|
|
this->UpdateData();
|
|
TDbEntity *pStep=TDbEntity::cast(NewObject());
|
|
this->Dlg2Obj(pStep);
|
|
if (!pStep->IsValid())
|
|
{
|
|
CAscentCreateDlg::m_bError=TRUE;
|
|
this->MessageBox(_T("输入的坡顶标高不正确,请正确填写"),_T("AutoCAD"),MB_OK);
|
|
m_strAscentElev=ss;
|
|
DDX_Text(&dOut,IDC_ASCENT_ELEV,m_strAscentElev);
|
|
delete pStep;
|
|
}
|
|
else
|
|
{
|
|
this->UpdateData();
|
|
m_strAscentElev=temp;
|
|
this->UpdateData(FALSE);
|
|
this->UpdateImage();
|
|
delete pStep;
|
|
}
|
|
break;
|
|
|
|
}
|
|
case IDC_LEFT_ALIGN:
|
|
{//左对齐
|
|
UpdateImage();
|
|
break;
|
|
}
|
|
case IDC_RIGHT_ALIGN:
|
|
{//右对齐
|
|
UpdateImage();
|
|
break;
|
|
}
|
|
case IDC_NEEDANTISKID:
|
|
{
|
|
UpdateImage();
|
|
break;
|
|
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
m_bUpdateEdit=TRUE;
|
|
if (!CAscentCreateDlg::m_bError)
|
|
{
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
else
|
|
{
|
|
CAscentCreateDlg::m_bError=FALSE;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
//处理函数
|
|
void CAscentCreateDlg::OnChangeAscEle()
|
|
{
|
|
//do nothing
|
|
}
|
|
void CAscentCreateDlg::OnChangeAscHei()
|
|
{
|
|
//do nothing
|
|
}
|
|
void CAscentCreateDlg::OnChangeAscInd()
|
|
{
|
|
//do nothing
|
|
}
|
|
void CAscentCreateDlg::OnChangeAscLen()
|
|
{
|
|
//do nothing
|
|
}
|
|
void CAscentCreateDlg::OnChangeAscWid()
|
|
{
|
|
//do nothing
|
|
}
|
|
void CAscentCreateDlg::OnKFAscEle()
|
|
{//坡顶标高
|
|
if (this->CheckENChnange(IDC_ASCENT_ELEV,m_strAscentElev))
|
|
{
|
|
this->UpdateEdit(IDC_ASCENT_ELEV,true);
|
|
}
|
|
|
|
}
|
|
void CAscentCreateDlg::OnKFAscHei()
|
|
{//坡道高度
|
|
if (this->CheckENChnange(IDC_ASCENT_HEIGHT,m_strAscentHeight))
|
|
{
|
|
this->UpdateEdit(IDC_ASCENT_HEIGHT,true);
|
|
}
|
|
|
|
}
|
|
void CAscentCreateDlg::OnKFAscWid()
|
|
{//坡道宽度
|
|
if (this->CheckENChnange(IDC_ASCENT_WIDTH,m_strAscentWidth))
|
|
{
|
|
this->UpdateEdit(IDC_ASCENT_WIDTH,true);
|
|
}
|
|
|
|
}
|
|
void CAscentCreateDlg::OnKFAscLen()
|
|
{//坡道长度
|
|
if (this->CheckENChnange(IDC_ASCENT_LEN,m_strAscentLen))
|
|
{
|
|
this->UpdateEdit(IDC_ASCENT_LEN,true);
|
|
}
|
|
|
|
}
|
|
void CAscentCreateDlg::OnKFAscInd()
|
|
{//边坡宽度
|
|
if (this->CheckENChnange(IDC_ASCENT_INDENT,m_strAscentIndent))
|
|
{
|
|
this->UpdateEdit(IDC_ASCENT_INDENT,true);
|
|
}
|
|
|
|
}
|
|
void CAscentCreateDlg::OnCancel()
|
|
{
|
|
CAscentCreateDlg::m_bpSelfCAC=NULL;
|
|
CObjPreviewDlg::OnCancel();
|
|
acedPostCommand(_T("\33"));
|
|
|
|
}
|
|
void CAscentCreateDlg::OnBnClickedLeftAlign()
|
|
{
|
|
this->UpdateEdit(IDC_LEFT_ALIGN,true);
|
|
}
|
|
|
|
void CAscentCreateDlg::OnBnClickedRightAlign()
|
|
{
|
|
this->UpdateEdit(IDC_RIGHT_ALIGN,true);
|
|
}
|
|
|
|
void CAscentCreateDlg::OnBnClickedNeedantiskid()
|
|
{
|
|
this->UpdateEdit(IDC_NEEDANTISKID,true);
|
|
}
|
|
BOOL CAscentCreateDlg::CheckENChnange(UINT ctrlID,const CString pStr)
|
|
{//检查是否编辑框的内容发生改变,如果发生改变则返回TRUE,否则返回FALSE
|
|
CString temp;
|
|
this->GetDlgItemText(ctrlID,temp);
|
|
if (temp==pStr)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
} |