203 lines
3.7 KiB
C++
203 lines
3.7 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TDbGrip.cpp
|
|
// = Version : ver2.0
|
|
// = Author : xlc
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: 夹点对象类的定义
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "TDbGrip.h"
|
|
|
|
#if ADS > 15
|
|
#include "TEntityBase.h"
|
|
|
|
TDbGrip::TDbGrip(TEntityBase *pEnt,const AcGePoint3d&pt,int type):
|
|
m_pGripEntity(pEnt),m_ptGrip(pt),m_bitFlags(0),m_iType(0)
|
|
{
|
|
|
|
}
|
|
|
|
TDbGrip::~TDbGrip()
|
|
{
|
|
|
|
}
|
|
|
|
int TDbGrip::Index() const
|
|
{
|
|
return m_iId;
|
|
}
|
|
|
|
void TDbGrip::SetIndex(long id)
|
|
{
|
|
m_iId = id;
|
|
}
|
|
|
|
const AcGePoint3d TDbGrip::Position() const
|
|
{
|
|
return m_ptGrip;
|
|
}
|
|
|
|
TEntityBase* TDbGrip::Owner() const
|
|
{
|
|
return m_pGripEntity;
|
|
}
|
|
|
|
TDbGripDim* TDbGrip::GetDim(long i) const
|
|
{
|
|
return m_allDims.GetAt(i);
|
|
}
|
|
|
|
int TDbGrip::FindDim(TDbGripDim* pDim) const
|
|
{
|
|
return m_allDims.Find(pDim);
|
|
}
|
|
|
|
int TDbGrip::GetDimNum() const
|
|
{
|
|
return m_allDims.GetLength();
|
|
}
|
|
|
|
bool TDbGrip::operator>(const TDbGrip&) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool TDbGrip::operator<(const TDbGrip&) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
void TDbGrip::AppendDim(TDbGripDim*pDim)
|
|
{
|
|
pDim->SetGrip(this);
|
|
m_allDims.AddTail(pDim);
|
|
}
|
|
|
|
//更新关联动态标注
|
|
void TDbGrip::UpdateDimEnt()
|
|
{
|
|
for (long i = 0; i < m_allDims.GetLength(); i++)
|
|
{
|
|
m_allDims[i]->UpdateDimEnt();
|
|
}
|
|
}
|
|
|
|
CString TDbGrip::ToolTip() const
|
|
{
|
|
CString sTip;
|
|
m_pGripEntity->GetGripText(Index(),sTip);
|
|
return sTip;
|
|
}
|
|
|
|
void TDbGrip::GetHotDimension(const AcDbObjectId & entId,
|
|
double dimScale,
|
|
AcDbDimDataPtrArray& dimData) const
|
|
{
|
|
if(entId.isNull() || !entId.isValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
AcDbEntity *pEnt = NULL;
|
|
acdbOpenObject(pEnt,entId,AcDb::kForRead);
|
|
if(pEnt == NULL)
|
|
{
|
|
return;
|
|
}
|
|
|
|
TEntityBase* pGripEntity = TEntityBase::Cast(pEnt);
|
|
if(pGripEntity == NULL)
|
|
{
|
|
pEnt->close();
|
|
return;
|
|
}
|
|
|
|
for(long i = 0; i < m_allDims.GetLength(); i++)
|
|
{
|
|
TDbGripDim *pGripDim = m_allDims.GetAt(i);
|
|
dimData.append(pGripDim->CreateDimData(entId,dimScale));
|
|
}
|
|
|
|
pGripEntity->UpdateDim(Index());
|
|
pGripEntity->Close();
|
|
}
|
|
|
|
void TDbGrip::GetHoverDimension(const AcDbObjectId& entId,
|
|
double dimScale,
|
|
AcDbDimDataPtrArray& dimData) const
|
|
{
|
|
if(entId.isNull() || !entId.isValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
AcDbEntity *pEnt = NULL;
|
|
acdbOpenObject(pEnt,entId,AcDb::kForRead);
|
|
|
|
if(pEnt == NULL)
|
|
{
|
|
return;
|
|
}
|
|
|
|
TEntityBase* pGripEntity = TEntityBase::Cast(pEnt);
|
|
if(pGripEntity == NULL)
|
|
{
|
|
pEnt->close();
|
|
return;
|
|
}
|
|
|
|
for(long i = 0; i < m_allDims.GetLength(); i++)
|
|
{
|
|
TDbGripDim *pGripDim = m_allDims.GetAt(i);
|
|
if(pGripDim->IsHoverDim())
|
|
{
|
|
AcDbDimData*pDimData = pGripDim->CreateDimData(entId,dimScale);
|
|
pDimData->setDimHideIfValueIsZero(true);
|
|
dimData.append(pDimData);
|
|
}
|
|
else
|
|
{
|
|
pGripDim->ResetDimData();
|
|
}
|
|
}
|
|
|
|
pGripEntity->UpdateDim(Index());
|
|
pGripEntity->Close();
|
|
}
|
|
|
|
AcDbGripData* TDbGrip::CreateGripData() const
|
|
{
|
|
AcDbGripData *pData = new AcDbGripData;
|
|
pData->setGripPoint(m_ptGrip);
|
|
pData->setAppData((void*)this);
|
|
pData->setBitFlags(m_bitFlags);
|
|
pData->setToolTipFunc(TEntityBase::GripToolTip);
|
|
pData->setHotGripDimensionFunc(TEntityBase::GripHotDimension);
|
|
pData->setHoverDimensionFunc(TEntityBase::GripHoverDimension);
|
|
|
|
if(m_iType > 0)
|
|
{
|
|
pData->setWorldDraw(TEntityBase::GripWorldDraw);
|
|
pData->setViewportDraw(TEntityBase::GripViewportDraw);
|
|
}
|
|
return pData;
|
|
}
|
|
|
|
bool TDbGrip::WorldDraw(AcGiWorldDraw* pWd,
|
|
AcDbGripOperations::DrawType typ,
|
|
double dGripSize) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
void TDbGrip::ViewportDraw(AcGiViewportDraw* pVd,
|
|
AcDbGripOperations::DrawType type,
|
|
int gripSize) const
|
|
{
|
|
|
|
}
|
|
|
|
#endif |