221 lines
4.8 KiB
C++
221 lines
4.8 KiB
C++
#include "stdafx.h"
|
|
#include "DbAirLets.h"
|
|
#include "DbDuct.h"
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS(ATSAirLets, ATSHDbEquipment, AcDb::kDHL_CURRENT,
|
|
AcDb::kMReleaseCurrent, 1, ATS_AIRLETS,
|
|
"ATS_AIRLETS,图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
IMPLEMENT_TENTBASE(TDbAirLets);
|
|
|
|
const Adesk::UInt8 TDbAirLets::g_nVersion = 1;
|
|
|
|
|
|
TDbAirLets::TDbAirLets():
|
|
m_sShape(kRectangle),m_dRadius(0),m_dAirLoad(0), m_dAreaRatio(1),
|
|
m_dDuctIfLength(0),m_dDuctIfWidth(0)
|
|
{
|
|
}
|
|
|
|
void TDbAirLets::CopyPropertiesFrom(AcDbEntity* pSrc, unsigned gMatchFlag)
|
|
{
|
|
assertWriteEnabled();
|
|
THDbEquipment::CopyPropertiesFrom(pSrc, gMatchFlag);
|
|
TDbAirLets *pAirLets = TDbAirLets::cast(pSrc);
|
|
if (pAirLets != NULL) {
|
|
;
|
|
}
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus TDbAirLets::subGetClassID(CLSID* pClsid) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbAirLets::dwgInFields(AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
Acad::ErrorStatus es = THDbEquipment::dwgInFields(pFiler);
|
|
if (es != Acad::eOk)
|
|
return es;
|
|
|
|
Adesk::UInt8 nVer;
|
|
pFiler->readItem(&nVer);
|
|
if (nVer>g_nVersion) // Version is too new
|
|
return Acad::eMakeMeProxy;
|
|
|
|
Adesk::UInt8 nTemp = 0;
|
|
pFiler->readItem(&nTemp);
|
|
m_sShape = (Shape)nTemp;
|
|
pFiler->readItem(&m_dAirLoad);
|
|
pFiler->readItem(&m_dDuctIfLength);
|
|
pFiler->readItem(&m_dDuctIfWidth);
|
|
pFiler->readItem(&m_dRadius);
|
|
pFiler->readItem(&m_dAreaRatio);
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbAirLets::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es = THDbEquipment::dwgOutFields(pFiler);
|
|
if (es != Acad::eOk)
|
|
return es;
|
|
pFiler->writeItem(g_nVersion);
|
|
pFiler->writeItem((Adesk::UInt8)(m_sShape));
|
|
pFiler->writeItem(m_dAirLoad);
|
|
pFiler->writeItem(m_dDuctIfLength);
|
|
pFiler->writeItem(m_dDuctIfWidth);
|
|
pFiler->writeItem(m_dRadius);
|
|
pFiler->writeItem(m_dAreaRatio);
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbAirLets::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
Acad::ErrorStatus es = THDbEquipment::dxfInFields(pFiler);
|
|
if (es != Acad::eOk)
|
|
return es;
|
|
|
|
if (!pFiler->atSubclassData(_T("TDbAirLets")))
|
|
return Acad::eBadDxfSequence;
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbAirLets::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
Acad::ErrorStatus es = THDbEquipment::dxfOutFields(pFiler);
|
|
assert(es == Acad::eOk);
|
|
es = pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbAirLets"));
|
|
assert(es == Acad::eOk);
|
|
return es;
|
|
}
|
|
|
|
void TDbAirLets::GetTips(DList<TObjInfoUnit> &info) const
|
|
{
|
|
info.Append(new TObjInfoUnit(_T("对象类型"), _T("空调风口")));
|
|
THDbEquipment::GetTips(info);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbAirLets::ExplodeOrDraw2d(XExplodeDraw &dc) const
|
|
{
|
|
// cet 2016.10.17 add 图层关闭时,实体不显示,不进行绘制(打印时,也不会绘制)
|
|
AcDbLayerTableRecordPointer player(this->layerId(), AcDb::kForRead);
|
|
if (player.openStatus() == Acad::eOk && player->isOff())
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
Acad::ErrorStatus es = THDbEquipment::ExplodeOrDraw2d(dc);
|
|
|
|
CString sBlkName, sDesName;
|
|
GetBlkNameById(m_idBlock3d, sBlkName, sDesName);
|
|
|
|
int nType(0);
|
|
if (_tcsicmp(sDesName, _T("sysD")) == 0) // 下接风口
|
|
{
|
|
nType = 0;
|
|
}
|
|
else if (_tcsicmp(sDesName, _T("sysS")) == 0) // 侧接风口
|
|
{
|
|
nType = 1;
|
|
}
|
|
else
|
|
{
|
|
return es;
|
|
}
|
|
|
|
DrawSys(dc, nType);
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbAirLets::ExplodeOrDraw3d(XExplodeDraw &dc) const
|
|
{
|
|
Acad::ErrorStatus es = THDbEquipment::ExplodeOrDraw3d(dc);
|
|
|
|
CString sBlkName, sDesName;
|
|
GetBlkNameById(m_idBlock2d, sBlkName, sDesName);
|
|
|
|
int nType(0);
|
|
if (_tcsicmp(sDesName, _T("sysD")) == 0) // 下接风口
|
|
{
|
|
nType = 0;
|
|
}
|
|
else if (_tcsicmp(sDesName, _T("sysS")) == 0) // 侧接风口
|
|
{
|
|
nType = 1;
|
|
}
|
|
else
|
|
{
|
|
return es;
|
|
}
|
|
|
|
DrawSys(dc, nType);
|
|
return es;
|
|
}
|
|
|
|
void TDbAirLets::DrawSys(XExplodeDraw &dc, int nType) const
|
|
{
|
|
int nLen = GetInterfaceNum();
|
|
if (nLen != 1)
|
|
{
|
|
return;
|
|
}
|
|
|
|
OPENOBJ_BEGIN(GetIPipe(0), AcDb::kForRead, TDbDuct, pDuct);
|
|
if (pDuct == NULL)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!pDuct->FindEquipment(objectId())) // 只处理附着风口
|
|
{
|
|
return;
|
|
}
|
|
|
|
XPoint ptLoc = GetLocation(), ptRet, ptTmp;
|
|
XCurveSegment seg = pDuct->GetCurve();
|
|
if (nType == 0) // 下接风口
|
|
{
|
|
ads_polar(ptLoc, PI/2, 100, ptRet);
|
|
}
|
|
else if (nType == 1) // 侧接风口
|
|
{
|
|
double dAngle = GetAngle(); // 图块角度
|
|
if ((fabs(dAngle-PI/4)<1.0E-5) || (fabs(dAngle-1.25*PI)<1.0E-5))
|
|
{
|
|
dAngle = CT_std_angle(dAngle - PI/4);
|
|
}
|
|
else
|
|
{
|
|
dAngle = CT_std_angle(dAngle + PI/4);
|
|
}
|
|
ads_polar(ptLoc, dAngle, 100, ptRet);
|
|
}
|
|
|
|
XLine line(ptLoc, ptRet, LS_INFINITE);
|
|
if (!line.Intersection(&seg, ptTmp))
|
|
{
|
|
return;
|
|
}
|
|
dc << XLine(ptLoc, ptTmp, LS_FINITE);
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
|
|
|
|
void InitTDbAirLets(BOOL bTrue)
|
|
{
|
|
if (bTrue)
|
|
{
|
|
TDbAirLets::rxInit();
|
|
TDbAirLets::InitMatchProtocol(TRUE);
|
|
}
|
|
else
|
|
{
|
|
TDbAirLets::InitMatchProtocol(FALSE);
|
|
deleteAcRxClass(TDbAirLets::desc());
|
|
}
|
|
}
|
|
|