2394 lines
52 KiB
C++
2394 lines
52 KiB
C++
#include "stdafx.h"
|
|
#include "AecDbECableTray.h"
|
|
#include "dbgrip.h"
|
|
#include "AecGripCback.h"
|
|
#include "KTCADUtilityEx.h"
|
|
#include "AecDbWall.h"
|
|
#include "AecDbSlab.h"
|
|
#include "KTSetting.h"
|
|
#include "AcGiViewDraw.h"
|
|
#include "AecDb3dRoadAxisLine.h"
|
|
#include "AecDbHolder.h"
|
|
|
|
extern double PixelToWcs(int nPixel);
|
|
extern BOOL Is2DView();
|
|
extern AcGeVector3d GetUcsZvt();
|
|
extern void PushGripMessage(GripMessage&);
|
|
|
|
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;
|
|
|
|
#ifndef GRIPPT_RESP_FROM_EWFIT
|
|
#define GRIPPT_RESP_FROM_EWFIT 1394
|
|
#endif
|
|
|
|
static AcGePoint3d Mid(const AcGePoint3d& ptGe1,const 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);
|
|
}
|
|
}
|
|
}
|
|
|
|
DLLIMPEXP AcDb3dPolyline *Format3dPolyline(const AcGePoint3dArray &arPts);
|
|
DLLIMPEXP AcDbPolyline *Format3dPolyline(const AcGePoint3d *pptGe, int nPoints, const AcGeVector3d &vtNorm);
|
|
DLLIMPEXP AcDbCurve *GetMinOffsetCurve(AcDbCurve *pPl, double dOff);
|
|
|
|
Adesk::UInt32 AecDbECableTray::kCurrentVersionNumber = 1;
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS (AecDbECableTray, AecDbEwPipeBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_DBCABTRY,
|
|
"AecDbECableTray"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
|
|
AecDbECableTray::AecDbECableTray(void)
|
|
{
|
|
}
|
|
|
|
AecDbECableTray::~AecDbECableTray(void)
|
|
{
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::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 AecDbECableTray::StartPoint() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d ptSta;
|
|
getStartPoint(ptSta);
|
|
|
|
return ptSta;
|
|
}
|
|
|
|
// 设置端点 如果是LINE管子
|
|
Acad::ErrorStatus AecDbECableTray::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 AecDbECableTray::EndPoint() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d ptSta;
|
|
getEndPoint(ptSta);
|
|
|
|
return ptSta;
|
|
}
|
|
|
|
bool AecDbECableTray::SetDuctParam(const AecHvac::DuctParam* pData)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (pData == NULL)
|
|
return false;
|
|
|
|
m_mapSpecXData.SetAt(KEY_APP, pData->m_app);
|
|
if (pData->m_app == WPipe::eTrench)
|
|
{
|
|
m_mapSpecXData.SetAt(KEY_HIDESTART, 1);
|
|
m_mapSpecXData.SetAt(KEY_HIDEEND, 1);
|
|
m_mapSpecXData.SetAt(PIPE_DRAWDIR, WPipe::eID);
|
|
|
|
m_mapSpecXData.SetAt(PIPE_OD, pData->dSize[0] + 2.0 * pData->dSize[2]);
|
|
m_mapSpecXData.SetAt(PIPE_THICK, pData->dSize[2]);
|
|
}
|
|
|
|
if (pData->m_app == WPipe::eBridge)
|
|
{
|
|
double dL0 = 0, dW0 = 0;
|
|
m_mapSpecXData.GetAt(KEY_SIZE1, dL0);
|
|
m_mapSpecXData.GetAt(KEY_SIZE2, dW0);
|
|
|
|
double dUse1 = 0, dUse2 = 0;
|
|
m_mapSpecXData.GetAt(KEY_FILLUSED, dUse1);//0.55
|
|
m_mapSpecXData.GetAt(KEY_FILLUSED, dUse2);//0.45
|
|
|
|
BOOL bSpart = 0;
|
|
m_mapSpecXData.GetAt(KEY_SPART, bSpart);
|
|
|
|
if (dUse1 > 1.e-3 && !bSpart)//有填充率
|
|
{
|
|
double dAreaUsedOld = dUse1 * dL0 * dW0;
|
|
double dAreaNewSet = dAreaUsedOld / (pData->dSize[0] * pData->dSize[1]);
|
|
m_mapSpecXData.SetAt(KEY_FILLUSED, dAreaNewSet);//0.55
|
|
}
|
|
else if (dUse1 > 1.e-3 && dUse2 > 1.e-3 && bSpart)
|
|
{
|
|
double dAreaUsedOld = dUse1 * dL0 * dW0 * 0.5;
|
|
double dAreaNewSet = dAreaUsedOld / (pData->dSize[0] * pData->dSize[1] * 0.5);
|
|
m_mapSpecXData.SetAt(KEY_FILLUSED, dAreaNewSet);//0.55
|
|
|
|
dAreaUsedOld = dUse2 * dL0 * dW0 * 0.5;
|
|
dAreaNewSet = dAreaUsedOld / (pData->dSize[0] * pData->dSize[1] * 0.5);
|
|
m_mapSpecXData.SetAt(KEY_FILLUSED, dAreaNewSet);//0.45
|
|
}
|
|
}
|
|
|
|
m_mapSpecXData.SetAt(KEY_MATERIAL,pData->szMat);
|
|
m_mapSpecXData.SetAt(KEY_FACTORY,pData->szFat);
|
|
m_mapSpecXData.SetAt(KEY_RRATIO,pData->m_dRatio);
|
|
m_mapSpecXData.SetAt(KEY_FULLPER,pData->m_dFullPer);
|
|
m_mapSpecXData.SetAt(KEY_FULLPER2, pData->m_dFullPer2);
|
|
m_mapSpecXData.SetAt(KEY_WELLW, pData->dSize[4]);
|
|
m_mapSpecXData.SetAt(KEY_SN,pData->szNo);
|
|
m_mapSpecXData.SetAt(KEY_TYPE,pData->szType);
|
|
m_mapSpecXData.SetAt(KEY_EXT,pData->szExt);
|
|
m_mapSpecXData.SetAt(PIPE_SYS,pData->szSys);
|
|
m_mapSpecXData.SetAt(KEY_COVER,pData->m_bCover);
|
|
m_mapSpecXData.SetAt(KEY_SPART,pData->m_bSpart);
|
|
m_mapSpecXData.SetAt(KEY_SYSSPLT, pData->m_nSysSplit);
|
|
m_mapSpecXData.SetAt(KEY_CENNODRAW,pData->m_bCenDraw ? 0 : 1);//中心线
|
|
m_mapSpecXData.SetAt(KEY_REM,pData->szRem);
|
|
m_mapSpecXData.SetAt(KEY_SECSHAPE,(int)pData->eType);
|
|
|
|
//设置标高
|
|
//如果是水平管子
|
|
AcGePoint3d ptS = StartPoint();
|
|
AcGePoint3d ptE = EndPoint();
|
|
AcGeVector3d vt = ptE - ptS;
|
|
AcGeLine3d ln(ptS,vt);
|
|
if (ln.isParallelTo(AcGePlane::kXYPlane))
|
|
{
|
|
SetElevation(pData->m_dEl);
|
|
}
|
|
|
|
bool bSetSect = false;
|
|
double dL = 0.0,dW = 0.0,dt = 0.0;
|
|
double dD = 0.0;
|
|
switch(pData->eType)
|
|
{
|
|
case eRect:
|
|
{
|
|
dL = pData->dSize[0];
|
|
dW = pData->dSize[1];
|
|
dt = pData->dSize[2];
|
|
|
|
if (dL > 1.e-6 && dW > 1.e-6 && dt > 1.e-6)
|
|
{
|
|
if (pData->m_bCover)
|
|
{
|
|
SetSection(dL,dW,dt);
|
|
}
|
|
else
|
|
{
|
|
//如果是立管,还要调成封闭
|
|
SetSection1(dL,dW,dt,true);
|
|
m_mapSpecXData.SetAt(KEY_SECSHAPE,(int)pData->eType);
|
|
|
|
m_mapSpecXData.SetAt(KEY_SIZE1,dL);
|
|
m_mapSpecXData.SetAt(KEY_SIZE2,dW);
|
|
m_mapSpecXData.SetAt(PIPE_THICK,dt);
|
|
}
|
|
bSetSect = true;
|
|
}
|
|
break;
|
|
}
|
|
case eCircle:
|
|
{
|
|
dD = pData->dSize[0];
|
|
dt = pData->dSize[2];
|
|
|
|
if (dD > 1.e-6 && dt > 1.e-6)
|
|
{
|
|
SetSection(dD,dt);
|
|
bSetSect = true;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//保存预留数据 电缆沟等用
|
|
CString sKey;
|
|
for (int i = 5; i < 33; i++)//
|
|
{
|
|
sKey.Format(_T("%s_%d"), KEY_SIZE, i);
|
|
m_mapSpecXData.SetAt(sKey, pData->dSize[i]);
|
|
}
|
|
|
|
return bSetSect;
|
|
}
|
|
|
|
void AecDbECableTray::SetElevation(double dEl)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)
|
|
{
|
|
AcGePoint3d ptSta = pLine->startPoint();
|
|
AcGePoint3d ptEnd = pLine->endPoint();
|
|
|
|
if (fabs(ptSta.z - ptEnd.z) < 1.e-2)
|
|
{
|
|
ptSta.z = dEl;ptEnd.z = dEl;
|
|
pLine->setStartPoint(ptSta);
|
|
pLine->setEndPoint(ptEnd);
|
|
}
|
|
}
|
|
}
|
|
|
|
void AecDbECableTray::GetDuctParam(AecHvac::DuctParam& data) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
memset(&data,0,sizeof(AecHvac::DuctParam));
|
|
|
|
int nType = 0;
|
|
m_mapSpecXData.GetAt(KEY_SECSHAPE,nType);
|
|
|
|
int nCenNDraw = 0;
|
|
ESection eType = (ESection)nType;
|
|
data.eType = eType;
|
|
|
|
data.m_app = WPipe::eBridge;
|
|
int nApp = 7;
|
|
m_mapSpecXData.GetAt(KEY_APP, nApp);
|
|
data.m_app = WPipe::EApp(nApp);
|
|
if (nApp == 0)
|
|
data.m_app = WPipe::eBridge;
|
|
|
|
switch(eType)
|
|
{
|
|
case eRect:
|
|
{
|
|
m_mapSpecXData.GetAt(KEY_SIZE1,data.dSize[0]); //L
|
|
m_mapSpecXData.GetAt(KEY_SIZE2,data.dSize[1]); //w
|
|
m_mapSpecXData.GetAt(PIPE_THICK,data.dSize[2]);//t
|
|
m_mapSpecXData.GetAt(KEY_CENNODRAW,nCenNDraw);//中心线
|
|
data.m_bCenDraw = nCenNDraw ? 0 : 1;
|
|
break;
|
|
}
|
|
case eCircle:
|
|
{
|
|
m_mapSpecXData.GetAt(KEY_SIZE1,data.dSize[0]); //D
|
|
data.dSize[1] = 0.0;
|
|
m_mapSpecXData.GetAt(PIPE_THICK,data.dSize[2]);//t
|
|
m_mapSpecXData.GetAt(KEY_CENNODRAW,nCenNDraw);//中心线
|
|
data.m_bCenDraw = nCenNDraw ? 0 : 1;
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//假设是平行XY
|
|
data.m_dEl = StartPoint().z;
|
|
|
|
data.m_nAlign = 1;//居中
|
|
m_mapSpecXData.GetAt(KEY_WELLW, data.dSize[4]);
|
|
m_mapSpecXData.GetAt(KEY_NORMAL,data.m_vtNrom);
|
|
m_mapSpecXData.GetAt(KEY_RRATIO,data.m_dRatio);
|
|
|
|
m_mapSpecXData.GetAt(KEY_FULLPER,data.m_dFullPer);
|
|
data.m_dFillUsed = 0;
|
|
m_mapSpecXData.GetAt(KEY_FILLUSED, data.m_dFillUsed);
|
|
|
|
m_mapSpecXData.GetAt(KEY_FULLPER2, data.m_dFullPer2);
|
|
data.m_dFillUsed2 = 0;
|
|
m_mapSpecXData.GetAt(KEY_FILLUSED2, data.m_dFillUsed2);
|
|
|
|
CString sTemp = _T("");
|
|
m_mapSpecXData.GetAt(KEY_SN,sTemp);
|
|
_tcscpy(data.szNo,(LPCTSTR)sTemp);
|
|
|
|
sTemp = _T("");
|
|
m_mapSpecXData.GetAt(KEY_TYPE,sTemp);
|
|
_tcscpy(data.szType,(LPCTSTR)sTemp);
|
|
|
|
sTemp = _T("");
|
|
m_mapSpecXData.GetAt(KEY_EXT,sTemp);
|
|
_tcscpy(data.szExt,(LPCTSTR)sTemp);
|
|
|
|
sTemp = _T("");
|
|
m_mapSpecXData.GetAt(PIPE_SYS,sTemp);
|
|
_tcscpy(data.szSys,(LPCTSTR)sTemp);
|
|
|
|
m_mapSpecXData.GetAt(KEY_COVER,data.m_bCover);
|
|
m_mapSpecXData.GetAt(KEY_SPART,data.m_bSpart);
|
|
m_mapSpecXData.GetAt(KEY_SYSSPLT,data.m_nSysSplit);
|
|
//...
|
|
m_mapSpecXData.GetAt(KEY_MATERIAL,sTemp);
|
|
_tcscpy(data.szMat,(LPCTSTR)sTemp);
|
|
|
|
m_mapSpecXData.GetAt(KEY_FACTORY,sTemp);
|
|
_tcscpy(data.szFat,(LPCTSTR)sTemp);
|
|
|
|
m_mapSpecXData.GetAt(KEY_REM,sTemp);
|
|
_tcscpy(data.szRem,(LPCTSTR)sTemp);
|
|
|
|
//提取预留数据 电缆沟等用
|
|
CString sKey;
|
|
for (int i = 5; i < 33; i++)//
|
|
{
|
|
sKey.Format(_T("%s_%d"), KEY_SIZE, i);
|
|
m_mapSpecXData.GetAt(sKey, data.dSize[i]);
|
|
}
|
|
}
|
|
|
|
bool AecDbECableTray::GetDlgData(DlgData &data) const
|
|
{
|
|
memset(&data, 0, sizeof(DlgData));
|
|
|
|
int nApp = 0;
|
|
if (!m_mapSpecXData.GetAt(KEY_APP, nApp))
|
|
return false;
|
|
|
|
if ((WPipe::EApp)nApp != WPipe::eTrench)
|
|
return false;
|
|
|
|
AecHvac::DuctParam param;
|
|
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
|
GetDuctParam(param);
|
|
data.m_bHasCover = param.m_bCover;
|
|
data.m_dW = param.dSize[4];
|
|
data.m_dH = param.dSize[5];
|
|
data.m_dt = param.dSize[6];
|
|
data.m_db = param.dSize[7];
|
|
data.m_dd = param.dSize[8];
|
|
data.m_dh2 = param.dSize[9];
|
|
data.m_dk = param.dSize[10];
|
|
data.m_dTopEl = param.dSize[11];
|
|
data.m_dRatio = param.m_dRatio;
|
|
_tcscpy(data.m_sGKind, param.szType);
|
|
_tcscpy(data.m_szNo, param.szNo);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AecDbECableTray::SetXHolder(EAlign kPos, XHolder &xH)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
switch (kPos)
|
|
{
|
|
case kLeft:
|
|
{
|
|
m_mapSpecXData.SetAt(KEY_LEFT, &xH, sizeof(XHolder));
|
|
break;
|
|
}
|
|
case kRight:
|
|
{
|
|
m_mapSpecXData.SetAt(KEY_RIGHT, &xH, sizeof(XHolder));
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbECableTray::GetXHolder(EAlign kPos, XHolder &xH) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int nSize1 = sizeof(XHolder);
|
|
int nSize2 = 0;
|
|
XHolder *pHolder = NULL;
|
|
|
|
switch (kPos)
|
|
{
|
|
case kLeft:
|
|
{
|
|
if (!m_mapSpecXData.GetAt(KEY_LEFT, (void *&)pHolder, nSize2))
|
|
return false;
|
|
|
|
if (pHolder->N <= 0) return false;
|
|
|
|
if (nSize2 == nSize1 && pHolder != NULL)
|
|
{
|
|
memcpy(&xH, pHolder, nSize1);
|
|
delete pHolder;
|
|
return true;
|
|
}
|
|
break;
|
|
}
|
|
case kRight:
|
|
{
|
|
if (!m_mapSpecXData.GetAt(KEY_RIGHT, (void *&)pHolder, nSize2))
|
|
return false;
|
|
|
|
if (pHolder->N <= 0) return false;
|
|
|
|
if (nSize2 == nSize1 && pHolder != NULL)
|
|
{
|
|
memcpy(&xH, pHolder, nSize1);
|
|
delete pHolder;
|
|
return true;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
AcGeVector3d AecDbECableTray::GetNormal() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGeVector3d vtNorm(0,0,1);
|
|
m_mapSpecXData.GetAt(KEY_NORMAL,vtNorm);
|
|
|
|
return vtNorm;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::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 > AecDbECableTray::kCurrentVersionNumber )
|
|
return (Acad::eMakeMeProxy);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::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 (AecDbECableTray::kCurrentVersionNumber)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
#if ARX>16
|
|
|
|
void AecDbECableTray::subList() const
|
|
{
|
|
assertReadEnabled();
|
|
AecDbEwPipeBase::subList();
|
|
|
|
acutPrintf(_T("\n桥架:"));
|
|
|
|
AcArray<AecInterface> arInf;
|
|
GetInterface(arInf);
|
|
|
|
for (int i = 0; i < arInf.length(); i++)
|
|
{
|
|
AecInterface &inf = arInf.at(i);
|
|
acutPrintf(_T("\nInf%d : pt = (%.3f,%.3f,%.3f) size = %.3f,%.3f"), i + 1, inf.ptPos.x, inf.ptPos.y, inf.ptPos.z, inf.dSize1, inf.dSize2);
|
|
}
|
|
|
|
acutPrintf(_T("\n属性数据:"));
|
|
m_mapSpecXData.List();
|
|
acutPrintf(_T("\n"));
|
|
}
|
|
|
|
bool AecDbECableTray::GetBimInfoTip(CString& sInfoTip) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecHvac::DuctParam data;
|
|
memset(&data,0,sizeof(AecHvac::DuctParam));
|
|
|
|
GetDuctParam(data);
|
|
|
|
CString sField,sFmt;
|
|
sField = _T("桥架:\n");
|
|
sInfoTip += sField;
|
|
|
|
MAKEFIELD(_T("类型"),_T("%s"),data.szType,sInfoTip);
|
|
|
|
MAKEFIELD(_T("宽度"),_T("%d"),(int)(data.dSize[0]+0.5),sInfoTip);
|
|
MAKEFIELD(_T("高度"),_T("%d"),(int)(data.dSize[1]+0.5),sInfoTip);
|
|
|
|
MAKEFIELD(_T("板材厚度"),_T("%.1f"),data.dSize[2],sInfoTip);
|
|
|
|
MAKEFIELD(_T("底标高"),_T("%.1f"),data.m_dEl,sInfoTip);
|
|
|
|
MAKEFIELD(_T("系统"),_T("%s"),data.szSys,sInfoTip);
|
|
|
|
MAKEFIELD(_T("材料"),_T("%s"),data.szMat,sInfoTip);
|
|
|
|
MAKEFIELD(_T("厂家"),_T("%s"),data.szFat,sInfoTip);
|
|
|
|
MAKEFIELD(_T("编号"),_T("%s"),data.szNo,sInfoTip);
|
|
|
|
return true;
|
|
}
|
|
|
|
#ifndef EL_SYS
|
|
#define HIGH_V _T("高压")
|
|
#define LOW_V _T("低压")
|
|
#define KVV _T("控制")
|
|
#define MSGV _T("通讯")
|
|
#define MSGV2 _T("信号")
|
|
#define MSGV3 _T("仪表")
|
|
#endif
|
|
bool IsSameAsSysUse(LPCTSTR pszSys1, LPCTSTR pszSysD)
|
|
{
|
|
CString sSys1 = pszSys1;
|
|
CString sSysD = pszSysD;
|
|
//sSysPt
|
|
//控制和通讯(<450-750v);仪表(24v);动力低压(0.6-1kv);动力高压[3-110kv);
|
|
|
|
//syscab 含有如下
|
|
/*
|
|
#define HIGH_V _T("高压")
|
|
#define LOW_V _T("低压")
|
|
#define KVV _T("控制")
|
|
#define MSGV _T("通讯")
|
|
#define MSGV2 _T("信号")
|
|
#define MSGV3 _T("仪表")
|
|
*/
|
|
|
|
//sSysPt 和 sSysCab 都含有上述define 是,为系统匹配
|
|
|
|
CStringList arSHv, arSLv;
|
|
CStringList arKMSG;
|
|
|
|
arSHv.AddTail(HIGH_V);
|
|
arSLv.AddTail(LOW_V);
|
|
|
|
arKMSG.AddTail(KVV); arKMSG.AddTail(MSGV); arKMSG.AddTail(MSGV2); arKMSG.AddTail(MSGV3);
|
|
|
|
//高压是否相同
|
|
CString sCmn;
|
|
bool bThis = false, bThat = false;
|
|
for (POSITION ps = arSHv.GetHeadPosition(); ps != NULL;)
|
|
{
|
|
sCmn = arSHv.GetNext(ps);
|
|
if (sSys1.Find(sCmn) != -1)
|
|
bThis = true;
|
|
|
|
if (sSysD.Find(sCmn) != -1)
|
|
bThat = true;
|
|
}
|
|
|
|
if (bThis && bThat)
|
|
return true;
|
|
|
|
//低压是否相同
|
|
bThis = false, bThat = false;
|
|
for (POSITION ps = arSLv.GetHeadPosition(); ps != NULL;)
|
|
{
|
|
sCmn = arSLv.GetNext(ps);
|
|
if (sSys1.Find(sCmn) != -1)
|
|
bThis = true;
|
|
|
|
if (sSysD.Find(sCmn) != -1)
|
|
bThat = true;
|
|
}
|
|
if (bThis && bThat)
|
|
return true;
|
|
|
|
//控制通讯
|
|
bThis = false, bThat = false;
|
|
for (POSITION ps = arKMSG.GetHeadPosition(); ps != NULL;)
|
|
{
|
|
sCmn = arKMSG.GetNext(ps);
|
|
if (sSys1.Find(sCmn) != -1)
|
|
bThis = true;
|
|
|
|
if (sSysD.Find(sCmn) != -1)
|
|
bThat = true;
|
|
}
|
|
|
|
if (bThis && bThat)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
//设置 加 减 填充率
|
|
bool AecDbECableTray::SendUserData(struct resbuf *pRb)
|
|
{
|
|
//解析 是 int-sys-double
|
|
if (pRb != NULL)
|
|
{
|
|
CString sSys;
|
|
double dD = 0;
|
|
int nAddOrSub = 1;
|
|
|
|
struct resbuf *pRb1 = pRb->rbnext;
|
|
struct resbuf *pRb2 = NULL;
|
|
if (pRb1 != NULL)
|
|
{
|
|
pRb2 = pRb1->rbnext;
|
|
}
|
|
|
|
bool bYs = false;
|
|
if (pRb1 != NULL && pRb2 != NULL)
|
|
{
|
|
if (pRb->restype == AcDb::kDxfXdInteger16)
|
|
{
|
|
nAddOrSub = pRb->resval.rint ? -1 : 1;
|
|
bYs = true;
|
|
}
|
|
else
|
|
{
|
|
bYs = false;
|
|
}
|
|
|
|
if (pRb1->restype == kDxfXdAsciiString)
|
|
{
|
|
sSys = pRb1->resval.rstring;
|
|
bYs = true;
|
|
}
|
|
else
|
|
{
|
|
bYs = false;
|
|
}
|
|
|
|
if (pRb2->restype == AcDb::kDxfReal)
|
|
{
|
|
dD = pRb2->resval.rreal;
|
|
bYs = true;
|
|
}
|
|
else
|
|
{
|
|
bYs = false;
|
|
}
|
|
|
|
if (bYs)
|
|
{
|
|
double dFillUsed = 0.0, dThisUsed = 0;
|
|
CString sSys2, sSysData = sSys;
|
|
double dSCab = 0.25 * PI * dD * dD;
|
|
|
|
struct resbuf rb;
|
|
acedGetVar(_T("INSUNITS"), &rb);
|
|
if (rb.resval.rint == AcDb::kUnitsMeters)
|
|
{
|
|
dSCab *= 1.e-6;
|
|
}
|
|
|
|
AecDbObjXDataMap *pDataMap = GetSpecialtyData(AcDb::kForWrite);
|
|
|
|
DlgData dlgData;
|
|
if (!GetDlgData(dlgData))
|
|
{
|
|
AecHvac::DuctParam param;
|
|
GetDuctParam(param);
|
|
|
|
if (param.m_bSpart)//有隔板
|
|
{
|
|
//隔板系统分类
|
|
//param.m_nSysSplit;
|
|
//判断
|
|
CString sSyss = param.szSys;
|
|
sSyss.TrimRight();
|
|
int nPos = sSyss.Find(_T('|'), 0);
|
|
if (nPos != -1)
|
|
{
|
|
sSys = sSyss.Mid(0, nPos);
|
|
if (nPos < sSyss.GetLength() - 1)
|
|
{
|
|
sSys2 = sSyss.Mid(nPos + 1);
|
|
}
|
|
|
|
if (IsSameAsSysUse(sSys, sSysData))
|
|
//if (sSysData.Find(sSys) != -1)//走左侧层
|
|
{
|
|
//...
|
|
dFillUsed = 0.0;
|
|
pDataMap->GetAt(KEY_FILLUSED, dFillUsed);//0.65
|
|
|
|
//面积 / 总面积 = 0.15
|
|
dThisUsed = dSCab;
|
|
dThisUsed /= (param.dSize[4]) * param.dSize[1];
|
|
|
|
//ext.累加 0.45 + 0.15
|
|
dFillUsed += dThisUsed * nAddOrSub;
|
|
pDataMap->SetAt(KEY_FILLUSED, dFillUsed);
|
|
}
|
|
//else if (sSysData.Find(sSys2) != -1)//走右侧层
|
|
else if (IsSameAsSysUse(sSys2, sSysData))
|
|
{
|
|
//...
|
|
dFillUsed = 0.0;
|
|
pDataMap->GetAt(KEY_FILLUSED2, dFillUsed);
|
|
|
|
//ext.面积 / 总面积 = 0.15
|
|
dThisUsed = dSCab;
|
|
dThisUsed /= (param.dSize[0] - param.dSize[4]) * param.dSize[1];
|
|
|
|
//ext.累加 0.45 + 0.15
|
|
dFillUsed += dThisUsed * nAddOrSub;
|
|
pDataMap->SetAt(KEY_FILLUSED2, dFillUsed);
|
|
}
|
|
else//都没有找到,走单层
|
|
{
|
|
//...
|
|
dFillUsed = 0.0;
|
|
pDataMap->GetAt(KEY_FILLUSED, dFillUsed);
|
|
|
|
//ext.面积 / 总面积 = 0.15
|
|
dThisUsed = dSCab;
|
|
dThisUsed /= param.dSize[0] * param.dSize[1];
|
|
|
|
//ext.累加 0.45 + 0.15
|
|
dFillUsed += dThisUsed * nAddOrSub;
|
|
pDataMap->SetAt(KEY_FILLUSED, dFillUsed);
|
|
}
|
|
}
|
|
else//有隔板,没有分层系统,走单层
|
|
{
|
|
dFillUsed = 0.0;
|
|
pDataMap->GetAt(KEY_FILLUSED, dFillUsed);
|
|
|
|
//ext.面积 / 总面积 = 0.15
|
|
dThisUsed = dSCab;
|
|
dThisUsed /= param.dSize[0] * param.dSize[1];
|
|
|
|
//ext.面积 / 总面积 = 0.15
|
|
dFillUsed += dThisUsed * nAddOrSub;
|
|
pDataMap->SetAt(KEY_FILLUSED, dFillUsed);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dFillUsed = 0.0;
|
|
pDataMap->GetAt(KEY_FILLUSED, dFillUsed);
|
|
|
|
//ext.面积 / 总面积 = 0.15
|
|
dThisUsed = dSCab;
|
|
dThisUsed /= param.dSize[0] * param.dSize[1];
|
|
|
|
//ext.面积 / 总面积 = 0.15
|
|
dFillUsed += dThisUsed * nAddOrSub;
|
|
pDataMap->SetAt(KEY_FILLUSED, dFillUsed);
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
EPosition AecDbECableTray::ExplainGripIndex(int nIndex) const
|
|
{
|
|
EPosition ePos = eStart;
|
|
switch(nIndex)
|
|
{
|
|
case 0:
|
|
{
|
|
ePos = eStart;
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
ePos = eMid;
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
ePos = eEnd;
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
ePos = (EPosition)(eCommand0 + nIndex - 3);
|
|
break;
|
|
}
|
|
}
|
|
return ePos;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::ImpGetGripPonts(AcGePoint3dArray& gripPoints,const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
const int nStbitflags = GRIPPT_RESP_FROM_EWFIT;
|
|
if (m_pBaseCurve != NULL)
|
|
{
|
|
AcGePoint3d ptSta,ptEnd;
|
|
m_pBaseCurve->getStartPoint(ptSta);
|
|
m_pBaseCurve->getEndPoint(ptEnd);
|
|
|
|
double dSta = 0.0,dEnd = 0.0;
|
|
m_pBaseCurve->getStartParam(dSta);
|
|
m_pBaseCurve->getEndParam(dEnd);
|
|
|
|
AcGeVector3d vtDir = ptEnd - ptSta;
|
|
vtDir.normalize();
|
|
|
|
AcGePoint3d ptMid;
|
|
m_pBaseCurve->getPointAtParam((dSta + dEnd) / 2.0,ptMid);
|
|
|
|
gripPoints.append(ptSta);
|
|
gripPoints.append(ptMid);
|
|
gripPoints.append(ptEnd);
|
|
|
|
if (bitflags == nStbitflags)
|
|
return Acad::eOk;
|
|
|
|
AcGeVector3d vtPerv = vtDir.perpVector();
|
|
AcGeVector3d vtNorm = vtDir.crossProduct(vtPerv);
|
|
vtNorm.normalize();
|
|
|
|
AcGePoint3d ptGe[4];
|
|
AcGeVector3d vtLine = ptEnd - ptSta;
|
|
vtLine.normalize();
|
|
|
|
AcGeVector3d vtVer = vtLine;
|
|
vtVer.normalize();
|
|
vtVer.rotateBy(PI / 2.0,vtNorm);
|
|
|
|
//增加三个命令夹点
|
|
AcGePoint3d ptCmd[3]; //Cmd 0,1
|
|
vtLine.normalize();
|
|
|
|
//按 15 个像素点
|
|
double dCmd = PixelToWcs(15);
|
|
|
|
if (vtLine.isParallelTo(AcGeVector3d::kZAxis))//立管
|
|
{
|
|
vtLine = AcGeVector3d::kXAxis;
|
|
|
|
ptCmd[0] = ptSta - dCmd * vtLine;
|
|
ptCmd[1] = ptEnd + dCmd * vtLine;
|
|
ptCmd[2] = ptMid + dCmd * AcGeVector3d::kYAxis;
|
|
}
|
|
else
|
|
{
|
|
ptCmd[0] = ptSta - dCmd * vtLine;
|
|
ptCmd[1] = ptEnd + dCmd * vtLine;
|
|
ptCmd[2] = ptMid + dCmd * vtVer;
|
|
}
|
|
|
|
gripPoints.append(ptCmd[0]);
|
|
gripPoints.append(ptCmd[1]);
|
|
gripPoints.append(ptCmd[2]);
|
|
|
|
//后面的是断管符号
|
|
//断管符号
|
|
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))
|
|
{
|
|
//开始
|
|
ptGeT = ptSta + vtDir * ptGeBK.x;
|
|
gripPoints.append(ptGeT);
|
|
|
|
//中间
|
|
ptGeT += vtDir * ptGeBK.y * 0.5;
|
|
gripPoints.append(ptGeT);
|
|
|
|
//结束
|
|
ptGeT += vtDir * ptGeBK.y * 0.5;
|
|
gripPoints.append(ptGeT);
|
|
}
|
|
}
|
|
|
|
//用户接口
|
|
for (int i = 0;i < m_arUserInfs.length();i++)
|
|
{
|
|
const AecUserInterface &infu = m_arUserInfs.at(i);
|
|
if (infu.nPoints == 2)
|
|
{
|
|
gripPoints.append(infu.ptGe[0] + infu.vtDir);
|
|
}
|
|
else if (infu.nPoints == 4)//目前只支持矩形
|
|
{
|
|
gripPoints.append( Mid(infu.ptGe[0], infu.ptGe[2]) + infu.vtDir);
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::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 = kWhite;
|
|
AcDbGripData* pGripData = NULL;
|
|
if ( bitflags >= 1394)
|
|
{
|
|
memset(&m_pGripAppData[0],0,sizeof(AecGripData));
|
|
m_pGripAppData[0].nIndex = 0;
|
|
m_pGripAppData[0].ePos = eFlag;
|
|
m_pGripAppData[0].nColor = nColor;
|
|
m_pGripAppData[0].ptGrip = gripPoints.at(0);
|
|
m_pGripAppData[0].pOwner = (AcDbEntity*)this;
|
|
|
|
pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(gripPoints.at(0));
|
|
pGripData->setAppData((void*)&m_pGripAppData[0]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
_tcscpy(m_pGripAppData[0].szTip,_T("点击定位造族<桥架>记录"));
|
|
_tcscpy(m_pGripAppData[0].szID,m_sGUID);
|
|
grips.append(pGripData);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
CString sCmd = _T("EW_HZFG");//绘制管道
|
|
EPosition ePos;
|
|
for (int i = 0;i < GRIP_MAXNUM && i < gripPoints.length();i++)
|
|
{
|
|
ePos = ExplainGripIndex(i);
|
|
if (ePos >= eCommand0 && ePos <= eCommand19)
|
|
{
|
|
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,sCmd);
|
|
_tcscpy(m_pGripAppData[i].szID,m_sGUID);
|
|
m_pGripAppData[i].pOwner = (AcDbEntity*)this;
|
|
m_pGripAppData[i].idHost = this->objectId();
|
|
|
|
pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(gripPoints.at(i));
|
|
pGripData->setAppData((void*)&m_pGripAppData[i]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
}
|
|
else
|
|
{
|
|
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 = this->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);
|
|
}
|
|
|
|
//调用基类加入单击修改
|
|
SubAddHitEditGrip(grips);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::subMoveGripPointsAt(const AcDbVoidPtrArray& gripAppData, const AcGeVector3d& offset, const int bitflags)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AecGripData* pAppData = NULL;
|
|
AcDbIntArray arIndex;
|
|
|
|
if (HitOnGripEdit(gripAppData))
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
if ( !gripAppData.isEmpty() )
|
|
{
|
|
pAppData = (AecGripData*)gripAppData.first();
|
|
arIndex.append(pAppData->nIndex);
|
|
}
|
|
else
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int nGripIndex = arIndex.first();
|
|
EPosition ePos = ExplainGripIndex(nGripIndex);
|
|
|
|
bool bMsgSendToAllInfs = false;
|
|
AcGeVector3d vtOffset = offset;
|
|
if(Is2DView())//如果是2D视图
|
|
{
|
|
//投影到XY
|
|
vtOffset = offset.orthoProject(GetUcsZvt());
|
|
|
|
AcDbLine* pLn = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
//小于10度的按照投影处理
|
|
//在夹角小于10度,认为是橡皮筋拉伸
|
|
AcGeVector3d vtLn = pLn->endPoint() - pLn->startPoint();
|
|
if (ePos == eStart || ePos == eEnd)
|
|
{
|
|
double dAngle = vtOffset.angleTo(vtLn);
|
|
dAngle *= 180.0 / PI;
|
|
//acutPrintf(_T("\nAngle = %g"),dAngle);
|
|
if ( ( (dAngle - 10.0 ) < 1.e-6 ) ||
|
|
( (180.0 - dAngle - 10.0 ) < 1.e-6) )
|
|
{
|
|
//认为是橡皮筋拉伸
|
|
AcGeVector3d vtNorm = vtLn;
|
|
vtNorm.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
AcGeVector3d vtOffsetOnLn = vtOffset.orthoProject(vtNorm);
|
|
vtOffsetOnLn.normalize();
|
|
vtOffsetOnLn *= vtOffset.length();
|
|
vtOffset = vtOffsetOnLn;
|
|
|
|
//仅仅本端口
|
|
bMsgSendToAllInfs = false;
|
|
}
|
|
else
|
|
{
|
|
bMsgSendToAllInfs = true;
|
|
}
|
|
}
|
|
else if (ePos == eMid)
|
|
{
|
|
AcGeVector3d vtNorm = vtLn;
|
|
vtLn.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
double dAngle = vtOffset.angleTo(vtLn);
|
|
dAngle *= 180.0 / PI;
|
|
|
|
//acutPrintf(_T("\nAngle = %g"),dAngle);
|
|
if ( ( (dAngle - 10.0 ) < 1.e-6 ) ||
|
|
( (180.0 - dAngle - 10.0 ) < 1.e-6) )
|
|
{
|
|
//认为是橡皮筋拉伸
|
|
AcGeVector3d vtOffsetOnLn = vtOffset.orthoProject(vtNorm);
|
|
vtOffsetOnLn.normalize();
|
|
vtOffsetOnLn *= vtOffset.length();
|
|
vtOffset = vtOffsetOnLn;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(vtOffset);
|
|
|
|
AcGePoint3dArray arBkPts;
|
|
GetBrokenOpenPnts(arBkPts);
|
|
int nBrok = arBkPts.length();
|
|
if (nGripIndex > 5 && nGripIndex < 5 + nBrok) //断管符号移动
|
|
{
|
|
nGripIndex -= 6;
|
|
return moveGripBrokenOpen(nGripIndex,offset);
|
|
}
|
|
|
|
GripMessage msg;
|
|
memset(&msg,0,sizeof(GripMessage));
|
|
//reset
|
|
msg.nSegindex = -1;
|
|
msg.nType = -1;
|
|
msg.idHost.setNull();
|
|
msg.pParam = 0;
|
|
msg.nData = -1;
|
|
_tcscpy(msg.szLockId, _T("0"));//锁定id,如果有
|
|
msg.fData = 0;
|
|
msg.nSegindex = 0;
|
|
msg.nSubSegIndex = 0;
|
|
msg.vtOffset.set(0,0,0);
|
|
msg.ptGrip.set(0,0,0);
|
|
|
|
AecInterface inf;
|
|
switch (ePos)
|
|
{
|
|
case eStart:
|
|
{
|
|
TransformAssocInf(0,xformM);
|
|
|
|
msg.nType = ePos;
|
|
msg.nData = bMsgSendToAllInfs ? -1 : 0;//控制消息源
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
break;
|
|
}
|
|
case eEnd:
|
|
{
|
|
TransformAssocInf(1,xformM);
|
|
|
|
msg.nType = ePos;
|
|
msg.nData = bMsgSendToAllInfs ? -1 : 1;//控制消息源
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
break;
|
|
}
|
|
case eMid:
|
|
{
|
|
TransformBy(xformM);
|
|
|
|
msg.nType = ePos;
|
|
msg.nData = -1;
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
break;
|
|
}
|
|
case eCommand0:
|
|
{
|
|
msg.nType = eCommand0;
|
|
msg.nData = 0;
|
|
GetInterface(msg.nData,inf);
|
|
msg.ptGrip = inf.ptPos;
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
CString sCmd = GetGripCmd();
|
|
if (!sCmd.IsEmpty())
|
|
{
|
|
acedPostCommand(_T("\x03"));
|
|
sCmd += _T("\n");
|
|
acedPostCommand(sCmd);
|
|
}
|
|
break;
|
|
}
|
|
case eCommand1:
|
|
{
|
|
msg.nType = eCommand1;
|
|
msg.nData = 1;
|
|
GetInterface(msg.nData,inf);
|
|
msg.ptGrip = inf.ptPos;
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
CString sCmd = GetGripCmd();
|
|
if (!sCmd.IsEmpty())
|
|
{
|
|
acedPostCommand(_T("\x03"));
|
|
sCmd += _T("\n");
|
|
acedPostCommand(sCmd);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
msg.nType = eCommand0;
|
|
msg.nData = 0;//按0接口
|
|
msg.ptGrip = pAppData->ptGrip;
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = vtOffset;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
CString sCmd = GetGripCmd();
|
|
if (!sCmd.IsEmpty())
|
|
{
|
|
acedPostCommand(_T("\x03"));
|
|
sCmd += _T("\n");
|
|
acedPostCommand(sCmd);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::moveGripBrokenOpen(int nBrokenGrip,const AcGeVector3d& offset)
|
|
{
|
|
AssertWriteEnabled();
|
|
AcGePoint3d ptSta = StartPoint();
|
|
AcGePoint3d ptEnd = EndPoint();
|
|
AcDbLine ln(ptSta,ptEnd);
|
|
|
|
AcGeVector3d vtDir = ptEnd - ptSta;
|
|
vtDir.normalize();
|
|
|
|
int nBrokenindex = nBrokenGrip / 3;
|
|
int nBrokenHit = nBrokenGrip % 3;
|
|
|
|
//断管符号
|
|
double dLen;
|
|
AcGePoint3d ptGeT,ptGeBK,ptGe1,ptGe2,ptGe3;
|
|
AcGePoint3dArray arPoints;
|
|
CString sIndex;
|
|
|
|
for(int i = 0;i < PIPE_BROKENNUM;i++)
|
|
{
|
|
sIndex.Format(_T("BKOP%d"),i);
|
|
if (m_mapSpecXData.GetAt(sIndex,ptGeBK))
|
|
{
|
|
if (nBrokenindex == i)
|
|
{
|
|
//开始
|
|
ptGe1 = ptSta + vtDir * ptGeBK.x;
|
|
|
|
//中间
|
|
ptGe2 = ptGe1 + vtDir * ptGeBK.y * 0.5;
|
|
|
|
//结束
|
|
ptGe3 = ptGe2 + vtDir * ptGeBK.y * 0.5;
|
|
|
|
switch(nBrokenHit)
|
|
{
|
|
case 0: //改长度和断开长度
|
|
{
|
|
ptGe1 += offset;
|
|
ln.getClosestPointTo(ptGe1,ptGe1);
|
|
|
|
ptGeBK.x = ptGe1.distanceTo(ptSta);
|
|
if (ptGeBK.x - ptSta.distanceTo(ptEnd) > 1.e-10)
|
|
{
|
|
//超出算删除
|
|
m_mapSpecXData.RemoveAt(sIndex);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
ptGeBK.y = ptGe3.distanceTo(ptGe1);
|
|
m_mapSpecXData.SetAt(sIndex,ptGeBK);
|
|
|
|
break;
|
|
}
|
|
case 1: // 改长度
|
|
{
|
|
ptGe1 += offset;
|
|
ln.getClosestPointTo(ptGe1,ptGe1);
|
|
|
|
dLen = ptGe3.distanceTo(ptSta);
|
|
if (dLen - ptSta.distanceTo(ptEnd) > 1.e-10)
|
|
{
|
|
//超出算删除
|
|
m_mapSpecXData.RemoveAt(sIndex);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
ptGeBK.x = ptGe1.distanceTo(ptSta);
|
|
m_mapSpecXData.SetAt(sIndex,ptGeBK);
|
|
break;
|
|
}
|
|
case 2://改断开长度
|
|
{
|
|
ptGe3 += offset;
|
|
ln.getClosestPointTo(ptGe3,ptGe3);
|
|
|
|
dLen = ptGe3.distanceTo(ptSta);
|
|
if (dLen - ptSta.distanceTo(ptEnd) > 1.e-10)
|
|
{
|
|
//超出算删除
|
|
m_mapSpecXData.RemoveAt(sIndex);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
dLen = ptGe3.distanceTo(ptGe1);
|
|
ptGeBK.y = dLen;
|
|
m_mapSpecXData.SetAt(sIndex,ptGeBK);
|
|
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbECableTray::GetGripText(int nPos, CString& sText)
|
|
{
|
|
sText = _T("夹点");
|
|
}
|
|
|
|
#endif
|
|
|
|
Acad::ErrorStatus AecDbECableTray::ShowUsedFill(AcGiDraw &dc) const
|
|
{
|
|
//显示已用填充率
|
|
struct resbuf rb;
|
|
rb.resval.rint = 0;
|
|
acedGetVar(_T("useri3"), &rb);
|
|
if (rb.resval.rint == 1395)
|
|
{
|
|
CString sFill, sFill2, sText;
|
|
//显示填充率
|
|
double dFillUsed1 = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_FILLUSED, dFillUsed1);//0.65
|
|
if (dFillUsed1 > 0.001)
|
|
{
|
|
sFill.Format(_T("已用填充率=%d%%"), (int)(dFillUsed1 * 100));
|
|
}
|
|
|
|
double dFillUsed2 = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_FILLUSED2, dFillUsed2);
|
|
if (dFillUsed2 > 0.001)
|
|
{
|
|
sFill2.Format(_T("已用填充率2=%d%%"), (int)(dFillUsed2 * 100));
|
|
}
|
|
sText = sFill + sFill2;
|
|
if (!sText.IsEmpty())
|
|
{
|
|
AcGePoint3d pt1 = StartPoint();
|
|
AcGePoint3d pt2 = EndPoint();
|
|
AcGePoint3d pt3;
|
|
Midpoint(pt1, pt2, pt3);
|
|
double dH = 2.5;
|
|
m_mapSpecXData.GetAt(KEY_SIZE1, dH);
|
|
dH *= 0.25;
|
|
dc.DrawTextFit(sText, pt3, pt2, dH, _T("Standard"));
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
BOOL DLLIMPEXP GetDocScale(double &dPScale);
|
|
Acad::ErrorStatus AecDbECableTray::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es = AecDbEwPipeBase::Draw2d(dc);
|
|
|
|
ShowUsedFill(dc);
|
|
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::DrawUserInf(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d ptGe[16], ptGe1, ptGe2, ptS, ptE;
|
|
for (int i = 0; i < m_arUserInfs.length(); i++)
|
|
{
|
|
const AecUserInterface &inf = m_arUserInfs.at(i);
|
|
|
|
if (inf.nPoints == 2)
|
|
{
|
|
AcDbCircle *pCir = new AcDbCircle;
|
|
pCir->setCenter(inf.ptGe[0]);
|
|
pCir->setNormal(inf.vtDir);
|
|
pCir->setRadius(inf.ptGe[1].distanceTo(inf.ptGe[0]));
|
|
pCir->setLayer(layerId());
|
|
|
|
if (inf.vtDir.isParallelTo(AcGeVector3d::kZAxis))
|
|
{
|
|
dc.DrawEntity(pCir);
|
|
Add2DBuffer(pCir);
|
|
}
|
|
else
|
|
{
|
|
AcDbCurve *pCurve = NULL;
|
|
pCir->getOrthoProjectedCurve(AcGePlane::kXYPlane, pCurve);
|
|
if (pCurve != NULL)
|
|
{
|
|
dc.DrawEntity(pCurve);
|
|
Add2DBuffer(pCurve);
|
|
|
|
pCurve->getStartPoint(ptS);
|
|
pCurve->getEndPoint(ptE);
|
|
|
|
AcDbLine *pLn = NULL;
|
|
|
|
ptGe1 = ptS + inf.vtDir;
|
|
pLn = new AcDbLine(ptS, ptGe1);
|
|
pLn->setLayer(layerId());
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
|
|
ptGe2 = ptE + inf.vtDir;
|
|
pLn = new AcDbLine(ptE, ptGe2);
|
|
pLn->setLayer(layerId());
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
|
|
pLn = new AcDbLine(ptGe1, ptGe2);
|
|
pLn->setLayer(layerId());
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
}
|
|
delete pCir;
|
|
}
|
|
}
|
|
else if (inf.nPoints > 2)
|
|
{
|
|
//投影到XY
|
|
AcGePoint3dArray arPts, arPts2;
|
|
for (int j = 0; j < inf.nPoints; j++)
|
|
{
|
|
ptGe[j] = inf.ptGe[j].orthoProject(AcGePlane::kXYPlane);
|
|
if (arPts.find(ptGe[j]) == -1)
|
|
arPts.append(ptGe[j]);
|
|
}
|
|
|
|
AcDbLine *pLn = NULL;
|
|
if (!inf.vtDir.isParallelTo(AcGeVector3d::kZAxis))
|
|
{
|
|
for (int j = 0; j < arPts.length(); j++)
|
|
{
|
|
ptGe2 = arPts.at(j) + inf.vtDir;
|
|
arPts2.append(ptGe2);
|
|
pLn = new AcDbLine(arPts.at(j), ptGe2);
|
|
pLn->setLayer(layerId());
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
}
|
|
|
|
for (int j = 0; j < arPts2.length() - 1; j++)
|
|
{
|
|
pLn = new AcDbLine(arPts2.at(j), arPts2.at(j + 1));
|
|
pLn->setLayer(layerId());
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
arPts.removeAll();
|
|
for (int j = 0; j < inf.nPoints; j++)
|
|
{
|
|
ptGe[j] = inf.ptGe[j].orthoProject(AcGePlane::kXYPlane);
|
|
|
|
if (arPts.length() > 0)
|
|
{
|
|
pLn = new AcDbLine(arPts.last(), ptGe[j]);
|
|
pLn->setLayer(layerId());
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
}
|
|
arPts.append(ptGe[j]);
|
|
|
|
if (j == inf.nPoints - 1)
|
|
{
|
|
pLn = new AcDbLine(arPts.first(), ptGe[j]);
|
|
pLn->setLayer(layerId());
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int nApp = WPipe::eBridge;
|
|
m_mapSpecXData.GetAt(KEY_APP, nApp);
|
|
WPipe::EApp eApp = (WPipe::EApp)nApp;
|
|
|
|
switch (eApp)
|
|
{
|
|
case WPipe::eBridge:
|
|
{
|
|
DrawBridge(dc);
|
|
break;
|
|
}
|
|
case WPipe::eTrench:
|
|
{
|
|
DrawTrech3D(dc);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcDbRegion *CreateRegion(const AcGePoint3d* pptGe,int nPoints, const AcGeVector3d& vtNorm,double dt)
|
|
{
|
|
AcDbVoidPtrArray arOutPl, arRegOuts;
|
|
AcDbVoidPtrArray arInPl, arRegIns;
|
|
|
|
if (nPoints == 2)
|
|
{
|
|
double dR = pptGe[1].distanceTo(pptGe[0]);
|
|
|
|
AcDbCircle *pCirIn = new AcDbCircle;
|
|
pCirIn->setCenter(pptGe[0]);
|
|
pCirIn->setNormal(vtNorm);
|
|
pCirIn->setRadius(dR);
|
|
|
|
AcDbCircle *pCirOut = new AcDbCircle;
|
|
pCirOut->setCenter(pptGe[0]);
|
|
pCirOut->setNormal(vtNorm);
|
|
pCirOut->setRadius(dR + dt);
|
|
|
|
arOutPl.append(pCirOut);
|
|
AcDbRegion::createFromCurves(arOutPl, arRegOuts);
|
|
|
|
arInPl.append(pCirIn);
|
|
AcDbRegion::createFromCurves(arInPl, arRegIns);
|
|
|
|
delete pCirOut;
|
|
delete pCirIn;
|
|
}
|
|
else if (nPoints >= 3)
|
|
{
|
|
AcDbPolyline *pPl = Format3dPolyline(pptGe, nPoints, vtNorm);
|
|
|
|
AcDbPolyline *pPlIn = NULL;
|
|
if (pPl != NULL && dt > 1.e-1)
|
|
{
|
|
pPl->setClosed(Adesk::kTrue);
|
|
pPlIn = (AcDbPolyline *)GetMinOffsetCurve(pPl, dt);
|
|
if (pPlIn != NULL)
|
|
{
|
|
arOutPl.append(pPl);
|
|
AcDbRegion::createFromCurves(arOutPl, arRegOuts);
|
|
|
|
arInPl.append(pPlIn);
|
|
AcDbRegion::createFromCurves(arInPl, arRegIns);
|
|
|
|
delete pPlIn;
|
|
delete pPl;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pPl->setClosed(Adesk::kTrue);
|
|
|
|
arOutPl.append(pPl);
|
|
AcDbRegion::createFromCurves(arOutPl, arRegOuts);
|
|
}
|
|
}
|
|
|
|
if (!arRegOuts.isEmpty() && !arRegIns.isEmpty())
|
|
{
|
|
AcDbRegion *pRegOut = (AcDbRegion *)arRegOuts.first();
|
|
AcDbRegion *pRegIn = (AcDbRegion *)arRegIns.first();
|
|
|
|
if (pRegOut != NULL && pRegIn != NULL)
|
|
{
|
|
if (Acad::eOk == pRegOut->booleanOper(AcDb::kBoolSubtract, pRegIn))
|
|
{
|
|
return pRegOut;
|
|
}
|
|
}
|
|
}
|
|
else if (!arRegOuts.isEmpty())
|
|
{
|
|
AcDbRegion *pRegOut = (AcDbRegion *)arRegOuts.first();
|
|
return pRegOut;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::DrawUserInf3d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcCmTransparency tr = transparency();
|
|
|
|
double dt = 0.0;
|
|
m_mapSpecXData.GetAt(PIPE_THICK, dt);
|
|
|
|
AcDbLine lnPath;
|
|
AcDbRegion *pRegion = NULL;
|
|
for (int i = 0; i < m_arUserInfs.length(); i++)
|
|
{
|
|
const AecUserInterface &inf = m_arUserInfs.at(i);
|
|
|
|
lnPath.setStartPoint(inf.ptGe[0]);
|
|
lnPath.setEndPoint(inf.ptGe[0] + inf.vtDir);
|
|
|
|
AecDbX3dPart part;
|
|
if (inf.nPoints >= 3) //多边形
|
|
{
|
|
pRegion = CreateRegion(inf.ptGe,inf.nPoints,inf.vtDir,dt);
|
|
if (pRegion != NULL)
|
|
{
|
|
AcDbX3dSolid *pX3dSolidTop = new AcDbX3dSolid;
|
|
pX3dSolidTop->CreateExtrude(pRegion, lnPath);
|
|
part.AddX3dSolid(pX3dSolidTop);
|
|
}
|
|
}
|
|
else if (inf.nPoints == 2)//圆
|
|
{
|
|
pRegion = CreateRegion(inf.ptGe,inf.nPoints,inf.vtDir,dt);
|
|
if (pRegion != NULL)
|
|
{
|
|
AcDbX3dSolid *pX3dSolidTop = new AcDbX3dSolid;
|
|
pX3dSolidTop->CreateExtrude(pRegion, lnPath);
|
|
part.AddX3dSolid(pX3dSolidTop);
|
|
}
|
|
}
|
|
|
|
part.Create();
|
|
AcDb3dSolid *pSolid = part.CreateDraw3dSolid();
|
|
if (pSolid != NULL)
|
|
{
|
|
pSolid->setTransparency(tr);
|
|
dc.DrawEntity(pSolid);
|
|
Add3DBuffer(pSolid);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::DrawBridge(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es = AecDbEwPipeBase::Draw3d(dc);
|
|
|
|
FreeBuffer(0, m_arDrawBuffer3d2);
|
|
|
|
AcGePoint3d ptSta = StartPoint();
|
|
AcGePoint3d ptEnd = EndPoint();
|
|
|
|
AcGeVector3d vtDir = EndPoint() - StartPoint();
|
|
vtDir.normalize();
|
|
|
|
Adesk::Int16 nCr = dc.GetColor();
|
|
|
|
if (IsActive())
|
|
{
|
|
AcDbEntity *p3dEnt = NULL;
|
|
double dOD = 0.0;
|
|
if (m_mapSpecXData.GetAt(KEY_SIZE1, dOD))
|
|
{
|
|
dc.SetColor(kMagenta);
|
|
p3dEnt = dc.DrawPipe(ptSta, ptEnd, 0.5 * dOD, 0.0);
|
|
if (p3dEnt != NULL)
|
|
{
|
|
DrawSubAxis(dc, p3dEnt);
|
|
m_arDrawBuffer3d2.append(p3dEnt);
|
|
}
|
|
}
|
|
}
|
|
|
|
AcGePoint3d ptGeFr, ptGeTo;
|
|
if (m_bShowFlowDir)//流向
|
|
{
|
|
dc.SetColor(kMagenta);//kMagenta
|
|
|
|
vtDir.normalize();
|
|
vtDir *= PixelToWcs(30);
|
|
|
|
//clinder
|
|
ptGeFr = Mid(ptSta, ptEnd);
|
|
ptGeTo = ptGeFr + vtDir;
|
|
|
|
double dDn = 0.0;
|
|
m_mapSpecXData.GetAt(KEY_SIZE1, dDn);
|
|
|
|
ptGeFr.z += 1.1 * dDn;
|
|
ptGeTo.z += 1.1 * dDn;
|
|
AcDbEntity *p3d = dc.DrawCone(ptGeFr, PixelToWcs(1), ptGeTo, PixelToWcs(1));
|
|
if (p3d != NULL)
|
|
{
|
|
m_arDrawBuffer3d2.append(p3d);
|
|
}
|
|
|
|
//arrow
|
|
ptGeFr = ptGeTo;
|
|
vtDir.normalize();
|
|
ptGeTo += vtDir * PixelToWcs(15);
|
|
p3d = dc.DrawCone(ptGeFr, PixelToWcs(5), ptGeTo, 1.e-3);
|
|
if (p3d != NULL)
|
|
{
|
|
m_arDrawBuffer3d2.append(p3d);
|
|
}
|
|
}
|
|
dc.SetColor(nCr);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
bool FormatRect(AcGePoint3d *pptGe, double dw, double dt)
|
|
{
|
|
pptGe[0].set(0, 0, 0);
|
|
pptGe[0].x -= dw;
|
|
pptGe[0].y += 0.5 * dt;
|
|
|
|
pptGe[1] = pptGe[0];
|
|
pptGe[1].x += dw;
|
|
|
|
pptGe[2] = pptGe[1];
|
|
pptGe[2].y -= dt;
|
|
|
|
pptGe[3] = pptGe[0];
|
|
pptGe[3].y -= dt;
|
|
|
|
pptGe[4] = pptGe[0];
|
|
|
|
return true;
|
|
}
|
|
|
|
extern AcDbRegion *CreatePolygonRegionOnly(AcGePoint3d *pPoints, int nSize);
|
|
bool AecDbECableTray::GetDlgRegionData(DlgData &data, AcArray<RegionAndEl> &arRegEl) const
|
|
{
|
|
AcDbRegion *pRegion = NULL;
|
|
|
|
//原始位置为原点
|
|
//底板
|
|
AcDbVoidPtrArray arLnPtrs;
|
|
RegionAndEl rel;
|
|
rel.pReg = NULL;
|
|
_tcscpy(rel.m_szMat, _T("混凝土"));
|
|
|
|
AcGePoint3d ptGe[5];
|
|
|
|
FormatRect(ptGe, data.m_dd, data.m_db);
|
|
|
|
pRegion = CreatePolygonRegionOnly(ptGe, 5);
|
|
if (pRegion == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
rel.m_dZ = data.m_dTopEl;
|
|
rel.m_dZ -= data.m_dk;
|
|
rel.m_dZ -= data.m_dH;
|
|
rel.m_dZ -= 0.5 * data.m_db;
|
|
rel.pReg = pRegion;
|
|
rel.nType = 1;//板
|
|
rel.m_dX = 0.0;//偏移
|
|
rel.dSize[0] = data.m_dd;
|
|
rel.dSize[1] = data.m_db;
|
|
rel.dSize[2] = 0.0;
|
|
arRegEl.append(rel);
|
|
|
|
//侧面墙体
|
|
FormatRect(ptGe, data.m_dt, (data.m_dH - data.m_dh2));
|
|
pRegion = CreatePolygonRegionOnly(ptGe, 5);
|
|
if (pRegion == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
_tcscpy(rel.m_szMat, _T("砌砖墙体"));
|
|
rel.m_dZ = data.m_dTopEl;
|
|
rel.m_dZ -= data.m_dk;
|
|
rel.m_dZ -= data.m_dh2;
|
|
rel.m_dZ -= 0.5 * (data.m_dH - data.m_dh2);
|
|
rel.m_dX = 0.0;
|
|
rel.m_dX -= 0.5 * data.m_dW;
|
|
rel.m_dX -= 0.5 * data.m_dt;
|
|
rel.pReg = pRegion;
|
|
rel.nType = 2;//墙
|
|
|
|
rel.dSize[0] = data.m_dt;
|
|
rel.dSize[1] = (data.m_dH - data.m_dh2);
|
|
rel.dSize[2] = 0.0;
|
|
|
|
arRegEl.append(rel);
|
|
|
|
//侧面墙体2
|
|
rel.m_dX += (data.m_dW + data.m_dt);
|
|
rel.pReg = (AcDbRegion *)pRegion->clone();
|
|
arRegEl.append(rel);
|
|
|
|
//压顶
|
|
FormatRect(ptGe, data.m_dt, data.m_dh2);
|
|
pRegion = CreatePolygonRegionOnly(ptGe, 5);
|
|
if (pRegion == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
_tcscpy(rel.m_szMat, _T("混凝土"));
|
|
rel.m_dZ = data.m_dTopEl;
|
|
rel.m_dZ -= data.m_dk;
|
|
rel.m_dZ -= 0.5 * data.m_dh2;
|
|
rel.pReg = pRegion;
|
|
rel.nType = 2;
|
|
rel.m_dX = 0.0;
|
|
rel.m_dX -= 0.5 * data.m_dW;
|
|
rel.m_dX -= 0.5 * data.m_dt;
|
|
|
|
rel.dSize[0] = data.m_dt;
|
|
rel.dSize[1] = data.m_dh2;
|
|
rel.dSize[2] = 0.0;
|
|
|
|
arRegEl.append(rel);
|
|
|
|
rel.m_dX += (data.m_dW + data.m_dt);
|
|
rel.pReg = (AcDbRegion *)pRegion->clone();
|
|
arRegEl.append(rel);
|
|
|
|
//盖板
|
|
if (data.m_bHasCover)
|
|
{
|
|
FormatRect(ptGe, data.m_dW + 2.0 * data.m_dt, data.m_dk);
|
|
pRegion = CreatePolygonRegionOnly(ptGe, 5);
|
|
if (pRegion == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
_tcscpy(rel.m_szMat, _T("钢筋混凝土盖板"));
|
|
rel.m_dZ = data.m_dTopEl;
|
|
rel.m_dZ -= 0.5 * data.m_dk;
|
|
rel.m_dX = 0.0;
|
|
rel.nType = 1;// 板
|
|
rel.pReg = pRegion;
|
|
|
|
rel.dSize[0] = data.m_dW + 2.0 * data.m_dt;
|
|
rel.dSize[1] = data.m_dk;
|
|
rel.dSize[2] = 0.0;
|
|
|
|
arRegEl.append(rel);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::DrawTrech3D(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcCmTransparency tr = transparency();
|
|
AcCmTransparency oldTr = dc.SetTransparency(tr);
|
|
|
|
////管线系统屏蔽掉
|
|
if (dc.IsDragging())
|
|
{
|
|
//return Acad::eOk;
|
|
}
|
|
|
|
if (m_pBaseCurve == NULL)
|
|
return Acad::eInvalidInput;
|
|
|
|
//图层
|
|
AcDbObjectId idLay = dc.GetLayerId();
|
|
dc.SetLayer(layerId());
|
|
|
|
int nCrBk = dc.GetColor();
|
|
|
|
DrawInfArrow(dc);
|
|
|
|
int nColor = nCrBk;
|
|
if (m_mapSpecXData.GetAt(_T("COLOR"), nColor))
|
|
{
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
int nSegIndex = m_nInfActive / 2;
|
|
if (m_nInfActive < 0)
|
|
nSegIndex = -1;
|
|
|
|
if (IsActive())
|
|
{
|
|
nColor = kMagenta;
|
|
m_mapSpecXData.GetAt(KEY_ACTIVECR, nColor);
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
//AcDb3dSolid
|
|
if (Has3DBuffer())
|
|
{
|
|
AcDbEntity *pEnt = NULL;
|
|
const AcDbVoidPtrArray &ar3D = Get3DBuffer();
|
|
for (int i = 0; i < ar3D.length(); i++)
|
|
{
|
|
pEnt = (AcDbEntity *)ar3D.at(i);
|
|
if (nSegIndex == i)//线缆段
|
|
{
|
|
pEnt->setColorIndex(kMagenta);
|
|
}
|
|
else
|
|
{
|
|
if (IsActive())
|
|
{
|
|
BackupColorIndex(pEnt);
|
|
pEnt->setColorIndex(nColor);
|
|
}
|
|
else
|
|
{
|
|
SetBackupColorIndex(pEnt);
|
|
}
|
|
}
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
|
|
dc.SetLayer(idLay);
|
|
dc.SetColor(nCrBk);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
DlgData data;
|
|
memset(&data, 0, sizeof(DlgData));
|
|
|
|
if (!GetDlgData(data))
|
|
return Acad::eOk;
|
|
|
|
AcArray<RegionAndEl> arRegEl;
|
|
GetDlgRegionData(data, arRegEl);
|
|
|
|
AcDbObjectId idLayerWall = KTSetting::InitLayer(_T("LAY_WALL"), true);
|
|
AcDbObjectId idLayerSlab = KTSetting::InitLayer(_T("LAY_SLAB"), true);
|
|
|
|
AecDb3dRoadAxisLine roadAx;
|
|
roadAx.AppendCurveSeg(m_pBaseCurve);
|
|
AecDb3dRoadAxisLine *pRoad = &roadAx;
|
|
|
|
for (int i = 0; i < arRegEl.length(); i++)
|
|
{
|
|
RegionAndEl &rel = arRegEl.at(i);
|
|
|
|
if (rel.nType == 2)// 墙体
|
|
{
|
|
AcDbPolyline *pPl = pRoad->ConvertTo2dPline();
|
|
if (pPl != NULL)
|
|
{
|
|
AcDbVoidPtrArray arOff;
|
|
pPl->getOffsetCurves(rel.m_dX, arOff);
|
|
if (!arOff.isEmpty())
|
|
{
|
|
AcDbCurve *pPlCrv = (AcDbCurve *)arOff.first();
|
|
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
pPlCrv->explode(arCurPtrs);
|
|
|
|
//去处0长度线
|
|
double dEnd = 0.0, dEndL = 0.0;
|
|
AcDbCurve *pCurveT = NULL;
|
|
for (int n = 0; n < arCurPtrs.length(); n++)
|
|
{
|
|
pCurveT = (AcDbCurve *)arCurPtrs.at(n);
|
|
pCurveT->getEndParam(dEnd);
|
|
pCurveT->getDistAtParam(dEnd, dEndL);
|
|
if (dEndL < 1.e-2)
|
|
{
|
|
arCurPtrs.removeAt(n);
|
|
n -= 1;
|
|
delete pCurveT;
|
|
}
|
|
}
|
|
|
|
//创建墙体
|
|
CString sSubNo;
|
|
AecDbXWall *pWall = NULL;
|
|
for (int ii = 0; ii < arCurPtrs.length(); ii++)
|
|
{
|
|
sSubNo.Format(_T("WALL-%d"), ii + 1);
|
|
|
|
pCurveT = (AcDbCurve *)arCurPtrs.at(ii);
|
|
|
|
pWall = new AecDbXWall;
|
|
pWall->SetBaseCurve(pCurveT);
|
|
pWall->GetSpecialtyData()->SetAt(KEY_NO, sSubNo);
|
|
pWall->GetSpecialtyData()->SetAt(KEY_MATERIAL, rel.m_szMat);
|
|
pWall->GetSpecialtyData()->SetAt(KEY_3DSHOW, 0);
|
|
|
|
pWall->SetWallData(rel.dSize[0], rel.dSize[1], rel.m_dZ - 0.5 * rel.dSize[1], kMid);
|
|
pWall->setLayer(idLayerWall);
|
|
pWall->Draw3d(dc);
|
|
|
|
dc.Add3dBuffer(pWall->Get3DBuffer());
|
|
pWall->Clean3DBufferNoDel();
|
|
delete pWall;
|
|
}
|
|
}
|
|
|
|
delete pPl;
|
|
}
|
|
}
|
|
else if (rel.nType == 1)//板
|
|
{
|
|
AcDbPolyline *pPl = pRoad->ConvertTo2dPline();
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setElevation(rel.m_dZ);
|
|
|
|
CString sNo;
|
|
sNo.Format(_T("板_%d"), i);
|
|
|
|
AecDbXSlab *pSlab = new AecDbXSlab;
|
|
pSlab->SetSection(rel.dSize[0], rel.dSize[1], 0.0);
|
|
pSlab->setLayer(idLayerSlab);
|
|
pSlab->SetBaseCurve(pPl);
|
|
pSlab->GetSpecialtyData()->SetAt(KEY_2DSTYLE, 2);
|
|
|
|
pSlab->GetSpecialtyData()->SetAt(KEY_MATERIAL, rel.m_szMat);
|
|
pSlab->GetSpecialtyData()->SetAt(KEY_NO, sNo);
|
|
pSlab->SetHatch(_T("AR-CONC"), 0.0, 1.0);
|
|
|
|
pSlab->Draw3d(dc);
|
|
|
|
dc.Add3dBuffer(pSlab->Get3DBuffer());
|
|
pSlab->Clean3DBufferNoDel();
|
|
delete pSlab;
|
|
|
|
delete pPl;
|
|
}
|
|
}
|
|
else //其他
|
|
{
|
|
//...
|
|
}
|
|
|
|
//释放截面
|
|
if (rel.pReg != NULL)
|
|
delete rel.pReg;
|
|
rel.pReg = NULL;
|
|
}
|
|
|
|
//然后绘制支吊架
|
|
bool bSucess(false);
|
|
XHolder lH;
|
|
memset(&lH, 0, sizeof(XHolder));
|
|
bSucess = GetXHolder(kLeft,lH);
|
|
|
|
AcGeVector3d vtDir, vtL,vtR;
|
|
AcDbLine *pLnBase = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLnBase != NULL)
|
|
{
|
|
vtDir = pLnBase->endPoint() - pLnBase->startPoint();
|
|
vtDir.normalize();
|
|
|
|
vtL = vtDir;
|
|
vtL.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
|
|
|
vtR = vtDir;
|
|
vtR.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
|
}
|
|
|
|
if (bSucess && lH.N > 0 && pLnBase != NULL)
|
|
{
|
|
AcGePoint3d ptL = StartPoint();
|
|
ptL += vtDir * 5.0 * lH.W;
|
|
|
|
ptL.z += (data.m_dH + data.m_db + data.m_dk) * 0.5;//到顶
|
|
ptL.z -= (data.m_dk + data.m_dH);//到内底
|
|
ptL += vtR * 0.5 * data.m_dW;
|
|
ptL.z += lH.nDists[0];//第一行底
|
|
|
|
AecDbHolder lHolder;
|
|
lHolder.SetPosition(ptL,vtL);
|
|
lHolder.SetHolder(lH);
|
|
|
|
lHolder.Draw3d(dc);
|
|
dc.Add3dBuffer(lHolder.Get3DBuffer());
|
|
lHolder.Clean3DBufferNoDel();
|
|
}
|
|
|
|
XHolder rH;
|
|
memset(&rH, 0, sizeof(XHolder));
|
|
bSucess = GetXHolder(kRight, rH);
|
|
if (bSucess && lH.N > 0 && pLnBase != NULL)
|
|
{
|
|
AcGePoint3d ptR = StartPoint();
|
|
ptR += vtDir * 5.0 * lH.W;
|
|
|
|
ptR.z += (data.m_dH + data.m_db + data.m_dk) * 0.5;//到顶
|
|
ptR.z -= (data.m_dk + data.m_dH);//到内底
|
|
ptR += vtL * 0.5 * data.m_dW;
|
|
ptR.z += lH.nDists[0];//第一行底
|
|
|
|
AecDbHolder rHolder;
|
|
rHolder.SetPosition(ptR, vtR);
|
|
rHolder.SetHolder(rH);
|
|
|
|
rHolder.Draw3d(dc);
|
|
dc.Add3dBuffer(rHolder.Get3DBuffer());
|
|
rHolder.Clean3DBufferNoDel();
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
bool AecDbECableTray::TransformAssocInf(int nInf,const AcGeMatrix3d& xform)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcArray<AecInterface> arInf;
|
|
GetInterface(arInf);
|
|
|
|
if (nInf > -1 && nInf < arInf.length() )
|
|
{
|
|
AecInterface& inf = arInf.at(nInf);
|
|
|
|
AcGePoint3d ptGe = inf.ptPos;
|
|
ptGe.transformBy(xform);
|
|
|
|
AcDbLine* pLine = AcDbLine::cast(m_pBaseCurve);
|
|
if (pLine != NULL)//直管
|
|
{
|
|
AcGePoint3d ptSta,ptEnd;
|
|
ptSta = pLine->startPoint();
|
|
ptEnd = pLine->endPoint();
|
|
AcGeVector3d vtL = ptEnd - ptSta;
|
|
|
|
if (inf.ptPos.distanceTo(ptSta) < 1.e-1)
|
|
{
|
|
pLine->setStartPoint(ptGe);//新位置z
|
|
|
|
AcGeVector3d vtL2 = ptEnd - ptGe;
|
|
if (!vtL2.isParallelTo(vtL))
|
|
{
|
|
ptEnd.transformBy(xform);
|
|
pLine->setEndPoint(ptEnd);
|
|
return true;//继续发消息
|
|
}
|
|
return false;//不再继续发消息
|
|
}
|
|
|
|
if (inf.ptPos.distanceTo(ptEnd) < 1.e-1)
|
|
{
|
|
pLine->setEndPoint(ptGe);//新位置
|
|
|
|
AcGeVector3d vtL2 = ptGe - ptSta;
|
|
if (!vtL.isParallelTo(vtL2))
|
|
{
|
|
ptSta.transformBy(xform);
|
|
pLine->setStartPoint(ptSta);
|
|
return true;//继续发消息
|
|
}
|
|
return false;//不再继续发消息
|
|
}
|
|
}
|
|
|
|
AcDbArc* pArc = AcDbArc::cast(m_pBaseCurve);//弧管
|
|
if (pArc != NULL)
|
|
{
|
|
AcGePoint3d ptSta,ptEnd,ptMid;
|
|
pArc->getStartPoint(ptSta);
|
|
pArc->getEndPoint(ptEnd);
|
|
|
|
double dSta = 0.0,dEnd = 0.0;
|
|
pArc->getStartParam(dSta);
|
|
pArc->getEndParam(dEnd);
|
|
double dMid = (dSta + dEnd) / 2.0;
|
|
pArc->getPointAtParam(dMid,ptMid);
|
|
|
|
if (inf.ptPos.distanceTo(ptSta) < 1.e-1)
|
|
{
|
|
AcDbArc* pArc2 = KTCADUtilityEx::FormatArc(ptGe,ptMid,ptEnd);
|
|
if (pArc2 != NULL)
|
|
{
|
|
pArc->setStartAngle(pArc2->startAngle());
|
|
pArc->setEndAngle(pArc2->endAngle());
|
|
pArc->setCenter(pArc2->center());
|
|
pArc->setRadius(pArc2->radius());
|
|
DELETE_PTR(pArc2);
|
|
}
|
|
return false;//不在继续发消息
|
|
}
|
|
|
|
if (inf.ptPos.distanceTo(ptEnd) < 1.e-1)
|
|
{
|
|
AcDbArc* pArc2 = KTCADUtilityEx::FormatArc(ptSta,ptMid,ptGe);
|
|
if (pArc2 != NULL)
|
|
{
|
|
pArc->setStartAngle(pArc2->startAngle());
|
|
pArc->setEndAngle(pArc2->endAngle());
|
|
pArc->setCenter(pArc2->center());
|
|
pArc->setRadius(pArc2->radius());
|
|
DELETE_PTR(pArc2);
|
|
}
|
|
return false;//不在继续发消息
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
LPCTSTR AecDbECableTray::GetGripCmd() const
|
|
{
|
|
assertReadEnabled();
|
|
return _T("EL_cabtryadd");
|
|
}
|
|
|
|
bool AecDbECableTray::GetSectionDraw(AcGePlane& plan,const AcGeVector3d& vtTo,AcDbVoidPtrArray& arRegionPtrs) const
|
|
{
|
|
AcGeMatrix3d xform;
|
|
xform.setToPlaneToWorld(plan);
|
|
xform.invert();
|
|
|
|
AcDbVoidPtrArray arSubPtrs;
|
|
AecDbECableTray* pFit = (AecDbECableTray *)clone();
|
|
if (pFit != NULL)
|
|
{
|
|
pFit->transformBy(xform);
|
|
|
|
AcGiViewDraw dc(NULL, NULL);
|
|
pFit->Draw2d(dc);
|
|
|
|
pFit->GetDraw2dables(0,arSubPtrs);
|
|
|
|
arRegionPtrs.append(arSubPtrs);
|
|
delete pFit;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
SHJson::WValue &AecDbECableTray::ToJson(bool bExprotGeo) const
|
|
{
|
|
assertReadEnabled();
|
|
return AecDbEwPipeBase::ToJson(bExprotGeo);
|
|
}
|
|
|
|
bool AecDbECableTray::ByJson(const SHJson::WValue &v)
|
|
{
|
|
AssertWriteEnabled();
|
|
return AecDbEwPipeBase::ByJson(v);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::DrawFlangInf3d(AcGiDraw &dc) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::DrawFlangInf3d(AcGiDraw &dc,const AcGePoint3d& ptPos,const AcGeVector3d& vtInf) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::DrawFlangInf2d(AcGiDraw &dc) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::DrawFlangInf2d(AcGiDraw &dc,const AcGePoint3d& ptPos,const AcGeVector3d& vtInf) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbECableTray::CheckBrokenOpen()
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int AecDbECableTray::ComparedTo(AecDbCurveBase* pCurOther) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AecDbECableTray* pPipeOther = AecDbECableTray::cast(pCurOther);
|
|
if (pPipeOther != NULL)
|
|
{
|
|
AecHvac::DuctParam dpThis;
|
|
GetDuctParam(dpThis);
|
|
|
|
AecHvac::DuctParam dpThat;
|
|
pPipeOther->GetDuctParam(dpThat);
|
|
|
|
if (dpThis.eType != dpThat.eType)
|
|
return 1;
|
|
|
|
if ( fabs(dpThis.dSize[0] - dpThat.dSize[0]) > 0.1)
|
|
return 1;
|
|
|
|
if ( fabs(dpThis.dSize[1] - dpThat.dSize[1]) > 0.1)
|
|
return 1;
|
|
|
|
if ( fabs(dpThis.dSize[2] - dpThat.dSize[2]) > 0.1)
|
|
return 1;
|
|
|
|
if ( fabs(dpThis.m_dEl - dpThat.m_dEl) > 0.1)
|
|
return 1;
|
|
|
|
AcGePoint3d ptSta,ptEnd;
|
|
getStartPoint(ptSta);
|
|
getEndPoint(ptEnd);
|
|
|
|
AcGePoint3d ptSta2,ptEnd2;
|
|
pPipeOther->getStartPoint(ptSta2);
|
|
pPipeOther->getEndPoint(ptEnd2);
|
|
|
|
if (ptSta.distanceTo(ptSta2) > 2.0)//误差2毫米
|
|
return 1;
|
|
|
|
if (ptEnd.distanceTo(ptEnd2) > 2.0)//误差2毫米
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
#include "hlrcutoption.h"
|
|
void AecDbECableTray::ProcessHlrResult(const AcArray<AcDbEntity *> &ar, const std::map<AcDbEntity *, AcArray<AcDbEntity *>> &preAr, AcArray<AcDbEntity *> &output) const
|
|
{
|
|
double dW;
|
|
HlrCutOption::ProcessHlrResult(this
|
|
, HlrCutOption::getHlrLW_ElecSys(dW)
|
|
, dW
|
|
, FALSE
|
|
, ar
|
|
, preAr
|
|
, output);
|
|
} |