2950 lines
84 KiB
C++
2950 lines
84 KiB
C++
//drawPipe.cpp
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include <dbPipeValve.h>
|
|
#include <DbEquipment.h>
|
|
#include <DbWell.h>
|
|
#include <PipeWireMonitor.h>
|
|
#include <TipWnd.h>
|
|
#include <TAPI.h>
|
|
//#include <DbWall.h>
|
|
#include <DbPipeCanal.h>
|
|
|
|
#include "DrawStandPipeDlg.h"
|
|
#include "jig.h"
|
|
#include "PipeVMultDrawDlg.h"
|
|
#include "TwtDef.h"
|
|
#include <stack>
|
|
|
|
extern TELAPI BOOL g_bTgOsnap;
|
|
|
|
Entity GetVertPipeByPt(XPoint &pt, double &nElevation, int &iPipeSys, double nRadius = 50)
|
|
{
|
|
|
|
RBList rbMaskPipe(RTDXF0, _T("ATS_PIPE"), 8, GetLayerNames(_T("管")), NULL);
|
|
PickSet ss(SS_FREE);
|
|
XPoint ptUcs = Wcs2Ucs(pt);
|
|
GetPointPickSet(ptUcs, ss, rbMaskPipe, (int)nRadius);
|
|
if(ss.Length() == 0)
|
|
return Entity();
|
|
//如果发现多个,逐一排查
|
|
if(ss.Length() > 1){
|
|
PickSet ssDel(SS_FREE);
|
|
long len = ss.Length();
|
|
for(long i=0;i<len;i++){
|
|
Entity entTmp = ss[i];
|
|
XPoint pt1 = pt;
|
|
pt1.z = 0;
|
|
OPENOBJ_BEGIN(entTmp, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
if(!pPipe->IsVertical())
|
|
ssDel += entTmp;
|
|
XPoint pt2 = pPipe->StartPoint();
|
|
pt2.z = 0;
|
|
if(pt1 != pt2)
|
|
ssDel += entTmp;
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
ss -= ssDel;
|
|
}
|
|
//zxl 2013.04.18 del 搜到多跟管线 就取第一根
|
|
// if(ss.Length() != 1)
|
|
// return Entity();
|
|
Entity entPipe = ss[0L];
|
|
OPENOBJ_BEGIN(entPipe, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
nElevation = pPipe->StartPoint().z;
|
|
CString csLay = pPipe->GetLayer();
|
|
iPipeSys = GetPipeLayerIdxByName(csLay);
|
|
|
|
// TPipeSys::SysType sys = pPipe->GetSysType();
|
|
// iPipeSys = GetPipeLayerIdxBySys(sys);
|
|
if(!pPipe->IsVertical())
|
|
return Entity();
|
|
pt = pPipe->GetStartPoint();
|
|
}
|
|
OPENOBJ_END();
|
|
// double x, y;
|
|
// if(!!entPipe)
|
|
// entPipe.GetExtend(pt, &x, &y);
|
|
return entPipe;
|
|
}
|
|
|
|
|
|
//已知管线图层名称,返回管线对话框INDEX
|
|
int GetPipeDlgIdxByName(const TCHAR* szLayer, int &iPos)
|
|
{
|
|
CString csLayer;
|
|
csLayer = (const TCHAR*)szLayer;
|
|
|
|
int ret = 0;
|
|
iPos = 0;
|
|
if(csLayer == LAY_PIPE_FEED || csLayer == LAY_VPIPE_FEED || csLayer == LAY_PIPE_FEED2 || csLayer == LAY_VPIPE_FEED2 || csLayer == LAY_PIPE_FEED3 || csLayer == LAY_VPIPE_FEED3)
|
|
{
|
|
if(csLayer == LAY_PIPE_FEED || csLayer == LAY_VPIPE_FEED)
|
|
iPos = 0;
|
|
else if(csLayer == LAY_PIPE_FEED2 || csLayer == LAY_VPIPE_FEED2)
|
|
iPos = 1;
|
|
else if(csLayer == LAY_PIPE_FEED3 || csLayer == LAY_VPIPE_FEED3)
|
|
iPos = 2;
|
|
ret = 0;
|
|
}
|
|
else if(csLayer == LAY_PIPE_HEADFEED || csLayer == LAY_VPIPE_HEADFEED || csLayer == LAY_PIPE_HEADFEED2 || csLayer == LAY_VPIPE_HEADFEED2 ||csLayer == LAY_PIPE_HEADFEED3 || csLayer == LAY_VPIPE_HEADFEED3)
|
|
{
|
|
if(csLayer == LAY_PIPE_HEADFEED || csLayer == LAY_VPIPE_HEADFEED)
|
|
iPos = 0;
|
|
else if(csLayer == LAY_PIPE_HEADFEED2 || csLayer == LAY_VPIPE_HEADFEED2)
|
|
iPos = 1;
|
|
else if(csLayer == LAY_PIPE_HEADFEED3 || csLayer == LAY_VPIPE_HEADFEED3)
|
|
iPos = 2;
|
|
ret = 1;
|
|
}
|
|
else if(csLayer == LAY_PIPE_HEADBACK || csLayer == LAY_VPIPE_HEADBACK ||csLayer == LAY_PIPE_HEADBACK2 || csLayer == LAY_VPIPE_HEADBACK2 ||csLayer == LAY_PIPE_HEADBACK3 || csLayer == LAY_VPIPE_HEADBACK3)
|
|
{
|
|
if(csLayer == LAY_PIPE_HEADBACK || csLayer == LAY_VPIPE_HEADBACK)
|
|
iPos = 0;
|
|
else if(csLayer == LAY_PIPE_HEADBACK2 || csLayer == LAY_VPIPE_HEADBACK2)
|
|
iPos = 1;
|
|
else if(csLayer == LAY_PIPE_HEADBACK3 || csLayer == LAY_VPIPE_HEADBACK3)
|
|
iPos = 2;
|
|
ret = 2;
|
|
}
|
|
else if(csLayer == LAY_PIPE_DIRT || csLayer == LAY_VPIPE_DIRT)
|
|
ret = 3;
|
|
else if(csLayer == LAY_PIPE_USELESS || csLayer == LAY_VPIPE_USELESS)
|
|
ret = 4;
|
|
else if(csLayer == LAY_PIPE_RAIN || csLayer == LAY_VPIPE_RAIN)
|
|
ret = 5;
|
|
else if(csLayer == LAY_PIPE_USED || csLayer == LAY_VPIPE_USED || csLayer == LAY_PIPE_USED2 || csLayer == LAY_VPIPE_USED2 ||csLayer == LAY_PIPE_USED3 || csLayer == LAY_VPIPE_USED3)
|
|
{
|
|
if(csLayer == LAY_PIPE_USED || csLayer == LAY_VPIPE_USED)
|
|
iPos = 0;
|
|
else if(csLayer == LAY_PIPE_USED2 || csLayer == LAY_VPIPE_USED2)
|
|
iPos = 1;
|
|
else if(csLayer == LAY_PIPE_USED3 || csLayer == LAY_VPIPE_USED3)
|
|
iPos = 2;
|
|
ret = 6;
|
|
}
|
|
else if(csLayer == LAY_PIPE_FIRE || csLayer == LAY_VPIPE_FIRE || csLayer == LAY_PIPE_FIRE2 || csLayer == LAY_VPIPE_FIRE2 ||csLayer == LAY_PIPE_FIRE3 || csLayer == LAY_VPIPE_FIRE3)
|
|
{
|
|
if(csLayer == LAY_PIPE_FIRE || csLayer == LAY_VPIPE_FIRE)
|
|
iPos = 0;
|
|
else if(csLayer == LAY_PIPE_FIRE2 || csLayer == LAY_VPIPE_FIRE2)
|
|
iPos = 1;
|
|
else if(csLayer == LAY_PIPE_FIRE3 || csLayer == LAY_VPIPE_FIRE3)
|
|
iPos = 2;
|
|
ret = 7;
|
|
}
|
|
else if(csLayer == LAY_PIPE_SPRINKLE || csLayer == LAY_VPIPE_SPRINKLE || csLayer == LAY_PIPE_SPRINKLE2 || csLayer == LAY_VPIPE_SPRINKLE2 ||csLayer == LAY_PIPE_SPRINKLE3 || csLayer == LAY_VPIPE_SPRINKLE3)
|
|
{
|
|
if(csLayer == LAY_PIPE_SPRINKLE || csLayer == LAY_VPIPE_SPRINKLE)
|
|
iPos = 0;
|
|
else if(csLayer == LAY_PIPE_SPRINKLE2 || csLayer == LAY_VPIPE_SPRINKLE2)
|
|
iPos = 1;
|
|
else if(csLayer == LAY_PIPE_SPRINKLE3 || csLayer == LAY_VPIPE_SPRINKLE3)
|
|
iPos = 2;
|
|
ret = 8;
|
|
}
|
|
else if(csLayer == LAY_PIPE_COAGULATE || csLayer == LAY_VPIPE_COAGULATE)
|
|
ret = 9;
|
|
else if(csLayer == LAY_PIPE_DRINK || csLayer == LAY_VPIPE_DRINK)
|
|
ret = 10;
|
|
else if(csLayer == LAY_PIPE_PRESSDIRT || csLayer == LAY_VPIPE_PRESSDIRT)
|
|
ret = 11;
|
|
else if(csLayer == LAY_PIPE_PRESSUSELESS || csLayer == LAY_VPIPE_PRESSUSELESS)
|
|
ret = 12;
|
|
else if(csLayer == LAY_PIPE_PRESSRAIN || csLayer == LAY_VPIPE_PRESSRAIN)
|
|
ret = 13;
|
|
else if(csLayer == LAY_PIPE_OTHER || csLayer == LAY_VPIPE_OTHER)
|
|
ret = 14;
|
|
else if(csLayer == LAY_PIPE_USER1 || csLayer == LAY_VPIPE_USER1)
|
|
ret = 15;
|
|
else if(csLayer == LAY_PIPE_USER2 || csLayer == LAY_VPIPE_USER2)
|
|
ret = 16;
|
|
else if (csLayer == LAY_VPIPE_USER3 || csLayer == LAY_PIPE_USER3) // cet 2011.12.1 add 29 - 34
|
|
{
|
|
ret = 29;
|
|
}
|
|
else if (csLayer == LAY_VPIPE_USER4 || csLayer == LAY_PIPE_USER4)
|
|
{
|
|
ret = 30;
|
|
}
|
|
else if (csLayer == LAY_VPIPE_USER5 || csLayer == LAY_PIPE_USER5)
|
|
{
|
|
ret = 31;
|
|
}
|
|
else if (csLayer == LAY_VPIPE_USER6 || csLayer == LAY_PIPE_USER6)
|
|
{
|
|
ret = 32;
|
|
}
|
|
else if (csLayer == LAY_VPIPE_USER7 || csLayer == LAY_PIPE_USER7)
|
|
{
|
|
ret = 33;
|
|
}
|
|
else if (csLayer == LAY_VPIPE_USER8 || csLayer == LAY_PIPE_USER8)
|
|
{
|
|
ret = 34;
|
|
}
|
|
else
|
|
ret = 14;
|
|
return ret;
|
|
}
|
|
|
|
Entity GetVertPipeByPt2(XPoint &pt, int &iPipeSys, int &iPos)
|
|
{
|
|
RBList rbMaskPipe(RTDXF0, _T("ATS_PIPE"), 8, GetLayerNames(_T("管")), NULL);
|
|
PickSet ss(SS_FREE);
|
|
XPoint ptUcs = Wcs2Ucs(pt);
|
|
GetPointPickSet(ptUcs, ss, rbMaskPipe, 50);
|
|
if(ss.Length() == 0){
|
|
GetPointPickSet(ptUcs, ss, rbMaskPipe, 100);
|
|
if(ss.Length() == 0){
|
|
GetPointPickSet(ptUcs, ss, rbMaskPipe, 200);
|
|
if(ss.Length() == 0)
|
|
return Entity();
|
|
}
|
|
}
|
|
if(ss.Length() > 0){
|
|
PickSet ssDel(SS_FREE);
|
|
long len = ss.Length();
|
|
for(long i=0;i<len;i++){
|
|
Entity entTmp = ss[i];
|
|
XPoint pt1 = pt;
|
|
pt1.z = 0;
|
|
OPENOBJ_BEGIN(entTmp, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
if(!pPipe->IsVertical())
|
|
ssDel += entTmp;
|
|
else{
|
|
XPoint pt2 = pPipe->StartPoint();
|
|
pt2.z = 0;
|
|
if(pt1 != pt2)
|
|
ssDel += entTmp;
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
ss -= ssDel;
|
|
}
|
|
long len2 = ss.Length();
|
|
if(ss.Length() == 0)
|
|
return Entity();
|
|
|
|
|
|
Entity entPipe = ss[0L];
|
|
OPENOBJ_BEGIN(entPipe, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
// TPipeSys::SysType sys = pPipe->GetSysType();
|
|
// iPipeSys = GetPipeLayerIdxBySys(sys);
|
|
CString csLay = pPipe->GetLayer();
|
|
iPipeSys = GetPipeDlgIdxByName(csLay, iPos);
|
|
|
|
pt = pPipe->StartPoint();
|
|
}
|
|
OPENOBJ_END();
|
|
// double x, y;
|
|
// XPoint ptRet;
|
|
// if(!!entPipe)
|
|
// entPipe.GetExtend(pt, &x, &y);
|
|
return entPipe;
|
|
}
|
|
|
|
//得到管线2个端点以及中点
|
|
Entity GetPipeByPt2(XPoint pt, double &nElevation, int &iPipeSys, int &iPos)
|
|
{
|
|
RBList rbMaskPipe(RTDXF0, _T("ATS_PIPE"), 8, GetLayerNames(_T("管线")), NULL);
|
|
PickSet ss(SS_FREE);
|
|
XPoint ptUcs = Wcs2Ucs(pt);
|
|
GetPointPickSet(ptUcs, ss, rbMaskPipe, (int)(DocGetPScale()/2));
|
|
double len = ss.Length();
|
|
if(len == 0)
|
|
return Entity();
|
|
else if(len > 1){
|
|
GetPointPickSet(ptUcs, ss, rbMaskPipe, (int)(DocGetPScale()/4));
|
|
}
|
|
if(ss.Length() != 1)
|
|
return Entity();
|
|
Entity entPipe = ss[0L];
|
|
OPENOBJ_BEGIN(entPipe, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe && !pPipe->IsVertical()){
|
|
nElevation = pPipe->StartPoint().z;
|
|
TPipeSys::SysType sys = pPipe->GetSysType();
|
|
CString csLay = pPipe->GetLayer();
|
|
iPipeSys = GetPipeDlgIdxByName(csLay, iPos);
|
|
}
|
|
else
|
|
return Entity();
|
|
OPENOBJ_END();
|
|
|
|
return ss[0L];
|
|
}
|
|
|
|
|
|
// COMMAND: 例:
|
|
// (setq pt1 (GetPoint))
|
|
// (setq pt2 (GetPoint))
|
|
// (TPIPE pt1 pt2)
|
|
int LispPipe()
|
|
{
|
|
resbuf *rb=ads_getargs();
|
|
RBList rbArgs=rb;
|
|
if(rb && rb->restype==RT3DPOINT) {
|
|
XPoint ptStart, ptEnd;
|
|
ptStart = rb->resval.rpoint;
|
|
|
|
|
|
if(rb->rbnext && rb->rbnext->restype==RT3DPOINT) {
|
|
resbuf *rbItem=rb->rbnext;
|
|
ptEnd = rbItem->resval.rpoint;
|
|
}
|
|
ads_relrb(rb);
|
|
if(!!ptStart || !!ptEnd){
|
|
InitPipeLayer(LAY_PIPE_FEED);
|
|
DrawPlanPipeByLayer(ptStart, ptEnd, LAY_PIPE_FEED);
|
|
return RTNORM;
|
|
}
|
|
}
|
|
ads_retnil();
|
|
return RTNORM;
|
|
}
|
|
|
|
|
|
|
|
|
|
int GetPipeIdxByEnt(Entity ent)
|
|
{
|
|
TCHAR szLay[256];
|
|
ent.GetData(8, szLay);
|
|
CString csLayer = szLay;
|
|
int idx(-1);
|
|
for(int i=0;i<35;i++){ // cet 2011.12.7 modify 比较次数由11改为35
|
|
if(_tcsicmp(csLayer, GetPipeLayerByIdx(i)) == 0){
|
|
idx = i;
|
|
break;
|
|
}
|
|
}
|
|
return idx;
|
|
}
|
|
|
|
//已知2点和dBulge, 根据对话框的数据,绘制这个线段的pipe
|
|
void DoDrawPipe(XPoint ptPick1, XPoint ptPick2, double dBulge, CDrawStandPipeDlg &dlg)
|
|
{
|
|
dlg.UpdateData();
|
|
InitPipeLayer(dlg.GetLayer());
|
|
int up(0), low(0);
|
|
double nElevation = _tstof(dlg.m_csEle)*1000;
|
|
BOOL ret = GetInterPipeLevel(ptPick1, ptPick2, nElevation, up, low);
|
|
ptPick1.z = nElevation;
|
|
TDbPipe *pPipe = new TDbPipe;
|
|
CString csMat = GetPipeMaterialByIdx(g_iPipeMaterial[dlg.m_iPipeType]);
|
|
CString csDnHead = GetDnByMat(csMat);
|
|
|
|
if(dlg.m_iPlace == 0 && ret){
|
|
if(up != 256)
|
|
pPipe->SetHideLevel(up);
|
|
else
|
|
pPipe->SetHideLevel(low);
|
|
}
|
|
else if(dlg.m_iPlace == 1 && ret){
|
|
if(up != 256)
|
|
pPipe->SetHideLevel(up+1);
|
|
else
|
|
pPipe->SetHideLevel(low+1);
|
|
}
|
|
else if(dlg.m_iPlace == 2 && ret)
|
|
pPipe->SetHideLevel(low-1);
|
|
else
|
|
pPipe->SetHideLevel(0);
|
|
|
|
pPipe->SetStartPoint(ptPick1);
|
|
pPipe->SetEndPoint(ptPick2);
|
|
if(fabs(dBulge) > 0.001){
|
|
pPipe->SetPoints(ptPick1, ptPick2, dBulge);
|
|
}
|
|
pPipe->setLayer(dlg.GetLayer());
|
|
pPipe->SetModelType(TPipeSys::kModel);
|
|
pPipe->setLinetype(GetPipeWireLayLineType(dlg.GetLayer()));
|
|
pPipe->SetLabel(csDnHead);
|
|
pPipe->SetMaterial(g_iPipeMaterial[dlg.m_iPipeType]);
|
|
pPipe->SetPipeWeight(g_nPipeWidth[dlg.m_iPipeType]);
|
|
pPipe->SetSysType(dlg.GetPipeSysType());
|
|
pPipe->SetRadius(g_nPipeRadius[dlg.m_iPipeType]);
|
|
pPipe->SetDnDiameter(_ttoi(dlg.m_csDn));
|
|
pPipe->setColor(AcCmColor()); //随层
|
|
AddToCurrentSpace(pPipe, Adesk::kTrue);
|
|
|
|
}
|
|
|
|
//已知1根AcDbCurve, 根据对话框的数据,绘制这个曲线的pipe
|
|
void DoDrawPipe(AcDbCurve *pCurve, CDrawStandPipeDlg &dlg)
|
|
{
|
|
AcDbLine *pLine = NULL;
|
|
AcDbArc *pArc = NULL;
|
|
AcDbPolyline *pPolyLine = NULL;
|
|
TDbWall *pWall = NULL;
|
|
if(pLine = AcDbLine::cast(pCurve)){
|
|
XPoint ptStart = pLine->startPoint();
|
|
XPoint ptEnd = pLine->endPoint();
|
|
DoDrawPipe(ptStart, ptEnd, 0, dlg);
|
|
}
|
|
else if(pArc = AcDbArc::cast(pCurve)){
|
|
XPoint ptCen = pArc->center();
|
|
double dRadius = pArc->radius();
|
|
double dStartAng = pArc->startAngle();
|
|
double dEndAng = pArc->endAngle();
|
|
XArc arc(ptCen, dRadius, dStartAng, dEndAng);
|
|
XPoint ptStart, ptEnd;
|
|
arc.GetStartPoint(ptStart);
|
|
arc.GetEndPoint(ptEnd);
|
|
DoDrawPipe(ptStart, ptEnd, arc.Bulge(), dlg);
|
|
}
|
|
else if(pPolyLine = AcDbPolyline::cast(pCurve)){
|
|
AcDbVoidPtrArray entSet;
|
|
pPolyLine->explode(entSet);
|
|
int len = entSet.length();
|
|
for(int i=0;i<len;i++){
|
|
AcDbEntity *pEnt = (AcDbEntity *)entSet[i];
|
|
if(pLine = AcDbLine::cast(pEnt)){
|
|
XPoint ptStart = pLine->startPoint();
|
|
XPoint ptEnd = pLine->endPoint();
|
|
DoDrawPipe(ptStart, ptEnd, 0, dlg);
|
|
}
|
|
else if(pArc = AcDbArc::cast(pEnt)){
|
|
XPoint ptCen = pArc->center();
|
|
double dRadius = pArc->radius();
|
|
double dStartAng = pArc->startAngle();
|
|
double dEndAng = pArc->endAngle();
|
|
XArc arc(ptCen, dRadius, dStartAng, dEndAng);
|
|
XPoint ptStart, ptEnd;
|
|
arc.GetStartPoint(ptStart);
|
|
arc.GetEndPoint(ptEnd);
|
|
DoDrawPipe(ptStart, ptEnd, arc.Bulge(), dlg);
|
|
}
|
|
}
|
|
ReleaseEntSet(entSet);
|
|
}
|
|
}
|
|
|
|
//***************************************************************************************************
|
|
// 沿线绘管
|
|
//***************************************************************************************************
|
|
//通过两点把PLINE线切割成两段(PLINE线必须是环形)
|
|
static void GetNeedPolylineTy2Pts(const AcDbPolyline &polyLine,XPoint ptSel1,XPoint ptSel2,XPoint ptNotIn,AcDbPolyline &plineOut)
|
|
{
|
|
AcGePoint3d ptT1,ptT2;
|
|
double dSeg1 = 0.0,dSeg2 = 0.0,dSegFirst = 0.0,dSegSecond = 0.0;
|
|
polyLine.getParamAtPoint(ptSel1,dSeg1);
|
|
polyLine.getParamAtPoint(ptSel2,dSeg2);
|
|
|
|
AcDbPolyline polyLine1,polyLine2;
|
|
int nSpec1 = 0,nSpec2 = 0; //截取点序号
|
|
//找到切割点附近点序号
|
|
for (UINT i = 0; i < polyLine.numVerts()-1; ++i)
|
|
{
|
|
polyLine.getPointAt(i,ptT1);
|
|
polyLine.getPointAt(i+1,ptT2);
|
|
polyLine.getParamAtPoint(ptT1,dSegFirst);
|
|
polyLine.getParamAtPoint(ptT2,dSegSecond);
|
|
|
|
if ((dSegFirst - dSeg1)*(dSegSecond - dSeg1) < 0)
|
|
nSpec1 = i + 1;
|
|
if ((dSegFirst - dSeg2)*(dSegSecond - dSeg2) < 0)
|
|
nSpec2 = i + 1;
|
|
}
|
|
|
|
//构建两条PLINE线
|
|
if (nSpec1 > nSpec2)
|
|
{
|
|
int nCount = 0;
|
|
polyLine1.addVertexAt(nCount,ptSel2);
|
|
nCount++;
|
|
for (int i = nSpec2; i < nSpec1; ++i)
|
|
{
|
|
polyLine.getPointAt(i,ptT1);
|
|
polyLine1.addVertexAt(nCount,ptT1.convert2d(AcGePlane::kXYPlane));
|
|
nCount++;
|
|
}
|
|
polyLine1.addVertexAt(nCount,ptSel1);
|
|
|
|
nCount = 0;
|
|
polyLine2.addVertexAt(nCount,ptSel2);
|
|
nCount++;
|
|
for (int j = nSpec2-1; j >= 0; --j)
|
|
{
|
|
polyLine.getPointAt(j,ptT1);
|
|
polyLine2.addVertexAt(nCount,ptT1.convert2d(AcGePlane::kXYPlane));
|
|
nCount++;
|
|
}
|
|
// cet 2010.5.19 modify 因UINT类型没有负值,无法满足循环条件
|
|
// for (UINT k = polyLine.numVerts()-1; k >= nSpec1; --k)
|
|
for (int k = polyLine.numVerts()-1; k >= nSpec1; --k)
|
|
{
|
|
polyLine.getPointAt(k,ptT1);
|
|
polyLine2.addVertexAt(nCount,ptT1.convert2d(AcGePlane::kXYPlane));
|
|
nCount++;
|
|
}
|
|
polyLine2.addVertexAt(nCount,ptSel1);
|
|
}
|
|
else
|
|
{
|
|
int nCount = 0;
|
|
polyLine1.addVertexAt(nCount,ptSel1);
|
|
nCount++;
|
|
for (int i = nSpec1; i < nSpec2; ++i)
|
|
{
|
|
polyLine.getPointAt(i,ptT1);
|
|
polyLine1.addVertexAt(nCount,ptT1.convert2d(AcGePlane::kXYPlane));
|
|
nCount++;
|
|
}
|
|
polyLine1.addVertexAt(nCount,ptSel2);
|
|
|
|
nCount = 0;
|
|
polyLine2.addVertexAt(nCount,ptSel1);
|
|
nCount++;
|
|
for (int j = nSpec1-1; j >= 0; --j)
|
|
{
|
|
polyLine.getPointAt(j,ptT1);
|
|
polyLine2.addVertexAt(nCount,ptT1.convert2d(AcGePlane::kXYPlane));
|
|
nCount++;
|
|
}
|
|
|
|
// cet 2010.5.19 modify 因UINT类型没有负值,无法满足循环条件
|
|
// for (UINT k = polyLine.numVerts()-1; k >= nSpec2; --k)
|
|
for (int k = polyLine.numVerts()-1; k >= nSpec2; --k)
|
|
{
|
|
polyLine.getPointAt(k,ptT1);
|
|
polyLine2.addVertexAt(nCount,ptT1.convert2d(AcGePlane::kXYPlane));
|
|
nCount++;
|
|
}
|
|
polyLine2.addVertexAt(nCount,ptSel2);
|
|
}
|
|
|
|
//找到需要的PLINE线
|
|
XPoint ptClose;
|
|
polyLine1.getClosestPointTo(ptNotIn,ptClose);
|
|
if (ptClose.Distance(ptNotIn) < 1e-3 && polyLine2.numVerts() > 0)
|
|
{
|
|
polyLine2.getPointAt(0,ptT1);
|
|
if (ptSel1.Distance(ptT1) < 1e-3)
|
|
{
|
|
for (UINT i = 0; i < polyLine2.numVerts(); ++i)
|
|
{
|
|
polyLine2.getPointAt(i,ptT1);
|
|
plineOut.addVertexAt(i,ptT1.convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// cet 2010.5.19 modify 因UINT类型没有负值,无法满足循环条件
|
|
// for (UINT i = polyLine2.numVerts()-1; i >= 0 ; --i)
|
|
for (int i = polyLine2.numVerts()-1; i >= 0 ; --i)
|
|
{
|
|
polyLine2.getPointAt(i,ptT1);
|
|
plineOut.addVertexAt(polyLine2.numVerts()-1-i,ptT1.convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
}
|
|
}
|
|
else if (ptClose.Distance(ptNotIn) > 1e-3 && polyLine1.numVerts() > 0)
|
|
{
|
|
polyLine1.getPointAt(0,ptT1);
|
|
if (ptSel1.Distance(ptT1) < 1e-3)
|
|
{
|
|
for (UINT i = 0; i < polyLine1.numVerts(); ++i)
|
|
{
|
|
polyLine1.getPointAt(i,ptT1);
|
|
plineOut.addVertexAt(i,ptT1.convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// cet 2010.5.19 modify 因UINT类型没有负值,无法满足循环条件
|
|
// for (UINT i = polyLine1.numVerts()-1; i >= 0 ; --i)
|
|
for (int i = polyLine1.numVerts()-1; i >= 0 ; --i)
|
|
{
|
|
polyLine1.getPointAt(i,ptT1);
|
|
plineOut.addVertexAt(polyLine1.numVerts()-1-i,ptT1.convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
static AcDbPolyline* CreatePLineBy2Wall(const XCurveSegment &seg1,const XCurveSegment &seg2,Entity idCol,Entity ent1,Entity ent2,const XPoint &ptPick1,const XPoint &ptPick2,const XCurveSegment &seg)
|
|
{
|
|
XPoly2D polyColum;
|
|
XPoint ptCen;
|
|
AcGePoint3dArray arPt;
|
|
XPoint ptSel1,ptSel2;//柱子上需要切的两点
|
|
//得到墙的PLINE线
|
|
AcDbPolyline *pWLine1= NULL;
|
|
AcDbPolyline *pWLine2= NULL;
|
|
XPoint ptNotIn; //用于判断切割柱子的哪一块
|
|
OPENOBJ_BEGIN(idCol,AcDb::kForRead,TDbColumn,pColum);
|
|
if (pColum != NULL)
|
|
{
|
|
pColum->GetOutline(polyColum);
|
|
|
|
//得到柱子上需要切割的两点
|
|
ptCen = pColum->GetLocation();
|
|
if (ptCen.Distance2d(seg1.StartPoint()) < ptCen.Distance2d(seg1.EndPoint()))
|
|
{
|
|
ptSel1 = seg1.StartPoint();
|
|
ptNotIn = seg.StartPoint();
|
|
}
|
|
else
|
|
{
|
|
ptSel1 = seg1.EndPoint();
|
|
ptNotIn = seg.EndPoint();
|
|
}
|
|
|
|
if (ptCen.Distance2d(seg2.StartPoint()) < ptCen.Distance2d(seg2.EndPoint()))
|
|
ptSel2 = seg2.StartPoint();
|
|
else
|
|
ptSel2 = seg2.EndPoint();
|
|
|
|
pWLine1 = GetNextPloyLine(ent1,ent1,ptPick1,ptSel1);
|
|
pWLine2 = GetNextPloyLine(ent2,ent2,ptSel2,ptPick2);
|
|
//得到两点的PLINE
|
|
AcDbPolyline polyLine,pline;
|
|
PolyConvert(polyColum,polyLine);
|
|
|
|
//通过两点把PLINE线切割成两段(PLINE线必须是环形)
|
|
GetNeedPolylineTy2Pts(polyLine,ptSel1,ptSel2,ptNotIn,pline);
|
|
|
|
AcGePoint3d ptT1;
|
|
//组合PLINE线
|
|
int nCount = pWLine1->numVerts();
|
|
for (UINT i = 0;i < pline.numVerts(); ++i)
|
|
{
|
|
pline.getPointAt(i,ptT1);
|
|
pWLine1->addVertexAt(nCount,ptT1.convert2d(AcGePlane::kXYPlane));
|
|
nCount++;
|
|
}
|
|
|
|
for (int j = 0; j < pWLine2->numVerts(); ++j)
|
|
{
|
|
pWLine2->getPointAt(j,ptT1);
|
|
pWLine1->addVertexAt(nCount,ptT1.convert2d(AcGePlane::kXYPlane));
|
|
nCount++;
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
delete pWLine2;
|
|
return pWLine1;
|
|
}
|
|
|
|
//得到的PLINE线必须在外面DELETE
|
|
static AcDbPolyline* GetNextWallLine(Entity ent1,Entity ent2,const XPoint &ptPick1,const XPoint &ptPick2)
|
|
{
|
|
AcDbPolyline *pLine = NULL;
|
|
bool bCon = FALSE;
|
|
Entity idCol;
|
|
XCurveSegment seg1,seg2;
|
|
XPoly2D poly1,poly2;
|
|
OPENOBJ_BEGIN(ent1,AcDb::kForRead,TDbWall,pWall1);
|
|
if (pWall1 != NULL)
|
|
{
|
|
OPENOBJ_BEGIN(ent2,AcDb::kForRead,TDbWall,pWall2);
|
|
if (pWall2 != NULL)
|
|
{
|
|
//得到两墙的PLINE线
|
|
XCurveSegment lCurve, rCurve, seg;
|
|
XPoint ptNew1, ptNew2;
|
|
pWall1->GetSideCurve(lCurve, rCurve);
|
|
lCurve.ProjectToMe(ptPick1, ptNew1);
|
|
rCurve.ProjectToMe(ptPick1, ptNew2);
|
|
if(ads_distance(ptPick1, ptNew1) < ads_distance(ptPick1, ptNew2))
|
|
{
|
|
seg1 = lCurve;
|
|
seg = rCurve;
|
|
}
|
|
else
|
|
{
|
|
seg1 = rCurve;
|
|
seg = lCurve;
|
|
}
|
|
|
|
pWall2->GetSideCurve(lCurve, rCurve);
|
|
lCurve.ProjectToMe(ptPick2, ptNew1);
|
|
rCurve.ProjectToMe(ptPick2, ptNew2);
|
|
if(ads_distance(ptPick2, ptNew1) < ads_distance(ptPick2, ptNew2))
|
|
seg2 = lCurve;
|
|
else
|
|
seg2 = rCurve;
|
|
|
|
pWall1->close();
|
|
pWall2->close();
|
|
|
|
//找到柱子
|
|
RBList rbMask(RTDXF0, _T("ATS_COLUMN"), NULL);
|
|
PickSet ss1(SS_FREE);
|
|
PickSet ss2(SS_FREE);
|
|
|
|
struct resbuf *pointlist1,*pointlist2;
|
|
pointlist1 = ads_buildlist(RTPOINT, &seg1.StartPoint(), RTPOINT, &seg1.EndPoint(), NULL);
|
|
pointlist2 = ads_buildlist(RTPOINT, &seg2.StartPoint(), RTPOINT, &seg2.EndPoint(), NULL);
|
|
ss1.Get(_T("F"), pointlist1, NULL, rbMask);
|
|
ss2.Get(_T("F"), pointlist2, NULL, rbMask);
|
|
ads_relrb(pointlist1);
|
|
ads_relrb(pointlist2);
|
|
|
|
|
|
//得到柱子的ID
|
|
for (long i = 0; i < ss1.Length(); ++i)
|
|
{
|
|
for (long j = 0; j < ss2.Length(); ++j)
|
|
{
|
|
if (ss1[i] == ss2[j])
|
|
{
|
|
bCon = true;
|
|
idCol = ss1[i];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//两墙连接
|
|
if (bCon)
|
|
{
|
|
//创建两墙的PLINE线
|
|
pLine = CreatePLineBy2Wall(seg1,seg2,idCol,ent1,ent2,ptPick1,ptPick2,seg);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
return pLine;
|
|
}
|
|
|
|
void CmdPipeByLine()
|
|
{
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
if(g_bTgOsnap)
|
|
{
|
|
nOsMode &= ~0x4000;
|
|
nOsMode |= OS_INT|OS_NEA|OS_PER|OS_END|OS_CEN;
|
|
}
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
|
|
long len = g_ssPickFirst.Length();
|
|
int iFisrtIdx(-1);
|
|
if(len == 1){
|
|
Entity entFirst = g_ssPickFirst[0L];
|
|
iFisrtIdx = GetPipeIdxByEnt(entFirst);
|
|
}
|
|
|
|
CDrawStandPipeDlg dlg(0, acedGetAcadFrame());
|
|
{
|
|
if(iFisrtIdx > -1)
|
|
dlg.m_iPipeType = iFisrtIdx;
|
|
CTemporaryResourceOverride vTemp;
|
|
dlg.Create(IDD_STAND_PIPE, acedGetAcadFrame());
|
|
}
|
|
dlg.ShowWindow(SW_SHOW);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
|
|
XPoint ptPick1, ptPick2, ptOnCurve;
|
|
|
|
double nElevation(0);
|
|
Entity entLastPipe;
|
|
int iRet;
|
|
INITGET_BEG(0, _T("R"));
|
|
iRet = ads_getpoint(NULL, _T("\n请点取管线的起始点(注意,点取靠近线的一侧,不要点在线上)[输入参考点(R)]<退出>:"), ptPick1);
|
|
ptPick1 = Ucs2Wcs(ptPick1);
|
|
INITGET_END();
|
|
if(iRet != RTNORM && iRet != RTKWORD){
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
if(iRet == RTKWORD){
|
|
if(ads_getpoint(NULL,_T("\n请输入参考点:"), ptPick1) != RTNORM){
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
double nXDist(0), nYDist(0);
|
|
ptPick1 = Ucs2Wcs(ptPick1);
|
|
ads_getpoint(ptPick1, _T("\n请输入距参考点的距离<确定>:"), ptPick1);
|
|
ptPick1 = Ucs2Wcs(ptPick1);
|
|
}
|
|
Entity entLine;
|
|
RBList rbMask(RTDXF0, _T("LINE,ARC,ATS_WALL"), NULL);
|
|
if(SelectEntity1(0.3, _T("\n请拾取布置管线需要沿的直线、弧线、墙线 <退出>"), entLine, ptPick2, rbMask) != RTNORM){
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
ptPick2 = Ucs2Wcs(ptPick2);
|
|
|
|
PickSet ssPoint(SS_FREE);
|
|
GetPointPickSet(ptPick1, ssPoint, rbMask);
|
|
if(ssPoint.Length() == 1){
|
|
if(entLine == ssPoint[0L]){
|
|
adsout << _T("\n操作有误,请先点取管线起始点,再选取所要沿的线!");
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
}
|
|
|
|
XPushVar<int> vOsMode2(_T("OSMODE"), 0);
|
|
|
|
double dOffsetDist(0);
|
|
OPENOBJ_BEGIN(entLine, AcDb::kForRead, AcDbCurve, pCurve);
|
|
if(pCurve){
|
|
TDbWall *pWall = NULL;
|
|
AcDbCurve *pWallCurve = NULL;
|
|
if(pWall = TDbWall::cast(pCurve)){
|
|
XCurveSegment lCurve, rCurve, seg;
|
|
XPoint ptNew1, ptNew2;
|
|
pWall->GetSideCurve(lCurve, rCurve);
|
|
lCurve.ProjectToMe(ptPick2, ptNew1);
|
|
rCurve.ProjectToMe(ptPick2, ptNew2);
|
|
if(ads_distance(ptPick2, ptNew1) < ads_distance(ptPick2, ptNew2))
|
|
seg = lCurve;
|
|
else
|
|
seg = rCurve;
|
|
pWallCurve = seg.AsAcDbCurve();
|
|
}
|
|
|
|
XPoint ptOnCurve1, ptOnCurve2;
|
|
if(pWallCurve != NULL)
|
|
pWallCurve->getClosestPointTo(ptPick1, ptOnCurve1);
|
|
else
|
|
pCurve->getClosestPointTo(ptPick1, ptOnCurve1);
|
|
|
|
dOffsetDist = ads_distance(ptPick1, ptOnCurve1);
|
|
CString csText;
|
|
csText.Format(_T("\n请输入距线距离<%.f>"), dOffsetDist);
|
|
ads_getreal(csText, &dOffsetDist);
|
|
AcGeVector3d vt(ptPick1 - ptOnCurve1);
|
|
vt.normalize();
|
|
vt *= dOffsetDist;
|
|
AcGeMatrix3d mat;
|
|
mat.setToTranslation(vt);
|
|
ptOnCurve1.TransformBy(mat);
|
|
if(dOffsetDist < 0.001){
|
|
adsout << _T("\n不能距线距离为0");
|
|
dlg.DestroyWindow();
|
|
if(pWallCurve != NULL)
|
|
delete pWallCurve;
|
|
return;
|
|
}
|
|
AcDbCurve *pCurve2 = NULL;
|
|
if(pWallCurve != NULL)
|
|
pCurve2 = GetOffsetCurve(pWallCurve, dOffsetDist, ptOnCurve1);
|
|
else
|
|
pCurve2 = GetOffsetCurve(pCurve, dOffsetDist, ptOnCurve1);
|
|
if(pWallCurve != NULL)
|
|
delete pWallCurve;
|
|
|
|
//AcDbCurve *pCurve2 = GetOffsetCurve(pCurve, dOffsetDist, ptOnCurve1);
|
|
if(pCurve2 != NULL){
|
|
pCurve2->getClosestPointTo(ptPick2, ptOnCurve2);
|
|
ptOnCurve = ptOnCurve2;
|
|
AcDbCurve *pCurve3 = GetCurveBy2Pt(pCurve2, ptOnCurve1, ptOnCurve2);
|
|
delete pCurve2;
|
|
if(pCurve3 != NULL){
|
|
DoDrawPipe(pCurve3, dlg);
|
|
delete pCurve3;
|
|
}
|
|
}
|
|
|
|
}
|
|
OPENOBJ_END();
|
|
if(entLine.Is(_T("LWPOLYLINE"))){
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
ptPick1 = ptPick2;
|
|
Entity entLine2;
|
|
while(SelectEntity1(0.3, _T("\n请拾取下一段PLINE、直线、弧线 <退出>"), entLine2, ptPick2, rbMask) == RTNORM){
|
|
ptPick2 = Ucs2Wcs(ptPick2);
|
|
|
|
//临时创建1条PLINE线,反复调用InsWellByCurve
|
|
AcDbPolyline *pLine = GetNextPloyLine(entLine, entLine2, ptPick1, ptPick2);
|
|
|
|
if (pLine == NULL)
|
|
pLine = GetNextWallLine(entLine,entLine2,ptPick1,ptPick2);
|
|
|
|
if(pLine != NULL)
|
|
{
|
|
|
|
AcDbCurve *pCurveOffset = GetOffsetCurve((AcDbCurve *)pLine, dOffsetDist, ptOnCurve);
|
|
|
|
if(pCurveOffset != NULL)
|
|
{
|
|
DoDrawPipe(pCurveOffset, dlg);
|
|
pCurveOffset->getClosestPointTo(ptPick2, ptOnCurve);
|
|
delete pCurveOffset;
|
|
}
|
|
pLine->getClosestPointTo(ptPick2, ptPick2);
|
|
delete pLine;
|
|
ptPick1 = ptPick2;
|
|
entLine = entLine2;
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
dlg.DestroyWindow();
|
|
}
|
|
|
|
//***************************************************************************************************
|
|
// 绘制管线
|
|
//***************************************************************************************************
|
|
BOOL GetInterArcPipeLevel(XArc arc, double nElevation, int &up, int &low)
|
|
{
|
|
RBList rbMaskPipe(RTDXF0, _T("ATS_PIPE"), 8, GetLayerNames(_T("管线")), NULL);
|
|
PickSet ss(SS_FREE);
|
|
|
|
XCurveSegment seg;
|
|
seg = arc;
|
|
XPoly2D xPline;
|
|
seg.AsPoly2D(xPline);
|
|
XPoint pt1, pt2;
|
|
pt1 = *xPline[0];
|
|
xPline.Length();
|
|
pt2 = *xPline[xPline.Length()-1];
|
|
AssureInCurrentView(pt1, pt2);
|
|
xPline.TransUCS(Groups(0),Groups(1)); // 把 UCS 转为 WCS
|
|
RBList rbPoint = xPline.Polygon();
|
|
ss.Get(_T("F"), rbPoint, NULL, rbMaskPipe);
|
|
|
|
|
|
BOOL ret = FALSE;
|
|
up = 256;
|
|
low = 256;
|
|
|
|
// struct resbuf *pointlist;
|
|
// XLine line(pt1, pt2);
|
|
// line.Make();
|
|
// pointlist = ads_buildlist(RTPOINT, &pt1, RTPOINT, &pt2, NULL);
|
|
// ss.Get(_T("F"), pointlist, NULL, rbMaskPipe);
|
|
// ads_relrb(pointlist);
|
|
for(long i=0;i<ss.Length();i++){
|
|
Entity ent = ss[i];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe && !pPipe->IsVertical()){
|
|
nElevation = pPipe->StartPoint().z;
|
|
if(up < pPipe->GetHideLevel() || up == 256)
|
|
up = pPipe->GetHideLevel();
|
|
if(low > pPipe->GetHideLevel() || low == 256)
|
|
low = pPipe->GetHideLevel();
|
|
ret = TRUE;
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
|
|
#include "OutDimSettingDlg.h"
|
|
#include"TGAs.h"
|
|
void test()
|
|
{
|
|
CodeBase db;
|
|
XString fullFile;
|
|
if(!FindFile(_T("上华标准材质.dbf"), fullFile))
|
|
{
|
|
AfxMessageBox(_T("对不起,没有发现上华标准材质.dbf文件!"));
|
|
return;
|
|
}
|
|
|
|
XDbfTable *pTable = db.Open(fullFile);
|
|
if(!pTable)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int nId = 1;
|
|
int nType = -1;
|
|
for(pTable->MoveFirst();!pTable->IsEOF();pTable->MoveNext())
|
|
{
|
|
GET_FIELD(pTable, _T("type"), nType);
|
|
if (nType == 0)
|
|
{
|
|
SET_FIELD(pTable, _T("id"), nId++);
|
|
}
|
|
else if (nType == 1)
|
|
{
|
|
SET_FIELD(pTable, _T("id"), -1);
|
|
}
|
|
}
|
|
|
|
return;
|
|
|
|
XPoint ptStart, ptEnd;
|
|
if(ads_getpoint(NULL,_T("\n请输入起点:"), ptStart) != RTNORM){
|
|
return;
|
|
}
|
|
if(ads_getpoint(ptStart, _T("\n请输入距参考点的距离<确定>:"), ptEnd)!= RTNORM){
|
|
return;
|
|
}
|
|
TDbPipeCanal *pPipe2 = new TDbPipeCanal;
|
|
pPipe2->SetStartPoint(ptStart);
|
|
pPipe2->SetEndPoint(ptEnd);
|
|
pPipe2->SetDoteLayer(InitLayer(LAY_TWT_DOTE));
|
|
pPipe2->setLinetype(_T("CONTINUOUS"));
|
|
pPipe2->SetPipeWeight(g_nPipeWidth[0]);
|
|
pPipe2->SetModelType(TPipeSys::kModel);
|
|
pPipe2->SetMaterial(0);
|
|
pPipe2->SetWidth(500);
|
|
pPipe2->SetHeight(600);
|
|
pPipe2->setColor(AcCmColor()); //随层
|
|
AddToCurrentSpace(pPipe2, Adesk::kTrue);
|
|
|
|
}
|
|
|
|
void CmdPipe()
|
|
{
|
|
xg_setvar(_T("CMDECHO"), 0);
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
if(g_bTgOsnap)
|
|
{
|
|
nOsMode &= ~0x4000;
|
|
nOsMode |= OS_INT|OS_NEA|OS_PER|OS_END|OS_CEN;
|
|
}
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
double dCeltScale = 1;
|
|
xg_getvar(_T("CELTSCALE"), &dCeltScale);
|
|
|
|
|
|
long len = g_ssPickFirst.Length();
|
|
int iFisrtIdx(-1);
|
|
if(len == 1){
|
|
Entity entFirst = g_ssPickFirst[0L];
|
|
iFisrtIdx = GetPipeIdxByEnt(entFirst);
|
|
}
|
|
|
|
CTemporaryResourceOverride vTemp;
|
|
CDrawStandPipeDlg dlg(0, acedGetAcadFrame());
|
|
{
|
|
if(iFisrtIdx > -1)
|
|
dlg.m_iPipeType = iFisrtIdx;
|
|
//cet 2011.12.6 add 设置默认选择管线类型
|
|
if (iFisrtIdx >= 0 && iFisrtIdx <= 8)
|
|
{
|
|
dlg.m_iPipeType2 = iFisrtIdx;
|
|
dlg.m_iPipeType3 = 9;
|
|
}
|
|
else if (iFisrtIdx >= 9 && iFisrtIdx <= 16
|
|
|| iFisrtIdx >= 29 && iFisrtIdx <= 34)
|
|
{
|
|
dlg.m_iPipeType2 = 9;
|
|
dlg.m_iPipeType3 = iFisrtIdx;
|
|
}
|
|
dlg.Create(IDD_STAND_PIPE, acedGetAcadFrame());
|
|
}
|
|
dlg.ShowWindow(SW_SHOW);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
|
|
XPoint ptPick1, ptPick2;
|
|
double nElevation(0);
|
|
Entity entLastPipe;
|
|
int iRet;
|
|
INITGET_BEG(0, _T("R"));
|
|
iRet = ads_getpoint(NULL, _T("\n请点取管线的起始点[输入参考点(R)]<退出>:"), ptPick1);
|
|
ptPick1 = Ucs2Wcs(ptPick1);
|
|
INITGET_END();
|
|
if(iRet != RTNORM && iRet != RTKWORD){
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
if(iRet == RTKWORD){
|
|
if(ads_getpoint(NULL,_T("\n请输入参考点:"), ptPick1) != RTNORM){
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
double nXDist(0), nYDist(0);
|
|
// ptPick1 = Ucs2Wcs(ptPick1); cet 2011.8.26 del 无需转换本来就是需要ucs点
|
|
ads_getpoint(ptPick1, _T("\n请输入距参考点的距离<确定>:"), ptPick1);
|
|
ptPick1 = Ucs2Wcs(ptPick1);
|
|
}
|
|
double dMeter(1);
|
|
if(!DocGetMeterUnitDraw())
|
|
dMeter = 1000;
|
|
|
|
// cet 2012.3.13 add 更新对话框数据
|
|
dlg.UpdateData();
|
|
|
|
XPointList lstPt;
|
|
Entity entPipeRef;
|
|
CString csDnType;
|
|
|
|
double dFisrtEle(-1);
|
|
int iPipeIdx(-1), iPos(-1);
|
|
if(!GetEquipmentByPt(ptPick1)){
|
|
if(!GetWellByPt(ptPick1, iPipeIdx))
|
|
if(!GetVertPipeByPt2(ptPick1, iPipeIdx, iPos))
|
|
entPipeRef = GetPipeByPt2(ptPick1, nElevation, iPipeIdx, iPos);
|
|
else // cet 2013.2.26 add 起始点在立管上,管径设置为初始设置中的默认管径值
|
|
{
|
|
dlg.m_csDn.Format(_T("%d"), g_iDefaultPipeDn);
|
|
dlg.UpdatePipeDn(FALSE);
|
|
}
|
|
}
|
|
else{
|
|
dlg.UpdateData(TRUE);
|
|
dlg.m_csEle.Format(_T("%.3f"), ptPick1.z/dMeter);
|
|
dlg.UpdateData(FALSE);
|
|
}
|
|
if(iPipeIdx > -1){
|
|
int iDn(25);
|
|
//2008-5-26 自动读取上1段管线的管径和DN类型
|
|
OPENOBJ_BEGIN(entPipeRef, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
iDn = (int)pPipe->GetDnDiameter();
|
|
csDnType = pPipe->GetLabel();
|
|
dFisrtEle = nElevation;
|
|
}
|
|
OPENOBJ_END();
|
|
// cet 2013.2.26 modify entPipeRef有效时设置管径
|
|
if (!!entPipeRef)
|
|
{
|
|
dlg.m_csDn.Format(_T("%d"), iDn);
|
|
dlg.UpdatePipeDn(FALSE); // cet 2012.8.31 add 更新管径控件当前值
|
|
}
|
|
|
|
dlg.m_iPipeType = iPipeIdx;
|
|
// cet 2011.12.6 add
|
|
if (iPipeIdx >= 0 && iPipeIdx <= 8)
|
|
{
|
|
dlg.m_iPipeType2 = iPipeIdx;
|
|
// dlg.m_iPipeType3 = 9; cet 2012.10.19 del 当前选择不变
|
|
}
|
|
else if (iPipeIdx >= 9 && iPipeIdx <= 16
|
|
|| iPipeIdx >= 29 && iPipeIdx <= 34)
|
|
{
|
|
dlg.m_iPipeType2 = 9;
|
|
dlg.m_iPipeType3 = iPipeIdx;
|
|
}
|
|
|
|
if(iPos < 0)
|
|
iPos = 0;
|
|
dlg.m_iPos = iPos;
|
|
|
|
// dlg.m_csEle.Format(_T("%.3f"), ptPick1.z/dMeter); // cet 2010.6.24 del
|
|
|
|
// cet 2010.6.24 add
|
|
bool bRead = dlg.IsGetEle(); // cet 2010.6.23 add 是否自动读取前一管线标高
|
|
if (bRead)
|
|
{
|
|
dlg.m_csEle.Format(_T("%.3f"), ptPick1.z/dMeter);
|
|
}
|
|
|
|
dlg.ResetShowRadio();
|
|
dlg.ResetRegion();
|
|
// dlg.UpdateData(FALSE);
|
|
// cet 2010.6.24 del
|
|
// CWnd *pWnd1 = dlg.GetDlgItem(IDC_EDIT_ELEVATION);
|
|
// pWnd1->SetWindowText(dlg.m_csEle);
|
|
|
|
// cet 2010.6.24 add
|
|
if (bRead)
|
|
{
|
|
CWnd *pWnd1 = dlg.GetDlgItem(IDC_EDIT_ELEVATION);
|
|
pWnd1->SetWindowText(dlg.m_csEle);
|
|
}
|
|
else
|
|
{
|
|
CWnd *pWnd1 = dlg.GetDlgItem(IDC_EDIT_ELEVATION);
|
|
CString strEle;
|
|
pWnd1->GetWindowText(strEle);
|
|
nElevation = _tstof(strEle) * 1000;
|
|
}
|
|
//cet 2011.12.1 del
|
|
//dlg.CheckRadioButton(IDC_RADIO_PIPETYPE1, IDC_RADIO_PIPETYPE19, IDC_RADIO_PIPETYPE1+iPipeIdx);
|
|
dlg.CheckRadioButton(IDC_RADIO_POS1, IDC_RADIO_POS3, IDC_RADIO_POS1+iPos);
|
|
dlg.UpdateData(FALSE); // cet 2011.12.7 add 更新对话框数据
|
|
dlg.UpdateDimText(); // cet 2011.12.14 add 更新标注文字
|
|
}
|
|
else{
|
|
ptPick1.z = _tstof(dlg.m_csEle)*dMeter;//空点pick1.z = 0, 实际应该从对话框读取上次标高。
|
|
}
|
|
lstPt.Append(new XPoint(ptPick1));
|
|
XPoint ptJig = ptPick1;
|
|
ptJig.z = 0;//必须保证JIG的z为0
|
|
TPipeEdJig jig(ptJig, ptJig, 0.5);
|
|
jig.SetDlg(&dlg); // cet 2011.7.27 add
|
|
CString csPrompt;
|
|
//cet 2012.3.16 增加关键字T用于轴锁其他角度设置
|
|
//jig.SetKeyword(_T("A S D G R U J W Y Z F X H V L")); // cet 2011.8.2 modify 增加关键字L用于控制角度盘是否显示
|
|
jig.SetKeyword(_T("A S D G R U J W Y Z F X H V L T"));
|
|
//adsout << _T("\n[给水(J)/污水(W)/废水(F)/雨水(Y)/中水(Z)/消防(X)/喷淋(H)]");// zxl 2013.10.15 del 删除无用提示信息
|
|
int nKeyIndex;
|
|
AcGeVector3d vt = AcGeVector3d::kXAxis; // cet 2011.8.1 add 记录上次绘制管线方向
|
|
vt.rotateBy(Ucs2Wcs(0.0), AcGeVector3d::kZAxis);
|
|
bool bKey = false; // cet 2011.8.1 add jig上一个操作是否为关键字, 控制是否刷新
|
|
int nKeyNum = 0; // cet 2011.8.2 add 连续按关键字的次数,用于控制是否刷新
|
|
// cet 2012.3.16 add 使用角度盘时,重设刻度
|
|
if (dlg.IsLockAngle())
|
|
{
|
|
jig.SetWatchAngle(dlg.GetAngleFromMenu());
|
|
}
|
|
|
|
while(1){
|
|
if (!bKey)
|
|
{
|
|
acedRedraw(NULL, 0); // cet 2011.7.27 add 刷新
|
|
}
|
|
|
|
// cet 2012.3.16 add 对话框可向cad发送命令关键字,以相应jig
|
|
dlg.EnableSendKeyToCAD(TRUE);
|
|
|
|
dlg.UpdateData(TRUE);
|
|
jig.m_ptRef = ptPick1;
|
|
jig.m_ptRef.z = 0;
|
|
csPrompt.Format(_T("\n请点取管线的终止点[轴锁0度(A)/轴锁30度(S)/轴锁45度(D)/选取行向线(G)/弧管线(R)/回退(U)]<结束> (当前标高:%.0f):"), nElevation);
|
|
jig.SetPrompt(csPrompt);
|
|
jig.m_bInit = TRUE;//保证第一次执行一下acquirePoint(pt, m_ptRef)
|
|
int ret = jig.DoIt(&nKeyIndex);
|
|
|
|
if(ret != RTNORM && ret != RTKWORD){
|
|
SHads_command(RTNONE);
|
|
break;
|
|
}
|
|
if(ret == RTNORM){
|
|
bKey = false; // cet 2011.8.1 add
|
|
nKeyNum = 0; // cet 2011.8.2 add
|
|
dlg.UpdateData(TRUE);
|
|
jig.m_pPipe->SetPipeWeight(g_nPipeWidth[dlg.m_iPipeType]);
|
|
nElevation = _tstof(dlg.m_csEle)*dMeter;
|
|
ptPick2 = jig.m_ptPick;
|
|
if(ptPick1 == ptPick2)
|
|
continue;
|
|
|
|
//首先判断是否从设备上引出
|
|
Entity entEq = GetEquipmentByPt(ptPick2);
|
|
if(!entEq){
|
|
ptPick2 = jig.GetCorrectPt();
|
|
}
|
|
else{
|
|
//设备默认标高为0,如果接管标高!=0, 而且设备还未接管,则强制修改设备标高
|
|
OPENOBJ_BEGIN(entEq, AcDb::kForWrite, TDbEquipment, pEquip);
|
|
if(pEquip){
|
|
int num = pEquip->GetInterfaceNum();
|
|
if(num == 0){
|
|
XPoint ptLoc = pEquip->GetLocation();
|
|
ptLoc.z = nElevation;
|
|
pEquip->SetLocation(ptLoc);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
ptPick2.z = nElevation;
|
|
if(jig.m_nLockAng > 0 && !jig.m_bLock){
|
|
jig.m_nLockAng = 0;
|
|
jig.m_bLock = TRUE;
|
|
}
|
|
lstPt.Append(new XPoint(ptPick2));
|
|
SHads_command(RTSTR, _T(".UNDO"), RTSTR, _T("MARK"), RTNONE); // Make a undo mark
|
|
InitPipeLayer(dlg.GetLayer());
|
|
iPipeIdx = GetPipeLayerIdxByName(dlg.GetLayer());
|
|
CString csMat = GetPipeMaterialByIdx(g_iPipeMaterial[iPipeIdx]);
|
|
CString csDnHead = GetDnByMat(csMat);
|
|
|
|
//2009-8-3 增加后面的判断
|
|
//lstPt.Length() > 2 连续绘制中变标高
|
|
//lstPt.Length() == 2 第一次绘制,如果跟参考管线有标高差
|
|
if((fabs(ptPick1.z - nElevation) > 0.00001 && lstPt.Length() > 2 ) || (fabs(ptPick1.z - nElevation) > 0.00001 && lstPt.Length() == 2 && fabs(ptPick1.z - dFisrtEle) < 0.00001 ) ) { //与上一根管线有高差
|
|
TDbPipe *pPipe2 = new TDbPipe;
|
|
pPipe2->SetStartPoint(ptPick1);
|
|
ptPick1.z = nElevation;
|
|
pPipe2->SetEndPoint(ptPick1);
|
|
pPipe2->setLinetype(_T("CONTINUOUS"));
|
|
if(!g_bStandPipeArc)//传统扣弯
|
|
pPipe2->SetRadiusIn(-2);
|
|
pPipe2->setLayer(dlg.GetLayer());
|
|
pPipe2->SetLabel(csDnType);
|
|
pPipe2->SetPipeWeight(g_nPipeWidth[iPipeIdx]);
|
|
pPipe2->SetSysType(dlg.GetPipeSysType());
|
|
pPipe2->SetModelType(TPipeSys::kModel);
|
|
pPipe2->SetLabel(csDnHead);
|
|
pPipe2->SetMaterial(g_iPipeMaterial[iPipeIdx]);
|
|
pPipe2->SetRadius(g_nPipeRadius[dlg.m_iPipeType]);
|
|
pPipe2->SetDnDiameter(_ttoi(dlg.m_csDn));
|
|
pPipe2->setColor(AcCmColor()); //随层
|
|
AddToCurrentSpace(pPipe2, Adesk::kTrue);
|
|
}
|
|
int up(0), low(0);
|
|
BOOL ret = GetInterPipeLevel(ptPick1, ptPick2, nElevation, up, low);
|
|
ptPick1.z = nElevation;
|
|
TDbPipe *pPipe = new TDbPipe;
|
|
if(dlg.m_iPlace == 0 && ret){
|
|
if(up != 256)
|
|
pPipe->SetHideLevel(up);
|
|
else
|
|
pPipe->SetHideLevel(low);
|
|
}
|
|
else if(dlg.m_iPlace == 1 && ret){
|
|
if(up != 256)
|
|
pPipe->SetHideLevel(up+1);
|
|
else
|
|
pPipe->SetHideLevel(low+1);
|
|
}
|
|
else if(dlg.m_iPlace == 2 && ret)
|
|
pPipe->SetHideLevel(low-1);
|
|
else
|
|
pPipe->SetHideLevel(0);
|
|
|
|
pPipe->SetStartPoint(ptPick1);
|
|
pPipe->SetEndPoint(ptPick2);
|
|
// 2008.10.27 自动修正上华带文字线型的逆向管线
|
|
CString csLineType = GetPipeWireLayLineType(dlg.GetLayer());
|
|
// 2011.7.8 sr GetPipeWireLayLineType有时候会返回byLayer
|
|
CString csLineType2 = GetLayerLineType(dlg.GetLayer());
|
|
if(csLineType2.Find(_T("TG")) > -1)
|
|
{
|
|
XLine line(ptPick1, ptPick2);
|
|
double nAng = line.Direction();
|
|
if(nAng > PI/2 && nAng < (PI/2*3 + 0.001)){
|
|
pPipe->SetStartPoint(ptPick2);
|
|
pPipe->SetEndPoint(ptPick1);
|
|
}
|
|
}
|
|
pPipe->setLayer(dlg.GetLayer());
|
|
pPipe->SetLabel(csDnType);
|
|
|
|
pPipe->SetModelType(TPipeSys::kModel);
|
|
pPipe->setLinetype(csLineType);
|
|
pPipe->setLinetypeScale(dCeltScale);
|
|
pPipe->SetMaterial(g_iPipeMaterial[iPipeIdx]);
|
|
pPipe->SetLabel(csDnHead);
|
|
pPipe->SetPipeWeight(g_nPipeWidth[iPipeIdx]);
|
|
pPipe->SetSysType(dlg.GetPipeSysType());
|
|
pPipe->SetRadius(g_nPipeRadius[iPipeIdx]);
|
|
pPipe->SetDnDiameter(_ttoi(dlg.m_csDn));
|
|
pPipe->setColor(AcCmColor()); //随层
|
|
// cet 2011.8.1 add
|
|
vt = pPipe->EndPoint() - pPipe->StartPoint();
|
|
vt.normalize();
|
|
jig.SetPipeDir(vt);
|
|
|
|
AddToCurrentSpace(pPipe, Adesk::kTrue);
|
|
entLastPipe.GetLast();
|
|
ptPick1 = ptPick2;
|
|
ptJig = ptPick2;
|
|
ptJig.z = 0;
|
|
jig.SetStartPoint(ptJig);
|
|
TPipePerDocData *pData = GetCurPipeDocData();
|
|
pData->ApplyUpdates();
|
|
|
|
}
|
|
else if(ret == RTKWORD){
|
|
if (bKey && nKeyNum == 0 || nKeyIndex == 4 || nKeyIndex == 14)
|
|
{
|
|
acedRedraw(NULL, 0); // cet 2011.8.1 add 刷新
|
|
if (nKeyIndex == 14)
|
|
{
|
|
// cet 2012.3.16 add 重绘角度盘
|
|
if (dlg.IsLockAngle())
|
|
{
|
|
jig.SetWatchAngle(dlg.GetAngleFromMenu());
|
|
jig.RedrawWatch();
|
|
}
|
|
else
|
|
{
|
|
jig.m_iUnit = 0;
|
|
}
|
|
continue;
|
|
}
|
|
}
|
|
bKey = true; // cet 2011.8.1 add
|
|
++nKeyNum; // cet 2011.8.2 add
|
|
if(nKeyIndex==0){
|
|
jig.m_iUnit = 0;
|
|
// cet 2012.3.16 禁用角度盘
|
|
dlg.EnableLockAngle(FALSE);
|
|
dlg.UpdateData(FALSE);
|
|
acedRedraw(NULL, 0);
|
|
|
|
if(fabs(jig.m_nLockAng) > 0.001){
|
|
jig.m_nLockAng = 0;
|
|
jig.m_bLock = TRUE;
|
|
}
|
|
}
|
|
else if(nKeyIndex==1)
|
|
{
|
|
jig.m_iUnit = 30;
|
|
dlg.SelectAngleMenuItem(30); // cet 2012.3.16 add 更新角度菜单选项
|
|
if (dlg.IsLockAngle()) // cet 2012.3.16 add 根据当前刻度重新绘制角度盘
|
|
{
|
|
jig.SetWatchAngle(30);
|
|
jig.RedrawWatch();
|
|
}
|
|
}
|
|
else if(nKeyIndex==2)
|
|
{
|
|
jig.m_iUnit = 45;
|
|
dlg.SelectAngleMenuItem(45); // cet 2012.3.16 add 更新角度菜单选项
|
|
if (dlg.IsLockAngle()) // cet 2012.3.16 add 根据当前刻度重新绘制角度盘
|
|
{
|
|
jig.SetWatchAngle(45);
|
|
jig.RedrawWatch();
|
|
}
|
|
}
|
|
else if(nKeyIndex==3){ //选取行向线
|
|
// cet 2012.3.16 禁用角度盘
|
|
dlg.EnableLockAngle(FALSE);
|
|
dlg.UpdateData(FALSE);
|
|
jig.m_iUnit = 0.0;
|
|
|
|
double s_angle(0);
|
|
int err_value=get_line_angle(s_angle);
|
|
if(err_value == RTNORM){
|
|
if(s_angle > (PI+0.001))
|
|
s_angle -= PI;
|
|
jig.m_ptRef = ptPick1;
|
|
jig.m_nLockAng = s_angle;
|
|
jig.m_bLock = FALSE;
|
|
}
|
|
}
|
|
else if(nKeyIndex==4){ //弧
|
|
vt = AcGeVector3d::kXAxis; // cet 2011.8.1 add
|
|
vt.rotateBy(Ucs2Wcs(0.0), AcGeVector3d::kZAxis); // cet 2011.8.2 add
|
|
XPoint ptArcEnd, ptArcMid, ptPick0, ptArcEnd0;
|
|
if(ads_getpoint(Wcs2Ucs(ptPick1), _T("\n弧线终点<退出>:"), ptArcEnd) != RTNORM)
|
|
break;
|
|
ptArcEnd = Ucs2Wcs(ptArcEnd);
|
|
ptArcEnd.z = 0;
|
|
ptPick1.z = 0;
|
|
ptPick0 = ptPick1;
|
|
ptArcEnd0 = ptArcEnd;
|
|
TPipeEdJig jig2(ptPick0, ptArcEnd);
|
|
jig2.SetPrompt(_T("\n点取弧上一点:"));
|
|
if(jig2.DoIt() != RTNORM){
|
|
dlg.DestroyWindow();
|
|
break;
|
|
}
|
|
ptArcMid = jig2.GetPickPoint();
|
|
dlg.UpdateData(TRUE);
|
|
nElevation = _tstof(dlg.m_csEle)*dMeter;
|
|
ptPick1.z = nElevation;
|
|
ptArcEnd.z = nElevation;
|
|
|
|
InitPipeLayer(dlg.GetLayer());
|
|
int iPipeIdx = GetPipeLayerIdxByName(dlg.GetLayer());
|
|
CString csMat = GetPipeMaterialByIdx(g_iPipeMaterial[iPipeIdx]);
|
|
CString csDnHead = GetDnByMat(csMat);
|
|
|
|
|
|
TDbPipe *pPipe = new TDbPipe;
|
|
XArc arc(ptPick0, ptArcMid, ptArcEnd0);
|
|
XPoint ptArcS, ptArcE;
|
|
arc.GetStartPoint(ptArcS);
|
|
arc.GetEndPoint(ptArcE);
|
|
|
|
//2009-1-8 支持弧管置上置下
|
|
int up(0), low(0);
|
|
BOOL ret = GetInterArcPipeLevel(arc, nElevation, up, low);
|
|
if(dlg.m_iPlace == 0 && ret){
|
|
if(up != 256)
|
|
pPipe->SetHideLevel(up);
|
|
else
|
|
pPipe->SetHideLevel(low);
|
|
}
|
|
else if(dlg.m_iPlace == 1 && ret){
|
|
if(up != 256)
|
|
pPipe->SetHideLevel(up+1);
|
|
else
|
|
pPipe->SetHideLevel(low+1);
|
|
}
|
|
else if(dlg.m_iPlace == 2 && ret)
|
|
pPipe->SetHideLevel(low-1);
|
|
else
|
|
pPipe->SetHideLevel(0);
|
|
|
|
|
|
if(ptPick0 == ptArcS)
|
|
pPipe->SetPoints(ptPick1, ptArcEnd, arc.Bulge());
|
|
else
|
|
pPipe->SetPoints(ptArcEnd, ptPick1, arc.Bulge());
|
|
// if(ptPick0 == ptArcS) sr 2009-1-8 用下面的方法,offset是反的
|
|
// pPipe->SetPoints(ptPick1, ptArcEnd, arc.Bulge());
|
|
// else
|
|
// pPipe->SetPoints(ptPick1, ptArcEnd, -arc.Bulge());
|
|
pPipe->setLayer(dlg.GetLayer());
|
|
pPipe->SetLabel(csDnType);
|
|
pPipe->setLinetype(GetPipeWireLayLineType(dlg.GetLayer()));
|
|
pPipe->SetModelType(TPipeSys::kModel);
|
|
pPipe->SetLabel(csDnHead);
|
|
pPipe->SetMaterial(g_iPipeMaterial[iPipeIdx]);
|
|
pPipe->SetPipeWeight(g_nPipeWidth[iPipeIdx]);
|
|
pPipe->SetSysType(dlg.GetPipeSysType());
|
|
pPipe->SetRadius(g_nPipeRadius[iPipeIdx]);
|
|
pPipe->SetDnDiameter(_ttoi(dlg.m_csDn));
|
|
pPipe->setColor(AcCmColor()); //随层
|
|
AddToCurrentSpace(pPipe, Adesk::kTrue);
|
|
ptPick1 = ptArcEnd;
|
|
ptJig = ptArcEnd;
|
|
ptJig.z = 0;
|
|
jig.SetStartPoint(ptJig);
|
|
TPipePerDocData *pData = GetCurPipeDocData();
|
|
pData->ApplyUpdates();
|
|
}
|
|
else if(nKeyIndex==5){
|
|
int len = lstPt.Length();
|
|
if(len == 1) continue; //最后一个, 不能再退了
|
|
SHads_command(RTSTR, _T("UNDO"), RTSTR, _T("BACK"), RTNONE);
|
|
lstPt.Remove(len - 1);
|
|
XPoint ptTemp = *lstPt[len - 2];
|
|
jig.SetStartPoint(ptTemp);
|
|
ptPick1 = ptTemp;
|
|
acedRedraw(NULL, 0); // cet 2012.3.16 add 刷新
|
|
}
|
|
else if(nKeyIndex==6){//J jig.SetKeyword(_T("A S D G R U J W Y Z F X H V"));
|
|
dlg.UpdateData(TRUE);
|
|
dlg.m_iPipeType = 0;
|
|
dlg.UpdateData(FALSE);
|
|
continue;
|
|
}
|
|
else if(nKeyIndex==7){//W
|
|
dlg.UpdateData(TRUE);
|
|
dlg.m_iPipeType = 3;
|
|
dlg.UpdateData(FALSE);
|
|
continue;
|
|
}
|
|
else if(nKeyIndex==8){//Y
|
|
dlg.UpdateData(TRUE);
|
|
dlg.m_iPipeType = 5;
|
|
dlg.UpdateData(FALSE);
|
|
continue;
|
|
}
|
|
else if(nKeyIndex==9){//Z
|
|
dlg.UpdateData(TRUE);
|
|
dlg.m_iPipeType = 6;
|
|
dlg.UpdateData(FALSE);
|
|
continue;
|
|
}
|
|
else if(nKeyIndex==10){//F
|
|
dlg.UpdateData(TRUE);
|
|
dlg.m_iPipeType = 4;
|
|
dlg.UpdateData(FALSE);
|
|
continue;
|
|
}
|
|
else if(nKeyIndex==11){//X
|
|
dlg.UpdateData(TRUE);
|
|
dlg.m_iPipeType = 7;
|
|
dlg.UpdateData(FALSE);
|
|
continue;
|
|
}
|
|
else if(nKeyIndex==12){//H
|
|
dlg.UpdateData(TRUE);
|
|
dlg.m_iPipeType = 8;
|
|
dlg.UpdateData(FALSE);
|
|
continue;
|
|
}
|
|
else if (nKeyIndex == 15)//T 轴锁其他角度值设置 cet 2012.3.16 add
|
|
{
|
|
dlg.UpdateData(TRUE);
|
|
if (dlg.IsLockAngle())
|
|
{
|
|
double dAngle = dlg.GetAngleFromMenu();
|
|
jig.m_iUnit = dAngle;
|
|
jig.SetWatchAngle(dAngle); // 重新设置角度盘角度
|
|
jig.RedrawWatch(); // 根据当前刻度重新绘制角度盘
|
|
}
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
dlg.DestroyWindow();
|
|
acedRedraw(NULL, 0); // cet 2011.8.1 add 刷新
|
|
}
|
|
|
|
//***************************************************************************************************
|
|
// 绘制多管
|
|
//***************************************************************************************************
|
|
XPoint GetMidPtByLst(XPointList &lstPtIn)
|
|
{
|
|
XPoint ptRet;
|
|
int iNum = lstPtIn.Length();
|
|
double nLong(0);
|
|
for(int i=0; i<iNum-1; i++){
|
|
XPoint ptTmp1 = *lstPtIn[i];
|
|
for(int j=0; j<iNum; j++){
|
|
XPoint ptTmp2 = *lstPtIn[j];
|
|
XLine line(ptTmp1, ptTmp2, 1);
|
|
if(line.GetLength() > nLong){
|
|
line.MidPoint(ptRet);
|
|
nLong = line.GetLength();
|
|
}
|
|
}
|
|
}
|
|
return ptRet;
|
|
}
|
|
|
|
XPoint GetNearPtByLst(XPoint pt, XPointList &lstPtIn)
|
|
{
|
|
pt.z = 0;
|
|
XPoint ptRet;
|
|
int iNum = lstPtIn.Length();
|
|
double nLong(-1);
|
|
for(int i=0; i<iNum; i++){
|
|
XPoint ptTmp = *lstPtIn[i];
|
|
ptTmp.z = 0;
|
|
double n = ads_distance(pt, ptTmp);
|
|
if(nLong < 0 || nLong > n){
|
|
nLong = n;
|
|
ptRet = ptTmp;
|
|
}
|
|
}
|
|
return ptRet;
|
|
}
|
|
|
|
BOOL LstDemoDisplayPoint(XPointList &lstPtIn, XPointList &lstPtOut, double dAngle, BOOL bFree = FALSE)
|
|
{
|
|
int itype;
|
|
double dAng, dDis;
|
|
XPoint ptStart, ptEnd, ptTurn, ptstart, ptend, ptMid;
|
|
XPointList lstStart, lstEnd;
|
|
int iNum = lstPtIn.Length();
|
|
|
|
|
|
int nOsMode=0;
|
|
xg_getvar(_T("ORTHOMODE"), &nOsMode);
|
|
|
|
XPointList lstTmp;
|
|
BOOL bFisrt = TRUE;
|
|
while(1){
|
|
struct resbuf pointbuf;
|
|
int iRet = ads_grread(5, &itype, &pointbuf);//得到动态点pointbuf
|
|
ads_point_set(pointbuf.resval.rpoint, ptEnd);//ptTurn动态点,也就是引出支线的结束点
|
|
if(itype != 5 && bFisrt)
|
|
continue;
|
|
ads_redraw(NULL, 1); //不画线演示
|
|
if(itype == 11 || itype == 2) // 11右键取消 2:空格,回车
|
|
return FALSE;
|
|
else if(itype == 5 || itype == 3){
|
|
lstStart.Reset();
|
|
lstEnd.Reset();
|
|
bFisrt = FALSE;
|
|
ptMid = GetNearPtByLst(ptEnd, lstPtIn);
|
|
dAng = ads_angle(ptMid, ptEnd);
|
|
dDis = fabs(ads_distance(ptMid, ptEnd));
|
|
|
|
XPoint ptEndTmp = ptEnd;
|
|
if(bFree && nOsMode == 1){//实现正交
|
|
int Ang = (int)Radian2Angle(dAng);
|
|
int nTmp = Ang % 90;
|
|
int multiple = Ang / 90;
|
|
if(nTmp > 45){
|
|
dAng = 90 * (multiple + 1);
|
|
}
|
|
else{
|
|
dAng = 90 * multiple;
|
|
}
|
|
dAng = dAng / 180 * PI;
|
|
dDis = fabs(ads_distance(ptMid, ptEnd)*cos(ads_angle(ptMid, ptEnd) - dAng));
|
|
ads_polar(ptMid, dAng, dDis, ptEndTmp);
|
|
}
|
|
|
|
|
|
for(int i=0; i<iNum; i++){
|
|
ptTurn = *lstPtIn[i];//ptTurn引出线起点
|
|
if(!bFree){
|
|
XPoint ptEndTmp;
|
|
int Ang = (int)Radian2Angle(dAng);
|
|
int nTmp = Ang % 90;
|
|
int multiple = Ang / 90;
|
|
if(nTmp > 45){
|
|
dAng = 90 * (multiple + 1);
|
|
}
|
|
else{
|
|
dAng = 90 * multiple;
|
|
}
|
|
dAng = dAng / 180 * PI;
|
|
dDis = fabs(ads_distance(ptTurn, ptEnd)*cos(ads_angle(ptTurn, ptEnd) - dAng));
|
|
ads_polar(ptTurn, dAng, dDis, ptEndTmp);
|
|
|
|
if(itype == 5)
|
|
ads_grdraw(ptTurn, ptEndTmp, -1, 0); //演示
|
|
else
|
|
lstPtOut.NewAppend(ptEndTmp);
|
|
}
|
|
else{
|
|
XPoint ptTmpEnd = ptEndTmp;
|
|
double nAngTmp = dAng;
|
|
if(ptMid != ptTurn){
|
|
double n = ads_distance(ptTurn, ptMid); //2管线距离
|
|
double nAn = ads_angle(ptMid, ptTurn);
|
|
if(fabs(nAn - PI*2) < 0.001 || nAn > PI*2)
|
|
nAn -= PI*2;
|
|
|
|
if(dAngle < (PI/2-1) || dAngle > PI/2*3 || fabs(dAngle - PI/2*3) < 0.001){
|
|
if(nAn < PI)
|
|
nAngTmp += PI/2;
|
|
else
|
|
nAngTmp -= PI/2;
|
|
}
|
|
else{
|
|
if(nAn > PI || fabs(nAn - PI) < 0.001)
|
|
nAngTmp += PI/2;
|
|
else
|
|
nAngTmp -= PI/2;
|
|
}
|
|
|
|
if(nAngTmp > PI*2)
|
|
nAngTmp -= PI*2;
|
|
ads_polar(ptEndTmp, nAngTmp, n, ptTmpEnd);
|
|
ads_polar(ptMid, nAngTmp, n, ptTurn);
|
|
}
|
|
if(itype == 5)
|
|
ads_grdraw(ptTurn, ptTmpEnd, -1, 0); //演示
|
|
else{
|
|
lstTmp.NewAppend(ptTurn);
|
|
lstPtOut.NewAppend(ptTmpEnd);
|
|
}
|
|
}
|
|
}
|
|
if(itype == 3){
|
|
if(bFree){
|
|
lstPtIn.Reset();
|
|
lstPtIn = lstTmp;
|
|
}
|
|
return TRUE;
|
|
}
|
|
}
|
|
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
void DrawSuperposablePipe(CPipeVMultDrawDlg *pDlg)
|
|
{
|
|
XPoint ptStart, ptEnd;
|
|
if(ads_getpoint(NULL, _T("\n请点取起点<退出>:"), ptStart) != RTNORM)
|
|
return;
|
|
ptStart = Ucs2Wcs(ptStart);
|
|
while(1){
|
|
if(ads_getpoint(ptStart, _T("\n请点取终点<退出>:"), ptEnd) != RTNORM)
|
|
return;
|
|
|
|
for(pDlg->m_grid.MoveToFirst(); !pDlg->m_grid.IsOut(); pDlg->m_grid.MoveToNext()){
|
|
WDGridRow *pRow = pDlg->m_grid.CurRow();
|
|
CString csPipe = (*pRow)[0].GetText().cs();
|
|
CString csDist = (*pRow)[1].GetText().cs();
|
|
CString csEle = (*pRow)[2].GetText().cs();
|
|
|
|
int idx(0);
|
|
if(csPipe == _T("给水"))
|
|
idx = 0;
|
|
else if(csPipe == _T("热给水"))
|
|
idx = 1;
|
|
else if(csPipe == _T("热回水"))
|
|
idx = 2;
|
|
else if(csPipe == _T("污水"))
|
|
idx = 3;
|
|
else if(csPipe == _T("废水"))
|
|
idx = 4;
|
|
else if(csPipe == _T("中水"))
|
|
idx = 6;
|
|
else if(csPipe == _T("消防"))
|
|
idx = 7;
|
|
else if(csPipe == _T("喷淋"))
|
|
idx = 8;
|
|
else if(csPipe == g_csPipeName[0])
|
|
idx = 9;
|
|
else if(csPipe == g_csPipeName[1])
|
|
idx = 10;
|
|
else if(csPipe == g_csPipeName[2])
|
|
idx = 11;
|
|
else if(csPipe == g_csPipeName[3])
|
|
idx = 12;
|
|
else if(csPipe == g_csPipeName[4])
|
|
idx = 13;
|
|
else if(csPipe == _T("其它"))
|
|
idx = 14;
|
|
CString csMat = GetPipeMaterialByIdx(g_iPipeMaterial[idx]);
|
|
CString csDnHead = GetDnByMat(csMat);
|
|
|
|
TDbPipe *pPipe=new TDbPipe;
|
|
ptStart.z = _tstof(csEle)*1000;
|
|
ptEnd.z = _tstof(csEle)*1000;
|
|
pPipe->SetStartPoint(ptStart);
|
|
pPipe->SetEndPoint(ptEnd);
|
|
InitPipeLayer(GetPipeLayerByIdx(idx));
|
|
pPipe->setLayer(GetPipeLayerByIdx(idx));
|
|
pPipe->setLinetype(GetPipeWireLayLineType(GetPipeLayerByIdx(idx)));
|
|
pPipe->SetModelType(TPipeSys::kModel);
|
|
pPipe->SetLabel(csDnHead);
|
|
pPipe->SetDnDiameter(g_iDefaultPipeDn);
|
|
pPipe->SetMaterial(g_iPipeMaterial[idx]);
|
|
pPipe->SetPipeWeight(g_nPipeWidth[idx]);
|
|
pPipe->SetRadius(g_nPipeRadius[idx]);
|
|
if(g_bPipeDouble[idx])
|
|
pPipe->SetRadiusIn(g_nPipeRadius[idx] / 2);
|
|
pPipe->setColor(AcCmColor()); //随层
|
|
AcDbObjectId id = AddToCurrentSpace(pPipe, Adesk::kTrue);
|
|
}
|
|
ptStart = ptEnd;
|
|
}
|
|
}
|
|
|
|
//已知管线类别INDEX,返回立管线图层名称
|
|
CString GetVPipeLayerByIdx(int iLayer)
|
|
{
|
|
//if(iLayer > 29 || iLayer < 0)
|
|
if(iLayer > 34 || iLayer < 0)
|
|
return CString();
|
|
CString csLayer[] = {LAY_VPIPE_FEED, LAY_VPIPE_HEADFEED, LAY_VPIPE_HEADBACK, LAY_VPIPE_DIRT,
|
|
LAY_VPIPE_USELESS, LAY_VPIPE_RAIN, LAY_VPIPE_USED, LAY_VPIPE_FIRE, LAY_VPIPE_SPRINKLE,
|
|
LAY_VPIPE_COAGULATE, LAY_VPIPE_DRINK, LAY_VPIPE_PRESSDIRT, LAY_VPIPE_PRESSUSELESS,
|
|
LAY_VPIPE_PRESSRAIN, LAY_VPIPE_OTHER, LAY_VPIPE_USER1, LAY_VPIPE_USER2,
|
|
LAY_VPIPE_FEED2,LAY_VPIPE_FEED3, LAY_VPIPE_HEADFEED2,LAY_VPIPE_HEADFEED3,
|
|
LAY_VPIPE_HEADBACK2,LAY_VPIPE_HEADBACK3,LAY_VPIPE_FIRE2,LAY_VPIPE_FIRE3,
|
|
LAY_VPIPE_SPRINKLE2,LAY_VPIPE_SPRINKLE3,LAY_VPIPE_USED2,LAY_VPIPE_USED3,
|
|
LAY_VPIPE_USER3, LAY_VPIPE_USER4, LAY_VPIPE_USER5, LAY_VPIPE_USER6, LAY_VPIPE_USER7, // cet 2011.12.8 add user3-user8
|
|
LAY_VPIPE_USER8
|
|
};
|
|
return csLayer[iLayer];
|
|
}
|
|
|
|
// zxl 2013.04.17 add 通过立管图层获取该管线图层名
|
|
CString GetLayerName(const CString &strLayer)
|
|
{
|
|
CString sName;
|
|
if (strLayer.Compare(LAY_VPIPE_FEED) == 0) //给水
|
|
{
|
|
sName = _T("给水管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_FEED2) == 0) //给水中
|
|
{
|
|
sName = _T("给水中区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_FEED3) == 0) //给水高
|
|
{
|
|
sName = _T("给水高区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_HEADFEED) == 0) //热给水
|
|
{
|
|
sName = _T("热给水管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_HEADFEED2) == 0)
|
|
{
|
|
sName = _T("热给水中区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_HEADFEED3) == 0)
|
|
{
|
|
sName = _T("热给水高区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_HEADBACK) == 0) //热回水
|
|
{
|
|
sName = _T("热回水管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_HEADBACK2) == 0) //热回水
|
|
{
|
|
sName = _T("热回水中区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_HEADBACK3) == 0) //热回水
|
|
{
|
|
sName = _T("热回水高区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_DIRT) == 0) //污水
|
|
{
|
|
sName = _T("污水管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_USELESS) == 0) //废水
|
|
{
|
|
sName = _T("废水管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_RAIN) == 0) //雨水
|
|
{
|
|
sName = _T("雨水管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_USED) == 0) //中水
|
|
{
|
|
sName = _T("中水管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_USED2) == 0) //中水
|
|
{
|
|
sName = _T("中水中区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_USED3) == 0) //中水
|
|
{
|
|
sName = _T("中水高区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_FIRE) == 0) //消防
|
|
{
|
|
sName = _T("消防管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_FIRE2) == 0) //消防
|
|
{
|
|
sName = _T("消防中区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_FIRE3) == 0) //消防
|
|
{
|
|
sName = _T("消防高区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_SPRINKLE) == 0) //喷淋
|
|
{
|
|
sName = _T("喷淋管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_SPRINKLE2) == 0) //喷淋
|
|
{
|
|
sName = _T("喷淋中区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_SPRINKLE3) == 0) //喷淋
|
|
{
|
|
sName = _T("喷淋高区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_COAGULATE) == 0) //凝结水
|
|
{
|
|
GetLayerReMark(LAY_PIPE_COAGULATE, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("凝结水管");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("水管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_DRINK) == 0) //直饮水
|
|
{
|
|
GetLayerReMark(LAY_PIPE_DRINK, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("直饮水管");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("水管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_PRESSDIRT) == 0) //压力污水
|
|
{
|
|
GetLayerReMark(LAY_PIPE_PRESSDIRT, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("压力污水管");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("水管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_PRESSUSELESS) == 0) //压力废水
|
|
{
|
|
GetLayerReMark(LAY_PIPE_PRESSUSELESS, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("压力废水管");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("水管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_PRESSRAIN) == 0) //压力雨水
|
|
{
|
|
GetLayerReMark(LAY_PIPE_PRESSRAIN, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("压力雨水管");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("水管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_OTHER) == 0) //其他
|
|
{
|
|
sName = _T("其它管");
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_USER1) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER1, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用1管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_USER2) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER2, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用户2管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_USER3) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER3, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用户3管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_USER4) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER4, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用户4管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_USER5) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER5, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用户5管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_USER6) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER6, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用户6管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_USER7) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER7, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用户7管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_VPIPE_USER8) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER8, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用户8管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
|
|
return sName;
|
|
}
|
|
|
|
// zxl 2013.04.23 add 通过管线图层获取该管线图层名
|
|
CString GetPipeLayerName(const CString &strLayer)
|
|
{
|
|
CString sName;
|
|
if (strLayer.Compare(LAY_PIPE_FEED) == 0) //给水
|
|
{
|
|
sName = _T("给水管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_FEED2) == 0) //给水中
|
|
{
|
|
sName = _T("给水中区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_FEED3) == 0) //给水高
|
|
{
|
|
sName = _T("给水高区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_HEADFEED) == 0) //热给水
|
|
{
|
|
sName = _T("热给水管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_HEADFEED2) == 0)
|
|
{
|
|
sName = _T("热给水中区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_HEADFEED3) == 0)
|
|
{
|
|
sName = _T("热给水高区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_HEADBACK) == 0) //热回水
|
|
{
|
|
sName = _T("热回水管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_HEADBACK2) == 0) //热回水
|
|
{
|
|
sName = _T("热回水中区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_HEADBACK3) == 0) //热回水
|
|
{
|
|
sName = _T("热回水高区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_DIRT) == 0) //污水
|
|
{
|
|
sName = _T("污水管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_USELESS) == 0) //废水
|
|
{
|
|
sName = _T("废水管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_RAIN) == 0) //雨水
|
|
{
|
|
sName = _T("雨水管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_USED) == 0) //中水
|
|
{
|
|
sName = _T("中水管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_USED2) == 0) //中水
|
|
{
|
|
sName = _T("中水中区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_USED3) == 0) //中水
|
|
{
|
|
sName = _T("中水高区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_FIRE) == 0) //消防
|
|
{
|
|
sName = _T("消防管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_FIRE2) == 0) //消防
|
|
{
|
|
sName = _T("消防中区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_FIRE3) == 0) //消防
|
|
{
|
|
sName = _T("消防高区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_SPRINKLE) == 0) //喷淋
|
|
{
|
|
sName = _T("喷淋管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_SPRINKLE2) == 0) //喷淋
|
|
{
|
|
sName = _T("喷淋中区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_SPRINKLE3) == 0) //喷淋
|
|
{
|
|
sName = _T("喷淋高区管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_COAGULATE) == 0) //凝结水
|
|
{
|
|
GetLayerReMark(LAY_PIPE_COAGULATE, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("凝结水管");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("水管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_DRINK) == 0) //直饮水
|
|
{
|
|
GetLayerReMark(LAY_PIPE_DRINK, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("直饮水管");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("水管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_PRESSDIRT) == 0) //压力污水
|
|
{
|
|
GetLayerReMark(LAY_PIPE_PRESSDIRT, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("压力污水管");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("水管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_PRESSUSELESS) == 0) //压力废水
|
|
{
|
|
GetLayerReMark(LAY_PIPE_PRESSUSELESS, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("压力废水管");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("水管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_PRESSRAIN) == 0) //压力雨水
|
|
{
|
|
GetLayerReMark(LAY_PIPE_PRESSRAIN, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("压力雨水管");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("水管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_OTHER) == 0) //其他
|
|
{
|
|
sName = _T("其它管");
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_USER1) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER1, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用1管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_USER2) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER2, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用户2管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_USER3) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER3, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用户3管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_USER4) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER4, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用户4管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_USER5) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER5, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用户5管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_USER6) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER6, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用户6管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_USER7) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER7, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用户7管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
else if (strLayer.Compare(LAY_PIPE_USER8) == 0)
|
|
{
|
|
GetLayerReMark(LAY_PIPE_USER8, sName);
|
|
if (sName.IsEmpty())
|
|
{
|
|
sName = _T("用户8管线");
|
|
}
|
|
else
|
|
{
|
|
sName += _T("管");
|
|
}
|
|
}
|
|
|
|
return sName;
|
|
}
|
|
|
|
// 立管信息 zxl 2013.04.17 add
|
|
struct VPipeInfo
|
|
{
|
|
Entity ent;
|
|
AcGePoint3d pt;
|
|
};
|
|
|
|
// 点在XOY平面排序 zxl 2013.04.17 add
|
|
// 排序规则:先在Y轴从大到小排序,Y轴相同时,按X轴从小到大排序
|
|
bool Less(VPipeInfo &info1, VPipeInfo &info2)
|
|
{
|
|
bool bVal = false;
|
|
XPoint pt1 = info1.pt, pt2 = info2.pt;
|
|
if (pt1.y > pt2.y)
|
|
{
|
|
bVal = true;
|
|
}
|
|
else if (fabs(pt1.y - pt2.y) < 1e-3 && pt1.x < pt2.x)
|
|
{
|
|
bVal = true;
|
|
}
|
|
return bVal;
|
|
}
|
|
|
|
// 立管在XOY平面排序 zxl 2013.04.17 add
|
|
void SortVPipe(PickSet &ss)
|
|
{
|
|
std::vector<VPipeInfo> vec;
|
|
for(long i=0;i<ss.Length();i++)
|
|
{
|
|
Entity ent = ss[i];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe)
|
|
{
|
|
if(pPipe->IsVertical())
|
|
{
|
|
VPipeInfo info;
|
|
info.ent = ent;
|
|
info.pt = pPipe->StartPoint();
|
|
std::vector<VPipeInfo>::iterator it;
|
|
for (it = vec.begin(); it != vec.end(); it++)
|
|
{
|
|
XPoint pt1, pt2;
|
|
pt1 = info.pt;
|
|
pt2 = (*it).pt;
|
|
if (pt1.Distance2d(pt2) < 1e-3)
|
|
{
|
|
if (pt1.z > pt2.z)
|
|
{
|
|
(*it).ent = ent;
|
|
(*it).pt = info.pt;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
if (it == vec.end())
|
|
{
|
|
vec.push_back(info);
|
|
}
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
if (vec.empty())
|
|
{
|
|
return;
|
|
}
|
|
PickSet ssVpipe(SS_FREE);
|
|
std::sort(vec.begin(), vec.end(), ::Less);
|
|
std::vector<VPipeInfo>::iterator it;
|
|
for (it = vec.begin(); it != vec.end(); it++)
|
|
{
|
|
ssVpipe += (*it).ent;
|
|
}
|
|
|
|
if (ssVpipe.Length() > 0)
|
|
{
|
|
ss.Free();
|
|
ss+=ssVpipe;
|
|
}
|
|
}
|
|
|
|
// 搜索经过pt点的管线,若多于一条,返回标高最小的管线 zxl 2013.04.23 add
|
|
Entity GetPipeByPt(XPoint pt, int &iPipeSys)
|
|
{
|
|
RBList rbMaskPipe(RTDXF0, _T("ATS_PIPE"), 8, GetLayerNames(_T("管线")), NULL);
|
|
PickSet ss(SS_FREE);
|
|
XPoint ptUcs = Wcs2Ucs(pt);
|
|
GetPointPickSet(ptUcs, ss, rbMaskPipe, (int)(DocGetPScale()/2));
|
|
double len = ss.Length();
|
|
if(len == 0)
|
|
return Entity();
|
|
else if(len > 1){
|
|
GetPointPickSet(ptUcs, ss, rbMaskPipe, (int)(DocGetPScale()/4));
|
|
}
|
|
|
|
double dElev = 0.0;
|
|
Entity entPipeSel = ss[0l];
|
|
int iPos = 0;
|
|
for (long l = 0l; l < ss.Length(); l++)
|
|
{
|
|
Entity entPipe = ss[l];
|
|
OPENOBJ_BEGIN(entPipe, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe && !pPipe->IsVertical())
|
|
{
|
|
double dEle = pPipe->StartPoint().z;
|
|
if (l == 0l)
|
|
{
|
|
dElev = dEle;
|
|
TPipeSys::SysType sys = pPipe->GetSysType();
|
|
CString csLay = pPipe->GetLayer();
|
|
iPipeSys = GetPipeDlgIdxByName(csLay, iPos);
|
|
}
|
|
else if (dElev > dEle)
|
|
{
|
|
TPipeSys::SysType sys = pPipe->GetSysType();
|
|
CString csLay = pPipe->GetLayer();
|
|
iPipeSys = GetPipeDlgIdxByName(csLay, iPos);
|
|
dElev = dEle;
|
|
entPipeSel = entPipe;
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
return entPipeSel;
|
|
}
|
|
|
|
// 延长立管到接管标高处 zxl 2013.04.17 add
|
|
void ModifyPipePt(const AcGePoint3d &pt, TDbPipe * const pPipe)
|
|
{
|
|
AcGePoint3d ptS, ptE;
|
|
ptS = pPipe->StartPoint();
|
|
ptE = pPipe->EndPoint();
|
|
double dDist1 = pt.distanceTo(ptS);
|
|
double dDist2 = pt.distanceTo(ptE);
|
|
double dLen = ptS.distanceTo(ptE);
|
|
|
|
if(pPipe->upgradeOpen()==Acad::eOk)
|
|
{
|
|
if (fabs(dLen + dDist2 - dDist1) < 1e-3)// 从立管末端延长
|
|
{
|
|
pPipe->SetEndPoint(pt);
|
|
}
|
|
else if (fabs(dLen + dDist1 - dDist2) < 1e-3)// 从立管起始端延长
|
|
{
|
|
pPipe->SetStartPoint(pt);
|
|
}
|
|
pPipe->downgradeOpen();
|
|
}
|
|
}
|
|
|
|
void DrawMutiPipe()
|
|
{
|
|
g_ssPickFirst.Free();
|
|
// zxl 2013.10.15 add 消除UNDO命令行提示
|
|
xg_setvar(_T("CMDECHO"), 0);
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
if(g_bTgOsnap)
|
|
{
|
|
nOsMode &= ~0x4000;
|
|
nOsMode |= OS_INT|OS_NEA|OS_PER|OS_END|OS_CEN;
|
|
}
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
|
|
bool bModifyElev = false;// zxl 2013.04.17 add
|
|
RBList rbMask(RTDXF0, _T("ATS_PIPE"), 8, GetLayerNames(_T("管")), NULL);
|
|
PickSet ss(SS_FREE);
|
|
if(SelectEntities(_T("\n请选择需要引出的立管或管线: <新绘制>"), ss, rbMask) != RTNORM){
|
|
bModifyElev = true;// zxl 2013.04.17 add
|
|
CTemporaryResourceOverride vTemp;
|
|
CPipeVMultDrawDlg dlg;
|
|
if(dlg.DoModal() != IDOK)
|
|
return;
|
|
if(dlg.m_grid.GetRowNum() < 2)
|
|
return;
|
|
if(dlg.m_bIsSuperposable){
|
|
DrawSuperposablePipe(&dlg);
|
|
return;
|
|
}
|
|
XPoint ptIns, ptEnd, ptUcs;
|
|
TPipeEdJig jig(ptIns, 0.5);
|
|
jig.SetPrompt(_T("\n请点选基点(第一个立管的位置)<退出>:"));
|
|
if(jig.DoIt()!=RTNORM)
|
|
return;
|
|
ptIns = jig.GetPickPoint();
|
|
ptUcs = Wcs2Ucs(ptIns);
|
|
if(ads_getpoint(ptUcs, _T("\n请点选方向<退出>:"), ptEnd) != RTNORM)
|
|
return;
|
|
ptEnd = Ucs2Wcs(ptEnd);
|
|
double nAngle = ads_angle(ptIns, ptEnd);
|
|
for(dlg.m_grid.MoveToFirst(); !dlg.m_grid.IsOut(); dlg.m_grid.MoveToNext()){
|
|
WDGridRow *pRow = dlg.m_grid.CurRow();
|
|
CString csPipe = (*pRow)[0].GetText().cs();
|
|
CString csDist = (*pRow)[1].GetText().cs();
|
|
CString csEle = (*pRow)[2].GetText().cs();
|
|
ads_polar(ptIns, nAngle, _tstof(csDist), ptIns);
|
|
int idx(0);
|
|
/* cet 2011.12.9 add
|
|
if(csPipe == _T("给水"))
|
|
idx = 0;
|
|
else if(csPipe == _T("热给水"))
|
|
idx = 1;
|
|
else if(csPipe == _T("热回水"))
|
|
idx = 2;
|
|
else if(csPipe == _T("污水"))
|
|
idx = 3;
|
|
else if(csPipe == _T("废水"))
|
|
idx = 4;
|
|
else if(csPipe == _T("中水"))
|
|
idx = 6;
|
|
else if(csPipe == _T("消防"))
|
|
idx = 7;
|
|
else if(csPipe == _T("喷淋"))
|
|
idx = 8;
|
|
else if(csPipe == g_csPipeName[0])
|
|
idx = 9;
|
|
else if(csPipe == g_csPipeName[1])
|
|
idx = 10;
|
|
else if(csPipe == g_csPipeName[2])
|
|
idx = 11;
|
|
else if(csPipe == g_csPipeName[3])
|
|
idx = 12;
|
|
else if(csPipe == g_csPipeName[4])
|
|
idx = 13;
|
|
else if(csPipe == _T("其它"))
|
|
idx = 14;
|
|
*/
|
|
idx = dlg.GetPipeIdxByPipeName(csPipe);
|
|
|
|
CString csMat = GetPipeMaterialByIdx(g_iPipeMaterial[idx]);
|
|
CString csDnHead = GetDnByMat(csMat);
|
|
|
|
TDbPipe *pPipe=new TDbPipe;
|
|
ptIns.z = _tstof(csEle)*1000;
|
|
pPipe->SetStartPoint(ptIns);
|
|
ptIns.z += 3000;
|
|
pPipe->SetEndPoint(ptIns);
|
|
InitPipeLayer(GetVPipeLayerByIdx(idx));
|
|
pPipe->setLayer(GetVPipeLayerByIdx(idx));
|
|
pPipe->setLinetype(GetPipeWireLayLineType(GetPipeLayerByIdx(idx)));
|
|
pPipe->SetModelType(TPipeSys::kModel);
|
|
pPipe->SetSysType(GetPipeSysByLayer(GetPipeLayerByIdx(idx)));
|
|
pPipe->SetDnDiameter(g_iDefaultPipeDn);
|
|
pPipe->SetMaterial(g_iPipeMaterial[idx]);
|
|
pPipe->SetPipeWeight(g_nPipeWidth[idx]);
|
|
pPipe->SetRadius(g_nPipeRadius[idx]);
|
|
pPipe->SetLabel(csDnHead);
|
|
if(g_bPipeDouble[idx])
|
|
pPipe->SetRadiusIn(g_nPipeRadius[idx] / 2);
|
|
pPipe->setColor(AcCmColor()); //随层
|
|
AcDbObjectId id = AddToCurrentSpace(pPipe, Adesk::kTrue);
|
|
ss += id;
|
|
|
|
}
|
|
//return;
|
|
}
|
|
BOOL bFromVerPipe = FALSE;
|
|
XPointList lstPt, lstPtOut;
|
|
double nRotate(-1), nRadius(0);
|
|
ss.Redraw(4);
|
|
SortVPipe(ss);
|
|
for(long i=0;i<ss.Length();i++){
|
|
Entity ent = ss[i];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
if(pPipe->IsVertical()){
|
|
bFromVerPipe = TRUE;
|
|
// lstPt.NewAppend(pPipe->StartPoint());
|
|
// zxl 2013.04.17 add 用户设置管线标高
|
|
PickSet ssSel(SS_FREE);
|
|
if (!bModifyElev)
|
|
{
|
|
ssSel += ent;
|
|
ssSel.Redraw(3);
|
|
AcGePoint3d ptS = pPipe->StartPoint();
|
|
double dOut = ptS.z / 1000;
|
|
CString sPipeName = GetLayerName(pPipe->GetLayer());
|
|
CString sNote;
|
|
sNote.Format(_T("\n请输入%s标高<%.1fm>:"), sPipeName, dOut);
|
|
double dElev = 0.0;
|
|
int nRet = ads_getreal(sNote, &dElev);
|
|
if (nRet == RTNORM)
|
|
{
|
|
ptS.z = dElev * 1000;
|
|
}
|
|
else if (nRet != RTNONE)
|
|
{
|
|
return;
|
|
}
|
|
lstPt.NewAppend(ptS);
|
|
ModifyPipePt(ptS, pPipe);
|
|
ssSel.Redraw(4);
|
|
}
|
|
else
|
|
{
|
|
lstPt.NewAppend(pPipe->StartPoint());
|
|
}
|
|
|
|
if(pPipe->GetRadius() > nRadius)
|
|
nRadius = pPipe->GetRadius();
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
BOOL bFree = FALSE;
|
|
BOOL bFromVer = TRUE;
|
|
|
|
if(lstPt.Length() < 1){//从干管上引出
|
|
bFree = TRUE;
|
|
bFromVer = FALSE;
|
|
XPoint ptPick, ptPick2;
|
|
Entity entSel;
|
|
if(SelectEntity1(g_nCurPipeWidth*DocGetPScale(), _T("\n请选取要引出管线的位置<退出>:"), entSel, ptPick, rbMask)!=RTNORM)
|
|
return;
|
|
if(entSel.In(&ss) == 0)
|
|
return;
|
|
OPENOBJ_BEGIN(entSel, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
if(ptPick == pPipe->EndPoint() || ptPick == pPipe->StartPoint()){
|
|
bFromVer = TRUE;
|
|
nRotate = ads_angle(pPipe->GetStartPoint(), pPipe->GetEndPoint());
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
std::vector<VPipeInfo> vec;
|
|
VPipeInfo info;
|
|
info.ent = entSel;
|
|
info.pt = ptPick;
|
|
vec.push_back(info);
|
|
ss -= entSel;
|
|
// ptPick.z = 0;
|
|
// lstPt.NewAppend(ptPick);
|
|
for(long i=0;i<ss.Length();i++){
|
|
Entity ent = ss[i];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
// XLine line(pPipe->EndPoint(), pPipe->StartPoint());
|
|
// XCurveSegment seg;
|
|
// seg = line;
|
|
// seg.ProjectToMe(ptPick, ptPick2);
|
|
XPoint ptPick3;
|
|
AcDbLine line(pPipe->EndPoint(), pPipe->StartPoint());
|
|
line.getClosestPointTo(ptPick, ptPick2, Adesk::kTrue);
|
|
line.getClosestPointTo(ptPick, ptPick3);
|
|
if (ptPick2.Distance2d(ptPick3) > 1e-3)// 投影点在延长线上
|
|
{
|
|
continue;
|
|
}
|
|
info.ent = ent;
|
|
info.pt = ptPick2;
|
|
|
|
std::vector<VPipeInfo>::iterator it;
|
|
for (it = vec.begin(); it != vec.end(); it++)
|
|
{
|
|
XPoint pt1, pt2;
|
|
pt1 = info.pt;
|
|
pt2 = (*it).pt;
|
|
if (pt1.Distance2d(pt2) < 1e-3)
|
|
{
|
|
if (pt1.z < pt2.z)
|
|
{
|
|
(*it).ent = ent;
|
|
(*it).pt = info.pt;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
if (it == vec.end())
|
|
{
|
|
vec.push_back(info);
|
|
}
|
|
// ptPick2.z = 0;
|
|
// lstPt.NewAppend(ptPick2);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
// zxl 2013.04.23 add 用户输入管线标高
|
|
std::sort(vec.begin(), vec.end(), ::Less);
|
|
std::vector<VPipeInfo>::iterator it;
|
|
for (it = vec.begin(); it != vec.end();)
|
|
{
|
|
XPoint pt;
|
|
pt = (*it).pt;
|
|
PickSet ssPipe(SS_FREE);
|
|
ssPipe += (*it).ent;
|
|
ssPipe.Redraw(3);
|
|
TCHAR szEqLay[256];;
|
|
(*it).ent.GetData(8, &szEqLay);
|
|
CString sPipeName = GetPipeLayerName(szEqLay);
|
|
CString sNote;
|
|
sNote.Format(_T("\n请输入%s标高<%.1fm>:"), sPipeName, pt.z / 1000);
|
|
double dElev = 0.0;
|
|
int nRet = ads_getreal(sNote, &dElev);
|
|
if (nRet == RTNORM)
|
|
{
|
|
pt.z = dElev * 1000;
|
|
(*it).pt.z = pt.z;
|
|
}
|
|
else if (nRet != RTNONE)
|
|
{
|
|
return;
|
|
}
|
|
|
|
ssPipe.Redraw(4);
|
|
if (pt.Distance2d(ptPick) < 1e-3)
|
|
{
|
|
lstPt.NewAppend(pt);
|
|
it = vec.erase(it);
|
|
}
|
|
else
|
|
{
|
|
it++;
|
|
}
|
|
}
|
|
|
|
for (it = vec.begin(); it != vec.end(); it++)
|
|
{
|
|
XPoint pt;
|
|
pt = (*it).pt;
|
|
lstPt.NewAppend(pt);
|
|
}
|
|
}
|
|
InitPipeLayer(LAY_PIPE_FEED);
|
|
XPushVarStr clayer(_T("CLAYER"), LAY_PIPE_FEED);
|
|
CString csPrompt;
|
|
int iMode = 1;
|
|
XPointList lstOld = lstPt;
|
|
XPointList lstOldOld = lstPt;
|
|
double nRotateOld = nRotate;
|
|
BOOL bFromVerPipeFirst = bFromVerPipe;
|
|
// zxl 2013.10.16 add
|
|
std::stack<std::pair<XPointList, double> > stkPtLst;
|
|
bool bUndo = false;
|
|
bool bStart = true;
|
|
bool bInsertPt = true;
|
|
while(1){
|
|
// zxl 2013.10.16 add
|
|
if (!bUndo && bInsertPt)
|
|
{
|
|
stkPtLst.push(std::make_pair(lstPt, nRotate));
|
|
}
|
|
if (stkPtLst.size() > 1)
|
|
{
|
|
bStart = false;
|
|
}
|
|
XPointList lstTmp = lstPt;
|
|
TMultPipeJig jig(lstTmp, nRotate, bFromVerPipe);
|
|
bFromVerPipe = FALSE;
|
|
if(iMode == 0)
|
|
csPrompt.Format(_T("\n请输入终点<退出>[生成四通(S)/管线置上(D)/管线置下(F)/回退(U)]: (当前状态:打断)"));
|
|
else if(iMode == 1)
|
|
csPrompt.Format(_T("\n请输入终点<退出>[生成四通(S)/管线置上(D)/管线置下(F)/回退(U)]: (当前状态:置上)"));
|
|
else if(iMode == 2)
|
|
csPrompt.Format(_T("\n请输入终点<退出>[生成四通(S)/管线置上(D)/管线置下(F)/回退(U)]: (当前状态:置下)"));
|
|
jig.SetPrompt(csPrompt);
|
|
int nKeyIndex;
|
|
jig.SetKeyword(_T("S D F U"));
|
|
int ret = jig.DoIt(&nKeyIndex);
|
|
if(ret == RTKWORD){
|
|
// zxl 2013.10.16 modify 支持连续UNDO到起始处
|
|
// if(nKeyIndex == 3){
|
|
// if(*lstOldOld[0] == *lstPt[0])
|
|
// continue;
|
|
// if(*lstOldOld[0] == *lstOld[0] && bFromVerPipeFirst){
|
|
// bFree = FALSE;
|
|
// bFromVerPipe = TRUE;
|
|
// }
|
|
bInsertPt = false;
|
|
if(nKeyIndex == 3 && !bStart){
|
|
bUndo = true;
|
|
stkPtLst.pop();
|
|
lstOld = (stkPtLst.top()).first;
|
|
nRotateOld = (stkPtLst.top()).second;
|
|
if (*lstOldOld[0] == *lstOld[0])
|
|
{
|
|
bStart = true;
|
|
if (bFromVerPipeFirst)
|
|
{
|
|
bFree = FALSE;
|
|
bFromVerPipe = TRUE;
|
|
}
|
|
}
|
|
|
|
SHads_command(RTSTR, _T("UNDO"), RTSTR, _T("BACK"), RTNONE);
|
|
nRotate = nRotateOld;
|
|
lstPt = lstOld;
|
|
}
|
|
else
|
|
iMode = nKeyIndex;
|
|
continue;
|
|
}
|
|
else if(ret != RTNORM){
|
|
break;
|
|
}
|
|
// zxl 2013.10.16 add
|
|
bUndo = false;
|
|
bInsertPt = true;
|
|
|
|
nRotateOld = nRotate;
|
|
lstPtOut = jig.m_pDrawEnt->m_lstEnd;
|
|
lstPt = jig.m_pDrawEnt->m_lstStart;
|
|
int len = lstPtOut.Length();
|
|
AssureInCurrentView(*lstPtOut[0], *lstTmp[0]);
|
|
AssureInCurrentView(*lstPtOut[len-1], *lstTmp[len-1]);
|
|
SHads_command(RTSTR, _T(".UNDO"), RTSTR, _T("MARK"), RTNONE); // Make a undo mark
|
|
|
|
for(int j=0;j<len;j++){
|
|
XPoint pe1, pe2, pe3, ptTmp, ptInt;
|
|
pe3 = *lstTmp[j];
|
|
pe1 = *lstPt[j];
|
|
pe2 = *lstPtOut[j];
|
|
AssureInCurrentView(pe3, pe2);
|
|
double nElevation(0);
|
|
int iPipeIdx(0);
|
|
Entity entPipe;
|
|
if(bFree){
|
|
double dElev = pe3.z;
|
|
entPipe = GetPipeByPt(pe3, iPipeIdx);
|
|
if(!entPipe)
|
|
//break;
|
|
// pe1.z = nElevation;
|
|
// pe2.z = nElevation;
|
|
// pe3.z = nElevation;
|
|
continue;
|
|
pe1.z = dElev;
|
|
pe2.z = dElev;
|
|
pe3.z = dElev;
|
|
}
|
|
else{
|
|
double dElevOld = pe3.z;// zxl 2013.04.17 add
|
|
entPipe = GetVertPipeByPt(pe3, nElevation, iPipeIdx, nRadius*DocGetPScale());
|
|
// zxl 2013.04.17 add
|
|
if (!bModifyElev)
|
|
{
|
|
nElevation = dElevOld;
|
|
}
|
|
|
|
pe1.z = nElevation;
|
|
pe2.z = nElevation;
|
|
pe3.z = nElevation;
|
|
}
|
|
|
|
OPENOBJ_BEGIN(entPipe, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
if(pe3 != pe1 && bFree){
|
|
XLine line1(pPipe->StartPoint(), pPipe->EndPoint());
|
|
XLine line2(pe1, pe2);
|
|
int ret = line1.Intersection(&line2, ptInt);
|
|
if(ret != 1){
|
|
if(bFromVer){//第一次画, 从立管引出, 如果不是正交, 很可能没有交点
|
|
TDbPipe *pNewPipe2 = (TDbPipe *)pPipe->clone();
|
|
pNewPipe2->SetEndPoint(pe2);
|
|
pNewPipe2->SetStartPoint(pe1);
|
|
AddToCurrentSpace(pNewPipe2, Adesk::kTrue);
|
|
}
|
|
continue;
|
|
}
|
|
double dEle = pe1.z;
|
|
pe1 = ptInt;
|
|
pe1.z = dEle;
|
|
if(bFromVer){ //把之前的管线往前补齐
|
|
TDbPipe *pNewPipe2 = (TDbPipe *)pPipe->clone();
|
|
pNewPipe2->SetEndPoint(pe3);
|
|
pNewPipe2->SetStartPoint(pe1);
|
|
AddToCurrentSpace(pNewPipe2, Adesk::kTrue);
|
|
}
|
|
}
|
|
|
|
int up(0), low(0);
|
|
BOOL bHasOther = GetInterPipeLevel(pe1, pe2, nElevation, up, low);
|
|
TDbPipe *pNewPipe = (TDbPipe *)pPipe->clone();
|
|
if(pPipe->IsVertical()){//如果从立管引出, 图层不能随立管
|
|
CString csNewLay = GetPipeLayerByIdx(iPipeIdx);
|
|
InitPipeLayer(csNewLay);
|
|
pNewPipe->setLayer(csNewLay);
|
|
}
|
|
pNewPipe->SetEndPoint(pe2);
|
|
if(bFree)
|
|
pNewPipe->SetStartPoint(pe1);
|
|
else
|
|
pNewPipe->SetStartPoint(pe3);
|
|
|
|
// 标高不同 生成立管 zxl 2013.04.23 add
|
|
XPoint ptS = pNewPipe->StartPoint();
|
|
XPoint pt;
|
|
pPipe->getClosestPointTo(ptS, pt);
|
|
if (ptS.Distance(pt) > 1e-3)
|
|
{
|
|
TDbPipe *pNewPipe2 = (TDbPipe *)pPipe->clone();
|
|
pNewPipe2->SetEndPoint(ptS);
|
|
pNewPipe2->SetStartPoint(pt);
|
|
AddToCurrentSpace(pNewPipe2, Adesk::kTrue);
|
|
}
|
|
|
|
if(bHasOther){
|
|
if(iMode == 0){ //生成四通
|
|
if(up != 256)
|
|
pNewPipe->SetHideLevel(up);
|
|
else
|
|
pNewPipe->SetHideLevel(low);
|
|
}
|
|
else if(iMode == 1){ //置上
|
|
if(up != 256)
|
|
pNewPipe->SetHideLevel(up+1);
|
|
else
|
|
pNewPipe->SetHideLevel(low+1);
|
|
}
|
|
else if(iMode == 2) //置下
|
|
pNewPipe->SetHideLevel(low-1);
|
|
}
|
|
AddToCurrentSpace(pNewPipe, Adesk::kTrue);
|
|
|
|
nRotate = ads_angle(pe1, pe2);
|
|
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
bFree = TRUE;
|
|
bFromVer = TRUE;
|
|
lstOld = lstTmp;
|
|
lstPt.Reset();
|
|
lstPt = lstPtOut;
|
|
lstPtOut.Reset();
|
|
TPipePerDocData *pData = GetCurPipeDocData();
|
|
pData->ApplyUpdates();
|
|
}
|
|
SHads_command(RTNONE);
|
|
}
|
|
|
|
|
|
|