2342 lines
72 KiB
C++
2342 lines
72 KiB
C++
// Plan2SysDlg.cpp : implementation file
|
||
//
|
||
|
||
#include "stdafx.h"
|
||
|
||
#include <dbPipe.h>
|
||
#include <DbEquipment.h>
|
||
#include <DbWell.h>
|
||
#include <dbPipeValve.h>
|
||
#include <DbPipeLabel.h>
|
||
#include <DbVPipeDim.h>
|
||
#include <dbWaterTank.h>
|
||
#include "DbSymbolAnnotate.h"
|
||
#include <PipeWireMonitor.h>
|
||
|
||
#include "twtdef.h"
|
||
#include "Plan2SysDlg.h"
|
||
|
||
#ifdef _DEBUG
|
||
#define new DEBUG_NEW
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[] = __FILE__;
|
||
#endif
|
||
|
||
extern BOOL IsAppandNode(DList<AcDbObjectId> &lstNode, AcDbObjectId id);
|
||
//extern XPoint ReadXPoint(AcDbObjectId id, const TCHAR*szName);
|
||
extern void DrawFloorLine(XPoint p1, XPoint p2, const TCHAR*szPipeLayer, const TCHAR*szText, double nHeight, const TCHAR*szSerial);
|
||
|
||
|
||
|
||
|
||
//***************************************************************************************************
|
||
// 生成系统管线
|
||
//***************************************************************************************************
|
||
/*
|
||
//克隆的时候,把所有的附件也克隆了
|
||
//导致的后果:
|
||
//如果取消系统生成,新管线删除了,而他记录的附件(实际不是他的)也被删除了
|
||
//所以这里手工把附件记录删除
|
||
TDbPipe * ClonePipe(TDbPipe *pOldPipe)
|
||
{
|
||
TDbPipe *pNewPipe = (TDbPipe *)pOldPipe->clone();
|
||
DList<AcDbObjectId> lstAttachment;
|
||
pNewPipe->GetAttachments(lstAttachment);
|
||
for(int n=0;n<lstAttachment.Length();n++){
|
||
AcDbObjectId idTmp = *lstAttachment[n];
|
||
pNewPipe->RemoveAttachment(idTmp);
|
||
}
|
||
return pNewPipe;
|
||
}
|
||
|
||
*/
|
||
|
||
TPipeSys::SysType GetPipeSys(Entity ent)
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe);
|
||
if(pPipe){
|
||
TPipeSys::SysType sys = pPipe->GetSysType();
|
||
return sys;
|
||
}
|
||
OPENOBJ_END();
|
||
return TPipeSys::kUnknownSys;
|
||
}
|
||
/*
|
||
BOOL IsHorAngle(double nAngle)
|
||
{
|
||
if(nAngle >= PI*2)
|
||
nAngle -= PI*2;
|
||
if(fabs(nAngle) < 0.00001 || fabs(nAngle - PI) < 0.00001)
|
||
return TRUE;
|
||
else
|
||
return FALSE;
|
||
}
|
||
*/
|
||
|
||
AcDbObjectId GetPipeIdByEq(Entity ent)
|
||
{
|
||
AcDbObjectId idRet = NULL;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbEquipment, pEquip);
|
||
int num = pEquip->GetInterfaceNum();
|
||
if(pEquip->GetInterfaceNum() > 0){
|
||
TPipeInterface face;
|
||
pEquip->GetInterface(0, face);
|
||
idRet = face.m_idPipe;
|
||
}
|
||
OPENOBJ_END();
|
||
return idRet;
|
||
}
|
||
|
||
/*
|
||
CString GetSysBlockByAng(const TCHAR* szOld, double angEq, BOOL &bIsBreak)
|
||
{
|
||
if(_tcsicmp(szOld, _T("")) == 0)
|
||
return CString();
|
||
CString csRet, csDesName, csTKName, csAllTk;
|
||
XString xsTKName, xsRocord;
|
||
SplitSlbName(szOld, xsTKName, xsRocord);
|
||
csTKName = xsTKName;
|
||
csAllTk.Format(_T("%s%s.tk"), g_csDwbPath, (const TCHAR*)xsTKName);
|
||
|
||
|
||
csDesName = GetBlkDesName((const TCHAR*)xsRocord, (const TCHAR*)csAllTk);
|
||
if(csDesName.Find(_T("(打断)"), 0) >= 0) // 2008-3-21 沈睿修改,默认都是打断管线
|
||
bIsBreak = TRUE;
|
||
else
|
||
bIsBreak = FALSE;
|
||
if(csDesName.Find(_T("-"), 0) < 0)
|
||
return CString(szOld);
|
||
csDesName = csDesName.Right(8); // 180度
|
||
if(angEq > 2*PI)
|
||
angEq -= 2*PI;
|
||
else if(fabs(angEq - 2*PI) < 0.01)
|
||
angEq = 0;
|
||
if(angEq < (PI/2-0.00001) && (angEq > 0 || fabs(angEq) < 0.01)){ //0
|
||
csDesName = GetBlkDesName((const TCHAR*)csDesName, (const TCHAR*)csAllTk);
|
||
csDesName = csDesName.Right(8);
|
||
csDesName = GetBlkDesName((const TCHAR*)csDesName, (const TCHAR*)csAllTk);
|
||
csDesName = csDesName.Right(8);
|
||
csRet = csDesName;
|
||
}
|
||
else if(angEq < (PI - 0.01) && angEq >= (PI/2-0.00001)){ //90
|
||
csDesName = GetBlkDesName((const TCHAR*)csDesName, (const TCHAR*)csAllTk);
|
||
csDesName = csDesName.Right(8);
|
||
csDesName = GetBlkDesName((const TCHAR*)csDesName, (const TCHAR*)csAllTk);
|
||
csDesName = csDesName.Right(8);
|
||
csDesName = GetBlkDesName((const TCHAR*)csDesName, (const TCHAR*)csAllTk);
|
||
csDesName = csDesName.Right(8);
|
||
csRet = csDesName;
|
||
}
|
||
else if((angEq + 0.01) < PI/2*3 && (angEq > PI || fabs(angEq - PI) < 0.01)){ //180
|
||
csRet = csDesName;
|
||
}
|
||
else if(angEq < PI*2 && (angEq > PI/2*3 || fabs(angEq - PI/2*3) < 0.01)){ //270
|
||
csDesName = GetBlkDesName((const TCHAR*)csDesName, (const TCHAR*)csAllTk);
|
||
csDesName = csDesName.Right(8);
|
||
csRet = csDesName;
|
||
}
|
||
if(csRet != _T(""))
|
||
csRet = csTKName + _T("(") + csRet + _T(")");
|
||
return csRet;
|
||
}
|
||
|
||
|
||
|
||
|
||
void PlanEquip2Sys(AcDbObjectId id, TDbPipe *pPipe, double nRadian, AcGeMatrix3d mat, AcGeScale3d scale)
|
||
{
|
||
if(!pPipe || !id)
|
||
return;
|
||
XPoint ptStart, ptEnd, ptNewS, ptNewE, ptInsert;
|
||
double dX = scale.sx;
|
||
double dY = scale.sy;
|
||
double dZ = scale.sz;
|
||
|
||
if(IsWell(id))
|
||
{
|
||
TDbWell *pNewWell = NULL;
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbWell, pEquip);
|
||
if(pEquip){
|
||
ptStart = pEquip->GetLocation();
|
||
pNewWell = (TDbWell *)pEquip->clone();
|
||
}
|
||
OPENOBJ_END();
|
||
ptStart.TransformBy(mat);
|
||
|
||
ptStart = Wcs2Ucs(ptStart); // sr 2010-1-28 modify 系统生成支持UCS
|
||
ptNewS.x = ptStart.x*dX + cos(nRadian)*ptStart.y*dY;
|
||
ptNewS.y = ptStart.z*dZ + sin(nRadian)*ptStart.y*dY;
|
||
ptNewS = Ucs2Wcs(ptNewS); // sr 2010-1-28 modify 系统生成支持UCS
|
||
|
||
pNewWell->SetLocation(ptNewS);
|
||
pNewWell->SetInsert(ptNewS);
|
||
pNewWell->EnableDrawLabel(FALSE);
|
||
pNewWell->SetHidePipe(TRUE);
|
||
// pNewWell->SetLabelLocation(ptNewS);
|
||
// pNewWell->SetHidePipe(FALSE);
|
||
|
||
AddToCurrentSpace(pNewWell, Adesk::kTrue);
|
||
return;
|
||
}
|
||
|
||
XString xsTmpSys;
|
||
TDbEquipment *pNewEquip = NULL;
|
||
|
||
BOOL bIsBreak = TRUE;
|
||
AcDbObjectId sysBlkId(NULL);
|
||
|
||
CString csBlkName, csSysBlk, csDesName;
|
||
int iItem;
|
||
GetEquipNameById(id, csBlkName, csDesName, iItem);
|
||
|
||
double angEq(0), nRotateNewEq(0), nPipeLength(0);
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbEquipment, pEquip);
|
||
if(pEquip){
|
||
ptStart = pEquip->GetLocation();
|
||
//ptStart = pEquip->GetInsert();
|
||
ptInsert = ptStart;
|
||
nPipeLength = pEquip->GetPipeLength();
|
||
AcDbObjectId idBlk = pEquip->GetBlock2d();
|
||
csBlkName = GetBlkNameById(idBlk);
|
||
csSysBlk = pEquip->GetSysBlock();
|
||
angEq = pEquip->GetAngle();
|
||
if(csSysBlk == _T("") && _tcsicmp(_T("$TWTSYS$00000320"), csBlkName) == 0)
|
||
return;//对于热水给水点(十字叉), 如果系统图块为空,就不生成了, 由给水生成
|
||
pNewEquip = (TDbEquipment *)pEquip->clone();
|
||
}
|
||
OPENOBJ_END();
|
||
ptStart.TransformBy(mat);
|
||
ptStart = Wcs2Ucs(ptStart); // sr 2010-1-28 modify 系统生成支持UCS
|
||
|
||
csSysBlk = GetSysBlockByAng(csSysBlk, angEq, bIsBreak);
|
||
|
||
if(LoadDwbBlock((const TCHAR*)csSysBlk, xsTmpSys) == RTNORM){
|
||
sysBlkId = GetBlkIdByName((const TCHAR*)xsTmpSys);
|
||
pNewEquip->SetBlock2d(sysBlkId);
|
||
}
|
||
|
||
if(fabs(nPipeLength) > 0.001){
|
||
if(_tcsicmp(_T("$TWTSYS$00000128"), csBlkName) == 0){ //上下喷头
|
||
ptEnd = ptStart;
|
||
ptEnd.z -= nPipeLength;
|
||
ptNewS.x = ptStart.x*dX + cos(nRadian)*ptStart.y*dY;
|
||
ptNewS.y = ptStart.z*dZ + sin(nRadian)*ptStart.y*dY;
|
||
ptNewE.x = ptEnd.x*dX + cos(nRadian)*ptEnd.y*dY;
|
||
ptNewE.y = ptEnd.z*dZ + sin(nRadian)*ptEnd.y*dY;
|
||
ptNewS = Ucs2Wcs(ptNewS); // sr 2010-1-28 modify 系统生成支持UCS
|
||
ptNewE = Ucs2Wcs(ptNewE); // sr 2010-1-28 modify 系统生成支持UCS
|
||
|
||
TDbPipe *pNewPipe = ClonePipe(pPipe);
|
||
pNewPipe->EnableDrawLabel(FALSE);
|
||
pNewPipe->SetDnDiameter(25);
|
||
pNewPipe->SetStartPoint(ptNewS);
|
||
pNewPipe->SetEndPoint(ptNewE);
|
||
pNewPipe->SetHideLevel(1);
|
||
pNewPipe->SetModelType(TPipeSys::kSystem);
|
||
AddToCurrentSpace(pNewPipe, Adesk::kTrue);
|
||
TDbEquipment *pNewEquip2 = NULL;
|
||
pNewEquip2 = (TDbEquipment *)pNewEquip->clone();
|
||
ptNewS.x = ptEnd.x*dX + cos(nRadian)*ptEnd.y*dY;
|
||
ptNewS.y = ptEnd.z*dZ + sin(nRadian)*ptEnd.y*dY;
|
||
ptNewS = Ucs2Wcs(ptNewS); // sr 2010-1-28 modify 系统生成支持UCS
|
||
|
||
pNewEquip2->SetSysBlock(_T(""));
|
||
pNewEquip2->SetHidePipe(bIsBreak);
|
||
pNewEquip2->SetAngle(Ucs2Wcs(0.0));// sr 2010-1-28 modify 系统生成支持UCS
|
||
pNewEquip2->SetLocation(ptNewS);
|
||
pNewEquip2->SetInsert(ptNewS);
|
||
AddToCurrentSpace(pNewEquip2, Adesk::kTrue);
|
||
}
|
||
else if(_tcsicmp(_T("$TWTSYS$00000131"), csBlkName) == 0){//侧喷头
|
||
ptEnd = ptStart;
|
||
ptEnd.z += nPipeLength;
|
||
ptNewS.x = ptEnd.x*dX + cos(nRadian)*ptEnd.y*dY;
|
||
ptNewS.y = ptEnd.z*dZ + sin(nRadian)*ptEnd.y*dY;
|
||
ptNewE = ptNewS;
|
||
ptNewE.x -= nPipeLength/2;//往右画
|
||
ptNewS = Ucs2Wcs(ptNewS); // sr 2010-1-28 modify 系统生成支持UCS
|
||
ptNewE = Ucs2Wcs(ptNewE); // sr 2010-1-28 modify 系统生成支持UCS
|
||
|
||
// TDbPipe *pNewPipe3 = (TDbPipe *)pPipe->clone();
|
||
TDbPipe *pNewPipe3 = ClonePipe(pPipe);
|
||
pNewPipe3->SetDnDiameter(25);
|
||
pNewPipe3->EnableDrawLabel(FALSE);
|
||
pNewPipe3->SetStartPoint(ptNewS);
|
||
pNewPipe3->SetEndPoint(ptNewE);
|
||
pNewPipe3->SetHideLevel(1);
|
||
pNewPipe3->SetModelType(TPipeSys::kSystem);
|
||
AddToCurrentSpace(pNewPipe3, Adesk::kTrue);
|
||
nRotateNewEq = PI/2;
|
||
|
||
}
|
||
|
||
ptEnd = ptStart;
|
||
ptEnd.z += nPipeLength;
|
||
ptNewS.x = ptStart.x*dX + cos(nRadian)*ptStart.y*dY;
|
||
ptNewS.y = ptStart.z*dZ + sin(nRadian)*ptStart.y*dY;
|
||
ptNewE.x = ptEnd.x*dX + cos(nRadian)*ptEnd.y*dY;
|
||
ptNewE.y = ptEnd.z*dZ + sin(nRadian)*ptEnd.y*dY;
|
||
|
||
ptNewS = Ucs2Wcs(ptNewS); // sr 2010-1-28 modify 系统生成支持UCS
|
||
ptNewE = Ucs2Wcs(ptNewE); // sr 2010-1-28 modify 系统生成支持UCS
|
||
|
||
TDbPipe *pNewPipe = ClonePipe(pPipe);
|
||
if(_tcsicmp(_T("TWTSYS(00000283)"), csSysBlk) == 0 || _tcsicmp(_T("TWTSYS(00000126)"), csSysBlk) == 0)
|
||
pNewPipe->SetDnDiameter(25);
|
||
pNewPipe->EnableDrawLabel(FALSE);
|
||
pNewPipe->SetStartPoint(ptNewS);
|
||
pNewPipe->SetEndPoint(ptNewE);
|
||
pNewPipe->SetHideLevel(1);
|
||
pNewPipe->SetModelType(TPipeSys::kSystem);
|
||
AddToCurrentSpace(pNewPipe, Adesk::kTrue);
|
||
ptStart = ptEnd;
|
||
}
|
||
if(nPipeLength > 0 && (_tcsicmp(_T("TWTSYS(00000283)"), csSysBlk) == 0 || _tcsicmp(_T("TWTSYS(00000126)"), csSysBlk) == 0))
|
||
nRotateNewEq = PI;
|
||
|
||
|
||
pNewEquip->SetAngle(nRotateNewEq + Ucs2Wcs(0.0));// sr 2010-1-28 modify 系统生成支持UCS
|
||
if(_tcsicmp(_T("$TWTSYS$00000147"), csBlkName) == 0){ //排水点
|
||
pNewEquip->SetScale(1);
|
||
pNewEquip->SetYScale(1);
|
||
}
|
||
|
||
|
||
ptNewS.x = ptStart.x*dX + cos(nRadian)*ptStart.y*dY;
|
||
ptNewS.y = ptStart.z*dZ + sin(nRadian)*ptStart.y*dY;
|
||
ptNewS = Ucs2Wcs(ptNewS); // sr 2010-1-28 modify 系统生成支持UCS
|
||
|
||
ptNewE = ptNewS;
|
||
|
||
if(csDesName.Find(_T("消火栓")) > -1){ //消火栓
|
||
// pNewEquip->SetNumber(_T("CIRCLE-131"));
|
||
pNewEquip->SetScale(1);
|
||
pNewEquip->SetYScale(1);
|
||
pNewEquip->SetZScale(1);
|
||
bIsBreak = FALSE;
|
||
//消火栓的插入基点要偏移
|
||
if(fabs(nPipeLength) > 0.001)//上接直接往上偏移131
|
||
{
|
||
if(pNewEquip->IsAutoScale())
|
||
ads_polar(ptNewS, PI/2, 131*pNewEquip->GetPScale()/100, ptNewE);
|
||
else
|
||
ads_polar(ptNewS, PI/2, 131, ptNewE);
|
||
}
|
||
else{//平接,要根据接管角度而定
|
||
XPoint ptTmp;
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbEquipment, pEquip);
|
||
if(pEquip){
|
||
int num = pEquip->GetInterfaceNum();
|
||
if(num == 1){
|
||
TPipeInterface face;
|
||
pEquip->GetInterface(0, face);
|
||
AcDbObjectId idPipeTmp = face.m_idPipe;
|
||
OPENOBJ_BEGIN(idPipeTmp, AcDb::kForRead, TDbPipe, pPipeTmp);
|
||
if(pPipeTmp){
|
||
XPoint p1 = pPipeTmp->StartPoint();
|
||
XPoint p2 = pPipeTmp->EndPoint();
|
||
XPoint p11 = p1;
|
||
XPoint P22 = p2;
|
||
p1.TransformBy(mat);
|
||
p2.TransformBy(mat);
|
||
|
||
XPoint p3, p4;
|
||
p3.x = p1.x*dX + cos(nRadian)*p1.y*dY;
|
||
p3.y = p1.z*dZ + sin(nRadian)*p1.y*dY;
|
||
p4.x = p2.x*dX + cos(nRadian)*p2.y*dY;
|
||
p4.y = p2.z*dZ + sin(nRadian)*p2.y*dY;
|
||
|
||
if(p11 == ptInsert)
|
||
ptTmp = p4;
|
||
else if(P22 == ptInsert)
|
||
ptTmp = p3;
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
if(!!ptTmp){//消火栓的插入基点要偏移
|
||
double dAng3 = ads_angle(ptTmp, ptNewS);
|
||
ads_polar(ptNewS, dAng3, 131, ptNewE);
|
||
}
|
||
}
|
||
}
|
||
pNewEquip->SetSysBlock(_T(""));
|
||
pNewEquip->SetHidePipe(bIsBreak);
|
||
if(csBlkName != _T("") && _tcsicmp(_T("$TWTSYS$00000131"), csBlkName) == 0)//侧喷时多画一段小横管
|
||
{
|
||
ptNewS = Wcs2Ucs(ptNewS);
|
||
ptNewS.x -= nPipeLength/2;
|
||
ptNewS = Ucs2Wcs(ptNewS);
|
||
ptNewE = ptNewS;
|
||
}
|
||
pNewEquip->SetLocation(ptNewS);
|
||
pNewEquip->SetInsert(ptNewE);
|
||
|
||
|
||
|
||
AddToCurrentSpace(pNewEquip, Adesk::kTrue);
|
||
}
|
||
|
||
*/
|
||
|
||
|
||
|
||
CString GetPipeLayerByVPipeLay(const TCHAR* szLayer)
|
||
{
|
||
CString csLayer = szLayer;
|
||
CString csRet;
|
||
if(csLayer == LAY_VPIPE_FEED || csLayer == LAY_PIPE_FEED)
|
||
csRet = LAY_PIPE_FEED;
|
||
else if(csLayer == LAY_VPIPE_HEADFEED || csLayer == LAY_PIPE_HEADFEED)
|
||
csRet = LAY_PIPE_HEADFEED;
|
||
else if(csLayer == LAY_VPIPE_HEADBACK || csLayer == LAY_PIPE_HEADBACK)
|
||
csRet = LAY_PIPE_HEADBACK;
|
||
else if(csLayer == LAY_VPIPE_DIRT || csLayer == LAY_PIPE_DIRT)
|
||
csRet = LAY_PIPE_DIRT;
|
||
else if(csLayer == LAY_VPIPE_USELESS || csLayer == LAY_PIPE_USELESS)
|
||
csRet = LAY_PIPE_USELESS;
|
||
else if(csLayer == LAY_VPIPE_RAIN || csLayer == LAY_PIPE_RAIN)
|
||
csRet = LAY_PIPE_RAIN;
|
||
else if(csLayer == LAY_VPIPE_USED || csLayer == LAY_PIPE_USED)
|
||
csRet = LAY_PIPE_USED;
|
||
else if(csLayer == LAY_VPIPE_FIRE || csLayer == LAY_PIPE_FIRE)
|
||
csRet = LAY_PIPE_FIRE;
|
||
else if(csLayer == LAY_VPIPE_SPRINKLE || csLayer == LAY_PIPE_SPRINKLE)
|
||
csRet = LAY_PIPE_SPRINKLE;
|
||
else if(csLayer == LAY_VPIPE_COAGULATE || csLayer == LAY_PIPE_COAGULATE)
|
||
csRet = LAY_PIPE_COAGULATE;
|
||
else if(csLayer == LAY_VPIPE_DRINK || csLayer == LAY_PIPE_DRINK)
|
||
csRet = LAY_PIPE_DRINK;
|
||
else if(csLayer == LAY_VPIPE_PRESSDIRT || csLayer == LAY_PIPE_PRESSDIRT)
|
||
csRet = LAY_PIPE_PRESSDIRT;
|
||
else if(csLayer == LAY_VPIPE_PRESSUSELESS || csLayer == LAY_PIPE_PRESSUSELESS)
|
||
csRet = LAY_PIPE_PRESSUSELESS;
|
||
else if(csLayer == LAY_VPIPE_PRESSRAIN || csLayer == LAY_PIPE_PRESSRAIN)
|
||
csRet = LAY_PIPE_PRESSRAIN;
|
||
else if(csLayer == LAY_VPIPE_OTHER || csLayer == LAY_PIPE_OTHER)
|
||
csRet = LAY_PIPE_OTHER;
|
||
else if(csLayer == LAY_VPIPE_FEED2 || csLayer == LAY_PIPE_FEED2)
|
||
csRet = LAY_PIPE_FEED2;
|
||
else if(csLayer == LAY_VPIPE_FEED3 || csLayer == LAY_PIPE_FEED3)
|
||
csRet = LAY_PIPE_FEED3;
|
||
else if(csLayer == LAY_VPIPE_HEADFEED2 || csLayer == LAY_PIPE_HEADFEED2)
|
||
csRet = LAY_PIPE_HEADFEED2;
|
||
else if(csLayer == LAY_VPIPE_HEADFEED3 || csLayer == LAY_PIPE_HEADFEED3)
|
||
csRet = LAY_PIPE_HEADFEED3;
|
||
else if(csLayer == LAY_VPIPE_HEADBACK2 || csLayer == LAY_PIPE_HEADBACK2)
|
||
csRet = LAY_PIPE_HEADBACK2;
|
||
else if(csLayer == LAY_VPIPE_HEADBACK3 || csLayer == LAY_PIPE_HEADBACK3)
|
||
csRet = LAY_PIPE_HEADBACK3;
|
||
else if(csLayer == LAY_VPIPE_FIRE2 || csLayer == LAY_PIPE_FIRE2)
|
||
csRet = LAY_PIPE_FIRE2;
|
||
else if(csLayer == LAY_VPIPE_FIRE3 || csLayer == LAY_PIPE_FIRE3)
|
||
csRet = LAY_PIPE_FIRE3;
|
||
else if(csLayer == LAY_VPIPE_SPRINKLE2 || csLayer == LAY_PIPE_SPRINKLE2)
|
||
csRet = LAY_PIPE_SPRINKLE2;
|
||
else if(csLayer == LAY_VPIPE_SPRINKLE3 || csLayer == LAY_PIPE_SPRINKLE3)
|
||
csRet = LAY_PIPE_SPRINKLE3;
|
||
else if(csLayer == LAY_VPIPE_USED2 || csLayer == LAY_PIPE_USED2)
|
||
csRet = LAY_PIPE_USED2;
|
||
else if(csLayer == LAY_VPIPE_USED3 || csLayer == LAY_PIPE_USED3)
|
||
csRet = LAY_PIPE_USED3;
|
||
else if(csLayer == LAY_PIPE_USER1 || csLayer == LAY_VPIPE_USER1)
|
||
csRet = LAY_PIPE_USER1;
|
||
else if(csLayer == LAY_PIPE_USER2 || csLayer == LAY_VPIPE_USER2)
|
||
csRet = LAY_PIPE_USER2;
|
||
else if(csLayer == LAY_PIPE_USER3 || csLayer == LAY_VPIPE_USER3) // cet 2011.12.12 add user3-user8
|
||
csRet = LAY_PIPE_USER3;
|
||
else if(csLayer == LAY_PIPE_USER4 || csLayer == LAY_VPIPE_USER4)
|
||
csRet = LAY_PIPE_USER4;
|
||
else if(csLayer == LAY_PIPE_USER5 || csLayer == LAY_VPIPE_USER5)
|
||
csRet = LAY_PIPE_USER5;
|
||
else if(csLayer == LAY_PIPE_USER6 || csLayer == LAY_VPIPE_USER6)
|
||
csRet = LAY_PIPE_USER6;
|
||
else if(csLayer == LAY_PIPE_USER7 || csLayer == LAY_VPIPE_USER7)
|
||
csRet = LAY_PIPE_USER7;
|
||
else if(csLayer == LAY_PIPE_USER8 || csLayer == LAY_VPIPE_USER8)
|
||
csRet = LAY_PIPE_USER8;
|
||
|
||
return csRet;
|
||
}
|
||
/*
|
||
AcDbObjectId PlanLabel2Sys(AcDbObjectId id, TDbPipe *pPipe)
|
||
{
|
||
TDbPipeLabel *pNewLabel = NULL;
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipeLabel, pLabel);
|
||
pNewLabel = (TDbPipeLabel *)pLabel->clone();
|
||
OPENOBJ_END();
|
||
|
||
XPoint ptS, ptE, ptMid;
|
||
ptS = pPipe->StartPoint();
|
||
ptE = pPipe->EndPoint();
|
||
XLine line(ptS, ptE, 1);
|
||
line.MidPoint(ptMid);
|
||
pNewLabel->SetLocation(ptMid);
|
||
AcDbObjectId idNewLabel = AddToCurrentSpace(pNewLabel, Adesk::kTrue);
|
||
return idNewLabel;
|
||
|
||
}
|
||
|
||
*/
|
||
|
||
//取消自定义实体中做系统图转换,改为重新生成水箱线框. sr 20061221
|
||
void PlanWaterTank2Sys(Entity ent, double nRadian)
|
||
{
|
||
XPushVarStr clayer(_T("CLAYER"), LAY_TWT_WATERTANK);
|
||
XPoint ptNewE, ptNewS;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWaterTank, pTank);
|
||
if(pTank){
|
||
AcDbVoidPtrArray entSet;
|
||
XExplodeStream dc(entSet);
|
||
pTank->ExplodeOrDraw3d(dc);
|
||
int nLen=entSet.length();
|
||
for(int n=0; n<nLen; n++) {
|
||
AcDbEntity *pEnt=(AcDbEntity *)entSet[n];
|
||
if(pEnt->isKindOf(AcDbFace::desc())) {
|
||
AcDbFace *pFace = AcDbFace::cast(pEnt);
|
||
XPoint p1,p2,p3,p4;
|
||
pFace->getVertexAt(0, p1);
|
||
pFace->getVertexAt(1, p2);
|
||
pFace->getVertexAt(2, p3);
|
||
pFace->getVertexAt(3, p4);
|
||
|
||
ptNewS.x = p1.x + cos(nRadian)*p1.y;
|
||
ptNewS.y = p1.z + sin(nRadian)*p1.y;
|
||
ptNewE.x = p2.x + cos(nRadian)*p2.y;
|
||
ptNewE.y = p2.z + sin(nRadian)*p2.y;
|
||
XLine l1(ptNewS, ptNewE);
|
||
l1.Make();
|
||
|
||
ptNewS.x = p2.x + cos(nRadian)*p2.y;
|
||
ptNewS.y = p2.z + sin(nRadian)*p2.y;
|
||
ptNewE.x = p3.x + cos(nRadian)*p3.y;
|
||
ptNewE.y = p3.z + sin(nRadian)*p3.y;
|
||
XLine l2(ptNewS, ptNewE);
|
||
l2.Make();
|
||
}
|
||
}
|
||
ReleaseEntSet(entSet);
|
||
}
|
||
OPENOBJ_END();
|
||
return;
|
||
}
|
||
/*
|
||
|
||
AcDbObjectId PlanValve2Sys(AcDbObjectId id, TDbPipe *pPipe, double nRadian, AcGeMatrix3d mat, AcGeScale3d scale)
|
||
{
|
||
XPoint ptStart, ptNewS;
|
||
CString csSysBlk, csSysBlk2, csSysBlk3;
|
||
CString csTK, csRecord;
|
||
|
||
double dX = scale.sx;
|
||
double dY = scale.sy;
|
||
double dZ = scale.sz;
|
||
|
||
TDbPipeValve *pNewValve = NULL;
|
||
AcDbObjectId idBlk = NULL;
|
||
double nWidth(0);
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipeValve, pValve);
|
||
pNewValve = (TDbPipeValve *)pValve->clone();
|
||
|
||
|
||
idBlk = pValve->GetBlock2d();
|
||
CString csBlkName = GetBlkNameById(idBlk);
|
||
SplitBlkStr(csBlkName, csTK, csRecord);
|
||
nWidth = pValve->GetWidth();
|
||
csSysBlk = pValve->GetSysBlock();
|
||
ptStart = pValve->GetLocation();
|
||
OPENOBJ_END();
|
||
|
||
ptStart.TransformBy(mat);
|
||
|
||
ptStart = Wcs2Ucs(ptStart); // sr 2010-1-28 modify 系统生成支持UCS
|
||
ptNewS.x = ptStart.x*dX + cos(nRadian)*ptStart.y*dY;
|
||
ptNewS.y = ptStart.z*dZ + sin(nRadian)*ptStart.y*dY;
|
||
ptNewS = Ucs2Wcs(ptNewS); // sr 2010-1-28 modify 系统生成支持UCS
|
||
|
||
pNewValve->SetLocation(ptNewS);
|
||
XPoint pt1 = pPipe->StartPoint();
|
||
XPoint pt2 = pPipe->EndPoint();
|
||
double ang = ads_angle(pt1, pt2) - Ucs2Wcs(0.0);// sr 2010-1-28 modify 系统生成支持UCS
|
||
pNewValve->SetSysBlock(_T(""));
|
||
int idx = csSysBlk.Find(_T("-"));
|
||
int idx2 = csSysBlk.Find(_T("-"), idx+1);
|
||
|
||
csSysBlk3 = csSysBlk.Right(8);
|
||
if(idx2 > -1)//平面阀门和系统阀门完全不一样 2005-5-31
|
||
csSysBlk2 = csSysBlk.Mid(idx+1, 8);
|
||
|
||
|
||
if(!IsHorAngle(ang) && csSysBlk3 != _T("")){
|
||
if(idx < 0){
|
||
pNewValve->SetBlock2d(idBlk);
|
||
pNewValve->SetWidth(nWidth);
|
||
}
|
||
else{
|
||
XString xsTmpSys;
|
||
CString csDwb = g_csDwbPath + csTK;
|
||
if(LoadDwbBlock(csDwb, (const TCHAR*)csSysBlk3, xsTmpSys) != RTNORM)
|
||
return NULL;
|
||
double nWidth = GetValveWidth(xsTmpSys);
|
||
pNewValve->SetWidth(nWidth);
|
||
AcDbObjectId recordId = GetBlkIdByName((const TCHAR*)xsTmpSys);
|
||
pNewValve->SetBlock2d(recordId);
|
||
}
|
||
}
|
||
else if(IsHorAngle(ang) && csSysBlk2 != _T("")){
|
||
XString xsTmpSys;
|
||
CString csDwb = g_csDwbPath + csTK;
|
||
if(LoadDwbBlock(csDwb, (const TCHAR*)csSysBlk2, xsTmpSys) != RTNORM)
|
||
return NULL;
|
||
double nWidth = GetValveWidth(xsTmpSys);
|
||
pNewValve->SetWidth(nWidth);
|
||
AcDbObjectId recordId = GetBlkIdByName((const TCHAR*)xsTmpSys);
|
||
pNewValve->SetBlock2d(recordId);
|
||
}
|
||
AcDbObjectId idNewValve = AddToCurrentSpace(pNewValve, Adesk::kTrue);
|
||
return idNewValve;
|
||
}
|
||
*/
|
||
|
||
//extern Acad::ErrorStatus AssureInCurrentView_New(const XPoint &ptLow, const XPoint &ptUp);
|
||
|
||
CString GetVPipeDimText(AcDbObjectId id)
|
||
{
|
||
CString csDimText;
|
||
RBList rbMask(RTDXF0, _T("ATS_VPIPEDIM"), NULL);
|
||
PickSet ss(SS_FREE);
|
||
ss.Get(_T("X"), NULL, NULL, rbMask);
|
||
long len = ss.Length();
|
||
for(long i=0;i<len;i++){
|
||
Entity ent = ss[i];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbVPipeDim, pDim);
|
||
if(pDim){
|
||
if(pDim->GetVPipeId() == id)
|
||
{
|
||
pDim->GetDimText(csDimText);
|
||
return csDimText;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
//2段立管,就找不到了
|
||
XPoint ptStart, ptEnd;
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipe, pPipe)
|
||
if(pPipe){
|
||
ptStart = pPipe->StartPoint();
|
||
ptEnd = pPipe->EndPoint();
|
||
}
|
||
OPENOBJ_END();
|
||
ptStart.z = 0;
|
||
ptEnd.z = 0;
|
||
PickSet ss2(SS_FREE);
|
||
AssureInCurrentView_New(ptStart, ptEnd);
|
||
GetPointPickSet(Wcs2Ucs(ptStart), ss2, rbMask);
|
||
if(ss2.Length() == 1)
|
||
{
|
||
Entity ent = ss2[0L];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbVPipeDim, pDim);
|
||
if(pDim){
|
||
pDim->GetDimText(csDimText);
|
||
return csDimText;
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
return csDimText;
|
||
}
|
||
|
||
BOOL IsOutDoorPipe(Entity ent)
|
||
{
|
||
BOOL bRet = FALSE;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe)
|
||
if(pPipe){
|
||
AcDbObjectId id0 = pPipe->GetNode(0);
|
||
AcDbObjectId id1 = pPipe->GetNode(1);
|
||
BOOL b1 = FALSE;
|
||
BOOL b2 = FALSE;
|
||
OPENOBJ_BEGIN(id0, AcDb::kForRead, TDbWell, pEquip);
|
||
if(pEquip){
|
||
b1 = TRUE;
|
||
}
|
||
OPENOBJ_END();
|
||
OPENOBJ_BEGIN(id1, AcDb::kForRead, TDbWell, pEquip);
|
||
if(pEquip){
|
||
b2 = TRUE;
|
||
}
|
||
OPENOBJ_END();
|
||
if(b1 && b2)
|
||
return TRUE;
|
||
}
|
||
OPENOBJ_END()
|
||
return bRet;
|
||
}
|
||
|
||
// cet 2013.4.27 add 系统生成时,如果TDbEquipment对象是洁具用到的给水点,
|
||
// 根据TDbEquipment的镜像,需要调整其角度,否则产生的洁具系统图有误
|
||
void UpdateSanitaryEqu(const AcDbObjectId &idEqu)
|
||
{
|
||
OPENOBJ_BEGIN(idEqu, AcDb::kForRead, TDbEquipment, pEqu);
|
||
if (pEqu != NULL)
|
||
{
|
||
AcDbObjectId idBlk = pEqu->GetBlock2d();
|
||
CString sBlkName;
|
||
AcDbBlockTableRecord *pRec = NULL;
|
||
acdbOpenObject(pRec, idBlk, AcDb::kForRead);
|
||
if (pRec != NULL)
|
||
{
|
||
const TCHAR *pszBlkName = NULL;
|
||
pRec->getName(pszBlkName);
|
||
sBlkName = pszBlkName;
|
||
pRec->close();
|
||
}
|
||
|
||
// 去除限制,所有给水附件和排水附件均支持镜像 zxl 2013.10.12 del
|
||
// 非给水点或排水点
|
||
// if (sBlkName.CompareNoCase(_T("$TwtSys$00000225")) != 0 && sBlkName.CompareNoCase(_T("$TwtSys$00000320")) != 0
|
||
// && sBlkName.CompareNoCase(_T("$TwtSys$00000519")) != 0 && sBlkName.CompareNoCase(_T("$TwtSys$00000147")) != 0)
|
||
// {
|
||
// return;
|
||
// }
|
||
|
||
// 更加镜像设置设备角度
|
||
if (pEqu->upgradeOpen() == Acad::eOk)
|
||
{
|
||
double dAngle = pEqu->GetAngle();
|
||
// x轴镜像
|
||
if (pEqu->IsMirrorByX())
|
||
{
|
||
dAngle += PI;
|
||
pEqu->MirrorByX(FALSE);
|
||
}
|
||
|
||
// y轴镜像
|
||
if (pEqu->IsMirrorByY())
|
||
{
|
||
dAngle += PI;
|
||
pEqu->MirrorByY(FALSE);
|
||
}
|
||
pEqu->SetAngle(dAngle);
|
||
pEqu->downgradeOpen();
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
// zxl 2013.07.16 add 系统生成显示井编号
|
||
void SetWellDimShow(Entity entWell, const AcDbObjectId idWellOld)
|
||
{
|
||
AcGeVector3d vtDim;
|
||
OPENOBJ_BEGIN(idWellOld, AcDb::kForRead, TDbEquipment, pEqu);
|
||
if (pEqu != NULL)
|
||
{
|
||
if (pEqu->isKindOf(TDbWell::desc()))
|
||
{
|
||
TDbWell *pWell = (TDbWell *)pEqu;
|
||
XPoint ptDim = pWell->GetLabelLocation();
|
||
XPoint ptLoc = pWell->GetLocation();
|
||
|
||
vtDim = ptDim - ptLoc;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
OPENOBJ_BEGIN(entWell, AcDb::kForWrite, AcDbEntity, pEnt);
|
||
if(pEnt != NULL)
|
||
{
|
||
if (pEnt->isKindOf(TDbWell::desc()))
|
||
{
|
||
TDbWell *pWell = (TDbWell *)pEnt;
|
||
pWell->EnableDrawLabel(TRUE);
|
||
XPoint ptLoc = pWell->GetLocation();
|
||
|
||
pWell->SetLabelLocation(ptLoc + vtDim);
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
|
||
void BuildSysPipe()
|
||
{
|
||
CTemporaryResourceOverride vTemp;
|
||
CPlan2SysDlg dlg;
|
||
if(dlg.DoModal() != IDOK)
|
||
return;
|
||
int nOsMode=0;
|
||
xg_getvar(_T("OSMODE"), &nOsMode);
|
||
nOsMode &= ~0x4000;
|
||
nOsMode |= OS_INT|OS_NEA|OS_PER|OS_END|OS_CEN;
|
||
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
||
|
||
XPoint ptIns;
|
||
xg_getvar(_T("VIEWCTR"), ptIns);
|
||
ptIns = Ucs2Wcs(ptIns);
|
||
ptIns.z = 0;
|
||
CString csPipeLayer = GetPipeLayerByIdx(dlg.m_iPipeType);
|
||
double nSysAng = _tstof(dlg.m_csAngle);
|
||
double nRadian = nSysAng/180.0*PI;
|
||
XPoint ptVerticalS, ptVerticalE;
|
||
XPoint ptStart, ptEnd, ptNewS, ptNewE;
|
||
PickSet ssNew(SS_FREE);
|
||
|
||
ssNew.IncludeBegin();
|
||
double nCountHeight(0);
|
||
int iFloorIdx = 0;
|
||
CString csFloorName = dlg.m_csFloorPostfixName; //楼层名后缀,1F 1层 1楼
|
||
int iFirstFloor = dlg.m_iFirstFloor;
|
||
CString csBasementName = dlg.m_csBasementName;
|
||
|
||
XPointList lstHasDimedPt;//已经标注的点
|
||
DList<SFloorLine> lstFloorDimed; //已经标注过的楼层线
|
||
|
||
//---------- 每个不同的楼层 ------------------------
|
||
for(dlg.m_grid.MoveToFirst(); !dlg.m_grid.IsOut(); dlg.m_grid.MoveToNext()){
|
||
WDGridRow *pRow = dlg.m_grid.CurRow();
|
||
double nFloorHeight(0);
|
||
CString csHeight = (*pRow)[2].GetText().cs();
|
||
nFloorHeight = _tstof(csHeight);
|
||
CString csNum = (*pRow)[1].GetText().cs();
|
||
int iFloorNum = _ttoi(csNum);
|
||
|
||
TGridFloorData *pNewData = (TGridFloorData *)pRow->GetExtendData();
|
||
if(pNewData == NULL)
|
||
continue;
|
||
XPoint ptBase = pNewData->m_ptBase;
|
||
|
||
int length = pNewData->m_lstId.Length();
|
||
|
||
//---------- 标准层 ------------------------
|
||
for(int m=0;m<iFloorNum;m++){
|
||
iFloorIdx++;
|
||
AcGeVector3d vectTmp(ptIns.x - ptBase.x, ptIns.y - ptBase.y, 0);
|
||
PickSet ssNew2(SS_FREE);
|
||
ssNew2.IncludeBegin();
|
||
DList<AcDbObjectId> lstNode;
|
||
|
||
//首先找到y坐标最大的管线
|
||
double nBigY(0);
|
||
for(int i=0;i<length;i++){
|
||
AcDbObjectId id = *pNewData->m_lstId[i];
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipe, pPipe);
|
||
if(pPipe){
|
||
XPoint ptMid = pPipe->MidPoint();
|
||
if(ptMid.y > nBigY || fabs(nBigY) < 0.001){
|
||
nBigY = ptMid.y;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
for(i=0;i<length;i++){
|
||
|
||
CString csSerial;
|
||
AcDbObjectId id = *pNewData->m_lstId[i];
|
||
Entity entSel;
|
||
ads_name entTmp;
|
||
acdbGetAdsName(entTmp, id);
|
||
entSel = entTmp;
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipe, pPipe);
|
||
if(!pPipe || pPipe->GetModelType() == TPipeSys::kSystem) //系统管线不理会
|
||
continue;
|
||
if(pPipe->IsVertical()){//楼层立管, 读立管编号
|
||
csSerial = ReadXdata(entSel, _T("PIPE-SERIAL"));
|
||
}
|
||
TPipeSys::SysType sysType = pPipe->GetSysType();
|
||
|
||
ptStart = pPipe->StartPoint();
|
||
ptEnd = pPipe->EndPoint();
|
||
if(ptStart == ptEnd)
|
||
continue;
|
||
|
||
TDbPipe *pNewPipe = ClonePipe(pPipe);
|
||
AcGeMatrix3d mat;
|
||
mat.setToTranslation(vectTmp);
|
||
pNewPipe->transformBy(mat);
|
||
|
||
ptStart = pNewPipe->StartPoint();
|
||
ptEnd = pNewPipe->EndPoint();
|
||
ptStart = Wcs2Ucs(ptStart);// sr 2010-1-28 modify 系统生成支持UCS
|
||
ptEnd = Wcs2Ucs(ptEnd); // sr 2010-1-28 modify 系统生成支持UCS
|
||
|
||
if(pPipe->IsVertical() && csSerial != _T("")){//楼层立管, 如果立管标高为3000,则按对话框定义的楼层高度
|
||
if(fabs(ptEnd.z - 3000) < 0.001)
|
||
ptEnd.z = nFloorHeight;
|
||
}
|
||
|
||
if(!pPipe->IsVertical())
|
||
{
|
||
if(IsOutDoorPipe(entSel))
|
||
{
|
||
ptStart.z = 0; //把室外横管z坐标置零 sr 2008-2-25
|
||
ptEnd.z = 0;
|
||
}
|
||
}
|
||
|
||
ptNewS.x = ptStart.x*dlg.m_dX + cos(nRadian)*ptStart.y*dlg.m_dY;
|
||
ptNewS.y = ptStart.z*dlg.m_dZ + sin(nRadian)*ptStart.y*dlg.m_dY;
|
||
ptNewE.x = ptEnd.x*dlg.m_dX + cos(nRadian)*ptEnd.y*dlg.m_dY;
|
||
ptNewE.y = ptEnd.z*dlg.m_dZ + sin(nRadian)*ptEnd.y*dlg.m_dY;
|
||
|
||
ptNewS = Ucs2Wcs(ptNewS);// sr 2010-1-28 modify 系统生成支持UCS
|
||
ptNewE = Ucs2Wcs(ptNewE);// sr 2010-1-28 modify 系统生成支持UCS
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||
//如果是立管,要进行楼层线绘制
|
||
if(pPipe->IsVertical() && csSerial != _T("") && dlg.m_bFloor && iFloorNum > 0){
|
||
XPoint ptFloorS, ptFloorE, ptFloorBase, ptFloorTmp;
|
||
ptFloorTmp = ptStart;
|
||
ptFloorTmp.z =0;
|
||
|
||
ptFloorBase.x = ptFloorTmp.x*dlg.m_dX + cos(nRadian)*ptFloorTmp.y*dlg.m_dY;
|
||
ptFloorBase.y = ptFloorTmp.z*dlg.m_dZ + sin(nRadian)*ptFloorTmp.y*dlg.m_dY;
|
||
ptFloorBase = Ucs2Wcs(ptFloorBase);// sr 2010-1-28 modify 系统生成支持UCS
|
||
|
||
double dFloorLen = 10;
|
||
CString csText;
|
||
|
||
if(dlg.m_bFloorName)
|
||
{
|
||
dFloorLen += 10;
|
||
int iCurFloor = iFloorIdx+iFirstFloor;
|
||
if((iFloorIdx <= abs(iFirstFloor) && iFirstFloor < 0) || iFirstFloor > 0)
|
||
iCurFloor -= 1;
|
||
if(iCurFloor < 0)
|
||
csText.Format(_T("%s%d%s"), csBasementName, abs(iCurFloor), csFloorName);
|
||
else
|
||
csText.Format(_T("%d%s"), iCurFloor, csFloorName);
|
||
}
|
||
|
||
double dEle(-999);
|
||
if(dlg.m_bFloorHeight){
|
||
dFloorLen += 10;
|
||
dEle = (nCountHeight/dlg.m_dZ + dlg.m_dFisrtEle)/1000;
|
||
}
|
||
ads_polar(ptFloorBase, PI+Ucs2Wcs(0.0), dFloorLen*DocGetPScale(), ptFloorS);
|
||
ads_polar(ptFloorBase, 0+Ucs2Wcs(0.0), 5*DocGetPScale(), ptFloorE);
|
||
//先判断一下是否标注过了(立管被支管打断后,会标注多次)
|
||
BOOL bFloorDimed = FALSE;
|
||
for(int mm=0;mm<lstFloorDimed.Length();mm++)
|
||
{
|
||
SFloorLine *pData = lstFloorDimed[mm];
|
||
if(pData->m_ptStart == ptFloorS && pData->m_ptEnd == ptFloorE && pData->m_csText == csText)
|
||
{
|
||
bFloorDimed = TRUE;
|
||
break;
|
||
}
|
||
}
|
||
if(!bFloorDimed)
|
||
{
|
||
SFloorLine *pData = new SFloorLine;
|
||
pData->m_csText = csText;
|
||
pData->m_ptStart = ptFloorS;
|
||
pData->m_ptEnd = ptFloorE;
|
||
lstFloorDimed.Append(pData);
|
||
if (dlg.m_bIsSingleSys)// zxl 2013.05.28 add 单层系统
|
||
{
|
||
if (dlg.m_bFloorName)
|
||
{
|
||
csText = dlg.m_csFloorName;
|
||
}
|
||
else
|
||
{
|
||
csText = _T("");
|
||
}
|
||
|
||
if (dlg.m_bFloorHeight)
|
||
{
|
||
dEle = dlg.m_dEle;;
|
||
}
|
||
}
|
||
|
||
DrawFloorLine(ptFloorS, ptFloorE, csPipeLayer, csText, dEle, csSerial);
|
||
}
|
||
|
||
if(!lstHasDimedPt.FindPoint(ptFloorTmp))
|
||
{//防止2根同层立管重复标注
|
||
lstHasDimedPt.NewAppend(ptFloorTmp);
|
||
if(m == 0)
|
||
{
|
||
XPoint ptTurn;
|
||
CString csDim = GetVPipeDimText(id);
|
||
if(csDim != _T(""))
|
||
{
|
||
ads_polar(ptFloorBase, PI/4+Ucs2Wcs(0.0), 10*DocGetPScale(), ptTurn);
|
||
//标注立管
|
||
CString csDimLay = GetDimLayBySys(sysType);
|
||
|
||
TDbSymbComposing *pDim = new TDbSymbComposing;
|
||
pDim->setLayer(InitLayer(csDimLay));
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0.0));
|
||
pDim->SetStartPoint(ptFloorBase);
|
||
pDim->SetTurnPoint(ptTurn);
|
||
pDim->SetText(csDim);
|
||
pDim->SetSideText(0);
|
||
pDim->SetTextStyleId(InitTwtTextStyle(g_csVPipeStyle));
|
||
pDim->SetTextLayerId(InitLayer(LAY_TEXT));
|
||
pDim->SetTextHeight(g_nVPipeHeight);
|
||
pDim->SetTextBaseLen(pDim->GetDefaultTextBaseLen()*1.2);
|
||
pDim->SetPageWidth(pDim->GetDefaultTextBaseLen());
|
||
|
||
pDim->AddToCSpace(Adesk::kTrue);
|
||
Entity entLast2;
|
||
entLast2.GetLast();
|
||
OPENOBJ_BEGIN(entLast2, AcDb::kForWrite, TDbEntity, pEnt)
|
||
if(pEnt){
|
||
pEnt->setLayer(csDimLay);
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
||
//根据平面管线中点的y坐标,决定遮挡先后系数
|
||
XPoint ptMid = pPipe->MidPoint();
|
||
double nLevel = (nBigY - ptMid.y)/100;
|
||
int iLevel = int(nLevel);
|
||
pNewPipe->SetHideLevel(iLevel);
|
||
pNewPipe->SetStartPoint(ptNewS);
|
||
pNewPipe->SetEndPoint(ptNewE);
|
||
pNewPipe->SetModelType(TPipeSys::kSystem);
|
||
if(pPipe->IsVertical()){
|
||
//通过立管得到横管的图层,然后得到横管的线形
|
||
|
||
TCHAR *szLayer = pPipe->layer();
|
||
CString csLayer;
|
||
csLayer = GetPipeLayerByVPipeLay(szLayer);
|
||
delete [] szLayer;
|
||
|
||
if(csLayer == _T(""))
|
||
csLayer = szLayer;
|
||
InitPipeLayer(csLayer);
|
||
pNewPipe->setLayer(csLayer);
|
||
pNewPipe->setLinetype(GetPipeWireLayLineType(csLayer));
|
||
pNewPipe->SetPipeGradient(0);
|
||
}
|
||
AddToCurrentSpace(pNewPipe, Adesk::kTrue);
|
||
Entity entLast;
|
||
entLast.GetLast();
|
||
XString xsTmp(_T("%.3f"), ptStart.z/1000 + (nCountHeight + dlg.m_dFisrtEle)/1000);
|
||
WriteXdata(entLast, _T("TG-ELEVATION"), (const TCHAR*)xsTmp);
|
||
if(csSerial != _T(""))
|
||
WriteXdata(entLast, _T("PIPE-SERIAL"), (const TCHAR*)csSerial);
|
||
|
||
//阀门阀件, 标注
|
||
DList<AcDbObjectId> lstAttachment;
|
||
pPipe->GetAttachments(lstAttachment);
|
||
int leng = lstAttachment.Length();
|
||
for(int m=0;m<leng;m++){
|
||
AcDbObjectId idTmp = *lstAttachment[m];
|
||
if(IsValve(idTmp))
|
||
PlanValve2Sys(idTmp, pPipe, nRadian, mat, AcGeScale3d(dlg.m_dX, dlg.m_dY, dlg.m_dZ));
|
||
else if(IsPipeLabel(idTmp))
|
||
PlanLabel2Sys(idTmp, pNewPipe);
|
||
}
|
||
|
||
//设备
|
||
AcDbObjectId nodeId1(NULL), nodeId2(NULL);
|
||
nodeId1 = pPipe->GetNode(0);
|
||
nodeId2 = pPipe->GetNode(1);
|
||
if(IsAppandEquip(lstNode, nodeId1))
|
||
{
|
||
UpdateSanitaryEqu(nodeId1); // cet 2013.4.27 add 当node1为给水点时,根据其是否镜像,需调整其角度
|
||
PlanEquip2Sys(nodeId1, pPipe, nRadian, mat, AcGeScale3d(dlg.m_dX, dlg.m_dY, dlg.m_dZ));
|
||
|
||
// zxl 2013.07.16 add 显示井编号
|
||
Entity entWell;
|
||
entWell.GetLast();
|
||
if (entWell.Is(_T("ATS_WELL")))
|
||
{
|
||
SetWellDimShow(entWell, nodeId1);
|
||
}
|
||
}
|
||
if(IsAppandEquip(lstNode, nodeId2))
|
||
{
|
||
UpdateSanitaryEqu(nodeId2); // cet 2013.4.27 add 当node1为给水点时,根据其是否镜像,需调整其角度
|
||
PlanEquip2Sys(nodeId2, pPipe, nRadian, mat, AcGeScale3d(dlg.m_dX, dlg.m_dY, dlg.m_dZ));
|
||
|
||
// zxl 2013.07.16 add 显示井编号
|
||
Entity entWell;
|
||
entWell.GetLast();
|
||
if (entWell.Is(_T("ATS_WELL")))
|
||
{
|
||
SetWellDimShow(entWell, nodeId2);
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||
//每层图元绘制完毕后自动向上偏移楼层高度
|
||
ssNew2.IncludeEnd();
|
||
|
||
|
||
XPoint ptNewIns;
|
||
ads_polar(ptIns, PI/2+Ucs2Wcs(0.0), nCountHeight, ptNewIns);// sr 2010-1-28 modify 系统生成支持UCS
|
||
AcGeVector3d vectTmp2(ptNewIns.x - ptIns.x, ptNewIns.y - ptIns.y, 0);
|
||
AcGeMatrix3d mat;
|
||
mat.setToTranslation(vectTmp2);
|
||
long len2 = ssNew2.Length();
|
||
for(long j=0;j<len2;j++){
|
||
Entity ent = ssNew2[j];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbEntity, pEnt);
|
||
if(pEnt){
|
||
pEnt->transformBy(mat);
|
||
// if(pEnt->isKindOf(TDbEntity::desc())){
|
||
// TDbEntity *pTg = TDbEntity::cast(pEnt);
|
||
// pTg->SetPScale(DocGetPScale());
|
||
// }
|
||
// else if(pEnt->isKindOf(TDbCurveEntity::desc())){
|
||
// TDbCurveEntity *pTg = TDbCurveEntity::cast(pEnt);
|
||
// pTg->SetPScale(DocGetPScale());
|
||
// }
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||
nCountHeight += nFloorHeight*dlg.m_dZ; //楼层标高增加一楼
|
||
}
|
||
|
||
}
|
||
TPipePerDocData *pData = GetCurPipeDocData();
|
||
pData->ApplyUpdates(); //2009-2-12 sr加,有些管线遮挡的长度计算错误,如果连井的管线
|
||
ssNew.IncludeEnd();
|
||
|
||
if(ssNew.Length() < 1)
|
||
return;
|
||
//2006-4-28日添加, 在立管上有阀门的时候, 生成系统阀门GetExtend出错,导致ptIns点错误
|
||
PickSet ssNew3(SS_FREE);
|
||
long len3 = ssNew.Length();
|
||
for(long j=0;j<len3;j++){
|
||
Entity ent = ssNew[j];
|
||
XPoint p1,p2;
|
||
ent.GetExtend(p1, p2);
|
||
if(!!p1 && !!p2)
|
||
ssNew3 += ent;
|
||
}
|
||
|
||
|
||
double x,y,z;
|
||
ssNew.Redraw(2);
|
||
ssNew3.GetExtend(ptIns, &x, &y, &z);
|
||
actrTransactionManager->flushGraphics(); //acad 刷新
|
||
ptIns = Wcs2Ucs(ptIns);
|
||
ptIns.z =0;
|
||
XPoint xp;
|
||
int nRet = DragMovePickSet(ssNew, _T("\n请点取系统图位置<退出>: "), ptIns, xp);
|
||
if(nRet != RTNORM){
|
||
ssNew.Erase();
|
||
return;
|
||
}
|
||
ssNew.Redraw(1);
|
||
|
||
}
|
||
|
||
|
||
|
||
//***************************************************************************************************
|
||
// 水箱系统
|
||
//***************************************************************************************************
|
||
|
||
void Plan2SysWaterTank()
|
||
{
|
||
RBList rbMask = ads_buildlist( -4, _T("<or"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_WATERTANK"), -4, _T("and>"),
|
||
-4, _T("or>"), NULL);
|
||
PickSet ss(SS_FREE), ssNew(SS_FREE);
|
||
if(SelectEntities(_T("\n选择自动生成系统图的所有平面图管线和水箱<退出>:"), ss, rbMask) != RTNORM)
|
||
return;
|
||
XPoint ptVerticalS, ptVerticalE;
|
||
ssNew.IncludeBegin();
|
||
XPoint ptPick, ptPick2, ptStart, ptEnd, ptNewS, ptNewE;
|
||
double nRadian = 45.0/180.0*PI;
|
||
long len = ss.Length();
|
||
DList<AcDbObjectId> lstNode;
|
||
for(long i=0;i<len;i++){
|
||
Entity entSel = ss[i];
|
||
if(entSel.Is(_T("ATS_WATERTANK"))){
|
||
PlanWaterTank2Sys(entSel, nRadian);
|
||
continue;
|
||
}
|
||
CString csSerial;
|
||
GetPipePoint(entSel, ptStart, ptEnd);
|
||
if(ptStart == ptEnd)
|
||
continue;
|
||
|
||
ptNewS.x = ptStart.x + cos(nRadian)*ptStart.y;
|
||
ptNewS.y = ptStart.z + sin(nRadian)*ptStart.y;
|
||
ptNewE.x = ptEnd.x + cos(nRadian)*ptEnd.y;
|
||
ptNewE.y = ptEnd.z + sin(nRadian)*ptEnd.y;
|
||
OPENOBJ_BEGIN(entSel, AcDb::kForRead, TDbPipe, pPipe);
|
||
if(!pPipe || pPipe->GetModelType() == TPipeSys::kSystem) //系统管线不理会
|
||
continue;
|
||
TDbPipe *pNewPipe = ClonePipe(pPipe);
|
||
if(pPipe->IsVertical()){
|
||
csSerial = ReadXdata(entSel, _T("PIPE-SERIAL"));
|
||
pNewPipe->SetHideLevel(100);
|
||
ptVerticalS = ptNewS;
|
||
ptVerticalE = ptNewE;
|
||
}
|
||
else{
|
||
pNewPipe->SetHideLevel(int(ptStart.z/1000*10)); //设置遮挡关系,把平面图标高转为米×10
|
||
}
|
||
pNewPipe->SetStartPoint(ptNewS);
|
||
pNewPipe->SetEndPoint(ptNewE);
|
||
pNewPipe->SetModelType(TPipeSys::kSystem);
|
||
AddToCurrentSpace(pNewPipe, Adesk::kTrue);
|
||
Entity entLast;
|
||
entLast.GetLast();
|
||
XString xsTmp(_T("%.3f"), ptStart.z/1000);
|
||
WriteXdata(entLast, _T("TG-ELEVATION"), (const TCHAR*)xsTmp);
|
||
if(csSerial != _T(""))
|
||
WriteXdata(entLast, _T("PIPE-SERIAL"), (const TCHAR*)csSerial);
|
||
//阀门阀件
|
||
DList<AcDbObjectId> lstAttachment;
|
||
pPipe->GetAttachments(lstAttachment);
|
||
int leng = lstAttachment.Length();
|
||
AcGeMatrix3d mat;
|
||
for(int m=0;m<leng;m++){
|
||
AcDbObjectId idTmp = *lstAttachment[m];
|
||
if(IsValve(idTmp))
|
||
PlanValve2Sys(idTmp, pPipe, nRadian, mat, AcGeScale3d(1, 1, 1));
|
||
else if(IsPipeLabel(idTmp))
|
||
PlanLabel2Sys(idTmp, pNewPipe);
|
||
}
|
||
|
||
//设备
|
||
AcDbObjectId nodeId1(NULL), nodeId2(NULL);
|
||
nodeId1 = pPipe->GetNode(0);
|
||
nodeId2 = pPipe->GetNode(1);
|
||
if(IsAppandEquip(lstNode, nodeId1)){
|
||
PlanEquip2Sys(nodeId1, pPipe, nRadian, mat, AcGeScale3d(1, 1, 1));
|
||
}
|
||
if(IsAppandEquip(lstNode, nodeId2)){
|
||
PlanEquip2Sys(nodeId2, pPipe, nRadian, mat, AcGeScale3d(1, 1, 1));
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
ssNew.IncludeEnd();
|
||
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);
|
||
|
||
double x,y,z;
|
||
XPoint ptIns;
|
||
ssNew.Redraw(2);
|
||
ssNew.GetExtend(ptIns, &x, &y, &z);
|
||
actrTransactionManager->flushGraphics(); //acad 刷新
|
||
ptIns = Wcs2Ucs(ptIns);
|
||
XPoint xp;
|
||
int nRet = DragMovePickSet(ssNew, _T("\n请点取系统图位置<退出>: "), ptIns, xp);
|
||
if(nRet != RTNORM){
|
||
ssNew.Erase();
|
||
return;
|
||
}
|
||
ssNew.Redraw(1);
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CPlan2SysDlg dialog
|
||
|
||
TGridFloor::TGridFloor()
|
||
{
|
||
AppendCol(_T("楼层"), 30);
|
||
AppendCol(_T("标准层数"), 50);
|
||
AppendCol(_T("层高"), 50);
|
||
AppendCol(_T("位置"));
|
||
SetColPosFix();
|
||
SetColFixLength();
|
||
SetNoPaste();
|
||
FitLastCol();
|
||
GetCol(3).SetRightButton();
|
||
m_iPipeType = 0;
|
||
|
||
COLORREF color = RGB(255,0,0);
|
||
GetCol(3).SetTextColor(color);
|
||
}
|
||
|
||
Entity GetVertPipeByPt(XPoint pt)
|
||
{
|
||
RBList rbMaskPipe(RTDXF0, _T("ATS_PIPE"), 8, GetLayerNames(_T("管")), NULL);
|
||
PickSet ss(SS_FREE);
|
||
XPoint ptUcs = Wcs2Ucs(pt);
|
||
GetPointPickSet(ptUcs, ss, rbMaskPipe, int(DocGetPScale()));
|
||
pt.z = 0;
|
||
for(long i=0;i<ss.Length();i++){
|
||
Entity entPipe = ss[i];
|
||
OPENOBJ_BEGIN(entPipe, AcDb::kForRead, TDbPipe, pPipe);
|
||
if(pPipe && pPipe->IsVertical()){
|
||
XPoint ptTmp = pPipe->StartPoint();
|
||
ptTmp.z = 0;
|
||
if(pt == ptTmp)
|
||
return entPipe;
|
||
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
return Entity();
|
||
}
|
||
|
||
extern CString GetVPipeLayerByIdx(int iLayer);
|
||
|
||
bool TGridFloor::OnCellButtonDown(WDGridCell &cell, CString &res)
|
||
{
|
||
if(cell.GetColIndex() == 3)
|
||
{
|
||
CPlan2SysDlg *pDlg=(CPlan2SysDlg*)GetParent();
|
||
int ret(0);
|
||
CString csLay;
|
||
PickSet ss(SS_FREE);
|
||
// if(m_iPipeType == 17){//多系统
|
||
if(m_iPipeType == 1000){ // 多系统 cet 2011.12.8 modify
|
||
csLay = pDlg->GetMutiSysLayer();
|
||
|
||
if(csLay == _T(""))//用户没有选择任何系统
|
||
return true;
|
||
RBList rbMask=ads_buildlist( -4, _T("<or"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, csLay, -4, _T("and>"),
|
||
-4, _T("or>"), NULL);
|
||
HideDialog(this->GetParent(), TRUE);
|
||
ret = SelectEntities(_T("\n选择自动生成系统图的所有平面图管线<退出>:"), ss, rbMask);
|
||
}
|
||
else{
|
||
CString csPipeLayer, csVPipeLayer;
|
||
pDlg->GetSingleSysLayer(csPipeLayer, csVPipeLayer);
|
||
RBList rbMask=ads_buildlist( -4, _T("<or"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, csPipeLayer, -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, csVPipeLayer, -4, _T("and>"),
|
||
-4, _T("or>"), NULL);
|
||
HideDialog(this->GetParent(), TRUE);
|
||
ret = SelectEntities(_T("\n选择自动生成系统图的所有平面图管线<退出>:"), ss, rbMask);
|
||
}
|
||
|
||
|
||
XPoint pt;
|
||
int nOsMode = OS_INT|OS_END|OS_CEN;
|
||
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
||
|
||
if(ret != RTNORM || ss.Length() < 1){
|
||
HideDialog(this->GetParent(), FALSE);
|
||
return true;
|
||
}
|
||
if(ads_getpoint(NULL, _T("\n请点取基点(建议是连接各楼层的立管)<退出>:"), pt) != RTNORM){
|
||
HideDialog(this->GetParent(), FALSE);
|
||
return true;
|
||
}
|
||
|
||
pt = Ucs2Wcs(pt);
|
||
|
||
long len = ss.Length();
|
||
TGridFloorData *pNewData = new TGridFloorData();
|
||
pt.z = 0;
|
||
pNewData->m_ptBase = pt;
|
||
for(long i=0;i<len;i++){
|
||
Entity entSel = ss[i];
|
||
AcDbObjectId id;
|
||
acdbGetObjectId(id, entSel);
|
||
pNewData->m_lstId.Append(new AcDbObjectId(id));
|
||
}
|
||
HideDialog(this->GetParent(), FALSE);
|
||
WDGridRow &row = cell.GetRow();
|
||
row[3].SetText(_T("已框选"));
|
||
|
||
row.SetExtendData(pNewData);
|
||
Refresh();
|
||
res=(const TCHAR*)cell;
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
|
||
extern BOOL GetLayerReMark(const TCHAR *szLayer, CString &sRemark); // cet 2011.12.8 add
|
||
extern void GetLayerPipeName(std::map<CString, CString> &mapLayerPipeName); // cet 2011.12.12 add
|
||
|
||
int CPlan2SysDlg::m_iPipeType = 0;
|
||
BOOL CPlan2SysDlg::m_bFloor = FALSE;
|
||
CString CPlan2SysDlg::m_csFloorName = _T("1层");
|
||
CString CPlan2SysDlg::m_csBaseEle = _T("±0");
|
||
|
||
CPlan2SysDlg::CPlan2SysDlg(CWnd* pParent /*=NULL*/)
|
||
: CDialog(CPlan2SysDlg::IDD, pParent)
|
||
{
|
||
//{{AFX_DATA_INIT(CPlan2SysDlg)
|
||
m_csAngle = _T("45");
|
||
m_bFloorHeight = FALSE;
|
||
m_bFloorName = FALSE;
|
||
m_bCivicismWater = FALSE;
|
||
m_bCyclleWater = FALSE;
|
||
m_dX = 1;
|
||
m_dY = 1;
|
||
m_dZ = 1;
|
||
m_bLQ = FALSE;
|
||
m_bQTMH = FALSE;
|
||
m_bSJ = FALSE;
|
||
m_bTQ = FALSE;
|
||
m_bYL2 = FALSE;
|
||
m_bZQ = FALSE;
|
||
//}}AFX_DATA_INIT
|
||
m_bHideDlg = TRUE;
|
||
m_csFloorPostfixName = _T("层"); //楼层名后缀,1F 1层 1楼
|
||
m_iFirstFloor = 1;
|
||
m_csBasementName = _T("");
|
||
m_dFisrtEle = 0;
|
||
m_dEle = 0;
|
||
m_bIsSingleSys = false;// zxl 2013.05.28 add
|
||
}
|
||
|
||
|
||
void CPlan2SysDlg::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CDialog::DoDataExchange(pDX);
|
||
//{{AFX_DATA_MAP(CPlan2SysDlg)
|
||
DDX_Control(pDX, IDC_COMBO_TYPE, m_comboType);
|
||
DDX_CBString(pDX, IDC_COMBO_ANGLE, m_csAngle);
|
||
DDX_Check(pDX, IDC_CHECK_FL, m_bFL);
|
||
DDX_Check(pDX, IDC_CHECK_HL, m_bHL);
|
||
DDX_Check(pDX, IDC_CHECK_JL, m_bJL);
|
||
DDX_Check(pDX, IDC_CHECK_RHL, m_bRHL);
|
||
DDX_Check(pDX, IDC_CHECK_RJL, m_bRJL);
|
||
DDX_Check(pDX, IDC_CHECK_WL, m_bWL);
|
||
DDX_Check(pDX, IDC_CHECK_XL, m_bXL);
|
||
DDX_Check(pDX, IDC_CHECK_YL, m_bYL);
|
||
DDX_Check(pDX, IDC_CHECK_ZL, m_bZL);
|
||
DDX_Check(pDX, IDC_CHECK_DRINK, m_bDrink);
|
||
DDX_Check(pDX, IDC_CHECK_OTHER, m_bOther);
|
||
DDX_Check(pDX, IDC_CHECK_PRESSDIRT, m_bPressDirt);
|
||
DDX_Check(pDX, IDC_CHECK_PRESSRAIN, m_bPressRain);
|
||
DDX_Check(pDX, IDC_CHECK_PRESSUSELESS, m_bPressUseless);
|
||
DDX_Check(pDX, IDC_CHECK_COAGULATE, m_bCoagulate);
|
||
DDX_Check(pDX, IDC_CHECK_FLOORHEIGHT, m_bFloorHeight);
|
||
DDX_Check(pDX, IDC_CHECK_FLOORNAME, m_bFloorName);
|
||
DDX_Check(pDX, IDC_CHK_CIVICISMWATER, m_bCivicismWater);
|
||
DDX_Check(pDX, IDC_CHK_CYCLEWATER, m_bCyclleWater);
|
||
DDX_Text(pDX, IDC_EDIT_X, m_dX);
|
||
DDX_Text(pDX, IDC_EDIT_Y, m_dY);
|
||
DDX_Text(pDX, IDC_EDIT_Z, m_dZ);
|
||
DDX_CBString(pDX, IDC_COMBO_FLOORNAME, m_csFloorName);
|
||
DDX_Check(pDX, IDC_CHECK_FLOOR, m_bFloor);
|
||
DDX_Text(pDX, IDC_EDIT_BASEELE, m_csBaseEle);
|
||
DDX_Check(pDX, IDC_CHECK_LQ, m_bLQ);
|
||
DDX_Check(pDX, IDC_CHECK_QTMH, m_bQTMH);
|
||
DDX_Check(pDX, IDC_CHECK_SJ, m_bSJ);
|
||
DDX_Check(pDX, IDC_CHECK_TQ, m_bTQ);
|
||
DDX_Check(pDX, IDC_CHECK_YL2, m_bYL2);
|
||
DDX_Check(pDX, IDC_CHECK_ZQ, m_bZQ);
|
||
//}}AFX_DATA_MAP
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CPlan2SysDlg, CDialog)
|
||
//{{AFX_MSG_MAP(CPlan2SysDlg)
|
||
ON_CBN_SELCHANGE(IDC_COMBO_TYPE, OnSelchangeComboType)
|
||
ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
|
||
ON_BN_CLICKED(IDC_BUTTON_DEL, OnButtonDel)
|
||
ON_BN_CLICKED(IDC_BUTTON_SINGLE, OnButtonSingle)
|
||
ON_BN_CLICKED(IDC_CHECK_FLOOR, OnCheckFloor)
|
||
//}}AFX_MSG_MAP
|
||
END_MESSAGE_MAP()
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CPlan2SysDlg message handlers
|
||
|
||
// 获取当前层标高 zxl 2013.05.27 add
|
||
double CPlan2SysDlg::GetCurEle()
|
||
{
|
||
double dEle = _tstof(m_csBaseEle);
|
||
double dFloor = 0;
|
||
if(m_bFloor)
|
||
{
|
||
// 1.0 得到后缀
|
||
int idx1 = -1;
|
||
if(m_csFloorName.Find(_T("F")) > -1)
|
||
{
|
||
idx1 = m_csFloorName.Find(_T("F"));
|
||
m_csFloorPostfixName = _T("F");
|
||
}
|
||
else if(m_csFloorName.Find(_T("楼")) > -1)
|
||
{
|
||
idx1 = m_csFloorName.Find(_T("楼"));
|
||
m_csFloorPostfixName = _T("楼");
|
||
}
|
||
else
|
||
{
|
||
idx1 = m_csFloorName.Find(_T("层"));
|
||
}
|
||
|
||
int idx2 = -1;
|
||
// 2.0 得到前缀
|
||
if(m_csFloorName.Find(_T("-")) > -1)
|
||
{
|
||
idx2 = m_csFloorName.Find(_T("-"));
|
||
m_csBasementName = _T("-");
|
||
}
|
||
else if(m_csFloorName.Find(_T("地下")) > -1)
|
||
{
|
||
idx2 = m_csFloorName.Find(_T("地下"));
|
||
m_csBasementName = _T("地下");
|
||
}
|
||
|
||
// 3.0 如果有地下,看看是从几层开始
|
||
if(idx2 > -1)
|
||
{
|
||
int iLen = (int)_tcslen(m_csBasementName);
|
||
CString csTmp = m_csFloorName.Mid(idx2+iLen, 1);
|
||
dFloor = -_ttoi(csTmp);
|
||
}
|
||
else if(idx1 > -1)
|
||
{
|
||
CString csTmp = m_csFloorName.Mid(idx1-1, 1);
|
||
dFloor = _ttoi(csTmp);
|
||
}
|
||
|
||
if (dFloor < 0)
|
||
{
|
||
double dBasementHeight(0);
|
||
double dEleOld = dEle;
|
||
m_grid.Refresh();
|
||
for(m_grid.MoveToFirst(); !m_grid.IsOut(); m_grid.MoveToNext())
|
||
{
|
||
WDGridRow *pRow = m_grid.CurRow();
|
||
double nFloorHeight(0);
|
||
CString csNum = (*pRow)[1].GetText().cs();
|
||
CString csHeight = (*pRow)[2].GetText().cs();
|
||
|
||
nFloorHeight = _tstof(csHeight) / 1000;
|
||
int iFloorNum = _ttoi(csNum);
|
||
for(int m=0;m<iFloorNum;m++)
|
||
{
|
||
dEle -= nFloorHeight;
|
||
dFloor++;
|
||
if (dFloor >= 0)
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
if (dFloor >= 0)
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (dFloor < 0)
|
||
{
|
||
return dEleOld;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return dEle;
|
||
}
|
||
}
|
||
return dEle;
|
||
}
|
||
|
||
BOOL CPlan2SysDlg::OnInitDialog()
|
||
{
|
||
CDialog::OnInitDialog();
|
||
/* cet 2011.12.8 modify
|
||
m_comboType.AddString(g_csPipeName[0]);
|
||
m_comboType.AddString(g_csPipeName[1]);
|
||
m_comboType.AddString(g_csPipeName[2]);
|
||
m_comboType.AddString(g_csPipeName[3]);
|
||
m_comboType.AddString(g_csPipeName[4]);
|
||
m_comboType.AddString(_T("其它"));
|
||
m_comboType.AddString(g_csPipeName[5]);
|
||
m_comboType.AddString(g_csPipeName[6]);
|
||
m_comboType.AddString(_T("多系统"));
|
||
*/
|
||
InitCmbPipeSysType();
|
||
|
||
m_grid.Clear();
|
||
m_grid.Create(this, IDC_LIST_LAYER);
|
||
m_grid.FitLastCol();
|
||
m_grid.m_iPipeType = m_iPipeType;
|
||
|
||
|
||
|
||
if(!ReadFloorInfo()){
|
||
m_grid.AppendRow();
|
||
m_grid.GetCell(0, 0).SetText(_T("1层"));
|
||
m_grid.GetCell(0, 1).SetText(_T("1"));
|
||
m_grid.GetCell(0, 2).SetText(_T("3000"));
|
||
m_grid.GetCell(0, 3).SetText(_T("未指定"));
|
||
}
|
||
CRect rect;
|
||
// if(m_iPipeType != 17){ // cet 2011.12.8 modify
|
||
if(m_iPipeType != 1000){
|
||
this->GetWindowRect(&rect);
|
||
//rect.bottom -= 110; // cet 2011.12.8 modify
|
||
rect.bottom -= 150;
|
||
this->MoveWindow(&rect);
|
||
m_bHideDlg = TRUE;
|
||
}
|
||
else
|
||
m_bHideDlg = FALSE;
|
||
|
||
m_grid.SetNoAppendButton(TRUE);
|
||
m_grid.SetNoDefaultMenu(true);
|
||
m_grid.Refresh();
|
||
|
||
InitCheckBoxName(); //cet 2009.12.29 add
|
||
|
||
UpdateData(FALSE);
|
||
OnCheckFloor();
|
||
return TRUE; // return TRUE unless you set the focus to a control
|
||
// EXCEPTION: OCX Property Pages should return FALSE
|
||
}
|
||
|
||
void CPlan2SysDlg::OnSelchangeComboType()
|
||
{
|
||
UpdateData(TRUE);
|
||
// m_grid.m_iPipeType = m_iPipeType; cet 2011.12.8 del
|
||
CString csSel;
|
||
//m_comboType.GetLBText(m_iPipeType, csSel);
|
||
m_comboType.GetWindowText(csSel);
|
||
std::map<CString,int>::iterator it;
|
||
it = m_mapPipeLayerSysType.find(csSel);
|
||
if (it == m_mapPipeLayerSysType.end())
|
||
{
|
||
return;
|
||
}
|
||
m_iPipeType = it->second;
|
||
m_grid.m_iPipeType = m_iPipeType;
|
||
|
||
CRect rect;
|
||
this->GetWindowRect(&rect);
|
||
if(csSel == _T("多系统")){
|
||
if(m_bHideDlg){
|
||
//rect.bottom += 110;
|
||
rect.bottom += 150; // cet 2011.12.8 modify
|
||
this->MoveWindow(&rect);
|
||
m_bHideDlg = FALSE;
|
||
}
|
||
}
|
||
else{
|
||
if(!m_bHideDlg){
|
||
//rect.bottom -= 110;
|
||
rect.bottom -= 150; // cet 2011.12.8 modify
|
||
this->MoveWindow(&rect);
|
||
m_bHideDlg = TRUE;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
void CPlan2SysDlg::OnButtonAdd()
|
||
{
|
||
m_grid.AppendRow();
|
||
int idx = m_grid.GetRowNum();
|
||
m_grid.GetCell(idx-1, 0).SetText(XString(_T("%d层"), idx));
|
||
m_grid.GetCell(idx-1, 1).SetText(_T("1"));
|
||
m_grid.GetCell(idx-1, 2).SetText(_T("3000"));
|
||
m_grid.GetCell(idx-1, 3).SetText(_T("未指定"));
|
||
}
|
||
|
||
void CPlan2SysDlg::OnButtonDel()
|
||
{
|
||
long idx = m_grid.GetCurRowIndex();
|
||
if(idx < 0){
|
||
MessageBox(_T("没有选中的行!请点击表格左侧的行标!"));
|
||
return;
|
||
}
|
||
m_grid.DelRow(idx);
|
||
}
|
||
|
||
void CPlan2SysDlg::OnOK()
|
||
{
|
||
UpdateData(TRUE);
|
||
m_bIsSingleSys = false;// zxl 2013.05.28 add
|
||
int num = m_grid.GetRowNum();
|
||
if(num == 1){
|
||
m_grid.MoveToFirst();
|
||
WDGridRow *pRow = m_grid.CurRow();
|
||
TGridFloorData *pNewData = (TGridFloorData *)pRow->GetExtendData();
|
||
if(pNewData == NULL){
|
||
MessageBox(_T("没有选择要生成的平面图!点击“位置”右侧按钮。\n"));
|
||
return;
|
||
}
|
||
}
|
||
SaveFloorInfo();
|
||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
if(m_bFloor){
|
||
// 1.0 得到后缀
|
||
int idx1 = -1;
|
||
if(m_csFloorName.Find(_T("F")) > -1)
|
||
{
|
||
idx1 = m_csFloorName.Find(_T("F"));
|
||
m_csFloorPostfixName = _T("F");
|
||
}
|
||
else if(m_csFloorName.Find(_T("楼")) > -1)
|
||
{
|
||
idx1 = m_csFloorName.Find(_T("楼"));
|
||
m_csFloorPostfixName = _T("楼");
|
||
}
|
||
else
|
||
{
|
||
idx1 = m_csFloorName.Find(_T("层"));
|
||
}
|
||
|
||
int idx2 = -1;
|
||
// 2.0 得到前缀
|
||
if(m_csFloorName.Find(_T("-")) > -1)
|
||
{
|
||
idx2 = m_csFloorName.Find(_T("-"));
|
||
m_csBasementName = _T("-");
|
||
}
|
||
else if(m_csFloorName.Find(_T("地下")) > -1)
|
||
{
|
||
idx2 = m_csFloorName.Find(_T("地下"));
|
||
m_csBasementName = _T("地下");
|
||
}
|
||
|
||
// 3.0 如果有地下,看看是从几层开始
|
||
if(idx2 > -1)
|
||
{
|
||
int iLen = (int)_tcslen(m_csBasementName);
|
||
CString csTmp = m_csFloorName.Mid(idx2+iLen, 1);
|
||
m_iFirstFloor = -_ttoi(csTmp);
|
||
}
|
||
else if(idx1 > -1)
|
||
{
|
||
CString csTmp = m_csFloorName.Mid(idx1-1, 1);
|
||
m_iFirstFloor = _ttoi(csTmp);
|
||
}
|
||
// 4.0 计算起始标高
|
||
m_dFisrtEle = _tstof(m_csBaseEle)*1000;
|
||
double dFirstTmp = m_dFisrtEle;
|
||
if(m_iFirstFloor < 1)
|
||
{
|
||
int iBasementNum(0);
|
||
double dBasementHeight(0);
|
||
for(m_grid.MoveToFirst(); !m_grid.IsOut(); m_grid.MoveToNext()){
|
||
WDGridRow *pRow = m_grid.CurRow();
|
||
double nFloorHeight(0);
|
||
CString csHeight = (*pRow)[2].GetText().cs();
|
||
nFloorHeight = _tstof(csHeight);
|
||
CString csNum = (*pRow)[1].GetText().cs();
|
||
int iFloorNum = _ttoi(csNum);
|
||
for(int m=0;m<iFloorNum;m++){
|
||
dBasementHeight+=nFloorHeight;
|
||
iBasementNum++;
|
||
if(iBasementNum == abs(m_iFirstFloor))
|
||
{
|
||
m_dFisrtEle = (dBasementHeight - m_dFisrtEle) * -1;
|
||
break;
|
||
}
|
||
}
|
||
if(fabs(m_dFisrtEle - dFirstTmp) > 0.001)
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
CDialog::OnOK();
|
||
}
|
||
|
||
BOOL CPlan2SysDlg::ReadFloorInfo()
|
||
{
|
||
XStringList lstHis;
|
||
TCHAR strTmpPath[100] = _T("");
|
||
GetTempPath(100, strTmpPath);
|
||
_tcscat(strTmpPath, _T("sysfloor.his"));
|
||
|
||
FILE *fp=fopen(_AS(strTmpPath), "r");
|
||
if(!fp)
|
||
return FALSE;
|
||
|
||
while(!feof(fp)) {
|
||
char sBuf[256]="";
|
||
fgets(sBuf, 255, fp);
|
||
CString csTmp = sBuf;
|
||
csTmp.TrimRight();
|
||
if(csTmp != _T(""))
|
||
lstHis.Append(tstrnew(csTmp));
|
||
}
|
||
fclose(fp);
|
||
|
||
|
||
int len = lstHis.Length();
|
||
if(len < 1)
|
||
return FALSE;
|
||
|
||
for(int i=0;i<len;i++){
|
||
CString csTmp = lstHis[i];
|
||
int idx = csTmp.Find(_T("-"));
|
||
CString csName = csTmp.Left(idx);
|
||
int idx2 = csTmp.Find(_T("-"), idx+1);
|
||
int iCharLen = (int)_tcslen(_T("-"));
|
||
CString csNum = csTmp.Mid(idx+iCharLen, idx2-idx-iCharLen);
|
||
CString csHeight = csTmp.Right(csTmp.GetLength() - idx2 - iCharLen);
|
||
|
||
m_grid.AppendRow();
|
||
m_grid.GetCell(i, 0).SetText(csName);
|
||
m_grid.GetCell(i, 1).SetText(csNum);
|
||
m_grid.GetCell(i, 2).SetText(csHeight);
|
||
m_grid.GetCell(i, 3).SetText(_T("未指定"));
|
||
|
||
}
|
||
return TRUE;
|
||
|
||
}
|
||
|
||
void CPlan2SysDlg::SaveFloorInfo()
|
||
{
|
||
TCHAR strTmpPath[256] = _T("");
|
||
GetTempPath(255, strTmpPath);
|
||
_tcscat(strTmpPath, _T("sysfloor.his"));
|
||
|
||
FILE *fp = fopen(_AS(strTmpPath), "w");
|
||
if(!fp)
|
||
return;
|
||
for(m_grid.MoveToFirst(); !m_grid.IsOut(); m_grid.MoveToNext()){
|
||
WDGridRow *pRow = m_grid.CurRow();
|
||
CString csName = (*pRow)[0].GetText().cs();
|
||
CString csNum = (*pRow)[1].GetText().cs();
|
||
CString csHeight = (*pRow)[2].GetText().cs();
|
||
|
||
CString csTmp = csName+_T("-")+csNum+_T("-")+csHeight+_T("\n");
|
||
fputs(_AS(csTmp), fp);
|
||
}
|
||
|
||
fclose(fp);
|
||
}
|
||
|
||
void CPlan2SysDlg::GetSingleSysLayer(CString &csPipeLayer, CString &csVPipeLayer)
|
||
{
|
||
UpdateData(TRUE);
|
||
csPipeLayer = GetPipeLayerByIdx(m_iPipeType);
|
||
csVPipeLayer = GetVPipeLayerByIdx(m_iPipeType);
|
||
if(csPipeLayer == LAY_PIPE_FEED)
|
||
csPipeLayer.Format(_T("%s,%s,%s"), LAY_PIPE_FEED, LAY_PIPE_FEED2, LAY_PIPE_FEED3);
|
||
if(csVPipeLayer == LAY_VPIPE_FEED)
|
||
csVPipeLayer.Format(_T("%s,%s,%s"), LAY_VPIPE_FEED, LAY_VPIPE_FEED2, LAY_VPIPE_FEED3);
|
||
|
||
if(csPipeLayer == LAY_PIPE_HEADFEED)
|
||
csPipeLayer.Format(_T("%s,%s,%s"), LAY_PIPE_HEADFEED, LAY_PIPE_HEADFEED2, LAY_PIPE_HEADFEED3);
|
||
if(csVPipeLayer == LAY_VPIPE_HEADFEED)
|
||
csVPipeLayer.Format(_T("%s,%s,%s"), LAY_VPIPE_HEADFEED, LAY_VPIPE_HEADFEED2, LAY_VPIPE_HEADFEED3);
|
||
|
||
if(csPipeLayer == LAY_PIPE_HEADBACK)
|
||
csPipeLayer.Format(_T("%s,%s,%s"), LAY_PIPE_HEADBACK, LAY_PIPE_HEADBACK2, LAY_PIPE_HEADBACK3);
|
||
if(csVPipeLayer == LAY_VPIPE_HEADBACK)
|
||
csVPipeLayer.Format(_T("%s,%s,%s"), LAY_VPIPE_HEADBACK, LAY_VPIPE_HEADBACK2, LAY_VPIPE_HEADBACK3);
|
||
|
||
if(csPipeLayer == LAY_PIPE_FIRE)
|
||
csPipeLayer.Format(_T("%s,%s,%s"), LAY_PIPE_FIRE, LAY_PIPE_FIRE2, LAY_PIPE_FIRE3);
|
||
if(csVPipeLayer == LAY_VPIPE_FIRE)
|
||
csVPipeLayer.Format(_T("%s,%s,%s"), LAY_VPIPE_FIRE, LAY_VPIPE_FIRE2, LAY_VPIPE_FIRE3);
|
||
|
||
if(csPipeLayer == LAY_PIPE_SPRINKLE)
|
||
csPipeLayer.Format(_T("%s,%s,%s"), LAY_PIPE_SPRINKLE, LAY_PIPE_SPRINKLE2, LAY_PIPE_SPRINKLE3);
|
||
if(csVPipeLayer == LAY_VPIPE_SPRINKLE)
|
||
csVPipeLayer.Format(_T("%s,%s,%s"), LAY_VPIPE_SPRINKLE, LAY_VPIPE_SPRINKLE2, LAY_VPIPE_SPRINKLE3);
|
||
|
||
if(csPipeLayer == LAY_PIPE_USED)
|
||
csPipeLayer.Format(_T("%s,%s,%s"), LAY_PIPE_USED, LAY_PIPE_USED2, LAY_PIPE_USED3);
|
||
if(csVPipeLayer == LAY_VPIPE_USED)
|
||
csVPipeLayer.Format(_T("%s,%s,%s"), LAY_VPIPE_USED, LAY_VPIPE_USED2, LAY_VPIPE_USED3);
|
||
|
||
// cet 2011.12.8 add user1-user8
|
||
if (csPipeLayer == LAY_PIPE_USER1)
|
||
csPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER1, LAY_VPIPE_USER1);
|
||
if (csPipeLayer == LAY_PIPE_USER2)
|
||
csPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER2, LAY_VPIPE_USER2);
|
||
if (csPipeLayer == LAY_PIPE_USER3)
|
||
csPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER3, LAY_VPIPE_USER3);
|
||
if (csPipeLayer == LAY_PIPE_USER4)
|
||
csPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER4, LAY_VPIPE_USER4);
|
||
if (csPipeLayer == LAY_PIPE_USER5)
|
||
csPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER5, LAY_VPIPE_USER5);
|
||
if (csPipeLayer == LAY_PIPE_USER6)
|
||
csPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER6, LAY_VPIPE_USER6);
|
||
if (csPipeLayer == LAY_PIPE_USER7)
|
||
csPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER7, LAY_VPIPE_USER7);
|
||
if (csPipeLayer == LAY_PIPE_USER8)
|
||
csPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER8, LAY_VPIPE_USER8);
|
||
|
||
if (csVPipeLayer == LAY_VPIPE_USER1)
|
||
csVPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER1, LAY_VPIPE_USER1);
|
||
if (csVPipeLayer == LAY_VPIPE_USER2)
|
||
csVPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER2, LAY_VPIPE_USER2);
|
||
if (csVPipeLayer == LAY_VPIPE_USER3)
|
||
csVPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER3, LAY_VPIPE_USER3);
|
||
if (csVPipeLayer == LAY_VPIPE_USER4)
|
||
csVPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER4, LAY_VPIPE_USER4);
|
||
if (csVPipeLayer == LAY_VPIPE_USER5)
|
||
csVPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER5, LAY_VPIPE_USER5);
|
||
if (csVPipeLayer == LAY_VPIPE_USER6)
|
||
csVPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER6, LAY_VPIPE_USER6);
|
||
if (csVPipeLayer == LAY_VPIPE_USER7)
|
||
csVPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER7, LAY_VPIPE_USER7);
|
||
if (csVPipeLayer == LAY_VPIPE_USER8)
|
||
csVPipeLayer.Format(_T("%s,%s"), LAY_PIPE_USER8, LAY_VPIPE_USER8);
|
||
}
|
||
|
||
CString CPlan2SysDlg::GetMutiSysLayer()
|
||
{
|
||
UpdateData(TRUE);
|
||
CString csLay;
|
||
if(m_bJL)
|
||
csLay.Format(_T("%s,%s,%s,%s,%s,%s"), LAY_PIPE_FEED, LAY_VPIPE_FEED, LAY_PIPE_FEED2, LAY_VPIPE_FEED2, LAY_PIPE_FEED3, LAY_VPIPE_FEED3);
|
||
if(m_bFL)
|
||
csLay = csLay + _T(",") + LAY_PIPE_USELESS + _T(",") + LAY_VPIPE_USELESS;
|
||
if(m_bRHL)
|
||
csLay.Format(_T("%s,%s,%s,%s,%s,%s,%s"), csLay, LAY_PIPE_HEADBACK, LAY_VPIPE_HEADBACK, LAY_PIPE_HEADBACK2, LAY_VPIPE_HEADBACK2, LAY_PIPE_HEADBACK3, LAY_VPIPE_HEADBACK3);
|
||
if(m_bRJL)
|
||
csLay.Format(_T("%s,%s,%s,%s,%s,%s,%s"), csLay, LAY_PIPE_HEADFEED, LAY_VPIPE_HEADFEED, LAY_PIPE_HEADFEED2, LAY_VPIPE_HEADFEED2, LAY_PIPE_HEADFEED3, LAY_VPIPE_HEADFEED3);
|
||
if(m_bWL)
|
||
csLay = csLay + _T(",") + LAY_PIPE_DIRT + _T(",") + LAY_VPIPE_DIRT;
|
||
if(m_bHL)
|
||
csLay.Format(_T("%s,%s,%s,%s,%s,%s,%s"), csLay, LAY_PIPE_SPRINKLE, LAY_VPIPE_SPRINKLE, LAY_PIPE_SPRINKLE2, LAY_VPIPE_SPRINKLE2, LAY_PIPE_SPRINKLE3, LAY_VPIPE_SPRINKLE3);
|
||
if(m_bXL)
|
||
csLay.Format(_T("%s,%s,%s,%s,%s,%s,%s"), csLay, LAY_PIPE_FIRE, LAY_VPIPE_FIRE, LAY_PIPE_FIRE2, LAY_VPIPE_FIRE2, LAY_PIPE_FIRE3, LAY_VPIPE_FIRE3);
|
||
if(m_bYL)
|
||
csLay = csLay + _T(",") + LAY_PIPE_RAIN + _T(",") + LAY_VPIPE_RAIN;
|
||
if(m_bZL)
|
||
csLay.Format(_T("%s,%s,%s,%s,%s,%s,%s"), csLay, LAY_PIPE_USED, LAY_VPIPE_USED, LAY_PIPE_USED2, LAY_VPIPE_USED2, LAY_PIPE_USED3, LAY_VPIPE_USED3);
|
||
if(m_bDrink)
|
||
csLay = csLay + _T(",") + LAY_PIPE_DRINK + _T(",") + LAY_VPIPE_DRINK;
|
||
if(m_bOther)
|
||
csLay = csLay + _T(",") + LAY_PIPE_OTHER + _T(",") + LAY_VPIPE_OTHER;
|
||
if(m_bCoagulate)
|
||
csLay = csLay + _T(",") + LAY_PIPE_COAGULATE + _T(",") + LAY_VPIPE_COAGULATE;
|
||
if(m_bPressDirt)
|
||
csLay = csLay + _T(",") + LAY_PIPE_PRESSDIRT + _T(",") + LAY_VPIPE_PRESSDIRT;
|
||
if(m_bPressRain)
|
||
csLay = csLay + _T(",") + LAY_PIPE_PRESSRAIN + _T(",") + LAY_VPIPE_PRESSRAIN;
|
||
if(m_bPressUseless)
|
||
csLay = csLay + _T(",") + LAY_PIPE_PRESSUSELESS + _T(",") + LAY_VPIPE_PRESSUSELESS;
|
||
// cet 2009.12.25 add
|
||
if(m_bCivicismWater)
|
||
{
|
||
csLay = csLay + _T(",") + LAY_PIPE_USER1 + _T(",") + LAY_VPIPE_USER1;
|
||
}
|
||
// cet 2009.12.25 add
|
||
if(m_bCyclleWater)
|
||
{
|
||
csLay = csLay + _T(",") + LAY_PIPE_USER2 + _T(",") + LAY_VPIPE_USER2;
|
||
}
|
||
// cet 2011.12.8 add user3-user8
|
||
if (m_bLQ)
|
||
csLay = csLay + _T(",") + LAY_PIPE_USER3 + _T(",") + LAY_VPIPE_USER3;
|
||
if (m_bQTMH)
|
||
csLay = csLay + _T(",") + LAY_PIPE_USER4 + _T(",") + LAY_VPIPE_USER4;
|
||
if (m_bZQ)
|
||
csLay = csLay + _T(",") + LAY_PIPE_USER5 + _T(",") + LAY_VPIPE_USER5;
|
||
if (m_bYL2)
|
||
csLay = csLay + _T(",") + LAY_PIPE_USER6 + _T(",") + LAY_VPIPE_USER6;
|
||
if (m_bTQ)
|
||
csLay = csLay + _T(",") + LAY_PIPE_USER7 + _T(",") + LAY_VPIPE_USER7;
|
||
if (m_bSJ)
|
||
csLay = csLay + _T(",") + LAY_PIPE_USER8 + _T(",") + LAY_VPIPE_USER8;
|
||
|
||
return csLay;
|
||
}
|
||
|
||
void CPlan2SysDlg::OnButtonSingle()
|
||
{
|
||
UpdateData(TRUE);
|
||
CDialog::OnOK();
|
||
PickSet ss(SS_FREE);
|
||
// if(m_iPipeType == 17){//多系统
|
||
if(m_iPipeType == 1000){ // 多系统 cet 2011.12.8 modify
|
||
CString csLay = GetMutiSysLayer();
|
||
if(csLay == _T(""))//用户没有选择任何系统
|
||
return;
|
||
RBList rbMask=ads_buildlist( -4, _T("<or"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, csLay, -4, _T("and>"),
|
||
-4, _T("or>"), NULL);
|
||
SelectEntities(_T("\n选择自动生成系统图的所有平面图管线<退出>:"), ss, rbMask);
|
||
}
|
||
else{
|
||
CString csPipeLayer, csVPipeLayer;
|
||
GetSingleSysLayer(csPipeLayer, csVPipeLayer);
|
||
RBList rbMask=ads_buildlist( -4, _T("<or"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, csPipeLayer, -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, csVPipeLayer, -4, _T("and>"),
|
||
-4, _T("or>"), NULL);
|
||
|
||
SelectEntities(_T("\n选择自动生成系统图的所有平面图管线<退出>:"), ss, rbMask);
|
||
}
|
||
|
||
XPoint pt;
|
||
int nOsMode = OS_INT|OS_END|OS_CEN;
|
||
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
||
long len = ss.Length();
|
||
TGridFloorData *pNewData = new TGridFloorData();
|
||
pt.z = 0;
|
||
pNewData->m_ptBase = pt;
|
||
for(long i=0;i<len;i++){
|
||
Entity entSel = ss[i];
|
||
AcDbObjectId id;
|
||
acdbGetObjectId(id, entSel);
|
||
pNewData->m_lstId.Append(new AcDbObjectId(id));
|
||
}
|
||
|
||
// 获取当前层标高 zxl 2013.05.27 add
|
||
if((m_bFloorHeight || m_bFloorName ) && len > 0)
|
||
{
|
||
m_dEle = GetCurEle();
|
||
m_bIsSingleSys = true;// zxl 2013.05.28 add
|
||
}
|
||
|
||
if(m_grid.GetRowNum() == 0)
|
||
{
|
||
m_grid.AppendRow();
|
||
m_grid.GetCell(0, 0).SetText(_T("1层"));
|
||
m_grid.GetCell(0, 1).SetText(_T("1"));
|
||
m_grid.GetCell(0, 2).SetText(_T("3000"));
|
||
m_grid.GetCell(0, 3).SetText(_T("未指定"));
|
||
}
|
||
|
||
m_grid.GetRow(0)[1].SetText(_T("1"));
|
||
m_grid.GetRow(0).SetExtendData(pNewData);
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
void CPlan2SysDlg::OnCheckFloor()
|
||
{
|
||
UpdateData(TRUE);
|
||
CWnd *pWnd = GetDlgItem(IDC_COMBO_FLOORNAME);
|
||
CWnd *pWnd2 = GetDlgItem(IDC_CHECK_FLOORNAME);
|
||
CWnd *pWnd3 = GetDlgItem(IDC_CHECK_FLOORHEIGHT);
|
||
CWnd *pWnd4 = GetDlgItem(IDC_EDIT_BASEELE);
|
||
|
||
if(m_bFloor)
|
||
{
|
||
pWnd->EnableWindow(TRUE);
|
||
pWnd2->EnableWindow(TRUE);
|
||
pWnd3->EnableWindow(TRUE);
|
||
pWnd4->EnableWindow(TRUE);
|
||
m_bFloorName = TRUE;
|
||
m_bFloorHeight = TRUE;
|
||
}
|
||
else
|
||
{
|
||
m_bFloorName = FALSE;
|
||
m_bFloorHeight = FALSE;
|
||
pWnd->EnableWindow(FALSE);
|
||
pWnd2->EnableWindow(FALSE);
|
||
pWnd3->EnableWindow(FALSE);
|
||
pWnd4->EnableWindow(FALSE);
|
||
}
|
||
UpdateData(FALSE);
|
||
}
|
||
|
||
//cet 2009.12.29 add
|
||
//初始化复选框
|
||
void CPlan2SysDlg::InitCheckBoxName()
|
||
{
|
||
/* cet 2011.12.12 modify
|
||
CWnd *pWnd = GetDlgItem(IDC_CHECK_COAGULATE);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(g_csPipeName[0]);
|
||
}
|
||
|
||
pWnd = GetDlgItem(IDC_CHECK_DRINK);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(g_csPipeName[1]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_PRESSDIRT);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(g_csPipeName[2]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_PRESSUSELESS);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(g_csPipeName[3]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_PRESSRAIN);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(g_csPipeName[4]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHK_CIVICISMWATER);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(g_csPipeName[5]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHK_CYCLEWATER);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(g_csPipeName[6]);
|
||
}
|
||
*/
|
||
|
||
std::map<CString,CString> mapLayerPipeName;
|
||
GetLayerPipeName(mapLayerPipeName);
|
||
CWnd *pWnd = GetDlgItem(IDC_CHECK_COAGULATE);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(mapLayerPipeName[LAY_PIPE_COAGULATE]);
|
||
}
|
||
|
||
pWnd = GetDlgItem(IDC_CHECK_DRINK);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(mapLayerPipeName[LAY_PIPE_DRINK]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_PRESSDIRT);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(mapLayerPipeName[LAY_PIPE_PRESSDIRT]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_PRESSUSELESS);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(mapLayerPipeName[LAY_PIPE_PRESSUSELESS]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_PRESSRAIN);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(mapLayerPipeName[LAY_PIPE_PRESSRAIN]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHK_CIVICISMWATER);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(mapLayerPipeName[LAY_PIPE_USER1]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHK_CYCLEWATER);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(mapLayerPipeName[LAY_PIPE_USER2]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_LQ);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(mapLayerPipeName[LAY_PIPE_USER3]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_QTMH);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(mapLayerPipeName[LAY_PIPE_USER4]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_ZQ);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(mapLayerPipeName[LAY_PIPE_USER5]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_YL2);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(mapLayerPipeName[LAY_PIPE_USER6]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_TQ);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(mapLayerPipeName[LAY_PIPE_USER7]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_SJ);
|
||
if (pWnd != NULL)
|
||
{
|
||
pWnd->SetWindowText(mapLayerPipeName[LAY_PIPE_USER8]);
|
||
}
|
||
}
|
||
|
||
void CPlan2SysDlg::InitCmbPipeSysType()
|
||
{
|
||
m_comboType.ResetContent();
|
||
int nIndex = -1;
|
||
m_comboType.InsertString(++nIndex, _T("给水"));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("给水")), 0));
|
||
m_comboType.InsertString(++nIndex, _T("热给水"));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("热给水")), 1));
|
||
m_comboType.InsertString(++nIndex, _T("热回水"));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("热回水")), 2));
|
||
m_comboType.InsertString(++nIndex, _T("污水"));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("污水")), 3));
|
||
m_comboType.InsertString(++nIndex, _T("废水"));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("废水")), 4));
|
||
m_comboType.InsertString(++nIndex, _T("雨水"));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("雨水")), 5));
|
||
m_comboType.InsertString(++nIndex, _T("中水"));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("中水")), 6));
|
||
m_comboType.InsertString(++nIndex, _T("消防"));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("消防")), 7));
|
||
m_comboType.InsertString(++nIndex, _T("喷淋"));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("喷淋")), 8));
|
||
|
||
CString sTemp;
|
||
if(GetLayerReMark(LAY_PIPE_COAGULATE, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
m_comboType.InsertString(++nIndex, sTemp);
|
||
m_mapPipeLayerSysType.insert(std::make_pair(sTemp, 9));
|
||
}
|
||
else
|
||
{
|
||
m_comboType.InsertString(++nIndex, CString(_T("凝结")));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("凝结")), 9));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_DRINK, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
m_comboType.InsertString(++nIndex, sTemp);
|
||
m_mapPipeLayerSysType.insert(std::make_pair(sTemp, 10));
|
||
}
|
||
else
|
||
{
|
||
m_comboType.InsertString(++nIndex, CString(_T("直饮")));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("直饮")), 10));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_PRESSDIRT, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
m_comboType.InsertString(++nIndex, sTemp);
|
||
m_mapPipeLayerSysType.insert(std::make_pair(sTemp, 11));
|
||
}
|
||
else
|
||
{
|
||
m_comboType.InsertString(++nIndex, CString(_T("压力污")));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("压力污")), 11));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_PRESSUSELESS, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
m_comboType.InsertString(++nIndex, sTemp);
|
||
m_mapPipeLayerSysType.insert(std::make_pair(sTemp, 12));
|
||
}
|
||
else
|
||
{
|
||
m_comboType.InsertString(++nIndex, CString(_T("压力废")));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("压力废")), 12));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_PRESSRAIN, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
m_comboType.InsertString(++nIndex, sTemp);
|
||
m_mapPipeLayerSysType.insert(std::make_pair(sTemp, 13));
|
||
}
|
||
else
|
||
{
|
||
m_comboType.InsertString(++nIndex, CString(_T("压力雨")));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("压力雨")), 13));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER1, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
m_comboType.InsertString(++nIndex, sTemp);
|
||
m_mapPipeLayerSysType.insert(std::make_pair(sTemp, 15));
|
||
}
|
||
else
|
||
{
|
||
m_comboType.InsertString(++nIndex, CString(_T("用户1管线")));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("用户1管线")), 15));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER2, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
m_comboType.InsertString(++nIndex, sTemp);
|
||
m_mapPipeLayerSysType.insert(std::make_pair(sTemp, 16));
|
||
}
|
||
else
|
||
{
|
||
m_comboType.InsertString(++nIndex, CString(_T("用户2管线")));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("用户2管线")), 16));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER3, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
m_comboType.InsertString(++nIndex, sTemp);
|
||
m_mapPipeLayerSysType.insert(std::make_pair(sTemp, 29));
|
||
}
|
||
else
|
||
{
|
||
m_comboType.InsertString(++nIndex, CString(_T("用户3管线")));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("用户3管线")), 29));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER4, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
m_comboType.InsertString(++nIndex, sTemp);
|
||
m_mapPipeLayerSysType.insert(std::make_pair(sTemp, 30));
|
||
}
|
||
else
|
||
{
|
||
m_comboType.InsertString(++nIndex, CString(_T("用户4管线")));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("用户4管线")), 30));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER5, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
m_comboType.InsertString(++nIndex, sTemp);
|
||
m_mapPipeLayerSysType.insert(std::make_pair(sTemp, 31));
|
||
}
|
||
else
|
||
{
|
||
m_comboType.InsertString(++nIndex, CString(_T("用户5管线")));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("用户5管线")), 31));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER6, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
m_comboType.InsertString(++nIndex, sTemp);
|
||
m_mapPipeLayerSysType.insert(std::make_pair(sTemp, 32));
|
||
}
|
||
else
|
||
{
|
||
m_comboType.InsertString(++nIndex, CString(_T("用户6管线")));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("用户6管线")), 32));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER7, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
m_comboType.InsertString(++nIndex, sTemp);
|
||
m_mapPipeLayerSysType.insert(std::make_pair(sTemp, 33));
|
||
}
|
||
else
|
||
{
|
||
m_comboType.InsertString(++nIndex, CString(_T("用户7管线")));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("用户7管线")), 33));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER8, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
m_comboType.InsertString(++nIndex, sTemp);
|
||
m_mapPipeLayerSysType.insert(std::make_pair(sTemp, 34));
|
||
}
|
||
else
|
||
{
|
||
m_comboType.InsertString(++nIndex, CString(_T("用户6管线")));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("用户8管线")), 34));
|
||
}
|
||
|
||
m_comboType.AddString(_T("其它"));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("其它")), 14));
|
||
m_comboType.AddString(_T("多系统"));
|
||
m_mapPipeLayerSysType.insert(std::make_pair(CString(_T("多系统")), 1000));
|
||
|
||
|
||
// 设置当前选择
|
||
sTemp.Empty();
|
||
std::map<CString,int>::iterator it;
|
||
for (it = m_mapPipeLayerSysType.begin(); it != m_mapPipeLayerSysType.end(); it++)
|
||
{
|
||
if (it->second == m_iPipeType)
|
||
{
|
||
sTemp = it->first;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (sTemp.IsEmpty())
|
||
{
|
||
m_comboType.SetCurSel(0);
|
||
}
|
||
else
|
||
{
|
||
nIndex = m_comboType.FindString(0,sTemp);
|
||
m_comboType.SetCurSel(nIndex);
|
||
}
|
||
}
|