442 lines
9.8 KiB
C++
442 lines
9.8 KiB
C++
#include "stdafx.h"
|
|
#include "AecDbDirPosition.h"
|
|
#include "dbgrip.h"
|
|
#include "AecGripCback.h"
|
|
#include "MFCDbDwgFiler.h"
|
|
|
|
extern void PushGripMessage(GripMessage &);
|
|
extern double PixelToWcs(int nPixel);
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS(AecDbDirPosition, AecDbEntityBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_DIRPS,
|
|
"AecDbXOpening"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
Adesk::UInt32 AecDbDirPosition::kCurrentVersionNumber = 2;
|
|
static const Adesk::UInt16 kBlue = 5;
|
|
|
|
AecDbDirPosition::AecDbDirPosition(void)
|
|
{
|
|
m_pGripAppData = new AecGripData[12];
|
|
m_sEquOn = _T("");
|
|
m_nIsEqu = 0;
|
|
m_sHd = _T("");
|
|
}
|
|
|
|
AecDbDirPosition::~AecDbDirPosition(void)
|
|
{
|
|
delete[] m_pGripAppData;
|
|
}
|
|
|
|
void AecDbDirPosition::SetPosition(const AcGePoint3d &ptPos)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_ptPos = ptPos;
|
|
}
|
|
|
|
AcGePoint3d AecDbDirPosition::GetPosition() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_ptPos;
|
|
}
|
|
|
|
void AecDbDirPosition::SetOnEqu(LPCTSTR pszEqu)
|
|
{
|
|
assertWriteEnabled();
|
|
m_sEquOn = pszEqu;
|
|
}
|
|
|
|
BOOL AecDbDirPosition::GetOnEqu(CString &sEqu) const
|
|
{
|
|
sEqu = m_sEquOn;
|
|
return m_sEquOn.IsEmpty();
|
|
}
|
|
|
|
void AecDbDirPosition::SetSys(LPCTSTR pszSys)
|
|
{
|
|
assertWriteEnabled();
|
|
m_sSys = pszSys;
|
|
}
|
|
|
|
void AecDbDirPosition::GetSys(CString &sSys)
|
|
{
|
|
assertReadEnabled();
|
|
sSys = m_sSys;
|
|
}
|
|
|
|
void AecDbDirPosition::SetIsEqu(bool bIsEqu)
|
|
{
|
|
assertWriteEnabled();
|
|
m_nIsEqu = bIsEqu ? 1 : 0;
|
|
}
|
|
|
|
bool AecDbDirPosition::IsEqu()
|
|
{
|
|
assertReadEnabled();
|
|
return m_nIsEqu > 0 ? true : false;
|
|
}
|
|
|
|
void AecDbDirPosition::SetAssocEnt(LPCTSTR pszHd)
|
|
{
|
|
assertWriteEnabled();
|
|
m_sHd = pszHd;
|
|
}
|
|
|
|
LPCTSTR AecDbDirPosition::GetAssocEnt() const
|
|
{
|
|
assertReadEnabled();
|
|
return (LPCTSTR)m_sHd;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbDirPosition::copyFrom(const AcRxObject *pSrc)
|
|
{
|
|
AssertWriteEnabled();
|
|
AecDbDirPosition *pDirPs = AecDbDirPosition::cast(pSrc);
|
|
if (pDirPs != NULL)
|
|
{
|
|
m_ptPos = pDirPs->m_ptPos;
|
|
m_sEquOn = pDirPs->m_sEquOn;
|
|
m_sSys = pDirPs->m_sSys;
|
|
m_nIsEqu = pDirPs->m_nIsEqu;
|
|
m_sHd = pDirPs->m_sHd;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbDirPosition::subList() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
acutPrintf(_T("\n关联标识:%s"),m_sEquOn);
|
|
acutPrintf(_T("\n关联桥架:%s"), m_nIsEqu ? _T("否") : (LPCTSTR)m_sHd);
|
|
acutPrintf(_T("\n系统:%s"), m_sSys);
|
|
acutPrintf(_T("\n位置点:%.3f,%.3f,%.3f"), m_ptPos.x,m_ptPos.y,m_ptPos.z);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbDirPosition::subTransformBy(const AcGeMatrix3d &xform)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_ptPos.transformBy(xform);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbDirPosition::subGetGripPoints(AcDbGripDataPtrArray &grips,
|
|
const double curViewUnitSize,
|
|
const int gripSize,
|
|
const AcGeVector3d &curViewDir,
|
|
const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
int nColor = kBlue;
|
|
AcDbGripData *pGripData = NULL;
|
|
|
|
EPosition ePos = eFlag;
|
|
CString sTip = _T("位置");
|
|
|
|
int i = 0;
|
|
memset(&m_pGripAppData[i], 0, sizeof(AecGripData));
|
|
m_pGripAppData[i].nIndex = i;
|
|
m_pGripAppData[i].nSegIndex = -1;
|
|
m_pGripAppData[i].ePos = ePos;
|
|
m_pGripAppData[i].nColor = kBlue;
|
|
m_pGripAppData[i].ptGrip = m_ptPos;
|
|
_tcscpy(m_pGripAppData[i].szTip, sTip);
|
|
m_pGripAppData[i].pOwner = (AcDbEntity *)this;
|
|
|
|
pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(m_ptPos);
|
|
pGripData->setAppData((void *)&m_pGripAppData[i]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
grips.append(pGripData);
|
|
|
|
double dCmd = PixelToWcs(15);
|
|
AcGePoint3d ptCmd = m_ptPos + AcGeVector3d::kXAxis * dCmd;
|
|
|
|
i += 1;
|
|
ePos = eCommand0;
|
|
pGripData = new AcDbGripData;
|
|
memset(&m_pGripAppData[i], 0, sizeof(AecGripData));
|
|
|
|
m_pGripAppData[i].nIndex = i;
|
|
m_pGripAppData[i].ePos = ePos;
|
|
m_pGripAppData[i].ptGrip = ptCmd;
|
|
_tcscpy(m_pGripAppData[i].szTip, _T("EL_HZXG"));
|
|
m_pGripAppData[i].pOwner = (AcDbEntity *)this;
|
|
m_pGripAppData[i].idHost = objectId();
|
|
|
|
pGripData->setGripPoint(ptCmd);
|
|
pGripData->setAppData((void *)&m_pGripAppData[i]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
grips.append(pGripData);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbDirPosition::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;
|
|
}
|
|
|
|
int nGripIndex = arIndex.first();
|
|
if (nGripIndex == 0)
|
|
{
|
|
m_ptPos += offset;
|
|
return Acad::eOk;
|
|
}
|
|
else
|
|
{
|
|
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.nType = eCommand0;
|
|
msg.nData = 0;
|
|
|
|
msg.ptGrip = m_ptPos;
|
|
msg.idHost = pAppData->idHost;
|
|
msg.vtOffset = offset;
|
|
|
|
PushGripMessage(msg);
|
|
|
|
CString sCmd = _T("EL_HZXG");
|
|
if (!sCmd.IsEmpty())
|
|
{
|
|
acedPostCommand(_T("\x03"));
|
|
sCmd += _T("\n");
|
|
acedPostCommand(sCmd);
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbDirPosition::subGetStretchPoints(AcGePoint3dArray &stretchPoints) const
|
|
{
|
|
assertReadEnabled();
|
|
stretchPoints.append(m_ptPos);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbDirPosition::subMoveStretchPointsAt(const AcDbIntArray &indices, const AcGeVector3d &offset)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_ptPos += offset;
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbDirPosition::subIntersectWith(const AcDbEntity *pEnt,
|
|
AcDb::Intersect intType,
|
|
AcGePoint3dArray &points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
assertReadEnabled();
|
|
AcDbEntity *pEntT = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
|
|
AcGePoint3dArray arPts1;
|
|
for (int i = 0; i < ar2D.length(); i++)
|
|
{
|
|
pEntT = (AcDbEntity *)ar2D.at(i);
|
|
pEntT->intersectWith(pEnt, intType, points, thisGsMarker, otherGsMarker);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbDirPosition::subIntersectWith(const AcDbEntity *pEnt,
|
|
AcDb::Intersect intType,
|
|
const AcGePlane &projPlane,
|
|
AcGePoint3dArray &points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
assertReadEnabled();
|
|
AcDbEntity *pEntT = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
|
|
AcGePoint3dArray arPts1;
|
|
for (int i = 0; i < ar2D.length(); i++)
|
|
{
|
|
pEntT = (AcDbEntity *)ar2D.at(i);
|
|
pEntT->intersectWith(pEnt, intType, projPlane, points, thisGsMarker, otherGsMarker);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbDirPosition::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 > AecDbDirPosition::kCurrentVersionNumber)
|
|
return (Acad::eMakeMeProxy);
|
|
|
|
pFiler->readPoint3d(&m_ptPos);
|
|
|
|
TCHAR *pszStr = NULL;
|
|
pFiler->readString(&pszStr);
|
|
m_sEquOn = pszStr;
|
|
if (pszStr != NULL)
|
|
acutDelString(pszStr);
|
|
|
|
pszStr = NULL;
|
|
pFiler->readString(&pszStr);
|
|
m_sSys = pszStr;
|
|
if (pszStr != NULL)
|
|
acutDelString(pszStr);
|
|
|
|
if (version > 1)
|
|
{
|
|
pFiler->readInt16(&m_nIsEqu);
|
|
|
|
pszStr = NULL;
|
|
pFiler->readString(&pszStr);
|
|
m_sHd = pszStr;
|
|
if (pszStr != NULL)
|
|
acutDelString(pszStr);
|
|
}
|
|
|
|
return (pFiler->filerStatus());
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbDirPosition::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(AecDbDirPosition::kCurrentVersionNumber)) != Acad::eOk)
|
|
return (es);
|
|
|
|
pFiler->writePoint3d(m_ptPos);
|
|
pFiler->writeString((LPCTSTR)m_sEquOn);
|
|
pFiler->writeString((LPCTSTR)m_sSys);
|
|
pFiler->writeInt16(m_nIsEqu);
|
|
pFiler->writeString((LPCTSTR)m_sHd);
|
|
|
|
return (pFiler->filerStatus());
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbDirPosition::dxfInFields(AcDbDxfFiler *pFiler)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbDirPosition::dxfOutFields(AcDbDxfFiler *pFiler) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbDirPosition::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDbObjectId idCurLay = dc.GetLayerId();
|
|
AcDbObjectId idCurLty = dc.GetLineTypeId();
|
|
Adesk::UInt16 nCrBk = colorIndex();
|
|
dc.SetLayer(layerId());
|
|
|
|
//二维缓存,未知出错!
|
|
if (Has2DBuffer())
|
|
{
|
|
Draw2DBuffers(dc);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//绘制桩
|
|
//绘制圆+ + 字 3.5 * 比例 100
|
|
double dR = 1.75 * 100.0;
|
|
AcDbCircle *pCir = new AcDbCircle;
|
|
pCir->setRadius(dR);
|
|
pCir->setCenter(m_ptPos);
|
|
pCir->setNormal(AcGeVector3d::kZAxis);
|
|
pCir->setLayer(layerId());
|
|
dc.DrawEntity(pCir);
|
|
Add2DBuffer(pCir);
|
|
|
|
AcGePoint3d ptS = m_ptPos;
|
|
ptS.x += dR;
|
|
AcGePoint3d ptE = ptS;
|
|
ptE.x += 2.0 * dR;
|
|
|
|
AcDbLine *pLn = NULL;
|
|
|
|
for (int i = 0;i < 4;i++)
|
|
{
|
|
pLn = new AcDbLine;
|
|
pLn->setStartPoint(ptS);
|
|
pLn->setEndPoint(ptE);
|
|
pLn->setNormal(AcGeVector3d::kZAxis);
|
|
pLn->setLayer(layerId());
|
|
dc.DrawEntity(pLn);
|
|
Add2DBuffer(pLn);
|
|
|
|
ptS.rotateBy(PI / 2.0, AcGeVector3d::kZAxis, m_ptPos);
|
|
ptE.rotateBy(PI / 2.0, AcGeVector3d::kZAxis, m_ptPos);
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbDirPosition::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
return Draw2d(dc);
|
|
}
|
|
|
|
AecDbObjXDataMap *AecDbDirPosition::GetSpecialtyData(AcDb::OpenMode bMode)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
const AecDbObjXDataMap *AecDbDirPosition::GetSpecialtyData() const
|
|
{
|
|
return NULL;
|
|
} |