www.mxdraw.com
|
直径标注类型
class McDbDiametricDimension : public McDbDimension;
McDbDimension.h
例如: 控件中绘直接标注的代码
void CDrawCommand::DrawDiametricDimension() { MrxDbgRbList spFilter = Mx::mcutBuildList(RTDXF0,_T("CIRCLE,ARC"),0); McDbObjectId objId; McGePoint3d ptPick; if(MrxDbgUtils::selectEnt(_T("选择圆弧或圆:"),spFilter.data(),objId,ptPick) != RTNORM) { return; } McDbDiametricDimension* pDim = new McDbDiametricDimension; pDim->setDimensionStyle(Mx::mcdbHostApplicationServices()->workingDatabase()->dimstyle() ); CDrawDiametricDimensionJig jig(pDim,objId,ptPick); if(jig.DoIt() ) { MrxDbgUtils::addToCurrentSpaceAndClose(pDim); } else { delete pDim; } } CDrawDiametricDimensionJig::CDrawDiametricDimensionJig(McDbDiametricDimension* pDim, McDbObjectId id,McGePoint3d ptPick) { m_pDim = pDim; m_id = id; CalculationDimPoint(ptPick); } BOOL CDrawDiametricDimensionJig::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(); McGePoint3d cordPoint; McGePoint3d farcordPoint; if(pArc->getClosestPointTo(ptPick,cordPoint) != Mcad::eOk) { MXASSERT(0); cordPoint = ptCenter + AcGeVector3d::kXAxis * pArc->radius(); } farcordPoint = cordPoint + (ptCenter - cordPoint) * 2.0; m_pDim->setChordPoint(cordPoint); m_pDim->setFarChordPoint(farcordPoint); 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(); McGePoint3d cordPoint; McGePoint3d farcordPoint; if(pCircle->getClosestPointTo(ptPick,cordPoint) != Mcad::eOk) { MXASSERT(0); cordPoint = ptCenter + AcGeVector3d::kXAxis * pCircle->radius(); } farcordPoint = cordPoint + (ptCenter - cordPoint) * 2.0; m_pDim->setChordPoint(cordPoint); m_pDim->setFarChordPoint(farcordPoint); m_pDim->setTextPosition(ptPick); m_pDim->setExtArcEndAngle(MxBase::k2PI); m_pDim->setExtArcStartAngle(0.0); return TRUE; } } MXASSERT(0); return FALSE; } CDrawDiametricDimensionJig::~CDrawDiametricDimensionJig(void) { } McEdJig::DragStatus CDrawDiametricDimensionJig::sampler() { AcGePoint3d point; AcEdJig::DragStatus ret = acquirePoint(point); if(ret == AcEdJig::kNormal) { CalculationDimPoint(point); } return ret; } Adesk::Boolean CDrawDiametricDimensionJig::update() { return Adesk::kTrue; } AcDbEntity* CDrawDiametricDimensionJig::entity() const { return m_pDim; } bool CDrawDiametricDimensionJig::DoIt() { if(drag(NULL,NULL,FALSE) == AcEdJig::kNormal) { return true; } return false; }