930 lines
20 KiB
C++
930 lines
20 KiB
C++
#include "stdafx.h"
|
|
#include "AecDbEwCable.h"
|
|
#include "AecDb3dRoadAxisLine.h"
|
|
#include "AecGripCback.h"
|
|
|
|
static const Adesk::UInt16 kColorByBlock = 0;
|
|
static const Adesk::UInt16 kRed = 1;
|
|
static const Adesk::UInt16 kYellow = 2;
|
|
static const Adesk::UInt16 kGreen = 3;
|
|
static const Adesk::UInt16 kCyan = 4;
|
|
static const Adesk::UInt16 kBlue = 5;
|
|
static const Adesk::UInt16 kMagenta = 6;
|
|
static const Adesk::UInt16 kWhite = 7;
|
|
static const Adesk::UInt16 kColorByLayer = 256;
|
|
static const Adesk::UInt16 kGold = 30;
|
|
static const Adesk::UInt16 kPurple = 200;
|
|
static const Adesk::UInt16 kMagenta2 = 210;
|
|
|
|
extern double PixelToWcs(int nPixel);
|
|
extern AcDbPolyline *FormatPolyline(AcGePoint3d *ppPts, int nCount);
|
|
|
|
static AcGePoint3d Mid(AcGePoint3d& ptGe1,AcGePoint3d& ptGe2)
|
|
{
|
|
return AcGePoint3d( (ptGe1.x + ptGe2.x) / 2.0,
|
|
(ptGe1.y + ptGe2.y) / 2.0,
|
|
(ptGe1.z + ptGe2.z) / 2.0);
|
|
}
|
|
static void FreeBuffer(int n,AcDbVoidPtrArray& arEntPtrs)
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
while(arEntPtrs.length() > n )
|
|
{
|
|
pEnt = (AcDbEntity*)arEntPtrs.last();
|
|
if (pEnt != NULL)
|
|
{
|
|
pEnt->erase();
|
|
pEnt->close();
|
|
arEntPtrs.removeLast();
|
|
DELETE_PTR(pEnt);
|
|
}
|
|
}
|
|
}
|
|
|
|
Adesk::UInt32 AecDbEwCable::kCurrentVersionNumber = 1;
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS (AecDbEwCable, AecDbEwPipeBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_EWCABLE,
|
|
"AecDbEwCable"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
|
|
AecDbEwCable::AecDbEwCable(void)
|
|
{
|
|
}
|
|
|
|
AecDbEwCable::~AecDbEwCable(void)
|
|
{
|
|
}
|
|
|
|
// 设置开始点,如果是LINE管子
|
|
Acad::ErrorStatus AecDbEwCable::SetStartPoint(const AcGePoint3d& ptSta)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (m_pBaseCurve == NULL)
|
|
m_pBaseCurve = new AcDbLine;
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
pLine->setStartPoint(ptSta);
|
|
return Acad::eOk;
|
|
}
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
AcGePoint3d AecDbEwCable::StartPoint() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d ptSta;
|
|
getStartPoint(ptSta);
|
|
|
|
return ptSta;
|
|
}
|
|
|
|
// 设置端点 如果是LINE管子
|
|
Acad::ErrorStatus AecDbEwCable::SetEndPoint(const AcGePoint3d& ptEnd)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (m_pBaseCurve == NULL)
|
|
m_pBaseCurve = new AcDbLine;
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
pLine->setEndPoint(ptEnd);
|
|
return Acad::eOk;
|
|
}
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
AcGePoint3d AecDbEwCable::EndPoint() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d ptSta;
|
|
getEndPoint(ptSta);
|
|
|
|
return ptSta;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwCable::dwgInFields(AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
//----- Read parent class information first.
|
|
Acad::ErrorStatus es = AecDbEwPipeBase::dwgInFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
|
|
//----- Object version number needs to be read first
|
|
Adesk::UInt32 version =0 ;
|
|
if ( (es =pFiler->readUInt32 (&version)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
if ( version > AecDbEwCable::kCurrentVersionNumber )
|
|
return (Acad::eMakeMeProxy) ;
|
|
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwCable::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//----- Save parent class information first.
|
|
Acad::ErrorStatus es = AecDbEwPipeBase::dwgOutFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
|
|
//----- Object version number needs to be saved first
|
|
if ( (es =pFiler->writeUInt32 (AecDbEwCable::kCurrentVersionNumber)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwCable::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwCable::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwCable::subExplode(AcDbVoidPtrArray& entitySet) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecDb3dRoadAxisLine* pAln = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pAln != NULL)
|
|
{
|
|
AcDbCurve* pCurve = NULL;
|
|
for (int i = 0;i < pAln->GetCurveSegCount();i++)
|
|
{
|
|
pCurve = pAln->GetCurveSeg(i);
|
|
entitySet.append(pCurve->clone());
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbEwCable::subList() const
|
|
{
|
|
AecDbEwPipeBase::subList();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwCable::ImpGetGripPonts(AcGePoint3dArray &gripPoints, const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcDbIntArray osnapModes, geomIds;
|
|
AecDb3dRoadAxisLine *pRoadALn = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoadALn != NULL)
|
|
{
|
|
pRoadALn->ImpGetGripPoints(gripPoints, osnapModes, geomIds);
|
|
}
|
|
else
|
|
{
|
|
m_pBaseCurve->getGripPoints(gripPoints, osnapModes, geomIds);
|
|
}
|
|
|
|
//后面的是断管符号
|
|
//断管符号
|
|
AcGePoint3d ptGeBK, ptGeT;
|
|
CString sIndex;
|
|
for (int i = 0; i < PIPE_BROKENNUM; i++)
|
|
{
|
|
sIndex.Format(_T("BKOP%d"), i);
|
|
if (m_mapSpecXData.GetAt(sIndex, ptGeBK))
|
|
{
|
|
//开始
|
|
m_pBaseCurve->getPointAtDist(ptGeBK.x, ptGeT);
|
|
gripPoints.append(ptGeT);
|
|
|
|
//中间
|
|
m_pBaseCurve->getPointAtDist(ptGeBK.x + ptGeBK.y * 0.5, ptGeT);
|
|
gripPoints.append(ptGeT);
|
|
|
|
//结束
|
|
m_pBaseCurve->getPointAtDist(ptGeBK.x + ptGeBK.y, ptGeT);
|
|
gripPoints.append(ptGeT);
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwCable::subGetGripPoints(AcDbGripDataPtrArray &grips,
|
|
const double curViewUnitSize,
|
|
const int gripSize,
|
|
const AcGeVector3d &curViewDir,
|
|
const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcGePoint3dArray gripPoints;
|
|
ImpGetGripPonts(gripPoints, bitflags);
|
|
|
|
int nColor = kBlue;
|
|
AcDbGripData *pGripData = NULL;
|
|
|
|
CString sCmd = GetGripCmd();
|
|
EPosition ePos;
|
|
for (int i = 0; i < GRIP_MAXNUM && i < gripPoints.length(); i++)
|
|
{
|
|
ePos = ExplainGripIndex(i);
|
|
{
|
|
memset(&m_pGripAppData[i], 0, sizeof(AecGripData));
|
|
m_pGripAppData[i].nIndex = i;
|
|
m_pGripAppData[i].ePos = ePos;
|
|
m_pGripAppData[i].nColor = nColor;
|
|
m_pGripAppData[i].ptGrip = gripPoints.at(i);
|
|
_tcscpy(m_pGripAppData[i].szTip, _T("拉伸夹点"));
|
|
_tcscpy(m_pGripAppData[i].szID, m_sGUID);
|
|
m_pGripAppData[i].pOwner = (AcDbEntity *)this;
|
|
m_pGripAppData[i].idHost = objectId();
|
|
|
|
pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(gripPoints.at(i));
|
|
pGripData->setAppData((void *)&m_pGripAppData[i]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
}
|
|
grips.append(pGripData);
|
|
}
|
|
|
|
//动态标注
|
|
//直线,半径 标注风格
|
|
if (!grips.isEmpty())
|
|
{
|
|
SubAddDimPoints(grips, curViewDir);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
EPosition AecDbEwCable::ExplainGripIndex(int nIndex) const
|
|
{
|
|
EPosition ePos = eStart;
|
|
return ePos;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwCable::SubAddDimPoints(AcDbGripDataPtrArray &grips, const AcGeVector3d &curViewDir) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwCable::subMoveGripPointsAt(const AcDbVoidPtrArray &appData, const AcGeVector3d &offset, const int bitflags)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcGePoint3dArray gripPoints;
|
|
AcDbIntArray osnapModes, geomIds;
|
|
|
|
AecDb3dRoadAxisLine *pRoadALn = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoadALn != NULL)
|
|
{
|
|
pRoadALn->ImpGetGripPoints(gripPoints, osnapModes, geomIds);
|
|
}
|
|
else
|
|
{
|
|
m_pBaseCurve->getGripPoints(gripPoints, osnapModes, geomIds);
|
|
}
|
|
|
|
AecGripData *pAppData = NULL;
|
|
AcDbIntArray arIndex;
|
|
|
|
if (!appData.isEmpty())
|
|
{
|
|
pAppData = (AecGripData *)appData.first();
|
|
arIndex.append(pAppData->nIndex);
|
|
}
|
|
else
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int nGripIndex = arIndex.first();
|
|
if (nGripIndex < gripPoints.length())
|
|
{
|
|
//直线中点的移动,关联拉伸,类似管线,由 AecDb3dRoadAxisLine 实现...
|
|
/*AecDb3dRoadAxisLine *pRoadAxLn = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoadAxLn != NULL)
|
|
{
|
|
|
|
}*/
|
|
if (pRoadALn != NULL)
|
|
{
|
|
return pRoadALn->ImpMoveGripPointsAt(arIndex, geomIds, offset);
|
|
}
|
|
else
|
|
{
|
|
//const AcDbIntArray &indices,
|
|
// const AcGeVector3d &offset
|
|
return m_pBaseCurve->moveGripPointsAt(arIndex, offset);
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
extern bool GetSamplePoints(AcDbCurve *pSubCrv, double dFitLen, AcGePoint3dArray &arSubPts);
|
|
AcDbPolyline *AecDbEwCable::OrtherProject2XY(AcDbCurve *pCrv, double dW)
|
|
{
|
|
AcDbLine *pLn = AcDbLine::cast(pCrv);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGePoint3d ptS = pLn->startPoint();
|
|
AcGePoint3d ptE = pLn->endPoint();
|
|
ptS.z = 0.0; ptE.z = 0.0;
|
|
|
|
if (ptS.distanceTo(ptE) > 1.e-3)
|
|
{
|
|
AcDbPolyline *pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
pPl->addVertexAt(0, ptS.convert2d(AcGePlane::kXYPlane));
|
|
pPl->addVertexAt(1, ptE.convert2d(AcGePlane::kXYPlane));
|
|
pPl->setElevation(0);
|
|
pPl->setConstantWidth(dW);
|
|
return pPl;
|
|
}
|
|
}
|
|
|
|
AcDbArc *pArc = AcDbArc::cast(pCrv);
|
|
if (pArc != NULL)
|
|
{
|
|
if (AcGeVector3d::kZAxis.isParallelTo(pArc->normal()))
|
|
{
|
|
double dSta = pArc->startAngle();
|
|
double dEnd = pArc->endAngle();
|
|
if (dSta > dEnd) dSta += 2.0 * PI;
|
|
double dSweep = dEnd - dSta;
|
|
double dBug = tan(0.25 * dSweep);
|
|
|
|
AcGePoint3d ptS, ptE;
|
|
pArc->getStartPoint(ptS);
|
|
pArc->getEndPoint(ptE);
|
|
|
|
AcDbPolyline *pPl = new AcDbPolyline;
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
pPl->addVertexAt(0, ptS.convert2d(AcGePlane::kXYPlane), dBug);
|
|
pPl->addVertexAt(1, ptE.convert2d(AcGePlane::kXYPlane));
|
|
pPl->setElevation(0);
|
|
pPl->setConstantWidth(dW);
|
|
return pPl;
|
|
}
|
|
else
|
|
{
|
|
AcDbCurve *pProj = NULL;
|
|
pArc->getOrthoProjectedCurve(AcGePlane::kXYPlane, pProj);
|
|
|
|
if (pProj != NULL)
|
|
{
|
|
return OrtherProject2XY(pProj, dW);
|
|
}
|
|
}
|
|
}
|
|
|
|
AcDbSpline *pSp = AcDbSpline::cast(pCrv);
|
|
if (pSp != NULL)
|
|
{
|
|
//样点化
|
|
AcGePoint3dArray arPts;
|
|
GetSamplePoints(pSp, dW, arPts);
|
|
|
|
AcDbPolyline *pPl = FormatPolyline(arPts.asArrayPtr(), arPts.length());
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setNormal(AcGeVector3d::kZAxis);
|
|
pPl->setElevation(0);
|
|
pPl->setConstantWidth(dW);
|
|
}
|
|
return pPl;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
//只针对管子
|
|
Acad::ErrorStatus AecDbEwCable::Draw2dSingleSegment(AcGiDraw &dc,AcDbPolyline* pPl) const
|
|
{
|
|
assertReadEnabled();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwCable::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//显示有宽度的二维线,投影 XY 面
|
|
|
|
//图层
|
|
AcDbObjectId idLay = dc.GetLayerId();
|
|
dc.SetLayer(layerId());
|
|
int nCrBk = dc.GetColor();
|
|
|
|
int nColor = nCrBk;
|
|
if (m_mapSpecXData.GetAt(_T("COLOR"), nColor))
|
|
{
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
if (IsActive())
|
|
{
|
|
nColor = kMagenta;
|
|
m_mapSpecXData.GetAt(KEY_ACTIVECR, nColor);
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
if (Has2DBuffer())
|
|
{
|
|
Draw2DBuffers(dc);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
double dSize1 = 0.0;
|
|
int nDrawGradient = 0;
|
|
|
|
//单线宽度
|
|
int nStyle = 0;
|
|
if (m_mapSpecXData.GetAt(KEY_2DSTYLE, nStyle))
|
|
{
|
|
m_mapSpecXData.GetAt(KEY_SINGLEW, dSize1);
|
|
|
|
//是否绘制坡度线
|
|
m_mapSpecXData.GetAt(KEY_DRAWGRAD, nDrawGradient);
|
|
}
|
|
else
|
|
{
|
|
m_mapSpecXData.GetAt(KEY_SIZE1, dSize1);
|
|
}
|
|
|
|
AcDbRegion *pReg = GetSection();
|
|
if (pReg == NULL)
|
|
{
|
|
acutPrintf(_T("\nError : FlexiblePipe section not set!"));
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcGePoint3d ptCen;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN, ptCen);;
|
|
|
|
AecDb3dRoadAxisLine *pRoadAL = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoadAL != NULL)
|
|
{
|
|
AecDb3dRoadAxisLine road;
|
|
road.copyFrom(pRoadAL);
|
|
|
|
AcGePoint2d ptDRatio;
|
|
if (road.ReadDandRatio(ptDRatio))
|
|
{
|
|
road.Create3dRoadAxisLine(ptDRatio.x, ptDRatio.y);
|
|
}
|
|
|
|
AecDbEwPipeBase pipe;
|
|
pipe.SetSection(pReg, ptCen);
|
|
|
|
for (int i = 0; i < road.GetCurveSegCount(); i++)
|
|
{
|
|
AcDbCurve *pCrv = road.GetCurveSeg(i);
|
|
if (pCrv != NULL)
|
|
{
|
|
//投影,变成有宽度的 acdbpolyline
|
|
AcDbPolyline *pPl = OrtherProject2XY(pCrv, dSize1);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setLayer(layerId());
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
AcDbLine *pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AecDbEwPipeBase pipe;
|
|
pipe.SetSection(pReg, ptCen);
|
|
|
|
//投影,变成有宽度的 acdbpolyline
|
|
AcDbPolyline *pPl = OrtherProject2XY(pLn, dSize1);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setLayer(layerId());
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
}
|
|
}
|
|
|
|
AcDbArc *pArc = AcDbArc::cast(m_pBaseCurve);
|
|
if (pArc != NULL)
|
|
{
|
|
AecDbEwPipeBase pipe;
|
|
pipe.SetSection(pReg, ptCen);
|
|
|
|
//投影,变成有宽度的 acdbpolyline
|
|
AcDbPolyline *pPl = OrtherProject2XY(pArc, dSize1);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setLayer(layerId());
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
}
|
|
}
|
|
|
|
AcDbSpline *pSp = AcDbSpline::cast(m_pBaseCurve);
|
|
if (pSp != NULL)
|
|
{
|
|
AecDbEwPipeBase pipe;
|
|
pipe.SetSection(pReg, ptCen);
|
|
|
|
//投影,变成有宽度的 acdbpolyline
|
|
AcDbPolyline *pPl = OrtherProject2XY(pSp, dSize1);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setLayer(layerId());
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
}
|
|
}
|
|
|
|
AcDbPolyline *pPl = AcDbPolyline::cast(m_pBaseCurve);
|
|
if (pPl != NULL)
|
|
{
|
|
AecDbEwPipeBase pipe;
|
|
pipe.SetSection(pReg, ptCen);
|
|
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
pPl->explode(arCurPtrs);
|
|
|
|
AcDbCurve *pCrv = NULL;
|
|
for (int i = 0; i < arCurPtrs.length(); i++)
|
|
{
|
|
pCrv = (AcDbCurve *)arCurPtrs.at(i);
|
|
|
|
//投影,变成有宽度的 acdbpolyline
|
|
AcDbPolyline *pPlT = OrtherProject2XY(pCrv, dSize1);
|
|
if (pPlT != NULL)
|
|
{
|
|
pPl->setLayer(layerId());
|
|
dc.DrawEntity(pPlT);
|
|
Add2DBuffer(pPlT);
|
|
}
|
|
|
|
DELETE_PTR(pCrv);
|
|
}
|
|
}
|
|
DELETE_PTR(pReg);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwCable::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcCmTransparency tr = transparency();
|
|
AcCmTransparency oldTr = dc.SetTransparency(tr);
|
|
|
|
//图层
|
|
AcDbObjectId idLay = dc.GetLayerId();
|
|
dc.SetLayer(layerId());
|
|
int nCrBk = dc.GetColor();
|
|
|
|
int nColor = nCrBk;
|
|
if (m_mapSpecXData.GetAt(_T("COLOR"), nColor))
|
|
{
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
if (IsActive())
|
|
{
|
|
nColor = kMagenta;
|
|
if (m_mapSpecXData.GetAt(KEY_ACTIVECR, nColor))
|
|
{
|
|
if (nColor < 0)
|
|
nColor = colorIndex();
|
|
}
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
//AcDb3dSolid
|
|
if (Has3DBuffer())
|
|
{
|
|
Draw3DBuffers(dc);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcDbRegion *pReg = GetSection();
|
|
if (pReg == NULL)
|
|
{
|
|
acutPrintf(_T("\nError : FlexiblePipe section not set!"));
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcGePoint3d ptCen;
|
|
m_mapSpecXData.GetAt(KEY_SECCEN, ptCen);;
|
|
|
|
AecDb3dRoadAxisLine *pRoadAL = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pRoadAL != NULL)
|
|
{
|
|
AecDb3dRoadAxisLine road;
|
|
road.copyFrom(pRoadAL);
|
|
|
|
AcGePoint2d ptDRatio;
|
|
if (road.ReadDandRatio(ptDRatio))
|
|
{
|
|
road.Create3dRoadAxisLine(ptDRatio.x, ptDRatio.y);
|
|
}
|
|
|
|
//--> CurveSeg + pipebase
|
|
AecDbEwPipeBase pipe;
|
|
AcDbVoidPtrArray ar3DEnPtrs;
|
|
pipe.SetSection(pReg, ptCen);
|
|
|
|
for (int ii = 0; ii < road.GetCurveSegCount(); ii++)
|
|
{
|
|
AcDbCurve *pCrv = road.GetCurveSeg(ii);
|
|
if (pCrv != NULL)
|
|
{
|
|
pipe.SetBaseCurve(pCrv);
|
|
pipe.Draw3d(dc);
|
|
const AcDbVoidPtrArray &arDraw3d = pipe.Get3DBuffer();
|
|
ar3DEnPtrs.append(arDraw3d);
|
|
pipe.Clean3DBufferNoDel();
|
|
}
|
|
}
|
|
|
|
AcDbEntity *pEnt = NULL;
|
|
for (int i = 0; i < ar3DEnPtrs.length(); i++)
|
|
{
|
|
pEnt = (AcDbEntity *)ar3DEnPtrs.at(i);
|
|
pEnt->setLayer(layerId());
|
|
dc.DrawEntity(pEnt);
|
|
Add3DBuffer(pEnt);
|
|
}
|
|
}
|
|
|
|
AcDbLine *pLn = AcDbLine::cast(m_pBaseCurve);
|
|
AcDbArc *pArc = AcDbArc::cast(m_pBaseCurve);
|
|
AcDbSpline *pSp = AcDbSpline::cast(m_pBaseCurve);
|
|
if (pLn != NULL || pArc != NULL || pSp != NULL)
|
|
{
|
|
AcDbVoidPtrArray ar3DEnPtrs;
|
|
AecDbEwPipeBase pipe;
|
|
pipe.SetSection(pReg, ptCen);
|
|
|
|
pipe.SetBaseCurve(m_pBaseCurve);
|
|
pipe.Draw3d(dc);
|
|
const AcDbVoidPtrArray &arDraw3d = pipe.Get3DBuffer();
|
|
ar3DEnPtrs.append(arDraw3d);
|
|
pipe.Clean3DBufferNoDel();
|
|
|
|
AcDbEntity *pEnt = NULL;
|
|
for (int i = 0; i < ar3DEnPtrs.length(); i++)
|
|
{
|
|
pEnt = (AcDbEntity *)ar3DEnPtrs.at(i);
|
|
pEnt->setLayer(layerId());
|
|
dc.DrawEntity(pEnt);
|
|
Add3DBuffer(pEnt);
|
|
}
|
|
}
|
|
|
|
AcDbPolyline *pPl = AcDbPolyline::cast(m_pBaseCurve);
|
|
if (pPl != NULL)
|
|
{
|
|
AecDbEwPipeBase pipe;
|
|
pipe.SetSection(pReg, ptCen);
|
|
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
pPl->explode(arCurPtrs);
|
|
|
|
AcDbVoidPtrArray ar3DEnPtrs;
|
|
|
|
AcDbCurve *pCrv = NULL;
|
|
for (int ii = 0; ii < arCurPtrs.length(); ii++)
|
|
{
|
|
pCrv = (AcDbCurve *)arCurPtrs.at(ii);
|
|
|
|
pipe.SetBaseCurve(pCrv);
|
|
pipe.Draw3d(dc);
|
|
const AcDbVoidPtrArray &arDraw3d = pipe.Get3DBuffer();
|
|
ar3DEnPtrs.append(arDraw3d);
|
|
pipe.Clean3DBufferNoDel();
|
|
|
|
DELETE_PTR(pCrv);
|
|
}
|
|
|
|
AcDbEntity *pEnt = NULL;
|
|
for (int i = 0; i < ar3DEnPtrs.length(); i++)
|
|
{
|
|
pEnt = (AcDbEntity *)ar3DEnPtrs.at(i);
|
|
pEnt->setLayer(layerId());
|
|
dc.DrawEntity(pEnt);
|
|
Add3DBuffer(pEnt);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEwCable::DrawInfArrow(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecDbEwPipeBase::DrawInfArrow(dc);
|
|
|
|
if (m_nInfActive >= 0 )
|
|
{
|
|
int nSegIndex = m_nInfActive / 2;
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
const AcDbVoidPtrArray &ar3D = Get3DBuffer();
|
|
|
|
if (nSegIndex > -1 && nSegIndex < ar3D.length())
|
|
{
|
|
pEnt = (AcDbEntity*)ar3D.at(nSegIndex);
|
|
pEnt->setColorIndex(kMagenta);
|
|
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
bool AecDbEwCable::GetInterface(AcArray<AecInterface>& arInfs) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecDb3dRoadAxisLine* pAln = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pAln != NULL)
|
|
{
|
|
pAln->GetInterface(arInfs);
|
|
|
|
double dD = 0.0;
|
|
m_mapSpecXData.GetAt(CABLE_D,dD);
|
|
|
|
for (int i = 0;i < arInfs.length();i++)
|
|
{
|
|
AecInterface& inf = arInfs.at(i);
|
|
inf.dSize1 = dD;
|
|
inf.idOwner = objectId();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AecDbEwPipeBase::GetInterface(arInfs);
|
|
}
|
|
return !arInfs.isEmpty();
|
|
}
|
|
|
|
bool AecDbEwCable::GetInterface(int nIndex,AecInterface& inf) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcArray<AecInterface> arInfs;
|
|
GetInterface(arInfs);
|
|
|
|
if (nIndex > -1 && nIndex < arInfs.length())
|
|
{
|
|
inf = arInfs.at(nIndex);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
int AecDbEwCable::GetInterfaceCount() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecDb3dRoadAxisLine* pAln = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pAln != NULL)
|
|
{
|
|
return pAln->GetInterfaceCount();
|
|
}
|
|
else
|
|
{
|
|
return AecDbEwPipeBase::GetInterfaceCount();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int AecDbEwCable::GetActiveInf() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_nInfActive;
|
|
}
|
|
|
|
void AecDbEwCable::SetActiveInf(int nIndex)
|
|
{
|
|
assertWriteEnabled();
|
|
m_nInfActive = nIndex;
|
|
}
|
|
|
|
bool AecDbEwCable::TransformAssocInf(AecInterface& inf,const AcGeMatrix3d& xform,AcDbEntity* pMsgFrom)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
bool bOnHitThis = false;
|
|
AecMInterfaces* pInf = NULL;
|
|
AcDbCurve* pEnt = NULL;
|
|
int nHitInf = -1;
|
|
|
|
AecDb3dRoadAxisLine* pAln = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pAln != NULL)
|
|
{
|
|
for (int i = 0;i < pAln->GetCurveSegCount();i++)
|
|
{
|
|
pEnt = pAln->GetCurveSeg(i);
|
|
if (pEnt == pMsgFrom)
|
|
continue;
|
|
|
|
AcArray<AecInterface> arInfs;
|
|
pAln->GetInterface(i,arInfs);
|
|
|
|
bOnHitThis = false;
|
|
for (int j = 0;j < arInfs.length();j++)
|
|
{
|
|
AecInterface& infTmp = arInfs.at(j);
|
|
|
|
if (infTmp.ptPos.distanceTo(inf.ptPos) < 1.e-2)//误差0.01米
|
|
{
|
|
bOnHitThis = true;
|
|
nHitInf = j;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (bOnHitThis)
|
|
{
|
|
bool bContinueSend = pAln->TransformAssocInf(i,nHitInf,xform);
|
|
if (bContinueSend)//继续发送消息
|
|
{
|
|
//作用在旧的接口上继续传递接口消息
|
|
for (int k = 0;k < arInfs.length();k++)
|
|
{
|
|
AecInterface& infK = arInfs.at(k);
|
|
TransformAssocInf(infK,xform,pMsgFrom);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbEwCable::TransformAssocInf(int nInf,const AcGeMatrix3d& xform)
|
|
{
|
|
if (nInf == -1)
|
|
return false;
|
|
|
|
AssertWriteEnabled();
|
|
|
|
AecDb3dRoadAxisLine* pAln = AecDb3dRoadAxisLine::cast(m_pBaseCurve);
|
|
if (pAln != NULL)
|
|
{
|
|
int nIndex = nInf / 2;
|
|
|
|
AcArray<AecInterface> arInfs;
|
|
pAln->GetInterface(nIndex,arInfs);
|
|
|
|
//先变换
|
|
AcDbCurve* pCurve = pAln->GetCurveSeg(nIndex);
|
|
pCurve->transformBy(xform);
|
|
|
|
//根据旧的接口传递变换
|
|
for(int i = 0;i < arInfs.length();i++)
|
|
{
|
|
AecInterface& inf = arInfs.at(i);
|
|
TransformAssocInf(inf,xform,pCurve);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
return false;
|
|
} |