2003 lines
54 KiB
C++
2003 lines
54 KiB
C++
#include "stdafx.h"
|
|
#include "StdArx.h"
|
|
#include "THImpHvacVRVEqu.h"
|
|
#include "TDbInterfaceRecord.h"
|
|
#include "TDbXDataMap.h"
|
|
#include "TDbInterfaceMsgWrite.h"
|
|
#include "math.h"
|
|
#include "dbxutil.h"
|
|
|
|
using namespace TDb;
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
|
|
THImpHvacVRVEqu::THImpHvacVRVEqu()
|
|
{
|
|
}
|
|
|
|
THImpHvacVRVEqu::~THImpHvacVRVEqu()
|
|
{
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::GetInterfaceSizeData(int nIndex, TInterface& pipeInterface) const
|
|
{
|
|
ASSERT(NULL != m_pXDataMap);
|
|
|
|
// 获取尺寸
|
|
double dWidth = 0.0, dThick = 0.0;
|
|
|
|
// 设置接口数据
|
|
pipeInterface.SetSize(dWidth, dThick);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::GetInterface(int nIndex,TInterface& pipeInterface) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return FALSE;
|
|
AcGePoint3d pt;
|
|
AcGeVector3d vt;
|
|
CString sName;
|
|
double dw,dt;
|
|
AcDbObjectId id;
|
|
|
|
GetInterFaceLocal(nIndex, pt);
|
|
GetInterFaceLocal(nIndex, vt);
|
|
GetInterFaceLocal(nIndex, sName);
|
|
GetInterFaceLocal(nIndex, dw, dt);
|
|
CString sID;
|
|
sID.Format(_T("%s%d"), KEY_IDCNT_, nIndex + 1);
|
|
if (m_pXDataMap->GetAt(sID, id) && id.isValid() && MakesureInterfaceValidate(id, pt, vt, pipeInterface))
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
pipeInterface.SetSize(dw,dt);
|
|
pipeInterface.SetOutDir(vt);
|
|
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
|
|
pipeInterface.SetPosition(pt);
|
|
pipeInterface.SetDescr(sName);
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::GetInterface(const AcGePoint3d& ptCon,TInterface& pipeInterface) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return FALSE;
|
|
|
|
int nIndex(-1);
|
|
if(GetIFIndexFormPt(nIndex,ptCon))
|
|
return GetInterface(nIndex,pipeInterface);
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::HasInterface(const AcGePoint3d& ptCon,const AcGeVector3d& vtDir)
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return FALSE;
|
|
|
|
// 获取各点位置
|
|
int nIndex(-1);
|
|
AcGeVector3d vtIf;
|
|
if(GetIFIndexFormPt(nIndex,ptCon))
|
|
{
|
|
GetInterFaceLocal(nIndex,vtIf);
|
|
return (vtDir.isParallelTo(vtIf));
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
int THImpHvacVRVEqu::GetInterfaceCount() const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return 0;
|
|
int iIfNum(0);
|
|
m_pXDataMap->GetAt(HVRV_InterfaceNum, iIfNum);
|
|
return iIfNum;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::SetInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return FALSE;
|
|
|
|
// 打开对象
|
|
AcDbEntity* pEnt;
|
|
if (Acad::eOk != acdbOpenObject(pEnt, idConnect, AcDb::kForRead))
|
|
return FALSE;
|
|
// 检查对象类型,是否是暖通管件
|
|
if (!(pEnt->isKindOf(TDbHvacDuct::desc()) || pEnt->isKindOf(TDbHvacFitting::desc())
|
|
|| pEnt->isKindOf(TDbHvacEquipment::desc())))
|
|
{
|
|
pEnt->close();
|
|
return FALSE;
|
|
}
|
|
|
|
// 获取各点位置
|
|
int nIndex(-1);
|
|
if(GetIFIndexFormPt(nIndex,ptConnect))
|
|
{
|
|
CString sID;
|
|
sID.Format(_T("%s%d"), KEY_IDCNT_, nIndex + 1);
|
|
|
|
// 基类指针
|
|
TDbInterfacesObj* pInterfaceObj = TDbInterfacesObj::cast(pEnt);
|
|
ASSERT(NULL != pInterfaceObj);
|
|
m_pXDataMap->SetAt(sID, idConnect);
|
|
pEnt->close();
|
|
return TRUE;
|
|
}
|
|
pEnt->close();
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::RemoveInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return FALSE;
|
|
|
|
// 浅层次删除; 命名字典中的关系,需要外面移除关系,只移除内部关系
|
|
|
|
AcDbObjectId id;
|
|
int nIndex(-1);
|
|
if(GetIFIndexFormPt(nIndex,ptConnect))
|
|
{
|
|
CString sID;
|
|
sID.Format(_T("%s%d"),KEY_IDCNT_,nIndex + 1);
|
|
m_pXDataMap->SetAt(sID, AcDbObjectId::kNull);
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::NotifyInterfaceToModify(const TInterfaceModifyMsg& iModiMsg,TInterfaceModifyMsgs& iModiMsgs)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::MakeCurves(TComplexCurve& cplCurve) const
|
|
{
|
|
return FALSE;
|
|
// AcGePoint3dArray arPts;
|
|
// GetBoxPts(arPts);
|
|
//
|
|
// TDb::TCurveElement el;
|
|
// memset(&el,0,sizeof(TDb::TCurveElement));
|
|
//
|
|
// el.ptGe[0] = arPts[1];
|
|
// el.ptGe[1] = arPts[2];
|
|
// el.ptGe[2] = arPts[2];
|
|
// cplCurve.append(el);
|
|
// el.ptGe[0] = arPts[3];
|
|
// el.ptGe[1] = arPts[4];
|
|
// el.ptGe[2] = arPts[4];
|
|
// cplCurve.append(el);
|
|
// el.ptGe[0] = arPts[1];
|
|
// el.ptGe[1] = arPts[4];
|
|
// el.ptGe[2] = arPts[4];
|
|
// cplCurve.append(el);
|
|
// el.ptGe[0] = arPts[2];
|
|
// el.ptGe[1] = arPts[3];
|
|
// el.ptGe[2] = arPts[3];
|
|
// cplCurve.append(el);
|
|
// return TRUE;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::GetCurvesInSide(TComplexCurve& compCurve) const
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
AcDbPolyline* THImpHvacVRVEqu::MakePolyCurve() const
|
|
{
|
|
//
|
|
//
|
|
// 1 ┃━━━━━┃ 3
|
|
// ┃ ┃
|
|
// ┃ 0 ┃
|
|
// ┃ ┃
|
|
// 2 ┃━━━━━┃ 4
|
|
//
|
|
//
|
|
// 获取各点位置
|
|
AcDbPolyline* pPolyLine = NULL;
|
|
AcGePoint3d pt1, pt2, pt3, pt4, ptCenter;
|
|
AcGePoint3d ptU1, ptU2, ptU3, ptU4;
|
|
AcGeVector3d vtMain, vtNor, vtMainv;
|
|
double dLength(50.0), dThick(50.0), dWidth(50.0), dPlusEdge(50.0);
|
|
AcDbDatabase* pDb = acdbCurDwg();
|
|
AcGeVector3d vtZAxis(pDb->ucsxdir().crossProduct(pDb->ucsydir()));
|
|
m_pXDataMap->GetAt(HVAC_Normal, vtNor);
|
|
m_pXDataMap->GetAt(HVRV_CenterPoint, ptCenter);
|
|
m_pXDataMap->GetAt(HVRV_MainDir, vtMain);
|
|
m_pXDataMap->GetAt(HVRV_Length, dLength);
|
|
m_pXDataMap->GetAt(HVRV_Width, dWidth);
|
|
m_pXDataMap->GetAt(HVRV_Thick, dThick);
|
|
|
|
// 避免有重复点造成无效的多段线,R16平台下崩溃
|
|
if (dLength < 1)
|
|
dLength = 1.0;
|
|
if (dWidth < 1)
|
|
dWidth = 1.0;
|
|
if (dThick < 1)
|
|
dThick = 1.0;
|
|
|
|
vtMainv = vtMain;
|
|
vtMainv.rotateBy(PI * 0.5, vtNor);
|
|
vtMain.normalize();
|
|
vtMainv.normalize();
|
|
|
|
pt1 = ptCenter + vtMainv * dWidth * 0.5;
|
|
pt2 = ptCenter - vtMainv * dWidth * 0.5;
|
|
pt1 = pt1 - vtMain * dLength *0.5;
|
|
pt3 = pt1 + vtMain * dLength;
|
|
pt2 = pt2 - vtMain * dLength *0.5;
|
|
pt4 = pt2 + vtMain * dLength;
|
|
ptU1 = pt1 + vtNor * dThick;
|
|
ptU2 = pt2 + vtNor * dThick;
|
|
ptU3 = pt3 + vtNor * dThick;
|
|
ptU4 = pt4 + vtNor * dThick;
|
|
AcGePoint3dArray arpts;
|
|
|
|
if (vtNor.angleTo(vtZAxis) < PI*0.25 || vtNor.angleTo(-vtZAxis) < PI*0.25)
|
|
{
|
|
arpts.append(pt1);
|
|
arpts.append(pt2);
|
|
arpts.append(pt4);
|
|
arpts.append(pt3);
|
|
}
|
|
else if (vtNor.angleTo(pDb->ucsxdir()) < PI*0.25 || vtNor.angleTo(-pDb->ucsxdir()) < PI*0.25)
|
|
{
|
|
ptU2.z = pt2.z = ptU1.z = pt1.z = ptCenter.z;
|
|
arpts.append(ptU2);
|
|
arpts.append(pt2);
|
|
arpts.append(pt1);
|
|
arpts.append(ptU1);
|
|
}
|
|
else if (vtNor.angleTo(pDb->ucsydir()) < PI*0.25 || vtNor.angleTo(-pDb->ucsydir()) < PI*0.25)
|
|
{
|
|
ptU1.z = pt1.z = ptU3.z = pt3.z = ptCenter.z;
|
|
arpts.append(ptU1);
|
|
arpts.append(pt1);
|
|
arpts.append(pt3);
|
|
arpts.append(ptU3);
|
|
}
|
|
AcGePlane plan(arpts[0], arpts[1], arpts[2]);
|
|
AcGePoint3d ptOrth = AcGePoint3d::kOrigin.orthoProject(plan);
|
|
plan.set(ptOrth, vtZAxis);
|
|
|
|
double dEl = ptOrth.asVector().length();
|
|
if (ptOrth.asVector().angleTo(plan.normal()) > PI*0.5)
|
|
dEl *= -1.0;
|
|
|
|
pPolyLine = new AcDbPolyline;
|
|
pPolyLine->addVertexAt(0,arpts[0].convert2d(plan));
|
|
pPolyLine->addVertexAt(1,arpts[1].convert2d(plan));
|
|
pPolyLine->addVertexAt(2,arpts[2].convert2d(plan));
|
|
pPolyLine->addVertexAt(3,arpts[3].convert2d(plan));
|
|
pPolyLine->setClosed(Adesk::kTrue);
|
|
pPolyLine->setElevation(dEl);
|
|
pPolyLine->setNormal(plan.normal());
|
|
return pPolyLine;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::MakePolyCurveFaces(AcDbVoidPtrArray& arFaces)
|
|
{
|
|
//
|
|
//
|
|
// 1 ┃━━━━━┃ 3
|
|
// ┃ ┃
|
|
// ┃ 0 ┃
|
|
// ┃ ┃
|
|
// 2 ┃━━━━━┃ 4
|
|
//
|
|
//
|
|
// 获取各点位置
|
|
AcGePoint3d pt1, pt2, pt3, pt4, ptCenter;
|
|
AcGeVector3d vtMain, vtNor, vtMainv;
|
|
AcDbDatabase* pDb = acdbCurDwg();
|
|
AcGeVector3d vtZAxis(pDb->ucsxdir().crossProduct(pDb->ucsydir()));
|
|
double dLength(50.0), dThick(50.0), dWidth(50.0), dPlusEdge(50.0);
|
|
m_pXDataMap->GetAt(HVAC_Normal, vtNor);
|
|
m_pXDataMap->GetAt(HVRV_CenterPoint, ptCenter);
|
|
m_pXDataMap->GetAt(HVRV_MainDir, vtMain);
|
|
m_pXDataMap->GetAt(HVRV_Length, dLength);
|
|
m_pXDataMap->GetAt(HVRV_Width, dWidth);
|
|
vtMainv = vtMain;
|
|
vtMainv.rotateBy(PI * 0.5, vtZAxis);
|
|
vtMain.normalize();
|
|
vtMainv.normalize();
|
|
|
|
if (IsParallelToX())
|
|
{
|
|
dLength = dThick;
|
|
}
|
|
else if (IsParallelToY())
|
|
{
|
|
dWidth = dThick;
|
|
}
|
|
|
|
pt1 = ptCenter + vtMainv * dWidth * 0.5;
|
|
pt2 = ptCenter - vtMainv * dWidth * 0.5;
|
|
pt1 = pt1 - vtMain * dLength *0.5;
|
|
pt3 = pt1 + vtMain * dLength;
|
|
pt2 = pt2 - vtMain * dLength *0.5;
|
|
pt4 = pt2 + vtMain * dLength;
|
|
AcDbFace * pFace = new AcDbFace;
|
|
pFace->setVertexAt(0,pt1);
|
|
pFace->setVertexAt(1,pt2);
|
|
pFace->setVertexAt(2,pt4);
|
|
pFace->setVertexAt(3,pt3);
|
|
arFaces.append(pFace);
|
|
|
|
return arFaces.length() > 0;
|
|
}
|
|
|
|
void THImpHvacVRVEqu::GetKindName(CString& sName)
|
|
{
|
|
sName = _T("TCH_DBHVRVEQUIPMENT");
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::GetGeomExtentsEdge(TComplexCurve& crLoop)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
TDb::Position THImpHvacVRVEqu::ExplainGripIndex(int nIndex) const
|
|
{
|
|
if(nIndex == 0)
|
|
{
|
|
return TDb::eMid;
|
|
}
|
|
else
|
|
{
|
|
if (nIndex <= GetInterfaceCount())
|
|
return TDb::eCommand0;
|
|
// add by zh 2012-12-5 对文字移动处理
|
|
if (nIndex > GetInterfaceCount() + 4)
|
|
return TDb::eStart;
|
|
}
|
|
|
|
return TDb::eMid;
|
|
}
|
|
|
|
// 按尺寸获取四角点,增加控制夹点用于捕捉定位,不会清空原arrPt
|
|
void THImpHvacVRVEqu::GetFourConer( AcGePoint3dArray &arrPt ) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return;
|
|
|
|
AcGePoint3d ptCenter;
|
|
AcGeVector3d vtMain, vtPerl, vtNormal;
|
|
double dLen(1.0), dWidth(1.0);
|
|
m_pXDataMap->GetAt(HVRV_CenterPoint, ptCenter);
|
|
m_pXDataMap->GetAt(HVRV_MainDir, vtMain);
|
|
m_pXDataMap->GetAt(HVAC_Normal, vtNormal);
|
|
vtPerl = vtMain.crossProduct(vtNormal);
|
|
|
|
m_pXDataMap->GetAt(HVRV_Width, dWidth);
|
|
m_pXDataMap->GetAt(HVRV_Length, dLen);
|
|
|
|
AcGePoint3d ptLeftUp = ptCenter - vtMain*dLen*0.5 - vtPerl*dWidth*0.5;
|
|
AcGePoint3d ptLeftDw = ptLeftUp + vtPerl*dWidth;
|
|
AcGePoint3d ptRightDw = ptLeftDw + vtMain*dLen;
|
|
AcGePoint3d ptRightUp = ptRightDw - vtPerl*dWidth;
|
|
arrPt.append(ptLeftUp);
|
|
arrPt.append(ptLeftDw);
|
|
arrPt.append(ptRightDw);
|
|
arrPt.append(ptRightUp);
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::GetGripText(int i, CString &cs) const
|
|
{
|
|
if (i == 0)
|
|
{
|
|
cs = _T("改变位置");
|
|
}
|
|
else
|
|
{
|
|
if (i <= GetInterfaceCount())
|
|
GetInterFaceLocal(i - 1,cs);
|
|
// add by zh 2012-12-5 增加夹点文字提示
|
|
else if (i > GetInterfaceCount() + 4)
|
|
cs = _T("改变文字位置");
|
|
else
|
|
cs = _T("改变位置");
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void THImpHvacVRVEqu::GetTips(CMapStringToString& mapLable2Tip) const
|
|
{
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::ExplodeOrDraw3d(XExplodeDraw &mode) const
|
|
{
|
|
ASSERT(NULL != m_pXDataMap);
|
|
AcDbObjectId idBlock,idBlock3D;
|
|
|
|
m_pXDataMap->GetAt(HVRV_PartCenter, idBlock);
|
|
m_pXDataMap->GetAt(HVRV_Part3D, idBlock3D);
|
|
double dThick(1.0);
|
|
m_pXDataMap->GetAt(HVRV_Thick, dThick);
|
|
if (dThick < 1.e-3 || idBlock3D == AcDbObjectId::kNull)
|
|
{
|
|
idBlock3D = idBlock;
|
|
}
|
|
|
|
InserBlockCen(mode, idBlock3D);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcGeVector3d THImpHvacVRVEqu::GetNormal() const
|
|
{
|
|
ASSERT(NULL != m_pXDataMap);
|
|
AcGeVector3d vtNor;
|
|
m_pXDataMap->GetAt(HVAC_Normal, vtNor);
|
|
return vtNor.normalize();
|
|
}
|
|
|
|
// AecObjectEditMethod THImpHvacEquipment::GetEditMethod() const
|
|
// {
|
|
// ASSERT(NULL != m_pXDataMap);
|
|
// ObjectKind eKind;
|
|
// m_pXDataMap->GetAt(KEY_RUNTIME, (int &)eKind);
|
|
//
|
|
// return TImpSpecEquipment::GetEditMethod();
|
|
// }
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::ExplodeOrDraw2d(XExplodeDraw &mode) const
|
|
{
|
|
if (m_pXDataMap == NULL)
|
|
{
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
|
|
if(((TDbHvacEquipment*)m_pOwnerEnt)->IsDragging())
|
|
{
|
|
HashInterFaceLine(AcDb::kVisible);
|
|
AcDbObjectId idBlock;
|
|
m_pXDataMap->GetAt(HVRV_PartCenter, idBlock);
|
|
if (idBlock.isValid())
|
|
InserBlockCen(mode,idBlock);
|
|
}
|
|
else
|
|
{
|
|
HashInterFaceLine(AcDb::kInvisible);
|
|
AcDbObjectId idBlock;
|
|
m_pXDataMap->GetAt(HVRV_PartCenter, idBlock);
|
|
if (idBlock.isValid())
|
|
InserBlockCen(mode,idBlock);
|
|
}
|
|
|
|
// BEGIN=============================
|
|
// add by zh 2012-12-3 多联机标注
|
|
BOOL bHasName = FALSE;
|
|
m_pXDataMap->GetAt(HVRV_HasText, bHasName);
|
|
if (bHasName)
|
|
{
|
|
CString sType(_T(""));
|
|
m_pXDataMap->GetAt(HVRV_SModel, sType);
|
|
AcGePoint3d ptInst = AcGePoint3d::kOrigin;
|
|
m_pXDataMap->GetAt(HVRV_TextPoint, ptInst);
|
|
AcGeVector3d vtMain = AcGeVector3d::kXAxis;
|
|
m_pXDataMap->GetAt(HVRV_MainDir, vtMain);
|
|
double dTextHeight = 3;
|
|
m_pXDataMap->GetAt(KEY_TextHeight, dTextHeight);
|
|
AcDbObjectId idLayer = AcDbObjectId::kNull;
|
|
m_pXDataMap->GetAt(KEY_EndLayer, idLayer);
|
|
|
|
double dAng = TAuxTools::GetUcsXvt().angleTo(vtMain, TAuxTools::GetUcsZvt());
|
|
if (dAng > PI / 2 && dAng <= PI + PI / 2){
|
|
vtMain.negate();
|
|
}
|
|
|
|
TDbText *pText = new TDbText;
|
|
pText->setPropertiesFrom(m_pOwnerEnt);
|
|
pText->SetText(sType);
|
|
|
|
AcDbObjectId idStyle = AcDbObjectId::kNull;
|
|
m_pXDataMap->GetAt(HDIM_DimTextId, idStyle);
|
|
pText->SetStyleId(idStyle);
|
|
|
|
pText->SetHeight(dTextHeight);
|
|
pText->SetLocation(ptInst);
|
|
pText->SetRotation(AcGeVector3d::kXAxis.angleTo(vtMain, AcGeVector3d::kZAxis));
|
|
pText->SetAlignment(XExplodeDraw::kMiddleCenter);
|
|
pText->setLayer(idLayer);//InitLayer(_T("TA-构件标注"))
|
|
|
|
BOOL bMask(FALSE);
|
|
m_pXDataMap->GetAt(HVRV_TextShadeBg, bMask);
|
|
pText->SetMaskFlag(bMask);
|
|
|
|
// 绘制文字
|
|
if (mode.IsFullExplode())
|
|
pText->ExplodeOrDraw2d(mode);
|
|
else
|
|
mode.DrawEntity(*pText);
|
|
delete pText;
|
|
}
|
|
// END==============================
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::InserBlockCen(XExplodeDraw &mode, AcDbObjectId idBlock) const
|
|
{
|
|
ASSERT(NULL != m_pXDataMap);
|
|
AcGeVector3d vtMain, vtScale, vtNor;
|
|
|
|
// mcl changed, 10.01.06,直接采用了比例参数vtScale
|
|
// double dLength(1.0);
|
|
// double dWidth(1.0);
|
|
// double dThick(1.0);
|
|
AcGePoint3d ptCenter;
|
|
m_pXDataMap->GetAt(HVAC_Normal, vtNor);
|
|
m_pXDataMap->GetAt(HVRV_CenterPoint, ptCenter);
|
|
// m_pXDataMap->GetAt(HVRV_Length, dLength);
|
|
// m_pXDataMap->GetAt(HVRV_Width, dWidth);
|
|
// m_pXDataMap->GetAt(HVRV_Thick, dThick);
|
|
m_pXDataMap->GetAt(HVRV_MainDir, vtMain);
|
|
m_pXDataMap->GetAt(HVRV_Scale, vtScale);
|
|
// if (dThick < 1)
|
|
// {
|
|
// dThick = 1;
|
|
// }
|
|
|
|
double dAngle(0.0);
|
|
|
|
// dLength *= vtScale.x;
|
|
// dWidth *= vtScale.y;
|
|
// dThick *= vtScale.z;
|
|
dAngle = AcGeVector3d::kXAxis.angleTo(vtMain,vtNor);
|
|
//如果没有高度值,则高度比例置为1
|
|
// if (vtScale.z == 1)
|
|
// {
|
|
// dThick = 1;
|
|
// }
|
|
|
|
// AcGeScale3d scale(dLength, dWidth, dThick);
|
|
AcGeScale3d scale(vtScale.x, vtScale.y, vtScale.z);
|
|
|
|
AcDbObject *pObj;
|
|
XPoint xpoint = ptCenter;
|
|
if (acdbOpenObject(pObj, idBlock, AcDb::kForRead) != Acad::eOk)
|
|
return Acad::eNotImplementedYet;
|
|
AcDbBlockTableRecord *pBlock = AcDbBlockTableRecord::cast(pObj);
|
|
if (pBlock == NULL)
|
|
{
|
|
pObj->close();
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
mode.DrawBlock(*pBlock, xpoint, scale, dAngle, TRUE);
|
|
pObj->close();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::InserBlockHand(XExplodeDraw &mode) const
|
|
{
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::Draw2dBox(XExplodeDraw &mode) const
|
|
{
|
|
AcGeVector3d vtNor;
|
|
m_pXDataMap->GetAt(HVAC_Normal, vtNor);
|
|
AcGePoint3dArray arPts;
|
|
GetBoxPts(arPts);
|
|
double dEl;
|
|
AcGePlane plane = TAuxTools::GetHidePlane(arPts[1],arPts[2],arPts[3],vtNor,dEl);
|
|
AcDbPolyline polyLine;
|
|
polyLine.addVertexAt(0,arPts[1].convert2d(plane));
|
|
polyLine.addVertexAt(1,arPts[2].convert2d(plane));
|
|
polyLine.addVertexAt(2,arPts[3].convert2d(plane));
|
|
polyLine.addVertexAt(3,arPts[4].convert2d(plane));
|
|
mode.Polyline(polyLine);
|
|
return Acad::eOk;
|
|
}
|
|
// 5 6
|
|
// ┃ ┃
|
|
// 1 ┃━━━━━┃ 2
|
|
// ┃ ┃
|
|
// ┃ 0 ┃
|
|
// ┃ ┃
|
|
// 4 ┃━━━━━┃ 3
|
|
// ┃ ┃
|
|
// 8 7
|
|
//
|
|
BOOL THImpHvacVRVEqu::GetBoxPts(AcGePoint3dArray &arPts) const
|
|
{
|
|
// 获取各点位置
|
|
AcGePoint3d ptStart, ptEnd, ptCenter;
|
|
AcGeVector3d vtMain, vtNor, vtMainv;
|
|
double dLength(50.0), dThick(50.0), dWidth(50.0), dPlusEdge(50.0);
|
|
m_pXDataMap->GetAt(HVAC_Normal, vtNor);
|
|
m_pXDataMap->GetAt(HVRV_CenterPoint, ptCenter);
|
|
m_pXDataMap->GetAt(HVRV_MainDir, vtMain);
|
|
m_pXDataMap->GetAt(HVRV_Length, dLength);
|
|
m_pXDataMap->GetAt(HVRV_Width, dWidth);
|
|
m_pXDataMap->GetAt(HVRV_Thick, dThick);
|
|
vtMainv = vtMain;
|
|
vtMainv.rotateBy(PI * 0.5, vtNor);
|
|
vtMain.normalize();
|
|
vtMainv.normalize();
|
|
dPlusEdge = dWidth * 0.1;
|
|
//0
|
|
arPts.append(ptCenter);
|
|
AcGePoint3d pt;
|
|
pt = ptCenter - vtMain * dLength * 0.5;
|
|
pt = pt + vtMainv * dWidth * 0.5;
|
|
//1
|
|
arPts.append(pt);
|
|
//2
|
|
arPts.append(arPts[1] + vtMain * dLength);
|
|
//3
|
|
arPts.append(arPts[2] - vtMainv * dWidth);
|
|
//4
|
|
arPts.append(arPts[1] - vtMainv * dWidth);
|
|
return TRUE;
|
|
}
|
|
|
|
void THImpHvacVRVEqu::list() const
|
|
{
|
|
if (m_pXDataMap == NULL)
|
|
return;
|
|
|
|
CString sFactory(_T("")), sInDoor(_T(""));
|
|
m_pXDataMap->GetAt(HVRV_SFactory, sFactory);
|
|
acutPrintf(_T("\t\t\t\t\t\t\t\t厂商:%s"), sFactory);
|
|
CString sTmp(_T(""));
|
|
m_pXDataMap->GetAt(HVRV_SOutdoor, sTmp);
|
|
acutPrintf(_T("\n\t\t\t\t\t系列: %s"), sTmp);
|
|
m_pXDataMap->GetAt(HVRV_SType, sTmp);
|
|
acutPrintf(_T("\n\t\t\t\t\t类型: %s"), sTmp);
|
|
m_pXDataMap->GetAt(HVRV_SModel, sTmp);
|
|
acutPrintf(_T("\n\t\t\t\t\t型号: %s"), sTmp);
|
|
double dTmp(0.0);
|
|
m_pXDataMap->GetAt(HVRV_ColdLoad, dTmp);
|
|
acutPrintf(_T("\n\t\t\t\t\t制冷量: %.2fkW"), dTmp);
|
|
m_pXDataMap->GetAt(HVRV_HeatLoad, dTmp);
|
|
acutPrintf(_T("\n\t\t\t\t\t制热量: %.2fkW"), dTmp);
|
|
m_pXDataMap->GetAt(HVRV_ColdPower, dTmp);
|
|
acutPrintf(_T("\n\t\t\t\t\t制冷功率: %.2fkW"), dTmp);
|
|
m_pXDataMap->GetAt(HVRV_HeatPower, dTmp);
|
|
acutPrintf(_T("\n\t\t\t\t\t制热功率: %.2fkW"), dTmp);
|
|
m_pXDataMap->GetAt(HVRV_Length, dTmp);
|
|
acutPrintf(_T("\n\t\t\t\t\t长度: %.0fmm"), dTmp);
|
|
m_pXDataMap->GetAt(HVRV_Width, dTmp);
|
|
acutPrintf(_T("\n\t\t\t\t\t宽度: %.0fmm"), dTmp);
|
|
m_pXDataMap->GetAt(HVRV_Thick, dTmp);
|
|
acutPrintf(_T("\n\t\t\t\t\t高度: %.0fmm"), dTmp);
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::transformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return Acad::eNotApplicable;
|
|
// 取得位置点
|
|
AcGePoint3d ptCenter, ptText; // add by zh 2013-2-27 增加文字节点ptText
|
|
AcGeVector3d vtMain,vtNor, vtScale;
|
|
double dL(1.0),dW(1.0),dT(1.0);
|
|
m_pXDataMap->GetAt(HVRV_CenterPoint, ptCenter);
|
|
m_pXDataMap->GetAt(HVRV_MainDir, vtMain);
|
|
m_pXDataMap->GetAt(HVRV_TextPoint, ptText); // add by zh 2013-2-27
|
|
m_pXDataMap->GetAt(HVRV_Length, dL);
|
|
m_pXDataMap->GetAt(HVRV_Width, dW);
|
|
m_pXDataMap->GetAt(HVRV_Thick, dT);
|
|
m_pXDataMap->GetAt(HVRV_Scale, vtScale);
|
|
m_pXDataMap->GetAt(HVAC_Normal, vtNor);
|
|
|
|
AcGeVector3d vtPrep(vtNor.crossProduct(vtMain));
|
|
|
|
// AcGeVector3d vtSz(dL,dW,dT);
|
|
// vtSz.transformBy(xform);
|
|
|
|
// 变换位置
|
|
vtNor.transformBy(xform);
|
|
ptCenter.transformBy(xform);
|
|
ptText.transformBy(xform); // add by zh 2013-2-27
|
|
vtMain.transformBy(xform);
|
|
|
|
vtPrep.transformBy(xform);
|
|
// 同向是旋转,不变号,反向是镜像,变号。
|
|
int iSign = ((vtPrep.isCodirectionalTo(vtNor.crossProduct(vtMain))) ? 1 : -1);
|
|
vtScale.y *= iSign;
|
|
|
|
SetInterFaceLocal(xform);
|
|
double dscale = xform.scale();
|
|
vtScale *= dscale;
|
|
|
|
// 更新点
|
|
m_pXDataMap->SetAt(HVAC_Normal, vtNor);
|
|
double ddd = xform.norm();
|
|
|
|
m_pXDataMap->SetAt(HVRV_CenterPoint, ptCenter);
|
|
m_pXDataMap->SetAt(HVRV_MainDir, vtMain);
|
|
m_pXDataMap->SetAt(HVRV_TextPoint, ptText); // add by zh 2013-2-27
|
|
m_pXDataMap->SetAt(HVRV_Length, dL * dscale);
|
|
m_pXDataMap->SetAt(HVRV_Width, dW * dscale);
|
|
m_pXDataMap->SetAt(HVRV_Thick, dT * dscale);
|
|
m_pXDataMap->SetAt(HVRV_Scale, vtScale);
|
|
|
|
// 传递消息
|
|
if (m_pOwnerEnt != NULL && m_pOwnerEnt->objectId().isValid())
|
|
{
|
|
// 如果实体不是在当前模型空间中,不做写消息,更新接口处理
|
|
AcDbDatabase* pDb = m_pOwnerEnt->database();
|
|
if (pDb == NULL) pDb = acdbCurDwg();
|
|
|
|
AcDbObjectId idModel;
|
|
AcDbBlockTable* pTable = NULL;
|
|
pDb->getBlockTable(pTable, AcDb::kForRead);
|
|
if (pTable != NULL)
|
|
{
|
|
pTable->getAt(ACDB_MODEL_SPACE, idModel);
|
|
pTable->close();
|
|
}
|
|
|
|
// 如果实体不是在当前模型空间中,不做写消息,更新接口处理
|
|
if (idModel == m_pOwnerEnt->blockId())
|
|
{
|
|
TInterfaceModifyMsg iMsg;
|
|
iMsg.SetInterfaceOper(TDb::eTransformBy);
|
|
iMsg.SetMsgValidate(TRUE);
|
|
iMsg.SetTransform(xform);
|
|
iMsg.SetMsgOperateOn(m_pOwnerEnt->objectId());
|
|
|
|
TDbInterfaceMsgWrite msgWrite;
|
|
msgWrite.WriteInterfaceMsg(iMsg);
|
|
|
|
//更新接口记录接口信息
|
|
UpdateInterfaceRec(m_pOwnerEnt->objectId(), xform);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::getStretchPoints(AcGePoint3dArray& stretchPoints) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return Acad::eNotApplicable;
|
|
|
|
// 取得位置点
|
|
AcGePoint3d ptCenter;
|
|
m_pXDataMap->GetAt(HVRV_CenterPoint, ptCenter);
|
|
|
|
stretchPoints.append(ptCenter);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::moveStretchPointsAt(const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
return moveGripPointsAt(indices,offset);
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::moveGripPointsAt(const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
ASSERT(NULL != m_pXDataMap);
|
|
|
|
int nSize = indices.length();
|
|
if (nSize > 0)
|
|
{
|
|
// 取得位置点
|
|
AcGePoint3d ptCenter;
|
|
m_pXDataMap->GetAt(HVRV_CenterPoint, ptCenter);
|
|
AcGeVector3d vtMain,vtMainv;
|
|
m_pXDataMap->GetAt(HVRV_MainDir, vtMain);
|
|
// 选择多个夹点,以first为准
|
|
int nIndex = indices.first();
|
|
TDb::Position ePos = ExplainGripIndex(nIndex);
|
|
switch(ePos)
|
|
{
|
|
case TDb::eMid:
|
|
{
|
|
TDb::InterfaceOper eOper = TDb::eMoveGripPoint;
|
|
AcGeVector3d vtMove = offset;
|
|
|
|
ptCenter += vtMove;
|
|
m_pXDataMap->SetAt(HVRV_CenterPoint, ptCenter);
|
|
|
|
//更改接口位置
|
|
AcGeMatrix3d maxvt;
|
|
maxvt.setToTranslation(vtMove);
|
|
SetInterFaceLocal(maxvt);
|
|
|
|
if (m_pOwnerEnt != NULL && m_pOwnerEnt->objectId().isValid())
|
|
{
|
|
// 写入接口更改消息
|
|
TInterfaceModifyMsg iMsg;
|
|
iMsg.SetMsgPoint(ptCenter);//new pos
|
|
iMsg.SetGripPosition(TDb::eMid);
|
|
iMsg.SetMoveGripOffset(vtMove);
|
|
if (eOper == TDb::eTransformBy)
|
|
iMsg.SetTransform(vtMove);
|
|
iMsg.SetMsgValidate(TRUE);
|
|
iMsg.SetInterfaceOper(eOper);
|
|
iMsg.SetMsgOperateOn(m_pOwnerEnt->objectId());
|
|
TDbInterfaceMsgWrite msgWrite;
|
|
msgWrite.WriteInterfaceMsg(iMsg);
|
|
|
|
//更新接口记录接口信息
|
|
AcGeMatrix3d xform;
|
|
xform.setToTranslation(vtMove);
|
|
UpdateInterfaceRec(m_pOwnerEnt->objectId(),xform);
|
|
}
|
|
break;
|
|
}
|
|
case TDb::eCommand0:
|
|
{
|
|
nIndex -= 1;
|
|
AcGePoint3d ptCom;
|
|
GetInterFaceLocal(nIndex, ptCom);
|
|
if (GetKeyState(VK_MENU) < 0)
|
|
{
|
|
TDbXDataMap xdatamap;
|
|
m_pXDataMap->GetAt(HVRV_Interface, nIndex, xdatamap);
|
|
ptCom += offset;
|
|
xdatamap.SetAt(HEQUIF_Point, ptCom);
|
|
m_pXDataMap->SetAt(HVRV_Interface, nIndex, xdatamap);
|
|
//GetInterfaceFromXdata(nIndex, offset);
|
|
break;
|
|
}
|
|
// 获得夹点命令
|
|
else
|
|
{
|
|
CString sCmdStr;
|
|
int nType(0);
|
|
GetInterFaceLocal(nIndex, nType);
|
|
switch(nType)
|
|
{
|
|
case 0:
|
|
GetGlobalContext()->GetAt(KEY_HVACCOLDGRIPCMD, sCmdStr);
|
|
break;
|
|
case 1:
|
|
case 2:
|
|
GetGlobalContext()->GetAt(KEY_HVACGRIPCMD, sCmdStr);
|
|
break;
|
|
case 3:
|
|
GetGlobalContext()->GetAt(KEY_HVACHEATGRIPCMD, sCmdStr);
|
|
break;
|
|
case 4:
|
|
GetGlobalContext()->GetAt(KEY_HVACMEDIAGRIPCMD, sCmdStr);
|
|
break;
|
|
case 5:
|
|
GetGlobalContext()->GetAt(KEY_HVACFJSQGRIPCMD, sCmdStr);
|
|
break;
|
|
}
|
|
if (sCmdStr.IsEmpty())
|
|
return Acad::eNotApplicable;
|
|
TInterface pipeInterface;
|
|
GetInterface(ptCom, pipeInterface );
|
|
|
|
double dw,dh;
|
|
GetInterFaceLocal(nIndex, dw,dh);
|
|
// 写入接口更改消息
|
|
TInterfaceModifyMsg iMsg;
|
|
iMsg.SetMsgPoint(ptCom);//new pos
|
|
iMsg.SetGripPosition(ePos);
|
|
iMsg.SetMoveGripOffset(offset);
|
|
iMsg.SetMsgValidate(TRUE);
|
|
iMsg.SetInterfaceOper(TDb::eNewCommand);
|
|
iMsg.SetPreviewObjToCreate(TDb::eVRVEqu, 0);
|
|
|
|
AcDbSoftPointerId idOwner;
|
|
m_pXDataMap->GetAt(KEY_THISID,idOwner);
|
|
iMsg.SetMsgOperateOn(idOwner);
|
|
TDbInterfaceMsgWrite msgWrite;
|
|
msgWrite.WriteInterfaceMsg(iMsg);
|
|
|
|
// 发送消息
|
|
acedPostCommand(_T("\33"));
|
|
acedPostCommand(sCmdStr + _T("\n"));
|
|
break;
|
|
}
|
|
|
|
}
|
|
// add by zh 2012-12-5 对标注文字夹点处理
|
|
case TDb::eStart:
|
|
{
|
|
AcGePoint3d ptText;
|
|
m_pXDataMap->GetAt(HVRV_TextPoint, ptText);
|
|
ptText += offset;
|
|
m_pXDataMap->SetAt(HVRV_TextPoint, ptText);
|
|
break;
|
|
}
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::intersectWith(const AcDbEntity* pEnt,
|
|
AcDb::Intersect intType,
|
|
const AcGePlane& projPlane,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::intersectWith(const AcDbEntity* pEnt,
|
|
AcDb::Intersect intType,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::getOsnapPoints(AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d& pickPoint,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return Acad::eNotApplicable;
|
|
AcGePoint3d ptCenter;
|
|
m_pXDataMap->GetAt(HVRV_CenterPoint, ptCenter);
|
|
|
|
// 根据捕捉模式处理
|
|
switch(osnapMode)
|
|
{
|
|
case AcDb::kOsModeEnd:
|
|
{
|
|
AcGePoint3dArray arpts;
|
|
GetInterFaceLocal(arpts);
|
|
GetFourConer(arpts);
|
|
snapPoints.append(arpts);
|
|
}
|
|
break;
|
|
case AcDb::kOsModeMid:
|
|
break;
|
|
case AcDb::kOsModeCen:
|
|
snapPoints.append(ptCenter);
|
|
break;
|
|
case AcDb::kOsModePerp:
|
|
break;
|
|
case AcDb::kOsModeNear:
|
|
break;
|
|
}
|
|
// add by hh 2011-07-12 支持任意位置捕捉
|
|
TImpSpecEquipment::getOsnapPoints(osnapMode, gsSelectionMark, pickPoint, lastPoint,
|
|
viewXform, snapPoints, geomIds);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::getGripPoints(AcGePoint3dArray& gripPoints,
|
|
AcDbIntArray& osnapModes,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return Acad::eNotApplicable;
|
|
double dPlusEdge = 50.0;
|
|
// 取得位置点
|
|
AcGeVector3d vtMain;
|
|
AcGePoint3d ptCenter;
|
|
double dL(1.0);
|
|
m_pXDataMap->GetAt(HVRV_CenterPoint, ptCenter);
|
|
m_pXDataMap->GetAt(HVRV_MainDir, vtMain);
|
|
m_pXDataMap->GetAt(HVRV_Length, dL);
|
|
//移动夹点
|
|
gripPoints.append(ptCenter); //MID
|
|
AcGePoint3dArray arpts;
|
|
if (GetInterFaceLocal(arpts))
|
|
{
|
|
for (int i = 0; i < arpts.length(); i++)
|
|
{
|
|
gripPoints.append(arpts[i]);
|
|
}
|
|
}
|
|
|
|
GetFourConer(gripPoints);// 四角点
|
|
|
|
// add by zh 2012-12-5 增加文字夹点
|
|
BOOL bHasText = FALSE;
|
|
m_pXDataMap->GetAt(HVRV_HasText, bHasText);
|
|
if (bHasText)
|
|
{
|
|
m_pXDataMap->GetAt(HVRV_TextPoint, ptCenter);
|
|
gripPoints.append(ptCenter);
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::GetInterFaceLocal(AcGePoint3dArray& arpts) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return FALSE;
|
|
arpts.setLogicalLength(0);
|
|
TDbXDataMap xdatamap;
|
|
int iIfNum(0);
|
|
AcGePoint3d ptInter;
|
|
arpts.setLogicalLength(0);
|
|
m_pXDataMap->GetAt(HVRV_InterfaceNum, iIfNum);
|
|
for (int i = 0; i < iIfNum; i++)
|
|
{
|
|
xdatamap.Empty();
|
|
m_pXDataMap->GetAt(HVRV_Interface, i, xdatamap);
|
|
if (xdatamap.GetAt(HEQUIF_Point, ptInter))
|
|
arpts.append(ptInter);
|
|
}
|
|
return arpts.length() > 0;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::SetInterFaceLocal(const AcGeMatrix3d& xform) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return FALSE;
|
|
int icount(0);
|
|
m_pXDataMap->GetAt(HVRV_InterfaceNum, icount);
|
|
TDbXDataMap xdatamap;
|
|
|
|
CString sName;
|
|
AcGeVector3d vt;
|
|
AcGePoint3d pt;
|
|
for (int i = 0; i < icount; i++)
|
|
{
|
|
xdatamap.Empty();
|
|
m_pXDataMap->GetAt(HVRV_Interface, i, xdatamap);
|
|
xdatamap.GetAt(HEQUIF_Point, pt);
|
|
xdatamap.GetAt(HEQUIF_Vector, vt);
|
|
pt.transformBy(xform);
|
|
vt.transformBy(xform);
|
|
xdatamap.SetAt(HEQUIF_Point, pt);
|
|
xdatamap.SetAt(HEQUIF_Vector, vt);
|
|
BOOL BB = m_pXDataMap->SetAt(HVRV_Interface, i, xdatamap);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
// 函数有问题
|
|
BOOL THImpHvacVRVEqu::SetInterFaceLocal(const AcGeScale3d& scale3d) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return FALSE;
|
|
int icount(0);
|
|
m_pXDataMap->GetAt(HVRV_InterfaceNum, icount);
|
|
|
|
TDbXDataMap xdatamap;
|
|
CString sName;
|
|
AcGeVector3d vt;
|
|
AcGePoint3d pt;
|
|
for (int i = 0; i < icount; i++)
|
|
{
|
|
xdatamap.Empty();
|
|
m_pXDataMap->GetAt(HVRV_Interface, i, xdatamap);
|
|
xdatamap.GetAt(HEQUIF_Point, pt);
|
|
xdatamap.GetAt(HEQUIF_Vector, vt);
|
|
pt.x *= scale3d.sx;
|
|
pt.y *= scale3d.sy;
|
|
pt.z *= scale3d.sz;
|
|
vt.x *= scale3d.sx;
|
|
vt.y *= scale3d.sy;
|
|
vt.z *= scale3d.sz;
|
|
vt.normalize();
|
|
xdatamap.SetAt(HEQUIF_Point, pt);
|
|
xdatamap.SetAt(HEQUIF_Vector, vt);
|
|
m_pXDataMap->SetAt(HVRV_Interface, i, xdatamap);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::GetInterFaceLocal(int nIndex, AcGePoint3d &pt) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return FALSE;
|
|
TDbXDataMap xdatamap;
|
|
if(m_pXDataMap->GetAt(HVRV_Interface, nIndex, xdatamap))
|
|
return xdatamap.GetAt(HEQUIF_Point, pt);
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::GetInterFaceLocal(int nIndex, int &nType) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return FALSE;
|
|
TDbXDataMap xdatamap;
|
|
if(m_pXDataMap->GetAt(HVRV_Interface, nIndex, xdatamap))
|
|
return xdatamap.GetAt(HEQUIF_Type, nType);
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::GetInterFaceLocal(int nIndex, AcGeVector3d &vt) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return FALSE;
|
|
TDbXDataMap xdatamap;
|
|
if(m_pXDataMap->GetAt(HVRV_Interface, nIndex, xdatamap))
|
|
return xdatamap.GetAt(HEQUIF_Vector, vt);
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::GetInterFaceLocal(int nIndex, CString &sName) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return FALSE;
|
|
TDbXDataMap xdatamap;
|
|
if(m_pXDataMap->GetAt(HVRV_Interface, nIndex, xdatamap))
|
|
return xdatamap.GetAt(HEQUIF_Name, sName);
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::GetInterFaceLocal(int nIndex, double &dWidth, double &dHeight) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return FALSE;
|
|
TDbXDataMap xdatamap;
|
|
double nw(0.0), nh(0.0);
|
|
if(m_pXDataMap->GetAt(HVRV_Interface, nIndex, xdatamap))
|
|
{
|
|
xdatamap.GetAt(HEQUIF_Width, nw);
|
|
xdatamap.GetAt(HEQUIF_Height, nh);
|
|
dWidth = nw;
|
|
dHeight = nh;
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::GetIFIndexFormPt(int &nIndex, const AcGePoint3d &pt) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
return FALSE;
|
|
TDbXDataMap xdatamap;
|
|
int iIfNum(0);
|
|
m_pXDataMap->GetAt(HVRV_InterfaceNum, iIfNum);
|
|
AcGePoint3d ptIF;
|
|
for (int i = 0; i < iIfNum; i++)
|
|
{
|
|
xdatamap.Empty();
|
|
m_pXDataMap->GetAt(HVRV_Interface, i, xdatamap);
|
|
xdatamap.GetAt(HEQUIF_Point, ptIF);
|
|
if(ptIF.distanceTo(pt) < 1.e-3)
|
|
{
|
|
//第一接口为设备位置点,所以需要+1
|
|
nIndex = i;
|
|
return TRUE;
|
|
}
|
|
}
|
|
nIndex = -1;
|
|
return FALSE;
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::getGeomExtents(AcDbExtents& extents) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::getClassID(CLSID* pClsid) const
|
|
{
|
|
//#if (ADS < 16)
|
|
// // {C7DFDF6A-A5F2-4add-ADCC-7AC0675AB6E8}
|
|
// CLSID CLSID_PipeBaseEntity = {0xC7DFDF6B, 0xA5F2, 0x4ADE, { 0xAD, 0xCC, 0x7A, 0xC0, 0x67, 0x5A, 0xB6, 0xE8 }};
|
|
//#endif
|
|
//
|
|
//#if (ADS == 16)
|
|
// // {C7DFDF6A-A5F2-4add-ADCC-7AC0675AB6E9}
|
|
// CLSID CLSID_PipeBaseEntity = {0xC7DFDF6B, 0xA5F2, 0x4ADE, { 0xAD, 0xCC, 0x7A, 0xC0, 0x67, 0x5A, 0xB6, 0xE9 }};
|
|
//#endif
|
|
//
|
|
//#if (ADS == 17)
|
|
// // {C7DFDF6A-A5F2-4add-ADCC-7AC0675AB6EA}
|
|
// CLSID CLSID_PipeBaseEntity = {0xC7DFDF6B, 0xA5F2, 0x4ADE, { 0xAD, 0xCC, 0x7A, 0xC0, 0x67, 0x5A, 0xB6, 0xEA }};
|
|
//#endif
|
|
//
|
|
//#if (ADS == 18)
|
|
// CLSID CLSID_PipeBaseEntity = {0xD7DFDF6B, 0xA5F2, 0x4ADE, { 0xAD, 0xCC, 0x7A, 0xC0, 0x67, 0x5A, 0xB6, 0xEB }};
|
|
//#endif
|
|
//
|
|
//#if (ADS == 19)
|
|
// CLSID CLSID_PipeBaseEntity = {0xD7DFDF6B, 0xA5F2, 0x4ADE, { 0xAD, 0xCC, 0x7A, 0xC0, 0x67, 0x5A, 0xB6, 0xEB }};
|
|
//#endif
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus THImpHvacVRVEqu::explode(AcDbVoidPtrArray& entitySet) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::HashInterFaceLine(AcDb::Visibility newVal) const
|
|
{
|
|
ASSERT(NULL != m_pXDataMap);
|
|
|
|
AcDbObjectId idBlock;
|
|
m_pXDataMap->GetAt(HVRV_PartCenter, idBlock);
|
|
if (!idBlock.isValid())
|
|
return FALSE;
|
|
|
|
AcDbObject *pObj = NULL;
|
|
Acad::ErrorStatus es = acdbOpenObject(pObj, idBlock, AcDb::kForRead);
|
|
|
|
if (es != Acad::eOk)
|
|
return FALSE;
|
|
AcDbBlockTableRecord *pBlock = AcDbBlockTableRecord::cast(pObj);
|
|
if (pBlock == NULL)
|
|
{
|
|
pObj->close();
|
|
return FALSE;
|
|
}
|
|
//迭代找到接口线,并隐藏
|
|
AcDbBlockTableRecordIterator* pIT = NULL;
|
|
pBlock->newIterator(pIT);
|
|
AcDbEntity* pEntIT = NULL;
|
|
AcDbEntity* pEnt = NULL;
|
|
resbuf *pXData = NULL;
|
|
//保证接口移动后,接口线也移动
|
|
int i(0);
|
|
AcGeVector3d vt;
|
|
AcGePoint3d pts, pte;
|
|
for (; !pIT->done(); pIT->step())
|
|
{
|
|
pIT->getEntity(pEnt, AcDb::kForRead);
|
|
if (pEnt == NULL)
|
|
{
|
|
continue;
|
|
}
|
|
AcDbLine *pLine = AcDbLine::cast(pEnt);
|
|
if (pLine == NULL)
|
|
{
|
|
pEnt->close();
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
int nCor = pLine->colorIndex();
|
|
double ddis = pLine->startPoint().distanceTo(pLine->endPoint());
|
|
//颜色是3长度是98
|
|
if (nCor == 3 && fabs(ddis - 98) < 1.e-3)
|
|
{
|
|
Acad::ErrorStatus es = pLine->upgradeOpen();
|
|
if (es == Acad::eOk)
|
|
{
|
|
pLine->setVisibility(newVal);
|
|
pts = pLine->startPoint();
|
|
pte = pLine->endPoint();
|
|
// GetInterFaceLocal(i,vt);
|
|
// GetInterFaceLocal(i,pts);
|
|
// vt.normalize();
|
|
// pte = pts + vt * ddis;
|
|
// pLine->setStartPoint(pts);
|
|
// pLine->setEndPoint(pte);
|
|
pLine->downgradeOpen();
|
|
i++;
|
|
}
|
|
}
|
|
pEnt->close();
|
|
continue;
|
|
}
|
|
}
|
|
delete pIT;
|
|
pObj->close();
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::OPMInfo(LPCTSTR pszName, TDb::OPMInfo* pInfo)
|
|
{
|
|
ASSERT(NULL != pszName && NULL != pInfo && NULL != m_pXDataMap);
|
|
// 暖通基本参数设置
|
|
if (0 == _tcsicmp(pszName, KEY_RUNTIME))
|
|
{
|
|
pInfo->bVisible = TRUE;
|
|
pInfo->bEditable = FALSE;
|
|
|
|
// 提供数据列表和对应关系
|
|
if (NULL != pInfo->parsValues && NULL != pInfo->parlValues)
|
|
{
|
|
pInfo->parsValues->Add(_T("多联机设备"));
|
|
pInfo->parlValues->Add(TDb::eVRVEqu);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
if (0 == _tcsicmp(pszName, HVRV_IType))
|
|
{
|
|
pInfo->bVisible = TRUE;
|
|
pInfo->bEditable = FALSE;
|
|
|
|
// 提供数据列表和对应关系
|
|
if (NULL != pInfo->parsValues && NULL != pInfo->parlValues)
|
|
{
|
|
pInfo->parlValues->Add(0);
|
|
pInfo->parsValues->Add(_T("室内机"));
|
|
pInfo->parlValues->Add(1);
|
|
pInfo->parsValues->Add(_T("室外机"));
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
if (0 == _tcsicmp(pszName, HVRV_SFactory))
|
|
{
|
|
pInfo->bVisible = TRUE;
|
|
pInfo->bEditable = FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
if (0 == _tcsicmp(pszName, HVRV_SModel))
|
|
{
|
|
pInfo->bVisible = TRUE;
|
|
pInfo->bEditable = FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
if (0 == _tcsicmp(pszName, HVRV_SOutdoor))
|
|
{
|
|
pInfo->bVisible = TRUE;
|
|
pInfo->bEditable = FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
if (0 == _tcsicmp(pszName, HVRV_Price))
|
|
{
|
|
pInfo->bVisible = TRUE;
|
|
pInfo->bEditable = FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
if (0 == _tcsicmp(pszName, KEY_StartPoint))
|
|
{
|
|
pInfo->bVisible = TRUE;
|
|
pInfo->bEditable = TRUE;
|
|
|
|
// 整体移动
|
|
if (NULL != pInfo->pXData && 0 != pInfo->pXData->nVt)
|
|
{
|
|
// 改变顶点变换行为
|
|
AcGePoint3d pt;
|
|
m_pXDataMap->GetAt(KEY_StartPoint, pt);
|
|
AcGeVector3d offset = asPnt3d(pInfo->pXData->dVal) - pt;
|
|
|
|
AcGeMatrix3d mat;
|
|
mat.setToTranslation(offset);
|
|
transformBy(mat);
|
|
pInfo->pXData->nVt = 0; // 设置处理完成标识
|
|
//TAuxTools::SetAndUpdateCover((TDbInterfacesObj*)m_pOwnerEnt, pszName, pInfo);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
int nType(0);
|
|
m_pXDataMap->GetAt(HVRV_IType, nType);
|
|
|
|
if (0 == _tcsicmp(pszName, KEY_ColdLoad) || 0 == _tcsicmp(pszName, KEY_HeatLoad)
|
|
|| 0 == _tcsicmp(pszName, KEY_ColdPower) || 0 == _tcsicmp(pszName, KEY_HeatPower)
|
|
|| 0 == _tcsicmp(pszName, KEY_MediaPipe)
|
|
|| (0 == _tcsicmp(pszName, KEY_WaterPipe) && 0 == nType)
|
|
|| (0 == _tcsicmp(pszName, KEY_MaxIndoor) && 1 == nType))
|
|
{
|
|
pInfo->bVisible = TRUE;
|
|
if (0 == _tcsicmp(pszName, KEY_ColdLoad))
|
|
pInfo->bEditable = TRUE;
|
|
else
|
|
pInfo->bEditable = FALSE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// 长/宽/高等比变化
|
|
if (0 == _tcsicmp(pszName, KEY_Length) || 0 == _tcsicmp(pszName, KEY_Width)
|
|
|| 0 == _tcsicmp(pszName, KEY_Thick))
|
|
{
|
|
pInfo->bVisible = TRUE;
|
|
pInfo->bEditable = FALSE;
|
|
// 替代属性,需要特殊处理数据获取和设置
|
|
// if (NULL != pInfo->pXData)
|
|
// {
|
|
// // 获取数据
|
|
// if (0 == pInfo->pXData->nVt)
|
|
// {
|
|
// m_pXDataMap->GetAt(pszName, *pInfo->pXData);
|
|
// pInfo->pXData->dVal[0] = fabs(pInfo->pXData->dVal[0]);
|
|
// }
|
|
// // 设置数据
|
|
// else
|
|
// {
|
|
// double dLen(1.0);
|
|
// m_pXDataMap->GetAt(pszName, dLen);
|
|
// if (pInfo->pXData->dVal[0] > 1e-3 && dLen > 1e-3)
|
|
// {
|
|
// AcGePoint3d ptCenter;
|
|
// m_pXDataMap->GetAt(HVRV_CenterPoint, ptCenter);
|
|
// double dScale = fabs(pInfo->pXData->dVal[0] / dLen);
|
|
// AcGeMatrix3d mat;
|
|
// mat.setToScaling(dScale, ptCenter);
|
|
// transformBy(mat);
|
|
// }
|
|
//
|
|
// pInfo->pXData->nVt = 0; // 设置处理完成标识
|
|
// }
|
|
// }
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
int THImpHvacVRVEqu::GetXBaseShell(TXShell& xShell)
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
// 获得参数
|
|
AcGeVector3d vtScale;
|
|
m_pXDataMap->GetAt(HVRV_Scale, vtScale);
|
|
double dWidth = 0.0;
|
|
m_pXDataMap->GetAt(HVRV_Width, dWidth);
|
|
double dThick = 0.0;
|
|
m_pXDataMap->GetAt(HVRV_Length, dThick);
|
|
double dLength = 0.0;
|
|
m_pXDataMap->GetAt(HVRV_Thick, dLength);
|
|
|
|
//dWidth *= vtScale.x;
|
|
//dThick *= vtScale.y;
|
|
//dLength *= vtScale.z;
|
|
|
|
AcGeVector3d vtNormal;
|
|
m_pXDataMap->GetAt(HVRV_MainDir, vtNormal);
|
|
vtNormal.normalize();
|
|
AcGeVector3d vt;
|
|
m_pXDataMap->GetAt(HVAC_Normal, vt);
|
|
vt.normalize();
|
|
AcGePoint3d ptStart;
|
|
m_pXDataMap->GetAt(HVRV_CenterPoint, ptStart);
|
|
AcGePoint3d ptEnd = ptStart + vt * dLength;
|
|
|
|
// 构造碰撞实体
|
|
TAuxTools::BuildRectDuct(ptStart, ptEnd, vtNormal, dWidth, dThick, dWidth, dThick, xShell);
|
|
|
|
return 1;
|
|
}
|
|
|
|
int THImpHvacVRVEqu::GetBodyBox( AcDbExtents& ext ) const
|
|
{
|
|
if (NULL == m_pXDataMap)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
// 获得参数
|
|
AcGeVector3d vtScale;
|
|
m_pXDataMap->GetAt(HVRV_Scale, vtScale);
|
|
double dWidth = 0.0;
|
|
m_pXDataMap->GetAt(HVRV_Width, dWidth);
|
|
double dHalfWidth = dWidth / 2.0;
|
|
double dThick = 0.0;
|
|
m_pXDataMap->GetAt(HVRV_Length, dThick);
|
|
double dHalfThick = dThick / 2.0;
|
|
double dLength = 0.0;
|
|
m_pXDataMap->GetAt(HVRV_Thick, dLength);
|
|
|
|
//dWidth *= vtScale.x;
|
|
//dThick *= vtScale.y;
|
|
//dLength *= vtScale.z;
|
|
|
|
AcGeVector3d vtNormal;
|
|
m_pXDataMap->GetAt(HVRV_MainDir, vtNormal);
|
|
vtNormal.normalize();
|
|
AcGeVector3d vt;
|
|
m_pXDataMap->GetAt(HVAC_Normal, vt);
|
|
vt.normalize();
|
|
AcGePoint3d ptStart;
|
|
m_pXDataMap->GetAt(HVRV_CenterPoint, ptStart);
|
|
AcGePoint3d ptEnd = ptStart + vt * dLength;
|
|
AcGeVector3d vtSide = vt;
|
|
vtSide.rotateBy(PI / 2.0, vtNormal);
|
|
vtSide.normalize();
|
|
|
|
// 计算端点
|
|
AcGePoint3dArray arpt;
|
|
arpt.append(ptStart + vtSide * dHalfWidth + vtNormal * dHalfThick);
|
|
arpt.append(ptStart + vtSide * dHalfWidth - vtNormal * dHalfThick);
|
|
arpt.append(ptStart - vtSide * dHalfWidth - vtNormal * dHalfThick);
|
|
arpt.append(ptStart - vtSide * dHalfWidth + vtNormal * dHalfThick);
|
|
arpt.append(ptEnd + vtSide * dHalfWidth + vtNormal * dHalfThick);
|
|
arpt.append(ptEnd + vtSide * dHalfWidth - vtNormal * dHalfThick);
|
|
arpt.append(ptEnd - vtSide * dHalfWidth - vtNormal * dHalfThick);
|
|
arpt.append(ptEnd - vtSide * dHalfWidth + vtNormal * dHalfThick);
|
|
|
|
// 构造最小包含体
|
|
TAuxTools::BuildMinRectangle(arpt, ext);
|
|
|
|
return 1;
|
|
}
|
|
|
|
BOOL THImpHvacVRVEqu::GetInterfaceFromXdata(const int& nIndex, const AcGeVector3d& vtOff) const
|
|
{
|
|
ASSERT(NULL != m_pXDataMap);
|
|
|
|
AcDbObjectId id2d(AcDbObjectId::kNull);
|
|
AcGeVector3d Scale3d;
|
|
m_pXDataMap->GetAt(HVRV_PartCenter,id2d);
|
|
m_pXDataMap->GetAt(HVRV_Scale,Scale3d);
|
|
AcDbBlockTableRecord *pObj;
|
|
if (acdbOpenObject(pObj, id2d, AcDb::kForRead)!=Acad::eOk)
|
|
{
|
|
AfxMessageBox(_T("打开图形失败!"));
|
|
return FALSE;
|
|
}
|
|
if (pObj == NULL)
|
|
return FALSE;
|
|
AcDbBlockTableRecordIterator* pIT = NULL;
|
|
pObj->newIterator(pIT);
|
|
AcDbEntity* pEnt = NULL;
|
|
resbuf *pXData = NULL;
|
|
for (pIT->start(); !pIT->done(); pIT->step())
|
|
{
|
|
pIT->getEntity(pEnt, AcDb::kForRead);
|
|
if (NULL == pEnt)
|
|
return FALSE;
|
|
pXData = pEnt->xData(_T("THLAYEQUIP_IF"));
|
|
if (pXData != NULL)
|
|
break;
|
|
}
|
|
pObj->close();
|
|
delete pIT;
|
|
if (pEnt != NULL)
|
|
pEnt->close();
|
|
AcGePoint3d pt;
|
|
int nIfNum(0);
|
|
if (pXData != NULL)
|
|
{
|
|
resbuf* pRb = pXData;
|
|
pRb = pRb->rbnext;
|
|
if (NULL != pRb && pRb->restype == 1070 )
|
|
nIfNum = pRb->resval.rint;
|
|
for (int i = 0; i < nIfNum; i++)
|
|
{
|
|
pRb = pRb->rbnext;
|
|
pRb = pRb->rbnext;
|
|
if (NULL != pRb && pRb->restype == 1011 )
|
|
{
|
|
pt[0] = pRb->resval.rpoint[0];
|
|
pt[1] = pRb->resval.rpoint[1];
|
|
pt[2] = 0;
|
|
}
|
|
pRb = pRb->rbnext;
|
|
if (i == nIndex - 1)
|
|
break;
|
|
}
|
|
acutRelRb(pXData);
|
|
}
|
|
OPENOBJ_BEGIN(id2d,AcDb::kForWrite,AcDbBlockTableRecord,pblk);
|
|
if (pblk == NULL)
|
|
return FALSE;
|
|
pblk->newIterator(pIT);
|
|
pEnt = NULL;
|
|
for (; !pIT->done(); pIT->step())
|
|
{
|
|
pIT->getEntity(pEnt, AcDb::kForWrite);
|
|
if (pEnt == NULL)
|
|
{
|
|
continue;
|
|
}
|
|
AcDbLine *pLine = AcDbLine::cast(pEnt);
|
|
if (pLine == NULL)
|
|
{
|
|
pEnt->close();
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
int nCor = pLine->colorIndex();
|
|
double ddis = pLine->startPoint().distanceTo(pLine->endPoint());
|
|
double ddisStr = pLine->startPoint().distanceTo(pt);
|
|
double ddisEnd = pLine->endPoint().distanceTo(pt);
|
|
//颜色是3长度是98
|
|
if (nCor == 3 && fabs(ddis - 98) < 1.e-3)
|
|
{
|
|
if (ddisStr < 1 || ddisEnd < 1)
|
|
{
|
|
AcGeMatrix3d mtx;
|
|
Scale3d.x *= vtOff.x;
|
|
Scale3d.y *= vtOff.y;
|
|
Scale3d.z = 0;
|
|
mtx.setTranslation(Scale3d);
|
|
pLine->transformBy(mtx);
|
|
pEnt->close();
|
|
return TRUE;
|
|
}
|
|
}
|
|
pEnt->close();
|
|
continue;
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
return FALSE;
|
|
}
|
|
|
|
// 导出XML
|
|
// CString THImpHvacVRVEqu::GetXml() const
|
|
// {
|
|
// if (NULL == m_pXDataMap || NULL == m_pOwnerEnt)
|
|
// return _T("");
|
|
//
|
|
// int nValue(0);
|
|
// double dValue(0.0);
|
|
// int nPtPreci = 6; // 位置精度
|
|
// int nWhPreci = 0; // 宽度、高度精度
|
|
//
|
|
// TXmlTree xmlTree;
|
|
// CString csText;
|
|
// CString csX, csY, csZ;
|
|
// AcGePoint3d pt;
|
|
// AcGeVector3d vt;
|
|
// AcDbObjectId id;
|
|
// POSITION posRoot = xmlTree.Insert(_T("ATS_DBHEQUIPMENT"), NULL, NULL);
|
|
// {
|
|
// xmlTree.SetAttribute(posRoot, _T("name"), _T("多联机"));
|
|
// xmlTree.SetAttribute(posRoot, _T("comment"), _T("上华对象名称,包含室内外机"));
|
|
// }
|
|
//
|
|
// POSITION posItemEquipType = xmlTree.Insert(_T("EquipType"), posRoot, NULL);
|
|
// {
|
|
// xmlTree.SetAttribute(posItemEquipType, _T("name"), _T("类型"));
|
|
// xmlTree.SetAttribute(posItemEquipType, _T("comment"), _T("多联机类型0:室内机,1:室外机"));
|
|
// m_pXDataMap->GetAt(HVRV_IType, nValue);
|
|
// csText.Format(_T("%d"), nValue);
|
|
// xmlTree.SetItemText(posItemEquipType, csText);
|
|
// }
|
|
//
|
|
// POSITION posItemEquipFct = xmlTree.Insert(_T("EquipFactory"), posRoot, posItemEquipType);
|
|
// {
|
|
// xmlTree.SetAttribute(posItemEquipFct, _T("name"), _T("厂商"));
|
|
// xmlTree.SetAttribute(posItemEquipFct, _T("comment"), _T("设备厂商"));
|
|
// m_pXDataMap->GetAt(HVRV_SFactory, csText);
|
|
// xmlTree.SetItemText(posItemEquipFct, csText);
|
|
// }
|
|
//
|
|
// POSITION posItemEquipSer = xmlTree.Insert(_T("EquipSeries"), posRoot, posItemEquipFct);
|
|
// {
|
|
// xmlTree.SetAttribute(posItemEquipSer, _T("name"), _T("系列"));
|
|
// xmlTree.SetAttribute(posItemEquipSer, _T("comment"), _T("产品系列"));
|
|
// m_pXDataMap->GetAt(HVRV_SType, csText);
|
|
// xmlTree.SetItemText(posItemEquipSer, csText);
|
|
// }
|
|
//
|
|
// POSITION posItemEquipMode = xmlTree.Insert(_T("EquipMode"), posRoot, posItemEquipSer);
|
|
// {
|
|
// xmlTree.SetAttribute(posItemEquipMode, _T("name"), _T("型号"));
|
|
// xmlTree.SetAttribute(posItemEquipMode, _T("comment"), _T("产品具体型号"));
|
|
// m_pXDataMap->GetAt(HVRV_SModel, csText);
|
|
// xmlTree.SetItemText(posItemEquipMode, csText);
|
|
// }
|
|
//
|
|
// POSITION posItemEquipPrice = xmlTree.Insert(_T("EquipPrice"), posRoot, posItemEquipMode);
|
|
// {
|
|
// xmlTree.SetAttribute(posItemEquipPrice, _T("name"), _T("价格"));
|
|
// xmlTree.SetAttribute(posItemEquipPrice, _T("comment"), _T("设备价格"));
|
|
// m_pXDataMap->GetAt(HVRV_Price, dValue);
|
|
// TAuxTools::DoubleToString(dValue, 2, csText);
|
|
// xmlTree.SetItemText(posItemEquipPrice, csText);
|
|
// }
|
|
//
|
|
// POSITION posItemNorDir = xmlTree.Insert(_T("NormalDir"),posRoot, posItemEquipPrice);
|
|
// {
|
|
// xmlTree.SetAttribute(posItemNorDir, _T("name"), _T("法向量"));
|
|
// m_pXDataMap->GetAt(HVAC_Normal, vt);
|
|
// TAuxTools::DoubleToString(vt.x, nPtPreci, csX);
|
|
// TAuxTools::DoubleToString(vt.y, nPtPreci, csY);
|
|
// TAuxTools::DoubleToString(vt.z, nPtPreci, csZ);
|
|
// csText.Format(_T("%s,%s,%s"), csX, csY, csZ);
|
|
// xmlTree.SetItemText(posItemNorDir, csText);
|
|
// }
|
|
//
|
|
// POSITION posItemCentPt = xmlTree.Insert(_T("CenterPoint"), posRoot, posItemNorDir);
|
|
// {
|
|
// xmlTree.SetAttribute(posItemCentPt, _T("name"), _T("中心点"));
|
|
// xmlTree.SetAttribute(posItemCentPt, _T("comment"), _T("布置点"));
|
|
// m_pXDataMap->GetAt(HVRV_CenterPoint, pt);
|
|
// TAuxTools::DoubleToString(pt.x, nPtPreci, csX);
|
|
// TAuxTools::DoubleToString(pt.y, nPtPreci, csY);
|
|
// TAuxTools::DoubleToString(pt.z, nPtPreci, csZ);
|
|
// csText.Format(_T("%s,%s,%s"), csX, csY, csZ);
|
|
// xmlTree.SetItemText(posItemCentPt, csText);
|
|
// }
|
|
//
|
|
// POSITION posItemMainDir = xmlTree.Insert(_T("MainDir"), posRoot, posItemCentPt);
|
|
// {
|
|
// xmlTree.SetAttribute(posItemMainDir, _T("name"), _T("主矢量"));
|
|
// xmlTree.SetAttribute(posItemMainDir, _T("comment"), _T("布置角度"));
|
|
// m_pXDataMap->GetAt(HVRV_MainDir, vt);
|
|
// TAuxTools::DoubleToString(vt.x, nPtPreci, csX);
|
|
// TAuxTools::DoubleToString(vt.y, nPtPreci, csY);
|
|
// TAuxTools::DoubleToString(vt.z, nPtPreci, csZ);
|
|
// csText.Format(_T("%s,%s,%s"), csX, csY, csZ);
|
|
// xmlTree.SetItemText(posItemMainDir, csText);
|
|
// }
|
|
//
|
|
// POSITION posItemPart2D = xmlTree.Insert(_T("Part2D"), posRoot, posItemMainDir);
|
|
// {
|
|
// xmlTree.SetAttribute(posItemPart2D, _T("name"), _T("2D块ID"));
|
|
// xmlTree.SetAttribute(posItemPart2D, _T("comment"), _T("平面图块"));
|
|
// m_pXDataMap->GetAt(HVRV_PartCenter, id);
|
|
// csText.Format(_T("%d"), id.asOldId());
|
|
// xmlTree.SetItemText(posItemPart2D, csText);
|
|
// }
|
|
//
|
|
// POSITION posItemPart3D = xmlTree.Insert(_T("Part3D"), posRoot, posItemPart2D);
|
|
// {
|
|
// xmlTree.SetAttribute(posItemPart3D, _T("name"), _T("3D块ID"));
|
|
// xmlTree.SetAttribute(posItemPart3D, _T("comment"), _T("三维图块"));
|
|
// m_pXDataMap->GetAt(HVRV_Part3D, id);
|
|
// csText.Format(_T("%d"), id.asOldId());
|
|
// xmlTree.SetItemText(posItemPart3D, csText);
|
|
// }
|
|
//
|
|
// POSITION posItemLength = xmlTree.Insert(_T("Length"), posRoot, posItemPart3D);
|
|
// {
|
|
// xmlTree.SetAttribute(posItemLength, _T("name"), _T("长度"));
|
|
// xmlTree.SetAttribute(posItemLength, _T("comment"), _T("设备长度"));
|
|
// m_pXDataMap->GetAt(HVRV_Length, dValue);
|
|
// TAuxTools::DoubleToString(dValue, nWhPreci, csText);
|
|
// xmlTree.SetItemText(posItemLength, csText);
|
|
// }
|
|
//
|
|
// POSITION posItemWidth = xmlTree.Insert(_T("Width"), posRoot, posItemLength);
|
|
// {
|
|
// xmlTree.SetAttribute(posItemWidth, _T("name"), _T("宽度"));
|
|
// xmlTree.SetAttribute(posItemWidth, _T("comment"), _T("设备宽度"));
|
|
// m_pXDataMap->GetAt(HVRV_Width, dValue);
|
|
// TAuxTools::DoubleToString(dValue, nWhPreci, csText);
|
|
// xmlTree.SetItemText(posItemWidth, csText);
|
|
// }
|
|
//
|
|
// POSITION posItemThick = xmlTree.Insert(_T("Thick"), posRoot, posItemWidth);
|
|
// {
|
|
// xmlTree.SetAttribute(posItemThick, _T("name"), _T("厚度"));
|
|
// xmlTree.SetAttribute(posItemThick, _T("comment"), _T("设备高度"));
|
|
// m_pXDataMap->GetAt(HVRV_Thick, dValue);
|
|
// TAuxTools::DoubleToString(dValue, nWhPreci, csText);
|
|
// xmlTree.SetItemText(posItemThick, csText);
|
|
// }
|
|
//
|
|
// POSITION posItemScale = xmlTree.Insert(_T("Scale"), posRoot, posItemThick);
|
|
// {
|
|
// xmlTree.SetAttribute(posItemScale, _T("name"), _T("图块比例"));
|
|
// xmlTree.SetAttribute(posItemScale, _T("comment"), _T("图块比例"));
|
|
// m_pXDataMap->GetAt(HVRV_Scale, vt);
|
|
// TAuxTools::DoubleToString(vt.x, nPtPreci, csX);
|
|
// TAuxTools::DoubleToString(vt.y, nPtPreci, csY);
|
|
// TAuxTools::DoubleToString(vt.z, nPtPreci, csZ);
|
|
// csText.Format(_T("%s,%s,%s"), csX, csY, csZ);
|
|
// xmlTree.SetItemText(posItemScale, csText);
|
|
// }
|
|
//
|
|
// CString csXml = xmlTree.GetXml();
|
|
//
|
|
// return csXml;
|
|
// }
|
|
|
|
CString THImpHvacVRVEqu::GetXml(const AcGeMatrix3d& mat) const
|
|
{
|
|
if (NULL == m_pXDataMap || NULL == m_pOwnerEnt)
|
|
return _T("");
|
|
|
|
int nValue(0);
|
|
double dValue(0.0);
|
|
int nPtPreci = 6; // 位置精度
|
|
int nWhPreci = 0; // 宽度、高度精度
|
|
|
|
TXmlTree xmlTree;
|
|
CString csText;
|
|
CString csX, csY, csZ;
|
|
AcGePoint3d pt;
|
|
AcGeVector3d vt;
|
|
AcDbObjectId id;
|
|
|
|
// 获得设备转换矩阵Lixl add 2012-2-1
|
|
// 插入点
|
|
XPoint ptLocation;
|
|
m_pXDataMap->GetAt(HVRV_CenterPoint, pt);
|
|
ptLocation = pt;
|
|
// 主方向
|
|
XVector3D vtDirection(0,0,1);
|
|
m_pXDataMap->GetAt(HVRV_MainDir, vt);
|
|
vtDirection = vt;
|
|
// 图块比例
|
|
m_pXDataMap->GetAt(HVRV_Scale, vt);
|
|
AcGeScale3d scale3d(vt.x, vt.y, vt.z);
|
|
XVector3D vtNormal(0,0,1);
|
|
//非水平面,计算法向
|
|
if(fabs(vtDirection.z) > 1.0E-6)
|
|
{
|
|
vtNormal = XVector3D(1,0,0)*vtDirection;
|
|
vtNormal.Normalize();
|
|
}
|
|
//计算ECS下的转角
|
|
XPoint ptLoc=Wcs2Ecs(ptLocation, vtNormal);
|
|
double nRotEcs = ads_angle(XPoint(),vtDirection);
|
|
m_pXDataMap->GetAt(HVRV_Part3D, id);
|
|
AcDbBlockReference block(ptLoc, id);
|
|
block.setRotation(nRotEcs);
|
|
block.setScaleFactors(scale3d);
|
|
AcGeMatrix3d mat1 = block.blockTransform();
|
|
mat1 *= mat;
|
|
CString sMat;
|
|
TAuxTools::Matrix3D2String(mat1, sMat);
|
|
|
|
POSITION posRoot = xmlTree.Insert(_T("ATS_DBHEQUIPMENT"), NULL, NULL);
|
|
{
|
|
xmlTree.SetAttribute(posRoot, _T("name"), _T("多联机"));
|
|
xmlTree.SetAttribute(posRoot, _T("comment"), _T("上华对象名称,包含室内外机"));
|
|
}
|
|
|
|
POSITION posItemEquipType = xmlTree.Insert(_T("EquipType"), posRoot, NULL);
|
|
{
|
|
xmlTree.SetAttribute(posItemEquipType, _T("name"), _T("类型"));
|
|
xmlTree.SetAttribute(posItemEquipType, _T("comment"), _T("多联机类型0:室内机,1:室外机"));
|
|
m_pXDataMap->GetAt(HVRV_IType, nValue);
|
|
csText.Format(_T("%d"), nValue);
|
|
xmlTree.SetItemText(posItemEquipType, csText);
|
|
}
|
|
|
|
POSITION posItemEquipFct = xmlTree.Insert(_T("EquipFactory"), posRoot, posItemEquipType);
|
|
{
|
|
xmlTree.SetAttribute(posItemEquipFct, _T("name"), _T("厂商"));
|
|
xmlTree.SetAttribute(posItemEquipFct, _T("comment"), _T("设备厂商"));
|
|
m_pXDataMap->GetAt(HVRV_SFactory, csText);
|
|
xmlTree.SetItemText(posItemEquipFct, csText);
|
|
}
|
|
|
|
POSITION posItemEquipSer = xmlTree.Insert(_T("EquipSeries"), posRoot, posItemEquipFct);
|
|
{
|
|
xmlTree.SetAttribute(posItemEquipSer, _T("name"), _T("系列"));
|
|
xmlTree.SetAttribute(posItemEquipSer, _T("comment"), _T("产品系列"));
|
|
m_pXDataMap->GetAt(HVRV_SType, csText);
|
|
xmlTree.SetItemText(posItemEquipSer, csText);
|
|
}
|
|
|
|
POSITION posItemEquipMode = xmlTree.Insert(_T("EquipMode"), posRoot, posItemEquipSer);
|
|
{
|
|
xmlTree.SetAttribute(posItemEquipMode, _T("name"), _T("型号"));
|
|
xmlTree.SetAttribute(posItemEquipMode, _T("comment"), _T("产品具体型号"));
|
|
m_pXDataMap->GetAt(HVRV_SModel, csText);
|
|
xmlTree.SetItemText(posItemEquipMode, csText);
|
|
}
|
|
|
|
POSITION posItemEquipPrice = xmlTree.Insert(_T("EquipPrice"), posRoot, posItemEquipMode);
|
|
{
|
|
xmlTree.SetAttribute(posItemEquipPrice, _T("name"), _T("价格"));
|
|
xmlTree.SetAttribute(posItemEquipPrice, _T("comment"), _T("设备价格"));
|
|
m_pXDataMap->GetAt(HVRV_Price, dValue);
|
|
TAuxTools::DoubleToString(dValue, 2, csText);
|
|
xmlTree.SetItemText(posItemEquipPrice, csText);
|
|
}
|
|
|
|
POSITION posItemNorDir = xmlTree.Insert(_T("NormalDir"),posRoot, posItemEquipPrice);
|
|
{
|
|
xmlTree.SetAttribute(posItemNorDir, _T("name"), _T("法向量"));
|
|
m_pXDataMap->GetAt(HVAC_Normal, vt);
|
|
TAuxTools::DoubleToString(vt.x, nPtPreci, csX);
|
|
TAuxTools::DoubleToString(vt.y, nPtPreci, csY);
|
|
TAuxTools::DoubleToString(vt.z, nPtPreci, csZ);
|
|
csText.Format(_T("%s,%s,%s"), csX, csY, csZ);
|
|
xmlTree.SetItemText(posItemNorDir, csText);
|
|
}
|
|
|
|
POSITION posItemCentPt = xmlTree.Insert(_T("CenterPoint"), posRoot, posItemNorDir);
|
|
{
|
|
xmlTree.SetAttribute(posItemCentPt, _T("name"), _T("中心点"));
|
|
xmlTree.SetAttribute(posItemCentPt, _T("comment"), _T("布置点"));
|
|
m_pXDataMap->GetAt(HVRV_CenterPoint, pt);
|
|
pt.transformBy(mat);
|
|
TAuxTools::DoubleToString(pt.x, nPtPreci, csX);
|
|
TAuxTools::DoubleToString(pt.y, nPtPreci, csY);
|
|
TAuxTools::DoubleToString(pt.z, nPtPreci, csZ);
|
|
csText.Format(_T("%s,%s,%s"), csX, csY, csZ);
|
|
xmlTree.SetItemText(posItemCentPt, csText);
|
|
}
|
|
|
|
POSITION posItemMainDir = xmlTree.Insert(_T("MainDir"), posRoot, posItemCentPt);
|
|
{
|
|
xmlTree.SetAttribute(posItemMainDir, _T("name"), _T("主矢量"));
|
|
xmlTree.SetAttribute(posItemMainDir, _T("comment"), _T("布置角度"));
|
|
m_pXDataMap->GetAt(HVRV_MainDir, vt);
|
|
TAuxTools::DoubleToString(vt.x, nPtPreci, csX);
|
|
TAuxTools::DoubleToString(vt.y, nPtPreci, csY);
|
|
TAuxTools::DoubleToString(vt.z, nPtPreci, csZ);
|
|
csText.Format(_T("%s,%s,%s"), csX, csY, csZ);
|
|
xmlTree.SetItemText(posItemMainDir, csText);
|
|
}
|
|
|
|
POSITION posItemPart2D = xmlTree.Insert(_T("Part2D"), posRoot, posItemMainDir);
|
|
{
|
|
xmlTree.SetAttribute(posItemPart2D, _T("name"), _T("2D块ID"));
|
|
xmlTree.SetAttribute(posItemPart2D, _T("comment"), _T("平面图块"));
|
|
m_pXDataMap->GetAt(HVRV_PartCenter, id);
|
|
csText.Format(_T("%d"), id.asOldId());
|
|
xmlTree.SetItemText(posItemPart2D, csText);
|
|
}
|
|
|
|
POSITION posItemPart3D = xmlTree.Insert(_T("Part3D"), posRoot, posItemPart2D);
|
|
{
|
|
xmlTree.SetAttribute(posItemPart3D, _T("name"), _T("3D块ID"));
|
|
xmlTree.SetAttribute(posItemPart3D, _T("comment"), _T("三维图块"));
|
|
m_pXDataMap->GetAt(HVRV_Part3D, id);
|
|
csText.Format(_T("%d"), id.asOldId());
|
|
xmlTree.SetItemText(posItemPart3D, csText);
|
|
}
|
|
|
|
POSITION posItemLength = xmlTree.Insert(_T("Length"), posRoot, posItemPart3D);
|
|
{
|
|
xmlTree.SetAttribute(posItemLength, _T("name"), _T("长度"));
|
|
xmlTree.SetAttribute(posItemLength, _T("comment"), _T("设备长度"));
|
|
m_pXDataMap->GetAt(HVRV_Length, dValue);
|
|
TAuxTools::DoubleToString(dValue, nWhPreci, csText);
|
|
xmlTree.SetItemText(posItemLength, csText);
|
|
}
|
|
|
|
POSITION posItemWidth = xmlTree.Insert(_T("Width"), posRoot, posItemLength);
|
|
{
|
|
xmlTree.SetAttribute(posItemWidth, _T("name"), _T("宽度"));
|
|
xmlTree.SetAttribute(posItemWidth, _T("comment"), _T("设备宽度"));
|
|
m_pXDataMap->GetAt(HVRV_Width, dValue);
|
|
TAuxTools::DoubleToString(dValue, nWhPreci, csText);
|
|
xmlTree.SetItemText(posItemWidth, csText);
|
|
}
|
|
|
|
POSITION posItemThick = xmlTree.Insert(_T("Thick"), posRoot, posItemWidth);
|
|
{
|
|
xmlTree.SetAttribute(posItemThick, _T("name"), _T("厚度"));
|
|
xmlTree.SetAttribute(posItemThick, _T("comment"), _T("设备高度"));
|
|
m_pXDataMap->GetAt(HVRV_Thick, dValue);
|
|
TAuxTools::DoubleToString(dValue, nWhPreci, csText);
|
|
xmlTree.SetItemText(posItemThick, csText);
|
|
}
|
|
|
|
POSITION posItemScale = xmlTree.Insert(_T("Scale"), posRoot, posItemThick);
|
|
{
|
|
xmlTree.SetAttribute(posItemScale, _T("name"), _T("图块比例"));
|
|
xmlTree.SetAttribute(posItemScale, _T("comment"), _T("图块比例"));
|
|
m_pXDataMap->GetAt(HVRV_Scale, vt);
|
|
TAuxTools::DoubleToString(vt.x, nPtPreci, csX);
|
|
TAuxTools::DoubleToString(vt.y, nPtPreci, csY);
|
|
TAuxTools::DoubleToString(vt.z, nPtPreci, csZ);
|
|
csText.Format(_T("%s,%s,%s"), csX, csY, csZ);
|
|
xmlTree.SetItemText(posItemScale, csText);
|
|
}
|
|
|
|
POSITION posItemMat= xmlTree.Insert(_T("Matrix3d"), posRoot, posItemScale);
|
|
{
|
|
xmlTree.SetAttribute(posItemMat, _T("name"), _T("矩阵"));
|
|
xmlTree.SetAttribute(posItemMat, _T("comment"), _T("图块转换矩阵"));
|
|
xmlTree.SetItemText(posItemMat, sMat);
|
|
}
|
|
|
|
CString csXml = xmlTree.GetXml();
|
|
|
|
return csXml;
|
|
}
|
|
|
|
// add by zh 2013-8-29 多联机各点捕捉
|
|
Acad::ErrorStatus THImpHvacVRVEqu::ExplodeOrDrawBlock2d(XExplodeDraw &mode) const
|
|
{
|
|
return ExplodeOrDraw2d(mode);
|
|
} |