505 lines
14 KiB
C++
505 lines
14 KiB
C++
#ifndef __DBRADIATOR_H
|
||
#define __DBRADIATOR_H
|
||
|
||
#include "DbPipe.h"
|
||
#include "DbPipeLabel.h"
|
||
|
||
// 散热器侧面进出口:接口方向
|
||
#define RAD_LEFT 0 // 左边
|
||
#define RAD_RIGHT 1 // 右边
|
||
|
||
class TDbRect;
|
||
|
||
/*============================================================================*
|
||
* Copyright(c), 1994-2007, Beijing Tangent Engineering Software Co.Ltd.
|
||
* 文 件 名: DbRadiator.h
|
||
* 版 本: 2.0
|
||
* 作 者:
|
||
* 创建时间:
|
||
* 描 述: TDbRadiator:散热器自定义实体
|
||
* 归属项目: 暖通
|
||
* 历史记录: 1、2007-12-10 sg modify,增加了散热器库数据
|
||
* 2、2010-12-28 hh modify,增加导出数据到XML的功能
|
||
=============================================================================*/
|
||
class PS_EXP TDbRadiator: public TDbPipeNode, public TLabelStyle
|
||
{
|
||
DECLARE_TENTBASE();
|
||
ACRX_DECLARE_MEMBERS(TDbRadiator);
|
||
|
||
private:
|
||
static const Adesk::UInt8 g_nVersion;
|
||
|
||
public:
|
||
enum IFaceType { // 接口类别
|
||
kSide = 0, // 0、侧面进出口
|
||
kUnder = 1, // 1、底面进出口
|
||
};
|
||
|
||
public:
|
||
TDbRadiator();
|
||
|
||
protected:
|
||
// ————绘制参数————
|
||
IFaceType m_typeIFace; // 接口类别
|
||
Adesk::UInt8 m_nType; // 0-模型图; 1-系统图
|
||
XPoint m_ptLocation; // z标高为底面高度
|
||
double m_dRotation; // 散热器的旋转角度
|
||
double m_dSysAngle; // 系统图的角度,为0是二维显示为矩形
|
||
double m_dSizeX, m_dSizeY, m_dSizeZ; // 散热器的尺寸:长,宽,高
|
||
double m_dWeight; // 散热器的显示宽度(线宽)
|
||
|
||
BOOL m_bHasValve; // 有无排气阀
|
||
BOOL m_bIsReverse; // 排气阀的绘制角度是否与散热器系统图角度相反,TRUE为相反,sg add
|
||
|
||
// ————标注参数————
|
||
// 标注模式:0:不标注,1:标注片数(片单位),2:标注负荷;3:标注片数(m单位)
|
||
Adesk::UInt8 m_iDrawMode;
|
||
AcDbHardPointerId m_idLabelLayer; // 标注文字图层
|
||
XPoint m_ptLabel; // 标注点
|
||
double m_dLoad; // 负荷
|
||
Adesk::UInt8 m_iNum; // 散热片数(片单位)
|
||
double m_dNum; // 散热片数(m单位),sg add
|
||
|
||
// ————库参数————,sg add
|
||
XString m_sFactory; // 厂家名称
|
||
XString m_sType; // 类型
|
||
Adesk::UInt8 m_nFormula; // 公式
|
||
double m_dA; // 实验参数A
|
||
double m_dB; // 实验参数B
|
||
double m_dUnitArea; // 单位散热面积
|
||
double m_dUnitQ; // 单位散热器
|
||
|
||
public: // 有关绘制部分的Set、Get函数
|
||
|
||
//add by yxx 2015年5月29
|
||
BOOL GetUnit() const;
|
||
void SetUnit(BOOL bUnit);
|
||
//end
|
||
|
||
void SetLocation(const XPoint &pt) { // 实体位置点
|
||
assertWriteEnabled();
|
||
m_ptLocation = pt;
|
||
UpdateInterface();
|
||
}
|
||
|
||
BOOL IsSysType() const { // 是否是散热器的系统图
|
||
return m_nType == 1;
|
||
}
|
||
void SetType(int n) {
|
||
assertWriteEnabled();
|
||
m_nType = (Adesk::UInt8)n;
|
||
}
|
||
int GetType() const {
|
||
return (int)m_nType;
|
||
}
|
||
|
||
void SetSysAngle(double dAngle) { // 系统图的角度
|
||
assertWriteEnabled();
|
||
m_dSysAngle = dAngle;
|
||
}
|
||
double GetSysAngle() const {
|
||
return m_dSysAngle;
|
||
}
|
||
|
||
void SetRotation(double nRot) { // 散热器的旋转角度
|
||
assertWriteEnabled();
|
||
m_dRotation = nRot;
|
||
UpdateInterface();
|
||
}
|
||
double GetRotation() const {
|
||
return m_dRotation;
|
||
}
|
||
|
||
void SetWeight(double dWeight) { // 散热器的显示宽度
|
||
assertWriteEnabled();
|
||
m_dWeight = dWeight;
|
||
}
|
||
double GetWeight() const {
|
||
return m_dWeight;
|
||
}
|
||
|
||
void SetValve(BOOL bHas) { // 排气阀
|
||
assertWriteEnabled();
|
||
m_bHasValve = bHas;
|
||
}
|
||
BOOL HasValve() const {
|
||
return m_bHasValve;
|
||
}
|
||
|
||
// 排气阀的绘制角度是否与散热器系统图角度相反,sg add
|
||
void SetValveAngle(const BOOL bIsReverse) {
|
||
assertWriteEnabled();
|
||
m_bIsReverse = bIsReverse;
|
||
}
|
||
BOOL GetValveAngle() const {
|
||
return m_bIsReverse;
|
||
}
|
||
|
||
void SetIFaceType(IFaceType type) { // 接口类型
|
||
assertWriteEnabled();
|
||
m_typeIFace = type;
|
||
}
|
||
IFaceType GetIFaceType() const {
|
||
return m_typeIFace;
|
||
}
|
||
|
||
// mcl add. 2010.05.11.根据接口高度判断
|
||
IFaceType GetIFaceTypeByJudge() const
|
||
{
|
||
double dHeigh = GetSize(2);
|
||
AcGePoint3d ptLoc = GetLocation();
|
||
AcGePoint3d ptIf = GetInLocation();
|
||
|
||
if (IsSysType())
|
||
{
|
||
double dBelow = ptLoc.y - dHeigh*0.5;
|
||
double dUp = dBelow + dHeigh;
|
||
if (ptIf.y - dBelow < 1e-1 || ptIf.y - dUp > -1e-1)
|
||
return kUnder;
|
||
}
|
||
else
|
||
{
|
||
double dBelow = ptLoc.z;
|
||
double dUp = dBelow + dHeigh;
|
||
if (ptIf.z - dBelow < 1e-1 || ptIf.z - dUp > -1e-1)
|
||
return kUnder;
|
||
}
|
||
|
||
return kSide;
|
||
}
|
||
|
||
void SetSize(int i, double val) { // 散热器的尺寸:长,宽,高
|
||
assertWriteEnabled();
|
||
if (i == 0)
|
||
{
|
||
m_dSizeX = val;
|
||
}
|
||
else if (i == 1)
|
||
{
|
||
m_dSizeY = val;
|
||
}
|
||
else if (i == 2)
|
||
{
|
||
m_dSizeZ = val;
|
||
}
|
||
UpdateInterface();
|
||
}
|
||
double GetSize(int i) const {
|
||
double val(0.0);
|
||
if (i == 0)
|
||
{
|
||
val = m_dSizeX;
|
||
}
|
||
else if (i == 1)
|
||
{
|
||
val = m_dSizeY;
|
||
}
|
||
else if (i == 2)
|
||
{
|
||
val = m_dSizeZ;
|
||
}
|
||
return val;
|
||
}
|
||
|
||
public: // 有关标注部分的Set、Get函数
|
||
void SetLabelLayer(const AcDbObjectId& id) { // 标注层
|
||
assertWriteEnabled();
|
||
m_idLabelLayer = id;
|
||
}
|
||
AcDbObjectId GetLabelLayer() const {
|
||
return m_idLabelLayer;
|
||
}
|
||
|
||
int GetDrawMode() const { // 标注方式
|
||
return m_iDrawMode;
|
||
}
|
||
void SetDrawMode(int iMode);
|
||
|
||
XPoint GetTextLocation() const { // 标注位置
|
||
return m_ptLabel;
|
||
}
|
||
void SetTextLocation(const XPoint& pt) {
|
||
assertWriteEnabled();
|
||
m_ptLabel = pt;
|
||
}
|
||
|
||
void SetNum(int iNum) { // 散热器片数(片单位)——标注方式1
|
||
assertWriteEnabled();
|
||
m_iNum = iNum;
|
||
}
|
||
int GetNum() const {
|
||
return m_iNum;
|
||
}
|
||
|
||
void SetLoad(double dLoad) { // 负荷——标注方式2
|
||
assertWriteEnabled();
|
||
m_dLoad = dLoad;
|
||
}
|
||
double GetLoad() const {
|
||
return m_dLoad;
|
||
}
|
||
|
||
void SetMNum(double dNum) { // 散热器片数(m单位)——标注方式3
|
||
assertWriteEnabled();
|
||
m_dNum = dNum;
|
||
}
|
||
double GetMNum() const {
|
||
return m_dNum;
|
||
}
|
||
|
||
public: // 有关绘制部分的Set、Get函数
|
||
void SetFactory(XString csName) { // 厂家名称
|
||
assertWriteEnabled();
|
||
m_sFactory = csName;
|
||
}
|
||
XString GetFactory() const {
|
||
return m_sFactory;
|
||
}
|
||
|
||
void SetRadiatorType(XString csType) { // 类型
|
||
assertWriteEnabled();
|
||
m_sType = csType;
|
||
}
|
||
XString GetRadiatorType() const {
|
||
return m_sType;
|
||
}
|
||
|
||
void SetFormula(int nType) { // 公式
|
||
assertWriteEnabled();
|
||
m_nFormula = nType;
|
||
}
|
||
int GetFormula() const {
|
||
return m_nFormula;
|
||
}
|
||
|
||
void SetAAndB(double dA, double dB) { // 实验参数A、B
|
||
assertWriteEnabled();
|
||
m_dA = dA;
|
||
m_dB = dB;
|
||
}
|
||
void GetAAndB(double &dA, double &dB) {
|
||
dA = m_dA;
|
||
dB = m_dB;
|
||
}
|
||
|
||
void SetUnitArea(double dArea) { // 单位散热面积
|
||
assertWriteEnabled();
|
||
m_dUnitArea = dArea;
|
||
}
|
||
double GetUnitArea() const {
|
||
return m_dUnitArea;
|
||
}
|
||
|
||
void SetUnitQ(double dQ) { // 单位散热器
|
||
assertWriteEnabled();
|
||
m_dUnitQ = dQ;
|
||
}
|
||
double GetUnitQ() const {
|
||
return m_dUnitQ;
|
||
}
|
||
|
||
|
||
public:
|
||
void AsRect(TDbRect &rect) const;
|
||
void ApplyChangeToPipe() const; // 将散热器的变化应用到连接的管线
|
||
|
||
XVector3D GetDirection() const { // 散热器的方向(平面)
|
||
double dAngle = GetAngle();
|
||
return XVector3D(cos(dAngle), sin(dAngle));
|
||
}
|
||
double GetAngle() const { // 散热器的角度
|
||
return IsSysType() ? m_dSysAngle : m_dRotation;
|
||
}
|
||
|
||
public: // 有关进出口接口的Set、Get函数
|
||
const TPipeInterface & GetInInterface() const { // 进口接口
|
||
return *m_lstInterface.Head();
|
||
}
|
||
const TPipeInterface & GetOutInterface() const { // 出口接口
|
||
return *m_lstInterface.Tail();
|
||
}
|
||
|
||
void SetInPipe(const AcDbObjectId & id) { // 进口管线
|
||
assertWriteEnabled();
|
||
InInterface().m_idPipe = id;
|
||
}
|
||
const AcDbObjectId & GetInPipe() const {
|
||
return GetInInterface().m_idPipe;
|
||
}
|
||
|
||
void SetOutPipe(const AcDbObjectId & id) { // 出口管线
|
||
assertWriteEnabled();
|
||
OutInterface().m_idPipe = id;
|
||
}
|
||
const AcDbObjectId & GetOutPipe() const {
|
||
return GetOutInterface().m_idPipe;
|
||
}
|
||
|
||
// 进出口管线是否连接
|
||
BOOL HasInPipe() const {
|
||
return GetInPipe().isValid();
|
||
}
|
||
BOOL HasOutPipe() const {
|
||
return GetOutPipe().isValid();
|
||
}
|
||
|
||
// 进出口接口位置
|
||
const XPoint & GetInLocation() const {
|
||
return GetInInterface().m_ptLocation;
|
||
}
|
||
const XPoint & GetOutLocation() const {
|
||
return GetOutInterface().m_ptLocation;
|
||
}
|
||
|
||
// 进出口接口法向
|
||
const XVector3D & GetInDirection() const {
|
||
return GetInInterface().m_vtLocation;
|
||
}
|
||
const XVector3D & GetOutDirection() const {
|
||
return GetOutInterface().m_vtLocation;
|
||
}
|
||
|
||
// 进出口系统类型 (默认in:kHeatSupply, out:kHeatReturn)
|
||
void SetInSysType(TPipeSys::SysType type) {
|
||
assertWriteEnabled();
|
||
InInterface().m_sysType = type;
|
||
}
|
||
TPipeSys::SysType GetInSysType() const {
|
||
return GetInInterface().m_sysType;
|
||
}
|
||
|
||
void SetOutSysType(TPipeSys::SysType type) {
|
||
assertWriteEnabled();
|
||
OutInterface().m_sysType = type;
|
||
}
|
||
TPipeSys::SysType GetOutSysType() const {
|
||
return GetOutInterface().m_sysType;
|
||
}
|
||
|
||
// 进出口接口标识
|
||
void SetInCookie(int cookie) {
|
||
assertWriteEnabled();
|
||
InInterface().m_cookie = (Adesk::UInt8)cookie;
|
||
}
|
||
int GetInCookie() const {
|
||
return (int)GetInInterface().m_cookie;
|
||
}
|
||
|
||
void SetOutCookie(int cookie) {
|
||
assertWriteEnabled();
|
||
OutInterface().m_cookie = (Adesk::UInt8)cookie;
|
||
}
|
||
int GetOutCookie() const {
|
||
return (int)GetOutInterface().m_cookie;
|
||
}
|
||
|
||
// 进出口系统编号
|
||
void SetInSysLabel(const TCHAR* sLabel) {
|
||
assertWriteEnabled();
|
||
InInterface().m_sSysLabel = sLabel;
|
||
}
|
||
XString GetInSysLabel() const {
|
||
return GetInInterface().m_sSysLabel;
|
||
}
|
||
|
||
void SetOutSysLabel(const TCHAR* sLabel) {
|
||
assertWriteEnabled();
|
||
OutInterface().m_sSysLabel = sLabel;
|
||
}
|
||
XString GetOutSysLabel() const {
|
||
return GetOutInterface().m_sSysLabel;
|
||
}
|
||
|
||
|
||
public:
|
||
// 取得底面的四个顶点
|
||
void GetSysVertexs(XPoint &ptLeftLow, XPoint &ptRightLow,
|
||
XPoint &ptRightUp, XPoint &ptLeftUp) const; // z=0
|
||
// if b2d==TRUE then z=0 or z=m_ptLocation.z
|
||
void GetRectVertexs(XPoint &ptLeftLow, XPoint &ptRightLow,
|
||
XPoint &ptRightUp, XPoint &ptLeftUp, BOOL b2d = FALSE) const;
|
||
|
||
BOOL CanInLinkSide(const AcDbObjectId &idPipe) const;
|
||
BOOL CanOutLinkSide(const AcDbObjectId &idPipe) const;
|
||
BOOL CanInLinkSide(const TDbPipe* pPipe, int nPos) const;
|
||
BOOL CanOutLinkSide(const TDbPipe* pPipe, int nPos) const;
|
||
|
||
|
||
public: // Override TDbPipeNode
|
||
virtual XPoint GetLocation() const { return m_ptLocation; }
|
||
// 对st类型的接口进行重新连接
|
||
virtual void UpdateLinkage(const XPoint &ptAt, TPipeSys::SysType st,
|
||
const DList<AcDbObjectId> &idPipes);
|
||
virtual BOOL CanLinkSide(const AcDbObjectId &idPipe, int nPos) const;
|
||
|
||
// add by hh 2010-12-28 导出XML
|
||
virtual CString GetXml(const AcGeMatrix3d& mat) const;
|
||
|
||
// add by 2011.02.10 剖切功能 注意 GetSection内不应将std::vector<TObjSectionRecord>参数清空
|
||
virtual bool GetSection(const AcDbFace &face, const AcGeVector3d &vtPlaneSecDir,
|
||
std::vector<TObjSectionRecord> §ionRecord, AcDbVoidPtrArray& arFillPtrs) const;
|
||
|
||
// 剖切用,返回Z坐标最高、最低点
|
||
virtual Acad::ErrorStatus GetExtents(TADSGePoint3d &ptLow, TADSGePoint3d &ptUp) const;
|
||
|
||
public: // Override TDbEntity
|
||
virtual void CopyPropertiesFrom(AcDbEntity *pSrc, unsigned gMatchFlag);
|
||
virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const;
|
||
virtual Acad::ErrorStatus GetGripText(int idx, CString &cs) const;
|
||
virtual Acad::ErrorStatus ExplodeOrDraw2d(XExplodeDraw &dc) const;
|
||
virtual Acad::ErrorStatus ExplodeOrDraw3d(XExplodeDraw &dc) const;
|
||
virtual void GetTips(DList<TObjInfoUnit> &) const; //取动态属性显示数据
|
||
|
||
virtual void SetSubText(long i, CString sText); // sg add
|
||
virtual long GetSubTextNum() const { return 1; } // ok
|
||
virtual bool IsModelEntity() const{return true;} // sg add
|
||
virtual int GetFirstVersion() const { return 7; } // sg add
|
||
|
||
|
||
public: // Override AcDbEntity
|
||
Acad::ErrorStatus subGetOsnapPoints(AcDb::OsnapMode osnapMode,
|
||
INT_PTR gsSelectionMark,
|
||
const AcGePoint3d& ptPick,
|
||
const AcGePoint3d& lastPoint,
|
||
const AcGeMatrix3d& viewXform,
|
||
AcGePoint3dArray& snapPoints,
|
||
AcDbIntArray& geomIds) const;
|
||
virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler*);
|
||
virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler*) const;
|
||
virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler*);
|
||
virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler*) const;
|
||
virtual Acad::ErrorStatus subGetGripPoints(AcGePoint3dArray& gripPoints,
|
||
AcDbIntArray& osnapModes,
|
||
AcDbIntArray& geomIds) const;
|
||
virtual Acad::ErrorStatus subGetStretchPoints(AcGePoint3dArray & stretchPoints) const;
|
||
virtual Acad::ErrorStatus subMoveGripPointsAt(const AcDbIntArray& indices,
|
||
const AcGeVector3d& offset);
|
||
virtual Acad::ErrorStatus subMoveStretchPointsAt(const AcDbIntArray& indices,
|
||
const AcGeVector3d& offset);
|
||
virtual Acad::ErrorStatus subTransformBy(const AcGeMatrix3d& xform);
|
||
|
||
|
||
protected:
|
||
Acad::ErrorStatus GetGSPoints(AcGePoint3dArray & stretchPoints) const;
|
||
Acad::ErrorStatus MoveGSPointsAt(const AcDbIntArray& indices,const AcGeVector3d& offset);
|
||
Acad::ErrorStatus DrawRadiator2d(XExplodeDraw &dc) const;
|
||
Acad::ErrorStatus DrawValve2d(XExplodeDraw &dc) const;
|
||
Acad::ErrorStatus DrawLabelText(XExplodeDraw &dc) const;
|
||
|
||
XPoint & InLocation() { return InInterface().m_ptLocation; }
|
||
XPoint & OutLocation() { return OutInterface().m_ptLocation; }
|
||
XVector3D & InDirection() { return InInterface().m_vtLocation; }
|
||
XVector3D & OutDirection() { return OutInterface().m_vtLocation; }
|
||
TPipeInterface & InInterface() { return *m_lstInterface.Head(); }
|
||
TPipeInterface & OutInterface() { return *m_lstInterface.Tail(); }
|
||
|
||
|
||
private:
|
||
void ChangePipe(TDbPipe *pPipe, const XPoint &pt) const;
|
||
void GetVertexs2d(XPoint &pt1, XPoint &pt2,XPoint &pt3,XPoint &pt4) const; // z=0
|
||
void GetSysVertexs2d(XPoint &pt1,XPoint &pt2,XPoint &pt3,XPoint &pt4) const; // z=0
|
||
void UpdateInterface();
|
||
void GetOutline(XPoly2D &poly) const;
|
||
};
|
||
|
||
#endif |