Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

815 lines
26 KiB
C++

#include "StdAfx.h"
#include "autostairdlg.h"
#include "resource.h"
//初始化
BOOL CAutoStairDlg::m_bSelectStair=FALSE;
int CAutoStairDlg::m_iSelectFloor=1;
BOOL CAutoStairDlg::m_bUpDir=TRUE;
BOOL CAutoStairDlg::m_bTongDir=FALSE;
BOOL CAutoStairDlg::m_bPutMode=TRUE;
CString CAutoStairDlg::m_strFloorHeight=_T("3000");
CString CAutoStairDlg::m_strSlabLength=_T("2200");
CString CAutoStairDlg::m_strSlopeAngle=_T("30");
CString CAutoStairDlg::m_strStepLength=_T("900");
CString CAutoStairDlg::m_strSpaceWidth=_T("100");
CString CAutoStairDlg::m_strStairWidth=_T("800");
CString CAutoStairDlg::m_strAscentLen=_T("12000");
//保留结果的操作
int CAutoStairDlg::m_isaveStepNum=20;
CString CAutoStairDlg::m_strsaveStepHeight=_T("150");
CString CAutoStairDlg::m_strsaveStairHeight=_T("3000");
IMPLEMENT_DYNAMIC(CAutoStairDlg,CBaseStairDlg)
CAutoStairDlg::CAutoStairDlg(CWnd* pParent /*=NULL*/)
: CBaseStairDlg(CAutoStairDlg::IDD, pParent)
{
Exchange(m_nStepNum,m_isaveStepNum);
Exchange(m_strStepHeight,m_strsaveStepHeight);
Exchange(m_strStairHeight,m_strsaveStairHeight);
//初始话
m_bEdit=FALSE;//处于非编辑状态
m_pBakObj=NULL;//为空状态
}
CAutoStairDlg::CAutoStairDlg(UINT id,CWnd* pParent /*=NULL*/)
: CBaseStairDlg(id, pParent)
{
Exchange(m_nStepNum,m_isaveStepNum);
Exchange(m_strStepHeight,m_strsaveStepHeight);
Exchange(m_strStairHeight,m_strsaveStairHeight);
//初始话
m_bEdit=FALSE;//处于非编辑状态
m_pBakObj=NULL;//为空状态
}
CAutoStairDlg::~CAutoStairDlg()
{
Exchange(m_nStepNum,m_isaveStepNum);
Exchange(m_strStepHeight,m_strsaveStepHeight);
Exchange(m_strStairHeight,m_strsaveStairHeight);
if (m_bEdit)
delete m_pBakObj;
}
AcDbEntity *CAutoStairDlg::NewObject()
{
TDbAutoStair *pEnt=new TDbAutoStair;
if (m_pBakObj==NULL)
{
pEnt=new TDbAutoStair;
pEnt->setLayer(InitLayer(LAY_STAIR));
pEnt->SetLayerText(InitLayer(LAY_TEXT));
pEnt->SetTextStyle(InitTextStyle(TS_DIM));
pEnt->SetLayerArrow(InitLayer(LAY_OTHER_DIM));
//add by xlc on 090205 解决用户坐标系下预览文字倾斜的问题
pEnt->SetLayoutRotation(0);
return pEnt;
}
else
{
return (AcDbEntity*)(m_pBakObj->clone());
}
}
void CAutoStairDlg::DoDataExchange(CDataExchange* pDX)
{
CBaseStairDlg::DoDataExchange(pDX);
DDX_Text(pDX,IDC_STATIC_LENGTH,m_strLength);
DDX_Text(pDX,IDC_STATIC_WIDTH,m_strWidth);
DDX_Text(pDX,IDC_EDIT_FLOORWIDTH,m_strFloorHeight);
DDX_Text(pDX,IDC_EDIT_STEPWIDTH,m_strStepLength);
DDX_Text(pDX,IDC_EDIT_SLABWIDTH,m_strSlabLength);
DDX_CBString(pDX,IDC_COMBO_ANGLE,m_strSlopeAngle);
DDX_Text(pDX,IDC_EDIT_SPACEWIDTH,m_strSpaceWidth);
DDX_Radio(pDX,IDC_RADIO_FIRST,m_iSelectFloor);
DDX_Check(pDX,IDC_CHECK_UPFLOOR,m_bUpDir);
DDX_Check(pDX,IDC_CHECK_TDIR,m_bTongDir);
DDX_Radio(pDX,IDC_RADIO_SINGLE,m_bSelectStair);
DDX_Radio(pDX,IDC_RADIO_APPOSE,m_bPutMode);
DDX_Control(pDX,IDC_COMBO_ANGLE,m_ctrlSlopeAngle);
DDX_Check(pDX,IDC_CHECK_OPENHOLE,m_bOpenHole);
DDX_Text(pDX,IDC_EDIT_STAIRWIDTH,m_strStairWidth);//楼梯宽度
DDX_Text(pDX,IDC_EDIT_ASCENTLEN,m_strAscentLen);// [7/10/2008 nsh]
}
BEGIN_MESSAGE_MAP(CAutoStairDlg, CBaseStairDlg)
ON_BN_CLICKED(IDC_AS_ASCENT,UpdateSel)
//ON_BN_CLICKED(IDC_CHECK_UPFLOOR,UpdateSel)
ON_EN_CHANGE(IDC_EDIT_FLOORWIDTH,OnChangeFloorWidth)
ON_EN_CHANGE(IDC_EDIT_SLABWIDTH,OnChangeSlabWidth)
ON_EN_CHANGE(IDC_EDIT_STEPWIDTH,OnChangeStepWidth)
ON_EN_CHANGE(IDC_EDIT_SPACEWIDTH,OnChangeSpaceWidth)
ON_CBN_SELCHANGE(IDC_COMBO_ANGLE,OnSelChangeSlopeAngle)
ON_EN_CHANGE(IDC_COMBO_ANGLE,OnSelChangeSlopeAngle)
ON_EN_CHANGE(IDC_EDIT_STAIRWIDTH,OnChangeStairWidth)
ON_CBN_EDITCHANGE(IDC_COMBO_ANGLE,OnChangeSlopeAngle)
//楼层设置
ON_BN_CLICKED(IDC_RADIO_FIRST,UpdateSel)
ON_BN_CLICKED(IDC_RADIO_MID,UpdateSel)
ON_BN_CLICKED(IDC_RADIO_TOP,UpdateSel)
//标注箭头方向
ON_BN_CLICKED(IDC_CHECK_UPFLOOR,UpdateSel)
ON_BN_CLICKED(IDC_CHECK_TDIR,UpdateSel)
//单双楼梯选择
ON_BN_CLICKED(IDC_RADIO_SINGLE,UpdateSel)
ON_BN_CLICKED(IDC_RADIO_DOUBLE,UpdateSel)
ON_BN_CLICKED(IDC_RADIO_APPOSE,UpdateSel)
ON_BN_CLICKED(IDC_RADIO_CROSS,UpdateSel)
//是否开洞
ON_BN_CLICKED(IDC_CHECK_OPENHOLE,UpdateSel)
//坡道长度
ON_BN_CLICKED(IDC_BUTTON_ASCENTLEN,OnClickSelectAscentLen)
ON_EN_CHANGE(IDC_EDIT_ASCENTLEN,OnChangeAscentLen)// [7/10/2008 nsh]
END_MESSAGE_MAP()
BOOL CAutoStairDlg::OnInitDialog()
{
CBaseStairDlg::OnInitDialog();
UpdateSel();
return TRUE;
}
bool CAutoStairDlg::UpdateEdit(UINT ctrlID,bool bReportError)
{
CWnd *pImageBox=GetDlgItem(IDC_PREVIEW);
if (!pImageBox)
return false;
if (GetSafeHwnd()==NULL)
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);
CString temp;
pEdit->GetWindowText(temp);
switch(ctrlID)
{
case IDC_EDIT_FLOORWIDTH:
{
//特殊处理
/*if (::_tstof(temp)<0.0 || temp=="")
{
if (m_bAsAscent)
::AfxMessageBox(_T("请输入正确的坡道长度"));
else
::AfxMessageBox(_T("请输入正确的楼层高度"));
DDX_Text(&dxOut,IDC_EDIT_FLOORWIDTH,m_strFloorHeight);
bUpdating=FALSE;
return false;
}*/
m_strFloorHeight=temp;
DDX_Text(&dxOut,IDC_EDIT_FLOORWIDTH,m_strFloorHeight);
if (!m_bSelectStair)
{//单梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(0,::_tstof(m_strStairWidth),0));
}
else
{//双梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(1,::_tstof(m_strStairWidth),::_tstof(m_strSpaceWidth)));
}
DDX_Text(&dxOut,IDC_STATIC_LENGTH,m_strLength);
DDX_Text(&dxOut,IDC_STATIC_WIDTH,m_strWidth);
}
break;
case IDC_EDIT_SLABWIDTH:
{
static CString strTemp;
strTemp=m_strSlabLength;
if (::_tstof(temp)<=0 || temp==_T(""))
{
bUpdating=FALSE;
return false;
}
m_strSlabLength=temp;
DDX_Text(&dxOut,IDC_EDIT_SLABWIDTH,m_strSlabLength);
if (!m_bSelectStair)
{//单梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(0,::_tstof(m_strStairWidth),0));
}
else
{//双梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(1,::_tstof(m_strStairWidth),::_tstof(m_strSpaceWidth)));
}
DDX_Text(&dxOut,IDC_STATIC_LENGTH,m_strLength);
DDX_Text(&dxOut,IDC_STATIC_WIDTH,m_strWidth);
}
break;
case IDC_EDIT_STEPWIDTH:
{
if (::_tstof(temp)<0 || temp==_T("")||::_tstof(temp)>::_tstof(m_strSlabLength))
{
bUpdating=FALSE;
return false;
}
m_strStepLength=temp;
DDX_Text(&dxOut,IDC_EDIT_STEPWIDTH,m_strStepLength);
}
break;
case IDC_EDIT_SPACEWIDTH:
{
m_strSpaceWidth=temp;
DDX_Text(&dxOut,IDC_EDIT_SPACEWIDTH,m_strSpaceWidth);
if (!m_bSelectStair)
{//单梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(0,::_tstof(m_strStairWidth),0));
}
else
{//双梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(1,::_tstof(m_strStairWidth),::_tstof(m_strSpaceWidth)));
}
DDX_Text(&dxOut,IDC_STATIC_LENGTH,m_strLength);
DDX_Text(&dxOut,IDC_STATIC_WIDTH,m_strWidth);
}
break;
case IDC_EDIT_STAIRWIDTH:
{
if (::_tstof(temp)<0.0 || temp=="")
{
bUpdating=FALSE;
return false;
}
m_strStairWidth=temp;
DDX_Text(&dxOut,IDC_EDIT_STAIRWIDTH,m_strStairWidth);
if (!m_bSelectStair)
{//单梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(1,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(0,::_tstof(m_strStairWidth),0));
}
else
{//双梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(1,::_tstof(m_strStairWidth),::_tstof(m_strSpaceWidth)));
}
DDX_Text(&dxOut,IDC_STATIC_LENGTH,m_strLength);
DDX_Text(&dxOut,IDC_STATIC_WIDTH,m_strWidth);
}
break;
case IDC_COMBO_ANGLE:// [7/7/2008 nsh]
{//倾斜角度改变
if (::_tstof(temp)>=45 || ::_tstof(temp)<0 || temp=="" || ((!m_bAsAscent) && ::_ttoi(temp)==0))
{
bUpdating=FALSE;
return false;
}
m_strSlopeAngle=temp;
//DDX_CBString(&dxOut,IDC_COMBO_ANGLE,m_strSlopeAngle);
if (!m_bSelectStair)
{//单梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(0,::_tstof(m_strStairWidth),0));
}
else
{//双梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(1,::_tstof(m_strStairWidth),::_tstof(m_strSpaceWidth)));
}
DDX_Text(&dxOut,IDC_STATIC_LENGTH,m_strLength);
DDX_Text(&dxOut,IDC_STATIC_WIDTH,m_strWidth);
}
break;
case IDC_EDIT_ASCENTLEN:
{// [7/10/2008 nsh]新的求坡道长度的问题
if (::_tstof(temp)<0 || temp==_T(""))
{
bUpdating=false;
return false;
}
m_strAscentLen=temp;
DDX_Text(&dxOut,IDC_EDIT_ASCENTLEN,m_strAscentLen);
if (!m_bSelectStair)
{//单梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(0,::_tstof(m_strStairWidth),0));
}
else
{//双梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(1,::_tstof(m_strStairWidth),::_tstof(m_strSpaceWidth)));
}
DDX_Text(&dxOut,IDC_STATIC_LENGTH,m_strLength);
DDX_Text(&dxOut,IDC_STATIC_WIDTH,m_strWidth);
}
break;
}
bUpdating=FALSE;
UpdateImage();
return false;
}
void CAutoStairDlg::UpdateSel()
{
CBaseStairDlg::UpdateSel();
UpdateData(TRUE);
// this->GetDlgItem(IDC_CHECK_TDIR)->EnableWindow(m_bUpDir);
//双梯的情况下
this->GetDlgItem(IDC_RADIO_APPOSE)->EnableWindow(m_bSelectStair);
this->GetDlgItem(IDC_RADIO_CROSS)->EnableWindow(m_bSelectStair);
this->GetDlgItem(IDC_EDIT_SPACEWIDTH)->EnableWindow(m_bSelectStair);
//楼层选择
if (((CButton*)this->GetDlgItem(IDC_RADIO_FIRST))->GetCheck())
m_iSelectFloor=0;
else if (((CButton*)this->GetDlgItem(IDC_RADIO_MID))->GetCheck())
m_iSelectFloor=1;
else
m_iSelectFloor=2;
if (m_iSelectFloor==2&&(!m_bSelectStair||((!m_bPutMode)&&m_bSelectStair)))
{
this->GetDlgItem(IDC_CHECK_OPENHOLE)->EnableWindow(TRUE);
}
else
this->GetDlgItem(IDC_CHECK_OPENHOLE)->EnableWindow(FALSE);
// [7/7/2008 nsh]
if (m_strSlopeAngle==_T("0") && m_bAsAscent)
{
this->GetDlgItem(IDC_BUTTON_ASCENTLEN)->ShowWindow(SW_SHOW);
this->GetDlgItem(IDC_EDIT_ASCENTLEN)->ShowWindow(SW_SHOW);
this->GetDlgItem(IDC_STATIC_FLOORHEIGHT)->ShowWindow(SW_HIDE);
this->GetDlgItem(IDC_EDIT_FLOORWIDTH)->ShowWindow(SW_HIDE);
this->GetDlgItem(IDC_RADIO_FIRST)->EnableWindow(FALSE);
this->GetDlgItem(IDC_RADIO_MID)->EnableWindow(FALSE);
this->GetDlgItem(IDC_RADIO_TOP)->EnableWindow(FALSE);
this->GetDlgItem(IDC_CHECK_OPENHOLE)->EnableWindow(FALSE);
m_strStepLength=_T("0");
}
else
{
this->GetDlgItem(IDC_BUTTON_ASCENTLEN)->ShowWindow(SW_HIDE);
this->GetDlgItem(IDC_EDIT_ASCENTLEN)->ShowWindow(SW_HIDE);
this->GetDlgItem(IDC_STATIC_FLOORHEIGHT)->ShowWindow(SW_SHOW);
this->GetDlgItem(IDC_EDIT_FLOORWIDTH)->ShowWindow(SW_SHOW);
this->GetDlgItem(IDC_RADIO_FIRST)->EnableWindow(TRUE);
this->GetDlgItem(IDC_RADIO_MID)->EnableWindow(TRUE);
this->GetDlgItem(IDC_RADIO_TOP)->EnableWindow(TRUE);
//this->GetDlgItem(IDC_CHECK_OPENHOLE)->EnableWindow(TRUE);
}
if (m_bAsAscent)
{
m_ctrlSlopeAngle.ResetContent();
m_ctrlSlopeAngle.AddString(_T("0"));
m_ctrlSlopeAngle.AddString(_T("10"));
m_ctrlSlopeAngle.AddString(_T("12"));
}
else
{
m_ctrlSlopeAngle.ResetContent();
m_ctrlSlopeAngle.AddString(_T("30"));
m_ctrlSlopeAngle.AddString(_T("35"));
}
if (m_bAsAscent && m_strSlopeAngle==_T("0"))
{//当为零的情况下要进行坡道的计算机
this->GetDlgItem(IDC_EDIT_STEPWIDTH)->EnableWindow(FALSE);
}
else
{
this->GetDlgItem(IDC_EDIT_STEPWIDTH)->EnableWindow(TRUE);
}
//以下测试,为保证
if (!m_bAsAscent && m_strSlopeAngle==_T("0"))
{
m_strSlopeAngle=_T("30");
}
//--------------------------------------
//层间同向运行/双梯同向运行
//modify by xlc on 090115
// if (m_bSelectStair && m_iSelectFloor==2)
// {//双梯,顶层
// this->GetDlgItem(IDC_CHECK_TDIR)->SetWindowText(_T("层间同向运行"));
// }
// else if (m_bSelectStair && m_bAsAscent && m_strSlopeAngle==_T("0"))
// {
// this->GetDlgItem(IDC_CHECK_TDIR)->SetWindowText(_T("层间同向运行"));
// }
// else
// this->GetDlgItem(IDC_CHECK_TDIR)->SetWindowText(_T("层间同向运行"));
if ((m_bAsAscent && m_strSlopeAngle==_T("0")))
{
this->GetDlgItem(IDC_CHECK_TDIR)->SetWindowText(_T("层间同向运行"));
}
else if (m_bSelectStair&& m_iSelectFloor==0)
{
this->GetDlgItem(IDC_CHECK_TDIR)->SetWindowText(_T("两梯都是上楼"));
}
else if (m_bSelectStair&& m_iSelectFloor==2)
{
this->GetDlgItem(IDC_CHECK_TDIR)->SetWindowText(_T("两梯都是下楼"));
}
else
{
this->GetDlgItem(IDC_CHECK_TDIR)->SetWindowText(_T("层间同向运行"));
}
//--------------------------------------
//对标注上楼方向的修改
if (m_bAsAscent && ::_tstof(m_strSlopeAngle)==0.0)
{
this->GetDlgItem(IDC_CHECK_UPFLOOR)->SetWindowText(_T("标注运行方向"));
this->GetDlgItem(IDC_CHECK_TDIR)->EnableWindow(FALSE);
}
else
{
this->GetDlgItem(IDC_CHECK_UPFLOOR)->SetWindowText(_T("标注上楼方向"));
if (m_bUpDir&&((!m_bSelectStair&&m_iSelectFloor==1)||m_bSelectStair))
this->GetDlgItem(IDC_CHECK_TDIR)->EnableWindow(TRUE);
else
this->GetDlgItem(IDC_CHECK_TDIR)->EnableWindow(FALSE);
}
// this->GetDlgItem(IDC_CHECK_TDIR)->EnableWindow((m_iSelectFloor==2 || m_iSelectFloor==0)?FALSE:TRUE);// [7/28/2008 nsh]
//modify by xlc on 090414
if (!m_bSelectStair&&(m_iSelectFloor==2 || m_iSelectFloor==0))
{
this->GetDlgItem(IDC_CHECK_TDIR)->EnableWindow(FALSE);
}
//------------------------------
//以下对2D or 3D的显示
if (m_bNeed2D && m_bNeed3D) m_iViewCtrl=0;
else if (!m_bNeed2D && m_bNeed3D) m_iViewCtrl=2;
else if (m_bNeed2D && !m_bNeed3D) m_iViewCtrl=1;
else m_iViewCtrl=0;
//对楼梯的标注
//this->GetDlgItem(IDC_CHECK_TDIR)->EnableWindow(m_bUpDir);
if (!m_bSelectStair)
{//单梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(0,::_tstof(m_strStairWidth),0));
}
else
{//双梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(1,::_tstof(m_strStairWidth),::_tstof(m_strSpaceWidth)));
}
UpdateData(FALSE);
UpdateImage();
}
void CAutoStairDlg::Dlg2Obj(AcDbEntity *pStep)//导出
{
TDbAutoStair *pStair=TDbAutoStair::cast(pStep);
pStair->SetAscent(m_bAsAscent);
/*if (!m_bAsAscent)
pStair->SetFloorHeight(::_tstof(m_strFloorHeight));
else
pStair->SetSlopeLength(::_tstof(m_strAscentLen));*/
// [7/10/2008 nsh]-----------------
if (m_bAsAscent && ::_ttoi(m_strSlopeAngle)==0)
{
pStair->SetSlopeLength(::_tstof(m_strAscentLen)-2*::_tstof(m_strSlabLength));
}
else
{
if (m_bAsAscent)
{
double length=::_tstof(m_strFloorHeight)/tan(PI*::_tstof(m_strSlopeAngle)/180);
int num=(int)(length/300);
length=num*300;
pStair->SetSlopeLength(length);
}
pStair->SetFloorHeight(::_tstof(m_strFloorHeight));
}
//----------------------------------
pStair->SetSlabSize(::_tstof(m_strSlabLength));
if (m_bAsAscent && m_strSlopeAngle==_T("0"))
pStair->SetStepDist(0);
else
pStair->SetStepDist(::_tstof(m_strStepLength));//平步距离
pStair->SetSameDir(m_bUpDir?m_bTongDir:FALSE);
pStair->SetSlopeAngle(::_ttoi(m_strSlopeAngle));
pStair->SetSingleStair(!m_bSelectStair);
pStair->SetCross(m_bSelectStair?m_bPutMode:FALSE);
if (m_bAsAscent && m_strSlopeAngle==_T("0"))
{
pStair->SetStairFlag(2);
}
else
pStair->SetStairFlag(m_iSelectFloor);
pStair->SetViewCtrl(m_iViewCtrl);
pStair->SetArrow(m_bUpDir);
pStair->SetSameDir(m_bUpDir?m_bTongDir:FALSE);
pStair->SetSpaceWidth(::_tstof(m_strSpaceWidth));
if (m_bAsAscent && m_strSlopeAngle==_T("0"))
{
pStair->SetHasHole(FALSE);
}
else
pStair->SetHasHole(m_iSelectFloor==2?m_bOpenHole:FALSE);
pStair->SetStairWidth(::_tstof(m_strStairWidth));
pStair->GetTotalLength();
pStair->GetTotalWidth();
// [8/14/2008 nsh]
//------------------------
if (m_bEdit)
{
delete m_pBakObj;
m_pBakObj=(TDbAutoStair*)(pStair->clone());
}
//------------------------
return;
}
void CAutoStairDlg::Obj2Dlg(const AcDbEntity *pStep)//导入
{
TDbAutoStair *pStair=TDbAutoStair::cast(pStep);
// [8/14/2008 nsh]
//--------------------------------
m_bEdit=TRUE;
m_pBakObj=(TDbAutoStair*)(pStair->clone());//专递值
//--------------------------------
m_strSlopeAngle=Dist2Str(pStair->GetSlopeAngle());
m_strStepLength=Dist2Str(pStair->GetStepDist());
m_strSlabLength=Dist2Str(pStair->GetSlabSize());
m_iSelectFloor=pStair->GetStairFlag();
m_bTongDir=pStair->IsSameDir();
m_bSelectStair=!pStair->IsSingleStair();
m_bOpenHole=pStair->IsHasHole();
m_strSpaceWidth=Dist2Str(pStair->GetSpaceWidth());
m_bAsAscent=pStair->IsAscent();
m_bPutMode=pStair->IsCross();
m_iViewCtrl=pStair->GetViewCtrl();
m_strSlopeAngle.Format(_T("%.0f"),pStair->GetSlopeAngle());
double sss=pStair->GetSlopeAngle();//测试
/*if (!pStair->IsAscent())
{
m_strFloorHeight=Dist2Str(pStair->GetFloorHeight());
}
else
m_strFloorHeight=Dist2Str(pStair->GetSlopeLength());*/
// [7/10/2008 nsh]---------------
if (pStair->IsAscent() && pStair->GetSlopeAngle()==0)
{
m_strAscentLen=Dist2Str(pStair->GetSlopeLength() + 2*pStair->GetSlabSize());
}
else
m_strFloorHeight=Dist2Str(pStair->GetFloorHeight());
//--------------------------------
m_strStairWidth=Dist2Str(pStair->GetStairWidth());
m_strWidth=Dist2Str(pStair->GetTotalWidth());
if (!m_bSelectStair)
{//单梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(0,::_tstof(m_strStairWidth),0));
}
else
{//双梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(1,::_tstof(m_strStairWidth),::_tstof(m_strSpaceWidth)));
}
return;
}
void CAutoStairDlg::OnChangeFloorWidth()
{//楼层高度或是坡道长度
UpdateEdit(IDC_EDIT_FLOORWIDTH,false);
return;
}
void CAutoStairDlg::OnChangeSlabWidth()
{//平台距离
UpdateEdit(IDC_EDIT_SLABWIDTH,false);
return;
}
void CAutoStairDlg::OnChangeStepWidth()
{//平步距离
UpdateEdit(IDC_EDIT_STEPWIDTH,false);
return;
}
void CAutoStairDlg::OnChangeSpaceWidth()
{//两跑之间的距离
UpdateEdit(IDC_EDIT_SPACEWIDTH,false);
return;
}
void CAutoStairDlg::OnChangeStairWidth()
{//梯段宽度
UpdateEdit(IDC_EDIT_STAIRWIDTH,false);
return;
}
void CAutoStairDlg::OnClickSelectAscentLen()
{
double dDist=::_tstof(m_strAscentLen);
BeginEditorCommand();
int nRet=GetDist(_T("\n直接键入坡道长度或给出两点定义坡道长度:"), dDist, RSG_NOZERO|RSG_NONEG|RSG_2D);
CompleteEditorCommand();
if (nRet==RTNORM)
{
CDataExchange dxOut(this,false);
m_strAscentLen=Dist2Str(dDist);
DDX_Text(&dxOut,IDC_EDIT_ASCENTLEN,m_strAscentLen);
UpdateImage();
}
return;
}
void CAutoStairDlg::OnSelChangeSlopeAngle()
{//倾斜角度
CString temp;
CDataExchange dxIn(this,TRUE);
DDX_CBString(&dxIn,IDC_COMBO_ANGLE,m_strStairHeight);
m_ctrlSlopeAngle.GetLBText(m_ctrlSlopeAngle.GetCurSel(),temp);
m_strSlopeAngle=temp;
if (temp==_T("0") && m_bAsAscent)
{
this->GetDlgItem(IDC_EDIT_STEPWIDTH)->EnableWindow(FALSE);
this->GetDlgItem(IDC_BUTTON_ASCENTLEN)->ShowWindow(SW_SHOW);
this->GetDlgItem(IDC_EDIT_ASCENTLEN)->ShowWindow(SW_SHOW);
this->GetDlgItem(IDC_STATIC_FLOORHEIGHT)->ShowWindow(SW_HIDE);
this->GetDlgItem(IDC_EDIT_FLOORWIDTH)->ShowWindow(SW_HIDE);
this->GetDlgItem(IDC_RADIO_FIRST)->EnableWindow(FALSE);
this->GetDlgItem(IDC_RADIO_MID)->EnableWindow(FALSE);
this->GetDlgItem(IDC_RADIO_TOP)->EnableWindow(FALSE);
this->GetDlgItem(IDC_CHECK_OPENHOLE)->EnableWindow(FALSE);
m_strStepLength=__T("0");
}
else
{
this->GetDlgItem(IDC_EDIT_STEPWIDTH)->EnableWindow(TRUE);
this->GetDlgItem(IDC_BUTTON_ASCENTLEN)->ShowWindow(SW_HIDE);
this->GetDlgItem(IDC_EDIT_ASCENTLEN)->ShowWindow(SW_HIDE);
this->GetDlgItem(IDC_STATIC_FLOORHEIGHT)->ShowWindow(SW_SHOW);
this->GetDlgItem(IDC_EDIT_FLOORWIDTH)->ShowWindow(SW_SHOW);
this->GetDlgItem(IDC_RADIO_FIRST)->EnableWindow(TRUE);
this->GetDlgItem(IDC_RADIO_MID)->EnableWindow(TRUE);
this->GetDlgItem(IDC_RADIO_TOP)->EnableWindow(TRUE);
if (m_iSelectFloor==2&&(!m_bSelectStair||((!m_bPutMode)&&m_bSelectStair)))
{
this->GetDlgItem(IDC_CHECK_OPENHOLE)->EnableWindow(TRUE);
}
else
this->GetDlgItem(IDC_CHECK_OPENHOLE)->EnableWindow(FALSE);
}
CDataExchange dxOut(this,FALSE);
DDX_CBString(&dxOut,IDC_COMBO_ANGLE,m_strSlopeAngle);
DDX_Text(&dxOut,IDC_EDIT_STEPWIDTH,m_strStepLength);
DDX_Text(&dxOut,IDC_EDIT_FLOORWIDTH,m_strFloorHeight);
if (!m_bSelectStair)
{//单梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(0,::_tstof(m_strStairWidth),0));
}
else
{//双梯
if (m_bAsAscent)
m_strLength=Dist2Str(CountStairTotalLen(0,m_strFloorHeight,m_strSlabLength));
else
m_strLength=Dist2Str(CountStairTotalLen(0,m_strSlabLength,m_strFloorHeight,m_strSlopeAngle));
m_strWidth=Dist2Str(CountStairTotalWidth(1,::_tstof(m_strStairWidth),::_tstof(m_strSpaceWidth)));
}
//对标注上楼方向的修改
if (m_bAsAscent && ::_tstof(m_strSlopeAngle)==0.0)
{
this->GetDlgItem(IDC_CHECK_UPFLOOR)->SetWindowText(_T("标注运行方向"));
this->GetDlgItem(IDC_CHECK_TDIR)->EnableWindow(FALSE);
}
else
{
this->GetDlgItem(IDC_CHECK_UPFLOOR)->SetWindowText(_T("标注上楼方向"));
if (!m_bSelectStair&&(m_iSelectFloor==2 || m_iSelectFloor==0))
{
this->GetDlgItem(IDC_CHECK_TDIR)->EnableWindow(FALSE);
}
else
this->GetDlgItem(IDC_CHECK_TDIR)->EnableWindow(TRUE);
}
if ((m_bAsAscent && m_strSlopeAngle==_T("0")))
{
this->GetDlgItem(IDC_CHECK_TDIR)->SetWindowText(_T("层间同向运行"));
}
else if (m_bSelectStair&& m_iSelectFloor==0)
{
this->GetDlgItem(IDC_CHECK_TDIR)->SetWindowText(_T("两梯都是上楼"));
}
else if (m_bSelectStair&& m_iSelectFloor==2)
{
this->GetDlgItem(IDC_CHECK_TDIR)->SetWindowText(_T("两梯都是下楼"));
}
else
{
this->GetDlgItem(IDC_CHECK_TDIR)->SetWindowText(_T("层间同向运行"));
}
//------------------------------
DDX_Text(&dxOut,IDC_STATIC_LENGTH,m_strLength);
DDX_Text(&dxOut,IDC_STATIC_WIDTH,m_strWidth);
UpdateImage();
return;
}
void CAutoStairDlg::OnChangeSlopeAngle()
{//改变角度
UpdateEdit(IDC_COMBO_ANGLE,false);
}
void CAutoStairDlg::OnChangeAscentLen()
{//坡道长度
UpdateEdit(IDC_EDIT_ASCENTLEN,false);
return;
}
//计算函数
double CAutoStairDlg::CountStairTotalLen(short nFlag,const CString AscentLen,const CString SlabLength)
{
if (::_tstof(m_strSlopeAngle)==0)
{
return ::_tstof(m_strAscentLen);//+::_tstof(SlabLength)+::_tstof(SlabLength);
}
else
{
double length=::_tstof(m_strFloorHeight)/tan(PI*::_tstof(m_strSlopeAngle)/180);
int num=(int)(length/300);
length=num*300;
return ::_tstof(SlabLength)+::_tstof(SlabLength)+ length;
}
}
double CAutoStairDlg::CountStairTotalLen(short nFlag,const CString SlabLength,const CString FloorHeight,const CString SlopeAngle)
{
double length=::_tstof(FloorHeight)/tan(PI*::_tstof(SlopeAngle)/180);
int num=(int)(length/300);
length=num*300;
return ::_tstof(SlabLength)+::_tstof(SlabLength)+ length;
}
double CAutoStairDlg::CountStairTotalWidth(short nFlag,const double StairWidth,const double SpaceWidth)
{
if (nFlag==0)
{//单梯的时候
return StairWidth+g_dWidth;
}
else
{
return 2*(StairWidth+g_dWidth)+SpaceWidth;
}
}