438 lines
12 KiB
C++
438 lines
12 KiB
C++
// SprinklerByArcDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "DbEquipment.h"
|
|
#include "Dbpipe.h"
|
|
#include "layerdef.h"
|
|
#include "SprinklerByLineDlg.h"
|
|
#include "SprinklerByArcDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
extern AcDbObjectId InitLayer(const TCHAR *szLayer, AcDbDatabase *pDb = NULL);
|
|
|
|
void GetPointList2(XCurveSegment seg, double dDist, XPointList &lstPt)
|
|
{
|
|
double dLen = seg.GetLength();
|
|
AcGePoint3d ptTmp;
|
|
AcDbCurve *pCurve = seg.AsAcDbCurve();
|
|
if(seg.Is(CURVE_CIRCLE)){
|
|
XCircle ar = seg.GetCircle();
|
|
pCurve = new AcDbCircle(ar.GetCenterPt(), AcGeVector3d(0,0,1), ar.GetRadius());
|
|
}
|
|
if(pCurve == NULL)
|
|
return;
|
|
if(dDist < 0){//反向
|
|
dDist = fabs(dDist);
|
|
double dAllDist = 1;
|
|
int n = 0;
|
|
while(dAllDist > 0){
|
|
dAllDist = dLen - n*dDist;
|
|
pCurve->getPointAtDist(dAllDist, ptTmp);
|
|
lstPt.NewAppend(ptTmp);
|
|
n++;
|
|
}
|
|
}
|
|
else{ //正向
|
|
double dAllDist = 0;
|
|
int n = 0;
|
|
while(dLen > dAllDist){
|
|
dAllDist = n*dDist;
|
|
pCurve->getPointAtDist(dAllDist, ptTmp);
|
|
lstPt.NewAppend(ptTmp);
|
|
n++;
|
|
}
|
|
}
|
|
// AddToCurrentSpace(pCurve, Adesk::kTrue);
|
|
delete pCurve;
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
//**************************************************************************
|
|
// 弧线喷头
|
|
//**************************************************************************
|
|
void SprinklerByArc()
|
|
{
|
|
CString csDwb = g_csDwbPath + _T("TwtSys");
|
|
XString xsTmp, xsTmp2, xsTmp3, xsTmp4, xsTmp5;
|
|
XString xsTmp6, xsTmp7, xsTmp8;//zxl 2011.12.19 add 增加水喷雾喷头
|
|
if(GlobalFunc::LoadDwbBlock(csDwb, _T("00000125"), xsTmp) != RTNORM)
|
|
return;
|
|
if(GlobalFunc::LoadDwbBlock(csDwb, _T("00000128"), xsTmp2) != RTNORM)
|
|
return;
|
|
if (GlobalFunc::LoadDwbBlock(csDwb, _T("00000283"), XString()) != RTNORM) // cet 2011.2.28 add 剖切时需要的图块
|
|
{
|
|
return;
|
|
}
|
|
if (GlobalFunc::LoadDwbBlock(csDwb, _T("00000529"), xsTmp6) != RTNORM)//zxl 2011.12.19 add 增加水喷雾喷头
|
|
{
|
|
return;
|
|
}
|
|
if (GlobalFunc::LoadDwbBlock(csDwb, _T("00000540"), xsTmp7) != RTNORM) // cet 2013.1.5 add 直立型水幕
|
|
{
|
|
return;
|
|
}
|
|
if (GlobalFunc::LoadDwbBlock(csDwb, _T("00000541"), xsTmp8) != RTNORM) // cet 2013.1.5 add 下垂型水幕
|
|
{
|
|
return;
|
|
}
|
|
|
|
if(g_Option::instance().g_bBlk3D){
|
|
if(GlobalFunc::LoadDwbBlock(csDwb, _T("00000365"), xsTmp3) != RTNORM)
|
|
return;
|
|
if(GlobalFunc::LoadDwbBlock(csDwb, _T("00000366"), xsTmp4) != RTNORM)
|
|
return;
|
|
if(GlobalFunc::LoadDwbBlock(csDwb, _T("00000367"), xsTmp5) != RTNORM)
|
|
return;
|
|
}
|
|
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
nOsMode &= ~0x4000;
|
|
nOsMode |= OS_INT|OS_NEA;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
CSprinklerByArcDlg dlg(acedGetAcadFrame());
|
|
{
|
|
CTemporaryResourceOverride vTemp;
|
|
dlg.Create(IDD_SPRINKLER_ARC, acedGetAcadFrame());
|
|
dlg.ShowWindow(SW_SHOW);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
}
|
|
|
|
CString m_csSysBlk1 = _T("TWTSYS(00000283)");
|
|
CString m_csSysBlk2 = _T("TWTSYS(00000530)");//水喷雾 系统 zxl 2011.12.19 add
|
|
XPoint ptStart, ptEnd, ptMid;
|
|
int iRet;
|
|
iRet = ads_getpoint(NULL, _T("请输入弧起始点<退出>:"), ptStart);
|
|
|
|
if(iRet != RTNORM ){
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
|
|
iRet = ads_getpoint(ptStart, _T("请输入弧终点<退出>:"), ptEnd);
|
|
ptStart = GlobalFunc::Ucs2Wcs(ptStart);
|
|
ptEnd = GlobalFunc::Ucs2Wcs(ptEnd);
|
|
|
|
if(iRet != RTNORM ){
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
|
|
if(dlg.m_bDrawCir)
|
|
g_Option::instance().adsout << _T("\n外圆表示喷淋头保护范围");
|
|
TSprinklerJig jig(&dlg, ptStart,ptEnd);
|
|
jig.SetPrompt(_T("\n请输入弧上一点<退出>:"));
|
|
int nKeyIdx;
|
|
if(jig.DoIt(&nKeyIdx) != RTNORM){
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
ptMid = jig.GetPickPoint();
|
|
|
|
XPushVar<int> vOsMode2(_T("OSMODE"), 0);
|
|
XArc arc(ptStart, ptMid, ptEnd);
|
|
XCurveSegment seg;
|
|
XPointList lstPt;
|
|
seg = arc;
|
|
// arc.Make();
|
|
// dlg.DestroyWindow();
|
|
// return;
|
|
|
|
if(dlg.m_iMode == 1) //均布
|
|
GlobalFunc::GetPointList(seg, dlg.m_iNum, lstPt, dlg.m_iDist2Wall);
|
|
else if(dlg.m_iMode == 0)//等距
|
|
GetPointList2(seg, dlg.m_dDist, lstPt);
|
|
int len = lstPt.Length();
|
|
|
|
|
|
|
|
GlobalFunc::InitPipeLayer(LAY_PIPE_SPRINKLE);
|
|
InitLayer(LAY_EQUIP_SPRINKLE);
|
|
for(int i=0;i<len;i++){
|
|
XPoint pt = *lstPt[i];
|
|
// XLine line(pt, XPoint());
|
|
// line.Make();
|
|
|
|
CDbEquipment *pEquip = new CDbEquipment;
|
|
if(dlg.m_bNoBreak == 2){
|
|
pEquip->SetBlock2d(GlobalFunc::GetBlkIdByName(xsTmp2));
|
|
pEquip->SetHidePipe(TRUE);
|
|
pEquip->SetPipeLength(250);
|
|
pEquip->SetBlock3d(GlobalFunc::GetBlkIdByName(xsTmp5));
|
|
pEquip->SetSysBlock(m_csSysBlk1);
|
|
}
|
|
else if (dlg.m_bNoBreak == 3)//zxl 2011.12.19 add 增加水喷雾喷头
|
|
{
|
|
pEquip->SetBlock2d(GlobalFunc::GetBlkIdByName(xsTmp6));
|
|
pEquip->SetHidePipe(TRUE);
|
|
pEquip->SetPipeLength( -250 );
|
|
pEquip->SetBlock3d(GlobalFunc::GetBlkIdByName(xsTmp3));
|
|
pEquip->SetSysBlock(m_csSysBlk2);
|
|
}
|
|
else if (dlg.m_bNoBreak == 4) // cet 2013.1.5 add 增加直立型水幕
|
|
{
|
|
pEquip->SetHidePipe(TRUE);
|
|
pEquip->SetPipeLength(250);
|
|
pEquip->SetSysBlock(_T("TWTSYS(00000542)"));
|
|
pEquip->SetBlock2d(GlobalFunc::GetBlkIdByName(xsTmp7));
|
|
pEquip->SetBlock3d(GlobalFunc::GetBlkIdByName(xsTmp4));
|
|
}
|
|
else if (dlg.m_bNoBreak == 5) // cet 2013.1.5 add 增加下垂型水幕
|
|
{
|
|
pEquip->SetHidePipe(TRUE);
|
|
pEquip->SetPipeLength(-250);
|
|
pEquip->SetSysBlock(_T("TWTSYS(00000542)"));
|
|
pEquip->SetBlock2d(GlobalFunc::GetBlkIdByName(xsTmp8));
|
|
pEquip->SetBlock3d(GlobalFunc::GetBlkIdByName(xsTmp3));
|
|
}
|
|
else{
|
|
pEquip->SetBlock2d(GlobalFunc::GetBlkIdByName(xsTmp));
|
|
if(dlg.m_bNoBreak == 0){ //上喷
|
|
pEquip->SetHidePipe(TRUE);
|
|
pEquip->SetPipeLength(250);
|
|
pEquip->SetBlock3d(GlobalFunc::GetBlkIdByName(xsTmp4));
|
|
pEquip->SetSysBlock(m_csSysBlk1);
|
|
}
|
|
else if(dlg.m_bNoBreak == 1){
|
|
pEquip->SetHidePipe(FALSE);
|
|
pEquip->SetBlock3d(GlobalFunc::GetBlkIdByName(xsTmp3));
|
|
pEquip->SetPipeLength(-250);
|
|
pEquip->SetSysBlock(m_csSysBlk1);
|
|
}
|
|
}
|
|
pt.z = dlg.m_nEle * 1000;
|
|
pEquip->SetLocation(pt);
|
|
pEquip->SetAngle(0);
|
|
pEquip->SetNumber(_T("CIRCLE-1"));
|
|
pEquip->SetScale(g_Option::instance().g_nSprinklerRadius);
|
|
//pEquip->SetSysBlock(m_csSysBlk1);
|
|
pEquip->setLayer(LAY_EQUIP_SPRINKLE);
|
|
pEquip->setColor(AcCmColor()); //随层
|
|
GlobalFunc::AddToCurrentSpace(pEquip, Adesk::kTrue);
|
|
Entity entLast;
|
|
entLast.GetLast();
|
|
GlobalFunc::WriteXdata(entLast, _T("HYDRANT_RADIUS"), dlg.m_csRadius);
|
|
|
|
}
|
|
if(len > 2){
|
|
ptStart = *lstPt[0];
|
|
ptEnd = *lstPt[len-1];
|
|
|
|
ptStart.z = dlg.m_nEle * 1000;
|
|
ptEnd.z = dlg.m_nEle * 1000;
|
|
ptMid.z = dlg.m_nEle * 1000;
|
|
CDbPipe *pPipe = new CDbPipe;
|
|
XArc arc(ptStart, ptMid, ptEnd);
|
|
XPoint ptArcS, ptArcE;
|
|
arc.GetStartPoint(ptArcS);
|
|
arc.GetEndPoint(ptArcE);
|
|
if(ptStart == ptArcS)
|
|
pPipe->SetPoints(ptStart, ptEnd, arc.Bulge());
|
|
else
|
|
pPipe->SetPoints(ptStart, ptEnd, -arc.Bulge());
|
|
|
|
pPipe->SetPipeWeight(g_Option::instance().g_nPipeWidth[8]);
|
|
|
|
pPipe->setLayer(LAY_PIPE_SPRINKLE);
|
|
pPipe->setLinetype(GlobalFunc::GetPipeWireLayLineType(LAY_PIPE_SPRINKLE));
|
|
pPipe->SetDnDiameter(g_Option::instance().g_iDefaultPipeDn);
|
|
pPipe->SetModelType(TPipeSys::kModel);
|
|
pPipe->SetSysType(TPipeSys::kSprinkle);
|
|
pPipe->SetRadius(g_Option::instance().g_nPipeRadius[8]);
|
|
pPipe->setColor(AcCmColor()); //随层
|
|
GlobalFunc::AddToCurrentSpace(pPipe, Adesk::kTrue);
|
|
}
|
|
dlg.DestroyWindow();
|
|
SHads_command(RTNONE);
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSprinklerByArcDlg dialog
|
|
|
|
IMPLEMENT_DYNAMIC(CSprinklerByArcDlg, CDialog)
|
|
|
|
CSprinklerByArcDlg::CSprinklerByArcDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CSprinklerByArcDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CSprinklerByArcDlg)
|
|
m_bDrawCir = FALSE;
|
|
m_bNoBreak = 1;
|
|
m_nEle = 0.0;
|
|
m_csRadius = _T("2.12");
|
|
m_iMode = 0;
|
|
m_dDist = 3200;
|
|
m_iNum = 5;
|
|
m_iDist2Wall = 0;
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
|
|
void CSprinklerByArcDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CSprinklerByArcDlg)
|
|
DDX_Control(pDX, IDC_EDIT_NUM, m_editNum);
|
|
DDX_Control(pDX, IDC_EDIT_DIST, m_editDist);
|
|
DDX_Control(pDX, IDC_EDIT_ELE, m_editEle);
|
|
DDX_Check(pDX, IDC_CHECK_DRAW, m_bDrawCir);
|
|
DDX_Radio(pDX, IDC_RADIO_POS1, m_bNoBreak);
|
|
DDX_Text(pDX, IDC_EDIT_ELE, m_nEle);
|
|
DDX_CBString(pDX, IDC_COMBO_RADIUS, m_csRadius);
|
|
DDX_Radio(pDX, IDC_RADIO_MODE1, m_iMode);
|
|
DDX_Text(pDX, IDC_EDIT_DIST, m_dDist);
|
|
DDX_Text(pDX, IDC_EDIT_NUM, m_iNum);
|
|
DDX_CBIndex(pDX, IDC_COMBO_DIST2WALL, m_iDist2Wall);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CSprinklerByArcDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CSprinklerByArcDlg)
|
|
ON_BN_CLICKED(IDC_CHECK_DRAW, OnCheckDraw)
|
|
ON_WM_CLOSE()
|
|
ON_BN_CLICKED(IDC_RADIO_MODE1, OnRadioMode1)
|
|
ON_BN_CLICKED(IDC_RADIO_MODE2, OnRadioMode2)
|
|
ON_EN_KILLFOCUS(IDC_EDIT_DIST, OnKillfocusEditDist)
|
|
ON_EN_KILLFOCUS(IDC_EDIT_ELE, OnKillfocusEditEle)
|
|
ON_CBN_KILLFOCUS(IDC_COMBO_RADIUS, OnKillfocusComboRadius)
|
|
ON_EN_KILLFOCUS(IDC_EDIT_NUM, OnKillfocusEditNum)
|
|
ON_MESSAGE(WM_ACAD_KEEPFOCUS, onAcadKeepFocus)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSprinklerByArcDlg message handlers
|
|
|
|
BOOL CSprinklerByArcDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
m_editNum.SetDataType(CRealEdit::eInteger);
|
|
m_editDist.SetDataType(CRealEdit::eReal);
|
|
m_editEle.SetDataType(CRealEdit::eReal);
|
|
|
|
OnCheckDraw();
|
|
OnRadioMode1();
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CSprinklerByArcDlg::OnCheckDraw()
|
|
{
|
|
UpdateData();
|
|
CWnd *pWnd1 = GetDlgItem(IDC_COMBO_RADIUS);
|
|
pWnd1->EnableWindow(m_bDrawCir);
|
|
|
|
}
|
|
|
|
void CSprinklerByArcDlg::OnClose()
|
|
{
|
|
CDialog::OnClose();
|
|
acedPostCommand(_T("\33\33"));
|
|
}
|
|
|
|
void CSprinklerByArcDlg::OnRadioMode1()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd1 = GetDlgItem(IDC_COMBO_DIST2WALL);
|
|
pWnd1->EnableWindow(m_iMode);
|
|
}
|
|
|
|
void CSprinklerByArcDlg::OnRadioMode2()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd1 = GetDlgItem(IDC_COMBO_DIST2WALL);
|
|
pWnd1->EnableWindow(m_iMode);
|
|
}
|
|
|
|
void CSprinklerByArcDlg::OnKillfocusEditDist()
|
|
{
|
|
double dData = m_dDist;
|
|
CString sText;
|
|
m_editDist.GetWindowText(sText);
|
|
m_dDist = _tstof(sText);
|
|
if (m_dDist <= 0 || !GlobalFunc::IsStrAllNum(sText))
|
|
{
|
|
m_dDist = dData;
|
|
UpdateData(FALSE);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
m_editDist.SetFocus();
|
|
m_editDist.SetSel(0, -1);
|
|
}
|
|
}
|
|
|
|
void CSprinklerByArcDlg::OnKillfocusEditEle()
|
|
{
|
|
double dData = m_nEle;
|
|
CString sText;
|
|
m_editEle.GetWindowText(sText);
|
|
m_nEle = _tstof(sText);
|
|
if (sText.IsEmpty() || !GlobalFunc::IsStrAllNum(sText))
|
|
{
|
|
m_nEle = dData;
|
|
UpdateData(FALSE);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
m_editEle.SetFocus();
|
|
m_editEle.SetSel(0, -1);
|
|
}
|
|
}
|
|
|
|
void CSprinklerByArcDlg::OnKillfocusComboRadius()
|
|
{
|
|
CString csData = m_csRadius;
|
|
CEdit *pWnd = (CEdit *)GetDlgItem(IDC_COMBO_RADIUS);
|
|
if (pWnd == NULL)
|
|
{
|
|
return;
|
|
}
|
|
CString sText;
|
|
pWnd->GetWindowText(sText);
|
|
double dNewData = _tstof(sText);
|
|
if (dNewData <= 0 || !GlobalFunc::IsStrAllNum(sText))
|
|
{
|
|
m_csRadius = csData;
|
|
UpdateData(FALSE);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
pWnd->SetFocus();
|
|
pWnd->SetSel(0, -1);
|
|
}
|
|
}
|
|
|
|
void CSprinklerByArcDlg::OnKillfocusEditNum()
|
|
{
|
|
double dData = m_iNum;
|
|
CString sText;
|
|
m_editNum.GetWindowText(sText);
|
|
m_iNum = _tstof(sText);
|
|
if (m_iNum <= 0 || !GlobalFunc::IsStrAllNum(sText))
|
|
{
|
|
m_iNum = dData;
|
|
UpdateData(FALSE);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
m_editNum.SetFocus();
|
|
m_editNum.SetSel(0, -1);
|
|
}
|
|
}
|
|
|
|
LONG_PTR CSprinklerByArcDlg::onAcadKeepFocus(UINT_PTR, LONG_PTR)
|
|
{
|
|
POINT pt;
|
|
::GetCursorPos(&pt);
|
|
CRect rect;
|
|
GetWindowRect(&rect);
|
|
if (!(rect.PtInRect(pt)))
|
|
{
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|