AutoCAD 图元具有夹点,当用户使用定点设备选择图元时,将显示这些夹点。该函数返回已为实体定义的夹点。该函数执行由夹点编辑产生的实体修改。getGripPoints()moveGripPointsAt() 在夹点编辑中使用拉伸模式时,您可以通过将所选夹点移动到新位置来拉伸对象。AutoCAD 在用户处于拉伸模式时调用该函数。但是,对于某些实体,某些夹点会移动对象而不是拉伸对象。这些夹点包括文本对象、块、直线中点、圆心、椭圆中心和点对象上的夹点。在这些情况下,函数调用。moveGripPointsAt()moveGripPointsAt()transformBy() 注意:函数的默认实现是调用函数。AcDbEntity::moveGripPointsAt()transformBy()
当用户处于抓取、移动、旋转、缩放或镜像模式时,AutoCAD 将调用“实体”部分中所述的函数。transformBy() 如果希望用户能够使用夹点编辑实体,则需要覆盖 and函数。实体定义其夹点以及如何解释用户提供的偏移。subGetGripPoints()subMoveGripPointsAt() 以下摘录显示了自定义类如何实现这些函数。此类定义的对象在每个顶点都有一个夹点,在其中心有一个夹点。这些握点由函数返回。如果用户在夹点拉伸模式下选择夹点,AutoCAD 将调用该函数。这将调用您的自定义实体,传入所选夹点的索引数组和指定用户移动定点设备的 3D 矢量。如果用户选择了顶点夹点,则多边形将按指定的偏移量均匀拉伸。如果用户选取中心夹点,则多边形只需平移等于偏移量。(此值将传递给函数,如下所示。AsdkPolysubGetGripPoints()moveGripPointsAt()subMoveGripPointsAt()transformBy() Acad::ErrorStatus
AsdkPoly::subGetGripPoints(
AcGePoint3dArray& gripPoints,
AcDbIntArray& osnapModes,
AcDbIntArray& geomIds) const
{
assertReadEnabled();
Acad::ErrorStatus es;
if ((es = getVertices3d(gripPoints)) != Acad::eOk) {
return es;
}
// Remove the duplicate point at the start/end and add
// center as the last point.
//
gripPoints.removeAt(gripPoints.length() - 1);
AcGePoint3d center;
getCenter(center);
gripPoints.append(center);
return es;
}
Acad::ErrorStatus
AsdkPoly::subMoveGripPointsAt(
const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
if (indices.length()== 0 || offset.isZeroLength())
return Acad::eOk; //that's easy :-)
if (mDragDataFlags & kCloneMeForDraggingCalled) {
mDragDataFlags |= kUseDragCache;
} else
// Only if we're not dragging do we want to make an undo
// recording and check if the object's open for write.
//
assertWriteEnabled();
//if there more than one hot vertex or there's one and it
// is the center then simply transform
if (indices.length()>1 || indices[0] == mNumSides)
return transformBy(AcGeMatrix3d::translation(offset));
AcGeVector3d off(offset);
//calculate the offset vector of the startpoint
//from the offset vector on a vertex
double rotateBy = 2.0 * 3.14159265358979323846 /
nNumSides * indices[0];
AcGePoint3d cent;
getCenter(cent);
off.transformBy(AcGeMatrix3d::rotation(-rotateBy,
normal(),cent));
acdbWcs2Ecs(asDblArray(off),asDblArray(off),asDblArray(normal()),
Adesk::kTrue);
if (mDragDataFlags & kUseDragCache){
mDragCenter = mCenter;
mDragPlaneNormal = mPlaneNormal;
mDragStartPoint = mStartPoint + AcGeVector2d(off.x,off.y);
mDragElevation = mElevation + off.z;
}else{
mStartPoint = mStartPoint + AcGeVector2d(off.x,off.y);
mElevation = mElevation + off.z;
}
return Acad::eOk;
}
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 17:09
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.