Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

242 lines
5.9 KiB
C++

#include "stdafx.h"
#include "StdArx.h"
#include "dbproxy.h"
#include "geassign.h"
#include "acgi.h"
#include "TDbHvacEquipment.h"
#define VERSION_TDBHVACEQUIPMENT 1
//{{AFX_ARX_MACRO
ACRX_DXF_DEFINE_MEMBERS( TDbHvacEquipment, TDbEquipmentBase,
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
AcDbProxyEntity::kAllAllowedBits,
ATS_DBHEQUIPMENT, "图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
//}}AFX_ARX_MACRO
TDbHvacEquipment::TDbHvacEquipment()
{
//{{AFX_ARX_DATA_INIT(TDbHvacEquipment)
//}}AFX_ARX_DATA_INIT
m_bIsDragging = FALSE;
}
TDbHvacEquipment::~TDbHvacEquipment()
{
}
Acad::ErrorStatus TDbHvacEquipment::dxfOutFields(AcDbDxfFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es;
if ((es = TDbEquipmentBase::dxfOutFields(pFiler)) != Acad::eOk)
return es;
// Write subclass marker.
pFiler->writeItem(AcDb::kDxfSubclass, _T("TDbHvacEquipment"));
// Write version number.
pFiler->writeItem(AcDb::kDxfInt16, (Adesk::UInt16) VERSION_TDBHVACEQUIPMENT);
// add begin
if( g_nProductId == 15 )
{
TDb::ObjectKind eKind;
CString sEquipName, sEquipType;
TDbXDataMap *pMap = GetSpecialtyDataReadOnly();
pMap->GetAt(KEY_RUNTIME, (int&)eKind);
pMap->GetAt(HALT_SEquipType, sEquipType);
pMap->GetAt(HALT_SEquipName, sEquipName);
pFiler->writeItem(AcDb::kDxfXXInt16, eKind); // 设备类型
pFiler->writeItem(AcDb::kDxfXTextString, sEquipType); // 设备名称
pFiler->writeItem(AcDb::kDxfXTextString+1, sEquipName); // 设备型号
if( TDb::eVRVEqu == eKind )
{// 多联机室外机/室外机
int nType = 0;
CString sMaker;
pMap->GetAt(HVRV_SFactory, sMaker);
pMap->GetAt(HVRV_IType, nType);
CString sKind = nType==0?_T("室内机"):_T("室外机");
pFiler->writeItem(AcDb::kDxfXTextString+2, sMaker); // 厂家(VRV)
pFiler->writeItem(AcDb::kDxfXTextString+3, sKind); // 样式(室内/外机)
}
}
// add end by cq 2015-06-03 增加dxf数据强化"过滤选择"功能
return es;
}
Acad::ErrorStatus TDbHvacEquipment::dxfInFields(AcDbDxfFiler* pFiler)
{
assertWriteEnabled();
struct resbuf rb;
if ((TDbEquipmentBase::dxfInFields(pFiler) != Acad::eOk) ||
!pFiler->atSubclassData(_T("TDbHvacEquipment")))
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_TDBHVACEQUIPMENT)
return Acad::eMakeMeProxy;
}
return pFiler->filerStatus();
}
Acad::ErrorStatus TDbHvacEquipment::dwgOutFields(AcDbDwgFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es;
// Call dwgOutFields from TDbInterfacesObj
if ((es = TDbEquipmentBase::dwgOutFields(pFiler)) != Acad::eOk)
{
return es;
}
// Write version number.
pFiler->writeItem((Adesk::UInt16) VERSION_TDBHVACEQUIPMENT);
return pFiler->filerStatus();
}
Acad::ErrorStatus TDbHvacEquipment::dwgInFields(AcDbDwgFiler* pFiler)
{
assertWriteEnabled();
Acad::ErrorStatus es;
// Call dwgInFields from TDbInterfacesObj
if ((es = TDbEquipmentBase::dwgInFields(pFiler)) != Acad::eOk)
{
return es;
}
// Read version number.
Adesk::UInt16 version;
pFiler->readItem(&version);
if (version > VERSION_TDBHVACEQUIPMENT)
return Acad::eMakeMeProxy;
switch (version)
{
case (1):
break;
default:
break;
}
return pFiler->filerStatus();
}
Acad::ErrorStatus TDbHvacEquipment::subGetTransformedCopy( const AcGeMatrix3d& xform,
AcDbEntity*& pEnt) const
{
assertReadEnabled();
pEnt = new TDbHvacEquipment;
(TDbHvacEquipment*)pEnt->copyFrom(this);
pEnt->transformBy(xform);
return Acad::eOk;
}
Acad::ErrorStatus TDbHvacEquipment::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 TDbEquipmentBase::ExplodeOrDraw3d(mode);
}
BOOL TDbHvacEquipment::IsDragging() const
{
return m_bIsDragging;
}
Adesk::Boolean TDbHvacEquipment::subWorldDraw(AcGiWorldDraw *pWd)
{
m_bIsDragging = pWd->isDragging();
Adesk::Boolean bRet = TDbEquipmentBase::subWorldDraw(pWd);
m_bIsDragging = FALSE;
return bRet;
}
void TDbHvacEquipment::subViewportDraw(AcGiViewportDraw* pMode)
{
m_bIsDragging = pMode->isDragging();
TDbEquipmentBase::subViewportDraw(pMode);
m_bIsDragging = FALSE;
}
// 建立接口关联关系 add by hh 2013-9-12 更新接口记录
BOOL TDbHvacEquipment::SetInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
{
if(!TDbEquipmentBase::SetInterfaceRelation(ptConnect, idConnect))
return FALSE;
// 更新接口记录
BOOL bSuccess = FALSE;
AcDbObjectId idOwner = objectId();
if (idOwner.isValid())
{
TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB();
if(NULL != pIntfRec)
{
if(Acad::eOk == pIntfRec->upgradeOpen())
{
bSuccess = pIntfRec->Update(idOwner,ptConnect,idConnect);
pIntfRec->downgradeOpen();
}
pIntfRec->close();
return bSuccess;
}
AcDbDictionary* pNamedDict = NULL;
if (Acad::eOk == acdbCurDwg()->getNamedObjectsDictionary(pNamedDict,AcDb::kForRead))
{
AcDbDictionary* pDict = NULL;
if (Acad::eOk == pNamedDict->getAt(KEY_IRECORD,(AcDbObject*&)pDict,AcDb::kForRead))
{
pNamedDict->close();
TDbInterfaceRecord* pInterfaceRec = NULL;
if (Acad::eOk == pDict->getAt(KEY_IRECORD,(AcDbObject*&)pInterfaceRec,AcDb::kForWrite))
{
pDict->close();
bSuccess = pIntfRec->Update(idOwner,ptConnect,idConnect);
pInterfaceRec->close();
}
else
{
pDict->close();
}
}
else
{
pNamedDict->close();
}
}
}
return TRUE;
}