213 lines
4.8 KiB
C++
213 lines
4.8 KiB
C++
#include "stdafx.h"
|
|
#include "dbproxy.h"
|
|
#include "geassign.h"
|
|
#include "acgi.h"
|
|
#include "TDbHvacFitting.h"
|
|
#include "TDbInterfaceMsgWrite.h"
|
|
|
|
#define VERSION_TDBHVACFITTING 1
|
|
|
|
//{{AFX_ARX_MACRO
|
|
ACRX_DXF_DEFINE_MEMBERS( TDbHvacFitting, TDbFittingBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kAllAllowedBits,
|
|
ATS_DBHFITTING, "图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
//}}AFX_ARX_MACRO
|
|
|
|
|
|
TDbHvacFitting::TDbHvacFitting()
|
|
{
|
|
//{{AFX_ARX_DATA_INIT(TDbHvacFitting)
|
|
//}}AFX_ARX_DATA_INIT
|
|
}
|
|
|
|
TDbHvacFitting::~TDbHvacFitting()
|
|
{
|
|
}
|
|
|
|
Acad::ErrorStatus TDbHvacFitting::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es;
|
|
|
|
if ((es = TDbFittingBase::dxfOutFields(pFiler)) != Acad::eOk)
|
|
return es;
|
|
|
|
// Write subclass marker.
|
|
pFiler->writeItem(AcDb::kDxfSubclass, _T("TDbHvacFitting"));
|
|
|
|
// Write version number.
|
|
pFiler->writeItem(AcDb::kDxfInt16, (Adesk::UInt16) VERSION_TDBHVACFITTING);
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbHvacFitting::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
struct resbuf rb;
|
|
|
|
if ((TDbFittingBase::dxfInFields(pFiler) != Acad::eOk) ||
|
|
!pFiler->atSubclassData(_T("TDbHvacFitting")))
|
|
return pFiler->filerStatus();
|
|
|
|
// Read version number.
|
|
pFiler->readItem(&rb);
|
|
if (rb.restype != AcDb::kDxfInt16)
|
|
{
|
|
pFiler->pushBackItem();
|
|
pFiler->setError(Acad::eInvalidDxfCode,
|
|
_T("Error: expected object version group code %d"),
|
|
AcDb::kDxfInt16);
|
|
return pFiler->filerStatus();
|
|
}
|
|
else
|
|
{
|
|
Adesk::UInt16 version = rb.resval.rint;
|
|
if (version > VERSION_TDBHVACFITTING)
|
|
return Acad::eMakeMeProxy;
|
|
}
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbHvacFitting::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es;
|
|
|
|
// Call dwgOutFields from TDbInterfacesObj
|
|
if ((es = TDbFittingBase::dwgOutFields(pFiler)) != Acad::eOk)
|
|
{
|
|
return es;
|
|
}
|
|
|
|
// Write version number.
|
|
pFiler->writeItem((Adesk::UInt16) VERSION_TDBHVACFITTING);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbHvacFitting::dwgInFields(AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
Acad::ErrorStatus es;
|
|
|
|
// Call dwgInFields from TDbInterfacesObj
|
|
if ((es = TDbFittingBase::dwgInFields(pFiler)) != Acad::eOk)
|
|
{
|
|
return es;
|
|
}
|
|
|
|
// Read version number.
|
|
Adesk::UInt16 version;
|
|
pFiler->readItem(&version);
|
|
if (version > VERSION_TDBHVACFITTING)
|
|
return Acad::eMakeMeProxy;
|
|
|
|
switch (version)
|
|
{
|
|
case (1):
|
|
{
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbHvacFitting::subGetTransformedCopy( const AcGeMatrix3d& xform,
|
|
AcDbEntity*& pEnt) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
pEnt = new TDbHvacFitting;
|
|
(TDbHvacFitting*)pEnt->copyFrom(this);
|
|
pEnt->transformBy(xform);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbHvacFitting::ExplodeOrDraw3d( XExplodeDraw &mode ) const
|
|
{
|
|
TDbXDataMap* pMap = GetSpecialtyDataReadOnly();
|
|
|
|
ASSERT(NULL != pMap);
|
|
HvacModelType eType = eModel;
|
|
pMap->GetAt(HVAC_ModeType, (int&)eType);
|
|
if (eSystem == eType)
|
|
return Acad::eNotImplementedYet;
|
|
|
|
return TDbFittingBase::ExplodeOrDraw3d(mode);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbHvacFitting::ExplodeOrDraw2d( XExplodeDraw &mode ) const
|
|
{
|
|
// 每个接口位置绘制一个点,用于完全遮挡管时,可以选择上实体
|
|
// 炸开时不绘制
|
|
BOOL bExplore(FALSE);
|
|
GetGlobalContext()->GetAt(HVAC_IsExplodeDraw, bExplore);
|
|
|
|
if (!bExplore)
|
|
{
|
|
AcColorSettings corSet;
|
|
acedGetCurrentColors(&corSet);
|
|
int nBlue = GetBValue(corSet.dwGfxModelBkColor);
|
|
int nRed = GetRValue(corSet.dwGfxModelBkColor);
|
|
int nGreen = GetGValue(corSet.dwGfxModelBkColor);
|
|
AcCmColor acCor;
|
|
acCor.setRGB(nRed, nGreen, nBlue);
|
|
|
|
TInterface tIf;
|
|
AcDbPoint ptDb;
|
|
ptDb.setLayer(layerId());
|
|
|
|
if (acCor.colorIndex() == 7)
|
|
ptDb.setColorIndex(255);
|
|
else
|
|
ptDb.setColor(acCor);
|
|
|
|
int i(0);
|
|
for (i = 0; i < GetInterfaceCount(); i++)
|
|
{
|
|
tIf.Reset();
|
|
GetInterface(i, tIf);
|
|
|
|
ptDb.setPosition(tIf.GetPosition());
|
|
mode.DrawEntity(ptDb);
|
|
}
|
|
}
|
|
|
|
return TDbFittingBase::ExplodeOrDraw2d(mode);
|
|
}
|
|
|
|
// 炸开
|
|
Acad::ErrorStatus TDbHvacFitting::subExplode( AcDbVoidPtrArray& entitySet ) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
GetGlobalContext()->SetAt(HVAC_IsExplodeDraw, TRUE);
|
|
Acad::ErrorStatus eState = TDbFittingBase::subExplode(entitySet);
|
|
GetGlobalContext()->SetAt(HVAC_IsExplodeDraw, FALSE);
|
|
|
|
return eState;
|
|
}
|
|
|
|
void TDbHvacFitting::WriteMoveTransMsg(AcGeVector3d vtMove)
|
|
{
|
|
if (vtMove.length() > 1e-6)
|
|
{
|
|
TInterfaceModifyMsg iMsg;
|
|
iMsg.SetGripPosition(TDb::eStart);
|
|
iMsg.SetMsgValidate(TRUE);
|
|
iMsg.SetTransform(vtMove);
|
|
iMsg.SetMoveGripOffset(vtMove);
|
|
iMsg.SetInterfaceOper(TDb::eMoveGripPoint);
|
|
iMsg.SetMsgOperateOn(objectId());
|
|
|
|
// 写入接口更改消息
|
|
TDbInterfaceMsgWrite msgWrite;
|
|
msgWrite.WriteInterfaceMsg(iMsg);
|
|
}
|
|
}
|
|
|