- UID
- 69086
- 积分
- 178
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-8-1
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2004-1-9 20:05:31
|
显示全部楼层
能给一个block的jig例子看么?
今天网络太慢,发不上来呢
class AsdkMyJig : public AcEdJig
{
public:
AcDbObjectId m_ublkID;
AsdkMyJig(AcDbObjectId blkId,AcGeVector3d& normal);
virtual ~AsdkMyJig();
void doIt();
virtual DragStatus sampler();
virtual Adesk::Boolean update();
virtual AcDbEntity* entity() const;
private:
AcGeMatrix3d rotateForm;
AcGeMatrix3d moveForm;
double mAng;
AcDbBlockReference* pBlockReference;
AcGeMatrix3d xform;
AcGePoint3d mInsertPt;
AcGeVector3d mNormal;
int mPromptCounter;
};
// The following defines the constructor that accepts a point to be used as the
// centerpoint of the ellipse and the current UCS normal
// vector to be used as the normal for the ellipse. It
// also initializes the radius ratio to a small value so
// that during selection of the major axis, the ellipse
// will appear as a line. The prompt counter is also
// initialized to 0.
//
AsdkMyJig::AsdkMyJig(AcDbObjectId blkId,AcGeVector3d& normal):mPromptCounter(0)//,mNormal(normal)
{
m_ublkID=blkId;
mNormal=normal;
pBlockReference=NULL;
}
AsdkMyJig::~AsdkMyJig()
{
pBlockReference->close();
}
// This function creates an AcDbEllipse object and gets the
// jig started acquiring the necessary info to properly fill
// it in.
//
void
AsdkMyJig::doIt()
{
pBlockReference=new AcDbBlockReference;//(AcGePoint3d(0.0,0.0,0.0),m_ublkID);
pBlockReference->setBlockTableRecord(m_ublkID);
AcEdJig::DragStatus stat;
// Get the major axis vector from the user.
//
// At this time, mPromptCounter == 0
//
setDispPrompt("\ninsert point: ");
stat = drag();
// Get the ellipse's radius ratio.
//
mPromptCounter++; // now == 1
setDispPrompt("\ninput angle: ");
stat = drag();
// Now add the ellipse to the database's current space.
//
append();
}
// This function is called by the drag function to
// acquire a sample input.
//
AcEdJig::DragStatus
AsdkMyJig::sampler()
{
DragStatus stat;
setUserInputControls((UserInputControls)
(AcEdJig::kAccept3dCoordinates
| AcEdJig::kNoNegativeResponseAccepted
| AcEdJig::kNoZeroResponseAccepted));
if (mPromptCounter == 0) {
static AcGePoint3d axisPointTemp;
const AcGePoint3d basePt(0.0,0.0,0.0);
stat = acquirePoint(mInsertPt, basePt);
if (axisPointTemp != mInsertPt)
{
axisPointTemp = mInsertPt;
AcGeVector3d Vector(mInsertPt[X],mInsertPt[Y],mInsertPt[Z]);
moveForm.setToTranslation(Vector);
}
else if (stat == AcEdJig::kNormal)
return AcEdJig::kNoChange;
}
else if (mPromptCounter == 1) {
static double angTemp=-1;
//AcGePoint3d basePnt=mInsertPt;
stat = acquireAngle(mAng, mInsertPt);
if (angTemp != mAng)
{
angTemp = mAng;
rotateForm.setToRotation(mAng,mNormal,mInsertPt);
}
else if (stat == AcEdJig::kNormal)
return AcEdJig::kNoChange;
}
return stat;
}
// This function is called to update the entity based on the
// input values.
//
Adesk::Boolean
AsdkMyJig::update()
{
switch (mPromptCounter) {
case 0:
xform=moveForm;
break;
case 1:
{
xform.setToProduct(rotateForm,moveForm);
}
break;
}
// Now update the ellipse with the latest setting.
//
pBlockReference->setBlockTransform(xform);
return Adesk::kTrue;
}
// This function must be implemented to return a pointer to
// the entity being manipulated by the jig.
//
AcDbEntity*
AsdkMyJig::entity() const
{
return pBlockReference;
} |
|