787 lines
21 KiB
C++
787 lines
21 KiB
C++
|
|
#include "stdafx.h"
|
|
#include "resource.h"
|
|
#include "LineStairCreateDlg.h"
|
|
#include "acutads.h"
|
|
#include "dbjig.h"
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CLineStairCreateDlg dialog
|
|
CString CLineStairCreateDlg::m_strStairWidth = _T("1200");
|
|
CString CLineStairCreateDlg::m_strStepWidth = _T("270");
|
|
CString CLineStairCreateDlg::m_strStairLength = _T("5130");
|
|
BOOL CLineStairCreateDlg::m_bGetStair=FALSE;
|
|
BOOL CLineStairCreateDlg::m_mm=TRUE;
|
|
TDbLineStair* CLineStairCreateDlg::pStepTest=NULL;
|
|
CLineStairCreateDlg *CLineStairCreateDlg::pSelfCSC =NULL;
|
|
//以下对填写出现错误的静态变量实现初始化
|
|
BOOL CLineStairCreateDlg::m_bError=FALSE;
|
|
//以下是对ESC键响应的变量的初始化
|
|
BOOL CLineStairCreateDlg::m_bUpdateEdit=FALSE;
|
|
BOOL CLineStairCreateDlg::m_bPickSW = FALSE;
|
|
//-----------------------------------------
|
|
//IDC_GROUP1的状态 FALSE 为合拢状态 TRUE为展开状态
|
|
BOOL CLineStairCreateDlg::m_bGroupStatus=FALSE;
|
|
//操作wgroupctrl
|
|
BOOL CLineStairCreateDlg::m_bOpWgc =FALSE;
|
|
IMPLEMENT_DYNAMIC(CLineStairCreateDlg, CBaseStairDlg)
|
|
CLineStairCreateDlg::CLineStairCreateDlg(CWnd* pParent /*=NULL*/)
|
|
:CBaseStairDlg(CLineStairCreateDlg::IDD, pParent),bValidWnd(false)
|
|
,m_blAscent(FALSE)
|
|
{
|
|
m_strStairLength=Dist2Str(_tstof(m_strStepWidth)*(m_bAsAscent? m_nStepNum : m_nStepNum-1));
|
|
|
|
m_bEdit=FALSE;//处于非编辑状态
|
|
m_pBakObj=NULL;//为空状态
|
|
m_bClickClose=FALSE;
|
|
}
|
|
#include "wgroupdlg.h"
|
|
CLineStairCreateDlg::CLineStairCreateDlg(UINT id,CWnd* pParent /*=NULL*/)
|
|
: CBaseStairDlg(id, pParent)
|
|
{
|
|
/*m_groups.Append(&m_group1);
|
|
m_groups.Append(&m_group2);
|
|
m_groups.Append(&m_group3);*/
|
|
//m_groups.SetMaxExtent(10);
|
|
//SetNeedCapBtn(TRUE);
|
|
m_strStairLength=Dist2Str(_tstof(m_strStepWidth)*(m_bAsAscent? m_nStepNum : m_nStepNum-1));
|
|
|
|
m_bEdit=FALSE;//处于非编辑状态
|
|
m_pBakObj=NULL;//为空状态
|
|
m_bClickClose=FALSE;
|
|
}
|
|
|
|
CLineStairCreateDlg::~CLineStairCreateDlg()
|
|
{
|
|
if (m_bEdit)
|
|
{
|
|
if (m_pBakObj)
|
|
delete m_pBakObj;//这个地方是不是有问题
|
|
}
|
|
}
|
|
|
|
AcDbEntity *CLineStairCreateDlg::NewObject()
|
|
{
|
|
if (m_pBakObj==NULL)
|
|
{
|
|
TDbLineStair *pStair=new TDbLineStair;
|
|
pStair->setLayer(InitLayer(LAY_STAIR));
|
|
return pStair;
|
|
}
|
|
return (AcDbEntity*)(m_pBakObj->clone());
|
|
}
|
|
void CLineStairCreateDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CBaseStairDlg::DoDataExchange(pDX);
|
|
DDX_Control(pDX,IDC_GROUP3,m_WGroup);
|
|
DDX_GroupStatus(pDX,IDC_GROUP3,m_bGroupStatus);
|
|
DDX_CBString(pDX,IDC_COMBO_STAIRHEIGHT,m_strStairHeight);//对楼梯高度映射
|
|
//DDX_GroupStatus(
|
|
//{{AFX_DATA_MAP(CLineStairCreateDlg)
|
|
//}}AFX_DATA_MAP
|
|
if (!pDX->m_bSaveAndValidate)
|
|
{
|
|
DDX_Text(pDX, IDC_STAIR_WIDTH, m_strStairWidth);
|
|
DDX_Text(pDX, IDC_STEP_WIDTH, m_strStepWidth);
|
|
DDX_Text(pDX, IDC_STAIR_LENGTH, m_strStairLength);
|
|
}
|
|
DDX_Check(pDX, IDC_AS_ASCENT, m_blAscent);
|
|
|
|
}
|
|
BEGIN_MESSAGE_MAP(CLineStairCreateDlg, CBaseStairDlg)
|
|
//{{AFX_MSG_MAP(CLineStairCreateDlg)
|
|
ON_BN_CLICKED(IDC_PICK_STAIRWIDTH, OnPickStairWidth)
|
|
ON_EN_CHANGE(IDC_STAIR_WIDTH,OnChangeStairWidth)
|
|
ON_EN_CHANGE(IDC_STEP_WIDTH,OnChangeStepWidth)
|
|
ON_EN_CHANGE(IDC_STAIR_LENGTH,OnChangeStairLength)
|
|
ON_EN_CHANGE(IDC_STEP_HEIGHT,OnChangeStepHeight)
|
|
ON_EN_CHANGE(IDC_STEP_NUM,OnChangeStepNum)
|
|
//}}AFX_MSG_MAP
|
|
ON_WM_NCDESTROY()
|
|
ON_WM_CLOSE()
|
|
ON_BN_CLICKED(IDC_LEFT_BEAM, CLineStairCreateDlg::OnBnClickedLeftBeam)
|
|
ON_BN_CLICKED(IDC_RIGHT_BEAM, CLineStairCreateDlg::OnBnClickedRightBeam)
|
|
ON_BN_CLICKED(IDC_NEED3D, CLineStairCreateDlg::OnBnClickedNeed3d)
|
|
ON_BN_CLICKED(IDC_NEED2D, CLineStairCreateDlg::OnBnClickedNeed2d)
|
|
ON_BN_CLICKED(IDC_NO_PAO, CLineStairCreateDlg::OnBnClickedNoPao)
|
|
ON_BN_CLICKED(IDC_BOTTOM_PAO, CLineStairCreateDlg::OnBnClickedBottomPao)
|
|
ON_BN_CLICKED(IDC_DOUBLE_PAO, CLineStairCreateDlg::OnBnClickedDoublePao)
|
|
ON_BN_CLICKED(IDC_UP_SECT, CLineStairCreateDlg::OnBnClickedUpSect)
|
|
ON_BN_CLICKED(IDC_HAS_SLANT, CLineStairCreateDlg::OnBnClickedHasSlant)
|
|
ON_BN_CLICKED(IDC_ON_GROUND, CLineStairCreateDlg::OnBnClickedOnGround)
|
|
ON_BN_CLICKED(IDC_AS_ASCENT, CLineStairCreateDlg::OnBnClickedAsAscent)
|
|
ON_WM_KEYUP()
|
|
//ON_EN_KILLFOCUS(IDC_STAIR_HEIGHT,OnKFStairHeight)
|
|
ON_CBN_KILLFOCUS(IDC_COMBO_STAIRHEIGHT,OnKFStairHeight)//楼梯失去交点的操作
|
|
ON_EN_KILLFOCUS(IDC_STAIR_WIDTH,OnKFStairWidth)
|
|
ON_EN_KILLFOCUS(IDC_STEP_WIDTH,OnKFStepWidth)
|
|
ON_EN_KILLFOCUS(IDC_STAIR_LENGTH,OnKFStairLength)
|
|
ON_EN_KILLFOCUS(IDC_STEP_NUM,OnKFStepNum)
|
|
ON_EN_KILLFOCUS(IDC_STEP_HEIGHT,OnKFStepHeight)
|
|
|
|
END_MESSAGE_MAP()
|
|
void CLineStairCreateDlg::OnChangeStairWidth()
|
|
{
|
|
|
|
}
|
|
void CLineStairCreateDlg::OnChangeStepNum()
|
|
{
|
|
//modify by xlc on 090325
|
|
CString temp;
|
|
this->GetDlgItem(IDC_STEP_NUM)->GetWindowText(temp);
|
|
if (temp!=_T("")&&temp!=_T("1"))
|
|
{
|
|
UpdateEdit(IDC_STEP_NUM,false);
|
|
}
|
|
}
|
|
void CLineStairCreateDlg::OnChangeStepWidth()
|
|
{
|
|
}
|
|
void CLineStairCreateDlg::OnChangeStairLength()
|
|
{
|
|
}
|
|
void CLineStairCreateDlg::OnKFStepHeight()//-----------------------------------
|
|
{
|
|
// if (this->CheckENChange(IDC_STEP_HEIGHT,m_strStepHeight))
|
|
// {
|
|
// this->UpdateEdit(IDC_STEP_HEIGHT,true);
|
|
// ::acedPostCommand(_T("\33"));
|
|
// }
|
|
if (m_bClickClose)
|
|
return;
|
|
if (GetFocus()!=GetDlgItem(IDCANCEL))
|
|
{
|
|
CString strText;
|
|
GetDlgItem(IDC_STEP_HEIGHT)->GetWindowText(strText);
|
|
if (fabs(_tstof(strText)-_tstof(m_strStepHeight))<_DIST_SNAP)
|
|
return;
|
|
|
|
UpdateEdit(IDC_STEP_HEIGHT,true);
|
|
}
|
|
}
|
|
void CLineStairCreateDlg::OnKFStepNum()
|
|
{
|
|
//modiby by xlc on 090325
|
|
// BOOL bresult;
|
|
// int x = this->GetDlgItemInt(IDC_STEP_NUM,&bresult,FALSE);
|
|
//
|
|
// if (x!= m_nStepNum)
|
|
// {
|
|
// this->UpdateEdit(IDC_STEP_NUM,true);
|
|
// acedPostCommand(_T("\33"));
|
|
// }
|
|
if (m_bClickClose)
|
|
return;
|
|
if (GetFocus()!=GetDlgItem(IDCANCEL))
|
|
{
|
|
CString strText;
|
|
GetDlgItem(IDC_STEP_NUM)->GetWindowText(strText);
|
|
if (fabs(_tstof(strText)-m_nStepNum)<_DIST_SNAP)
|
|
return;
|
|
|
|
UpdateEdit(IDC_STEP_NUM,true);
|
|
}
|
|
}
|
|
void CLineStairCreateDlg::OnKFStairWidth()
|
|
{
|
|
//modiby by xlc on 090325
|
|
// if (this->CheckENChange(IDC_STAIR_WIDTH,m_strStairWidth))
|
|
// {
|
|
// this->UpdateEdit(IDC_STAIR_WIDTH,true);
|
|
// ::acedPostCommand(_T("\33"));
|
|
// }
|
|
if (m_bClickClose)
|
|
return;
|
|
if (GetFocus()!=GetDlgItem(IDCANCEL))
|
|
{
|
|
CString strText;
|
|
GetDlgItem(IDC_STAIR_WIDTH)->GetWindowText(strText);
|
|
if (fabs(_tstof(strText)-_tstof(m_strStairWidth))<_DIST_SNAP)
|
|
return;
|
|
|
|
UpdateEdit(IDC_STAIR_WIDTH,true);
|
|
}
|
|
}
|
|
void CLineStairCreateDlg::OnKFStepWidth()//----------------------------
|
|
{
|
|
//modiby by xlc on 090325
|
|
// if (this->CheckENChange(IDC_STEP_WIDTH,m_strStepWidth))
|
|
// {
|
|
// this->UpdateEdit(IDC_STEP_WIDTH,true);
|
|
// ::acedPostCommand(_T("\33"));
|
|
// }
|
|
if (m_bClickClose)
|
|
return;
|
|
if (GetFocus()!=GetDlgItem(IDCANCEL))
|
|
{
|
|
CString strText;
|
|
GetDlgItem(IDC_STEP_WIDTH)->GetWindowText(strText);
|
|
if (fabs(_tstof(strText)-_tstof(m_strStepWidth))<_DIST_SNAP)
|
|
return;
|
|
|
|
UpdateEdit(IDC_STEP_WIDTH,true);
|
|
}
|
|
}
|
|
void CLineStairCreateDlg::OnKFStairLength()
|
|
{
|
|
//modiby by xlc on 090325
|
|
// if (this->CheckENChange(IDC_STAIR_LENGTH,m_strStairLength))
|
|
// {
|
|
// this->UpdateEdit(IDC_STAIR_LENGTH,true);
|
|
// ::acedPostCommand(_T("\33"));
|
|
// }
|
|
if (m_bClickClose)
|
|
return;
|
|
if (GetFocus()!=GetDlgItem(IDCANCEL))
|
|
{
|
|
CString strText;
|
|
GetDlgItem(IDC_STAIR_LENGTH)->GetWindowText(strText);
|
|
if (fabs(_tstof(strText)-_tstof(m_strStairLength))<_DIST_SNAP)
|
|
return;
|
|
|
|
UpdateEdit(IDC_STAIR_LENGTH,true);
|
|
}
|
|
}
|
|
void CLineStairCreateDlg::OnKFStairHeight()
|
|
{
|
|
//modiby by xlc on 090325
|
|
// if (this->CheckENChange(IDC_COMBO_STAIRHEIGHT,m_strStairHeight))
|
|
// {
|
|
// this->UpdateEdit(IDC_COMBO_STAIRHEIGHT,true);
|
|
// ::acedPostCommand(_T("\33"));
|
|
// }
|
|
if (m_bClickClose)
|
|
return;
|
|
if (GetFocus()!=GetDlgItem(IDCANCEL))
|
|
{
|
|
//modiby by xlc on 090317
|
|
CString strText;
|
|
GetDlgItem(IDC_COMBO_STAIRHEIGHT)->GetWindowText(strText);
|
|
if (fabs(_tstof(strText)-_tstof(m_strStairHeight))<_DIST_SNAP)
|
|
return;
|
|
|
|
UpdateEdit(IDC_COMBO_STAIRHEIGHT,true);
|
|
}
|
|
}
|
|
void CLineStairCreateDlg::OnChangeStepHeight()
|
|
{
|
|
//to do nothing
|
|
}
|
|
BOOL CLineStairCreateDlg::OnInitDialog()
|
|
{
|
|
//初始化对话窗
|
|
//设置对话窗的大小
|
|
CBaseStairDlg::OnInitDialog();
|
|
//m_groups.SetMaxExtent(310);
|
|
this->UpdateData();
|
|
this->UpdateData(FALSE);
|
|
bValidWnd=true;
|
|
|
|
if (m_bEdit)
|
|
{
|
|
GetDlgItem(IDC_STEP_ELEV)->EnableWindow(TRUE);
|
|
}
|
|
else
|
|
{
|
|
m_strElev="0";
|
|
CRect rect,rect1;
|
|
GetDlgItem(IDC_PREVIEW)->GetWindowRect(rect);
|
|
GetDlgItem(IDOK)->GetWindowRect(rect1);
|
|
|
|
ScreenToClient(rect);
|
|
ScreenToClient(rect1);
|
|
rect.bottom = rect1.bottom;
|
|
GetDlgItem(IDC_PREVIEW)->MoveWindow(rect);
|
|
|
|
GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
|
|
}
|
|
|
|
UpdateImage();
|
|
return TRUE;
|
|
}
|
|
void CLineStairCreateDlg::OnPickStairWidth()
|
|
{
|
|
if (m_bEdit)
|
|
{
|
|
double nStairWidth=_tstof(m_strStairWidth);
|
|
|
|
BeginEditorCommand();
|
|
int nRet=GetDist(_T("\n梯段宽度"), nStairWidth, RSG_NOZERO|RSG_NONEG);
|
|
CompleteEditorCommand();
|
|
|
|
if (nRet==RTNORM)
|
|
{
|
|
CString temp=Dist2Str(nStairWidth);
|
|
CDataExchange dxOut(this,false);
|
|
DDX_Text(&dxOut,IDC_STAIR_WIDTH,temp);
|
|
UpdateEdit(IDC_STAIR_WIDTH,true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
CLineStairCreateDlg::m_bGetStair=TRUE;
|
|
acedGetAcadDwgView()->SetFocus();
|
|
this->ShowWindow(SW_HIDE);
|
|
CLineStairCreateDlg::m_bPickSW=TRUE;
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
}
|
|
//数据关系:
|
|
//梯段长度变化会引起踏步宽度同比例变化;
|
|
//踏步宽度变化会引起梯段长度同比例变化;
|
|
//踏步数变化会引起踏步宽度反向变化。
|
|
// 对于坡道: 长度=步距*步数
|
|
// 对于梯段: 长度=步距*(步数-1)
|
|
bool CLineStairCreateDlg::UpdateEdit(UINT ctrlID,bool bReportError)
|
|
{
|
|
CWnd *pImageBox=GetDlgItem(IDC_PREVIEW);
|
|
if (!pImageBox)
|
|
return false;
|
|
|
|
bool result=false;
|
|
if (!bValidWnd)
|
|
return false;
|
|
CEdit *pEdit=(CEdit*)GetDlgItem(ctrlID);
|
|
if (pEdit==NULL)
|
|
return false;
|
|
|
|
static bool bUpdating=false;
|
|
if (bUpdating)
|
|
return false;
|
|
bUpdating=true;
|
|
CDataExchange dxOut(this,false);
|
|
|
|
if (ctrlID==IDC_STAIR_LENGTH||ctrlID==IDC_STEP_WIDTH||ctrlID==IDC_STAIR_WIDTH
|
|
||IDC_STEP_NUM||IDC_STEP_HEIGHT||IDC_STAIR_HEIGHT || ctrlID==IDC_COMBO_STAIRHEIGHT)
|
|
{
|
|
CString temp;
|
|
pEdit->GetWindowText(temp);
|
|
if (ctrlID==IDC_STAIR_LENGTH)
|
|
{
|
|
if (_tstof(temp)>0)
|
|
{
|
|
//对梯段长度和踏步宽度的保留
|
|
CString x1,x2;
|
|
x1=m_strStepWidth;
|
|
x2=m_strStairLength;
|
|
m_strStairLength=temp;
|
|
int num=m_bAsAscent? m_nStepNum : (m_nStepNum-1);
|
|
if (num<1) num=1;
|
|
//m_strStepWidth=Dist2Str(_tstof(temp)/num);
|
|
m_strStepWidth.Format(_T("%.2f"),::_tstof(temp)/num);
|
|
DDX_Text(&dxOut,IDC_STEP_WIDTH,m_strStepWidth);
|
|
//判断是否正确
|
|
TDbEntity *pStep=TDbEntity::cast(NewObject());
|
|
this->Dlg2Obj(pStep);
|
|
if (!pStep->IsValid())
|
|
{
|
|
this->MessageBox(_T("梯段长度太小"),_T("AutoCAD"),MB_OK);
|
|
m_strStepWidth =x1;
|
|
m_strStairLength =x2;
|
|
DDX_Text(&dxOut,IDC_STAIR_LENGTH,m_strStairLength);
|
|
DDX_Text(&dxOut,IDC_STEP_WIDTH,m_strStepWidth);
|
|
ASSERT(pStep!=NULL);
|
|
delete pStep;
|
|
}
|
|
else
|
|
{
|
|
ASSERT(pStep!=NULL);
|
|
delete pStep;
|
|
UpdateImage();
|
|
}
|
|
|
|
}
|
|
else if (bReportError)
|
|
{
|
|
CLineStairCreateDlg::m_bError =TRUE;
|
|
this->MessageBox(_T("梯段长度太小!"),_T("AutoCAD"),MB_OK);
|
|
DDX_Text(&dxOut,IDC_STAIR_LENGTH,m_strStairLength);
|
|
}
|
|
}
|
|
else if (ctrlID==IDC_STEP_WIDTH)
|
|
{
|
|
if (_tstof(temp)>0)
|
|
{
|
|
m_strStepWidth=temp;
|
|
m_strStairLength=Dist2Str(_tstof(temp)*(m_bAsAscent? m_nStepNum : m_nStepNum-1));
|
|
DDX_Text(&dxOut,IDC_STAIR_LENGTH,m_strStairLength);
|
|
UpdateImage();
|
|
}
|
|
else if (bReportError)
|
|
{
|
|
CLineStairCreateDlg::m_bError =TRUE;
|
|
this->MessageBox(_T("踏步宽度太小!"),_T("AutoCAD"),MB_OK);
|
|
DDX_Text(&dxOut,IDC_STEP_WIDTH,m_strStepWidth);
|
|
}
|
|
}
|
|
else if (ctrlID==IDC_STAIR_WIDTH)
|
|
{
|
|
if (_tstof(temp)>0)
|
|
{
|
|
m_strStairWidth=temp;
|
|
UpdateImage();//更新
|
|
}
|
|
else if (bReportError)
|
|
{
|
|
CLineStairCreateDlg::m_bError =TRUE;
|
|
this->MessageBox(_T("梯段宽度太小!"),_T("AutoCAD"),MB_OK);
|
|
DDX_Text(&dxOut,IDC_STAIR_WIDTH,m_strStairWidth);//还原
|
|
}
|
|
}
|
|
else if (ctrlID==IDC_STAIR_HEIGHT)
|
|
{
|
|
if (_tstof(temp)>=2*_tstof(m_strStepHeight)-_DIST_SNAP)
|
|
{//最少当前两踏步高
|
|
m_strStairHeight=temp;
|
|
m_nStepNum=(int)(_tstof(m_strStairHeight)/_tstof(m_strStepHeight)+0.5);
|
|
m_strStepHeight.Format(_T("%.2f"),(_tstof(m_strStairHeight)/m_nStepNum));
|
|
DDX_Text(&dxOut,IDC_STEP_HEIGHT,m_strStepHeight);
|
|
DDX_Text(&dxOut,IDC_STEP_NUM,m_nStepNum);
|
|
//add by xlc on 090702
|
|
m_strStairLength=Dist2Str(_tstof(m_strStepWidth)*(m_bAsAscent? m_nStepNum : m_nStepNum-1));
|
|
DDX_Text(&dxOut,IDC_STAIR_LENGTH,m_strStairLength);
|
|
|
|
UpdateImage();
|
|
}
|
|
else if (bReportError)
|
|
{
|
|
CLineStairCreateDlg::m_bError =TRUE;
|
|
this->MessageBox(_T("梯段高度太小!"),_T("AutoCAD"),MB_OK);
|
|
DDX_Text(&dxOut,IDC_STAIR_HEIGHT,m_strStairHeight);//还原
|
|
}
|
|
}
|
|
// [8/18/2008 nsh]
|
|
else if (ctrlID==IDC_COMBO_STAIRHEIGHT)
|
|
{
|
|
if (_tstof(temp)>=2*_tstof(m_strStepHeight)-_DIST_SNAP)
|
|
{//最少当前两踏步高
|
|
m_strStairHeight=temp;
|
|
m_nStepNum=(int)(_tstof(m_strStairHeight)/_tstof(m_strStepHeight)+0.5);
|
|
m_strStepHeight.Format(_T("%.2f"),(_tstof(m_strStairHeight)/m_nStepNum));
|
|
DDX_Text(&dxOut,IDC_STEP_HEIGHT,m_strStepHeight);
|
|
DDX_Text(&dxOut,IDC_STEP_NUM,m_nStepNum);
|
|
//add by xlc on 090702
|
|
m_strStairLength=Dist2Str(_tstof(m_strStepWidth)*(m_bAsAscent? m_nStepNum : m_nStepNum-1));
|
|
DDX_Text(&dxOut,IDC_STAIR_LENGTH,m_strStairLength);
|
|
|
|
UpdateImage();
|
|
}
|
|
else if (bReportError)
|
|
{
|
|
CLineStairCreateDlg::m_bError =TRUE;
|
|
this->MessageBox(_T("梯段高度太小!"),_T("AutoCAD"),MB_OK);
|
|
DDX_CBString(&dxOut,IDC_COMBO_STAIRHEIGHT,m_strStairHeight);//还原
|
|
}
|
|
}
|
|
//------------------------------
|
|
else if (ctrlID==IDC_STEP_NUM)
|
|
{
|
|
if (_ttoi(temp)>1)
|
|
{
|
|
m_nStepNum=_ttoi(temp);
|
|
m_strStepHeight.Format(_T("%.2f"),_tstof(m_strStairHeight)/m_nStepNum);//modified on 03/07/15 by whl
|
|
DDX_Text(&dxOut,IDC_STEP_HEIGHT,m_strStepHeight);
|
|
if (m_bAsAscent) {
|
|
m_strStepWidth=Dist2Str(_tstof(m_strStairLength)/m_nStepNum);
|
|
DDX_Text(&dxOut,IDC_STEP_WIDTH,m_strStepWidth);
|
|
} else {
|
|
m_strStairLength=Dist2Str(_tstof(m_strStepWidth)*(m_nStepNum-1));
|
|
DDX_Text(&dxOut, IDC_STAIR_LENGTH, m_strStairLength);
|
|
}
|
|
UpdateImage();
|
|
//acedPostCommand(_T("\33"));
|
|
}
|
|
else if (bReportError)
|
|
{
|
|
CLineStairCreateDlg::m_bError =TRUE;
|
|
this->MessageBox(_T("踏步数必需大于1!"),_T("AutoCAD"),MB_OK);
|
|
DDX_Text(&dxOut,IDC_STEP_NUM,m_nStepNum);//还原
|
|
}
|
|
|
|
}
|
|
else if (ctrlID==IDC_STEP_HEIGHT)
|
|
{
|
|
int num=(int)(_tstof(m_strStairHeight)/_tstof(temp)+0.5);
|
|
if (_tstof(temp)>0&&num>1) {
|
|
m_nStepNum=num;
|
|
m_strStepHeight.Format(_T("%.2f"),_tstof(m_strStairHeight)/m_nStepNum);//modified on 03/07/15 by whl
|
|
DDX_Text(&dxOut,IDC_STEP_NUM,m_nStepNum);
|
|
DDX_Text(&dxOut,IDC_STEP_HEIGHT,m_strStepHeight);
|
|
|
|
//add by xlc on 090702
|
|
m_strStairLength=Dist2Str(_tstof(m_strStepWidth)*(m_bAsAscent? m_nStepNum : m_nStepNum-1));
|
|
DDX_Text(&dxOut,IDC_STAIR_LENGTH,m_strStairLength);
|
|
|
|
UpdateImage();
|
|
}
|
|
else if (bReportError)
|
|
{
|
|
CLineStairCreateDlg::m_bError =TRUE;
|
|
if (_tstof(temp)<=0)
|
|
this->MessageBox(_T("踏步高度大于0!"),_T("AutoCAD"),MB_OK);
|
|
else
|
|
this->MessageBox(_T("新踏步高度将造成踏步数小于2,请重新输入或先增大梯段高度!"),_T("AutoCAD"),MB_OK);
|
|
DDX_Text(&dxOut,IDC_STEP_HEIGHT,m_strStepHeight);//还原
|
|
}
|
|
}
|
|
else if (ctrlID==IDC_STAIR_WIDTH) {
|
|
if (_tstof(temp)>0) {
|
|
m_strStairWidth=temp;
|
|
UpdateImage();//更新
|
|
}
|
|
else if (bReportError)
|
|
{
|
|
CLineStairCreateDlg::m_bError =TRUE;
|
|
this->MessageBox(_T("梯段宽度太小!"),_T("AutoCAD"),MB_OK);
|
|
DDX_Text(&dxOut,IDC_STAIR_WIDTH,m_strStairWidth);//还原
|
|
}
|
|
}
|
|
}
|
|
// else
|
|
// result=true;
|
|
CLineStairCreateDlg::m_bUpdateEdit=TRUE;
|
|
if (!m_bEdit)
|
|
{
|
|
if ((!m_bError))
|
|
{
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
else
|
|
{
|
|
m_bError=FALSE;
|
|
}
|
|
}
|
|
bUpdating=false;
|
|
return result;
|
|
|
|
}
|
|
void CLineStairCreateDlg::UpdateSel()
|
|
{
|
|
BOOL bOld2D=m_bNeed2D,bOld3D=m_bNeed3D;
|
|
UpdateData();
|
|
GetDlgItem(IDC_HAS_SLANT)->EnableWindow(m_bAsAscent);
|
|
GetDlgItem(IDC_ON_GROUND)->EnableWindow(m_bAsAscent);
|
|
if (!m_bNeed3D&&!m_bNeed2D)
|
|
{
|
|
this->MessageBox(_T("三维和二维至少选其一!"),_T("AutoCAD"),MB_OK);
|
|
m_bNeed3D=bOld3D;
|
|
m_bNeed2D=bOld2D;
|
|
((CButton*)GetDlgItem(IDC_NEED2D))->SetCheck(m_bNeed2D);
|
|
((CButton*)GetDlgItem(IDC_NEED3D))->SetCheck(m_bNeed3D);
|
|
}
|
|
GetDlgItem(IDC_NO_PAO)->EnableWindow(m_bNeed2D);
|
|
GetDlgItem(IDC_BOTTOM_PAO)->EnableWindow(m_bNeed2D);
|
|
GetDlgItem(IDC_DOUBLE_PAO)->EnableWindow(m_bNeed2D);
|
|
GetDlgItem(IDC_UP_SECT)->EnableWindow(m_bNeed2D);
|
|
UpdateImage();
|
|
this->UpdateData(FALSE);
|
|
}
|
|
void CLineStairCreateDlg::Dlg2Obj(AcDbEntity *pStep)//导出
|
|
{
|
|
CBaseStairDlg::Dlg2Obj(pStep);
|
|
TDbLineStair *pLineStair=TDbLineStair::cast(pStep);
|
|
ASSERT(pLineStair);
|
|
pLineStair->SetStairWidth(_tstof(m_strStairWidth));
|
|
pLineStair->SetStepWidth(_tstof(m_strStepWidth));
|
|
// [7/10/2008 nsh]
|
|
pLineStair->SetStepHeight(_tstof(m_strStepHeight));
|
|
pLineStair->SetStepNum(m_nStepNum);
|
|
|
|
if (m_bEdit)
|
|
{
|
|
if (m_pBakObj)
|
|
delete m_pBakObj;
|
|
m_pBakObj=(TDbLineStair*)(pStep->clone());
|
|
}
|
|
}
|
|
void CLineStairCreateDlg::Obj2Dlg(const AcDbEntity *pStep)//导入
|
|
{
|
|
CBaseStairDlg::Obj2Dlg(pStep);
|
|
TDbLineStair *pLineStair=TDbLineStair::cast(pStep);
|
|
|
|
m_bEdit=TRUE;
|
|
m_pBakObj=(TDbLineStair*)(pStep->clone());
|
|
|
|
ASSERT(pLineStair);
|
|
m_nStepNum=pLineStair->GetStepNum();
|
|
m_strStairWidth=Dist2Str(pLineStair->GetStairWidth());
|
|
//m_strStepWidth=Dist2Str(pLineStair->GetStepWidth());
|
|
m_strStepWidth.Format(_T("%.2f"),pLineStair->GetStepWidth());
|
|
m_strStepHeight.Format(_T("%.2f"),pLineStair->GetStepHeight());
|
|
if (!m_bAsAscent)
|
|
m_strStepWidth=Dist2Str(pLineStair->GetStepWidth());
|
|
m_strStairLength=Dist2Str(_tstof(m_strStepWidth)*(m_bAsAscent? m_nStepNum : m_nStepNum-1));
|
|
m_blAscent=pLineStair->IsAscent();
|
|
return;
|
|
}
|
|
|
|
void CLineStairCreateDlg::OnNcDestroy()
|
|
{
|
|
if (m_bEdit)
|
|
return;
|
|
CBaseStairDlg::OnNcDestroy();
|
|
delete this;
|
|
}
|
|
|
|
void CLineStairCreateDlg::OnClose()
|
|
{
|
|
if (m_bEdit)
|
|
{
|
|
GetDlgItem(IDCANCEL)->SetFocus();
|
|
}
|
|
else
|
|
{
|
|
m_bClickClose=TRUE;
|
|
CLineStairCreateDlg::pSelfCSC=NULL;
|
|
::acedPostCommand(_T("\33"));
|
|
}
|
|
CBaseStairDlg::OnClose();
|
|
}
|
|
|
|
|
|
void CLineStairCreateDlg::OnBnClickedLeftBeam()
|
|
{
|
|
this->UpdateData();
|
|
UpdateImage();
|
|
UpdateEdit(IDC_LEFT_BEAM,true);
|
|
}
|
|
|
|
void CLineStairCreateDlg::OnBnClickedRightBeam()
|
|
{
|
|
this->UpdateData();
|
|
UpdateImage();
|
|
UpdateEdit(IDC_RIGHT_BEAM,true);
|
|
}
|
|
|
|
void CLineStairCreateDlg::OnBnClickedNeed3d()
|
|
{
|
|
this->UpdateSel();
|
|
this->UpdateData();
|
|
|
|
UpdateImage();
|
|
UpdateEdit(IDC_NEED3D,true);
|
|
}
|
|
|
|
void CLineStairCreateDlg::OnBnClickedNeed2d()
|
|
{
|
|
this->UpdateSel();
|
|
this->UpdateData();
|
|
UpdateImage();
|
|
UpdateEdit(IDC_NEED2D,true);
|
|
}
|
|
|
|
void CLineStairCreateDlg::OnBnClickedNoPao()
|
|
{
|
|
this->UpdateData();
|
|
UpdateImage();
|
|
UpdateEdit(IDC_NO_PAO,true);
|
|
}
|
|
|
|
void CLineStairCreateDlg::OnBnClickedBottomPao()
|
|
{
|
|
this->UpdateData();
|
|
UpdateImage();
|
|
UpdateEdit(IDC_BOTTOM_PAO,true);
|
|
}
|
|
|
|
void CLineStairCreateDlg::OnBnClickedDoublePao()
|
|
{
|
|
this->UpdateData();
|
|
UpdateImage();
|
|
UpdateEdit(IDC_DOUBLE_PAO,true);
|
|
}
|
|
|
|
void CLineStairCreateDlg::OnBnClickedUpSect()
|
|
{
|
|
this->UpdateData();
|
|
UpdateImage();
|
|
UpdateEdit(IDC_UP_SECT,true);
|
|
}
|
|
|
|
void CLineStairCreateDlg::OnBnClickedHasSlant()
|
|
{
|
|
this->UpdateData();
|
|
UpdateImage();
|
|
UpdateEdit(IDC_HAS_SLANT,true);
|
|
}
|
|
|
|
void CLineStairCreateDlg::OnBnClickedOnGround()
|
|
{
|
|
this->UpdateData();
|
|
UpdateImage();
|
|
UpdateEdit(IDC_ON_GROUND,true);
|
|
}
|
|
|
|
void CLineStairCreateDlg::OnBnClickedAsAscent()
|
|
{
|
|
this->UpdateData();
|
|
CDataExchange dxOut(this,false);
|
|
if (this->m_blAscent ==TRUE)
|
|
{
|
|
m_strStairLength=Dist2Str(m_nStepNum*::_tstof(m_strStepWidth));
|
|
DDX_Text(&dxOut,IDC_STAIR_LENGTH,m_strStairLength);
|
|
((CButton*)(this->GetDlgItem(IDC_HAS_SLANT)))->EnableWindow(TRUE);
|
|
((CButton*)(this->GetDlgItem(IDC_ON_GROUND)))->EnableWindow(TRUE);
|
|
}
|
|
else
|
|
{
|
|
m_strStairLength=Dist2Str((m_nStepNum-1)*::_tstof(m_strStepWidth));
|
|
DDX_Text(&dxOut,IDC_STAIR_LENGTH,m_strStairLength);
|
|
((CButton*)(this->GetDlgItem(IDC_HAS_SLANT)))->EnableWindow(FALSE);
|
|
((CButton*)(this->GetDlgItem(IDC_ON_GROUND)))->EnableWindow(FALSE);
|
|
}
|
|
// [7/15/2008 nsh]
|
|
|
|
UpdateImage();
|
|
UpdateEdit(IDC_AS_ASCENT,true);
|
|
}
|
|
|
|
void CLineStairCreateDlg::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
|
|
{
|
|
if (nChar==VK_ESCAPE)
|
|
{
|
|
if (!m_bEdit)
|
|
{
|
|
m_bUpdateEdit=TRUE;
|
|
acedPostCommand(_T("\33"));
|
|
::PostQuitMessage(0);
|
|
}
|
|
}
|
|
|
|
CBaseStairDlg::OnKeyUp(nChar, nRepCnt, nFlags);
|
|
}
|
|
void CLineStairCreateDlg::HideDialogBase(BOOL bFlag)
|
|
{
|
|
if (bFlag) {
|
|
GetParent()->EnableWindow(TRUE);
|
|
GetParent()->SetFocus();
|
|
GetParent()->SetActiveWindow();
|
|
ShowWindow(SW_HIDE);
|
|
GetParent()->RedrawWindow();
|
|
}
|
|
else {
|
|
GetParent()->EnableWindow(FALSE);
|
|
EnableWindow(TRUE);
|
|
SetActiveWindow();
|
|
ShowWindow(SW_SHOW);
|
|
}
|
|
|
|
return;
|
|
}
|
|
BOOL CLineStairCreateDlg::CheckENChange(UINT ctrlID,const CString pStr)
|
|
{
|
|
CString temp;
|
|
this->GetDlgItemText(ctrlID,temp);
|
|
if (temp==pStr)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
} |