我从AcDbEntity派生了一个子类AzhtEntity,然后又从AzhtEntity派生AzhtBreaker,如下:一些必须的重载函数还有些返回值都已省略, AzhtEntity中: class AzhtEntity:public AcDbEntity { public: ACRX_DECLARE_MEMBERS(AzhtEntity); AzhtEntity(); virtual ~AzhtEntity(); ..................................... ..................................... ..................moveGripPointsAt().......... ..................getGripPoints()................ ..................transformBy().................. ......................................................... ........................................................ private: AcGePoint3d m_insertPt; //插入点 };
AzhtEntity::getGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const { assertReadEnabled(); gripPoints.append(m_insertPt); return Acad::eOk; }
AzhtEntity::moveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset) { assertWriteEnabled(); return Acad::eOk; }
AzhtEntity::transformBy(const AcGeMatrix3d& xform) { assertWriteEnabled(); return Acad::eOk; } AzhtBreaker中: class AzhtBreaker:public AzhtEntity { public: ACRX_DECLARE_MEMBERS(AzhtBreaker); AzhtBreaker(); virtual ~AzhtBreaker(); ..................................... ..................................... ..................moveGripPointsAt().......... ..................getGripPoints()................ ..................transformBy().................. ......................................................... ........................................................ private: AcGePoint3d m_otherPt; //插入点 }; AzhtBreaker::getGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const { assertReadEnabled(); int iDirection = ((AzhtEntity*)this)->getDirection(); AcGePoint3d insertPt = ((AzhtEntity*)this)->getInsertPt(); gripPoints.append(m_otherPt); AzhtEntity::getGripPoints(gripPoints, osnapModes, geomIds); return Acad::eOk; }
AzhtBreaker::moveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset) { assertWriteEnabled(); //若没有选中点或偏移为0 if(indices.length()==0 || offset.isZeroLength()) return Acad::eOk; return transformBy(AcGeMatrix3d::translation(offset)); }
AzhtBreaker::transformBy(const AcGeMatrix3d& xform) { assertWriteEnabled(); AcGePoint3d insertPt = getInsertPt(); insertPt.transformBy(xform); m_otherPt.transformBy(xform);
return Acad::eOk; }
我这样做之后,能够得到夹点,但在移动的时候出现问题,说什么内存不足!请高手指教一下,谢谢!!!!!!
在下想知道,在重载这些函数的时候需要有些什么原则和注意的地方吗? |