444 lines
11 KiB
C++
444 lines
11 KiB
C++
// DbIDDot.cpp: implementation of the TDbIDProcessLine class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "stdafx.h"
|
|
#include "DbIDProcessLine.h"
|
|
|
|
#define LINEWIDTH 20.0
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS(ATSIDProcessLine, ATSEntity,AcDb::kDHL_CURRENT,
|
|
AcDb::kMReleaseCurrent, 1, ATS_IDPROCESSLINE,
|
|
"ATS_IDPROCESSLINE图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
IMPLEMENT_TENTBASE(TDbIDProcessLine);
|
|
|
|
const Adesk::UInt8 TDbIDProcessLine::g_nVersion = 1;
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
TDbIDProcessLine::TDbIDProcessLine()
|
|
{
|
|
m_bDirection = TRUE;
|
|
}
|
|
|
|
void TDbIDProcessLine::SetDbIDEntity(AcDbHandle IDHandle)
|
|
{
|
|
m_IDHandle = IDHandle;
|
|
recordGraphicsModified();
|
|
}
|
|
|
|
TDbIDEntity* TDbIDProcessLine::GetIDEntity()const
|
|
{
|
|
TDbIDEntity* pIDEnt = NULL;
|
|
AcDbObjectId Id;
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
es = acdbCurDwg()->getAcDbObjectId(Id,false,m_IDHandle);
|
|
if(es != Acad::eOk)
|
|
return NULL;
|
|
AcDbEntity *pEnt = NULL;
|
|
acdbOpenAcDbEntity(pEnt,Id,AcDb::kForRead);
|
|
if(pEnt!= NULL)
|
|
{
|
|
pIDEnt = (TDbIDEntity*)pEnt;
|
|
pIDEnt->close();
|
|
}
|
|
return pIDEnt;
|
|
}
|
|
|
|
TDbIDDot* TDbIDProcessLine::GetDotEntity1()const
|
|
{
|
|
TDbIDDot *pIDDot = NULL;
|
|
AcDbObjectId Id;
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
es = acdbCurDwg()->getAcDbObjectId(Id,false,m_DotHandle1);
|
|
if(es != Acad::eOk)
|
|
return NULL;
|
|
AcDbEntity *pEnt = NULL;
|
|
acdbOpenAcDbEntity(pEnt,Id,AcDb::kForRead);
|
|
if(pEnt!= NULL)
|
|
{
|
|
pIDDot = (TDbIDDot*)pEnt;
|
|
pIDDot->Close();
|
|
}
|
|
return pIDDot;
|
|
}
|
|
|
|
TDbIDDot* TDbIDProcessLine::GetDotEntity2()const
|
|
{
|
|
TDbIDDot *pIDDot = NULL;
|
|
AcDbObjectId Id;
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
acdbCurDwg()->getAcDbObjectId(Id,false,m_DotHandle2);
|
|
if(es != Acad::eOk)
|
|
return NULL;
|
|
AcDbEntity *pEnt = NULL;
|
|
acdbOpenAcDbEntity(pEnt,Id,AcDb::kForRead);
|
|
if(pEnt!= NULL)
|
|
{
|
|
pIDDot = (TDbIDDot*)pEnt;
|
|
pIDDot->Close();
|
|
}
|
|
return pIDDot;
|
|
}
|
|
|
|
void TDbIDProcessLine::CopyPropertiesFrom(AcDbEntity *pSrc,unsigned gMatchFlag)
|
|
{
|
|
assertWriteEnabled();
|
|
TDbEntity::CopyPropertiesFrom(pSrc, gMatchFlag);
|
|
TDbIDProcessLine *pLine = TDbIDProcessLine::cast(pSrc);
|
|
if(pLine != NULL)
|
|
{
|
|
m_IDHandle = pLine->m_IDHandle;
|
|
m_ptDot1 = pLine->m_ptDot1;
|
|
m_ptDot2 = pLine->m_ptDot2;
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus TDbIDProcessLine::subGetClassID(CLSID* pClsid) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void TDbIDProcessLine::GetTips(DList<TObjInfoUnit> &info) const
|
|
{
|
|
TDbEntity::GetTips(info);
|
|
CString sz;
|
|
info.Append(new TObjInfoUnit(_T("对象类型"), _T("过程线")));
|
|
TDbIDDot *pDot1 = GetDotEntity1();
|
|
TDbIDDot *pDot2 = GetDotEntity2();
|
|
if(pDot1 == NULL)
|
|
return;
|
|
if(pDot2 == NULL)
|
|
return;
|
|
if(m_bDirection)
|
|
{
|
|
info.Append(new TObjInfoUnit(_T("起始点"), pDot1->GetDotName()));
|
|
info.Append(new TObjInfoUnit(_T("终止点"), pDot2->GetDotName()));
|
|
}
|
|
else
|
|
{
|
|
info.Append(new TObjInfoUnit(_T("起始点"), pDot1->GetDotName()));
|
|
info.Append(new TObjInfoUnit(_T("终止点"), pDot2->GetDotName()));
|
|
}
|
|
|
|
}
|
|
|
|
Acad::ErrorStatus TDbIDProcessLine::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;
|
|
XAcGiViewDraw &viewDraw = (XAcGiViewDraw &)dc;
|
|
|
|
AcDbPolyline Line;
|
|
XPoint pt1,pt2;
|
|
if (m_bDirection)
|
|
{
|
|
pt1 = m_ptDot1;
|
|
pt2 = m_ptDot2;
|
|
}
|
|
else
|
|
{
|
|
pt2 = m_ptDot1;
|
|
pt1 = m_ptDot2;
|
|
}
|
|
//箭头起始,终止点计算
|
|
XPoint ptStart,ptEnd;
|
|
ads_polar(pt1,ads_angle(pt1,pt2),pt1.Distance2d(pt2) * 0.6,ptStart);
|
|
// ptStart.x = (pt1.x + pt2.x) * 0.5;
|
|
// ptStart.y = (pt1.y + pt2.y) * 0.5;
|
|
ads_polar(ptStart,ads_angle(pt1,pt2),LINEWIDTH * 3.0,ptEnd);
|
|
Line.addVertexAt(0,pt1);
|
|
Line.addVertexAt(1,ptStart);
|
|
Line.addVertexAt(2,ptEnd);
|
|
Line.addVertexAt(3,pt2);
|
|
//画箭头
|
|
Line.setWidthsAt(0,LINEWIDTH,LINEWIDTH);
|
|
Line.setWidthsAt(1,LINEWIDTH * 3.0,LINEWIDTH);
|
|
Line.setWidthsAt(2,LINEWIDTH,LINEWIDTH);
|
|
//颜色
|
|
int nIndex = -1;
|
|
AcDbObjectId Id;
|
|
acdbCurDwg()->getAcDbObjectId(Id,false,m_IDHandle);
|
|
CAirState As1,As2;
|
|
OPENOBJ_BEGIN(Id,AcDb::kForRead,TDbIDEntity,pIDEnt);
|
|
if(pIDEnt != NULL)
|
|
{
|
|
As1 = pIDEnt->GetDot(m_ptDot1);
|
|
As2 = pIDEnt->GetDot(m_ptDot2);
|
|
//等温
|
|
if(fabs(As1.GetD() - As2.GetD()) < 0.1)
|
|
{
|
|
nIndex = pIDEnt->GetDColor();
|
|
}
|
|
//等焓
|
|
if(fabs(As1.GetE() - As2.GetE()) < 0.1)
|
|
{
|
|
nIndex = pIDEnt->GetEColor();
|
|
}
|
|
//等相对湿度
|
|
if(fabs(As1.GetRH() - As2.GetRH()) < 0.00001)
|
|
{
|
|
nIndex = pIDEnt->GetRHColor();
|
|
}
|
|
//等含湿量
|
|
if(fabs(As1.GetHR() - As2.GetHR()) < 0.1)
|
|
{
|
|
nIndex = pIDEnt->GetHRColor();
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
if(nIndex != -1)
|
|
Line.setColorIndex(nIndex);
|
|
dc.Polyline(Line);
|
|
return es;
|
|
}
|
|
|
|
void TDbIDProcessLine::subList() const
|
|
{
|
|
assertReadEnabled();
|
|
AcDbEntity::subList();
|
|
|
|
}
|
|
|
|
Acad::ErrorStatus TDbIDProcessLine::subTransformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
assertWriteEnabled();
|
|
m_ptDot1.transformBy(xform);
|
|
m_ptDot2.transformBy(xform);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
Acad::ErrorStatus TDbIDProcessLine::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
|
AcDbIntArray& osnapModes,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
assertReadEnabled();
|
|
gripPoints.append(m_ptDot1);
|
|
gripPoints.append(m_ptDot2);
|
|
return Acad::eOk;
|
|
}
|
|
// 取得夹点说明
|
|
Acad::ErrorStatus TDbIDProcessLine::GetGripText(int idx, CString &cs) const
|
|
{
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
switch(idx)
|
|
{
|
|
case 0:
|
|
{
|
|
CString str;
|
|
CString sz;
|
|
CAirState As;
|
|
TDbIDEntity *pEnt = GetIDEntity();
|
|
if(pEnt == NULL)
|
|
return es;
|
|
As = pEnt->GetDot(m_ptDot1);
|
|
sz.Format(_T("干球:%0.1f℃"),As.GetD());
|
|
str += sz;
|
|
sz.Format(_T(" | 湿球:%0.1f℃"),As.GetW());
|
|
str += sz;
|
|
sz.Format(_T(" | 相对湿度:%0.1f%%"),As.GetRH() * 100);
|
|
str += sz;
|
|
sz.Format(_T(" | 含湿量:%0.1fg/kg"),As.GetHR());
|
|
str += sz;
|
|
sz.Format(_T(" | 焓:%0.1fkJ/kg"),As.GetE());
|
|
str += sz;
|
|
cs=str;
|
|
}
|
|
break;
|
|
case 1:
|
|
{
|
|
CString str;
|
|
CString sz;
|
|
CAirState As;
|
|
TDbIDEntity *pEnt = GetIDEntity();
|
|
if(pEnt == NULL)
|
|
return es;
|
|
As = pEnt->GetDot(m_ptDot2);
|
|
sz.Format(_T("干球:%0.1f℃"),As.GetD());
|
|
str += sz;
|
|
sz.Format(_T(" | 湿球:%0.1f℃"),As.GetW());
|
|
str += sz;
|
|
sz.Format(_T(" | 相对湿度:%0.1f%%"),As.GetRH() * 100);
|
|
str += sz;
|
|
sz.Format(_T(" | 含湿量:%0.1fg/kg"),As.GetHR());
|
|
str += sz;
|
|
sz.Format(_T(" | 焓:%0.1fkJ/kg"),As.GetE());
|
|
str += sz;
|
|
cs=str;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbIDProcessLine::subGetOsnapPoints(AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d& pickPoint,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
snapPoints.setLogicalLength(2);
|
|
snapPoints.append(m_ptDot1);
|
|
snapPoints.append(m_ptDot2);
|
|
TDbEntity::subGetOsnapPoints(osnapMode,gsSelectionMark,pickPoint,lastPoint,viewXform,snapPoints,geomIds);
|
|
return Acad::eOk;
|
|
}
|
|
//-----------------------------------------------------------------------------
|
|
Acad::ErrorStatus TDbIDProcessLine::subMoveGripPointsAt(const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
assertReadEnabled();
|
|
for(int i=0; i<indices.length();i++)
|
|
{
|
|
int nIndex=indices[i];
|
|
switch(nIndex)
|
|
{
|
|
case 0:
|
|
m_ptDot1 = m_ptDot1 + offset;
|
|
break;
|
|
case 1:
|
|
m_ptDot2 = m_ptDot2 + offset;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
Acad::ErrorStatus TDbIDProcessLine::dwgInFields(AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
Acad::ErrorStatus es;
|
|
|
|
if ((es = AcDbEntity::dwgInFields(pFiler)) != Acad::eOk) {
|
|
return es;
|
|
}
|
|
|
|
Adesk::UInt16 version;
|
|
pFiler->readItem(&version);
|
|
if (version > g_nVersion)
|
|
return Acad::eMakeMeProxy;
|
|
|
|
pFiler->readItem(&m_IDHandle);
|
|
pFiler->readItem(&m_DotHandle1);
|
|
pFiler->readItem(&m_DotHandle2);
|
|
//pFiler->readItem(&m_bDirection);
|
|
FilerRead(pFiler, m_bDirection);
|
|
pFiler->readItem(&m_ptDot1);
|
|
pFiler->readItem(&m_ptDot2);
|
|
|
|
// Read the data members.
|
|
switch (version)
|
|
{
|
|
case (1):
|
|
break;
|
|
}
|
|
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
Acad::ErrorStatus TDbIDProcessLine::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es;
|
|
|
|
// Call dwgOutFields from AcDbEntity
|
|
if ((es = AcDbEntity::dwgOutFields(pFiler)) != Acad::eOk) {
|
|
return es;
|
|
}
|
|
// Write version number.
|
|
pFiler->writeItem((Adesk::UInt16) g_nVersion);
|
|
pFiler->writeItem(m_IDHandle);
|
|
pFiler->writeItem(m_DotHandle1);
|
|
pFiler->writeItem(m_DotHandle2);
|
|
//pFiler->writeItem(m_bDirection);
|
|
FilerWrite(pFiler, m_bDirection);
|
|
pFiler->writeItem(m_ptDot1);
|
|
pFiler->writeItem(m_ptDot2);
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
|
|
int TDbIDProcessLine::GetHWRatio(double &dbHWRatio)
|
|
{
|
|
TDbIDDot *pDot1 = GetDotEntity1();
|
|
TDbIDDot *pDot2 = GetDotEntity2();
|
|
if(pDot1 == NULL || pDot2 == NULL)
|
|
return 0;
|
|
double dbLoad = pDot1->GetDot().GetE() - pDot2->GetDot().GetE();
|
|
double dbWetLoad = pDot1->GetDot().GetHR() - pDot2->GetDot().GetHR();
|
|
dbHWRatio = dbLoad / dbWetLoad * 1000.0; //热湿比 kj/kg
|
|
if(dbWetLoad == 0.0 && dbLoad >=0)
|
|
{
|
|
return 1;
|
|
}
|
|
else if(dbWetLoad == 0.0 && dbLoad < 0)
|
|
{
|
|
return -1;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
void TDbIDProcessLine::SetDotHandle(AcDbHandle DotHandle1,AcDbHandle DotHandle2)
|
|
{
|
|
m_DotHandle1 = DotHandle1;
|
|
m_DotHandle2 = DotHandle2;
|
|
|
|
if(GetDotEntity1() == NULL || GetDotEntity2() == NULL)
|
|
return;
|
|
m_ptDot1 = GetDotEntity1()->GetDotPt();
|
|
m_ptDot2 = GetDotEntity2()->GetDotPt();
|
|
}
|
|
|
|
void TDbIDProcessLine::SetDotHandle1(AcDbHandle DotHandle1)
|
|
{
|
|
m_DotHandle1 = DotHandle1;
|
|
if(GetDotEntity1() == NULL)
|
|
return;
|
|
m_ptDot1 = GetDotEntity1()->GetDotPt();
|
|
}
|
|
|
|
void TDbIDProcessLine::SetDotHandle2(AcDbHandle DotHandle2)
|
|
{
|
|
m_DotHandle2 = DotHandle2;
|
|
if(GetDotEntity2() == NULL)
|
|
return;
|
|
m_ptDot2 = GetDotEntity2()->GetDotPt();
|
|
}
|
|
|
|
void InitDbIDProcessLine(BOOL bTrue)
|
|
{
|
|
if (bTrue) {
|
|
TDbIDProcessLine::rxInit();
|
|
TDbIDProcessLine::InitMatchProtocol(TRUE);
|
|
}
|
|
else {
|
|
TDbIDProcessLine::InitMatchProtocol(FALSE);
|
|
deleteAcRxClass(TDbIDProcessLine::desc());
|
|
}
|
|
}
|