1038 lines
22 KiB
C++
1038 lines
22 KiB
C++
#include "stdafx.h"
|
|
#include "AecDbHolder.h"
|
|
#include "MFCDbDwgFiler.h"
|
|
#include "AecDbEwPipe.h"
|
|
#include "dbgrip.h"
|
|
#include "AecGripCback.h"
|
|
#include "AcGiViewDraw.h"
|
|
#include "ImpMD5.h"
|
|
|
|
extern AcDbPolyline* FormatPolyline(AcGePoint3d* ppPts,int nCount);
|
|
extern AcGePoint3d MidPoint(const AcGePoint3d& pt1,const AcGePoint3d& pt2);
|
|
extern BOOL DLLIMPEXP GetDimGripOff();
|
|
extern void DLLIMPEXP OrthoProjected3DSolid(AcDb3dSolid* pSolidClone,const AcGePlane& plan,AcGeMatrix3d& xformPlanToWorld,AcDbVoidPtrArray& arEntPtrs);
|
|
|
|
Adesk::UInt32 AecDbHolder::kCurrentVersionNumber = 1;
|
|
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;
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS (AecDbHolder, AecDbEntityBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_DBHOLDER,
|
|
"AecDbHolder"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
AecDbHolder::AecDbHolder(void)
|
|
{
|
|
m_pGripAppData = new AecGripData[GRIP_MAXNUM];
|
|
m_mapSpecXData.SetAt(KEY_NAME,_T("支架"));
|
|
}
|
|
|
|
AecDbHolder::~AecDbHolder(void)
|
|
{
|
|
delete [] m_pGripAppData;
|
|
deleteContainerOfStd(m_solids);
|
|
deleteContainerOfStd(m_pipes);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHolder::SetPosition(const AcGePoint3d& ptPos,const AcGeVector3d& vtL)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_mapSpecXData.SetAt(KEY_POS,ptPos);
|
|
m_mapSpecXData.SetAt(PIPE_DIR,vtL);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcGePoint3d AecDbHolder::GetPosition(AcGeVector3d& vtL) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d pt;
|
|
m_mapSpecXData.GetAt(KEY_POS,pt);
|
|
m_mapSpecXData.GetAt(PIPE_DIR,vtL);
|
|
return pt;
|
|
}
|
|
|
|
void AecDbHolder::SetHolder(const XHolder& holder)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
/*
|
|
// 支架行数
|
|
int N;
|
|
|
|
// 支架垂直间距(m)
|
|
double V;
|
|
|
|
// 支架臂长度(mm)
|
|
double L;
|
|
|
|
// 角钢宽度(mm)
|
|
double W;
|
|
|
|
// 角钢厚度(mm)
|
|
double t;
|
|
|
|
// 材质
|
|
TCHAR szMat[33];
|
|
|
|
// 用途
|
|
TCHAR szUsage[33];
|
|
|
|
//预留
|
|
double dResv[6];
|
|
int nResv[6];
|
|
TCHAR szResv[MAX_PATH];
|
|
*/
|
|
m_mapSpecXData.SetAt(KEY_EQK, holder.bNoEquDis);
|
|
m_mapSpecXData.SetAt(KEY_N,holder.N);
|
|
m_mapSpecXData.SetAt(KEY_V,holder.V);
|
|
m_mapSpecXData.SetAt(KEY_L,holder.L);
|
|
m_mapSpecXData.SetAt(KEY_W,holder.W);
|
|
m_mapSpecXData.SetAt(KEY_T,holder.t);
|
|
|
|
if (holder.bNoEquDis && holder.N < 64)
|
|
{
|
|
CString sKey;
|
|
for (int i = 0; i < holder.N; i++)
|
|
{
|
|
sKey.Format(_T("%s%d"), KEY_N, i);
|
|
m_mapSpecXData.SetAt(sKey, holder.nDists[i]);
|
|
|
|
sKey.Format(_T("%sS%d"), KEY_N, i);
|
|
m_mapSpecXData.SetAt(sKey, holder.nSyss[i]);
|
|
}
|
|
}
|
|
m_mapSpecXData.SetAt(KEY_MATERIAL,holder.szMat);
|
|
m_mapSpecXData.SetAt(KEY_PURPOSE,holder.szUsage);
|
|
}
|
|
|
|
bool AecDbHolder::GetHolder(XHolder& holder) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
memset(&holder, 0, sizeof(XHolder));
|
|
|
|
//bNoEquDis
|
|
holder.bNoEquDis = 0;
|
|
m_mapSpecXData.GetAt(KEY_EQK,holder.bNoEquDis);
|
|
m_mapSpecXData.GetAt(KEY_N,holder.N);
|
|
m_mapSpecXData.GetAt(KEY_V,holder.V);
|
|
m_mapSpecXData.GetAt(KEY_L,holder.L);
|
|
m_mapSpecXData.GetAt(KEY_W,holder.W);
|
|
m_mapSpecXData.GetAt(KEY_T,holder.t);
|
|
|
|
if (holder.bNoEquDis && holder.N < 64)
|
|
{
|
|
CString sKey;
|
|
for (int i = 0;i < holder.N;i++)
|
|
{
|
|
sKey.Format(_T("%s%d"),KEY_N,i);
|
|
m_mapSpecXData.GetAt(sKey, holder.nDists[i]);
|
|
|
|
sKey.Format(_T("%sS%d"), KEY_N, i);
|
|
m_mapSpecXData.GetAt(sKey, holder.nSyss[i]);
|
|
}
|
|
}
|
|
|
|
CString sTemp;
|
|
m_mapSpecXData.GetAt(KEY_MATERIAL,sTemp);
|
|
_tcscpy(holder.szMat,(LPCTSTR)sTemp);
|
|
|
|
m_mapSpecXData.GetAt(KEY_PURPOSE,sTemp);
|
|
_tcscpy(holder.szUsage,(LPCTSTR)sTemp);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AecDbHolder::GetASteelLength(ASteel& aSteel) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
XHolder holder;
|
|
GetHolder(holder);
|
|
|
|
memset(&aSteel, 0, sizeof(ASteel));
|
|
aSteel.W = holder.W;
|
|
aSteel.t = holder.t;
|
|
aSteel.L = holder.N * holder.L;
|
|
aSteel.L += holder.V * (holder.N - 1) + 2.0 * holder.W;
|
|
_tcscpy(aSteel.szMat, holder.szMat);
|
|
|
|
return true;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHolder::dwgInFields(AcDbDwgFiler* pFiler)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
//----- Read parent class information first.
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
if ( !pFiler->isKindOf(CMFCDbDwgFiler::desc()))
|
|
{
|
|
es = AecDbEntityBase::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 > AecDbHolder::kCurrentVersionNumber )
|
|
return (Acad::eMakeMeProxy);
|
|
|
|
m_mapSpecXData.dwgInFields(pFiler);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHolder::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//----- Save parent class information first.
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
if ( !pFiler->isKindOf(CMFCDbDwgFiler::desc()))
|
|
{
|
|
es = AecDbEntityBase::dwgOutFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
}
|
|
|
|
//----- Object version number needs to be saved first
|
|
if ( (es =pFiler->writeUInt32 (AecDbHolder::kCurrentVersionNumber)) != Acad::eOk )
|
|
return (es) ;
|
|
|
|
m_mapSpecXData.dwgOutFields(pFiler);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHolder::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHolder::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbHolder::subList() const
|
|
{
|
|
assertReadEnabled();
|
|
AecDbEntityBase::subList();
|
|
|
|
acutPrintf(_T("\n属性数据:"));
|
|
m_mapSpecXData.List();
|
|
acutPrintf(_T("\n"));
|
|
}
|
|
|
|
bool AecDbHolder::GetBimInfoTip(CString& sInfoTip) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
CString sField,sFmt;
|
|
|
|
sField = _T("支架杆:\n");
|
|
sInfoTip += sField;
|
|
|
|
XHolder holder;
|
|
memset(&holder,0,sizeof(XHolder));
|
|
|
|
GetHolder(holder);
|
|
|
|
MAKEFIELD(_T("支架行数"),_T("%d"),holder.N,sInfoTip);
|
|
|
|
MAKEFIELD(_T("支架垂直间距"),_T("%.1f"),holder.V,sInfoTip);
|
|
|
|
MAKEFIELD(_T("支架臂长度"),_T("%.2f"),holder.L,sInfoTip);
|
|
|
|
MAKEFIELD(_T("角钢宽度"),_T("%d"),(int)(holder.W + 0.5),sInfoTip);
|
|
|
|
MAKEFIELD(_T("角钢厚度"),_T("%.2f"),holder.t,sInfoTip);
|
|
|
|
MAKEFIELD(_T("材质"),_T("%s"),holder.szMat,sInfoTip);
|
|
|
|
MAKEFIELD(_T("用途"),_T("%s"),holder.szUsage,sInfoTip);
|
|
|
|
MAKEFIELD(_T("编号"),_T("%s"),holder.szNo,sInfoTip);
|
|
|
|
return true;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHolder::copyFrom(const AcRxObject* pSrc)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AecDbHolder* pFit = AecDbHolder::cast(pSrc);
|
|
if (pFit != NULL)
|
|
{
|
|
m_mapSpecXData.Empty();
|
|
m_mapSpecXData.CopyFrom(&pFit->m_mapSpecXData);
|
|
|
|
//发送提资需要相同的ID
|
|
extern CString IDCreate();
|
|
Adesk::Int16 nVal = acdbCurDwg()->useri4();
|
|
if (nVal != KEY_NOPROTECT)
|
|
{
|
|
int nVt = 0;
|
|
CString sID = IDCreate();
|
|
if (m_mapSpecXData.HasKey(KEY_NO, nVt))
|
|
m_mapSpecXData.SetAt(KEY_NO, sID);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHolder::subTransformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcGePoint3d pt;
|
|
AcGeVector3d vtL;
|
|
|
|
m_mapSpecXData.GetAt(KEY_POS,pt);
|
|
m_mapSpecXData.GetAt(PIPE_DIR,vtL);
|
|
|
|
pt.transformBy(xform);
|
|
vtL.transformBy(xform);
|
|
|
|
m_mapSpecXData.SetAt(KEY_POS,pt);
|
|
m_mapSpecXData.SetAt(PIPE_DIR,vtL);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
#if ARX>16
|
|
Acad::ErrorStatus AecDbHolder::subGetGripPoints(AcDbGripDataPtrArray& grips,
|
|
const double curViewUnitSize,
|
|
const int gripSize,
|
|
const AcGeVector3d& curViewDir,
|
|
const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d pt;
|
|
AcGeVector3d vtL;
|
|
m_mapSpecXData.GetAt(KEY_POS,pt);
|
|
m_mapSpecXData.GetAt(PIPE_DIR,vtL);
|
|
|
|
XHolder holder;
|
|
GetHolder(holder);
|
|
|
|
vtL.normalize();
|
|
vtL *= holder.L;
|
|
AcGePoint3d pt2 = pt + vtL;
|
|
|
|
AcDbGripData* pGripData = NULL;
|
|
|
|
int i = 0;
|
|
pGripData = new AcDbGripData;
|
|
memset(&m_pGripAppData[i],0,sizeof(AecGripData));
|
|
m_pGripAppData[i].nIndex = i;
|
|
m_pGripAppData[i].ePos = eStart;
|
|
m_pGripAppData[i].ptGrip = pt;
|
|
m_pGripAppData[i].nColor = kBlue;
|
|
_tcscpy(m_pGripAppData[i].szTip,_T("位置夹点"));
|
|
m_pGripAppData[i].pOwner = (AcDbEntity*)this;
|
|
m_pGripAppData[i].idHost = objectId();
|
|
|
|
pGripData->setGripPoint(pt);
|
|
pGripData->setAppData((void*)&m_pGripAppData[i]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
grips.append(pGripData);
|
|
|
|
i = 1;
|
|
pGripData = new AcDbGripData;
|
|
memset(&m_pGripAppData[i],0,sizeof(AecGripData));
|
|
m_pGripAppData[i].nIndex = i;
|
|
m_pGripAppData[i].ePos = eEnd;
|
|
m_pGripAppData[i].ptGrip = pt2;
|
|
m_pGripAppData[i].nColor = kBlue;
|
|
_tcscpy(m_pGripAppData[i].szTip,_T("方位夹点"));
|
|
m_pGripAppData[i].pOwner = (AcDbEntity*)this;
|
|
m_pGripAppData[i].idHost = objectId();
|
|
|
|
pGripData->setGripPoint(pt2);
|
|
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;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHolder::SubAddDimPoints(AcDbGripDataPtrArray& grips,const AcGeVector3d& curViewDir) const
|
|
{
|
|
if (GetDimGripOff())
|
|
return Acad::eOk;
|
|
|
|
AcGePoint3d pt,pt2;
|
|
AcGeVector3d vtL;
|
|
m_mapSpecXData.GetAt(KEY_POS,pt);
|
|
m_mapSpecXData.GetAt(PIPE_DIR,vtL);
|
|
|
|
XHolder holder;
|
|
GetHolder(holder);
|
|
|
|
vtL.normalize();
|
|
pt2 = pt + vtL * holder.L;
|
|
|
|
AcGeVector3d vtDirX;
|
|
AcGePoint3d ptGe[3],ptMid;
|
|
ptGe[0] = pt;ptGe[0].z += 10.0;
|
|
ptGe[1] = pt2;ptGe[1].z += 10.0;
|
|
|
|
vtDirX = vtL;
|
|
vtDirX.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtDirX.normalize();
|
|
ptMid = MidPoint(ptGe[0],ptGe[1]);
|
|
vtDirX.normalize();
|
|
ptMid += vtDirX * 10.0 * 100.0;//标注文字位置
|
|
AddDimPoints(grips,curViewDir,ptGe[0],ptGe[1],ptMid,0);
|
|
|
|
ptGe[0] = pt;
|
|
ptGe[1] = pt;
|
|
ptGe[1].z += (holder.N - 1) * holder.V;
|
|
ptGe[0] -= vtL * 10.0;
|
|
ptGe[1] -= vtL * 10.0;
|
|
|
|
ptMid = MidPoint(ptGe[0],ptGe[1]);
|
|
vtDirX.normalize();
|
|
ptMid -= vtL * 10.0 * 100.0;//标注文字位置
|
|
AddDimPoints(grips,curViewDir,ptGe[0],ptGe[1],ptMid,0);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHolder::AddDimPoints(AcDbGripDataPtrArray& grips,const AcGeVector3d& curViewDir,
|
|
const AcGePoint3d& ptSta,const AcGePoint3d& ptEnd,
|
|
const AcGePoint3d& ptMid,int nDimType,double dVal/* = -1.0*/,double dt) const
|
|
{
|
|
int i = grips.length();
|
|
EPosition ePos = eDim0;
|
|
memset(&m_pGripAppData[i],0,sizeof(AecGripData));
|
|
m_pGripAppData[i].nIndex = i;
|
|
m_pGripAppData[i].ePos = ePos;
|
|
m_pGripAppData[i].nColor = kGreen;
|
|
m_pGripAppData[i].ptGrip = ptMid;
|
|
m_pGripAppData[i].ptDim[0] = ptSta;
|
|
m_pGripAppData[i].ptDim[1] = ptEnd;
|
|
m_pGripAppData[i].nDimType = nDimType;
|
|
|
|
if (dVal > 1.e-3)
|
|
{
|
|
if (nDimType == 1)
|
|
{
|
|
_stprintf(m_pGripAppData[i].szTip,_T("R%.1f"),dVal);
|
|
}
|
|
else if (nDimType == 2)//@100 标注
|
|
{
|
|
_stprintf(m_pGripAppData[i].szTip,_T("Ø%.1f"),dVal);
|
|
}
|
|
else if (nDimType == 3)//角度标注
|
|
{
|
|
_stprintf(m_pGripAppData[i].szTip,_T("%.1f°"),dVal);
|
|
}
|
|
else if (nDimType == 4)//@107x3.5
|
|
{
|
|
_stprintf(m_pGripAppData[i].szTip,_T("Ø%.1fx%.1f"),dVal,dt);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_tcscpy(m_pGripAppData[i].szTip,_T(" "));
|
|
}
|
|
_tcscpy(m_pGripAppData[i].szID,_T(" "));
|
|
m_pGripAppData[i].pOwner = (AcDbEntity*)this;
|
|
|
|
AcDbGripData* pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(ptMid);
|
|
pGripData->setAppData((void*)&m_pGripAppData[i]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
grips.append(pGripData);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHolder::subGetStretchPoints(AcGePoint3dArray& stretchPoints) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d pt;
|
|
AcGeVector3d vtL;
|
|
m_mapSpecXData.GetAt(KEY_POS,pt);
|
|
m_mapSpecXData.GetAt(PIPE_DIR,vtL);
|
|
|
|
XHolder holder;
|
|
GetHolder(holder);
|
|
|
|
vtL.normalize();
|
|
vtL *= holder.L;
|
|
AcGePoint3d pt2 = pt + vtL;
|
|
|
|
stretchPoints.append(pt);
|
|
stretchPoints.append(pt2);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHolder::subMoveGripPointsAt(const AcDbVoidPtrArray& appData, const AcGeVector3d& offset, const int bitflags)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AecGripData* pAppData = NULL;
|
|
AcDbIntArray arIndex;
|
|
|
|
if ( !appData.isEmpty() )
|
|
{
|
|
pAppData = (AecGripData*)appData.first();
|
|
arIndex.append(pAppData->nIndex);
|
|
}
|
|
else
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcGePoint3d pt;
|
|
AcGeVector3d vtL;
|
|
m_mapSpecXData.GetAt(KEY_POS,pt);
|
|
m_mapSpecXData.GetAt(PIPE_DIR,vtL);
|
|
|
|
int nGripIndex = arIndex.first();
|
|
if (nGripIndex == 0)
|
|
{
|
|
pt += offset;
|
|
m_mapSpecXData.SetAt(KEY_POS,pt);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
if (nGripIndex == 1)
|
|
{
|
|
XHolder holder;
|
|
GetHolder(holder);
|
|
|
|
vtL.normalize();
|
|
vtL *= holder.L;
|
|
AcGePoint3d pt2 = pt + vtL;
|
|
|
|
pt2 += offset;
|
|
|
|
double dL = pt2.distanceTo(pt);
|
|
if (dL > 10.0)
|
|
{
|
|
holder.L = dL;
|
|
m_mapSpecXData.SetAt(KEY_L,holder.L);
|
|
|
|
vtL = pt2 - pt;
|
|
vtL.normalize();
|
|
m_mapSpecXData.SetAt(PIPE_DIR,vtL);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHolder::subMoveStretchPointsAt(const AcDbIntArray& indices,const AcGeVector3d& offset)
|
|
{
|
|
if (indices.isEmpty())
|
|
return Acad::eOk;
|
|
|
|
AssertWriteEnabled();
|
|
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(offset);
|
|
|
|
if (indices.length() == 1)
|
|
{
|
|
AcGePoint3d pt;
|
|
AcGeVector3d vtL;
|
|
m_mapSpecXData.GetAt(KEY_POS,pt);
|
|
m_mapSpecXData.GetAt(PIPE_DIR,vtL);
|
|
|
|
int nGripIndex = indices.first();
|
|
if (nGripIndex == 0)
|
|
{
|
|
pt += offset;
|
|
m_mapSpecXData.SetAt(KEY_POS,pt);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
if (nGripIndex == 1)
|
|
{
|
|
XHolder holder;
|
|
GetHolder(holder);
|
|
|
|
vtL.normalize();
|
|
vtL *= holder.L;
|
|
AcGePoint3d pt2 = pt + vtL;
|
|
|
|
pt2 += offset;
|
|
|
|
double dL = pt2.distanceTo(pt);
|
|
if (dL > 10.0)
|
|
{
|
|
vtL = pt2 - pt;
|
|
vtL.normalize();
|
|
|
|
m_mapSpecXData.SetAt(PIPE_DIR,vtL);
|
|
}
|
|
}
|
|
}
|
|
else if (indices.length() == 2)
|
|
{
|
|
AcGePoint3d pt;
|
|
m_mapSpecXData.GetAt(KEY_POS,pt);
|
|
|
|
pt += offset;
|
|
m_mapSpecXData.SetAt(KEY_POS,pt);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbHolder::GetGripText(int nPos, CString& sText)
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
//AEC 派生
|
|
Acad::ErrorStatus AecDbHolder::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//管线系统屏蔽掉
|
|
if ( dc.IsDragging() )
|
|
{
|
|
//return Acad::eOk;
|
|
}
|
|
|
|
//图层
|
|
AcDbObjectId idLay = dc.GetLayerId();
|
|
dc.SetLayer(layerId());
|
|
//dc.SetSelectionMarker(1);
|
|
|
|
int nCrBk = dc.GetColor();
|
|
int nColor = nCrBk;
|
|
if ( m_mapSpecXData.GetAt(_T("COLOR"),nColor) )
|
|
{
|
|
dc.SetColor(nColor);
|
|
}
|
|
|
|
if (Has2DBuffer())
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2D.at(i);
|
|
//pEnt->setColorIndex(nColor);
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
|
|
dc.SetLayer(idLay);
|
|
dc.SetColor(nCrBk);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
XHolder holder;
|
|
GetHolder(holder);
|
|
|
|
AcGePoint3d pt;
|
|
AcGeVector3d vtL;
|
|
m_mapSpecXData.GetAt(KEY_POS,pt);
|
|
m_mapSpecXData.GetAt(PIPE_DIR,vtL);
|
|
|
|
pt.z = 0.0;//2D
|
|
vtL.z = 0.0;//2D
|
|
vtL.normalize();
|
|
AcGeVector3d vtV = vtL;
|
|
vtV.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
//
|
|
AcGePoint3d ptGe[5];
|
|
ptGe[0] = pt;
|
|
ptGe[0] += vtV * 0.5 * holder.W;
|
|
|
|
ptGe[1] = ptGe[0] + vtL * holder.L;
|
|
ptGe[2] = ptGe[1] - vtV * holder.W;
|
|
|
|
ptGe[3] = ptGe[0] - vtV * holder.W;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcDbPolyline* pPl = FormatPolyline(ptGe,5);
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setLayer(idLay);
|
|
dc.DrawEntity(pPl);
|
|
Add2DBuffer(pPl);
|
|
}
|
|
|
|
ptGe[1] = MidPoint(ptGe[0],ptGe[3]);
|
|
ptGe[1] -= vtL * holder.W;
|
|
|
|
ptGe[2] = ptGe[1] + vtL * 2.0 * holder.W;
|
|
|
|
AcDbLine* pLn = new AcDbLine(ptGe[1],ptGe[2]);
|
|
pLn->setLayer(idLay);
|
|
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbHolder::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcCmTransparency tr = transparency();
|
|
|
|
//管线系统屏蔽掉
|
|
if ( dc.IsDragging() )
|
|
{
|
|
//return Acad::eOk;
|
|
}
|
|
|
|
//图层
|
|
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 (Has3DBuffer())
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
const AcDbVoidPtrArray &ar3D = Get3DBuffer();
|
|
for (int i = 0;i < ar3D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar3D.at(i);
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
|
|
dc.SetLayer(idLay);
|
|
dc.SetColor(nCrBk);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
deleteContainerOfStd(m_solids);
|
|
deleteContainerOfStd(m_pipes);
|
|
|
|
XHolder holder;
|
|
GetHolder(holder);
|
|
|
|
AcGePoint3d pt;
|
|
AcGeVector3d vtL;
|
|
m_mapSpecXData.GetAt(KEY_POS,pt);
|
|
m_mapSpecXData.GetAt(PIPE_DIR,vtL);
|
|
|
|
vtL.normalize();
|
|
AcGeVector3d vtV = vtL;
|
|
vtV.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
//pt 中含有标高
|
|
AcGePoint3d ptFr = pt;
|
|
AcGePoint3d ptTo,ptL[2];
|
|
double dLL = 2.0 * holder.W;
|
|
|
|
AcDb3dSolid* pSolid = NULL;
|
|
int i(0);
|
|
for (i = 0;i < holder.N;i++)
|
|
{
|
|
ptTo = ptFr + vtL * holder.L;
|
|
|
|
pSolid = Create3dRod(ptFr,ptTo,holder.W,holder.t,1,0.0);
|
|
if (pSolid != NULL)
|
|
{
|
|
pSolid->setTransparency(tr);
|
|
dc.DrawEntity(pSolid);
|
|
Add3DBuffer(pSolid);
|
|
}
|
|
|
|
//是否绘制支撑?
|
|
ptL[1] = ptFr + dLL * vtL;
|
|
ptL[0] = ptFr;
|
|
ptL[0].z -= dLL;
|
|
|
|
pSolid = Create3dRod(ptL[0],ptL[1],holder.W,holder.t,1,0.0);
|
|
if (pSolid != NULL)
|
|
{
|
|
pSolid->setTransparency(tr);
|
|
dc.DrawEntity(pSolid);
|
|
Add3DBuffer(pSolid);
|
|
}
|
|
|
|
if (holder.bNoEquDis)
|
|
{
|
|
//第一行的行距包含在标高中
|
|
ptFr.z += holder.nDists[i+1];//下一行
|
|
}
|
|
else
|
|
{
|
|
ptFr.z += holder.V;
|
|
}
|
|
}
|
|
|
|
//墙固
|
|
if (holder.bNoEquDis)
|
|
{
|
|
ptFr.z -= holder.nDists[i];
|
|
}
|
|
else
|
|
{
|
|
ptFr.z -= holder.V;
|
|
}
|
|
ptFr.z += 0.5 * dLL;
|
|
pt.z -= 1.5 * dLL;
|
|
|
|
double dAngle = AcGeVector3d::kXAxis.angleTo(vtL,AcGeVector3d::kZAxis);
|
|
dAngle -= PI / 2.0;
|
|
|
|
pSolid = Create3dRod(pt,ptFr,holder.W,holder.t,2,dAngle);
|
|
if (pSolid != NULL)
|
|
{
|
|
pSolid->setTransparency(tr);
|
|
dc.DrawEntity(pSolid);
|
|
Add3DBuffer(pSolid);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//专业数据 和 绘制设置
|
|
AecDbObjXDataMap* AecDbHolder::GetSpecialtyData(AcDb::OpenMode bMode/* = AcDb::kForWrite*/)
|
|
{
|
|
switch(bMode)
|
|
{
|
|
case AcDb::kForRead:
|
|
{
|
|
assertReadEnabled();
|
|
break;
|
|
}
|
|
case AcDb::kForWrite:
|
|
{
|
|
if (!isWriteEnabled())
|
|
{
|
|
upgradeOpen();
|
|
}
|
|
assertWriteEnabled();
|
|
break;
|
|
}
|
|
case AcDb::kForNotify:
|
|
{
|
|
assertReadEnabled();
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return &m_mapSpecXData;
|
|
}
|
|
|
|
const AecDbObjXDataMap* AecDbHolder::GetSpecialtyData() const
|
|
{
|
|
assertReadEnabled();
|
|
return &m_mapSpecXData;
|
|
}
|
|
|
|
AcDb3dSolid* AecDbHolder::Create3dRod(const AcGePoint3d& ptFr,const AcGePoint3d& ptTo,double dL1,double dt,int nShape,double dRegRoate) const
|
|
{
|
|
AcDb3dSolid* pPipe = NULL;
|
|
AcGiViewDraw dcTmp(NULL,NULL);
|
|
if (nShape == 0)//圆杆
|
|
{
|
|
AecDbEwPipe pipe;
|
|
pipe.SetSection(dL1,0.0);
|
|
pipe.SetStartPoint(ptFr);
|
|
pipe.SetEndPoint(ptTo);
|
|
m_pipes.push_back((AecDbEwPipe*)pipe.clone());
|
|
|
|
pipe.Draw3d(dcTmp);
|
|
pPipe = pipe.GetCreatPipe3dSolid();
|
|
}
|
|
else if(nShape == 1)//角钢
|
|
{
|
|
AecDbEwPipe pipe;
|
|
pipe.SetSection3(dL1,dt);
|
|
pipe.SetSectionRotation(dRegRoate);
|
|
pipe.SetStartPoint(ptFr);
|
|
pipe.SetEndPoint(ptTo);
|
|
m_pipes.push_back((AecDbEwPipe*)pipe.clone());
|
|
|
|
pipe.Draw3d(dcTmp);
|
|
pPipe = pipe.GetCreatPipe3dSolid();
|
|
}
|
|
else if (nShape == 2)//矩形
|
|
{
|
|
AecDbEwPipe pipe;
|
|
pipe.SetSection(dL1,dt,0.0);
|
|
pipe.SetSectionRotation(dRegRoate);
|
|
pipe.SetStartPoint(ptFr);
|
|
pipe.SetEndPoint(ptTo);
|
|
m_pipes.push_back((AecDbEwPipe*)pipe.clone());
|
|
pipe.Draw3d(dcTmp);
|
|
pPipe = pipe.GetCreatPipe3dSolid();
|
|
}
|
|
return pPipe;
|
|
}
|
|
|
|
int AecDbHolder::GetSectionDraw(const AcGePoint3d& ptFr,const AcGePoint3d& ptTo,const AcGeVector3d& vtViewDir,const AcGeVector3d& vtTo, AcDbVoidPtrArray& arRegPtrs) const
|
|
{
|
|
AcGeVector3d vtLn = ptTo - ptFr;
|
|
AcGeVector3d vtNorm = vtLn.crossProduct(vtViewDir);
|
|
|
|
AcGePlane plan;
|
|
plan.set(ptFr,vtNorm);
|
|
|
|
AcGeMatrix3d xform;
|
|
xform.setToPlaneToWorld(plan);
|
|
xform.invert();
|
|
|
|
if (Get3DBuffer().length() == 0)
|
|
{
|
|
AcGiViewDraw dc(NULL,NULL);
|
|
Draw3d(dc);
|
|
}
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDb3dSolid* pSolid = NULL;
|
|
|
|
const AcDbVoidPtrArray &ar3D = Get3DBuffer();
|
|
for (int i = 0;i < ar3D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar3D.at(i);
|
|
|
|
pSolid = AcDb3dSolid::cast(pEnt);
|
|
if (pSolid != NULL)
|
|
{
|
|
//投影法
|
|
OrthoProjected3DSolid(pSolid,plan,xform,arRegPtrs);
|
|
}
|
|
}
|
|
return arRegPtrs.length();
|
|
}
|
|
|
|
CString AecDbHolder::getUniqueName() const
|
|
{
|
|
XHolder holder;
|
|
::memset(&holder, 0, sizeof(XHolder));
|
|
GetHolder(holder);
|
|
|
|
::memset(holder.szNo, 0, 33 * sizeof(TCHAR));
|
|
::memset(holder.szMat, 0, 33 * sizeof(TCHAR));
|
|
::memset(holder.szUsage, 0, 33 * sizeof(TCHAR));
|
|
|
|
return ImpMD5(&holder, sizeof(XHolder)).toString16W().c_str();
|
|
}
|
|
|
|
SHJson::WValue &AecDbHolder::ToJson(bool bExprotGeo) const
|
|
{
|
|
using namespace SHJson;
|
|
assertReadEnabled();
|
|
|
|
WValue &v = AecDbEntityBase::ToJson(bExprotGeo);
|
|
|
|
if (bExprotGeo)
|
|
{
|
|
AecDbHolder *pNew = (AecDbHolder*)clone();
|
|
pNew->SetPosition(AcGePoint3d::kOrigin, AcGeVector3d::kXAxis);
|
|
pNew->Clean3DBuffer();
|
|
AcGiViewDraw dc;
|
|
pNew->Draw3d(dc);
|
|
|
|
WValue ar;
|
|
ar.SetArray();
|
|
|
|
for (size_t i(0); i < pNew->m_solids.size(); ++i)
|
|
{
|
|
AcDbX3dSolid *pSolid(pNew->m_solids[i]);
|
|
if (!pSolid) continue;
|
|
WValue &x = pSolid->ToJson();
|
|
pushBack(ar, x);
|
|
}
|
|
if (!pNew->m_solids.empty())
|
|
addMember(v, _T("__solids__"), ar);
|
|
|
|
ar.SetArray();
|
|
for (size_t i(0); i < pNew->m_pipes.size(); ++i)
|
|
{
|
|
AecDbEwPipeBase *pPipe(pNew->m_pipes[i]);
|
|
if (!pPipe) continue;
|
|
WValue &x = pPipe->ToJson();
|
|
pushBack(ar, x);
|
|
}
|
|
if (!pNew->m_pipes.empty())
|
|
addMember(v, _T("__pipes__"), ar);
|
|
DELETE_PTR(pNew);
|
|
}
|
|
|
|
/*
|
|
typedef struct XHolder // 支架 {
|
|
int N;
|
|
double V;
|
|
double L;
|
|
double W;
|
|
double t;
|
|
TCHAR szMat[33];
|
|
TCHAR szNo[33];
|
|
TCHAR szUsage[33];
|
|
double dResv[6];
|
|
int nResv[6];
|
|
TCHAR szResv[MAX_PATH]; }XHolder;
|
|
*/
|
|
XHolder holder;
|
|
::memset(&holder, 0, sizeof(XHolder));
|
|
GetHolder(holder);
|
|
WValue data;
|
|
addMember(data, _T("__N__"), holder.N);
|
|
addMember(data, _T("__V__"), holder.V);
|
|
addMember(data, _T("__L__"), holder.L);
|
|
addMember(data, _T("__W__"), holder.W);
|
|
addMember(data, _T("__t__"), holder.t);
|
|
addMember(data, _T("__szMat__"), holder.szMat);
|
|
addMember(data, _T("__szNo__"), holder.szNo);
|
|
addMember(data, _T("__szUsage__"), holder.szUsage);
|
|
addMember(data, _T("__szResv__"), holder.szResv);
|
|
|
|
WValue ar;
|
|
ar.SetArray();
|
|
for (int i(0); i < 6; ++i)
|
|
pushBack(ar, holder.dResv[i]);
|
|
addMember(data, _T("__dResv__"), ar);
|
|
|
|
ar.SetArray();
|
|
for (int i(0); i < 6; ++i)
|
|
pushBack(ar, holder.nResv[i]);
|
|
addMember(data, _T("__nResv__"), ar);
|
|
|
|
|
|
addMember(v, _T("_holderData_"), data);
|
|
|
|
return v;
|
|
}
|