388 lines
10 KiB
C++
388 lines
10 KiB
C++
// DbFloorRect.cpp: implementation of the TDbFloorRect class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "stdafx.h"
|
|
#include "DbFloorRect_old.h"
|
|
#include "DbText.h"
|
|
|
|
//#if (ADS==17)
|
|
//#include "..\tch_ComPipewire17\ComPipewire_i.c"
|
|
//#elif (ADS==16)
|
|
//#include "..\tch_ComPipewire16\ComPipewire_i.c"
|
|
//#elif(ADS==15)
|
|
//#include "..\tch_ComPipewire15\ComPipewire_i.c"
|
|
//#endif
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS(TDbFloorRectOld, TDbEntity, AcDb::kDHL_CURRENT,
|
|
AcDb::kMReleaseCurrent, 1, ATS_FLOORRECT_OLD,
|
|
"图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
IMPLEMENT_TENTBASE(TDbFloorRectOld);
|
|
|
|
const Adesk::UInt8 TDbFloorRectOld::g_nVersion = 1;
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
TDbFloorRectOld::TDbFloorRectOld()
|
|
{
|
|
m_dLength = 0; // 长
|
|
m_dWidth = 0; // 宽
|
|
m_dFloorHeight = 3000; // 楼层高度
|
|
m_sFloorName = _T("1层");// 楼层名词
|
|
m_nFloorFrom = 1; // 楼层起始层
|
|
m_nFloorTo = 1; // 楼层终止层
|
|
|
|
}
|
|
|
|
|
|
void TDbFloorRectOld::CopyPropertiesFrom(AcDbEntity *pSrc,unsigned gMatchFlag)
|
|
{
|
|
assertWriteEnabled();
|
|
TDbEntity::CopyPropertiesFrom(pSrc, gMatchFlag);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbFloorRectOld::getClassID(CLSID* pClsid) const
|
|
{
|
|
// *pClsid = CLSID_ComFloorRect;
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus
|
|
TDbFloorRectOld::getOsnapPoints(AcDb::OsnapMode osnapMode,
|
|
int gsSelectionMark,
|
|
const AcGePoint3d& ptPick,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
snapPoints.append(m_ptBase);
|
|
return es;
|
|
}
|
|
|
|
// 从DWG读入数据:
|
|
Acad::ErrorStatus TDbFloorRectOld::dwgInFields(AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
Acad::ErrorStatus es = TDbEntity::dwgInFields(pFiler);
|
|
if(es != Acad::eOk) return es;
|
|
Adesk::UInt8 nVer;
|
|
pFiler->readItem(&nVer);
|
|
ReadString(pFiler, m_sFloorName);
|
|
ReadString(pFiler, m_sSpare);
|
|
pFiler->readItem(&m_nFloorFrom);
|
|
pFiler->readItem(&m_nFloorTo);
|
|
pFiler->readItem(&m_dLength);
|
|
pFiler->readItem(&m_dWidth);
|
|
pFiler->readItem(&m_dFloorHeight);
|
|
pFiler->readItem(&m_bShow);
|
|
pFiler->readItem(&m_nSpare);
|
|
pFiler->readItem((AcGePoint3d *)&m_ptBase);
|
|
pFiler->readItem((AcGePoint3d *)&m_ptCenter);
|
|
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbFloorRectOld::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es = TDbEntity::dwgOutFields(pFiler);
|
|
if(es != Acad::eOk) return es;
|
|
pFiler->writeItem(g_nVersion);
|
|
pFiler->writeItem((const TCHAR *)m_sFloorName);
|
|
pFiler->writeItem((const TCHAR *)m_sSpare);
|
|
pFiler->writeItem(m_nFloorFrom);
|
|
pFiler->writeItem(m_nFloorTo);
|
|
pFiler->writeItem(m_dLength);
|
|
pFiler->writeItem(m_dWidth);
|
|
pFiler->writeItem(m_dFloorHeight);
|
|
pFiler->writeItem(m_bShow);
|
|
pFiler->writeItem(m_nSpare);
|
|
pFiler->writeItem((const AcGePoint3d &)m_ptBase);
|
|
pFiler->writeItem((const AcGePoint3d &)m_ptCenter);
|
|
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbFloorRectOld::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
es=TDbEntity::dxfInFields(pFiler);
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbFloorRectOld::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
es=TDbEntity::dxfOutFields(pFiler);
|
|
return es;
|
|
}
|
|
|
|
|
|
|
|
Acad::ErrorStatus TDbFloorRectOld::transformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
assertWriteEnabled();
|
|
TDbEntity::transformBy(xform);
|
|
m_ptBase.TransformBy(xform);
|
|
m_ptCenter.TransformBy(xform);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//禁止拷贝
|
|
Acad::ErrorStatus TDbFloorRectOld::deepClone(AcDbObject* pOwner,
|
|
AcDbObject*& pClonedObject,
|
|
AcDbIdMapping& idMap,
|
|
Adesk::Boolean isPrimary) const
|
|
{
|
|
pClonedObject = NULL;
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus TDbFloorRectOld::getGripPoints(AcGePoint3dArray& gripPoints,
|
|
AcDbIntArray& osnapModes,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
gripPoints.append(m_ptBase);
|
|
gripPoints.append(m_ptCenter);
|
|
gripPoints.append(GetLowLeft());
|
|
gripPoints.append(GetLowRight());
|
|
gripPoints.append(GetUpRight());
|
|
gripPoints.append(GetUpLeft());
|
|
return Acad::eOk;
|
|
}
|
|
|
|
// 功能: 夹点操作
|
|
Acad::ErrorStatus TDbFloorRectOld::moveStretchPointsAt(
|
|
const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
assertWriteEnabled();
|
|
if(indices.length())
|
|
{
|
|
XPoint &vtOffset=*(XPoint *)&offset;
|
|
// XVector3D vtEcs=Wcs2Ecs(vtOffset, m_vtNormal, TRUE);
|
|
m_ptCenter += vtOffset;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
// 功能: 夹点操作
|
|
Acad::ErrorStatus TDbFloorRectOld::moveGripPointsAt(
|
|
const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
assertWriteEnabled();
|
|
XPoint &vtOffset=*(XPoint *)&offset;
|
|
AcGeMatrix3d mat;
|
|
mat.setToTranslation(offset);
|
|
|
|
int idx=0;
|
|
for (int i = 0; i < indices.length(); i++) {
|
|
idx = indices[i];
|
|
switch(idx) {
|
|
case 0: // Move Center
|
|
{
|
|
m_ptBase.TransformBy(mat);
|
|
}
|
|
break; // stretch begin point
|
|
case 1: // Move Center
|
|
{
|
|
m_ptCenter.TransformBy(mat);
|
|
}
|
|
break; // stretch begin point
|
|
case 2: // Move LowLeft
|
|
{
|
|
XPoint ptLowLeft=GetLowLeft();
|
|
XPoint ptUpRight=GetUpRight();
|
|
ptLowLeft += vtOffset;
|
|
ptLowLeft.z = ptUpRight.z;
|
|
XLine ln(ptUpRight, m_nLayoutRotation);
|
|
XPoint ptPrj;
|
|
ptLowLeft.Project(ln, ptPrj);
|
|
m_dLength = ptPrj.Distance2d(ptUpRight);
|
|
m_dWidth = ptPrj.Distance2d(ptLowLeft);
|
|
Midpoint(ptUpRight, ptLowLeft, m_ptCenter);
|
|
}
|
|
break;
|
|
case 3: // Move LowRight
|
|
{
|
|
XPoint ptLowRight=GetLowRight();
|
|
XPoint ptUpLeft=GetUpLeft();
|
|
ptLowRight += vtOffset;
|
|
ptLowRight.z = ptUpLeft.z;
|
|
XLine ln(ptUpLeft, m_nLayoutRotation);
|
|
XPoint ptPrj;
|
|
ptLowRight.Project(ln, ptPrj);
|
|
m_dLength = ptPrj.Distance2d(ptUpLeft);
|
|
m_dWidth = ptPrj.Distance2d(ptLowRight);
|
|
Midpoint(ptLowRight, ptUpLeft, m_ptCenter);
|
|
}
|
|
break;
|
|
case 4: // Move UpRight
|
|
{
|
|
XPoint ptUpRight=GetUpRight();
|
|
XPoint ptLowLeft=GetLowLeft();
|
|
ptUpRight += vtOffset;
|
|
ptUpRight.z = ptLowLeft.z;
|
|
XLine ln(ptLowLeft, m_nLayoutRotation);
|
|
XPoint ptPrj;
|
|
ptUpRight.Project(&ln, ptPrj);
|
|
m_dLength = ptPrj.Distance2d(ptLowLeft);
|
|
m_dWidth = ptPrj.Distance2d(ptUpRight);
|
|
Midpoint(ptUpRight, ptLowLeft, m_ptCenter);
|
|
}
|
|
break;
|
|
case 5: // Move UpLeft
|
|
{
|
|
XPoint ptUpLeft=GetUpLeft();
|
|
XPoint ptLowRight=GetLowRight();
|
|
ptUpLeft += vtOffset;
|
|
ptUpLeft.z = ptUpLeft.z;
|
|
XLine ln(ptLowRight, m_nLayoutRotation);
|
|
XPoint ptPrj;
|
|
ptUpLeft.Project(&ln, ptPrj);
|
|
m_dLength = ptPrj.Distance2d(ptLowRight);
|
|
m_dWidth = ptPrj.Distance2d(ptUpLeft);
|
|
Midpoint(ptLowRight, ptUpLeft, m_ptCenter);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbFloorRectOld::ExplodeOrDraw3d(XExplodeDraw &dc) const
|
|
{
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
// 取得四个角点
|
|
XPoint TDbFloorRectOld::GetLowLeft() const
|
|
{
|
|
double nAng = atan(m_dWidth/m_dLength);
|
|
double nLen = sqrt(m_dWidth*m_dWidth + m_dLength*m_dLength);
|
|
XPoint ptLowLeft;
|
|
ads_polar(m_ptCenter, m_nLayoutRotation+PI+nAng, nLen/2.0, ptLowLeft);
|
|
return ptLowLeft;
|
|
}
|
|
|
|
|
|
XPoint TDbFloorRectOld::GetLowRight() const
|
|
{
|
|
double nAng = atan(m_dWidth/m_dLength);
|
|
double nLen = sqrt(m_dWidth*m_dWidth + m_dLength*m_dLength);
|
|
XPoint ptLowRight;
|
|
ads_polar(m_ptCenter, m_nLayoutRotation-nAng, nLen/2.0, ptLowRight);
|
|
return ptLowRight;
|
|
}
|
|
|
|
|
|
XPoint TDbFloorRectOld::GetUpRight() const
|
|
{
|
|
double nAng = atan(m_dWidth/m_dLength);
|
|
double nLen = sqrt(m_dWidth*m_dWidth + m_dLength*m_dLength);
|
|
XPoint ptUpRight;
|
|
ads_polar(m_ptCenter, m_nLayoutRotation+nAng, nLen/2.0, ptUpRight);
|
|
return ptUpRight;
|
|
}
|
|
|
|
|
|
XPoint TDbFloorRectOld::GetUpLeft() const
|
|
{
|
|
double nAng = atan(m_dWidth/m_dLength);
|
|
double nLen = sqrt(m_dWidth*m_dWidth + m_dLength*m_dLength);
|
|
XPoint ptUpLeft;
|
|
ads_polar(m_ptCenter, m_nLayoutRotation+PI-nAng, nLen/2.0, ptUpLeft);
|
|
return ptUpLeft;
|
|
}
|
|
|
|
void TDbFloorRectOld::GetPolyline(AcDbPolyline &pline) const
|
|
{
|
|
pline.reset(Adesk::kFalse, 0);
|
|
pline.setElevation(0.0);
|
|
pline.addVertexAt(0, GetLowLeft().AsAcGePoint2d());
|
|
pline.addVertexAt(1, GetLowRight().AsAcGePoint2d());
|
|
pline.addVertexAt(2, GetUpRight().AsAcGePoint2d());
|
|
pline.addVertexAt(3, GetUpLeft().AsAcGePoint2d());
|
|
pline.setClosed(Adesk::kTrue);
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus TDbFloorRectOld::ExplodeOrDraw2d(XExplodeDraw &dc) const
|
|
{
|
|
XPoint ptLowLeft=GetLowLeft();
|
|
XPoint ptLowRight=GetLowRight();
|
|
XPoint ptUpRight=GetUpRight();
|
|
XPoint ptUpLeft=GetUpLeft();
|
|
|
|
|
|
|
|
if(m_bShow)
|
|
{
|
|
ptLowLeft.z=ptLowRight.z=ptUpRight.z=ptUpLeft.z=0;
|
|
XPoly2D poly2d(1);
|
|
poly2d.AppendNode(ptLowLeft);
|
|
poly2d.AppendNode(ptLowRight);
|
|
poly2d.AppendNode(ptUpRight);
|
|
poly2d.AppendNode(ptUpLeft);
|
|
dc << poly2d;
|
|
|
|
|
|
TDbText text;
|
|
text.setPropertiesFrom(this);
|
|
text.SetStyleId(InitTextStyle(TS_STANDARD));
|
|
text.SetText(m_sFloorName);
|
|
text.SetLocation(m_ptCenter);
|
|
text.SetHeight(20);
|
|
text.SetAlignment(XExplodeDraw::kMiddleCenter);
|
|
TPushProperty vProp(&text, dc);
|
|
if(dc.IsFullExplode())
|
|
text.ExplodeOrDraw2d(dc);
|
|
else
|
|
dc.DrawEntity(text);
|
|
}
|
|
|
|
AcDbPoint ptEnt;
|
|
ptEnt.setPosition(m_ptBase);
|
|
dc.DrawEntity(ptEnt);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
void TDbFloorRectOld::GetTips(DList<TObjInfoUnit> &info) const
|
|
{
|
|
info.Append(new TObjInfoUnit(_T("对象类型"), _T("楼层框")));
|
|
|
|
info.Append(new TObjInfoUnit(_T("楼层名词"), m_sFloorName));
|
|
|
|
}
|
|
|
|
|
|
void IniTDbFloorRect(BOOL bTrue)
|
|
{
|
|
if(bTrue) {
|
|
TDbFloorRectOld::rxInit();
|
|
TDbFloorRectOld::InitMatchProtocol(TRUE);
|
|
} else {
|
|
TDbFloorRectOld::InitMatchProtocol(FALSE);
|
|
deleteAcRxClass(TDbFloorRectOld::desc());
|
|
}
|
|
}
|
|
|
|
|