1322 lines
32 KiB
C++
1322 lines
32 KiB
C++
#include "stdafx.h"
|
||
#include "DbRadiator.h"
|
||
#include "DbPipe.h"
|
||
#include "DbRect.h"
|
||
#include "PipeTools.h"
|
||
#include "dbtext.h"
|
||
|
||
ACRX_DXF_DEFINE_MEMBERS(ATSRadiator, ATSPipeNode, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
||
1, ATS_RADIATOR, "ATS_RADIATOR图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
||
IMPLEMENT_TENTBASE(TDbRadiator);
|
||
|
||
|
||
// const Adesk::UInt8 TDbRadiator::g_nVersion = 1;
|
||
const Adesk::UInt8 TDbRadiator::g_nVersion = 2; // sg modify
|
||
extern BOOL Is2DView();
|
||
|
||
#define SHOW_UNIT _T("ShowUnit") // 是否显示单位i
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// Construction
|
||
//////////////////////////////////////////////////////////////////////
|
||
TDbRadiator::TDbRadiator():
|
||
m_typeIFace(kSide), m_dSysAngle(0), m_bHasValve(TRUE), m_bIsReverse(FALSE),
|
||
m_nType(0), m_dWeight(0.35), m_dLoad(1000)
|
||
{
|
||
m_visibility = TPipeSys::kVisible;
|
||
m_dSizeX = 800.0;
|
||
m_dSizeY = 200.0;
|
||
m_dSizeZ = 600.0;
|
||
m_dRotation = 0.0;
|
||
|
||
// 添加2个接口
|
||
TPipeInterface iFace;
|
||
iFace.m_faceType = TPipeInterface::kBoundry;
|
||
iFace.m_flowDir = TPipeSys::kInlet; // 第1个接口流进
|
||
AddInterface(iFace);
|
||
|
||
iFace.m_flowDir = TPipeSys::kOutlet; // 第2个接口流出
|
||
AddInterface(iFace);
|
||
|
||
m_iDrawMode = 0;
|
||
m_iNum = 20;
|
||
m_dNum = 1.0; // sg add
|
||
|
||
m_sFactory = _T("无");
|
||
m_sType = _T("无");
|
||
m_nFormula = 0;
|
||
m_dA = 0;
|
||
m_dB = 0;
|
||
m_dUnitArea = 0;
|
||
m_dUnitQ = 0;
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// Override TDbEntity
|
||
//////////////////////////////////////////////////////////////////////
|
||
void TDbRadiator::CopyPropertiesFrom(AcDbEntity *pSrc, unsigned gMatchFlag)
|
||
{
|
||
assertWriteEnabled();
|
||
TDbPipeNode::CopyPropertiesFrom(pSrc, gMatchFlag);
|
||
TDbRadiator *pRadiator = TDbRadiator::cast(pSrc);
|
||
if (pRadiator != NULL)
|
||
{
|
||
m_dSizeX = pRadiator->m_dSizeX;
|
||
m_dSizeY = pRadiator->m_dSizeY;
|
||
m_dSizeZ = pRadiator->m_dSizeZ;
|
||
m_bHasValve = pRadiator->m_bHasValve;
|
||
m_bIsReverse = pRadiator->m_bIsReverse;
|
||
|
||
m_dRotation = pRadiator->m_dRotation;
|
||
m_dSysAngle = pRadiator->m_dSysAngle;
|
||
m_dWeight = pRadiator->m_dWeight;
|
||
m_iDrawMode = pRadiator->m_iDrawMode;
|
||
m_iNum = pRadiator->m_iNum;
|
||
m_dLoad = pRadiator->m_dLoad;
|
||
m_dNum = pRadiator->m_dNum;
|
||
m_sFactory = pRadiator->m_sFactory;
|
||
m_sType = pRadiator->m_sType;
|
||
m_nFormula = pRadiator->m_nFormula;
|
||
m_dA = pRadiator->m_dA;
|
||
m_dB = pRadiator->m_dB;
|
||
m_dUnitArea = pRadiator->m_dUnitArea;
|
||
m_dUnitQ = pRadiator->m_dUnitQ;
|
||
}
|
||
}
|
||
//AOLAPI double g_nAcadVer;
|
||
|
||
Acad::ErrorStatus TDbRadiator::subGetClassID(CLSID* pClsid) const
|
||
{
|
||
// delete by hh 2013-1-15 18及以上平台 开启特性表
|
||
// if (g_nAcadVer > 17.19)
|
||
// return Acad::eOk;
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// 取动态属性显示数据
|
||
void TDbRadiator::GetTips(DList<TObjInfoUnit> &info) const
|
||
{
|
||
info.Append(new TObjInfoUnit(_T("对象类型"), _T("散热器")));
|
||
|
||
BOOL bValidIn = FALSE;
|
||
BOOL bValidOut = FALSE;
|
||
if (m_lstInterface.Length() == 2)
|
||
{
|
||
bValidIn = HasInPipe();
|
||
bValidOut = HasOutPipe();
|
||
}
|
||
|
||
info.Append(new TObjInfoUnit(_T("散热器厂家"), m_sFactory));
|
||
info.Append(new TObjInfoUnit(_T("散热器型号"), m_sType));
|
||
info.Append(new TObjInfoUnit(_T("散热器长"), Dist2Str(m_dSizeX)));
|
||
info.Append(new TObjInfoUnit(_T("散热器宽"), Dist2Str(m_dSizeY)));
|
||
info.Append(new TObjInfoUnit(_T("散热器高"), Dist2Str(m_dSizeZ)));
|
||
info.Append(new TObjInfoUnit(_T("负荷"), XString(_T("%.1f"), m_dLoad)));
|
||
if (m_iDrawMode == 1)
|
||
{
|
||
info.Append(new TObjInfoUnit(_T("片数"), XString(_T("%.d"), m_iNum)));
|
||
}
|
||
else if (m_iDrawMode == 3)
|
||
{
|
||
info.Append(new TObjInfoUnit(_T("片数"), XString(_T("%.1f"), m_dNum)));
|
||
}
|
||
info.Append(new TObjInfoUnit(_T("进口连接"), bValidIn? _T("完成") : _T("未连")));
|
||
info.Append(new TObjInfoUnit(_T("出口连接"), bValidOut? _T("完成") : _T("未连")));
|
||
}
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// Override AcTDbEntity
|
||
//////////////////////////////////////////////////////////////////////
|
||
Acad::ErrorStatus
|
||
TDbRadiator::subGetOsnapPoints(AcDb::OsnapMode osnapMode,
|
||
INT_PTR gsSelectionMark,
|
||
const AcGePoint3d& ptPick,
|
||
const AcGePoint3d& lastPoint,
|
||
const AcGeMatrix3d& viewXform,
|
||
AcGePoint3dArray& snapPoints,
|
||
AcDbIntArray& geomIds) const
|
||
{
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
if (osnapMode == AcDb::kOsModeIns || osnapMode == AcDb::kOsModeCen ||
|
||
osnapMode == AcDb::kOsModeNode)
|
||
{
|
||
snapPoints.append(m_ptLocation);
|
||
}
|
||
|
||
es = TDbPipeNode::subGetOsnapPoints(osnapMode, gsSelectionMark, ptPick,
|
||
lastPoint, viewXform, snapPoints, geomIds);
|
||
return es;
|
||
}
|
||
|
||
Acad::ErrorStatus
|
||
TDbRadiator::GetGripText(int idx, CString &cs) const
|
||
{
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
switch(idx) {
|
||
case 0:
|
||
cs = _T("流进接口");
|
||
break;
|
||
case 1:
|
||
cs = _T("流出接口");
|
||
break;
|
||
case 2:
|
||
cs = _T("移动散热器");
|
||
break;
|
||
case 3:
|
||
cs = _T("移动标注点");
|
||
break;
|
||
default:
|
||
es = Acad::eInvalidInput;
|
||
}
|
||
return es;
|
||
}
|
||
|
||
Acad::ErrorStatus
|
||
TDbRadiator::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
||
AcDbIntArray& osnapModes,
|
||
AcDbIntArray& geomIds) const
|
||
{
|
||
assertReadEnabled();
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
es = TDbPipeNode::subGetGripPoints(gripPoints, osnapModes, geomIds);
|
||
if (es != Acad::eOk)
|
||
{
|
||
return es;
|
||
}
|
||
return GetGSPoints(gripPoints);
|
||
}
|
||
|
||
Acad::ErrorStatus
|
||
TDbRadiator::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
|
||
{
|
||
assertReadEnabled();
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
es = TDbPipeNode::subGetStretchPoints(stretchPoints);
|
||
if (es != Acad::eOk)
|
||
{
|
||
return es;
|
||
}
|
||
return GetGSPoints(stretchPoints);
|
||
}
|
||
|
||
Acad::ErrorStatus
|
||
TDbRadiator::GetGSPoints(AcGePoint3dArray & stretchPoints) const
|
||
{
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
XPoint pt1, pt2, pt3, pt4;
|
||
if (GetExplodeMode()==DRAW_2D || IsSysType())
|
||
{
|
||
GetVertexs2d(pt1, pt2, pt3, pt4);
|
||
}
|
||
else
|
||
{
|
||
GetRectVertexs(pt1, pt2, pt3, pt4, FALSE);
|
||
}
|
||
stretchPoints.append(m_ptLocation);
|
||
|
||
if (!!m_ptLabel)
|
||
{
|
||
stretchPoints.append(m_ptLabel);
|
||
}
|
||
return es;
|
||
}
|
||
|
||
Acad::ErrorStatus
|
||
TDbRadiator::subMoveGripPointsAt(const AcDbIntArray& indices,
|
||
const AcGeVector3d& offset)
|
||
{
|
||
assertWriteEnabled();
|
||
Acad::ErrorStatus es = MoveGSPointsAt(indices, offset);
|
||
if (objectId().isValid())
|
||
{
|
||
ApplyChangeToPipe();
|
||
}
|
||
return es;
|
||
}
|
||
|
||
Acad::ErrorStatus
|
||
TDbRadiator::MoveGSPointsAt(const AcDbIntArray& indices,
|
||
const AcGeVector3d& offset)
|
||
{
|
||
assertWriteEnabled();
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
XPoint ptFix = m_ptLocation;
|
||
int idx = 0;
|
||
for (int i = 0; i < indices.length(); i++)
|
||
{
|
||
idx = indices[i];
|
||
switch(idx) {
|
||
case 2:
|
||
{
|
||
m_ptLocation += offset;
|
||
OutLocation() += offset;
|
||
InLocation() += offset;
|
||
break;
|
||
}
|
||
case 3:
|
||
{
|
||
m_ptLabel += offset;
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus
|
||
TDbRadiator::subMoveStretchPointsAt(const AcDbIntArray& indices,
|
||
const AcGeVector3d& offset)
|
||
{
|
||
assertWriteEnabled();
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
es = TDbPipeNode::subMoveStretchPointsAt(indices, offset);
|
||
if (es != Acad::eOk)
|
||
{
|
||
return es;
|
||
}
|
||
return MoveGSPointsAt(indices, offset);
|
||
}
|
||
|
||
Acad::ErrorStatus TDbRadiator::subTransformBy(const AcGeMatrix3d& xform)
|
||
{
|
||
assertWriteEnabled();
|
||
|
||
/*TDbPipeNode::subTransformBy(xform);
|
||
m_ptLocation.TransformBy(xform);
|
||
if (!!m_ptLabel)
|
||
{
|
||
m_ptLabel.TransformBy(xform); // gesp added
|
||
}
|
||
|
||
XVector3D vtRot(cos(m_dRotation), sin(m_dRotation));
|
||
((AcGeVector3d &)vtRot).transformBy(xform);
|
||
m_dRotation = ads_angle(XPoint(), vtRot);
|
||
|
||
// 系统图的角度 ywb 2009-6-11
|
||
XVector3D vtRot1(cos(m_dSysAngle), sin(m_dSysAngle));
|
||
((AcGeVector3d &)vtRot1).transformBy(xform);
|
||
m_dSysAngle = ads_angle(XPoint(), vtRot1);*/
|
||
|
||
// if (objectId().isValid()) {
|
||
// ApplyChangeToPipe();
|
||
// } // gesp
|
||
|
||
// change by hh 2012-08-16 move或copy时,忽略标高差
|
||
AcGeMatrix3d matNew(xform);
|
||
XString &sCmd = GetCurDocData()->m_sCurCommand;
|
||
if((0 == _tcsicmp(sCmd, _T("move")) || 0 == _tcsicmp(sCmd, _T("copy"))
|
||
|| 0 == _tcsicmp(sCmd, _T("pasteclip"))) && Is2DView())
|
||
{
|
||
/*AcGeVector3d vtNoneZ = xform.translation();
|
||
vtNoneZ = vtNoneZ.orthoProject(GetUcsZvt());
|
||
matNew.setToTranslation(vtNoneZ);*/
|
||
// delete by yxx 20150708 修改散热器在ucs下角度问题
|
||
}
|
||
TDbPipeNode::subTransformBy(matNew);
|
||
m_ptLocation.TransformBy(matNew);
|
||
if (!!m_ptLabel)
|
||
{
|
||
m_ptLabel.TransformBy(matNew);
|
||
}
|
||
|
||
XVector3D vtRot(cos(m_dRotation), sin(m_dRotation));
|
||
((AcGeVector3d &)vtRot).transformBy(matNew);
|
||
m_dRotation = ads_angle(XPoint(), vtRot);
|
||
|
||
// 系统图的角度
|
||
XVector3D vtRot1(cos(m_dSysAngle), sin(m_dSysAngle));
|
||
((AcGeVector3d &)vtRot1).transformBy(matNew);
|
||
m_dSysAngle = ads_angle(XPoint(), vtRot1);
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 读写数据
|
||
//////////////////////////////////////////////////////////////////////
|
||
Acad::ErrorStatus TDbRadiator::dwgInFields(AcDbDwgFiler* pFiler)
|
||
{
|
||
assertWriteEnabled();
|
||
Acad::ErrorStatus es = TDbPipeNode::dwgInFields(pFiler);
|
||
if (es != Acad::eOk)
|
||
{
|
||
return es;
|
||
}
|
||
es = TLabelStyle::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;
|
||
}
|
||
|
||
pFiler->readItem((AcGePoint3d *)&m_ptLocation);
|
||
pFiler->readItem((AcGePoint3d *)&m_ptLabel);
|
||
|
||
pFiler->readItem(&m_dRotation);
|
||
pFiler->readItem(&m_dSizeX);
|
||
pFiler->readItem(&m_dSizeY);
|
||
pFiler->readItem(&m_dSizeZ);
|
||
|
||
pFiler->readItem(&m_dSysAngle);
|
||
//pFiler->readItem(&m_bHasValve);
|
||
//pFiler->readItem(&m_bIsReverse);
|
||
FilerRead(pFiler, m_bHasValve);
|
||
FilerRead(pFiler, m_bIsReverse);
|
||
pFiler->readItem(&m_nType);
|
||
pFiler->readItem(&m_dWeight);
|
||
pFiler->readItem(&m_iNum);
|
||
pFiler->readItem(&m_iDrawMode);
|
||
pFiler->readItem(&m_idLabelLayer);
|
||
pFiler->readItem(&m_dLoad);
|
||
if (nVer > 1)
|
||
{
|
||
pFiler->readItem(&m_dNum);
|
||
ReadString(pFiler, m_sFactory);
|
||
ReadString(pFiler, m_sType);
|
||
pFiler->readItem(&m_nFormula);
|
||
pFiler->readItem(&m_dA);
|
||
pFiler->readItem(&m_dB);
|
||
pFiler->readItem(&m_dUnitArea);
|
||
pFiler->readItem(&m_dUnitQ);
|
||
}
|
||
else
|
||
{
|
||
m_dNum = 1.0;
|
||
m_sFactory = _T("无");
|
||
m_sType = _T("无");
|
||
m_nFormula = 0;
|
||
m_dA = 0;
|
||
m_dB = 0;
|
||
m_dUnitArea = 0;
|
||
m_dUnitQ = 0;
|
||
|
||
}
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TDbRadiator::dwgOutFields(AcDbDwgFiler* pFiler) const
|
||
{
|
||
assertReadEnabled();
|
||
Acad::ErrorStatus es = TDbPipeNode::dwgOutFields(pFiler);
|
||
if (es != Acad::eOk)
|
||
{
|
||
return es;
|
||
}
|
||
es = TLabelStyle::dwgOutFields(pFiler);
|
||
if (es != Acad::eOk)
|
||
{
|
||
return es;
|
||
}
|
||
|
||
// if (g_nSaveTArchVer == 7) // 8.0使用
|
||
// {
|
||
// pFiler->writeItem((Adesk::UInt8)1);
|
||
// }
|
||
// else
|
||
// {
|
||
// pFiler->writeItem(g_nVersion);
|
||
// }
|
||
pFiler->writeItem(g_nVersion);
|
||
pFiler->writeItem((const AcGePoint3d &)m_ptLocation);
|
||
pFiler->writeItem((const AcGePoint3d &)m_ptLabel);
|
||
|
||
pFiler->writeItem(m_dRotation);
|
||
pFiler->writeItem(m_dSizeX);
|
||
pFiler->writeItem(m_dSizeY);
|
||
pFiler->writeItem(m_dSizeZ);
|
||
|
||
pFiler->writeItem(m_dSysAngle);
|
||
//pFiler->writeItem(m_bHasValve);
|
||
//pFiler->writeItem(m_bIsReverse);
|
||
FilerWrite(pFiler, m_bHasValve);
|
||
FilerWrite(pFiler, m_bIsReverse);
|
||
pFiler->writeItem(m_nType);
|
||
pFiler->writeItem(m_dWeight);
|
||
|
||
pFiler->writeItem(m_iNum);
|
||
pFiler->writeItem(m_iDrawMode);
|
||
pFiler->writeItem(m_idLabelLayer);
|
||
pFiler->writeItem(m_dLoad);
|
||
|
||
// if (g_nSaveTArchVer > 7) // 8.0使用
|
||
// {
|
||
pFiler->writeItem(m_dNum);
|
||
pFiler->writeItem((const TCHAR *)m_sFactory);
|
||
pFiler->writeItem((const TCHAR *)m_sType);
|
||
pFiler->writeItem(m_nFormula);
|
||
pFiler->writeItem(m_dA);
|
||
pFiler->writeItem(m_dB);
|
||
pFiler->writeItem(m_dUnitArea);
|
||
pFiler->writeItem(m_dUnitQ);
|
||
// }
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TDbRadiator::dxfInFields(AcDbDxfFiler* pFiler)
|
||
{
|
||
assertWriteEnabled();
|
||
Acad::ErrorStatus es = TDbPipeNode::dxfInFields(pFiler);
|
||
if (es!=Acad::eOk)
|
||
{
|
||
return es;
|
||
}
|
||
|
||
if (!pFiler->atSubclassData(_T("TDbRadiator")))
|
||
{
|
||
return Acad::eBadDxfSequence;
|
||
}
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TDbRadiator::dxfOutFields(AcDbDxfFiler* pFiler) const
|
||
{
|
||
Acad::ErrorStatus es;
|
||
es = TDbPipeNode::dxfOutFields(pFiler);
|
||
assert(es == Acad::eOk);
|
||
es = pFiler->writeItem(AcDb::kDxfSubclass, _T("TDbRadiator"));
|
||
assert(es == Acad::eOk);
|
||
return es;
|
||
}
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 有关Rect
|
||
//////////////////////////////////////////////////////////////////////
|
||
void TDbRadiator::AsRect(TDbRect &rect) const
|
||
{
|
||
rect.setPropertiesFrom(this);
|
||
rect.SetCenter(m_ptLocation);
|
||
rect.SetSizeX(m_dSizeX);
|
||
rect.SetSizeY(m_dSizeY);
|
||
rect.SetSizeZ(m_dSizeZ);
|
||
rect.SetRotation(m_dRotation);
|
||
}
|
||
void TDbRadiator::GetVertexs2d(XPoint &pt1, XPoint &pt2, XPoint &pt3,
|
||
XPoint &pt4) const
|
||
{
|
||
if (IsSysType())
|
||
{
|
||
GetSysVertexs2d(pt1, pt2, pt3, pt4);
|
||
}
|
||
else
|
||
{
|
||
GetRectVertexs(pt1, pt2, pt3, pt4, TRUE);
|
||
}
|
||
}
|
||
|
||
void TDbRadiator::GetSysVertexs2d(XPoint &pt1, XPoint &pt2, XPoint &pt3,
|
||
XPoint &pt4) const
|
||
{
|
||
double dAngle = CT_std_angle(m_dSysAngle);
|
||
double dSizeX = cos(dAngle) * m_dSizeX;
|
||
double dSubZ = sin(dAngle) * m_dSizeX;
|
||
|
||
pt1.x = m_ptLocation.x;
|
||
pt1.y = m_ptLocation.y - m_dSizeZ/2;
|
||
|
||
pt2.x = pt1.x + dSizeX;
|
||
pt2.y = pt1.y + dSubZ;
|
||
|
||
pt3.x = pt2.x;
|
||
pt3.y = pt2.y + m_dSizeZ;
|
||
|
||
pt4.x = m_ptLocation.x;
|
||
pt4.y = m_ptLocation.y + m_dSizeZ/2;
|
||
|
||
pt1.z = pt2.z = pt3.z = pt4.z = 0;
|
||
}
|
||
|
||
void TDbRadiator::GetSysVertexs(XPoint &ptLeftLow, XPoint &ptRightLow,
|
||
XPoint &ptRightUp, XPoint &ptLeftUp) const
|
||
{
|
||
GetSysVertexs2d(ptLeftLow, ptRightLow, ptRightUp, ptLeftUp);
|
||
double dAngle = CT_std_angle(m_dSysAngle);
|
||
if (dAngle>PI/2 && dAngle<PI*3/2)
|
||
{
|
||
TchPrivate::Exchange(ptLeftLow, ptRightLow);
|
||
TchPrivate::Exchange(ptRightUp, ptLeftUp);
|
||
}
|
||
}
|
||
|
||
void TDbRadiator::GetRectVertexs(XPoint &ptLeftLow, XPoint &ptRightLow,
|
||
XPoint &ptRightUp, XPoint &ptLeftUp, BOOL b2d) const
|
||
{
|
||
double dSizeX = fabs(m_dSizeX/2);
|
||
double dSizeY = fabs(m_dSizeY/2);
|
||
|
||
ptLeftLow.x = m_ptLocation.x - dSizeX;
|
||
ptLeftLow.y = m_ptLocation.y - dSizeY;
|
||
ptRightLow.x = m_ptLocation.x + dSizeX;
|
||
ptRightLow.y = m_ptLocation.y - dSizeY;
|
||
ptRightUp.x = m_ptLocation.x + dSizeX;
|
||
ptRightUp.y = m_ptLocation.y + dSizeY;
|
||
ptLeftUp.x = m_ptLocation.x - dSizeX;
|
||
ptLeftUp.y = m_ptLocation.y + dSizeY;
|
||
|
||
ads_matrix mat;
|
||
m_ptLocation.GetRotationMatrix(m_dRotation, mat);
|
||
ptLeftLow.TransformBy(mat);
|
||
ptRightLow.TransformBy(mat);
|
||
ptRightUp.TransformBy(mat);
|
||
ptLeftUp.TransformBy(mat);
|
||
|
||
if (b2d)
|
||
{
|
||
ptLeftLow.z = ptRightLow.z = ptRightUp.z = ptLeftUp.z = 0;
|
||
}
|
||
else
|
||
{
|
||
ptLeftLow.z = ptRightLow.z = ptRightUp.z = ptLeftUp.z = m_ptLocation.z;
|
||
}
|
||
}
|
||
|
||
void TDbRadiator::GetOutline(XPoly2D &poly) const
|
||
{
|
||
poly.Reset();
|
||
poly.SetFlag(1);
|
||
XPoint pt1, pt2, pt3, pt4;
|
||
GetVertexs2d(pt1, pt2, pt3, pt4);
|
||
poly.AppendNode(pt1);
|
||
poly.AppendNode(pt2);
|
||
poly.AppendNode(pt3);
|
||
poly.AppendNode(pt4);
|
||
}
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 有关绘制
|
||
//////////////////////////////////////////////////////////////////////
|
||
extern void DrawWeight(XExplodeDraw &dc, double dWeight, XPoly2D &poly,
|
||
int nColorIndex, double nScale);
|
||
// 绘制2D散热器实体
|
||
Acad::ErrorStatus TDbRadiator::DrawRadiator2d(XExplodeDraw &dc) const
|
||
{
|
||
XAcGiViewDraw &viewDraw = (XAcGiViewDraw &)dc;
|
||
XPoly2D poly;
|
||
GetOutline(poly);
|
||
if (!IsSysType())
|
||
{
|
||
double dWeight = GetPScale()*m_dWeight;
|
||
DrawWeight(dc, dWeight, poly, colorIndex(), linetypeScale());
|
||
}
|
||
else
|
||
{
|
||
// change by zh 解决系统散热器不加粗的问题
|
||
//dc << poly;
|
||
double dWeight = GetPScale()*m_dWeight;
|
||
DrawWeight(dc, dWeight, poly, colorIndex(), linetypeScale());
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// 绘制2D阀门
|
||
Acad::ErrorStatus TDbRadiator::DrawValve2d(XExplodeDraw &dc) const
|
||
{
|
||
if (m_bHasValve && IsSysType())
|
||
{
|
||
XPoint ptLeftLow, ptRightLow, ptRightUp, ptLeftUp;
|
||
// 散热器的系统图边框
|
||
GetSysVertexs2d(ptLeftLow, ptRightLow, ptRightUp, ptLeftUp);
|
||
|
||
// double dAngle = CT_std_angle(m_dSysAngle); // sg modify
|
||
double dAngle(0);
|
||
XPoint pt0, pt1, pt2;
|
||
if (m_bIsReverse) // 相反
|
||
{
|
||
dAngle = CT_std_angle(m_dSysAngle - PI);
|
||
pt0 = ptLeftLow;
|
||
}
|
||
else // 相同
|
||
{
|
||
dAngle = CT_std_angle(m_dSysAngle);
|
||
pt0 = ptRightLow;
|
||
}
|
||
|
||
pt0.y += m_dSizeZ * 5/6;
|
||
ads_polar(pt0, dAngle, m_dSizeZ/6, pt1);
|
||
pt2 = pt1;
|
||
pt2.y += m_dSizeZ * 2/6;
|
||
|
||
dc << XLine(pt0, pt1) << XLine(pt1, pt2); // 排气阀
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// 绘制2D标注文字
|
||
Acad::ErrorStatus TDbRadiator::DrawLabelText(XExplodeDraw &dc) const
|
||
{
|
||
AcDbObjectId idLayerOld = dc.GetLayerId();
|
||
if (m_idLabelLayer.isValid())
|
||
{
|
||
dc.SetLayer(m_idLabelLayer);
|
||
}
|
||
|
||
TDbText text;
|
||
text.setPropertiesFrom(this);
|
||
text.setLayer(m_idLabelLayer);
|
||
text.SetStyleId(m_idTextStyle);
|
||
BOOL bUnit = GetUnit();
|
||
if (m_iDrawMode == 1)
|
||
{
|
||
// text.SetText(XString(_T("%d"), m_iNum)); // 标注片数,片单位 modify yxx 2015 -5-29
|
||
if ( !bUnit )
|
||
text.SetText(XString(_T("%d"), m_iNum));
|
||
else
|
||
text.SetText(XString(_T("%d 片"), m_iNum));
|
||
|
||
}
|
||
else if (m_iDrawMode == 2) // sg add
|
||
{
|
||
//text.SetText(XString(_T("%.1f"), m_dLoad)); // 标注负荷 modify yxx 2015 -5-29
|
||
if ( !bUnit )
|
||
text.SetText(XString(_T("%.1f"), m_dLoad));
|
||
else
|
||
text.SetText(XString(_T("%.1f W"), m_dLoad));
|
||
}
|
||
else if (m_iDrawMode == 3)
|
||
{
|
||
//text.SetText(XString(_T("%.1f"), m_dNum)); // 标注片数,m单位 modify yxx 2015 -5-29
|
||
if ( !bUnit )
|
||
text.SetText(XString(_T("%.1f"), m_dNum));
|
||
else
|
||
text.SetText(XString(_T("%.1f M"), m_dNum));
|
||
}
|
||
|
||
text.SetHeight(m_dTextHeight);
|
||
double dAngle = GetAngle(); // sg add
|
||
dAngle = CT_std_angle(dAngle);
|
||
if ((dAngle > -1.0E-5) && (dAngle < PI/2 + 1.0E-5)) // [0, PI/2]
|
||
{
|
||
dAngle = dAngle;
|
||
}
|
||
else if ((dAngle > PI/2 + 1.0E-5) && (dAngle < PI*1.5 + 1.0E-5)) // (PI/2, 1.5*PI]
|
||
{
|
||
dAngle = dAngle + PI;
|
||
}
|
||
else if ((dAngle > PI*1.5 + 1.0E-5) && (dAngle < 2*PI - 1.0E-5)) // (1.5*PI, 2*PI)
|
||
{
|
||
dAngle = dAngle - PI*2;
|
||
}
|
||
text.SetAlignment(XExplodeDraw::kMiddleCenter);
|
||
text.SetLocation(m_ptLabel);
|
||
text.SetRotation(dAngle);
|
||
dc.DrawEntity(text);
|
||
dc.SetLayer(idLayerOld);
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// 2D绘制
|
||
Acad::ErrorStatus TDbRadiator::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 = Acad::eOk;
|
||
es = DrawRadiator2d(dc); // 散热器
|
||
es = DrawValve2d(dc); // 排气阀
|
||
if (m_iDrawMode > 0) // 标注,支持模型图也标注
|
||
{
|
||
DrawLabelText(dc);
|
||
}
|
||
return es;
|
||
}
|
||
|
||
// 3D绘制
|
||
Acad::ErrorStatus TDbRadiator::ExplodeOrDraw3d(XExplodeDraw &dc) const
|
||
{
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
if (!IsSysType()) // 实体,平面图
|
||
{
|
||
if (fabs(m_dSizeX)>1.0E-3 || fabs(m_dSizeY)>1.0E-3)
|
||
{
|
||
TDbRect rect;
|
||
AsRect(rect);
|
||
es = rect.ExplodeOrDraw3d(dc);
|
||
}
|
||
}
|
||
else // 系统图
|
||
{
|
||
return ExplodeOrDraw2d(dc);
|
||
}
|
||
return es;
|
||
}
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 有关连接
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 判断节点是否可以连接管段,nPos:0——start;1——end
|
||
BOOL TDbRadiator::CanLinkSide(const AcDbObjectId &idPipe, int nPos) const
|
||
{
|
||
BOOL bRet = FALSE;
|
||
OPENOBJ_BEGIN(idPipe, AcDb::kForRead, TDbPipe, pPipe);
|
||
if (pPipe != NULL)
|
||
{
|
||
XPoint ptRef = nPos ? pPipe->EndPoint() : pPipe->StartPoint();
|
||
if (IsSysType()) // 系统图
|
||
{
|
||
XPoly2D poly;
|
||
GetOutline(poly);
|
||
XPoint pt(ptRef.x, ptRef.y);
|
||
if (poly.HitTestOnCurve(pt) != 0)
|
||
{
|
||
bRet = TRUE;
|
||
}
|
||
}
|
||
else // 平面图
|
||
{
|
||
TDbRect rect;
|
||
AsRect(rect);
|
||
rect.SetElevation(0.0);
|
||
XPoint pt(ptRef.x, ptRef.y);
|
||
XPoint ptHit;
|
||
if (rect.getClosestPointTo(pt, ptHit)==Acad::eOk &&
|
||
pt.Distance2d(ptHit)<PS_SNAP)
|
||
{
|
||
bRet = TRUE;
|
||
}
|
||
|
||
if (bRet == FALSE) // 下接口情况
|
||
{
|
||
TDbRect newRect;
|
||
AsRect(newRect);
|
||
XPoint ptLeft, ptRight, ptHit;
|
||
ads_polar(m_ptLocation, m_dRotation, -m_dSizeX/2, ptLeft);
|
||
ads_polar(m_ptLocation, m_dRotation, m_dSizeX/2, ptRight);
|
||
AcDbLine helpLine(ptLeft, ptRight);
|
||
if (helpLine.getClosestPointTo(ptRef, ptHit, false) == Acad::eOk
|
||
&& ptRef.Distance(ptHit)<PS_SNAP)
|
||
{
|
||
bRet = TRUE;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
return bRet;
|
||
}
|
||
|
||
BOOL TDbRadiator::CanInLinkSide(const AcDbObjectId &idPipe) const
|
||
{
|
||
BOOL bRet = FALSE;
|
||
OPENOBJ_BEGIN(idPipe, AcDb::kForRead, TDbPipe, pPipe);
|
||
if (pPipe != NULL)
|
||
{
|
||
if (CanInLinkSide(pPipe, 0))
|
||
{
|
||
bRet = TRUE;
|
||
}
|
||
else if (CanInLinkSide(pPipe, 1))
|
||
{
|
||
bRet = TRUE;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
return bRet;
|
||
}
|
||
|
||
BOOL TDbRadiator::CanOutLinkSide(const AcDbObjectId &idPipe) const
|
||
{
|
||
BOOL bRet = FALSE;
|
||
OPENOBJ_BEGIN(idPipe, AcDb::kForRead, TDbPipe, pPipe);
|
||
if (pPipe != NULL)
|
||
{
|
||
if (CanOutLinkSide(pPipe, 0))
|
||
{
|
||
bRet = TRUE;
|
||
}
|
||
else if (CanOutLinkSide(pPipe, 1))
|
||
{
|
||
bRet = TRUE;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
return bRet;
|
||
}
|
||
|
||
// nPos: 0--start; 1--end
|
||
BOOL TDbRadiator::CanInLinkSide(const TDbPipe* pPipe, int nPos) const
|
||
{
|
||
BOOL bRet = FALSE;
|
||
const XPoint &ptRef = nPos==1 ? pPipe->EndPoint() : pPipe->StartPoint();
|
||
double dDist = ptRef.Distance(GetInLocation());
|
||
if (dDist < PS_SNAP) // 进口
|
||
{
|
||
bRet = TRUE;
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
// nPos: 0--start; 1--end
|
||
BOOL TDbRadiator::CanOutLinkSide(const TDbPipe* pPipe, int nPos) const
|
||
{
|
||
BOOL bRet=FALSE;
|
||
const XPoint &ptRef = nPos==1 ? pPipe->EndPoint() : pPipe->StartPoint();
|
||
double dDist = ptRef.Distance(GetOutLocation());
|
||
if (dDist < PS_SNAP) // 出口
|
||
{
|
||
bRet=TRUE;
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
//对st类型的接口进行重新连接
|
||
void TDbRadiator::UpdateLinkage(const XPoint &ptAt, TPipeSys::SysType st,
|
||
const DList<AcDbObjectId> &idPipes)
|
||
{
|
||
assertWriteEnabled();
|
||
if (m_lstInterface.Length() != 2)
|
||
{
|
||
return;
|
||
}
|
||
|
||
TPipeInterface &inFace = *m_lstInterface.Head();
|
||
TPipeInterface &outFace = *m_lstInterface.Tail();
|
||
XPoint ptConnet;
|
||
if (!CanInLinkSide(inFace.m_idPipe))
|
||
{
|
||
inFace.m_idPipe = AcDbObjectId::kNull;
|
||
for (int i = 0; i < idPipes.Length(); i++)
|
||
{
|
||
const AcDbObjectId &id1 = idPipes[i];
|
||
if (id1 == outFace.m_idPipe)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
OPENOBJ_BEGIN(id1, AcDb::kForRead, TDbPipe, pPipe);
|
||
if (pPipe != NULL)
|
||
{
|
||
if (ptAt.Distance(pPipe->StartPoint()) < ptAt.Distance(pPipe->EndPoint()))
|
||
{
|
||
ptConnet = pPipe->StartPoint();
|
||
}
|
||
else
|
||
{
|
||
ptConnet = pPipe->EndPoint();
|
||
}
|
||
|
||
if (ptConnet.Distance(InLocation())<ptConnet.Distance(OutLocation())
|
||
|| HasOutPipe())
|
||
{
|
||
inFace.m_idPipe = id1;
|
||
inFace.m_ptLocation = ptConnet;
|
||
}
|
||
else
|
||
{
|
||
outFace.m_idPipe = id1;
|
||
outFace.m_ptLocation = ptConnet;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
|
||
if (!CanOutLinkSide(outFace.m_idPipe))
|
||
{
|
||
outFace.m_idPipe = AcDbObjectId::kNull;
|
||
for (int i = 0; i < idPipes.Length(); i++)
|
||
{
|
||
const AcDbObjectId &id1 = idPipes[i];
|
||
if (id1 == inFace.m_idPipe)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
OPENOBJ_BEGIN(id1, AcDb::kForRead, TDbPipe, pPipe);
|
||
if (pPipe != NULL)
|
||
{
|
||
if (ptAt.Distance(pPipe->StartPoint()) < ptAt.Distance(pPipe->EndPoint()))
|
||
{
|
||
ptConnet = pPipe->StartPoint();
|
||
}
|
||
else
|
||
{
|
||
ptConnet = pPipe->EndPoint();
|
||
}
|
||
|
||
if (ptConnet.Distance(InLocation())>ptConnet.Distance(OutLocation())
|
||
|| HasInPipe())
|
||
{
|
||
outFace.m_idPipe = id1;
|
||
outFace.m_ptLocation = ptConnet;
|
||
}
|
||
else
|
||
{
|
||
inFace.m_idPipe = id1;
|
||
inFace.m_ptLocation = ptConnet;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
}
|
||
|
||
void TDbRadiator::UpdateInterface()
|
||
{
|
||
assertWriteEnabled();
|
||
if (!IsSysType())
|
||
{
|
||
TDbRect rect;
|
||
AsRect(rect);
|
||
XPoint ptLowLeft = rect.GetLowLeft();
|
||
XPoint ptUpRight = rect.GetUpRight();
|
||
Midpoint(rect.GetLowLeft(), rect.GetUpLeft(), InLocation())
|
||
Midpoint(rect.GetLowRight(), rect.GetUpRight(), OutLocation())
|
||
}
|
||
else
|
||
{
|
||
XPoint pt1, pt2, pt3, pt4;
|
||
GetSysVertexs2d(pt1,pt2,pt3,pt4);
|
||
double dAngle = CT_std_angle(m_dSysAngle) + PI/2;
|
||
ads_polar(m_ptLocation, dAngle, 200, InLocation());
|
||
ads_polar(m_ptLocation, -dAngle, 200, OutLocation());
|
||
}
|
||
}
|
||
|
||
// nPos:0-start,1-end
|
||
// pt——与接口连接的点;vt——接口向量;pPipe——AcDb::kForWrite
|
||
void TDbRadiator::ChangePipe(TDbPipe *pPipe, const XPoint &pt) const
|
||
{
|
||
if (pPipe == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (pPipe->isWriteEnabled() && pPipe->Is(CURVE_LINE))
|
||
{
|
||
int nFlag = pt&(*pPipe);
|
||
BOOL bChangeOneSide = nFlag==PR_INSIDE || nFlag==PR_EXTEND || nFlag==PR_ONPT1
|
||
|| nFlag==PR_ONPT2;
|
||
if (bChangeOneSide)
|
||
{
|
||
pPipe->assertWriteEnabled();
|
||
double nAng = ads_angle(pPipe->GetStartPoint(), pPipe->GetEndPoint());
|
||
if (pPipe->GetNode(1) == objectId())
|
||
{
|
||
double nAng2 = ads_angle(pPipe->GetStartPoint(), pt);
|
||
if (fabs(nAng - nAng2) < 0.01)
|
||
{
|
||
pPipe->EndPoint() = pt;
|
||
}
|
||
}
|
||
else if (pPipe->GetNode(0) == objectId())
|
||
{
|
||
double nAng2 = ads_angle(pt, pPipe->EndPoint());
|
||
if (fabs(nAng - nAng2) < 0.01)
|
||
{
|
||
pPipe->StartPoint() = pt;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 将散热器的变化应用到连接的管线
|
||
void TDbRadiator::ApplyChangeToPipe() const
|
||
{
|
||
TPipeInterface &inFace = *m_lstInterface.Head();
|
||
TPipeInterface &outFace = *m_lstInterface.Tail();
|
||
OPENOBJ_BEGIN(GetInPipe(), AcDb::kForWrite, TDbPipe, pPipe);
|
||
if (pPipe != NULL)
|
||
{
|
||
ChangePipe(pPipe, GetInLocation());
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
OPENOBJ_BEGIN(GetOutPipe(), AcDb::kForWrite, TDbPipe, pPipe);
|
||
if (pPipe != NULL)
|
||
{
|
||
ChangePipe(pPipe, GetOutLocation());
|
||
}
|
||
OPENOBJ_END();
|
||
inFace.m_idPipe = AcDbObjectId::kNull;
|
||
outFace.m_idPipe = AcDbObjectId::kNull;
|
||
}
|
||
|
||
// 导出XML
|
||
CString TDbRadiator::GetXml(const AcGeMatrix3d& mat) const
|
||
{
|
||
if (1 == m_nType) // 系统图不导出
|
||
return CString();
|
||
|
||
int nPtPreci = 6; // 位置精度
|
||
int nWhPreci = 0; // 宽度、高度精度
|
||
|
||
TXmlTree xmlTree;
|
||
CString csText;
|
||
POSITION posRoot = xmlTree.Insert(_T("ATS_RADIATOR"), NULL, NULL);
|
||
{
|
||
xmlTree.SetAttribute(posRoot, _T("name"), _T("散热器"));
|
||
xmlTree.SetAttribute(posRoot, _T("comment"), _T("上华对象名称"));
|
||
}
|
||
|
||
POSITION posItemDrawType = xmlTree.Insert(_T("DrawType"), posRoot, NULL);
|
||
{
|
||
xmlTree.SetAttribute(posItemDrawType, _T("name"), _T("绘制类型"));
|
||
xmlTree.SetAttribute(posItemDrawType, _T("comment"), _T("0:模型图,1:系统图"));
|
||
csText.Format(_T("%d"), m_nType);
|
||
xmlTree.SetItemText(posItemDrawType, csText);
|
||
}
|
||
|
||
POSITION posItemLoc = xmlTree.Insert(_T("Location"), posRoot, posItemDrawType);
|
||
{
|
||
xmlTree.SetAttribute(posItemLoc, _T("name"), _T("位置"));
|
||
xmlTree.SetAttribute(posItemLoc, _T("comment"), _T("基准点为底面中心点"));
|
||
AcGePoint3d ptLoc = m_ptLocation;
|
||
ptLoc.transformBy(mat);
|
||
csText.Format(_T("%s,%s,%s"), DoubleToString(ptLoc.x, nPtPreci),
|
||
DoubleToString(ptLoc.y, nPtPreci), DoubleToString(ptLoc.z, nPtPreci));
|
||
xmlTree.SetItemText(posItemLoc, csText);
|
||
}
|
||
|
||
POSITION posItemRotation = xmlTree.Insert(_T("Rotation"), posRoot, posItemLoc);
|
||
{
|
||
xmlTree.SetAttribute(posItemRotation, _T("name"), _T("角度"));
|
||
xmlTree.SetAttribute(posItemRotation, _T("comment"), _T("布置时旋转的角度(角度制)"));
|
||
csText = DoubleToString(m_dRotation * 180.0 / PI, 2);
|
||
xmlTree.SetItemText(posItemRotation, csText);
|
||
}
|
||
|
||
POSITION posItemLength = xmlTree.Insert(_T("Length"), posRoot, posItemRotation);
|
||
{
|
||
xmlTree.SetAttribute(posItemLength, _T("name"), _T("长度"));
|
||
xmlTree.SetAttribute(posItemLength, _T("comment"), _T("散热器的长度"));
|
||
csText = DoubleToString(m_dSizeX, nWhPreci);
|
||
xmlTree.SetItemText(posItemLength, csText);
|
||
}
|
||
|
||
POSITION posItemWidth = xmlTree.Insert(_T("Width"), posRoot, posItemLength);
|
||
{
|
||
xmlTree.SetAttribute(posItemWidth, _T("name"), _T("宽度"));
|
||
xmlTree.SetAttribute(posItemWidth, _T("comment"), _T("散热器的宽度"));
|
||
csText = DoubleToString(m_dSizeY, nWhPreci);
|
||
xmlTree.SetItemText(posItemWidth, csText);
|
||
}
|
||
|
||
POSITION posItemHeight = xmlTree.Insert(_T("Height"), posRoot, posItemLength);
|
||
{
|
||
xmlTree.SetAttribute(posItemHeight, _T("name"), _T("高度"));
|
||
xmlTree.SetAttribute(posItemHeight, _T("comment"), _T("散热器的高度"));
|
||
csText = DoubleToString(m_dSizeZ, nWhPreci);
|
||
xmlTree.SetItemText(posItemHeight, csText);
|
||
}
|
||
|
||
POSITION posItemFactory = xmlTree.Insert(_T("Factory"), posRoot, posItemHeight);
|
||
{
|
||
xmlTree.SetAttribute(posItemFactory, _T("name"), _T("厂家"));
|
||
xmlTree.SetAttribute(posItemFactory, _T("comment"), _T("厂家"));
|
||
xmlTree.SetItemText(posItemFactory, m_sFactory);
|
||
}
|
||
|
||
POSITION posItemModel = xmlTree.Insert(_T("Model"), posRoot, posItemFactory);
|
||
{
|
||
xmlTree.SetAttribute(posItemModel, _T("name"), _T("型号"));
|
||
xmlTree.SetAttribute(posItemModel, _T("comment"), _T("型号"));
|
||
xmlTree.SetItemText(posItemModel, m_sType);
|
||
}
|
||
|
||
POSITION posObjId = xmlTree.Insert(_T("Object_ID"), posRoot, posItemModel);
|
||
{
|
||
xmlTree.SetAttribute(posObjId, _T("name"),_T("ID"));
|
||
xmlTree.SetAttribute(posObjId, _T("comment"),_T("散热器ID"));
|
||
|
||
csText.Format(_T("%ld"), 0x7FFFFFFF & objectId().asOldId());
|
||
xmlTree.SetItemText(posObjId, csText);
|
||
}
|
||
|
||
CString csXml = xmlTree.GetXml();
|
||
CString csBase = TEntityBase::GetXml(mat);
|
||
int nIndex = csXml.Find(_T("</TCH_"));
|
||
if (nIndex > -1)
|
||
csXml.Insert(nIndex, csBase);
|
||
|
||
return csXml;
|
||
}
|
||
|
||
bool TDbRadiator::GetSection(const AcDbFace &face, const AcGeVector3d &vtPlaneSecDir,
|
||
std::vector<TObjSectionRecord> §ionRecord, AcDbVoidPtrArray& arFillPtrs) const
|
||
{
|
||
TGGeSectionPlane section_pln(face, vtPlaneSecDir); // 构造一个辅助剖面
|
||
|
||
AcDbVoidPtrArray arFaces;
|
||
XExplodeStream dc(arFaces);
|
||
ExplodeOrDraw3d(dc);
|
||
|
||
double dElevation(0.0);
|
||
AcDbEntity* pEnt = NULL;
|
||
AcDbFace* pFace = NULL;
|
||
int i(0);
|
||
for (i = 0; i < arFaces.length(); ++i)
|
||
{
|
||
pEnt = (AcDbEntity*)arFaces[i];
|
||
if (NULL == pEnt)
|
||
continue;
|
||
|
||
pFace = AcDbFace::cast(pEnt);
|
||
if (pFace)
|
||
{
|
||
TGGeSectionPlane pln(*pFace, vtPlaneSecDir);
|
||
TGGePoly2D poly;
|
||
dElevation = SectionUtility::Projection_plane2plane(section_pln, pln, poly);
|
||
sectionRecord.push_back(TObjSectionRecord(objectId(), layerId(), TObjSectionRecord::eTCH_RADIATOR, dElevation, poly));
|
||
}
|
||
|
||
delete pEnt;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbRadiator::GetExtents(TADSGePoint3d &ptLow, TADSGePoint3d &ptUp) const
|
||
{
|
||
// mcl add 2011.4.7. 解决自由复制、自由移动时 消失(跑远)问题
|
||
XPoly2D poly;
|
||
GetOutline(poly);
|
||
|
||
if (RTNORM == poly.GetExtend(ptLow, ptUp))
|
||
return Acad::eOk;
|
||
|
||
return Acad::eNotImplementedYet;
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 有关标注
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 设置标注方式
|
||
void TDbRadiator::SetDrawMode(int iMode)
|
||
{
|
||
assertWriteEnabled();
|
||
m_iDrawMode = iMode;
|
||
if (m_iDrawMode > 0 && !m_ptLabel)
|
||
{
|
||
XPoint pt1, pt2, pt3, pt4;
|
||
GetSysVertexs2d(pt1, pt2, pt3, pt4);
|
||
Midpoint(pt1, pt3, m_ptLabel);
|
||
|
||
if (!IsSysType()) // 默认标在散热器上面
|
||
{
|
||
m_ptLabel.y += m_dSizeY/2 + m_dTextHeight*DocGetPScale();
|
||
}
|
||
}
|
||
}
|
||
|
||
BOOL TDbRadiator::GetUnit() const
|
||
{
|
||
assertReadEnabled();
|
||
BOOL bUnit;
|
||
const TEntityFields &fd = GetFields();
|
||
if( !fd.GFD(SHOW_UNIT, bUnit) )
|
||
{
|
||
bUnit = FALSE;
|
||
}
|
||
return bUnit;
|
||
}
|
||
|
||
void TDbRadiator::SetUnit(BOOL bUnit)
|
||
{
|
||
assertWriteEnabled();
|
||
TEntityFields &fd = Fields();
|
||
fd.SFD(SHOW_UNIT, bUnit);
|
||
}
|
||
|
||
// 在位编辑
|
||
double StringAnalysis(const CString &src, const Adesk::UInt8 &nType);
|
||
void TDbRadiator::SetSubText(long i, CString sText) // sg add
|
||
{
|
||
assertWriteEnabled();
|
||
double dRet = ::StringAnalysis(sText, m_iDrawMode);
|
||
if (dRet < 0)
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (m_iDrawMode == 3) // 散热器片数(M)
|
||
{
|
||
SetMNum(dRet);
|
||
}
|
||
else if (m_iDrawMode == 2) // 负荷
|
||
{
|
||
SetLoad(dRet);
|
||
}
|
||
else if (m_iDrawMode == 1) // 散热器片数(片)
|
||
{
|
||
SetNum((int)dRet);
|
||
}
|
||
}
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
void InitDbRadiator(BOOL bTrue)
|
||
{
|
||
if (bTrue)
|
||
{
|
||
TDbRadiator::rxInit();
|
||
TDbRadiator::InitMatchProtocol(TRUE);
|
||
}
|
||
else
|
||
{
|
||
TDbRadiator::InitMatchProtocol(FALSE);
|
||
deleteAcRxClass(TDbRadiator::desc());
|
||
}
|
||
}
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
// 用于分析系统散热器的标注。sg add
|
||
// Adesk::UInt8 nType; // 1:标注片数(片);2:标注负荷;3:标注片数(m)
|
||
double StringAnalysis(const CString &src, const Adesk::UInt8 &nType)
|
||
{
|
||
double dRet = -1.0;
|
||
BOOL bFlag(TRUE);
|
||
int nLen = src.GetLength();
|
||
for (int i = 0; i < nLen; i++)
|
||
{
|
||
if (_istdigit(src[i]))
|
||
{
|
||
continue;
|
||
}
|
||
else if (src[i] == _T('.'))
|
||
{
|
||
if ((nType == 2) || (nType == 3))
|
||
{
|
||
continue;
|
||
}
|
||
else if (nType == 1)
|
||
{
|
||
dRet = _tstof(src.Left(i));
|
||
dRet++;
|
||
bFlag = FALSE;
|
||
break;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
bFlag = FALSE;
|
||
ads_alert(_T("请输入数字!"));
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (bFlag)
|
||
{
|
||
dRet = _tstof(src);
|
||
}
|
||
return dRet;
|
||
}
|