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

872 lines
26 KiB
C++

// RectStairDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Resource.h"
#include "RectStairDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRectStairDlg dialog
int CRectStairDlg::m_nStairFlag = 1;
int CRectStairDlg::m_nStairSide = 0;
int CRectStairDlg::m_nAlignment = 2;
int CRectStairDlg::m_nStepNum1=10;
int CRectStairDlg::m_nStepNum2=0;
CString CRectStairDlg::m_strSpaceWidth = _T("2560");
CString CRectStairDlg::m_strSlabWidth = _T("1200");
CString CRectStairDlg::m_strRailHeight = _T("900");
CString CRectStairDlg::m_strRailWidth = _T("60");
CString CRectStairDlg::m_strRailDistToSide = _T("0");
int CRectStairDlg::m_iSlabType = 0;
BOOL CRectStairDlg::m_bAutoRail=FALSE;
BOOL CRectStairDlg::m_bOutRail=FALSE;
//add by whl on 03/08/15
int CRectStairDlg::m_nStepNum3 = 20;
CString CRectStairDlg::m_strStepHeight1;
CString CRectStairDlg::m_strStairHeight1;
CString CRectStairDlg::m_strStairWidth3=_T("1230");
BOOL CRectStairDlg::m_bOutHandRail=TRUE;//外侧扶手
// [10/9/2007 nsh]
//BOOL CRectStairDlg::m_bgroup5Status=FALSE;
// [7/9/2008 nsh]
CString CRectStairDlg::m_strFloorRailDist=_T("60");
CString CRectStairDlg::m_strRoationRailDist=_T("60");
BOOL CRectStairDlg::m_bgroup6Status=FALSE;
BOOL CRectStairDlg::m_bUpDir=TRUE;
IMPLEMENT_DYNAMIC(CRectStairDlg, CLineStairDlg)
CRectStairDlg::CRectStairDlg(CWnd* pParent /*=NULL*/)
: CLineStairDlg(CRectStairDlg::IDD, pParent),m_group6(0)//,m_group5(WG_ST_HORZ)// [10/9/2007 nsh]
{
m_csStairHeight = Dist2Str(DocGetLHeight());
//add by whl on 03/08/15
//Swap In
Exchange(m_strStairHeight,m_strStairHeight1);
Exchange(m_strStepHeight,m_strStepHeight1);
Exchange(m_nStepNum,m_nStepNum3);
Exchange(m_strStairWidth,m_strStairWidth3);
// [10/9/2007 nsh]
//m_groups.Append(&m_group5);
//m_iSectNumOK=5;
m_bNeed2D0=m_bNeed2D;
m_bNeed3D0=m_bNeed3D;
m_bNeed2D=m_bNeed3D=TRUE;
m_strStairHeight=Dist2Str(DocGetLHeight());
m_strStepHeight.Format(_T("%.2f"),DocGetLHeight()/m_nStepNum);//modified on 03/07/15 by whl
m_strStairLength=Dist2Str(_tstof(m_strStepWidth)*(m_bAsAscent? m_nStepNum/2 : (m_nStepNum/2-1)));
//初始话
m_bEdit=FALSE;//处于非编辑状态
m_pBakObj=NULL;//为空状态
}
CRectStairDlg::~CRectStairDlg()
{
//双跑楼梯对这些静态项不影响
m_bNeed2D=m_bNeed2D0;
m_bNeed3D=m_bNeed3D0;
//add by whl on 03/08/15
//Swap Out
Exchange(m_strStairHeight,m_strStairHeight1);
Exchange(m_strStepHeight,m_strStepHeight1);
Exchange(m_nStepNum,m_nStepNum3);
Exchange(m_strStairWidth,m_strStairWidth3);
if (m_bEdit)
delete m_pBakObj;//这个地方是不是有问题
}
void CRectStairDlg::DoDataExchange(CDataExchange* pDX)
{
CLineStairDlg::DoDataExchange(pDX);
// [7/9/2008 nsh]
DDX_Text(pDX,IDC_EDIT_FLOORDIST20,m_strFloorRailDist);
DDX_Text(pDX,IDC_EDIT_ROATIONDIST20,m_strRoationRailDist);
DDX_Text(pDX,IDC_EDIT1,m_dSectNumOK);
DDX_Control(pDX,IDC_SPIN1,m_ctrlSectNum);
//{{AFX_DATA_MAP(CRectStairDlg)
DDX_Control(pDX, IDC_STAIR_HEIGHT_COMBO, m_stairHeightBox);
DDX_Control(pDX,IDC_STEP_NUM1_SPIN,stepNum1Spin);
DDX_Control(pDX,IDC_STEP_NUM2_SPIN,stepNum2Spin);
DDX_Text(pDX, IDC_SLAB_WIDTH, m_strSlabWidth);
DDX_Text(pDX, IDC_RAIL_HEIGHT, m_strRailHeight);
DDX_Text(pDX, IDC_RAIL_WIDTH, m_strRailWidth);
DDX_Text(pDX, IDC_RAIL_DISTTOSIDE, m_strRailDistToSide);
DDX_Text(pDX,IDC_EDIT_SECTNUM2,m_iSectNum);//剖切步数
DDX_Check(pDX, IDC_AUTORAIL, m_bAutoRail);
DDX_Check(pDX, IDC_OUTRAIL, m_bOutRail);
DDX_Radio(pDX, IDC_RADIO_FIRST, m_nStairFlag);
DDX_Radio(pDX, IDC_SIDE_LEFT, m_nStairSide);
DDX_Radio(pDX, IDC_ALIGN_SLAB, m_nAlignment);
DDX_Radio(pDX, IDC_RECT_PLATFORM, m_iSlabType);
DDX_CBString(pDX, IDC_STAIR_HEIGHT_COMBO, m_csStairHeight);
//add by xlc on 090222
DDX_CBString(pDX, IDC_STAIR_HEIGHT, m_strStairHeight);
DDX_Check(pDX,IDC_CHECK1,m_bOutHandRail);//外侧栏杆
DDX_Check(pDX,IDC_CHECK_CONNCTION,m_bRailConnection);
// [10/9/2007 nsh]
/*DDX_Control(pDX,IDC_GROUP5,m_group5);
DDX_GroupStatus(pDX,IDC_GROUP5,m_bgroup5Status);*/
DDX_Control(pDX,IDC_GROUP7,m_group6);
DDX_GroupStatus(pDX,IDC_GROUP7,m_bgroup6Status);
DDX_Check(pDX,IDC_CHECK2,m_bUpDir);//标注上楼方向
//}}AFX_DATA_MAP
if (pDX->m_bSaveAndValidate)
m_bNeed2D=m_bNeed3D=TRUE;
else
{
DDX_Text(pDX, IDC_SPACE_WIDTH, m_strSpaceWidth);
DDX_Text(pDX, IDC_STAIR_WIDTH, m_strStairWidth);
DDX_Text(pDX, IDC_STEP_NUM1, m_nStepNum1);
DDX_Text(pDX, IDC_STEP_NUM2, m_nStepNum2);
m_strStairWidth2.Format(_T("%.2f"),_tstof(m_strSpaceWidth)-2*_tstof(m_strStairWidth));
DDX_Text(pDX, IDC_STAIR_WIDTH2,m_strStairWidth2);
}
}
BEGIN_MESSAGE_MAP(CRectStairDlg, CLineStairDlg)
//{{AFX_MSG_MAP(CRectStairDlg)
ON_BN_CLICKED(IDC_RECTSTAIR_SPACE_WIDTH, OnPickSpaceWidth)
ON_BN_CLICKED(IDC_PICK_STAIRWIDTH2, OnPickStairWidth2)
ON_EN_KILLFOCUS(IDC_SPACE_WIDTH, OnKFSpaceWidth)
ON_EN_KILLFOCUS(IDC_STAIR_WIDTH, OnKFStairWidth)
ON_EN_KILLFOCUS(IDC_STAIR_WIDTH2, OnKFStairWidth2)
ON_EN_KILLFOCUS(IDC_STEP_NUM1, OnKFStepNum1)
ON_EN_KILLFOCUS(IDC_STEP_NUM2, OnKFStepNum2)
ON_EN_CHANGE(IDC_SPACE_WIDTH,OnChangeSpaceWidth)
ON_EN_CHANGE(IDC_STAIR_WIDTH,OnChangeStairWidth)
ON_EN_CHANGE(IDC_STAIR_WIDTH2,OnChangeStairWidth2)
ON_EN_CHANGE(IDC_STEP_NUM1,OnChangeStepNum1)
ON_EN_CHANGE(IDC_STEP_NUM2,OnChangeStepNum2)
ON_EN_KILLFOCUS(IDC_SLAB_WIDTH, UpdateImage)
ON_EN_KILLFOCUS(IDC_RAIL_WIDTH, UpdateImage)
ON_EN_KILLFOCUS(IDC_RAIL_DISTTOSIDE, UpdateImage)
ON_EN_KILLFOCUS(IDC_STEP_WIDTH,OnKFStepWidth)
ON_EN_KILLFOCUS(IDC_STEP_HEIGHT,OnKFStepHeight)
ON_EN_KILLFOCUS(IDC_STEP_NUM,OnKFStepNum)
ON_EN_CHANGE(IDC_SLAB_WIDTH,UpdateImage)
ON_EN_CHANGE(IDC_RAIL_WIDTH,UpdateImage)
ON_EN_CHANGE(IDC_RAIL_DISTTOSIDE,UpdateImage)
ON_BN_CLICKED(IDC_SIDE_LEFT, UpdateImage)
ON_BN_CLICKED(IDC_SIDE_RIGHT, UpdateImage)
ON_BN_CLICKED(IDC_ALIGN_SLAB, UpdateImage)
ON_BN_CLICKED(IDC_ALIGN_MID, UpdateImage)
ON_BN_CLICKED(IDC_ALIGN_FLOOR, UpdateImage)
ON_BN_CLICKED(IDC_RADIO_FIRST, UpdateImage)
ON_BN_CLICKED(IDC_RADIO_MID, UpdateImage)
ON_BN_CLICKED(IDC_RADIO_TOP, UpdateImage)
ON_BN_CLICKED(IDC_RECT_PLATFORM, UpdateSel)
ON_BN_CLICKED(IDC_ARC_PLATFORM, UpdateSel)
ON_BN_CLICKED(IDC_NO_PLATFORM, UpdateSel)
ON_BN_CLICKED(IDC_OUTRAIL,UpdateSel)
ON_BN_CLICKED(IDC_CHECK2,UpdateSel)
ON_BN_CLICKED(IDC_CHECK_CONNCTION,UpdateSel)
// Add By LCF ON 2004/06/30
ON_CBN_KILLFOCUS(IDC_STAIR_HEIGHT_COMBO, OnKillfocusStairHeightCombo)
ON_CBN_EDITCHANGE(IDC_STAIR_HEIGHT_COMBO, OnEditchangeStairHeightCombo)
ON_CBN_SELCHANGE(IDC_STAIR_HEIGHT_COMBO, OnSelchangeStairHeightCombo) //
// [7/9/2008 nsh]
ON_EN_CHANGE(IDC_EDIT_ROATIONDIST20,OnChangeRoationRailDist)
ON_EN_CHANGE(IDC_EDIT_FLOORDIST20,OnChangeFloorRailDist)
ON_EN_CHANGE(IDC_EDIT1,OnChangeSectNum)
ON_EN_CHANGE(IDC_EDIT_SECTNUM2,OnChangeSectNum2)//剖切步数
ON_BN_CLICKED(IDC_CHECK1,OnClickOutHandRail)
ON_EN_CHANGE(IDC_STEP_HEIGHT,OnChangeStepHeight)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRectStairDlg message handlers
void CRectStairDlg::OnChangeSpaceWidth()
{
UpdateEdit(IDC_SPACE_WIDTH);
}
void CRectStairDlg::OnChangeStairWidth()
{
UpdateEdit(IDC_STAIR_WIDTH);
}
void CRectStairDlg::OnChangeStairWidth2()
{
UpdateEdit(IDC_STAIR_WIDTH2);
}
void CRectStairDlg::OnChangeStepNum1()
{
UpdateEdit(IDC_STEP_NUM1);
}
void CRectStairDlg::OnChangeStepNum2()
{
UpdateEdit(IDC_STEP_NUM2);
}
// Add By LCF ON 2004/06/30
void CRectStairDlg::OnEditchangeStairHeightCombo()
{
m_stairHeightBox.GetWindowText(m_csStairHeight);
GetDlgItem(IDC_STAIR_HEIGHT)->SetWindowText(m_csStairHeight);
UpdateEdit(IDC_STAIR_HEIGHT);
}
void CRectStairDlg::OnKFSpaceWidth()
{
if (GetFocus()!=GetDlgItem(IDCANCEL))
UpdateEdit(IDC_SPACE_WIDTH,true);
}
void CRectStairDlg::OnKFStairWidth()
{
if (GetFocus()!=GetDlgItem(IDCANCEL))
UpdateEdit(IDC_STAIR_WIDTH,true);
}
void CRectStairDlg::OnKFStairWidth2()
{
if (GetFocus()!=GetDlgItem(IDCANCEL))
UpdateEdit(IDC_STAIR_WIDTH2,true);
}
void CRectStairDlg::OnKFStepNum1()
{
if (GetFocus()!=GetDlgItem(IDCANCEL))
UpdateEdit(IDC_STEP_NUM1,true);
}
void CRectStairDlg::OnKFStepNum2()
{
if (GetFocus()!=GetDlgItem(IDCANCEL))
UpdateEdit(IDC_STEP_NUM2,true);
}
void CRectStairDlg::OnKFStepHeight()
{
if (GetFocus()!=GetDlgItem(IDCANCEL))
UpdateEdit(IDC_STEP_HEIGHT,true);
}
void CRectStairDlg::OnKFStepNum()
{
}
// Add By LCF ON 2004/06/30
void CRectStairDlg::OnKillfocusStairHeightCombo()
{
//取消失去交点的操作,失去交点操作对编辑产生影响
/*if (GetFocus() != GetDlgItem(IDCANCEL))
{
m_stairHeightBox.GetWindowText(m_csStairHeight);
GetDlgItem(IDC_STAIR_HEIGHT)->SetWindowText(m_csStairHeight);
UpdateEdit(IDC_STAIR_HEIGHT,true);
CString strEdit;
GetDlgItemText(IDC_STAIR_HEIGHT, strEdit);
if (strEdit != m_csStairHeight)
SetDlgItemText(IDC_STAIR_HEIGHT_COMBO, m_strStairHeight);
}*/
}
void CRectStairDlg::OnKFStepWidth()
{
//不做内核处理
}
AcDbEntity * CRectStairDlg::NewObject()
{
TDbRectStair *pEnt=new TDbRectStair;
if (m_pBakObj==NULL)
{
pEnt=new TDbRectStair;
pEnt->setLayer(InitLayer(LAY_STAIR));
pEnt->SetLayerHand3d(InitLayer(LAY_HANDRAIL));
pEnt->SetLayerRail3d(InitLayer(LAY_RAIL));
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());
}
return pEnt;
}
void CRectStairDlg::Dlg2Obj(AcDbEntity *pObj)
{
TDbRectStair *pStep=TDbRectStair::cast(pObj);
ASSERT(pStep);
pStep->SetRailHeight(_tstof(m_strRailHeight));
pStep->SetRailWidth(_tstof(m_strRailWidth));
pStep->SetRailDistToSide(_tstof(m_strRailDistToSide));
pStep->SetSpaceWidth(_tstof(m_strSpaceWidth));
//处理关于自由与其他情况
if (m_nAlignment!=3)
{
//pStep->SetSlabSize((m_iSlabType==0 || m_iSlabType==1)? _tstof(m_strSlabWidth) : 0.0);
pStep->SetSlabSize(_tstof(m_strSlabWidth));
}
else
{
double temp1=::_tstof(m_strSlabSize1);
double temp2=::_tstof(m_strSlabSize2);
double temp3=::_tstof(m_strSlabWidth);
if (temp1==temp2)
{
pStep->SetSlabSize1(temp3);
pStep->SetSlabSize2(temp3);
pStep->SetSlabSize(temp3);
}
else if (temp1<temp2)
{
if (temp3<temp2)
{
pStep->SetSlabSize1(temp3);
pStep->SetSlabSize(temp3);
pStep->SetSlabSize2(temp2);
}
else if (temp3>=temp2)
{
pStep->SetSlabSize1(temp3);
pStep->SetSlabSize2(temp3);
pStep->SetSlabSize(temp3);
}
}
else if (temp1> temp2)
{
if (temp3<temp1)
{
pStep->SetSlabSize2(temp3);
pStep->SetSlabSize(temp3);
pStep->SetSlabSize1(temp1);
}
else if (temp3>=temp1)
{
pStep->SetSlabSize1(temp3);
pStep->SetSlabSize2(temp3);
pStep->SetSlabSize(temp3);
}
}
}
//--------------------------------------
if (m_iSlabType==1)
pStep->SetArcPlatform(TRUE);
else
pStep->SetArcPlatform(FALSE);
// [8/11/2008 nsh]
if (m_iSlabType!=1 && m_iSlabType!=0)
{
pStep->SetShowSlab(FALSE);
}
else
pStep->SetShowSlab(TRUE);
pStep->SetStairWidth(_tstof(m_strStairWidth));
pStep->SetStartSide(m_nStairSide);
pStep->SetAlignment(m_nAlignment);
pStep->SetStairFlag(m_nStairFlag);
pStep->SetInSideBeam(m_bNeedLeft);
pStep->SetOutSideBeam(m_bNeedRight);
pStep->SetAscent(m_bAsAscent);
pStep->SetSlant(m_bHasSlant);
pStep->SetOnGround(m_bOnGround);
pStep->SetAutoRail(m_bAutoRail);
pStep->SetOutRail(m_bOutRail);
pStep->SetStepWidth(_tstof(m_strStepWidth));
pStep->SetStepHeight(_tstof(m_strStepHeight));
pStep->SetStepNum1(m_nStepNum1);
pStep->SetStepNum2(m_nStepNum2);
// [7/9/2008 nsh]
pStep->SetRailDist(::_tstof(m_strRoationRailDist));
pStep->SetRailDistMid(::_tstof(m_strFloorRailDist));
pStep->SetAutoOutRail(m_bOutRail?m_bOutHandRail:FALSE);
pStep->SetArrow(m_bUpDir);
pStep->SetConnectRail(m_bRailConnection);
if (m_bAsAscent)
pStep->SetSectElev(m_dSectNumOK);
else
pStep->SetSectStepNum(m_iSectNum);
//------------------------
if (m_bEdit)
{
delete m_pBakObj;
m_pBakObj=(TDbRectStair*)(pStep->clone());
}
//------------------------
return;
}
void CRectStairDlg::Obj2Dlg(const AcDbEntity *pObj)
{
TDbRectStair *pStep=TDbRectStair::cast(pObj);
ASSERT(pStep);
// [8/14/2008 nsh]
//--------------------------------
m_bEdit=TRUE;
m_pBakObj=(TDbRectStair*)(pObj->clone());//专递值
//--------------------------------
m_strRailWidth =Dist2Str(pStep->GetRailWidth());
m_strRailDistToSide=Dist2Str(pStep->GetRailDistToSide());
m_strRailHeight=Dist2Str(pStep->GetRailHeight());
m_strSpaceWidth=Dist2Str(pStep->GetSpaceWidth());
m_strStairWidth=Dist2Str(pStep->GetStairWidth());
m_strStepWidth=Dist2Str(pStep->GetStepWidth());
m_nStairSide=pStep->GetStartSide();
m_nAlignment=pStep->GetAlignment();
m_nStairFlag=pStep->GetStairFlag();
if (pStep->IsShowSlab())
{
if (pStep->IsArcPlatform())
m_iSlabType=1;
else
m_iSlabType=0;
m_strSlabWidth=Dist2Str(pStep->GetSlabSize());
}
else
m_iSlabType = 2;
m_bNeedLeft=pStep->IsInSideBeam();
m_bNeedRight=pStep->IsOutSideBeam();
m_bAutoRail = pStep->IsAutoRail();
m_bOutRail=pStep->IsOutRail();
m_bAsAscent = pStep->IsAscent();
m_bHasSlant = pStep->HasSlant();
m_bOnGround = pStep->IsOnGround();
m_strSlabSize1=Dist2Str(pStep->GetSlabSize1());//得到平台一的宽度
m_strSlabSize2=Dist2Str(pStep->GetSlabSize2());//得到平台二的宽度
//if (!m_bAsAscent)
//{
m_nStepNum1=pStep->GetStepNum1();
m_nStepNum2=pStep->GetStepNum2();
m_nStepNum=m_nStepNum1+m_nStepNum2;
m_strStepHeight.Format(_T("%.2f"),pStep->GetStepHeight()); ////modified on 03/07/15 by whl
//}
m_strStairLength=Dist2Str(_tstof(m_strStepWidth)*(m_bAsAscent? m_nStepNum1 : m_nStepNum1-1));
m_strStairHeight =Dist2Str(m_nStepNum * pStep->GetStepHeight());
m_csStairHeight=m_strStairHeight;//add by whl
// [7/9/2008 nsh]
m_strRoationRailDist=Dist2Str(pStep->GetRailDist());
m_strFloorRailDist=Dist2Str(pStep->GetRailDistMid());
//m_dSectNumOK=pStep->GetSectElev();
m_bOutHandRail=pStep->IsAutoOutRail();
m_bUpDir=pStep->IsArrow();
m_bRailConnection=pStep->IsConnectRail();
m_dSectNumOK=pStep->GetSectElev();
m_iSectNum=(int)pStep->GetSectStepNum();
return;
}
void CRectStairDlg::UpdateSel()
{
int oldSlabType=m_iSlabType;
CLineStairDlg::UpdateSel();
GetDlgItem(IDC_SLAB_WIDTH)->EnableWindow(m_iSlabType!=2);
if (m_bAsAscent==TRUE)
{
this->GetDlgItem(IDC_HAS_SLANT)->EnableWindow(TRUE);
this->GetDlgItem(IDC_ON_GROUND)->EnableWindow(TRUE);
}
else
{
this->GetDlgItem(IDC_HAS_SLANT)->EnableWindow(FALSE);
this->GetDlgItem(IDC_ON_GROUND)->EnableWindow(FALSE);
}
this->GetDlgItem(IDC_CHECK1)->EnableWindow(m_bOutRail);
//当坡道的情况下的处理
if (m_bAsAscent==TRUE)
{
this->GetDlgItem(IDC_HAS_SLANT)->EnableWindow(TRUE);
this->GetDlgItem(IDC_ON_GROUND)->EnableWindow(TRUE);
//新添加
this->GetDlgItem(IDC_EDIT_SECTNUM2)->ShowWindow(SW_HIDE);
this->GetDlgItem(IDC_SPIN1)->ShowWindow(SW_HIDE);
this->GetDlgItem(IDC_STATIC_SECT)->ShowWindow(SW_HIDE);
this->GetDlgItem(IDC_STATIC_SECTNUM)->ShowWindow(SW_SHOW);
this->GetDlgItem(IDC_EDIT1)->ShowWindow(SW_SHOW);
}
else
{
this->GetDlgItem(IDC_EDIT_SECTNUM2)->ShowWindow(SW_SHOW);
this->GetDlgItem(IDC_SPIN1)->ShowWindow(SW_SHOW);
this->GetDlgItem(IDC_STATIC_SECT)->ShowWindow(SW_SHOW);
this->GetDlgItem(IDC_STATIC_SECTNUM)->ShowWindow(SW_HIDE);
this->GetDlgItem(IDC_EDIT1)->ShowWindow(SW_HIDE);
this->GetDlgItem(IDC_HAS_SLANT)->EnableWindow(FALSE);
this->GetDlgItem(IDC_ON_GROUND)->EnableWindow(FALSE);
}
CDataExchange dxOut(this,false);
m_dSectNumOK=(m_iSectNum-0.5)*::_tstof(m_strStepHeight);
DDX_Text(&dxOut,IDC_EDIT1,m_dSectNumOK);
m_iSectNum=(int)(m_dSectNumOK/::_tstof(m_strStepHeight)+0.5);
DDX_Text(&dxOut,IDC_EDIT_SECTNUM2,m_iSectNum);
if (oldSlabType!=m_iSlabType)
UpdateImage();
}
bool CRectStairDlg::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;
CString temp;
pEdit->GetWindowText(temp);
bool bContinue=false;
CDataExchange dxOut(this,false);
switch(ctrlID) {
case IDC_SPACE_WIDTH: {
if (_tstof(temp)>_tstof(m_strStairWidth)*2)
{
m_strSpaceWidth=temp;
m_strStairWidth2.Format(_T("%.0f"),(_tstof(temp)-_tstof(m_strStairWidth)*2));
GetDlgItem(IDC_STAIR_WIDTH2)->SetWindowText(m_strStairWidth2);
UpdateImage();
} else if (bReportError) {
AfxMessageBox(_T("梯间宽太小,请重新输入或先减小井宽!"));
DDX_Text(&dxOut,IDC_SPACE_WIDTH,m_strSpaceWidth);
pEdit->SetFocus();
pEdit->SetSel(0,-1);
}
}
break;
case IDC_STAIR_WIDTH: {
if (_tstof(temp)>0&&_tstof(temp)*2<=_tstof(m_strSpaceWidth)){
m_strStairWidth=temp;
m_strStairWidth2.Format(_T("%.0f"),_tstof(m_strSpaceWidth)-_tstof(temp)*2);
GetDlgItem(IDC_STAIR_WIDTH2)->SetWindowText(m_strStairWidth2);
UpdateImage();
}
else if (bReportError){
if (_tstof(temp)>0)
AfxMessageBox(_T("梯段宽度总和超过了梯间宽,请重新输入或先增大梯间宽!"));
else
AfxMessageBox(_T("梯段宽度太小!"));
DDX_Text(&dxOut,IDC_STAIR_WIDTH,m_strStairWidth);
pEdit->SetFocus();
pEdit->SetSel(0,-1);
}
}
break;
case IDC_STAIR_WIDTH2: {
if (_tstof(temp)>=0&&_tstof(temp)<_tstof(m_strSpaceWidth)){
m_strStairWidth2=temp;
m_strStairWidth.Format(_T("%.2f"),(_tstof(m_strSpaceWidth)-_tstof(temp))/2);
GetDlgItem(IDC_STAIR_WIDTH)->SetWindowText(m_strStairWidth);
UpdateImage();
}
else if (bReportError){
if (_tstof(temp)>0)
AfxMessageBox(_T("井宽必须小于梯间宽,请重新输入或先增大梯间宽!"));
else
AfxMessageBox(_T("井宽太小!"));
DDX_Text(&dxOut,IDC_STAIR_WIDTH2,m_strStairWidth2);
pEdit->SetFocus();
pEdit->SetSel(0,-1);
}
}
break;
case IDC_STEP_NUM1: {
if (_ttoi(temp)>1&&_ttoi(temp)<m_nStepNum-1) {
m_nStepNum1=_ttoi(temp);
m_nStepNum2=m_nStepNum-m_nStepNum1;
DDX_Text(&dxOut,IDC_STEP_NUM2,m_nStepNum2);
UpdateImage();
}
else if (bReportError) {
if (_ttoi(temp)<2)
AfxMessageBox(_T("第一跑踏步数太少!"));
else
AfxMessageBox(_T("第一跑踏步数太多!,请重新输入或先增大总踏步数。"));
DDX_Text(&dxOut,IDC_STEP_NUM1,m_nStepNum1);
pEdit->SetFocus();
pEdit->SetSel(0,-1);
}
}
break;
case IDC_STEP_NUM2: {
if (_ttoi(temp)>1&&_ttoi(temp)<m_nStepNum-1) {
m_nStepNum2=_ttoi(temp);
m_nStepNum1=m_nStepNum-m_nStepNum2;
DDX_Text(&dxOut,IDC_STEP_NUM1,m_nStepNum1);
UpdateImage();
} else if (bReportError) {
if (_ttoi(temp)<1)
AfxMessageBox(_T("第二跑踏步数太少!"));
else
AfxMessageBox(_T("第二跑踏步数太多!,请重新输入或先增大总踏步数。"));
DDX_Text(&dxOut,IDC_STEP_NUM2,m_nStepNum2);
pEdit->SetFocus();
pEdit->SetSel(0,-1);
}
}
break;
case IDC_STEP_NUM: {
if (_ttoi(temp)!=2&&_ttoi(temp)!=3) {
CBaseStairDlg::UpdateEdit(ctrlID,bReportError);
if (m_bAsAscent) {
m_strStepWidth=Dist2Str(_tstof(m_strStairLength)/(max(1,m_nStepNum/2)));
DDX_Text(&dxOut,IDC_STEP_WIDTH,m_strStepWidth);
} else {
m_strStairLength=Dist2Str(_tstof(m_strStepWidth)*
(m_bAsAscent? m_nStepNum/2 : (m_nStepNum/2-1)));
DDX_Text(&dxOut,IDC_STAIR_LENGTH,m_strStairLength);
}
stepNum1Spin.SetRange(2,m_nStepNum-2);
stepNum2Spin.SetRange(2,m_nStepNum-2);
m_ctrlSectNum.SetRange(1,m_nStepNum);
DDX_Text(&dxOut,IDC_STEP_NUM1,m_nStepNum1=m_nStepNum/2);
DDX_Text(&dxOut,IDC_STEP_NUM2,m_nStepNum2=m_nStepNum-m_nStepNum1);
UpdateImage();
} else if (bReportError) {
AfxMessageBox(_T("总踏步数至少为4!"));
DDX_Text(&dxOut,IDC_STEP_NUM,m_nStepNum);
pEdit->SetFocus();
pEdit->SetSel(0,-1);
}
}
break;
case IDC_STAIR_HEIGHT:
{//add by whl on 03/08/15
if (_tstof(temp)>=4*_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);
stepNum1Spin.SetRange(2,m_nStepNum-2);
stepNum2Spin.SetRange(2,m_nStepNum-2);
m_ctrlSectNum.SetRange(1,m_nStepNum);
DDX_Text(&dxOut,IDC_STEP_NUM1,m_nStepNum1=m_nStepNum/2);
DDX_Text(&dxOut,IDC_STEP_NUM2,m_nStepNum2=m_nStepNum-m_nStepNum1);
UpdateImage();
} else if (bReportError) {
AfxMessageBox(_T("梯段高度太小!"));
DDX_Text(&dxOut,IDC_STAIR_HEIGHT,m_strStairHeight);//还原
pEdit->SetFocus();
pEdit->SetSel(0,-1);
}
}
break;
case IDC_STEP_HEIGHT: {
int num=(int)(_tstof(m_strStairHeight)/_tstof(temp)+0.5);
if (num>3) {
CBaseStairDlg::UpdateEdit(ctrlID,bReportError);
m_nStepNum=num;
stepNum1Spin.SetRange(2,m_nStepNum-2);
stepNum2Spin.SetRange(2,m_nStepNum-2);
DDX_Text(&dxOut,IDC_STEP_NUM1,m_nStepNum1=m_nStepNum/2);
DDX_Text(&dxOut,IDC_STEP_NUM2,m_nStepNum2=m_nStepNum-m_nStepNum1);
DDX_Text(&dxOut,IDC_STEP_NUM,m_nStepNum);
m_strStepHeight.Format(_T("%.2f"),(_tstof(m_strStairHeight)/m_nStepNum));
DDX_Text(&dxOut,IDC_STEP_HEIGHT,m_strStepHeight);
UpdateImage();
} else if (bReportError) {
AfxMessageBox(_T("新踏步高度将造成踏步数小于4,请重新输入或先增大梯段高度!"));
DDX_Text(&dxOut,IDC_STEP_HEIGHT,m_strStepHeight);
pEdit->SetFocus();
pEdit->SetSel(0,-1);
}
}
break;
case IDC_STAIR_LENGTH: {
if (m_bAsAscent) {
if (_tstof(temp)>0) {
m_strStairLength=temp;
m_strStepWidth=Dist2Str(_tstof(temp)/(m_bAsAscent? m_nStepNum/2 : (m_nStepNum/2-1)));
DDX_Text(&dxOut,IDC_STEP_WIDTH,m_strStepWidth);
UpdateImage();
} else if (bReportError){
AfxMessageBox(_T("梯段长度太小!"));
DDX_Text(&dxOut,IDC_STAIR_LENGTH,m_strStairLength);
pEdit->SetFocus();
pEdit->SetSel(0,-1);
}
}
}
break;
case IDC_STEP_WIDTH: {
if (_tstof(temp)>0) {
m_strStepWidth=temp;
m_strStairLength=Dist2Str(_tstof(temp)*(m_bAsAscent? m_nStepNum/2 : (m_nStepNum/2-1)));
DDX_Text(&dxOut,IDC_STAIR_LENGTH,m_strStairLength);
UpdateImage();
} else if (bReportError) {
AfxMessageBox(_T("踏步宽度太小!"));
DDX_Text(&dxOut,IDC_STEP_WIDTH,m_strStepWidth);
pEdit->SetFocus();
pEdit->SetSel(0,-1);
}
}
break;
case IDC_EDIT_FLOORDIST20:
{
m_strFloorRailDist=temp;
DDX_Text(&dxOut,IDC_EDIT_FLOORDIST20,m_strFloorRailDist);
UpdateImage();
}
break;
case IDC_EDIT_ROATIONDIST20:
{
m_strRoationRailDist=temp;
DDX_Text(&dxOut,IDC_EDIT_ROATIONDIST20,m_strRoationRailDist);
UpdateImage();
}
break;
case IDC_EDIT1:
{//为什么这里就能处理
m_dSectNumOK=::_ttoi(temp);
DDX_Text(&dxOut,IDC_EDIT1,m_dSectNumOK);
//UpdateEdit(false);
UpdateImage();
}
break;
case IDC_EDIT_SECTNUM2:
{
m_ctrlSectNum.SetRange(1,m_nStepNum);//剖切步数
if (::_ttoi(temp)>0&&::_ttoi(temp)<=m_nStepNum)
{
m_iSectNum=::_ttoi(temp);
DDX_Text(&dxOut,IDC_EDIT_SECTNUM2,m_iSectNum);
UpdateImage();
}
else
{
//add by xlc on 090222
int sectNum=m_iSectNum;
if (m_iSectNum<0||m_iSectNum>m_nStepNum)
{
sectNum=(int)(m_nStepNum/2);
}
DDX_Text(&dxOut,IDC_EDIT_SECTNUM2,sectNum);
}
}
break;
default:
bContinue=true;
}
bUpdating=false;
return false; // bContinue?CBaseStairDlg::UpdateEdit(ctrlID,bReportError):true;
}
BOOL CRectStairDlg::OnInitDialog()
{
if (m_nStepNum<4)
{
m_nStepNum=20;
m_nStepNum1=m_nStepNum2=10;
m_strStairHeight=Dist2Str(_tstof(m_strStepHeight)*20);
}
else if ((m_nStepNum1+m_nStepNum2)!=m_nStepNum||m_nStepNum1<2||m_nStepNum2<2)
{
m_nStepNum1=m_nStepNum/2;
m_nStepNum2=m_nStepNum-m_nStepNum1;
}
CLineStairDlg::OnInitDialog();
//m_groups.SetMaxExtent(230);
for(long i=0;i<m_stairHeightBox.GetCount();i++)
{
CString temp;
m_stairHeightBox.GetLBText(i,temp);
if (temp==m_csStairHeight)
break;
}
if (i==m_stairHeightBox.GetCount())//没找到这一项
m_stairHeightBox.AddString(m_csStairHeight);
AddTip(IDC_RAIL_DISTTOSIDE_TEXT);
stepNum1Spin.SetRange(2,m_nStepNum-2);
stepNum2Spin.SetRange(2,m_nStepNum-2);
stepNumSpin.SetRange(4,10000);
m_ctrlSectNum.SetRange(1,m_nStepNum);
UpdateImage();
//add by xlc on 090211
SetWindowText(_T("双跑楼梯"));
return TRUE;
}
void CRectStairDlg::OnPickSpaceWidth()
{
double nSpaceWidth=_tstof(m_strSpaceWidth);
BeginEditorCommand();
int nRet=GetDist(_T("\n楼梯间宽度"), nSpaceWidth, /*RSG_NOZERO|*/RSG_NONEG);
CompleteEditorCommand();
if (nRet==RTNORM)
{
CString temp;
temp.Format(_T("%.2f"),nSpaceWidth);
GetDlgItem(IDC_SPACE_WIDTH)->SetWindowText(temp);;
UpdateEdit(IDC_SPACE_WIDTH,true);
}
}
void CRectStairDlg::OnPickStairWidth2()
{
double nWidth=_tstof(m_strStairWidth2);
BeginEditorCommand();
int nRet=GetDist(_T("\n井宽"), nWidth, RSG_NOZERO|RSG_NONEG);
CompleteEditorCommand();
if (nRet==RTNORM)
{
CString temp;
temp.Format(_T("%.2f"),nWidth);
GetDlgItem(IDC_STAIR_WIDTH2)->SetWindowText(temp);
UpdateEdit(IDC_STAIR_WIDTH2,true);
}
}
// Add By LCF ON 2004/06/30
void CRectStairDlg::OnSelchangeStairHeightCombo()
{
int nCurSel = m_stairHeightBox.GetCurSel();
if (nCurSel>=0)
m_stairHeightBox.GetLBText(nCurSel, m_csStairHeight);
if (nCurSel == 0)
{
m_csStairHeight = Dist2Str(DocGetLHeight());
CDataExchange dx(this, false);
DDX_CBString(&dx, IDC_STAIR_HEIGHT_COMBO, m_csStairHeight);
}
GetDlgItem(IDC_STAIR_HEIGHT)->SetWindowText(m_csStairHeight);
UpdateEdit(IDC_STAIR_HEIGHT);
}
// [7/9/2008 nsh]
void CRectStairDlg::OnChangeFloorRailDist()
{
UpdateEdit(IDC_EDIT_FLOORDIST20,false);
}
void CRectStairDlg::OnChangeRoationRailDist()
{
UpdateEdit(IDC_EDIT_ROATIONDIST20,false);
}
void CRectStairDlg::OnChangeSectNum()
{
UpdateEdit(IDC_EDIT1,false);
}
void CRectStairDlg::OnClickOutHandRail()
{//外侧栏杆
this->UpdateData();
this->UpdateImage();
this->UpdateEdit(IDC_CHECK1,false);
}
void CRectStairDlg::OnChangeSectNum2()
{//剖切步数
UpdateEdit(IDC_EDIT_SECTNUM2,true);
}
void CRectStairDlg::OnChangeStepHeight()
{
}