#include "stdafx.h" #include "TInterfaceTransformByManager.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif TInterfaceTransformByManager::TInterfaceTransformByManager() { } TInterfaceTransformByManager::~TInterfaceTransformByManager() { } void TInterfaceTransformByManager::TranslateTransformByMsg(const TInterfaceModifyMsg& msg,AcDbObjectIdArray& idOperOns) { AcDbObjectId idOn = msg.GetMsgOperateOn(); AcDbEntity* pEnt = NULL; CString sIsAssoc = _T("0");; GetGlobalContext(KEY_MOVEASS,sIsAssoc); // 1. 移动桥架关联拉伸 没有设置 if (sIsAssoc.CompareNoCase(_T("0")) == 0) { TranslateMoveOperationMsg(msg); return; } // 2. 移动桥架关联拉伸,但新位置寻求可能新关系建立 TInterfaceModifyMsg msgT; if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,idOn,AcDb::kForRead,true)) { TDbInterfacesObj* pIObj = TDbInterfacesObj::cast(pEnt); if (pIObj != NULL) { AcDbObjectId idCon,idCon2,idOwner; TInterface pipeInterface,pipeInterfaceOther; int nCount = pIObj->GetInterfaceCount(); for (int i = 0;i < nCount;i++) { pipeInterface.Reset(); if ( pIObj->GetInterface(i,pipeInterface) ) { idCon = pipeInterface.GetConnectObject(); idOwner = pipeInterface.GetOwnerId(); if (idCon.isNull()) { TranslateMoveOperationMsg(pIObj,pipeInterface); continue; } int nFoundAt = -1; if (idOperOns.find(idCon,nFoundAt) ) //不处理 { } else { //变换前的对方的接口,调整关系方向 pipeInterfaceOther = pipeInterface; pipeInterfaceOther.OtherBeforeTransformBy(msg); if (Find(pipeInterfaceOther))//确认两接口在变换前吻合 { // 定义消息,设置消息作用点,作用对象 msgT = msg; // 找到本对象的接口,[注该接口已经在其transform调用更改了] // 而连接对象的接口点没有更改,调整消息作用点到原来连接点 // 以便消息准确的按消息作用点传递 AcGeMatrix3d xform = msg.GetTransform(); xform.invert(); AcGePoint3d pTe = pipeInterface.GetPosition(); pTe.transformBy(xform); msgT.SetMsgPoint(pTe); msgT.SetMsgOperateOn(pipeInterfaceOther.GetOwnerId()); NotifyInterfaceToModify(msgT,idOperOns); } else //判断是否有 T 型的可能性,或新位置建立关系 { TranslateMoveOperationMsg(pIObj,pipeInterface); } } } } } pEnt->close(); } } void TInterfaceTransformByManager::TranslateMoveOperationMsg(const TInterfaceModifyMsg& msg) { AcDbObjectId idOn = msg.GetMsgOperateOn(); AcDbEntity* pEnt = NULL; if (idOn.isValid() && Acad::eOk == acdbOpenAcDbEntity(pEnt,idOn,AcDb::kForRead)) { TDbInterfacesObj* pIObj = TDbInterfacesObj::cast(pEnt); if (pIObj != NULL) { TInterface pipeInterface; int nCount = pIObj->GetInterfaceCount(); for (int i = 0;i < nCount;i++) { pipeInterface.Reset(); if ( pIObj->GetInterface(i,pipeInterface) ) { TranslateMoveOperationMsg(pIObj,pipeInterface); } } } pEnt->close(); } } void TInterfaceTransformByManager::TranslateMoveOperationMsg(TDbInterfacesObj* pIObj,const TInterfaceModifyMsg& msg) { TInterface pipeInterface; pIObj->GetInterface(0,pipeInterface); //1.判断新位置是否有新的接口吻合连接 AcDbObjectId idFind1,idFind2; BOOL bSuccess = Find(pipeInterface.GetPosition(),pipeInterface.GetOutDir(),idFind1,idFind2,pIObj->objectId()); if (bSuccess) { if (idFind1.isValid())//一个接口 { //建立idOwner,idFind1 的一对接口关系 TInterface pipeInterface; pIObj->GetInterface(0,pipeInterface); //建立关联关系 if (pIObj->isWriteEnabled()) { pIObj->SetInterfaceRelation(pipeInterface.GetPosition(),idFind1); } else if (Acad::eOk == pIObj->upgradeOpen()) { pIObj->SetInterfaceRelation(pipeInterface.GetPosition(),idFind1); pIObj->downgradeOpen(); } //更新接口关系 pipeInterface.SetOwnerId(pIObj->objectId()); pipeInterface.SetConnectObject(idFind1); Update(pipeInterface); TInterface pipeInterfaceOther; pipeInterfaceOther.SetOwnerId(idFind1); pipeInterfaceOther.SetPosition(pipeInterface.GetPosition()); pipeInterfaceOther.SetOutDir(-pipeInterface.GetOutDir()); pipeInterfaceOther.SetConnectObject(pIObj->objectId()); SetInterfaceRelation(acdbCurDwg(),pipeInterfaceOther); } } else //该位置没有接口; 判断是否有 T 型的可能性,断开对方三通连接 { TInterface pipeInterface; pIObj->GetInterface(0,pipeInterface); pipeInterface.SetConnectObject(AcDbObjectId::kNull); Update2(pipeInterface,AcDbObjectId::kNull,AcDbObjectId::kNull); AcGeMatrix3d xform = msg.GetTransform(); AcGePoint3d ptPos = pipeInterface.GetPosition(); AcGeVector3d vtDir = pipeInterface.GetOutDir(); xform.invert(); ptPos.transformBy(xform); vtDir.transformBy(xform); BOOL bSuccess1 = Find(ptPos,vtDir,idFind1,pIObj->objectId()); BOOL bSuccess2 = Find(ptPos,vtDir,idFind2,idFind1); if (bSuccess1 && bSuccess2) { //iRecord 中建立 idFind1-idFind2关联关系 //更新接口关系 TInterface pipeInterface; pipeInterface.SetPosition(ptPos); pipeInterface.SetOutDir(vtDir); pipeInterface.SetOwnerId(idFind1); pipeInterface.SetConnectObject(idFind2); SetInterfaceRelation(acdbCurDwg(),pipeInterface); //更新接口关系 pipeInterface.SetPosition(ptPos); pipeInterface.SetOutDir(vtDir); pipeInterface.SetOwnerId(idFind2); pipeInterface.SetConnectObject(idFind1); SetInterfaceRelation(acdbCurDwg(),pipeInterface); } else { //主要是寻找管子对象 //TryGetPerpPipeToTeeConnect(pIObj,pipeInterface); } } } void TInterfaceTransformByManager::TranslateMoveOperationMsg(TDbInterfacesObj* pIObj,TInterface& pipeInterface) { AcDbObjectId idOwner = pipeInterface.GetOwnerId(); AcDbObjectId idFind1,idCon1; //1.判断新位置是否有新的接口吻合连接 BOOL nSuccess = Find(pipeInterface.GetPosition(),pipeInterface.GetOutDir(),idFind1,idOwner); if (nSuccess) { //建立关联关系 Adesk::Boolean bWrite = TRUE; if (pIObj->isWriteEnabled()) { pIObj->SetInterfaceRelation(pipeInterface.GetPosition(),idFind1); } else if (Acad::eOk == pIObj->upgradeOpen()) { pIObj->SetInterfaceRelation(pipeInterface.GetPosition(),idFind1); pIObj->downgradeOpen(); } //更新接口关系 pipeInterface.SetOwnerId(pIObj->objectId()); pipeInterface.SetConnectObject(idFind1); Update(pipeInterface); TInterface pipeInterfaceOther; pipeInterfaceOther.SetOwnerId(idFind1); pipeInterfaceOther.SetPosition(pipeInterface.GetPosition()); pipeInterfaceOther.SetOutDir(-pipeInterface.GetOutDir()); pipeInterfaceOther.SetConnectObject(pipeInterface.GetOwnerId()); SetInterfaceRelation(acdbCurDwg(),pipeInterfaceOther); } else //该位置没有接口; 判断是否有 T 型的可能性,断开对方三通连接 { //主要是寻找管子对象 TryGetPerpPipeToTeeConnect(pIObj,pipeInterface); } } void TInterfaceTransformByManager::TryGetPerpPipeToTeeConnect(TDbInterfacesObj* pIObj,TInterface& pipeInterface) { } void TInterfaceTransformByManager::NotifyInterfaceToModify(TInterfaceModifyMsg& msg,AcDbObjectIdArray& idOperOns) { int nFoundAt = 0; if (!idOperOns.find(msg.GetMsgOperateOn(),nFoundAt)) { TInterfaceModifyMsgs idModiNewMsgs; TDbInterfacesObj* pIObj2 = NULL; AcDbEntity* pEnt2 = NULL; if (msg.GetMsgOperateOn().isValid() && Acad::eOk == acdbOpenAcDbEntity(pEnt2,msg.GetMsgOperateOn(),AcDb::kForWrite)) { pIObj2 = TDbInterfacesObj::cast(pEnt2); if (pIObj2 != NULL) { pIObj2->NotifyInterfaceToModify(msg,idModiNewMsgs); idOperOns.append(msg.GetMsgOperateOn()); } pEnt2->close(); } //继续传递更改消息,当新的消息对象已经处理过时(在idOperOns内),不传递 TInterfaceModifyMsg msgT; for (int i = 0;i < idModiNewMsgs.length();i++) { msgT = idModiNewMsgs.at(i); if (!idOperOns.find(msgT.GetMsgOperateOn(),nFoundAt)) { NotifyInterfaceToModify(msgT,idOperOns); idOperOns.append(msgT.GetMsgOperateOn()); } } } } BOOL TInterfaceTransformByManager::Find(const TInterface& pipeInterface) { //到命名对象字典中找; BOOL bSuccess = FALSE; // add by hh 2011-08-09 接口记录从字典移动到数据库中 TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB(); if(NULL != pIntfRec) { AcGePoint3d ptCon = pipeInterface.GetPosition(); AcGeVector3d vtDir = pipeInterface.GetOutDir(); AcDbObjectId idCon = pipeInterface.GetConnectObject(); AcDbObjectId idOwner = pipeInterface.GetOwnerId(); TInterface pipeInterface2; bSuccess = pIntfRec->Find(ptCon,vtDir,idOwner,pipeInterface2); if (bSuccess && pipeInterface2.GetConnectObject() == idCon && !idCon.isNull()) { } else bSuccess = FALSE; 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(); AcGePoint3d ptCon = pipeInterface.GetPosition(); AcGeVector3d vtDir = pipeInterface.GetOutDir(); AcDbObjectId idCon = pipeInterface.GetConnectObject(); AcDbObjectId idOwner = pipeInterface.GetOwnerId(); TInterface pipeInterface2; bSuccess = pInterfaceRec->Find(ptCon,vtDir,idOwner,pipeInterface2); if (bSuccess && pipeInterface2.GetConnectObject() == idCon && !idCon.isNull()) { } else { bSuccess = FALSE; } pInterfaceRec->close(); } else { pDict->close(); } } else { pNamedDict->close(); } } return bSuccess; } BOOL TInterfaceTransformByManager::Find(const AcGePoint3d& ptCon,const AcGeVector3d& vtDir, AcDbObjectId& idFind,const AcDbObjectId& idOwnerNotMe) { //到命名对象字典中找; BOOL bSuccess = FALSE; // add by hh 2011-08-09 接口记录从字典移动到数据库中 TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB(); if(NULL != pIntfRec) { TInterface pipeInterface2; bSuccess = pIntfRec->FindOtherSide(ptCon,vtDir,pipeInterface2,idOwnerNotMe); if (bSuccess) { idFind = pipeInterface2.GetOwnerId(); AcDbObjectId idCon = pipeInterface2.GetConnectObject(); if (!idCon.isNull()) { //反过来以 connect 为 owner 找,验证 idCon,idFind是有效关联关系 bSuccess = pIntfRec->Find(ptCon,vtDir,idCon,pipeInterface2); if (bSuccess && pipeInterface2.GetConnectObject() == idFind && !idFind.isNull() && idFind != idOwnerNotMe) { //是有效关系:ptCon,vtDir位置没有空余接口找到 bSuccess = FALSE; } idFind = idCon; } } 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(); TInterface pipeInterface2; bSuccess = pInterfaceRec->FindOtherSide(ptCon,vtDir,pipeInterface2,idOwnerNotMe); if (bSuccess) { idFind = pipeInterface2.GetOwnerId(); AcDbObjectId idCon = pipeInterface2.GetConnectObject(); if (!idCon.isNull()) { //反过来以 connect 为 owner 找,验证 idCon,idFind是有效关联关系 bSuccess = pInterfaceRec->Find(ptCon,vtDir,idCon,pipeInterface2); if (bSuccess && pipeInterface2.GetConnectObject() == idFind && !idFind.isNull() && idFind != idOwnerNotMe) { //是有效关系:ptCon,vtDir位置没有空余接口找到 bSuccess = FALSE; } idFind = idCon; } } pInterfaceRec->close(); } else { pDict->close(); } } else { pNamedDict->close(); } } return bSuccess; } int TInterfaceTransformByManager::Find( const AcGePoint3d& ptCon,const AcGeVector3d& vtDir, AcDbObjectId& idFind1,AcDbObjectId& idFind2, const AcDbObjectId& idOwnerNotMe) { int bSuccess = 0; // add by hh 2011-08-09 接口记录从字典移动到数据库中 TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB(); if(NULL != pIntfRec) { TInterface pipeInterface1,pipeInterface2; bSuccess = pIntfRec->FindOtherSide(ptCon,vtDir,pipeInterface1,pipeInterface2,idOwnerNotMe); if (bSuccess) { idFind1 = pipeInterface1.GetOwnerId(); idFind2 = pipeInterface2.GetOwnerId(); AcDbObjectId idCon1 = pipeInterface1.GetConnectObject(); AcDbObjectId idCon2 = pipeInterface2.GetConnectObject(); bSuccess = FALSE; BOOL bSuccess1 = FALSE,bSuccess2 = NULL; if (idFind1.isValid() && idFind2.isValid()) //初步发现ptCon,vtDir 有一对接口连接了 { //对对方逐一进行反方向验证是否可以建立关系 AcDbEntity* pEnt = NULL; TDbInterfacesObj* pIObj = NULL; if (idCon1.isValid() && Acad::eOk == acdbOpenAcDbEntity(pEnt,idCon1,AcDb::kForRead)) { pIObj = TDbInterfacesObj::cast(pEnt); if (pIObj != NULL) { bSuccess1 = pIObj->HasInterface(ptCon,vtDir); } pEnt->close(); } //验证2是否建立关系 if (idCon2.isValid() && Acad::eOk == acdbOpenAcDbEntity(pEnt,idCon2,AcDb::kForRead)) { pIObj = TDbInterfacesObj::cast(pEnt); if (pIObj != NULL) { bSuccess2 = pIObj->HasInterface(ptCon,vtDir); } pEnt->close(); } if (bSuccess1 && bSuccess2) { bSuccess = 2; idFind1 = idCon1; idFind2 = idCon2; } } else { if (idFind1.isValid()) pipeInterface2 = pipeInterface1; else idFind1 = pipeInterface2.GetOwnerId(); AcDbObjectId idCon = pipeInterface2.GetConnectObject(); if (!idCon.isNull()) { //反过来以 connect 为 owner 找,验证 idCon,idFind是有效关联关系 bSuccess = pIntfRec->Find(ptCon,vtDir,idCon,pipeInterface2); if (bSuccess && pipeInterface2.GetConnectObject() == idFind1 && !idFind1.isNull() && idFind1 != idOwnerNotMe) { //是有效关系:ptCon,vtDir位置没有空余接口找到 bSuccess = 0; } idFind1 = idCon; } } } 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(); TInterface pipeInterface1,pipeInterface2; bSuccess = pInterfaceRec->FindOtherSide(ptCon,vtDir,pipeInterface1,pipeInterface2,idOwnerNotMe); if (bSuccess) { idFind1 = pipeInterface1.GetOwnerId(); idFind2 = pipeInterface2.GetOwnerId(); AcDbObjectId idCon1 = pipeInterface1.GetConnectObject(); AcDbObjectId idCon2 = pipeInterface2.GetConnectObject(); bSuccess = FALSE; BOOL bSuccess1 = FALSE,bSuccess2 = NULL; if (idFind1.isValid() && idFind2.isValid()) //初步发现ptCon,vtDir 有一对接口连接了 { //对对方逐一进行反方向验证是否可以建立关系 AcDbEntity* pEnt = NULL; TDbInterfacesObj* pIObj = NULL; if (idCon1.isValid() && Acad::eOk == acdbOpenAcDbEntity(pEnt,idCon1,AcDb::kForRead)) { pIObj = TDbInterfacesObj::cast(pEnt); if (pIObj != NULL) { bSuccess1 = pIObj->HasInterface(ptCon,vtDir); } pEnt->close(); } //验证2是否建立关系 if (idCon2.isValid() && Acad::eOk == acdbOpenAcDbEntity(pEnt,idCon2,AcDb::kForRead)) { pIObj = TDbInterfacesObj::cast(pEnt); if (pIObj != NULL) { bSuccess2 = pIObj->HasInterface(ptCon,vtDir); } pEnt->close(); } if (bSuccess1 && bSuccess2) { bSuccess = 2; idFind1 = idCon1; idFind2 = idCon2; } } else { if (idFind1.isValid()) { pipeInterface2 = pipeInterface1; } else { idFind1 = pipeInterface2.GetOwnerId(); } AcDbObjectId idCon = pipeInterface2.GetConnectObject(); if (!idCon.isNull()) { //反过来以 connect 为 owner 找,验证 idCon,idFind是有效关联关系 bSuccess = pInterfaceRec->Find(ptCon,vtDir,idCon,pipeInterface2); if (bSuccess && pipeInterface2.GetConnectObject() == idFind1 && !idFind1.isNull() && idFind1 != idOwnerNotMe) { //是有效关系:ptCon,vtDir位置没有空余接口找到 bSuccess = 0; } idFind1 = idCon; } } } pInterfaceRec->close(); } else { pDict->close(); } } else { pNamedDict->close(); } } return bSuccess; } BOOL TInterfaceTransformByManager::SetInterfaceRelation(const AcDbDatabase* pDb,const TInterface& pipeInterface,AcDbObjectId idCon2) { AcDbEntity* pEnt = NULL; if (pipeInterface.GetOwnerId().isValid() && Acad::eOk == acdbOpenAcDbEntity(pEnt,pipeInterface.GetOwnerId(),AcDb::kForWrite)) { TDbInterfacesObj* pIObj = TDbInterfacesObj::cast(pEnt); if (pIObj != NULL) { if (idCon2.isNull()) { pIObj->SetInterfaceRelation(pipeInterface.GetPosition(),pipeInterface.GetConnectObject()); } else { pIObj->SetInterfaceRelation(pipeInterface.GetPosition(),pipeInterface.GetConnectObject(),idCon2); } } pEnt->close(); } // add by hh 2011-08-09 接口记录从字典移动到数据库中 TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB(); if(NULL != pIntfRec) { if(Acad::eOk == pIntfRec->upgradeOpen()) { if (idCon2.isNull()) pIntfRec->Update(pipeInterface.GetOwnerId(),pipeInterface.GetPosition(),pipeInterface.GetConnectObject()); else pIntfRec->Update(pipeInterface.GetOwnerId(),pipeInterface.GetPosition(),pipeInterface.GetConnectObject(),idCon2); pIntfRec->downgradeOpen(); } pIntfRec->close(); return TRUE; } // add end AcDbDictionary* pNamedDict = NULL; if (Acad::eOk == ((AcDbDatabase*)pDb)->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::kForWrite)) { pDict->close(); if (idCon2.isNull()) pInterfaceRec->Update(pipeInterface.GetOwnerId(),pipeInterface.GetPosition(),pipeInterface.GetConnectObject()); else pInterfaceRec->Update(pipeInterface.GetOwnerId(),pipeInterface.GetPosition(),pipeInterface.GetConnectObject(),idCon2); pInterfaceRec->close(); } else { pDict->close(); } } else { pNamedDict->close(); } } return TRUE; } BOOL TInterfaceTransformByManager::Update(const TInterface& pipeInterface) { // add by hh 2011-08-09 接口记录从字典移动到数据库中 TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB(); if(NULL != pIntfRec) { if(Acad::eOk == pIntfRec->upgradeOpen()) { pIntfRec->Update(pipeInterface.GetOwnerId(),pipeInterface.GetPosition(),pipeInterface.GetConnectObject()); pIntfRec->downgradeOpen(); } pIntfRec->close(); return TRUE; } // 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::kForWrite)) { pDict->close(); pInterfaceRec->Update(pipeInterface.GetOwnerId(),pipeInterface.GetPosition(),pipeInterface.GetConnectObject()); pInterfaceRec->close(); } else { pDict->close(); } } else { pNamedDict->close(); } } return TRUE; } BOOL TInterfaceTransformByManager::Update2(const TInterface& pipeInterface,const AcDbObjectId& idCon1,const AcDbObjectId& idCon2) { // add by hh 2011-08-09 接口记录从字典移动到数据库中 TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB(); if(NULL != pIntfRec) { if(Acad::eOk == pIntfRec->upgradeOpen()) { pIntfRec->Update(pipeInterface.GetOwnerId(),pipeInterface.GetPosition(),idCon1,idCon2); pIntfRec->downgradeOpen(); } pIntfRec->close(); return TRUE; } // 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::kForWrite)) { pDict->close(); pInterfaceRec->Update(pipeInterface.GetOwnerId(),pipeInterface.GetPosition(),idCon1,idCon2); pInterfaceRec->close(); } else { pDict->close(); } } else { pNamedDict->close(); } } return TRUE; } BOOL TInterfaceTransformByManager::Update(const TInterface& pipeInterface,const AcDbObjectId& idConnectAlso) { // add by hh 2011-08-09 接口记录从字典移动到数据库中 TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB(); if(NULL != pIntfRec) { if(Acad::eOk == pIntfRec->upgradeOpen()) { pIntfRec->Update(pipeInterface.GetOwnerId(),pipeInterface.GetPosition(),pipeInterface.GetConnectObject(),idConnectAlso); pIntfRec->downgradeOpen(); } pIntfRec->close(); return TRUE; } // 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::kForWrite)) { pDict->close(); pInterfaceRec->Update(pipeInterface.GetOwnerId(),pipeInterface.GetPosition(),pipeInterface.GetConnectObject(),idConnectAlso); pInterfaceRec->close(); } else { pDict->close(); } } else { pNamedDict->close(); } } return TRUE; }