439 lines
9.3 KiB
C++
439 lines
9.3 KiB
C++
#include "stdafx.h"
|
|
#include "AcDbXFloorFrame.h"
|
|
#include "dbgrip.h"
|
|
#include "AecGripCback.h"
|
|
#include "MFCDbDwgFiler.h"
|
|
|
|
static const Adesk::UInt16 kColorByBlock = 0;
|
|
static const Adesk::UInt16 kRed = 1;
|
|
static const Adesk::UInt16 kYellow = 2;
|
|
static const Adesk::UInt16 kGreen = 3;
|
|
static const Adesk::UInt16 kCyan = 4;
|
|
static const Adesk::UInt16 kBlue = 5;
|
|
static const Adesk::UInt16 kMagenta = 6;
|
|
static const Adesk::UInt16 kWhite = 7;
|
|
static const Adesk::UInt16 kColorByLayer = 256;
|
|
|
|
extern CString IDCreate();
|
|
BOOL DLLIMPEXP GetDocScale(double &dPScale);
|
|
|
|
Adesk::UInt32 AcDbXFloorFrame::kCurrentVersionNumber = 2;
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS(AcDbXFloorFrame, AecDbEntityBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_XFLOORFR,
|
|
"AcDbXFloorFrame"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
|
|
AcDbXFloorFrame::AcDbXFloorFrame(void)
|
|
{
|
|
m_pGripAppData = new AecGripData[GRIP_MAXNUM];
|
|
|
|
_tcscpy(m_szFloorName, _T(""));
|
|
_tcscpy(m_szFloorNo, _T(""));
|
|
_tcscpy(m_szName, _T(""));
|
|
m_nFloorH = 3000;
|
|
}
|
|
|
|
AcDbXFloorFrame::~AcDbXFloorFrame(void)
|
|
{
|
|
delete[] m_pGripAppData;
|
|
}
|
|
|
|
bool AcDbXFloorFrame::SetFloorFrame(LPCTSTR pszFloor, const AcGePoint3d &pt1, const AcGePoint3d &pt2,const AcGePoint3d& ptAg)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (NULL == pszFloor)
|
|
return false;
|
|
|
|
_tcscpy(m_szFloorNo, pszFloor);
|
|
m_ptLB = pt1; m_ptRT = pt2;
|
|
m_ptAg = ptAg;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AcDbXFloorFrame::GetFloorFrame(CString &sFloor, AcGePoint3d &pt1, AcGePoint3d &pt2, AcGePoint3d &ptAg) const
|
|
{
|
|
assertReadEnabled();
|
|
sFloor = m_szFloorNo;
|
|
pt1 = m_ptLB;
|
|
pt2 = m_ptRT;
|
|
ptAg = m_ptAg;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AcDbXFloorFrame::SetFloorViewName(LPCTSTR pszName)
|
|
{
|
|
assertWriteEnabled();
|
|
_tcscpy(m_szFloorName, pszName);
|
|
return true;
|
|
}
|
|
|
|
bool AcDbXFloorFrame::GetFloorViewName(CString &sName) const
|
|
{
|
|
assertReadEnabled();
|
|
sName = m_szFloorName;
|
|
return true;
|
|
}
|
|
|
|
bool AcDbXFloorFrame::SetFloorName(LPCTSTR pszName)
|
|
{
|
|
assertWriteEnabled();
|
|
_tcscpy(m_szName, pszName);
|
|
return true;
|
|
}
|
|
|
|
bool AcDbXFloorFrame::GetFloorName(CString &sName) const
|
|
{
|
|
assertReadEnabled();
|
|
sName = m_szName;
|
|
return true;
|
|
}
|
|
|
|
bool AcDbXFloorFrame::SetFloorHeight(Adesk::Int16 nHeight)
|
|
{
|
|
assertWriteEnabled();
|
|
m_nFloorH = nHeight;
|
|
return true;
|
|
}
|
|
|
|
Adesk::Int16 AcDbXFloorFrame::GetFloorHeight() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_nFloorH;
|
|
}
|
|
|
|
bool AcDbXFloorFrame::AddHandle(LPCTSTR szHd)
|
|
{
|
|
assertWriteEnabled();
|
|
m_arHds.Add(szHd);
|
|
return true;
|
|
}
|
|
|
|
bool AcDbXFloorFrame::GetHandles(CStringArray &arHds) const
|
|
{
|
|
assertReadEnabled();
|
|
arHds.Append(m_arHds);
|
|
return true;
|
|
}
|
|
|
|
bool AcDbXFloorFrame::GetHandles(AcDbObjectIdArray &arIds) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDbDatabase *pDb = this->database();
|
|
if (pDb == NULL)
|
|
pDb = acdbCurDwg();
|
|
|
|
CString sHD;
|
|
AcDbObjectId id;
|
|
for (int i = 0;i < m_arHds.GetSize();i++)
|
|
{
|
|
sHD = m_arHds.GetAt(i);
|
|
AcDbHandle hd(sHD);
|
|
|
|
if (Acad::eOk == pDb->getAcDbObjectId(id, false, hd))
|
|
{
|
|
arIds.append(id);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AcDbXFloorFrame::RemoveAll()
|
|
{
|
|
assertReadEnabled();
|
|
m_arHds.RemoveAll();
|
|
return true;
|
|
}
|
|
|
|
Acad::ErrorStatus AcDbXFloorFrame::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 > AcDbXFloorFrame::kCurrentVersionNumber)
|
|
return (Acad::eMakeMeProxy);
|
|
|
|
TCHAR *pszTmp = NULL;
|
|
pFiler->readString(&pszTmp);
|
|
if (pszTmp != NULL)
|
|
{
|
|
_tcscpy(m_szFloorNo, pszTmp);
|
|
acutDelString(pszTmp);
|
|
}
|
|
|
|
pFiler->readPoint3d(&m_ptLB);
|
|
pFiler->readPoint3d(&m_ptRT);
|
|
pFiler->readPoint3d(&m_ptAg);
|
|
|
|
pszTmp = NULL;
|
|
pFiler->readString(&pszTmp);
|
|
if (pszTmp != NULL)
|
|
{
|
|
_tcscpy(m_szFloorName, pszTmp);
|
|
acutDelString(pszTmp);
|
|
}
|
|
pszTmp = NULL;
|
|
pFiler->readString(&pszTmp);
|
|
if (pszTmp != NULL)
|
|
{
|
|
_tcscpy(m_szName, pszTmp);
|
|
acutDelString(pszTmp);
|
|
}
|
|
pFiler->readInt16(&m_nFloorH);
|
|
|
|
Adesk::Int32 nLen = 0;
|
|
pFiler->readInt32(&nLen);
|
|
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
pszTmp = NULL;
|
|
pFiler->readString(&pszTmp);
|
|
if (pszTmp != NULL)
|
|
{
|
|
m_arHds.Add(pszTmp);
|
|
acutDelString(pszTmp);
|
|
}
|
|
}
|
|
|
|
return (pFiler->filerStatus());
|
|
}
|
|
|
|
Acad::ErrorStatus AcDbXFloorFrame::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(AcDbXFloorFrame::kCurrentVersionNumber)) != Acad::eOk)
|
|
return (es);
|
|
|
|
pFiler->writeString((LPCTSTR)m_szFloorNo);
|
|
|
|
pFiler->writePoint3d(m_ptLB);
|
|
pFiler->writePoint3d(m_ptRT);
|
|
pFiler->writePoint3d(m_ptAg);
|
|
|
|
pFiler->writeString((LPCTSTR)m_szFloorName);
|
|
pFiler->writeString((LPCTSTR)m_szName);
|
|
pFiler->writeInt16(m_nFloorH);
|
|
|
|
Adesk::Int32 nLen = m_arHds.GetSize();
|
|
pFiler->writeInt32(nLen);
|
|
|
|
for (int i = 0; i < nLen; i++)
|
|
{
|
|
const CString& sTemp = m_arHds.GetAt(i);
|
|
pFiler->writeString((LPCTSTR)sTemp);
|
|
}
|
|
|
|
return (pFiler->filerStatus());
|
|
}
|
|
|
|
Acad::ErrorStatus AcDbXFloorFrame::dxfInFields(AcDbDxfFiler *pFiler)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AcDbXFloorFrame::dxfOutFields(AcDbDxfFiler *pFiler) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AcDbXFloorFrame::subList() const
|
|
{
|
|
assertReadEnabled();
|
|
AecDbEntityBase::subList();
|
|
|
|
acutPrintf(_T("\nFloorName %s"), m_szName);
|
|
|
|
acutPrintf(_T("\nFloors %s"), m_szFloorNo);
|
|
acutPrintf(_T("\nPoint1 : (%g,%g,%g)"), m_ptLB.x, m_ptLB.y, m_ptLB.z);
|
|
acutPrintf(_T("\nPoint2 : (%g,%g,%g)"), m_ptRT.x, m_ptRT.y, m_ptRT.z);
|
|
|
|
acutPrintf(_T("\nFloorName %s"), m_szFloorName);
|
|
}
|
|
|
|
Acad::ErrorStatus AcDbXFloorFrame::copyFrom(const AcRxObject *pSrc)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AcDbXFloorFrame *pFit = AcDbXFloorFrame::cast(pSrc);
|
|
if (pFit != NULL)
|
|
{
|
|
_tcscpy(m_szFloorNo, pFit->m_szFloorNo);
|
|
m_ptLB = pFit->m_ptLB;
|
|
m_ptRT = pFit->m_ptRT;
|
|
_tcscpy(m_szFloorName, pFit->m_szFloorName);
|
|
m_nFloorH = pFit->m_nFloorH;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AcDbXFloorFrame::subTransformBy(const AcGeMatrix3d &xform)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
m_ptLB.transformBy(xform);
|
|
m_ptRT.transformBy(xform);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
#if ARX>16
|
|
Acad::ErrorStatus AcDbXFloorFrame::subGetGripPoints(AcDbGripDataPtrArray &grips,
|
|
const double curViewUnitSize,
|
|
const int gripSize,
|
|
const AcGeVector3d &curViewDir,
|
|
const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDbGripData *pGripData = NULL;
|
|
|
|
pGripData = new AcDbGripData;
|
|
|
|
int i = 0;
|
|
memset(&m_pGripAppData[i], 0, sizeof(AecGripData));
|
|
|
|
m_pGripAppData[i].nIndex = i;
|
|
m_pGripAppData[i].ePos = eStart;
|
|
m_pGripAppData[i].ptGrip = m_ptLB;
|
|
_tcscpy(m_pGripAppData[i].szTip, _T("开始夹点"));
|
|
m_pGripAppData[i].pOwner = (AcDbEntity *)this;
|
|
m_pGripAppData[i].idHost = objectId();
|
|
|
|
pGripData->setGripPoint(m_ptLB);
|
|
pGripData->setAppData((void *)&m_pGripAppData[i]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AcDbXFloorFrame::subMoveGripPointsAt(const AcDbVoidPtrArray &appData, const AcGeVector3d &offset, const int bitflags)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
AecGripData *pAppData = NULL;
|
|
AcDbIntArray arIndex;
|
|
|
|
if (!appData.isEmpty())
|
|
{
|
|
pAppData = (AecGripData *)appData.first();
|
|
if (pAppData->nIndex == 0)
|
|
{
|
|
m_ptLB += offset;
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AcDbXFloorFrame::subGetGeomExtents(AcDbExtents &extents) const
|
|
{
|
|
extents.set(m_ptLB, m_ptRT);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
#endif
|
|
|
|
//AEC 派生
|
|
Acad::ErrorStatus AcDbXFloorFrame::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
AcGePoint3d ptGe[5];
|
|
|
|
AcDbExtents ext;
|
|
ext.addPoint(m_ptLB);
|
|
ext.addPoint(m_ptRT);
|
|
|
|
ptGe[0] = ext.minPoint();
|
|
ptGe[1] = ptGe[0];
|
|
ptGe[1].x = ext.maxPoint().x;
|
|
ptGe[2] = ext.maxPoint();
|
|
ptGe[3] = ext.minPoint();
|
|
ptGe[3].y = ext.maxPoint().y;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcDbObjectId idBk = dc.GetLayerId();
|
|
dc.SetLayer(layerId());
|
|
dc.DrawPolyline(5, ptGe);
|
|
|
|
double dScale = 100.0;
|
|
GetDocScale(dScale);
|
|
|
|
AcGeVector3d vtDir = ptGe[1] - ptGe[0];
|
|
vtDir.normalize();
|
|
AcGeVector3d vtV = vtDir;
|
|
vtV.rotateBy(-PI / 2.0, AcGeVector3d::kZAxis);
|
|
ptGe[0] += vtV * 4.0 * dScale;
|
|
dc.DrawText(ptGe[0],AcGeVector3d::kZAxis,vtDir,3.5 * dScale,0.75,0,m_szFloorNo);
|
|
|
|
//绘制对齐点
|
|
AcGeVector3d vt45(1, 1, 0);
|
|
vt45.normalize();
|
|
|
|
Adesk::Int16 nBk = dc.GetColor();
|
|
dc.SetColor(kRed);
|
|
ptGe[0] = m_ptAg;
|
|
ptGe[0] -= vt45 * 3.0 * dScale;
|
|
ptGe[1] = m_ptAg;
|
|
ptGe[1] += vt45 * 3.0 * dScale;
|
|
dc.DrawPolyline(2, ptGe);
|
|
|
|
vt45.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
|
ptGe[0] = m_ptAg;
|
|
ptGe[0] -= vt45 * 3.0 * dScale;
|
|
ptGe[1] = m_ptAg;
|
|
ptGe[1] += vt45 * 3.0 * dScale;
|
|
dc.DrawPolyline(2, ptGe);
|
|
|
|
dc.SetColor(nBk);
|
|
dc.SetLayer(idBk);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AcDbXFloorFrame::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AecDbObjXDataMap *AcDbXFloorFrame::GetSpecialtyData(AcDb::OpenMode bMode /*= AcDb::kForWrite*/)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
const AecDbObjXDataMap *AcDbXFloorFrame::GetSpecialtyData() const
|
|
{
|
|
assertReadEnabled();
|
|
return NULL;
|
|
} |