646 lines
21 KiB
C++
646 lines
21 KiB
C++
// DrawPumpPipeDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include <dbPump.h>
|
|
#include <dbDoubleLinePipe.h>
|
|
#include <dbPipeValve.h>
|
|
|
|
#include "twt_pump.h"
|
|
#include "DrawPumpPipeDlg.h"
|
|
#include "DbDoubleLinePipeReducer.h"
|
|
#include "DoubleLinePipeReducerEditDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
|
|
|
|
//***************************************************************************************************
|
|
// 大小接头
|
|
//***************************************************************************************************
|
|
|
|
AcDbObjectId InsEquipmentByName(const TCHAR* szName, XPoint pt, double nAng, const TCHAR* szLayer, double dScale)
|
|
{
|
|
AcDbObjectId recordId = GetBlkIdByName(szName);
|
|
if(!recordId)
|
|
return recordId;
|
|
TDbEquipment *pEquip = new TDbEquipment;
|
|
pEquip->SetBlock2d(recordId);
|
|
pEquip->SetLocation(pt);
|
|
pEquip->SetScale(dScale);
|
|
pEquip->SetHidePipe(TRUE);
|
|
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 InsDoubleLineReducer()
|
|
{
|
|
// cet 2010.3.2 del
|
|
// g_ssPickFirst.Free();
|
|
// RBList rbMask(RTDXF0, _T("ATS_DOUBLELINEPIPE"), NULL);
|
|
//
|
|
//
|
|
// Entity ent;
|
|
// XPoint ptPick;
|
|
// if(SelectEntity(_T("\n请选择需要插入大小接头的管线<退出>"), ent, ptPick, rbMask) != RTNORM)
|
|
// return;
|
|
// CString csDwb = g_csDwbPath + _T("TwtSys");
|
|
// XString xsTmp, xsTmp2;
|
|
//
|
|
// if(LoadDwbBlock(csDwb, _T("00000493"), xsTmp) != RTNORM) //双线管 同心小头
|
|
// return;
|
|
// if(LoadDwbBlock(csDwb, _T("00000495"), xsTmp2) != RTNORM) //双线管 同心小头 法兰
|
|
// return;
|
|
//
|
|
//
|
|
// TCHAR szInput[256];
|
|
// ads_getstring(NULL, _T("\n请选择大小头样式[同心接小头(1)/同心接大头(2)/偏心接小头(3)/偏心接大头(4)]<同心接小头>:"), szInput);
|
|
// if(_tcsicmp(szInput, _T("2")) == 0)
|
|
// {
|
|
// if(LoadDwbBlock(csDwb, _T("00000497"), xsTmp) != RTNORM) //双线管 同心大头
|
|
// return;
|
|
// if(LoadDwbBlock(csDwb, _T("00000496"), xsTmp2) != RTNORM) //双线管 同心大头 法兰
|
|
// return;
|
|
// }
|
|
// else if(_tcsicmp(szInput, _T("3")) == 0)
|
|
// {
|
|
// if(LoadDwbBlock(csDwb, _T("00000500"), xsTmp) != RTNORM) //双线管 偏心小头
|
|
// return;
|
|
// if(LoadDwbBlock(csDwb, _T("00000501"), xsTmp2) != RTNORM) //双线管 偏心小头 法兰
|
|
// return;
|
|
// }
|
|
// else if(_tcsicmp(szInput, _T("4")) == 0)
|
|
// {
|
|
// if(LoadDwbBlock(csDwb, _T("00000498"), xsTmp) != RTNORM) //双线管 偏心大头
|
|
// return;
|
|
// if(LoadDwbBlock(csDwb, _T("00000499"), xsTmp2) != RTNORM) //双线管 偏心大头 法兰
|
|
// return;
|
|
// }
|
|
//
|
|
// Entity entLast;
|
|
// InitLayer(LAY_EQUIP_PIPE);
|
|
// double nRotate(0), dDn(0);
|
|
//
|
|
// TCHAR szLayer[256];
|
|
// ent.GetData(8, szLayer);
|
|
// OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbDoubleLinePipe, pPipe);
|
|
// if(pPipe && !pPipe->IsVertical()){
|
|
// int iType = pPipe->GetFlange();
|
|
// if(iType == 0)
|
|
// xsTmp = xsTmp2; //法兰连接
|
|
//
|
|
// dDn = pPipe->GetDnDiameter();
|
|
// double dDist1 = ads_distance(pPipe->startPoint, ptPick);
|
|
// double dDist2 = ads_distance(pPipe->endPoint, ptPick);
|
|
// AcDbObjectId nodeId(NULL);
|
|
// if(dDist1 < dDist2)
|
|
// {
|
|
// nRotate = ads_angle(pPipe->endPoint, pPipe->startPoint);
|
|
// nodeId = pPipe->GetNode(0);
|
|
// }
|
|
// else
|
|
// {
|
|
// nRotate = ads_angle(pPipe->startPoint, pPipe->endPoint);
|
|
// nodeId = pPipe->GetNode(1);
|
|
// }
|
|
//
|
|
// OPENOBJ_BEGIN(nodeId, AcDb::kForRead, TDbPipeNode, pNode1);
|
|
// if(pNode1){
|
|
// int num = pNode1->GetInterfaceNum();
|
|
// if(num == 1){
|
|
// InsEquipmentByName(xsTmp, pNode1->GetLocation(), nRotate, LAY_EQUIP_PIPE, dDn);
|
|
// entLast.GetLast();
|
|
// WriteXdata(entLast, _T("TG-LAYER"), szLayer);
|
|
//
|
|
// }
|
|
// }
|
|
// OPENOBJ_END();
|
|
// }
|
|
// OPENOBJ_END();
|
|
|
|
// cet 2010.3.2 add
|
|
RBList rbMask(RTDXF0, _T("ATS_DOUBLELINEPIPE"), NULL);
|
|
Entity ent;
|
|
XPoint ptPick;
|
|
if(SelectEntity(_T("\n请选择需要插入大小接头的管线<退出>"), ent, ptPick, rbMask) != RTNORM)
|
|
{
|
|
return;
|
|
}
|
|
ptPick = Ucs2Wcs(ptPick);
|
|
|
|
double dPipeDia = 0.0;
|
|
double dDist1 = 0.0;
|
|
double dDist2 = 0.0;
|
|
double dRotate = 0.0;
|
|
AcGePoint3d ptIns;
|
|
int nType = 0;
|
|
double dFlangeThick = 0.0;
|
|
double dFlangeDia = 0.0;
|
|
double dPresure = 0.0;
|
|
|
|
TDbDoubleLinePipe *pPipe = NULL;
|
|
AcDbObjectId idPipe = AcDbObjectId::kNull;
|
|
acdbGetObjectId(idPipe, ent);
|
|
acdbOpenObject(pPipe, idPipe, AcDb::kForRead);
|
|
if(pPipe && !pPipe->IsVertical())
|
|
{
|
|
dPipeDia = pPipe->GetWidth();
|
|
XPoint ptS, ptE;
|
|
pPipe->getStartPoint(ptS);
|
|
pPipe->getEndPoint(ptE);
|
|
dDist1 = ads_distance(ptS, ptPick);
|
|
dDist2 = ads_distance(ptE, ptPick);
|
|
if(dDist1 < dDist2)
|
|
{
|
|
dRotate = ads_angle(ptE, ptS);
|
|
ptIns = ptS;
|
|
}
|
|
else
|
|
{
|
|
dRotate = ads_angle(ptS, ptE);
|
|
ptIns = ptE;
|
|
}
|
|
nType = pPipe->GetFlange();
|
|
if(nType == 0) //法兰连接
|
|
{
|
|
dFlangeThick = pPipe->GetFlangeThick();
|
|
dFlangeDia = pPipe->GetFlangeDn();
|
|
}
|
|
CString csPn = ReadXdata(ent, _T("TG-PIPE-FLANGE-PN"));
|
|
if (csPn.IsEmpty())
|
|
{
|
|
csPn = _T("1.0MPa");
|
|
}
|
|
csPn.TrimRight(_T("MPa"));
|
|
dPresure = _tstof(csPn);
|
|
pPipe->Close();
|
|
}
|
|
|
|
CTemporaryResourceOverride vTemp;
|
|
CDoubleLinePipeReducerEditDlg dlg;
|
|
dlg.SetOldPipeDiameter(dPipeDia);
|
|
dlg.SetOldPipePressure(dPresure);
|
|
dlg.SetOldFlangeThick(dFlangeThick);
|
|
dlg.SetOldFlangeDiameter(dFlangeDia);
|
|
dlg.SetNewPipePressure(dPresure);
|
|
dlg.SetLinkType(nType == 0 ? CDoubleLinePipeReducerEditDlg::eFlangeLInk : CDoubleLinePipeReducerEditDlg::eJointing);
|
|
if (dlg.DoModal() == IDOK)
|
|
{
|
|
// cet 2012.11.7 moidfy 支持米单位
|
|
double dMeter = 1;
|
|
if (DocGetCurMeterUnitDraw())
|
|
{
|
|
dMeter = 0.001;
|
|
}
|
|
|
|
TDbDoubleLinePipeReducer *pDLPipeReducer = new TDbDoubleLinePipeReducer();
|
|
AcGeVector3d vt = AcGeVector3d::kXAxis;
|
|
vt.rotateBy(dRotate, AcGeVector3d::kZAxis);
|
|
if(nType == 0) //法兰连接
|
|
{
|
|
ptIns += vt * dFlangeThick * dMeter;
|
|
}
|
|
int nPipeType = dlg.GetPipeType(); //异径管样式
|
|
pDLPipeReducer->SetType(nPipeType);
|
|
pDLPipeReducer->SetStartPosition(ptIns);
|
|
pDLPipeReducer->SetLinkType(nType == 0 ? TDbDoubleLinePipeReducer::eFlangeLink : TDbDoubleLinePipeReducer::eJointing);
|
|
pDLPipeReducer->SetAngle(dRotate);
|
|
pDLPipeReducer->SetSPipeDiameter(dPipeDia);
|
|
pDLPipeReducer->SetSFlangeDiameter(dFlangeDia);
|
|
pDLPipeReducer->SetSFlangeThick(dFlangeThick);
|
|
pDLPipeReducer->SetSPipeFlangeDist(dlg.GetH1());
|
|
pDLPipeReducer->SetEFlangeDiameter(dlg.GetNewFlangeDiameter());
|
|
pDLPipeReducer->SetEFlangeThick(dlg.GetNewFlangeThick());
|
|
pDLPipeReducer->SetEPipeDiameter(dlg.GetNewPipeDiameter());
|
|
pDLPipeReducer->SetEPipeFlangeDist(dlg.GetH2());
|
|
|
|
AcGePoint3d ptLocation;
|
|
if (nType == 0)
|
|
{
|
|
ptLocation = ptIns + vt * (dlg.GetH1() + dlg.GetL() / 2) * dMeter;
|
|
}
|
|
else
|
|
{
|
|
ptLocation = ptIns + vt * dlg.GetL() / 2 * dMeter;
|
|
}
|
|
pDLPipeReducer->SetLocation(ptLocation);
|
|
pDLPipeReducer->SetLenght(dlg.GetL());
|
|
pDLPipeReducer->setLayer(InitLayer(_T("PIPE-双管")));
|
|
pDLPipeReducer->AddPipeReducerInterface();
|
|
|
|
AddToCurrentSpace(pDLPipeReducer, Adesk::kTrue);
|
|
}
|
|
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbDoubleLinePipe, pPipe);
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
//***************************************************************************************************
|
|
// 进出水管
|
|
//***************************************************************************************************
|
|
AcDbObjectId Get3dBlockByDesName(const TCHAR* szDesName)
|
|
{
|
|
if(!g_bBlk3D)
|
|
return NULL;
|
|
//平面阀门描述名一般为 名字+(三维记录)+“-”+系统记录
|
|
//如 通用阀门(00000623)-00000337
|
|
CString csDes = szDesName;
|
|
int idx = csDes.Find(_T("("));
|
|
int idx2 = csDes.Find(_T(")"));
|
|
if(idx < 0 || idx2 < 0)
|
|
return NULL;
|
|
CString csRecord = csDes.Mid(idx+1, 8);
|
|
XString xsTmp;
|
|
CString csDwb = g_csDwbPath + _T("VALVE");
|
|
if(LoadDwbBlock(csDwb, csRecord, xsTmp) != RTNORM)//跌水井
|
|
return NULL;
|
|
AcDbObjectId recordId3d = GetBlockIdFromString(xsTmp);
|
|
return recordId3d;
|
|
}
|
|
|
|
AcDbObjectId InsValveByName(const TCHAR* szName, XPoint pt)
|
|
{
|
|
CString csTk, csRecord, csDesName;
|
|
SplitBlkStr(szName, csTk, csRecord);
|
|
csTk = g_csDwbPath + csTk + _T(".tk");
|
|
csDesName = GetBlkDesName(csRecord, csTk);
|
|
AcDbObjectId recordId3d = Get3dBlockByDesName((const TCHAR*)csDesName);
|
|
|
|
InitLayer(LAY_EQUIP_VALVE);
|
|
AcDbObjectId recordId = GetBlockIdFromString(szName);
|
|
if(!recordId)
|
|
return recordId;
|
|
double nScale = g_nValveScale;
|
|
double nWidth = GetValveWidth(szName);
|
|
TDbPipeValve *pValve = new TDbPipeValve;
|
|
pValve->SetBlock2d(recordId);
|
|
pValve->SetBlock3d(recordId3d);
|
|
pValve->SetLocation(pt);
|
|
pValve->SetWidth(nWidth);
|
|
pValve->SetScale(nScale);
|
|
pValve->SetYScale(nScale);
|
|
|
|
pValve->SetFlangeDn(nWidth/2);
|
|
pValve->setLayer(LAY_EQUIP_VALVE);
|
|
pValve->setColor(AcCmColor()); //随层
|
|
pValve->SetSysType(TPipeSys::kFeedWater);
|
|
AcDbObjectId id = AddToCurrentSpace(pValve, Adesk::kTrue);
|
|
return id;
|
|
}
|
|
|
|
AcDbObjectId InsDoubleLineValve(const TCHAR* szName, XPoint pt, double nScale)
|
|
{
|
|
CString csTk, csRecord, csDesName;
|
|
SplitBlkStr(szName, csTk, csRecord);
|
|
csTk = g_csDwbPath + csTk + _T(".tk");
|
|
csDesName = GetBlkDesName(csRecord, csTk);
|
|
|
|
AcDbObjectId recordId3d = Get3dBlockByDesName((const TCHAR*)csDesName);
|
|
|
|
InitLayer(LAY_EQUIP_VALVE);
|
|
AcDbObjectId recordId = GetBlockIdFromString(szName);
|
|
if(!recordId)
|
|
return recordId;
|
|
double nWidth = GetValveWidth(szName);
|
|
TDbPipeValve *pValve = new TDbPipeValve;
|
|
|
|
pValve->SetHasFlange(FALSE);
|
|
pValve->SetFlangeWidth(0.25);
|
|
pValve->SetFlangeDn(nScale+50);
|
|
pValve->SetScale(nScale);
|
|
pValve->SetYScale(nScale);
|
|
pValve->SetBlock3d(recordId3d);
|
|
pValve->SetBlock2d(recordId);
|
|
pValve->SetLocation(pt);
|
|
pValve->SetWidth(nWidth);
|
|
// pValve->SetFlangeDn(nWidth/2);
|
|
pValve->setLayer(LAY_EQUIP_VALVE);
|
|
pValve->setColor(AcCmColor()); //随层
|
|
AcDbObjectId id = AddToCurrentSpace(pValve, Adesk::kTrue);
|
|
return id;
|
|
}
|
|
|
|
//cet 2009.12.11 add
|
|
//求水泵二维图块与直线的交点
|
|
BOOL GetIntersectionPt(double dAngle, const AcGePoint3d& ptIns, AcGePoint3d &ptResult, AcDbLine* line, double dLength, double dWidth)
|
|
{
|
|
BOOL bSuccess = FALSE;
|
|
|
|
AcDbPolyline polyLine;
|
|
|
|
AcGeVector3d vtDir = AcGeVector3d::kXAxis;
|
|
vtDir.rotateBy(dAngle, AcGeVector3d::kZAxis);
|
|
|
|
AcGePoint3d ptPosT = ptIns;
|
|
ptPosT.z = 0;
|
|
AcGeVector3d vtr = vtDir;
|
|
vtr = vtr.rotateBy(PI / 2, AcGeVector3d::kZAxis);
|
|
|
|
AcGePoint3d pt1 = ptPosT + vtDir * (dLength / 2.0) + vtr * (dWidth / 2.0);
|
|
AcGePoint3d pt2 = pt1 - vtDir * dLength;
|
|
AcGePoint3d pt3 = pt2 - vtr * dWidth;
|
|
AcGePoint3d pt4 = pt3 + vtDir * dLength;
|
|
|
|
polyLine.addVertexAt(0, pt1.convert2d(AcGePlane::kXYPlane));
|
|
polyLine.addVertexAt(1, pt2.convert2d(AcGePlane::kXYPlane));
|
|
polyLine.addVertexAt(2, pt3.convert2d(AcGePlane::kXYPlane));
|
|
polyLine.addVertexAt(3, pt4.convert2d(AcGePlane::kXYPlane));
|
|
polyLine.addVertexAt(4, pt1.convert2d(AcGePlane::kXYPlane));
|
|
|
|
AcGePoint3dArray arPts;
|
|
polyLine.intersectWith(line,AcDb::kOnBothOperands,arPts);
|
|
if (arPts.length() == 1)
|
|
{
|
|
ptResult = arPts[0];
|
|
bSuccess = TRUE;
|
|
}
|
|
|
|
return bSuccess;
|
|
}
|
|
|
|
void DrawPumpPipeCmd()
|
|
{
|
|
Entity entSel;
|
|
RBList rbMask(RTDXF0, _T("ATS_PUMP"), NULL);
|
|
if(SelectEntity(_T("\n请选择要连接的水泵<退出>:"), entSel, rbMask) != RTNORM)
|
|
return;
|
|
CTemporaryResourceOverride vTemp;
|
|
CDrawPumpPipeDlg dlg;
|
|
XPoint ptLoc, ptEnd;
|
|
AcGePoint3d ptIns; //cet 2009.12.11 add
|
|
double dLength = 0.0, dWidth = 0.0; //cet 2009.12.11 add
|
|
double dAngle = 0.0; //cet 2009.12.11 add
|
|
OPENOBJ_BEGIN(entSel, AcDb::kForRead, TDbPump, pEquip);
|
|
if(pEquip){
|
|
ptLoc = pEquip->GetLocation();
|
|
ptIns = pEquip->GetInsert(); //cet 2009.12.11 add
|
|
dLength = pEquip->GetPumpLength(); //cet 2009.12.11 add
|
|
dWidth = pEquip->GetPumpWidth(); //cet 2009.12.11 add
|
|
dAngle = pEquip->GetAngle(); //cet 2009.12.11 add
|
|
dlg.m_nPumpEle = ptLoc.z/1000;
|
|
dlg.m_csInEle.Format(_T("%.2f"), pEquip->GetInPipeEle()/1000);
|
|
dlg.m_csOutEle.Format(_T("%.2f"), pEquip->GetOutPipeEle()/1000);
|
|
}
|
|
OPENOBJ_END();
|
|
if(dlg.DoModal() != IDOK)
|
|
return;
|
|
XPushVar<int> vOrthoMode(_T("ORTHOMODE"), 1); //f8
|
|
ptLoc = Wcs2Ucs(ptLoc); // cet 2011.9.14 add
|
|
if(ads_getpoint(ptLoc, _T("\n请点取管线终点<退出>:"), ptEnd) != RTNORM)
|
|
return;
|
|
ptLoc = Ucs2Wcs(ptLoc); // cet 2011.9.14 add
|
|
ptEnd = Ucs2Wcs(ptEnd);
|
|
ptLoc.z = dlg.m_nEle*1000;
|
|
ptEnd.z = dlg.m_nEle*1000;
|
|
CString csDwb = g_csDwbPath + _T("valve");
|
|
XString xsTmp, xsTmp2, xsTmp3;
|
|
XPoint ptValve;
|
|
//double nRotate = ads_angle(ptLoc, ptEnd); cet 2011.10.13 modify
|
|
double nRotate = ads_angle(Wcs2Ucs(ptLoc), Wcs2Ucs(ptEnd));
|
|
|
|
/***********cet 2009.12.11 add*****/
|
|
XPoint ptLoc1 = ptLoc, ptEnd1 = ptEnd;
|
|
ptLoc1[Z] = 0;
|
|
ptEnd1[Z] = 0;
|
|
AcDbLine line(ptLoc1, ptEnd1);
|
|
AcGePoint3d ptInsection; //交点
|
|
GetIntersectionPt(dAngle, ptIns, ptInsection, &line, dLength, dWidth);
|
|
ptInsection.z = ptLoc.z;
|
|
ptLoc = ptInsection;
|
|
/***********cet 2009.12.11 add*****/
|
|
|
|
if(dlg.m_iPipeType == 0){
|
|
InitLayer(LAY_PIPE_FEED);
|
|
TDbPipe *pPipe = new TDbPipe;
|
|
pPipe->SetStartPoint(ptLoc);
|
|
pPipe->SetEndPoint(ptEnd);
|
|
pPipe->setLayer(LAY_PIPE_FEED);
|
|
pPipe->setLinetype(GetPipeWireLayLineType(LAY_PIPE_FEED));
|
|
pPipe->SetDnDiameter(_tstof(dlg.m_csDn));
|
|
pPipe->SetMaterial(4); // 焊接钢管
|
|
pPipe->SetPipeWeight(0.35);
|
|
pPipe->SetSysType(TPipeSys::kFeedWater);
|
|
pPipe->SetRadius(0.5);
|
|
pPipe->setColor(AcCmColor()); //随层
|
|
pPipe->SetModelType(TPipeSys::kModel);
|
|
AddToCurrentSpace(pPipe, Adesk::kTrue);
|
|
if(dlg.m_bNeed1){
|
|
if(LoadDwbBlock(csDwb, _T("00000447"), xsTmp) != RTNORM) //挠头
|
|
return;
|
|
//ads_polar(ptLoc, nRotate, DocGetPScale()*4, ptValve); cet 2011.10.13 modify
|
|
ads_polar(Wcs2Ucs(ptLoc), nRotate, DocGetPScale()*4, ptValve);
|
|
ptValve = Ucs2Wcs(ptValve);
|
|
InsValveByName((const TCHAR*)xsTmp, ptValve);
|
|
}
|
|
if(dlg.m_bNeed2 && dlg.m_iType == 1){
|
|
if(LoadDwbBlock(csDwb, _T("00000315"), xsTmp2) != RTNORM) //止回阀
|
|
return;
|
|
//ads_polar(ptLoc, nRotate, DocGetPScale()*7, ptValve); cet 2011.10.13 modify
|
|
ads_polar(Wcs2Ucs(ptLoc), nRotate, DocGetPScale()*7, ptValve);
|
|
ptValve = Ucs2Wcs(ptValve);
|
|
InsValveByName((const TCHAR*)xsTmp2, ptValve);
|
|
}
|
|
if(dlg.m_bNeed3){
|
|
if(LoadDwbBlock(csDwb, _T("00000296"), xsTmp3) != RTNORM) //闸阀
|
|
return;
|
|
if(dlg.m_bNeed2 && dlg.m_iType == 1)
|
|
//ads_polar(ptLoc, nRotate, DocGetPScale()*10, ptValve); cet 2011.10.13 modify
|
|
ads_polar(Wcs2Ucs(ptLoc), nRotate, DocGetPScale()*10, ptValve);
|
|
else
|
|
//ads_polar(ptLoc, nRotate, DocGetPScale()*7, ptValve); cet 2011.10.13 modify
|
|
ads_polar(Wcs2Ucs(ptLoc), nRotate, DocGetPScale()*7, ptValve);
|
|
ptValve = Ucs2Wcs(ptValve); // cet 2011.10.13 add
|
|
InsValveByName((const TCHAR*)xsTmp3, ptValve);
|
|
}
|
|
|
|
}
|
|
else{
|
|
InitLayer(LAY_PIPE_DOUBLE);
|
|
double nFlangeDn = _tstof(dlg.m_csDn) + 100;
|
|
double nFlangeThick = 16;
|
|
if(dlg.m_csDn == _T("65")){
|
|
nFlangeDn = 185;
|
|
nFlangeThick = 20;
|
|
}
|
|
else if(dlg.m_csDn == _T("80")){
|
|
nFlangeDn = 200;
|
|
nFlangeThick = 20;
|
|
}
|
|
else if(dlg.m_csDn == _T("100")){
|
|
nFlangeDn = 220;
|
|
nFlangeThick = 22;
|
|
}
|
|
else if(dlg.m_csDn == _T("125")){
|
|
nFlangeDn = 250;
|
|
nFlangeThick = 24;
|
|
}
|
|
else if(dlg.m_csDn == _T("150")){
|
|
nFlangeDn = 285;
|
|
nFlangeThick = 24;
|
|
}
|
|
else if(dlg.m_csDn == _T("200")){
|
|
nFlangeDn = 340;
|
|
nFlangeThick = 24;
|
|
}
|
|
else if(dlg.m_csDn == _T("250")){
|
|
nFlangeDn = 395;
|
|
nFlangeThick = 26;
|
|
}
|
|
else if(dlg.m_csDn == _T("300")){
|
|
nFlangeDn = 445;
|
|
nFlangeThick = 28;
|
|
}
|
|
else if(dlg.m_csDn == _T("350")){
|
|
nFlangeDn = 505;
|
|
nFlangeThick = 28;
|
|
}
|
|
else if(dlg.m_csDn == _T("400")){
|
|
nFlangeDn = 565;
|
|
nFlangeThick = 30;
|
|
}
|
|
|
|
TDbDoubleLinePipe *pPipe = new TDbDoubleLinePipe;
|
|
pPipe->setLayer(LAY_PIPE_DOUBLE);
|
|
pPipe->SetStartPoint(ptLoc);
|
|
pPipe->SetEndPoint(ptEnd);
|
|
pPipe->SetWidth(_tstof(dlg.m_csDn));
|
|
pPipe->SetPipeWeight(0.35);
|
|
pPipe->SetDnDiameter(_tstof(dlg.m_csDn));
|
|
pPipe->SetFlange(0);
|
|
pPipe->SetRate(g_nElbowRate);
|
|
pPipe->SetFlangeDn(nFlangeDn);
|
|
pPipe->SetFlangeThick(nFlangeThick);
|
|
pPipe->SetDoteLayer(InitLayer(LAY_TWT_DOTE));
|
|
AddToCurrentSpace(pPipe, Adesk::kTrue);
|
|
|
|
if(dlg.m_bNeed1){
|
|
if(LoadDwbBlock(csDwb, _T("00000654"), xsTmp) != RTNORM) //挠头
|
|
return;
|
|
//ads_polar(ptLoc, nRotate, DocGetPScale()*4, ptValve); cet 2011.10.13 modify
|
|
ads_polar(Wcs2Ucs(ptLoc), nRotate, DocGetPScale()*4, ptValve);
|
|
ptValve = Ucs2Wcs(ptValve);
|
|
InsDoubleLineValve((const TCHAR*)xsTmp, ptValve, _tstof(dlg.m_csDn));
|
|
}
|
|
if(dlg.m_bNeed2 && dlg.m_iType == 1){
|
|
if(LoadDwbBlock(csDwb, _T("00000640"), xsTmp2) != RTNORM) //止回阀
|
|
return;
|
|
//ads_polar(ptLoc, nRotate, DocGetPScale()*7, ptValve); cet 2011.10.13 modify
|
|
ads_polar(Wcs2Ucs(ptLoc), nRotate, DocGetPScale()*7, ptValve);
|
|
ptValve = Ucs2Wcs(ptValve);
|
|
InsDoubleLineValve((const TCHAR*)xsTmp2, ptValve, _tstof(dlg.m_csDn));
|
|
}
|
|
if(dlg.m_bNeed3){
|
|
if(LoadDwbBlock(csDwb, _T("00000641"), xsTmp3) != RTNORM) //闸阀
|
|
return;
|
|
if(dlg.m_bNeed2 && dlg.m_iType == 1)
|
|
//ads_polar(ptLoc, nRotate, DocGetPScale()*10, ptValve); cet 2011.10.13 modify
|
|
ads_polar(Wcs2Ucs(ptLoc), nRotate, DocGetPScale()*10, ptValve);
|
|
else
|
|
//ads_polar(ptLoc, nRotate, DocGetPScale()*7, ptValve); cet 2011.10.13 modify
|
|
ads_polar(Wcs2Ucs(ptLoc), nRotate, DocGetPScale()*7, ptValve);
|
|
ptValve = Ucs2Wcs(ptValve); // cet 2011.10.13 add
|
|
InsDoubleLineValve((const TCHAR*)xsTmp3, ptValve, _tstof(dlg.m_csDn));
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDrawPumpPipeDlg dialog
|
|
|
|
int CDrawPumpPipeDlg::m_iPipeType = 0; //cet 2010.1.6 add
|
|
|
|
CDrawPumpPipeDlg::CDrawPumpPipeDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CDrawPumpPipeDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CDrawPumpPipeDlg)
|
|
m_csDn = _T("100");
|
|
m_nPumpEle = 0.0;
|
|
m_csInEle = _T("");
|
|
m_csOutEle = _T("");
|
|
m_nEle = 0.0;
|
|
m_iType = 0;
|
|
// m_iPipeType = 0; //cet 2010.1.6 del
|
|
m_bNeed1 = TRUE;
|
|
m_bNeed2 = TRUE;
|
|
m_bNeed3 = TRUE;
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
|
|
void CDrawPumpPipeDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CDrawPumpPipeDlg)
|
|
DDX_CBString(pDX, IDC_COMBO_DN, m_csDn);
|
|
DDX_Text(pDX, IDC_EDIT_ELE, m_nPumpEle);
|
|
DDX_Text(pDX, IDC_EDIT_IN_ELE, m_csInEle);
|
|
DDX_Text(pDX, IDC_EDIT_OUT_ELE, m_csOutEle);
|
|
DDX_Text(pDX, IDC_EDIT_PIPE_ELE, m_nEle);
|
|
DDX_Radio(pDX, IDC_RADIO_TYPE1, m_iType);
|
|
DDX_Radio(pDX, IDC_RADIO_TYPE4, m_iPipeType);
|
|
DDX_Check(pDX, IDC_CHECK_VALVE1, m_bNeed1);
|
|
DDX_Check(pDX, IDC_CHECK_VALVE2, m_bNeed2);
|
|
DDX_Check(pDX, IDC_CHECK_VALVE3, m_bNeed3);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CDrawPumpPipeDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CDrawPumpPipeDlg)
|
|
ON_BN_CLICKED(IDC_RADIO_TYPE1, OnRadioType1)
|
|
ON_BN_CLICKED(IDC_RADIO_TYPE2, OnRadioType2)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDrawPumpPipeDlg message handlers
|
|
|
|
BOOL CDrawPumpPipeDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
ResetEle();
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
|
|
void CDrawPumpPipeDlg::OnRadioType1()
|
|
{
|
|
ResetEle();
|
|
}
|
|
|
|
void CDrawPumpPipeDlg::OnRadioType2()
|
|
{
|
|
ResetEle();
|
|
}
|
|
|
|
void CDrawPumpPipeDlg::ResetEle()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd = GetDlgItem(IDC_CHECK_VALVE2);
|
|
if(m_iType == 0){
|
|
m_nEle = m_nPumpEle + _tstof(m_csInEle);
|
|
pWnd->EnableWindow(FALSE);
|
|
}
|
|
else{
|
|
m_nEle = m_nPumpEle + _tstof(m_csOutEle);
|
|
pWnd->EnableWindow(TRUE);
|
|
}
|
|
UpdateData(FALSE);
|
|
}
|