541 lines
13 KiB
C++
541 lines
13 KiB
C++
// CuspRoofDlg.cpp : 实现文件
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "CuspRoofDlg.h"
|
|
|
|
|
|
double CCuspRoofDlg::m_dElev = 0;
|
|
|
|
// CCuspRoofDlg 对话框
|
|
IMPLEMENT_DYNAMIC(CCuspRoofDlg, GlwCAcUiDialog)
|
|
|
|
CCuspRoofDlg::CCuspRoofDlg(CWnd* pParent /*=NULL*/)
|
|
: CModelessDialog(CCuspRoofDlg::IDD, pParent), m_nEdgeNum(0), m_dRadus(0), m_dHeight(0), m_dChuyanchang(0)
|
|
{
|
|
m_bFlag = FALSE;
|
|
m_bClickClose=FALSE;//是否关闭对话框退出
|
|
}
|
|
|
|
CCuspRoofDlg::~CCuspRoofDlg()
|
|
{
|
|
}
|
|
|
|
void CCuspRoofDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CModelessDialog::DoDataExchange(pDX);
|
|
DDX_Control(pDX,IDC_SPIN1,m_ctrlSideNumSpin);
|
|
DDX_Text(pDX, IDC_EDIT_EDGENUM, m_nEdgeNum);
|
|
DDX_Text(pDX, IDC_EDIT_RADUS, m_dRadus);
|
|
DDX_Text(pDX, IDC_EDIT_HEIGHT, m_dHeight);
|
|
DDX_Text(pDX, IDC_EDIT_CHUYANCHANG, m_dChuyanchang);
|
|
DDX_Text(pDX, IDC_EDIT_ELEV, m_dElev);
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CCuspRoofDlg, CModelessDialog)
|
|
ON_EN_KILLFOCUS(IDC_EDIT_EDGENUM, OnKFEditEDdgeNum)
|
|
ON_EN_KILLFOCUS(IDC_EDIT_RADUS, OnKFEditRadus)
|
|
ON_EN_KILLFOCUS(IDC_EDIT_HEIGHT, OnKFEditEHeight)
|
|
ON_EN_KILLFOCUS(IDC_EDIT_CHUYANCHANG, OnKFEditChuyangao)
|
|
ON_EN_KILLFOCUS(IDC_EDIT_ELEV, OnKFEditElev)
|
|
ON_WM_CLOSE()
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// CCuspRoofDlg 消息处理程序
|
|
BOOL CCuspRoofDlg::OnInitDialog()
|
|
{
|
|
BOOL bRet=CModelessDialog::OnInitDialog();
|
|
|
|
m_ctrlSideNumSpin.SetRange32(3,10000);
|
|
m_ctrlSideNumSpin.SetBuddy(GetDlgItem(IDC_EDIT_EDGENUM));
|
|
// if (m_bCheck)
|
|
// GetDlgItem(IDC_STATIC_ABC)->SetWindowText(_T("底标高:"));
|
|
if (!m_bFlag)
|
|
// GetDlgItem(IDC_STATIC_ABC)->SetWindowText(_T("底标高:"));
|
|
// else
|
|
{
|
|
CRect rect,rect1;
|
|
GetWindowRect(rect);
|
|
GetDlgItem(IDC_EDIT_CHUYANCHANG)->GetWindowRect(rect1);
|
|
rect.bottom = rect1.bottom + 7;
|
|
MoveWindow(rect);
|
|
GetDlgItem(IDC_EDIT_RADUS)->EnableWindow(FALSE);
|
|
}
|
|
UpdateData(FALSE);
|
|
|
|
return bRet;
|
|
}
|
|
void CCuspRoofDlg::OnKFEditChuyangao()
|
|
{
|
|
if (m_bClickClose||GetFocus()==GetDlgItem(IDCANCEL))
|
|
return;
|
|
|
|
CString temp;
|
|
GetDlgItem(IDC_EDIT_CHUYANCHANG)->GetWindowText(temp);
|
|
if (::_tstof(temp)<0||temp==_T(""))
|
|
{
|
|
UpdateData(FALSE);
|
|
::AfxMessageBox(_T("出檐长不正确!"));
|
|
//add by xlc on 090527 焦点问题
|
|
GetDlgItem(IDC_EDIT_CHUYANCHANG)->SetFocus();
|
|
return;
|
|
}
|
|
UpdateData();
|
|
//if (!m_bFlag)
|
|
//{
|
|
// XPoint ptCenter=m_CuspRoof->GetCenter();//modified by whl on 070205
|
|
// ptCenter.z-=m_dHeight*m_dChuyanchang/m_dRadus;
|
|
// m_CuspRoof->SetRotation(0);
|
|
// m_CuspRoof->SetCenter(ptCenter);
|
|
//}
|
|
if (m_CuspRoof != NULL)
|
|
{
|
|
m_CuspRoof->SetEavesLen(m_dChuyanchang);
|
|
}
|
|
}
|
|
void CCuspRoofDlg::OnKFEditEDdgeNum()
|
|
{
|
|
if (m_bClickClose||GetFocus()==GetDlgItem(IDCANCEL))
|
|
return;
|
|
|
|
CString temp;
|
|
GetDlgItem(IDC_EDIT_EDGENUM)->GetWindowText(temp);
|
|
if (::_tstof(temp)<3)
|
|
{
|
|
UpdateData(FALSE);
|
|
::AfxMessageBox(_T("边数不正确!"));
|
|
//add by xlc on 090527 焦点问题
|
|
GetDlgItem(IDC_EDIT_EDGENUM)->SetFocus();
|
|
return;
|
|
}
|
|
UpdateData();
|
|
if (m_CuspRoof != NULL)
|
|
m_CuspRoof->SetSideNum(m_nEdgeNum);
|
|
}
|
|
void CCuspRoofDlg::OnKFEditEHeight()
|
|
{
|
|
if (m_bClickClose||GetFocus()==GetDlgItem(IDCANCEL))
|
|
return;
|
|
|
|
CString temp;
|
|
GetDlgItem(IDC_EDIT_HEIGHT)->GetWindowText(temp);
|
|
if (::_tstof(temp)<_DIST_SNAP)
|
|
{
|
|
UpdateData(FALSE);
|
|
::AfxMessageBox(_T("高度不正确!"));
|
|
//add by xlc on 090527 焦点问题
|
|
GetDlgItem(IDC_EDIT_HEIGHT)->SetFocus();
|
|
return;
|
|
}
|
|
UpdateData();
|
|
if (m_CuspRoof != NULL)
|
|
m_CuspRoof->SetHeight(m_dHeight);
|
|
}
|
|
void CCuspRoofDlg::OnKFEditRadus()
|
|
{
|
|
if (m_bClickClose||GetFocus()==GetDlgItem(IDCANCEL))
|
|
return;
|
|
|
|
CString temp;
|
|
GetDlgItem(IDC_EDIT_RADUS)->GetWindowText(temp);
|
|
if (::_tstof(temp)<_DIST_SNAP)
|
|
{
|
|
UpdateData(FALSE);
|
|
::AfxMessageBox(_T("半径不正确!"));
|
|
//add by xlc on 090527 焦点问题
|
|
GetDlgItem(IDC_EDIT_RADUS)->SetFocus();
|
|
return;
|
|
}
|
|
UpdateData();
|
|
if (m_CuspRoof != NULL)
|
|
m_CuspRoof->SetRadius(m_dRadus);
|
|
}
|
|
void CCuspRoofDlg::OnKFEditElev()
|
|
{
|
|
if (m_bClickClose||GetFocus()==GetDlgItem(IDCANCEL))
|
|
return;
|
|
|
|
CString temp;
|
|
GetDlgItem(IDC_EDIT_ELEV)->GetWindowText(temp);
|
|
//if (temp==_T(""))
|
|
//{
|
|
// UpdateData(FALSE);
|
|
// ::AfxMessageBox(_T("基点标高不正确!"));
|
|
// //add by xlc on 090527 焦点问题
|
|
// GetDlgItem(IDC_EDIT_ELEV)->SetFocus();
|
|
// return;
|
|
//}
|
|
if (fabs(_tstof(temp))<_DIST_SNAP)
|
|
{
|
|
GetDlgItem(IDC_EDIT_ELEV)->SetWindowText(_T("0"));
|
|
//GetDlgItem(IDC_EDIT_ELEV)->SetFocus();
|
|
}
|
|
UpdateData();
|
|
if (m_CuspRoof != NULL)
|
|
{
|
|
m_CuspRoof->SetElevation(m_dElev);
|
|
}
|
|
}
|
|
void CCuspRoofDlg::OnClose()
|
|
{
|
|
if (!m_bFlag)
|
|
{
|
|
m_bClickClose=TRUE;
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem(IDCANCEL)->SetFocus();
|
|
CModelessDialog::OnClose();
|
|
}
|
|
}
|
|
|
|
|
|
class CuspRoofJig: public AcEdJig
|
|
{
|
|
public:
|
|
CuspRoofJig(TDbCuspRoof *m_pDrawEnt,AcGePoint3d Ptbase);
|
|
~CuspRoofJig();
|
|
virtual DragStatus sampler();
|
|
virtual Adesk::Boolean update();
|
|
virtual AcDbEntity* entity() const;
|
|
void SetPrompt(const TCHAR *m_pTemp);
|
|
int GetRetCode() const;
|
|
int doIt();
|
|
|
|
int m_nRetCode; //返回码
|
|
const TCHAR *m_pszPrompt; //提示信息
|
|
AcGePoint3d m_point;
|
|
AcGePoint3d m_BasePoint;
|
|
TDbCuspRoof *m_CuspRoof;
|
|
CCuspRoofDlg *m_dlg;
|
|
};
|
|
CuspRoofJig::CuspRoofJig(TDbCuspRoof *m_pDrawEnt,AcGePoint3d Ptbase)
|
|
{
|
|
m_CuspRoof = m_pDrawEnt;
|
|
m_BasePoint = Ptbase;
|
|
}
|
|
CuspRoofJig::~CuspRoofJig()
|
|
{
|
|
}
|
|
void CuspRoofJig::SetPrompt(const TCHAR *m_pTemp)
|
|
{
|
|
m_pszPrompt = m_pTemp;
|
|
acutPrintf(m_pTemp);
|
|
}
|
|
int CuspRoofJig::GetRetCode() const
|
|
{
|
|
int ret = m_nRetCode;
|
|
if (ret == AcEdJig::kCancel)
|
|
ret = RTCAN;
|
|
else if (ret == AcEdJig::kNull)
|
|
ret = RTNONE;
|
|
else if (ret == AcEdJig::kNormal)
|
|
ret = RTNORM;
|
|
return ret;
|
|
}
|
|
int CuspRoofJig::doIt()
|
|
{
|
|
m_nRetCode = drag();
|
|
int nRet = GetRetCode();
|
|
return nRet;
|
|
}
|
|
Adesk::Boolean CuspRoofJig::update()
|
|
{
|
|
double dX,dY;
|
|
dX = m_point.x - m_BasePoint.x;
|
|
dY = m_point.y - m_BasePoint.y;
|
|
ads_point point1,point2;
|
|
point1[0] = m_point.x;
|
|
point1[1] = m_point.y;
|
|
point1[2] = 0;
|
|
point2[0] = m_BasePoint.x;
|
|
point2[1] = m_BasePoint.y;
|
|
point2[2] = 0;
|
|
double dLength = acutDistance(point1,point2);
|
|
double Temp = sin(PI / 2.0 - PI / m_dlg->m_nEdgeNum);
|
|
double Radus,dEavesLen=0;
|
|
// [2/19/2008 nsh]
|
|
//-----begin------------
|
|
if (m_dlg->m_bCheck)
|
|
{
|
|
Radus=dLength;
|
|
m_CuspRoof->SetRadius(Radus);
|
|
AcGeVector2d vt(dX,dY);
|
|
m_CuspRoof->SetRotation(vt.angle());
|
|
double nSlabThick=200;
|
|
m_BasePoint.z =0;
|
|
}
|
|
else
|
|
{
|
|
//modify by xlc on 081224
|
|
//Radus=dLength+m_dlg->m_dChuyanchang / Temp;
|
|
Radus=dLength;
|
|
dEavesLen=m_dlg->m_dChuyanchang;
|
|
|
|
//modify by xlc on 081230
|
|
// if (m_dlg->m_dChuyanchang>1E-3)
|
|
// {
|
|
// //modify by xlc on 081224
|
|
// //Radus=dLength+m_dlg->m_dChuyanchang / Temp;
|
|
// Radus=dLength;
|
|
// dEavesLen=m_dlg->m_dChuyanchang;
|
|
//
|
|
// }
|
|
// else
|
|
// Radus=dLength;
|
|
|
|
m_CuspRoof->SetRadius(Radus);
|
|
AcGeVector2d vt(dX,dY);
|
|
m_CuspRoof->SetRotation(vt.angle());
|
|
|
|
//modify by xlc on 081230
|
|
// double nSlabThick=200;
|
|
// if (m_dlg->m_dChuyanchang>1E-3)
|
|
// m_BasePoint.z =- m_dlg->m_dHeight*m_dlg->m_dChuyanchang/(Radus*Temp);
|
|
// else
|
|
// m_BasePoint.z =0;
|
|
m_BasePoint.z =m_dlg->m_dElev;
|
|
}
|
|
//-----------end----------
|
|
m_CuspRoof->SetCenter(m_BasePoint);
|
|
m_CuspRoof->SetEavesLen(dEavesLen);
|
|
m_dlg->m_dRadus = Radus;
|
|
|
|
//modify by xlc on 081230
|
|
// [2/20/2008 nsh]
|
|
// if (m_dlg->m_bCheck)
|
|
// m_CuspRoof->SetElevation(m_dlg->m_dChuyanchang);
|
|
m_CuspRoof->SetElevation(m_dlg->m_dElev);
|
|
|
|
m_dlg->UpdateData(FALSE);
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
AcEdJig::DragStatus CuspRoofJig::sampler()
|
|
{
|
|
DragStatus stat;
|
|
setUserInputControls((UserInputControls)
|
|
(AcEdJig::kAccept3dCoordinates|AcEdJig::kNullResponseAccepted));
|
|
AcGePoint3d m_Temp;
|
|
stat = acquirePoint(m_Temp,m_BasePoint);
|
|
if (stat == AcEdJig::kNormal)
|
|
{
|
|
if (m_point == m_Temp)
|
|
return AcEdJig::kNoChange;
|
|
m_point = m_Temp;
|
|
}
|
|
return stat;
|
|
}
|
|
AcDbEntity* CuspRoofJig::entity() const
|
|
{
|
|
return (AcDbEntity*)m_CuspRoof;
|
|
}
|
|
|
|
//攒尖屋顶
|
|
// [11/15/2007 nsh]
|
|
//临时变量
|
|
static double tRadius=10000;
|
|
static double tHeight=3000;
|
|
static double tRoofDist=600;
|
|
static double tElveMove=24000;
|
|
//----------------------------
|
|
void CuspRoof()
|
|
{
|
|
static int num=6;
|
|
/*static double nRadius=10000,nHeight=3000;
|
|
static double nRoofDist=600;*/
|
|
// [11/8/2007 nsh]
|
|
//适应 米单位操作
|
|
static double nRadius;
|
|
static double nHeight;
|
|
static double nRoofDist;
|
|
nRadius=_AS_SYS_UNIT(tRadius);
|
|
nHeight=_AS_SYS_UNIT(tHeight);
|
|
nRoofDist=_AS_SYS_UNIT(tRoofDist);
|
|
//-----------------------------------------
|
|
TDbCuspRoof *pRoof=new TDbCuspRoof;
|
|
if (pRoof != NULL)
|
|
{
|
|
pRoof->SetRadius(nRadius);
|
|
pRoof->SetRotation(0);
|
|
pRoof->SetHeight(nHeight);
|
|
pRoof->SetSideNum(num);
|
|
pRoof->setLayer(InitLayer(LAY_ROOF));
|
|
}
|
|
CCuspRoofDlg dlg;
|
|
dlg.m_bCheck=FALSE;
|
|
dlg.m_CuspRoof = pRoof;
|
|
dlg.m_nEdgeNum = num;
|
|
dlg.m_dRadus = nRadius;
|
|
dlg.m_dHeight = nHeight;
|
|
dlg.m_dChuyanchang = nRoofDist;
|
|
CAcModuleResourceOverride vTemp;
|
|
dlg.Create(CCuspRoofDlg::IDD,acedGetAcadFrame());
|
|
dlg.ShowWindow(SW_SHOW);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
XPoint ptCenter;
|
|
if (acedGetPoint(NULL,_T("\n请输入屋顶中心位置<退出>:"),ptCenter)!=RTNORM)
|
|
{
|
|
if (::IsWindow(dlg.m_hWnd))
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
ptCenter=Ucs2Wcs(ptCenter);
|
|
if (pRoof != NULL)
|
|
pRoof->SetCenter(ptCenter);
|
|
CuspRoofJig jig(pRoof,ptCenter);
|
|
jig.m_dlg = &dlg;
|
|
jig.SetPrompt(_T("获得第二个点:"));
|
|
|
|
//add by xlc on 090505 06以下平台资源冲突
|
|
CAcModuleResourceOverride resOverride(acedGetAcadResourceInstance());
|
|
|
|
if (jig.doIt() == RTNORM)
|
|
{
|
|
pRoof->AddToMSpace(Adesk::kTrue);
|
|
num=pRoof->GetSideNum();
|
|
nHeight=pRoof->GetHeight();
|
|
tHeight =_AS_MM(nHeight);// [11/15/2007 nsh]
|
|
nRoofDist=dlg.m_dChuyanchang;
|
|
tRoofDist=_AS_MM(nRoofDist);// [11/15/2007 nsh]
|
|
}
|
|
else if (pRoof != NULL)
|
|
delete pRoof;
|
|
if (::IsWindow(dlg.m_hWnd))
|
|
dlg.DestroyWindow();
|
|
}
|
|
// [2/19/2008 nsh]
|
|
//-----------------------------------------------begin--------------------------------------------
|
|
void CuspRoof2()
|
|
{
|
|
// ywb 090915
|
|
static double tChuyanchangTmp = 0; // 出檐儿长度
|
|
|
|
static int num=6;
|
|
/*static double nRadius=10000,nHeight=3000;
|
|
static double nRoofDist=600;*/
|
|
// [11/8/2007 nsh]
|
|
//适应 米单位操作
|
|
static double nRadius;
|
|
static double nHeight;
|
|
static double nRoofDist;
|
|
nRadius=_AS_SYS_UNIT(tRadius);
|
|
nHeight=_AS_SYS_UNIT(tHeight);
|
|
nRoofDist=_AS_SYS_UNIT(tElveMove);//注意
|
|
//-----------------------------------------
|
|
TDbCuspRoof *pRoof=new TDbCuspRoof;
|
|
if (pRoof != NULL)
|
|
{
|
|
pRoof->SetRadius(nRadius);
|
|
pRoof->SetRotation(0);
|
|
pRoof->SetHeight(nHeight);
|
|
pRoof->SetSideNum(num);
|
|
pRoof->setLayer(InitLayer(LAY_ROOF));
|
|
}
|
|
CCuspRoofDlg dlg;
|
|
//dlg.m_bCheck=TRUE;
|
|
dlg.m_bCheck = FALSE; // ywb 090914
|
|
dlg.m_CuspRoof = pRoof;
|
|
dlg.m_nEdgeNum = num;
|
|
dlg.m_dRadus = nRadius;
|
|
dlg.m_dHeight = nHeight;
|
|
dlg.m_dChuyanchang = _AS_SYS_UNIT(tChuyanchangTmp);
|
|
dlg.m_dElev = nRoofDist;
|
|
|
|
CAcModuleResourceOverride vTemp;
|
|
dlg.Create(CCuspRoofDlg::IDD,acedGetAcadFrame());
|
|
dlg.ShowWindow(SW_SHOW);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
XPoint ptCenter;
|
|
if (acedGetPoint(NULL,_T("\n请输入屋顶中心位置<退出>:"),ptCenter)!=RTNORM)
|
|
{
|
|
if (::IsWindow(dlg.m_hWnd))
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
ptCenter=Ucs2Wcs(ptCenter);
|
|
if (pRoof != NULL)
|
|
pRoof->SetCenter(ptCenter);
|
|
CuspRoofJig jig(pRoof,ptCenter);
|
|
jig.m_dlg = &dlg;
|
|
|
|
//add by xlc on 090505 06以下平台资源冲突
|
|
CAcModuleResourceOverride resOverride(acedGetAcadResourceInstance());
|
|
|
|
jig.SetPrompt(_T("获得第二个点:"));
|
|
if (jig.doIt() == RTNORM)
|
|
{
|
|
pRoof->AddToMSpace(Adesk::kTrue);
|
|
num=pRoof->GetSideNum();
|
|
nHeight=pRoof->GetHeight();
|
|
tHeight =_AS_MM(nHeight);// [11/15/2007 nsh]
|
|
tChuyanchangTmp = _AS_MM(dlg.m_dChuyanchang);
|
|
//tRoofDist=_AS_MM(nRoofDist);// [11/15/2007 nsh]
|
|
tElveMove = _AS_MM(dlg.m_dElev);
|
|
}
|
|
else if (pRoof != NULL)
|
|
delete pRoof;
|
|
if (::IsWindow(dlg.m_hWnd))
|
|
dlg.DestroyWindow();
|
|
}
|
|
//------------------------------------------------end---------------------------------------------
|
|
int EditCuspRoof(AcDbObjectId id_CuspRoof)
|
|
{
|
|
XDbObject obj(id_CuspRoof,AcDb::kForWrite);
|
|
TDbCuspRoof *pRoof = NULL;
|
|
if (!!obj)
|
|
pRoof = TDbCuspRoof::cast(obj.m_pObject);
|
|
if (!pRoof)
|
|
return RTERROR;
|
|
double dRadius = pRoof->GetRadius();
|
|
double dHeight = pRoof->GetHeight();
|
|
double dElevation = pRoof->GetElevation();
|
|
|
|
double dEavesLen = pRoof->GetEavesLen();
|
|
|
|
long lSideNum = pRoof->GetSideNum();
|
|
CAcModuleResourceOverride vTemp;
|
|
CWnd *pWnd = acedGetAcadFrame();
|
|
CCuspRoofDlg dlg(pWnd);
|
|
|
|
CString strRad,strEavesLen;
|
|
strRad.Format(_T("%.2f"),dRadius);
|
|
strEavesLen.Format(_T("%.2f"),dEavesLen);
|
|
|
|
dlg.m_CuspRoof = pRoof;
|
|
dlg.m_nEdgeNum = lSideNum;
|
|
dlg.m_dRadus = ::_tstof(strRad);
|
|
dlg.m_dHeight = dHeight;
|
|
|
|
//modify by xlc on 081230
|
|
//dlg.m_dChuyanchang = dElevation;
|
|
dlg.m_dChuyanchang = ::_tstof(strEavesLen);
|
|
dlg.m_dElev = dElevation;
|
|
|
|
dlg.m_bFlag = TRUE;
|
|
if (dlg.DoModal() ==IDOK)
|
|
{
|
|
pRoof->SetElevation(dlg.m_dElev);
|
|
pRoof->Close();
|
|
ads_redraw(NULL,NULL);
|
|
}
|
|
else
|
|
{
|
|
pRoof->SetElevation(dElevation);
|
|
pRoof->SetRadius(dRadius);
|
|
pRoof->SetHeight(dHeight);
|
|
pRoof->SetSideNum((Adesk::UInt8)lSideNum);
|
|
|
|
//modify by xlc on 081230
|
|
pRoof->SetEavesLen(dEavesLen);
|
|
|
|
pRoof->Close();
|
|
ads_redraw(NULL,NULL);
|
|
}
|
|
return RTNORM;
|
|
}
|
|
|