Files
envi-code/SourceCode/Code2026/tg_shs/shs_pipebase/TDbInterfacesObj.cpp
T
2026-09-28 15:28:50 +08:00

1230 lines
27 KiB
C++

#include "StdAfx.h"
#include "StdArx.h"
#include "dbproxy.h"
#include "geassign.h"
#include "acgi.h"
#include "dbcfilrs.h"
#include "TDbInterfaceMsgWrite.h"
#include "TCoverBooleanOper.h"
#include "TCoverReleationManager.h"
#include "TInterfaceModifyMsgContext.h"
#define VERSION_TDBINTERFACESOBJ 1
extern TDbRelInterfaceReactor* g_pRelInterfaceReactor;
extern void MakeSureDbHasAssocReactor(AcDbDatabase* pDb,TToolKitBase* pToolKit);
extern TInterfaceModifyMsgContext g_iMsgContext;
//{{AFX_ARX_MACRO
ACRX_DXF_DEFINE_MEMBERS(TDbInterfacesObj, TDbCurveEntity,
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
AcDbProxyEntity::kAllAllowedBits,
ATS_INTERFACESOBJ, "图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
//}}AFX_ARX_MACRO
IMPLEMENT_TENTBASE(TDbInterfacesObj);
TDbInterfacesObj::TDbInterfacesObj()
{
//{{AFX_ARX_DATA_INIT(TDbInterfacesObj)
//}}AFX_ARX_DATA_INIT
}
TDbInterfacesObj::~TDbInterfacesObj()
{
}
BOOL TDbInterfacesObj::GetInterface(int nIndex,TInterface& pipeInterface) const
{
return FALSE;
}
BOOL TDbInterfacesObj::GetInterface(const AcGePoint3d& ptCon,TInterface& pipeInterface) const
{
return FALSE;
}
BOOL TDbInterfacesObj::HasInterface(const AcGePoint3d& ptCon,const AcGeVector3d& vtDir)
{
return FALSE;
}
int TDbInterfacesObj::GetInterfaceCount() const
{
return 0;
}
BOOL TDbInterfacesObj::SetInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
{
return FALSE;
}
BOOL TDbInterfacesObj::SetInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect1,const AcDbObjectId& idConnect2)
{
return FALSE;
}
BOOL TDbInterfacesObj::RemoveInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
{
return FALSE;
}
BOOL TDbInterfacesObj::NotifyInterfaceToModify(const TInterfaceModifyMsg& iModiMsg,TInterfaceModifyMsgs& iModiMsgs)
{
return FALSE;
}
// TDbXDataMap* TDbInterfacesObj::GetSpecialtyData()
// {
// return NULL;
// }
// BOOL TDbInterfacesObj::SetAt(LPCTSTR pszKey,TXData& XData)
// {
// assertWriteEnabled();
// TDbXDataMap* pXMap = GetSpecialtyData();
// if (pXMap != NULL)
// {
// pXMap->SetAt(pszKey,XData);
// return TRUE;
// }
// return FALSE;
// }
//
// BOOL TDbInterfacesObj::GetAt(LPCTSTR pszKey,TXData& XData)
// {
// assertReadEnabled();
//
// TDbXDataMap* pXMap = GetSpecialtyData();
// if (pXMap != NULL)
// {
// return pXMap->GetAt(pszKey,XData);
// }
// return FALSE;
// }
//
// TDbXDataMap* TDbInterfacesObj::GetSpecialtyDataReadOnly() const
// {
// return NULL;
// }
void TDbInterfacesObj::GetKindName(CString& sName)
{
assertReadEnabled();
sName = _T("ATS_INTERFACESOBJ");
}
BOOL TDbInterfacesObj::AddCoverEdge(AcDbObjectId& id,TComplexCurve& curEdge)
{
return FALSE;
}
BOOL TDbInterfacesObj::RemoveCoverEdge(AcDbObjectId& id)
{
return FALSE;
}
BOOL TDbInterfacesObj::GetCoverEdgeIds(AcDbObjectIdArray& arIds)
{
return FALSE;
}
BOOL TDbInterfacesObj::GetIdsCoverByMe(AcDbObjectIdArray& arByMeIds)
{
return FALSE;
}
BOOL TDbInterfacesObj::AddIdsCoverByMe(AcDbObjectId& id)
{
return FALSE;
}
BOOL TDbInterfacesObj::GetGeomExtentsEdge(TComplexCurve& crLoop)
{
return FALSE;
}
void TDbInterfacesObj::SetDashLayer(AcDbObjectId idDash)
{
assertWriteEnabled();
m_idDash = idDash;
}
AcDbObjectId TDbInterfacesObj::DashLayer() const
{
assertReadEnabled();
return m_idDash;
}
void TDbInterfacesObj::SetCenterLayer(AcDbObjectId idCen)
{
assertWriteEnabled();
m_idCenter = idCen;
}
AcDbObjectId TDbInterfacesObj::CenterLayer() const
{
assertReadEnabled();
return m_idCenter;
}
BOOL TDbInterfacesObj::UpdateRecInterface(const AcDbObjectIdArray& arids)
{
class CRelHelper : public TDbRelInterfaceReactor
{
public:
void UpdateRecInterface(const AcDbObjectIdArray& arIds)
{
TDbRelInterfaceReactor::UpdateRelInterface(arIds);
}
};
CRelHelper cHelp;
cHelp.UpdateRecInterface(arids);
return TRUE;
}
BOOL TDbInterfacesObj::FindInterfaceRec(const AcGePoint3d& ptConnect, TInterface& pipeInterface)
{
assertReadEnabled();
//到命名对象字典中找;
BOOL bSuccess = FALSE;
AcDbObjectId idOwner = this->objectId();
if (idOwner.isValid())
{
// add by hh 2011-08-09 接口记录从字典移动到数据库中
TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB();
if(NULL != pIntfRec)
{
if(Acad::eOk == pIntfRec->upgradeOpen())
{
bSuccess = pIntfRec->Find(idOwner,ptConnect,pipeInterface);
pIntfRec->downgradeOpen();
}
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::kForWrite))
{
pDict->close();
bSuccess = pInterfaceRec->Find(idOwner,ptConnect,pipeInterface);
pInterfaceRec->close();
}
else
{
pDict->close();
}
}
else
{
pNamedDict->close();
}
}
}
return bSuccess;
}
BOOL TDbInterfacesObj::UpdateInterfaceRec(const AcGeMatrix3d& xform,AcGePoint3d* ppOld)
{
assertReadEnabled();
//到命名对象字典中找;
BOOL bSuccess = FALSE;
AcDbObjectId idOwner = this->objectId();
if (idOwner.isValid())
{
// add by hh 2011-08-09 接口记录从字典移动到数据库中
TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB();
if(NULL != pIntfRec)
{
if(Acad::eOk == pIntfRec->upgradeOpen())
{
//如果没有注册接口,注册接口
if (!pIntfRec->Find(idOwner))
{
TInterface pipeInterface;
for (int i = 0;i < GetInterfaceCount();i++)
{
pipeInterface.Reset();
if (GetInterface(i,pipeInterface))
{
pIntfRec->Add(pipeInterface);
}
}
}
else
{
if (ppOld == NULL)
bSuccess = pIntfRec->TransformBy(idOwner,xform);
else
bSuccess = pIntfRec->TransformBy(idOwner,*ppOld,xform);
}
pIntfRec->downgradeOpen();
}
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::kForWrite))
{
pDict->close();
//如果没有注册接口,注册接口
if (!pInterfaceRec->Find(idOwner))
{
TInterface pipeInterface;
for (int i = 0;i < GetInterfaceCount();i++)
{
pipeInterface.Reset();
if (GetInterface(i,pipeInterface))
{
pInterfaceRec->Add(pipeInterface);
}
}
}
else
{
if (ppOld == NULL)
{
bSuccess = pInterfaceRec->TransformBy(idOwner,xform);
}
else
{
bSuccess = pInterfaceRec->TransformBy(idOwner,*ppOld,xform);
}
}
pInterfaceRec->close();
}
else
{
pDict->close();
}
}
else
{
pNamedDict->close();
}
}
}
return bSuccess;
}
BOOL TDbInterfacesObj::UpdateInterfaceRec(const AcGePoint3d& ptGeOld,const AcGeVector3d& vtDirNew)
{
assertReadEnabled();
//到命名对象字典中找;
BOOL bSuccess = FALSE;
AcDbObjectId idOwner = this->objectId();
if (idOwner.isValid())
{
// add by hh 2011-08-09 接口记录从字典移动到数据库中
TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB();
if(NULL != pIntfRec)
{
if(Acad::eOk == pIntfRec->upgradeOpen())
{
bSuccess = pIntfRec->Update(idOwner,ptGeOld,vtDirNew);
pIntfRec->downgradeOpen();
}
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::kForWrite))
{
pDict->close();
bSuccess = pInterfaceRec->Update(idOwner,ptGeOld,vtDirNew);
pInterfaceRec->close();
}
else
{
pDict->close();
}
}
else
{
pNamedDict->close();
}
}
}
return bSuccess;
}
BOOL TDbInterfacesObj::UpdateCoverDisplay()
{
if (!objectId().isNull())
{
TInterfaceModifyMsg iMsg;
iMsg.SetInterfaceOper(TDb::eUpdateCover);
iMsg.SetMsgOperateOn(objectId());
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
iMsg.SetInterfaceOper(TDb::eUpdateRel);
msgWrite.WriteInterfaceMsg(iMsg);
// add by hh 2011-09-22 更新被自身遮挡的实体
// 解决风管删除后遮挡无法自动更新的问题(暂定方案)
// BOOL bShowHide = TRUE;
// GetGlobalContext(KEY_HIDEDRAW, bShowHide);
// TAuxTools::GetTHvacDataFromDwg(KEY_HIDEDRAW, bShowHide);
//if(!bShowHide)
{
AcDbObjectIdArray arIds;
GetIdsCoverByMe(arIds);
for(int i = 0; i < arIds.length(); i++)
{
iMsg.SetInterfaceOper(TDb::eUpdateCover);
iMsg.SetMsgOperateOn(arIds.at(i));
msgWrite.WriteInterfaceMsg(iMsg);
}
}
return TRUE;
}
return FALSE;
}
BOOL TDbInterfacesObj::FlashCoverDisplay()
{
if (!objectId().isNull())
{
BOOL bWrite = isWriteEnabled();
if (bWrite) downgradeOpen();
TCoverReleationManager cover;
cover.UpdateCoverDisplay(this);
if (bWrite) upgradeOpen();
return TRUE;
}
return FALSE;
}
double TDbInterfacesObj::GetElevation()
{
assertReadEnabled();
int nCount = GetInterfaceCount();
if (nCount > 1)
{
TInterface pipeInt1,pipeInt2;
GetInterface(0,pipeInt1);
GetInterface(1,pipeInt2);
return TSupportFunc::Mid(pipeInt1.GetPosition(),pipeInt2.GetPosition()).z;
}
return 0.0;
}
Acad::ErrorStatus TDbInterfacesObj::copyFrom(const AcRxObject* pSrc)
{
assertWriteEnabled();
if (pSrc != NULL)
{
TDbCurveEntity::copyFrom(pSrc);
TDbInterfacesObj* pIObj = TDbInterfacesObj::cast(pSrc);
if (pIObj != NULL)
{
m_idDash = pIObj->m_idDash;
m_idCenter = pIObj->m_idCenter;
}
}
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::setLayer( const TCHAR* newVal,Adesk::Boolean doSubents)
{
assertWriteEnabled();
Acad::ErrorStatus es = AcDbEntity::setLayer(newVal,doSubents);
if (!m_idDash.isValid())
m_idDash = layerId();
if (!m_idCenter.isValid())
m_idCenter = layerId();
return es;
}
Acad::ErrorStatus TDbInterfacesObj::setLayer( AcDbObjectId newVal,Adesk::Boolean doSubents)
{
assertWriteEnabled();
if (!m_idDash.isValid())
m_idDash = newVal;
if (!m_idCenter.isValid())
m_idCenter = newVal;
return AcDbEntity::setLayer(newVal,doSubents);
}
Acad::ErrorStatus TDbInterfacesObj::dxfOutFields(AcDbDxfFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es;
if ((es = TDbCurveEntity::dxfOutFields(pFiler)) != Acad::eOk)
return es;
// Write subclass marker.
pFiler->writeItem(AcDb::kDxfSubclass, _T("TDbInterfacesObj"));
// Write version number.
pFiler->writeItem(AcDb::kDxfInt16, (Adesk::UInt16) VERSION_TDBINTERFACESOBJ);
return es;
}
Acad::ErrorStatus TDbInterfacesObj::dxfInFields(AcDbDxfFiler* pFiler)
{
assertWriteEnabled();
struct resbuf rb;
if ((TDbCurveEntity::dxfInFields(pFiler) != Acad::eOk) ||
!pFiler->atSubclassData(_T("TDbInterfacesObj")))
return pFiler->filerStatus();
// Read version number.
pFiler->readItem(&rb);
if (rb.restype != AcDb::kDxfInt16)
{
pFiler->pushBackItem();
pFiler->setError(Acad::eInvalidDxfCode,
_T("Error: expected object version group code %d"),
AcDb::kDxfInt16);
return pFiler->filerStatus();
}
else
{
Adesk::UInt16 version = rb.resval.rint;
if (version > VERSION_TDBINTERFACESOBJ)
return Acad::eMakeMeProxy;
}
return pFiler->filerStatus();
}
Acad::ErrorStatus TDbInterfacesObj::dwgOutFields(AcDbDwgFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es;
// Call dwgOutFields from TDbInterfacesObj
if ((es = TDbCurveEntity::dwgOutFields(pFiler)) != Acad::eOk)
{
return es;
}
pFiler->writeItem((Adesk::UInt16) VERSION_TDBINTERFACESOBJ);
pFiler->writeHardPointerId(m_idDash);
pFiler->writeHardPointerId(m_idCenter);
return pFiler->filerStatus();
}
Acad::ErrorStatus TDbInterfacesObj::dwgInFields(AcDbDwgFiler* pFiler)
{
assertWriteEnabled();
Acad::ErrorStatus es;
// Call dwgInFields from TDbInterfacesObj
if ((es = TDbCurveEntity::dwgInFields(pFiler)) != Acad::eOk)
{
return es;
}
Adesk::UInt16 version;
pFiler->readItem(&version);
if (version > VERSION_TDBINTERFACESOBJ)
return Acad::eMakeMeProxy;
switch(version)
{
case 1:
{
pFiler->readHardPointerId(&m_idDash);
pFiler->readHardPointerId(&m_idCenter);
break;
}
default:
break;
}
return pFiler->filerStatus();
}
BOOL TDbInterfacesObj::UpdateInterfaceRec(const AcGePoint3d& ptGeOld,const AcGePoint3d& ptGeNew)
{
assertReadEnabled();
//到命名对象字典中找;
BOOL bSuccess = FALSE;
AcDbObjectId idOwner = this->objectId();
if (idOwner.isValid())
{
// add by hh 2011-08-09 接口记录从字典移动到数据库中
TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB();
if(NULL != pIntfRec)
{
if(Acad::eOk == pIntfRec->upgradeOpen())
{
bSuccess = pIntfRec->Update(idOwner,ptGeOld,ptGeNew);
pIntfRec->downgradeOpen();
}
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::kForWrite))
{
pDict->close();
bSuccess = pInterfaceRec->Update(idOwner,ptGeOld,ptGeNew);
pInterfaceRec->close();
}
else
{
pDict->close();
}
}
else
{
pNamedDict->close();
}
}
}
return bSuccess;
}
void TDbInterfacesObj::UpdateNormal(const AcGePoint3d& ptOld,const AcGePoint3d& ptNew)
{
}
Acad::ErrorStatus TDbInterfacesObj::setNormal(const AcGeVector3d& vtNorm)
{
return Acad::eNotImplementedYet;
}
AcGeVector3d TDbInterfacesObj::normal() const
{
return AcGeVector3d::kZAxis;
}
Acad::ErrorStatus TDbInterfacesObj::subDeepClone(AcDbObject* pOwnerObject,
AcDbObject*& pClonedObject,
AcDbIdMapping& idMap,
Adesk::Boolean isPrimary) const
{
assertReadEnabled();
Acad::ErrorStatus es = TDbCurveEntity::subDeepClone(pOwnerObject, pClonedObject, idMap, isPrimary);
if(es!=Acad::eOk)
return es;
/*
pClonedObject = NULL;
//1.对象在 map 中 返回
bool isPrim = false;
if (isPrimary) isPrim = true;
AcDbIdPair idPair(objectId(), (AcDbObjectId)NULL, false, isPrim);
if (idMap.compute(idPair) && (idPair.value() != NULL))
{
return Acad::eOk;
}
TDbInterfacesObj *pClone = (TDbInterfacesObj*)isA()->create();
if (pClone != NULL)
pClonedObject = pClone;
else
return Acad::eOutOfMemory;
AcDbDeepCloneFiler filer;
dwgOut(&filer);
filer.seek(0L, AcDb::kSeekFromStart);
pClone->dwgIn(&filer);
bool bOwnerXlated = false;
if (isPrimary)
{
AcDbBlockTableRecord *pBTR = AcDbBlockTableRecord::cast(pOwnerObject);
if (pBTR != NULL)
{
//判断对方是否有接口记录对象
MakeSureDbHasAssocReactor(pBTR->database(),g_pRelInterfaceReactor != NULL ? g_pRelInterfaceReactor->m_pToolKit : NULL);
pBTR->appendAcDbEntity(pClone);
bOwnerXlated = true;
}
else
{
pOwnerObject->database()->addAcDbObject(pClone);
}
}
else
{
pOwnerObject->database()->addAcDbObject(pClone);
pClone->setOwnerId(pOwnerObject->objectId());
bOwnerXlated = true;
}
pClone->setAcDbObjectIdsInFlux();
idPair.setValue(pClonedObject->objectId());
idPair.setIsCloned(Adesk::kTrue);
idPair.setIsOwnerXlated(bOwnerXlated);
idMap.assign(idPair);
*/
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::subWblockClone( AcRxObject* pOwnerObject,
AcDbObject*& pClonedObject,
AcDbIdMapping& idMap,
Adesk::Boolean isPrimary) const
{
assertReadEnabled();
Acad::ErrorStatus es = TDbCurveEntity::subWblockClone(pOwnerObject, pClonedObject, idMap, isPrimary);
if(es!=Acad::eOk)
return es;
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getStartPoint(AcGePoint3d& x0) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getStartParam(double& x0) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getSplitCurves(const AcGePoint3dArray& points,
AcDbVoidPtrArray& curveSegments) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getSplitCurves(const AcGeDoubleArray& params,
AcDbVoidPtrArray& curveSegments) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getPointAtParam(double x0,
AcGePoint3d& x1) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getPointAtDist(double x0,
AcGePoint3d& x1) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getParamAtPoint(const AcGePoint3d& x0,
double& x1)const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getParamAtDist(double dist,
double& param) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getOffsetCurves(double offsetDist,
AcDbVoidPtrArray& offsetCurves) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getFirstDeriv(double param,
AcGeVector3d& firstDeriv) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getFirstDeriv(const AcGePoint3d& x0,
AcGeVector3d& firstDeriv) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getEndPoint(AcGePoint3d& x0) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getEndParam(double& x0) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getDistAtPoint(const AcGePoint3d& x0,
double& x1) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getDistAtParam(double param,
double& dist) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getClosestPointTo(const AcGePoint3d& givenPnt,
const AcGeVector3d& direction,
AcGePoint3d& pointOnCurve,
Adesk::Boolean extend) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getClosestPointTo(const AcGePoint3d& givenPnt,
AcGePoint3d& pointOnCurve,
Adesk::Boolean extend) const
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::extend(double newParam)
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::extend(Adesk::Boolean extendStart,
const AcGePoint3d& toPoint)
{
assertReadEnabled();
return Acad::eOk;
}
Acad::ErrorStatus TDbInterfacesObj::getPlane(AcGePlane& plan,AcDb::Planarity& panvt) const
{
return Acad::eOk;
}
BOOL TDbInterfacesObj::MakeCurves(TComplexCurve& cplCurve) const
{
return FALSE;
}
BOOL TDbInterfacesObj::GetCurvesInSide(TComplexCurve& compCurve) const
{
return FALSE;
}
AcDbPolyline* TDbInterfacesObj::MakePolyCurve() const
{
return NULL;
}
BOOL TDbInterfacesObj::MakePolyCurveFaces(AcDbVoidPtrArray& arFaces)
{
return FALSE;
}
void TDbInterfacesObj::subList() const
{
TDbCurveEntity::subList();
}
TDb::Position TDbInterfacesObj::ExplainGripIndex(int nIndex) const
{
return TDb::eStart;
}
Acad::ErrorStatus TDbInterfacesObj::GetGripText(int i, CString &cs) const
{
TDb::Position ePs = ExplainGripIndex(i);
switch(ePs)
{
case TDb::eStart: //夹点 Start 点
{
cs = _T("改变起点位置");
break;
}
case TDb::eMid: //夹点 中点
{
cs = _T("移动");
break;
}
case TDb::eEnd: //夹点 End点
{
cs = _T("改变终点位置");
break;
}
case TDb::eBr1: //夹点 分支点1
case TDb::eBr2: //夹点 分支点2
case TDb::eBr3: //夹点 分支点3
case TDb::eBr4: //夹点 分支点4 1~4一般用于三通,四通
{
cs = _T("端点");
break;
}
case TDb::eInf1: //夹点 接口点1
case TDb::eInf2: //夹点 接口点2
case TDb::eInf3: //夹点 接口点3
case TDb::eInf4: //夹点 接口点4
case TDb::eInf5: //夹点 接口点5
case TDb::eInf6: //夹点 接口点6
case TDb::eInf7: //夹点 接口点7
case TDb::eInf8: //夹点 接口点8
case TDb::eInf9: //夹点 接口点9
case TDb::eInf10: //夹点 接口点10 1~10 用于小型设备的接口
{
cs = _T("接口夹点");
break;
}
case TDb::eSizeMid0: //夹点 尺寸0
case TDb::eSizeMid1: //夹点 尺寸1
case TDb::eSizeMid2: //夹点 尺寸2
case TDb::eSizeMid3: //夹点 尺寸3 0~3 用于尺寸拉动的夹点
{
cs = _T("调整尺寸");
break;
}
case TDb::eCommand0: //夹点 命令点0
case TDb::eCommand1: //夹点 命令点1
case TDb::eCommand2: //夹点 命令点2
case TDb::eCommand3: //夹点 命令点3 0~3 用于启动命令的夹点
{
cs = _T("启动绘制命令");
break;
}
case TDb::eDim0: //夹点 标注0
case TDb::eDim1: //夹点 标注1
case TDb::eDim2: //夹点 标注2 0~2 用于埋标注的夹点解释
{
cs = _T("标注");
break;
}
case TDb::eAdjust0: // 夹点 弧风管,弧度控制点
{
cs = _T("调整点");
break;
}
default:
cs.Empty();
break;
}
return Acad::eOk;
}
int TDbInterfacesObj::GetFirstVersion()const
{
return 8;
}
void TDbInterfacesObj::GetTips(DList<TObjInfoUnit> &lstInfo) const
{
CString sKey,sValue;
CMapStringToString mapLable2Tip;
for (POSITION ps = mapLable2Tip.GetStartPosition();ps != NULL;)
{
mapLable2Tip.GetNextAssoc(ps,sKey,sValue);
lstInfo.Append(new TObjInfoUnit(sKey,sValue));
}
}
void TDbInterfacesObj::GetTips(CMapStringToString& mapLable2Tip) const
{
}
double TDbInterfacesObj::GetPrintScale() const
{
assertReadEnabled();
return GetPScale();
}
void TDbInterfacesObj::SetPrintScale(double scale)
{
assertWriteEnabled();
SetPScale(scale);
}
//布局转角
double TDbInterfacesObj::GetLayoutRotationAngle() const
{
assertReadEnabled();
return GetLayoutRotation();
}
void TDbInterfacesObj::SetLayoutRotationAngle(double dRot)
{
assertWriteEnabled();
SetLayoutRotation(dRot);
}
void TDbInterfacesObj::CopyPropertiesFrom(AcDbEntity *pSrcEntity,unsigned gMatchFlag)
{
// change by hh 2014.8.13 TDbXDataMap移植到底层后,基类的该函数会复制XDataMap中
// 的数据,pipebase中无此需求,不再调用基类函数
// TDbCurveEntity::CopyPropertiesFrom(pSrc,gMatchFlag);
AcDbEntity *pTrgEntity = GetMe();
if (!pTrgEntity)
{
return;
}
// 颜色
if (gMatchFlag & AcDbMatchProperties::kColorFlag)
{
pTrgEntity->setColorIndex(pSrcEntity->colorIndex());
}
//图层
if (pTrgEntity->database() == NULL
|| pSrcEntity->database() == NULL
|| pTrgEntity->database() == pSrcEntity->database()) //add by W on 060317
{
if (gMatchFlag & AcDbMatchProperties::kLayerFlag)
{
pTrgEntity->setLayer(pSrcEntity->layerId());
}
// 线型
if (gMatchFlag & AcDbMatchProperties::kLtypeFlag)
{
pTrgEntity->setLinetype(pSrcEntity->linetypeId());
}
#if ADS > 16
// 材质
if (gMatchFlag & AcDbMatchProperties::kMaterialFlag)
{
pTrgEntity->setMaterial(pSrcEntity->materialId());
}
#endif
}
// 线型比例
if (gMatchFlag & AcDbMatchProperties::kLtscaleFlag)
{
pTrgEntity->setLinetypeScale(pSrcEntity->linetypeScale());
}
// 可见性. 总是被复制
pTrgEntity->setVisibility(pSrcEntity->visibility());
const TDbCurveEntity *pSrc2 = TDbCurveEntity::cast(pSrcEntity);
if (pSrc2)
{
m_nPaperScale = pSrc2->GetPScale();
m_nLayoutRotation = pSrc2->GetLayoutRotation();
}
}
void TDbInterfacesObj::CopyPropertiesTo(AcDbObjectId& idTgr,unsigned gMatchFlag)
{
}
void TDbInterfacesObj::CopyPropertiesTo(AcDbObjectIdArray& arIds,unsigned gMatchFlag)
{
for (int i = 0;i < arIds.length();i++)
{
CopyPropertiesTo(arIds.at(i),gMatchFlag);
}
}
Acad::ErrorStatus TDbInterfacesObj::getArea(double& x0) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->setClosed(Adesk::kTrue);
pPl->getArea(x0);
}
return Acad::eOk;
}
BOOL TDbInterfacesObj::OPMInfo(LPCTSTR pszName, TDb::OPMInfo* pInfo)
{
return FALSE;
}
BOOL TDbInterfacesObj::IsValid(TDbXDataMap* pXMap)
{
return FALSE;
}
void TDbInterfacesObj::SetSubText(long i,CString sText)
{
}
LRESULT TDbInterfacesObj::UserCall(long i,LPVOID pData)
{
return 0l;
}
Acad::ErrorStatus TDbInterfacesObj::subErase(Adesk::Boolean erasing)
{
//调用基类处理,保证 undo,shade 涉及图元的机制正确
Acad::ErrorStatus es = TDbCurveEntity::subErase(erasing);
if (objectId().isValid() && erasing)
{
AcDbObjectId idOwner = objectId();
BOOL bResetConet = FALSE;
AcDbDictionary* pNamedDict = NULL;
// change by hh 2011-08-09 接口记录从字典移动到数据库中
TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB();
if(NULL != pIntfRec)
{
if(Acad::eOk == pIntfRec->upgradeOpen())
{
pIntfRec->disableUndoRecording(Adesk::kTrue);
pIntfRec->Remove(idOwner);
bResetConet = pIntfRec->ResetConnect(idOwner);
pIntfRec->disableUndoRecording(Adesk::kFalse);
pIntfRec->downgradeOpen();
}
pIntfRec->close();
if (bResetConet)
{
TInterfaceModifyMsg iMsg;
iMsg.SetInterfaceOper(TDb::eUpdateDisp);
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
}
}
else
{
if (Acad::eOk == database()->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))
{
// mcl add. 避免记录撤消后,删除实体后恢复时很慢
pInterfaceRec->disableUndoRecording(Adesk::kTrue);
pDict->close();
pInterfaceRec->Remove(idOwner);
bResetConet = pInterfaceRec->ResetConnect(idOwner);
pInterfaceRec->disableUndoRecording(Adesk::kFalse);
pInterfaceRec->close();
if (bResetConet)
{
TInterfaceModifyMsg iMsg;
iMsg.SetInterfaceOper(TDb::eUpdateDisp);
TDbInterfaceMsgWrite msgWrite;
msgWrite.WriteInterfaceMsg(iMsg);
}
}
else
{
pDict->close();
}
}
else
{
pNamedDict->close();
}
}
} // change end
// mcl add. 由于对pInterfaceRec暂时进行了禁止撤销记录,所以搜集起来,统一处理关系
AcDbDatabase* pDwg = acdbCurDwg();
// CUIntArray* pArray = NULL; 64位下id不能转换为UINT了
AcDbObjectIdArray* pArray = NULL;
if (!g_iMsgContext.m_mapDb2InfErase.Lookup((void*)pDwg, (void*&)pArray))
{
pArray = new AcDbObjectIdArray;
g_iMsgContext.m_mapDb2InfErase.SetAt((void*)pDwg, (void*)pArray);
}
if (pArray != NULL)
{
pArray->append(idOwner);
}
//5.写入遮挡关系更新
UpdateCoverDisplay();
}
return es;
}
int TDbInterfacesObj::GetXBaseShell(TXShell& xShell)
{
return 0;
}
int TDbInterfacesObj::GetBodyBox( AcDbExtents& ext )
{
return 0;
}
Acad::ErrorStatus TDbInterfacesObj::applyPartialUndo(AcDbDwgFiler* undoFiler,AcRxClass* classObj)
{
if (TDbInterfacesObj::desc() == classObj)
{
//发消息更新接口记录
}
return AcDbEntity::applyPartialUndo(undoFiler,classObj);
}