#include "stdafx.h" #include "SprinklerByInterDlg.h" #include "DbEquipment.h" #include "dbpipe.h" #include "AcDbObjectPtr.h" #include "PickEntSet.h" #include "layerdef.h" extern AcDbObjectId InitLayer(const TCHAR *szLayer, AcDbDatabase *pDb = NULL); extern bool GlobalFunc::IsStrAllNum(CString csText); //************************************************************************** // 交点喷头 //************************************************************************** void SprinklerByInter(int idx, double nRadius, BOOL bDrawCir) { CString csDwb = g_csDwbPath + _T("TwtSys"); XString xsTmp, xsTmp2, xsTmp3d; const TCHAR *szBlkName = NULL; if(GlobalFunc::LoadDwbBlock(csDwb, _T("00000125"), xsTmp) != RTNORM) return; if(GlobalFunc::LoadDwbBlock(csDwb, _T("00000128"), xsTmp2) != RTNORM) return; if(g_Option::instance().g_bBlk3D){ if(idx == 0){ if(GlobalFunc::LoadDwbBlock(csDwb, _T("00000365"), xsTmp3d) != RTNORM) return; } else if(idx == 1){ if(GlobalFunc::LoadDwbBlock(csDwb, _T("00000366"), xsTmp3d) != RTNORM) return; } else if(idx == 2){ if(GlobalFunc::LoadDwbBlock(csDwb, _T("00000367"), xsTmp3d) != RTNORM) return; } } if(idx == 2) xsTmp = xsTmp2; CString m_csSysBlk1 = _T("TWTSYS(00000283)"); PickSet ssAll; XPoint ptTmp1, ptTmp2; if(ads_getpoint(NULL, _T("\n请输入第一角点(辅助线LINE,ARC,CIRCLE):<退出>"), ptTmp1) != RTNORM) return; // ptTmp1 = Ucs2Wcs(ptTmp1); if(ads_getcorner(ptTmp1, _T("\n再点取其对角点(辅助线LINE,ARC,CIRCLE) <退出>:"), ptTmp2) != RTNORM) return; // ptTmp2 = Ucs2Wcs(ptTmp2); Entity entTmp; CString csLay = _T("*"); RBList rb; if(GlobalFunc::SelectEntity(_T("\n如果希望指定辅助线图层,请选取其中一个图元:<不指定>"), entTmp, rb) == RTNORM){ TCHAR szLay[256]; entTmp.GetData(8, szLay); csLay = szLay; } RBList rbMask = ads_buildlist( -4, _T(""), -4, _T(""), -4, _T(""), -4, _T("or>"), NULL); ssAll.Get(_T("C"), ptTmp1, ptTmp2, rbMask); XPointList lstPt; for(long i=0;iSetBlock2d(GlobalFunc::GetBlkIdByName(xsTmp)); if(idx == 1){ pEquip->SetHidePipe(FALSE);//下喷 pEquip->SetPipeLength(-250); } else{ pEquip->SetHidePipe(TRUE); pEquip->SetPipeLength(250); } pEquip->SetBlock3d(GlobalFunc::GetBlkIdByName(xsTmp3d)); pEquip->SetLocation(ptTmp); 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); if(bDrawCir){ Entity entLast; entLast.GetLast(); GlobalFunc::WriteXdata(entLast, _T("HYDRANT_RADIUS"), XString(_T("%.2f"), nRadius)); } } SHads_command(RTNONE); return; } //************************************************************************** // 交点喷头 //************************************************************************** XCurveSegment GetPipeCurve(Entity ent) { XCurveSegment seg; OPENOBJ_BEGIN(ent, AcDb::kForRead, CDbPipe, pPipe); if(pPipe && !pPipe->IsVertical()){ seg = (XCurveSegment)*pPipe; } OPENOBJ_END(); return seg; } void SprinklerByInter() { int nOsMode=0; xg_getvar(_T("OSMODE"), &nOsMode); nOsMode &= ~0x4000; nOsMode |= OS_INT|OS_NEA|OS_CEN|OS_PER; XPushVar vOsMode(_T("OSMODE"), nOsMode); XPoint ptStart, ptEnd; CString csDwb = g_csDwbPath + _T("TwtSys"); XString xsTmp, xsTmp2, xsTmp3, xsTmp4, xsTmp5, xsTmp2d, xsTmp3d; XString xsTmp8, xsTmp9, xsTmp10;//zxl 2011.12.19 add 增加水喷雾喷头 const TCHAR *szBlkName = NULL; 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"), xsTmp8) != RTNORM)//zxl 2011.12.19 add 增加水喷雾喷头 { return; } if (GlobalFunc::LoadDwbBlock(csDwb, _T("00000540"), xsTmp9) != RTNORM) // cet 2013.1.5 add 直立型水幕 { return; } if (GlobalFunc::LoadDwbBlock(csDwb, _T("00000541"), xsTmp10) != 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; } CString m_csSysBlk1 = _T("TWTSYS(00000283)"); CString m_csSysBlk2 = _T("TWTSYS(00000530)");//水喷雾 系统 zxl 2011.12.19 add CSprinklerByInterDlg dlg(acedGetAcadFrame()); { CTemporaryResourceOverride vTemp; dlg.Create(IDD_SPRINKLER_INTER, acedGetAcadFrame()); dlg.ShowWindow(SW_SHOW); acedGetAcadDwgView()->SetFocus(); } GlobalFunc::InitPipeLayer(LAY_PIPE_SPRINKLE); InitLayer(LAY_EQUIP_SPRINKLE); while(1){ PickSet ssAll; XPoint ptTmp1, ptTmp2; if(ads_getpoint(NULL, _T("\n请输入第一角点(辅助线LINE,ARC,CIRCLE):<退出>"), ptTmp1) != RTNORM) break; if(ads_getcorner(ptTmp1, _T("\n再点取其对角点(辅助线LINE,ARC,CIRCLE) <退出>:"), ptTmp2) != RTNORM) break; Entity entTmp; CString csLay = _T("*"); dlg.UpdateData(TRUE); if(dlg.m_bLay){ RBList rb; if(GlobalFunc::SelectEntity(_T("\n如果希望指定辅助线图层,请选取其中一个图元:<不指定>"), entTmp, rb) == RTNORM){ TCHAR szLay[256]; entTmp.GetData(8, szLay); csLay = szLay; } } RBList rbMask = ads_buildlist( -4, _T(""), -4, _T(""), -4, _T(""), -4, _T(""), -4, _T("or>"), NULL); dlg.UpdateData(TRUE); ssAll.Get(_T("C"), ptTmp1, ptTmp2, rbMask); //zxl 2011.12.19 add if(dlg.m_iType == 0){ xsTmp2d = xsTmp; xsTmp3d = xsTmp4; } else if(dlg.m_iType == 1){ xsTmp2d = xsTmp; xsTmp3d = xsTmp3; } else if(dlg.m_iType == 2){ xsTmp2d = xsTmp2; xsTmp3d = xsTmp5; } else if (dlg.m_iType == 3)//zxl 2011.12.19 add 增加水喷雾喷头 { xsTmp2d = xsTmp8; xsTmp3d = xsTmp3; } else if (dlg.m_iType == 4) // cet 2013.1.5 add 直立型水幕 { xsTmp2d = xsTmp9; xsTmp3d = xsTmp4; } else if (dlg.m_iType == 5) // cet 2013.1.5 add 下垂型水幕 { xsTmp2d = xsTmp10; xsTmp3d = xsTmp3; } XPointList lstPt; for(long i=0;iSetBlock2d(GlobalFunc::GetBlkIdByName(xsTmp2d)); if(dlg.m_iType == 1){ pEquip->SetHidePipe(FALSE);//下喷 pEquip->SetPipeLength(-250); pEquip->SetSysBlock(m_csSysBlk1); } else if (dlg.m_iType == 3)//zxl 2011.12.19 add 增加水喷雾喷头 { pEquip->SetHidePipe(TRUE); pEquip->SetPipeLength(-250); pEquip->SetSysBlock(m_csSysBlk2); } else if (dlg.m_iType == 4) // cet 2013.1.5 add 增加直立型水幕 { pEquip->SetHidePipe(TRUE); pEquip->SetPipeLength(250); pEquip->SetSysBlock(_T("TWTSYS(00000542)")); } else if (dlg.m_iType == 5) // cet 2013.1.5 add 增加下垂型水幕 { pEquip->SetHidePipe(TRUE); pEquip->SetPipeLength(-250); pEquip->SetSysBlock(_T("TWTSYS(00000542)")); } else { pEquip->SetHidePipe(TRUE); pEquip->SetPipeLength(250); pEquip->SetSysBlock(m_csSysBlk1); } pEquip->SetBlock3d(GlobalFunc::GetBlkIdByName(xsTmp3d)); ptTmp.z = dlg.m_nEle*1000; pEquip->SetLocation(ptTmp); 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); if(dlg.m_bDrawCir){ Entity entLast; entLast.GetLast(); GlobalFunc::WriteXdata(entLast, _T("HYDRANT_RADIUS"), dlg.m_csRadius); } } } SHads_command(RTNONE); dlg.DestroyWindow(); return; } ///////////////////////////////////////////////////////////////////////////// // CSprinklerByInterDlg dialog IMPLEMENT_DYNAMIC(CSprinklerByInterDlg, CDialog) int CSprinklerByInterDlg::m_iType = 1; CSprinklerByInterDlg::CSprinklerByInterDlg(CWnd* pParent /*=NULL*/) : CDialog(CSprinklerByInterDlg::IDD, pParent) { //{{AFX_DATA_INIT(CSprinklerByInterDlg) m_bDrawCir = TRUE; m_csRadius = _T(""); m_nEle = 0.0; m_bLay = FALSE; m_bPipe = FALSE; //}}AFX_DATA_INIT } void CSprinklerByInterDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSprinklerByInterDlg) DDX_Control(pDX, IDC_EDIT_ELE, m_editEle); DDX_Check(pDX, IDC_CHECK_DRAW, m_bDrawCir); DDX_CBString(pDX, IDC_COMBO_RADIUS, m_csRadius); DDX_Text(pDX, IDC_EDIT_ELE, m_nEle); DDX_Check(pDX, IDC_CHECK_LAY, m_bLay); DDX_Check(pDX, IDC_CHECK_PIPE, m_bPipe); DDX_Radio(pDX, IDC_RADIO_POS1, m_iType); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSprinklerByInterDlg, CDialog) //{{AFX_MSG_MAP(CSprinklerByInterDlg) ON_BN_CLICKED(IDC_CHECK_DRAW, OnCheckDraw) ON_WM_CLOSE() ON_EN_KILLFOCUS(IDC_EDIT_ELE, OnKillfocusEditEle) ON_CBN_KILLFOCUS(IDC_COMBO_RADIUS, OnKillfocusComboRadius) ON_MESSAGE(WM_ACAD_KEEPFOCUS, onAcadKeepFocus) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSprinklerByInterDlg message handlers void CSprinklerByInterDlg::OnCheckDraw() { UpdateData(); CWnd *pWnd1 = GetDlgItem(IDC_COMBO_RADIUS); pWnd1->EnableWindow(m_bDrawCir); } void CSprinklerByInterDlg::OnClose() { CDialog::OnClose(); acedPostCommand(_T("\33\33")); } BOOL CSprinklerByInterDlg::OnInitDialog() { CDialog::OnInitDialog(); m_editEle.SetDataType(CRealEdit::eReal); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CSprinklerByInterDlg::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 CSprinklerByInterDlg::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); } } LONG_PTR CSprinklerByInterDlg::onAcadKeepFocus(UINT_PTR, LONG_PTR) { POINT pt; ::GetCursorPos(&pt); CRect rect; GetWindowRect(&rect); if (!(rect.PtInRect(pt))) { return FALSE; } return TRUE; }