www.mxdraw.com
|
半径标注类型
class McDbRadialDimension : public McDbDimension;
McDbDimension.h
例如: 控件中绘制半径标注的代码
void CDrawCommand::DrawRadialDimension() { MrxDbgRbList spFilter = Mx::mcutBuildList(RTDXF0,_T("CIRCLE,ARC"),0); McDbObjectId objId; McGePoint3d ptPick; if(MrxDbgUtils::selectEnt(_T("选择圆弧或圆:"),spFilter.data(),objId,ptPick) != RTNORM) { return; } McDbRadialDimension* pDim = new McDbRadialDimension; pDim->setDimensionStyle(Mx::mcdbHostApplicationServices()->workingDatabase()->dimstyle() ); CDrawRadialDimensionJig jig(pDim,objId,ptPick); if(jig.DoIt() ) { MrxDbgUtils::addToCurrentSpaceAndClose(pDim); } else { delete pDim; } } CDrawRadialDimensionJig::CDrawRadialDimensionJig(McDbRadialDimension* pDim, McDbObjectId id,McGePoint3d ptPick) { m_pDim = pDim; m_id = id; CalculationDimPoint(ptPick); } BOOL CDrawRadialDimensionJig::CalculationDimPoint(McGePoint3d ptPick) { McDbObjectPointer<McDbEntity> spEnt(m_id,McDb::kForRead); if(spEnt.openStatus() != Mcad::eOk) { MXASSERT(0); return FALSE; } { McDbArc* pArc = McDbArc::cast(spEnt.object() ); if(pArc != NULL) { McGePoint3d ptCenter = pArc->center(); m_pDim->setCenter(ptCenter ); McGePoint3d cordPoint; if(pArc->getClosestPointTo(ptPick,cordPoint) != Mcad::eOk) { MXASSERT(0); cordPoint = ptCenter + AcGeVector3d::kXAxis * pArc->radius(); } m_pDim->setChordPoint(cordPoint); m_pDim->setTextPosition(ptPick); double dSAng = pArc->startAngle(); double dEAng = pArc->endAngle(); if(dEAng < dSAng) dEAng += MxBase::k2PI; m_pDim->setExtArcEndAngle(dEAng); m_pDim->setExtArcStartAngle(dSAng); return TRUE; } } { McDbCircle* pCircle = McDbCircle::cast(spEnt.object() ); if(pCircle != NULL) { McGePoint3d ptCenter = pCircle->center(); m_pDim->setCenter(ptCenter ); McGePoint3d cordPoint; if(pCircle->getClosestPointTo(ptPick,cordPoint) != Mcad::eOk) { MXASSERT(0); cordPoint = ptCenter + AcGeVector3d::kXAxis * pCircle->radius(); } m_pDim->setChordPoint(cordPoint); m_pDim->setTextPosition(ptPick); m_pDim->setExtArcEndAngle(MxBase::k2PI); m_pDim->setExtArcStartAngle(0.0); return TRUE; } } MXASSERT(0); return FALSE; } CDrawRadialDimensionJig::~CDrawRadialDimensionJig(void) { } McEdJig::DragStatus CDrawRadialDimensionJig::sampler() { AcGePoint3d point; AcEdJig::DragStatus ret = acquirePoint(point); if(ret == AcEdJig::kNormal) { CalculationDimPoint(point); } return ret; } Adesk::Boolean CDrawRadialDimensionJig::update() { return Adesk::kTrue; } AcDbEntity* CDrawRadialDimensionJig::entity() const { return m_pDim; } bool CDrawRadialDimensionJig::DoIt() { if(drag(NULL,NULL,FALSE) == AcEdJig::kNormal) { return true; } return false; }