Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

248 lines
6.2 KiB
C++

#include "stdafx.h"
#include "TInterfaceSizeReleationManger.h"
#include "TInterfaceReleationManager.h"
TInterfaceSizeReleationManger::TInterfaceSizeReleationManger()
{
}
TInterfaceSizeReleationManger::~TInterfaceSizeReleationManger()
{
}
void TInterfaceSizeReleationManger::TranslateSizeModifyMsg(const TInterfaceModifyMsg& msg,AcDbObjectIdArray& idOperOns)
{
CTempTolPipe tol(1.e-6);
AcDbObjectId idOn = msg.GetMsgOperateOn();
AcDbEntity* pEnt = NULL;
if ( idOn.isValid() && Acad::eOk == acdbOpenAcDbEntity(pEnt,idOn,AcDb::kForRead,true))
{
BOOL bClose = FALSE;
TDbInterfacesObj* pIObj = TDbInterfacesObj::cast(pEnt);
if (pIObj != NULL)
{
//执行size的操作
TransactSizeOperation(msg,idOperOns,pIObj,bClose);
}
if (!bClose) pEnt->close();
}
}
void TInterfaceSizeReleationManger::TransactSizeOperation(const TInterfaceModifyMsg& msg,AcDbObjectIdArray& idOperOns,
TDbInterfacesObj* pIObj,BOOL& bClose)
{
TInterfaces intfs;
AcDbObjectId idConnect,idFind;
TInterface pipeInterface;
AcDbEntity *pEntConnect = NULL;
if (pIObj != NULL)
{
int nCount = pIObj->GetInterfaceCount();
for (int i = 0;i < nCount;i++)
{
if (pIObj->GetInterface(i,pipeInterface))
{
intfs.append(pipeInterface);
}
}
pIObj->close();
bClose = TRUE;
}
for (int i = 0;i < intfs.length();i++)
{
pipeInterface = intfs.at(i);
idConnect = pipeInterface.GetConnectObject();
// 还需要检查接口的有效性
if (idConnect.isNull() || !Find2(pipeInterface.GetPosition()-msg.GetMoveGripOffset(),pipeInterface.GetOutDir(),idFind,pIObj->objectId()))
{
continue;
}
if ( idConnect.isValid() && Acad::eOk == acdbOpenAcDbEntity(pEntConnect,idConnect,AcDb::kForRead,true))
{
pEntConnect->close();
int nFind = -1;
//
if (idOperOns.find(idConnect,nFind))
{
//不需要处理
}
else
{
TInterfaceModifyMsg msgT = msg;
AcGePoint3d ptT = pipeInterface.GetPosition();
AcGeVector3d vecT = msg.GetMoveGripOffset();
ptT -= vecT;
msgT.SetMsgPoint(ptT);
msgT.SetMsgOperateOn(idConnect);
TransactCycleSizeMsg(msgT,idOperOns);
}
}
}
}
BOOL TInterfaceSizeReleationManger::TransactCycleSizeMsg(const TInterfaceModifyMsg& msg,AcDbObjectIdArray& idOperOns)
{
int nFoundAt = 0;
if (!idOperOns.find(msg.GetMsgOperateOn(),nFoundAt))
{
TInterfaceModifyMsgs idModiNewMsgs;
TDbInterfacesObj* pIObj2 = NULL;
AcDbEntity* pEnt2 = NULL;
if (Acad::eOk == acdbOpenAcDbEntity(pEnt2,msg.GetMsgOperateOn(),AcDb::kForWrite,true))
{
pIObj2 = TDbInterfacesObj::cast(pEnt2);
if (pIObj2 != NULL)
{
//发送通知尺寸更改消息
pIObj2->NotifyInterfaceToModify(msg,idModiNewMsgs);
idOperOns.append(msg.GetMsgOperateOn());
}
pEnt2->close();
}
//继续传递更改消息,当新的消息对象已经处理过时(在idOperOns内),不传递
TInterfaceModifyMsg msgT;
TDb::InterfaceOper eOper;
TInterfaceReleationManager intfRel;
for (int i = 0;i < idModiNewMsgs.length();i++)
{
msgT = idModiNewMsgs.at(i);
eOper = msgT.GetInterfaceOper();
if (eOper == TDb::eSize)
{
if (!idOperOns.find(msgT.GetMsgOperateOn(),nFoundAt))
{
TransactCycleSizeMsg(msgT,idOperOns);
idOperOns.append(msgT.GetMsgOperateOn());
}
}
else if (eOper == TDb::eMoveGripPoint)
{
intfRel.TranslateTransformByMsg(msgT,idOperOns);
}
}
}
return TRUE;
}
BOOL TInterfaceSizeReleationManger::Find2(const AcGePoint3d& ptCon,const AcGeVector3d& vtDir,AcDbObjectId& idFind,AcDbObjectId& idOwnerThis)
{
//到命名对象字典中找;
BOOL bSuccess = FALSE;
// add by hh 2011-08-09 接口记录从字典移动到数据库中
TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB();
if(NULL != pIntfRec)
{
// 通过数组找所有接口,一一查找验证。mcl changed 09.11.10
TInterfaces tIfArr;
TInterface pipeInterfaceFind;
pIntfRec->Find(ptCon, tIfArr);
int i(0);
for (i = 0; i < tIfArr.length(); i++)
{
pipeInterfaceFind = tIfArr[i];
idFind = pipeInterfaceFind.GetConnectObject();
// 排除空id及自身接口
if (idFind.isValid() && idFind.asOldId() != idOwnerThis.asOldId())
{
bSuccess = TRUE;
break;
}
else
{
idFind = pipeInterfaceFind.GetOwnerId();
if (idFind.isValid() && idFind.asOldId() != idOwnerThis.asOldId())
{
bSuccess = TRUE;
break;
}
}
}
pIntfRec->close();
return bSuccess;
}
// add end
AcDbDictionary* pNamedDict = NULL;
if (Acad::eOk == acdbCurDwg()->getNamedObjectsDictionary(pNamedDict,AcDb::kForRead))
{
AcDbDictionary* pDict = NULL;
if (Acad::eOk == pNamedDict->getAt(KEY_IRECORD,(AcDbObject*&)pDict,AcDb::kForRead))
{
pNamedDict->close();
TDbInterfaceRecord* pInterfaceRec = NULL;
if (Acad::eOk == pDict->getAt(KEY_IRECORD,(AcDbObject*&)pInterfaceRec,AcDb::kForRead))
{
pDict->close();
//修改原因 : 需要得到改点的多个接口
//修改 : mcl changed 09.11.10
/*TInterface pipeInterface2;
bSuccess = pInterfaceRec->Find(ptCon,vtDir,pipeInterface2);
if (bSuccess)
{
//1. 排除此地是自身[如管子端点拉到中点后] 2. 找到连接对象有效
idFind = pipeInterface2.GetConnectObject();
if (!idFind.isValid() || idFind.asOldId() == idOwnerThis.asOldId()) bSuccess = FALSE;
if (!bSuccess)
{
idFind = pipeInterface2.GetOwnerId();
if (idFind.isValid() && idFind.asOldId() != idOwnerThis.asOldId())
bSuccess = TRUE;
}
}*/
// 通过数组找所有接口,一一查找验证。mcl changed 09.11.10
TInterfaces tIfArr;
TInterface pipeInterfaceFind;
pInterfaceRec->Find(ptCon, tIfArr);
int i(0);
for (i = 0; i < tIfArr.length(); i++)
{
pipeInterfaceFind = tIfArr[i];
idFind = pipeInterfaceFind.GetConnectObject();
// 排除空id及自身接口
if (idFind.isValid() && idFind.asOldId() != idOwnerThis.asOldId())
{
bSuccess = TRUE;
break;
}
else
{
idFind = pipeInterfaceFind.GetOwnerId();
if (idFind.isValid() && idFind.asOldId() != idOwnerThis.asOldId())
{
bSuccess = TRUE;
break;
}
}
}
pInterfaceRec->close();
}
else
{
pDict->close();
}
}
else
{
pNamedDict->close();
}
}
return bSuccess;
}