455 lines
13 KiB
C++
455 lines
13 KiB
C++
// HydrantSysDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include <DbEquipment.h>
|
|
#include <xtext.h>
|
|
#include <dbPipeValve.h>
|
|
#include <DbSymbolAnnotate.h>
|
|
#include <PipeWireMonitor.h>
|
|
|
|
#include "HydrantSysDlg.h"
|
|
#include "DistFloorDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
extern void DrawFloorLine(XPoint p1, XPoint p2, const TCHAR*szPipeLayer, const TCHAR*szText, double nHeight, const TCHAR*szSerial);
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// 消防系统
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
AcDbObjectId InsEquipmentByName(const TCHAR* szName, XPoint pt, double nAng, const TCHAR* szLayer, BOOL bReversal, BOOL bHidePipe)
|
|
{
|
|
InitLayer(szLayer);
|
|
AcDbObjectId recordId = GetBlkIdByName(szName);
|
|
if(!recordId)
|
|
return recordId;
|
|
TDbEquipment *pEquip = new TDbEquipment;
|
|
pEquip->SetBlock2d(recordId);
|
|
pEquip->SetLocation(pt);
|
|
pEquip->SetScale(1);
|
|
pEquip->SetHidePipe(bHidePipe);
|
|
pEquip->SetSpare(0);
|
|
pEquip->SetDang(0);
|
|
pEquip->SetPipeLength(0);
|
|
pEquip->SetAngle(nAng);
|
|
pEquip->MirrorByY(bReversal);
|
|
pEquip->setLayer(szLayer);
|
|
pEquip->setColor(AcCmColor()); //随层
|
|
AcDbObjectId id = AddToCurrentSpace(pEquip, Adesk::kTrue);
|
|
return id;
|
|
}
|
|
|
|
|
|
void HydrantSys()
|
|
{
|
|
CTemporaryResourceOverride vTemp;
|
|
CHydrantSysDlg dlg;
|
|
if(dlg.DoModal() != IDOK)
|
|
return;
|
|
|
|
InitLayer(LAY_EQUIP_HYDRANT);
|
|
InitPipeLayer(LAY_PIPE_FIRE);
|
|
XPoint ptIns, ptStart, ptEnd, ptFloor;
|
|
xg_getvar(_T("VIEWCTR"), ptIns);
|
|
ptIns = Ucs2Wcs(ptIns);
|
|
PickSet ss(SS_FREE);
|
|
ss.IncludeBegin();
|
|
|
|
double nAllHeight = dlg.m_nAllHeight;
|
|
double nBraLength = dlg.m_nFloorLen;
|
|
ptStart = ptIns;
|
|
ads_polar(ptStart, PI/2*3, dlg.m_nFloorHeight*1000, ptStart);
|
|
ads_polar(ptIns, PI/2, nAllHeight-_tstof(dlg.m_lstHeight[dlg.m_iFloorNum-1])*1000+dlg.m_nElevation*1000, ptEnd);
|
|
AcDbObjectId idMain = DrawSysPipeByLayer(ptStart, ptEnd, LAY_PIPE_FIRE);
|
|
OPENOBJ_BEGIN(idMain, AcDb::kForWrite, TDbPipe, pPipeMain);
|
|
if(pPipeMain){
|
|
pPipeMain->SetHideLevel(pPipeMain->GetHideLevel()+1);
|
|
pPipeMain->SetDnDiameter(100);
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
ptFloor = ptIns;
|
|
|
|
CString csDwb = g_csDwbPath + _T("TwtSys");
|
|
XString xsTmp, xsTmp2, xsTmp3;
|
|
if(dlg.m_iFireType == 0)
|
|
xsTmp2 = _T("00000386");//单栓
|
|
else
|
|
xsTmp2 = _T("00000383");//双栓
|
|
if(LoadDwbBlock(csDwb, xsTmp2, xsTmp) != RTNORM)
|
|
return;
|
|
csDwb = g_csDwbPath + _T("valve");
|
|
if(LoadDwbBlock(csDwb, _T("00000295"), xsTmp3) != RTNORM) //阀门
|
|
return;
|
|
ads_polar(ptStart, PI/2, dlg.m_nFloorHeight*1000/2, ptEnd);
|
|
InsValveByName((const TCHAR*)xsTmp3, ptEnd, LAY_PIPE_FIRE);
|
|
double nCountHeight = dlg.m_nMinEle;
|
|
|
|
for(int i=0;i<dlg.m_iFloorNum;i++){
|
|
ptStart = ptFloor;
|
|
|
|
if(dlg.m_bFloor){
|
|
//楼板线和字
|
|
ads_polar(ptStart, PI, dlg.m_nFloorHeight*1000, ptStart);
|
|
ads_polar(ptFloor, 0, nBraLength-(dlg.m_nFloorHeight*1000), ptEnd);
|
|
CString csText = dlg.m_lstName[i];
|
|
double nLastHeight(0);
|
|
if(i > 0)
|
|
nLastHeight = _tstof(dlg.m_lstHeight[i-1]);
|
|
nCountHeight += nLastHeight;
|
|
DrawFloorLine(ptStart, ptEnd, LAY_PIPE_FIRE, csText, nCountHeight,_T(""));
|
|
|
|
// //标高
|
|
// XPoint ptEle;
|
|
// CString csEle;
|
|
// double nLastHeight(0);
|
|
// if(i > 0)
|
|
// nLastHeight = _tstof(dlg.m_lstHeight[i-1]);
|
|
// nCountHeight += nLastHeight;
|
|
// csEle.Format(_T("%.3f"), nCountHeight);
|
|
// ads_polar(ptFloor, PI, dlg.m_nFloorHeight*1000/2+200, ptEle);
|
|
// InsElevation(ptEle, csEle, LAY_PIPE_FIRE);
|
|
}
|
|
//干管
|
|
XPoint ptPipeS, ptPipeE;
|
|
ads_polar(ptFloor, PI/2, dlg.m_nElevation*1000, ptPipeS);
|
|
BOOL bLeft = FALSE;
|
|
if(dlg.m_iType == 1 || dlg.m_iType == 2 || dlg.m_iType == 8 || dlg.m_iType == 6
|
|
|| dlg.m_iType == 10 || dlg.m_iType == 9)
|
|
bLeft = TRUE;
|
|
double nHydrantRadius = 130;
|
|
if(dlg.m_iMode == 0)
|
|
nHydrantRadius = 0;
|
|
|
|
if(dlg.m_iType < 4){//单管
|
|
if(dlg.m_iType == 0)
|
|
ads_polar(ptPipeS, 0, dlg.m_nLenFire+nHydrantRadius, ptPipeE);
|
|
else if(dlg.m_iType == 1)
|
|
ads_polar(ptPipeS, PI, dlg.m_nLenFire+nHydrantRadius, ptPipeE);
|
|
else if(dlg.m_iType == 2)
|
|
ads_polar(ptPipeS, PI+PI/4, dlg.m_nLenFire+nHydrantRadius, ptPipeE);
|
|
else if(dlg.m_iType == 3)
|
|
ads_polar(ptPipeS, PI/4, dlg.m_nLenFire+nHydrantRadius, ptPipeE);
|
|
DrawSysPipeByLayer(ptPipeS, ptPipeE, LAY_PIPE_FIRE);
|
|
}
|
|
else{ //引双管
|
|
XPoint ptPipeS2, ptPipeE2;
|
|
if(dlg.m_iType == 4){ //立管左下
|
|
ads_polar(ptPipeS, 0, dlg.m_nLenPipe, ptPipeE);
|
|
ptPipeS2 = ptPipeE;
|
|
ads_polar(ptPipeS2, PI/4, dlg.m_nLenFire+nHydrantRadius, ptPipeE2);
|
|
}
|
|
else if(dlg.m_iType == 5){ //立管右下
|
|
ads_polar(ptPipeS, PI, dlg.m_nLenPipe, ptPipeE);
|
|
ptPipeS2 = ptPipeE;
|
|
ads_polar(ptPipeS2, PI/4, dlg.m_nLenFire+nHydrantRadius, ptPipeE2);
|
|
}
|
|
else if(dlg.m_iType == 6){ //立管右上
|
|
ads_polar(ptPipeS, PI+PI/4, dlg.m_nLenPipe, ptPipeE);
|
|
ptPipeS2 = ptPipeE;
|
|
ads_polar(ptPipeS2, PI, dlg.m_nLenFire+nHydrantRadius, ptPipeE2);
|
|
}
|
|
else if(dlg.m_iType == 7){ //立管左上
|
|
ads_polar(ptPipeS, PI+PI/4, dlg.m_nLenPipe, ptPipeE);
|
|
ptPipeS2 = ptPipeE;
|
|
ads_polar(ptPipeS2, 0, dlg.m_nLenFire+nHydrantRadius, ptPipeE2);
|
|
}
|
|
else if(dlg.m_iType == 8){ //立管左上
|
|
ads_polar(ptPipeS, 0, dlg.m_nLenPipe, ptPipeE);
|
|
ptPipeS2 = ptPipeE;
|
|
ads_polar(ptPipeS2, PI+PI/4, dlg.m_nLenFire+nHydrantRadius, ptPipeE2);
|
|
}
|
|
else if(dlg.m_iType == 9){ //立管右上
|
|
ads_polar(ptPipeS, PI, dlg.m_nLenPipe, ptPipeE);
|
|
ptPipeS2 = ptPipeE;
|
|
ads_polar(ptPipeS2, PI+PI/4, dlg.m_nLenFire+nHydrantRadius, ptPipeE2);
|
|
}
|
|
else if(dlg.m_iType == 10){ //立管右下
|
|
ads_polar(ptPipeS, PI/4, dlg.m_nLenPipe, ptPipeE);
|
|
ptPipeS2 = ptPipeE;
|
|
ads_polar(ptPipeS2, PI, dlg.m_nLenFire+nHydrantRadius, ptPipeE2);
|
|
}
|
|
else if(dlg.m_iType == 11){ //立管左下
|
|
ads_polar(ptPipeS, PI/4, dlg.m_nLenPipe, ptPipeE);
|
|
ptPipeS2 = ptPipeE;
|
|
ads_polar(ptPipeS2, 0, dlg.m_nLenFire+nHydrantRadius, ptPipeE2);
|
|
}
|
|
DrawSysPipeByLayer(ptPipeS, ptPipeE, LAY_PIPE_FIRE);
|
|
DrawSysPipeByLayer(ptPipeS2, ptPipeE2, LAY_PIPE_FIRE);
|
|
ptPipeE = ptPipeE2;
|
|
}
|
|
|
|
if(dlg.m_iMode == 0){
|
|
ptPipeS = ptPipeE;
|
|
ads_polar(ptPipeS, PI/2, dlg.m_nLength, ptPipeE);
|
|
DrawSysPipeByLayer(ptPipeS, ptPipeE, LAY_PIPE_FIRE);
|
|
bLeft = FALSE;
|
|
}
|
|
InsEquipmentByName((const TCHAR*)xsTmp, ptPipeE, 0, LAY_EQUIP_HYDRANT, bLeft, TRUE);
|
|
ads_polar(ptFloor, PI/2, _tstof(dlg.m_lstHeight[i])*1000, ptFloor);
|
|
}
|
|
|
|
ss.IncludeEnd();
|
|
long lenss = ss.Length();
|
|
for(long j=0;j<lenss;j++){
|
|
Entity ent = ss[j];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
if(pPipe->GetDnDiameter() < 100)
|
|
pPipe->SetDnDiameter(70);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
nOsMode &= ~0x4000;
|
|
nOsMode |= OS_INT|OS_END|OS_NEA|OS_MID;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
|
|
ptIns = Wcs2Ucs(ptIns);
|
|
|
|
ss.Redraw(2);
|
|
actrTransactionManager->flushGraphics(); //acad 刷新
|
|
XPoint xp;
|
|
int nRet = DragMovePickSet(ss, _T("\n请点取系统图位置<退出>: "), ptIns, xp);
|
|
if(nRet != RTNORM){
|
|
TPipePerDocData *pData = GetCurPipeDocData();
|
|
pData->EnableWork(FALSE);
|
|
ss.Erase();
|
|
return;
|
|
}
|
|
ss.Redraw(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CHydrantSysDlg dialog
|
|
|
|
BOOL CHydrantSysDlg::m_bFloor = TRUE;
|
|
int CHydrantSysDlg::m_iFloorNum = 8;
|
|
CHydrantSysDlg::CHydrantSysDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CHydrantSysDlg::IDD, pParent), m_spinFire(50), m_spinFloor(1), m_spinLength(50), m_spinPipe(50), m_spinFloorLen(500)
|
|
{
|
|
//{{AFX_DATA_INIT(CHydrantSysDlg)
|
|
m_nElevation = 1.1;
|
|
m_nFloorHeight = 3;
|
|
m_nLenFire = 500;
|
|
m_nLenPipe = 300;
|
|
m_nLength = 250;
|
|
m_iMode = 1;
|
|
m_iType = 0;
|
|
m_iFireType = 0;
|
|
m_nFloorLen = 20000;
|
|
//}}AFX_DATA_INIT
|
|
m_nAllHeight = 0;
|
|
m_nMinEle = 0;
|
|
}
|
|
|
|
|
|
void CHydrantSysDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CHydrantSysDlg)
|
|
DDX_Control(pDX, IDC_SPIN_LEN, m_spinFloorLen);
|
|
DDX_Control(pDX, IDC_SPIN_FIRE, m_spinFire);
|
|
DDX_Control(pDX, IDC_SPIN_FLOOR, m_spinFloor);
|
|
DDX_Control(pDX, IDC_SPIN_LENGTH, m_spinLength);
|
|
DDX_Control(pDX, IDC_SPIN_PIPE, m_spinPipe);
|
|
DDX_Text(pDX, IDC_EDIT_ELEVATION, m_nElevation);
|
|
DDX_Text(pDX, IDC_EDIT_FOOR_HEIGHT, m_nFloorHeight);
|
|
DDX_Text(pDX, IDC_EDIT_LEN_FIRE, m_nLenFire);
|
|
DDX_Text(pDX, IDC_EDIT_LEN_PIPE, m_nLenPipe);
|
|
DDX_Text(pDX, IDC_EDIT_LENGTH, m_nLength);
|
|
DDX_Text(pDX, IDC_FLOOR_NUM, m_iFloorNum);
|
|
DDX_Radio(pDX, IDC_RADIO_MODE1, m_iMode);
|
|
DDX_CBIndex(pDX, IDC_COMBO_TYPE, m_iType);
|
|
DDX_Radio(pDX, IDC_RADIO_TYPE1, m_iFireType);
|
|
DDX_Check(pDX, IDC_CHECK_FLOOR, m_bFloor);
|
|
DDX_Text(pDX, IDC_FLOOR_LEN, m_nFloorLen);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CHydrantSysDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CHydrantSysDlg)
|
|
ON_WM_PAINT()
|
|
ON_BN_CLICKED(IDC_RADIO_TYPE1, OnRadioType1)
|
|
ON_BN_CLICKED(IDC_RADIO_TYPE2, OnRadioType2)
|
|
ON_CBN_SELCHANGE(IDC_COMBO_TYPE, OnSelchangeComboType)
|
|
ON_BN_CLICKED(IDC_RADIO_MODE2, OnRadioMode2)
|
|
ON_BN_CLICKED(IDC_RADIO_MODE1, OnRadioMode1)
|
|
ON_BN_CLICKED(IDC_BUTTON_HEIGHT, OnButtonHeight)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CHydrantSysDlg message handlers
|
|
|
|
BOOL CHydrantSysDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
m_spinFire.SetRange(50, 5000);
|
|
m_spinFloor.SetRange(1, 50);
|
|
m_spinPipe.SetRange(50, 5000);
|
|
m_spinLength.SetRange(50, 1000);
|
|
m_spinFloorLen.SetRange(50, 600000);
|
|
OnRadioMode1();
|
|
OnSelchangeComboType();
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CHydrantSysDlg::OnPaint()
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
OpenSlide();
|
|
CWnd *pWnd = GetDlgItem(IDC_PREVIEW3);
|
|
DrawSlide(_T("TWT(DIM2)"), pWnd);
|
|
}
|
|
|
|
void CHydrantSysDlg::OpenSlide()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pImageBox = GetDlgItem(IDC_PREVIEW);
|
|
CWnd *pImageBox2 = GetDlgItem(IDC_STATIC_PREVIEW2);
|
|
CString csSldName;
|
|
if(m_iFireType == 0)
|
|
csSldName = _T("TWTSYS(00000386)");
|
|
else if(m_iFireType == 1)
|
|
csSldName = _T("TWTSYS(00000383)");
|
|
|
|
csSldName = g_csDwbPath + csSldName;
|
|
DrawSlide((const TCHAR*)csSldName, pImageBox);
|
|
|
|
csSldName.Format(_T("TWT(XHS%d)"), m_iType+1);
|
|
DrawSlide((const TCHAR*)csSldName, pImageBox2);
|
|
}
|
|
|
|
void CHydrantSysDlg::OnRadioType1()
|
|
{
|
|
OpenSlide();
|
|
}
|
|
|
|
void CHydrantSysDlg::OnRadioType2()
|
|
{
|
|
OpenSlide();
|
|
}
|
|
|
|
void CHydrantSysDlg::OnSelchangeComboType()
|
|
{
|
|
OpenSlide();
|
|
CWnd *pWnd1 = GetDlgItem(IDC_EDIT_LEN_PIPE);
|
|
CWnd *pWnd2 = GetDlgItem(IDC_SPIN_PIPE);
|
|
if(m_iType > 3){
|
|
pWnd1->EnableWindow(TRUE);
|
|
pWnd2->EnableWindow(TRUE);
|
|
}
|
|
else{
|
|
pWnd1->EnableWindow(FALSE);
|
|
pWnd2->EnableWindow(FALSE);
|
|
}
|
|
|
|
}
|
|
|
|
void CHydrantSysDlg::OnRadioMode2()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd1 = GetDlgItem(IDC_EDIT_LENGTH);
|
|
CWnd *pWnd2 = GetDlgItem(IDC_SPIN_LENGTH);
|
|
if(m_iMode == 0){
|
|
pWnd1->EnableWindow(TRUE);
|
|
pWnd2->EnableWindow(TRUE);
|
|
}
|
|
else{
|
|
pWnd1->EnableWindow(FALSE);
|
|
pWnd2->EnableWindow(FALSE);
|
|
}
|
|
}
|
|
|
|
void CHydrantSysDlg::OnRadioMode1()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd1 = GetDlgItem(IDC_EDIT_LENGTH);
|
|
CWnd *pWnd2 = GetDlgItem(IDC_SPIN_LENGTH);
|
|
if(m_iMode == 0){
|
|
pWnd1->EnableWindow(TRUE);
|
|
pWnd2->EnableWindow(TRUE);
|
|
}
|
|
else{
|
|
pWnd1->EnableWindow(FALSE);
|
|
pWnd2->EnableWindow(FALSE);
|
|
}
|
|
}
|
|
|
|
void CHydrantSysDlg::OnButtonHeight()
|
|
{
|
|
UpdateData(TRUE);
|
|
CTemporaryResourceOverride vTemp;
|
|
CDistFloorDlg dlg;
|
|
for(int i=0;i<m_iFloorNum;i++){
|
|
CString csText, csHeight;
|
|
csText.Format(_T("%d楼"), i+1);
|
|
dlg.m_lstName.Append(tstrnew(csText));
|
|
csHeight.Format(_T("%.2f"), m_nFloorHeight);
|
|
dlg.m_lstHeight.Append(tstrnew(csHeight));
|
|
}
|
|
if(dlg.DoModal() != IDOK)
|
|
return;
|
|
|
|
|
|
m_nMinEle = _tstof(dlg.m_sStartBaseEle);//zxl 2011.10.20 add
|
|
|
|
m_lstHeight.Reset();
|
|
m_iFloorNum = dlg.m_lstHeight.Length();
|
|
for(i=0;i<m_iFloorNum;i++){
|
|
CString csHeight;
|
|
csHeight = dlg.m_lstHeight[i];
|
|
m_lstHeight.Append(tstrnew(csHeight));
|
|
CString csText = dlg.m_lstName[i];
|
|
m_lstName.Append(tstrnew(csText));
|
|
}
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CHydrantSysDlg::OnOK()
|
|
{
|
|
UpdateData(TRUE);
|
|
CString csText, csHeight;
|
|
if(m_lstHeight.Length() < 1){
|
|
for(int i=0;i<m_iFloorNum;i++){
|
|
csText.Format(_T("%d楼"), i+1);
|
|
m_lstName.Append(tstrnew(csText));
|
|
|
|
csHeight.Format(_T("%.2f"), m_nFloorHeight);
|
|
m_lstHeight.Append(tstrnew(csHeight));
|
|
}
|
|
}
|
|
int len = m_iFloorNum - m_lstHeight.Length();
|
|
for(int j=0;j<len;j++){
|
|
csHeight.Format(_T("%.2f"), m_nFloorHeight);
|
|
m_lstHeight.Append(tstrnew(csHeight));
|
|
csText.Format(_T("%d楼"), m_lstHeight.Length());
|
|
m_lstName.Append(tstrnew(csText));
|
|
|
|
}
|
|
for(int i=0;i<m_iFloorNum;i++){
|
|
csText = m_lstHeight[i];
|
|
m_nAllHeight += (_tstof(csText)*1000);
|
|
csText = m_lstName[i];
|
|
//if(csText.Find(_T("地下")) > -1)
|
|
if(csText.Find(_T("地下")) > -1 || csText.Find(_T("-")) > -1)//添加-1F -2F表示楼层 zxl 2011.10.20 add
|
|
m_nMinEle -= _tstof(m_lstHeight[i]);
|
|
}
|
|
|
|
CDialog::OnOK();
|
|
}
|