ObjectARX单点JIG正交简单例子
2021/12/24 23:38:03
本文主要是介绍ObjectARX单点JIG正交简单例子,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
代码
//----------------------------------------------------------------------------- //- BeamLineJig.h #pragma once //----------------------------------------------------------------------------- class CBeamLineJig : public AcEdJig { public: //- Array of input points, each level corresponds to the mCurrentInputLevel AcGePoint3d mPtStart ; AcGePoint3d mPtEnd ; //- Entity being jigged AcDbLine *mpEntity ; public: CBeamLineJig () ; ~CBeamLineJig () ; //- Command invoke the jig, call passing a new'd instance of the object to jig AcEdJig::DragStatus startJig (AcDbLine *pEntityToJig,AcGePoint3d ptStart) ; protected: //- AcEdJig overrides //- input sampler virtual DragStatus sampler () ; //- jigged entity update virtual Adesk::Boolean update () ; //- jigged entity pointer return virtual AcDbEntity *entity () const ; //- Std input to get a point with no rubber band AcEdJig::DragStatus GetStartPoint () ; } ;
Cpp
//----------------------------------------------------------------------------- #include "StdAfx.h" #include "BeamLineJig.h" //----------------------------------------------------------------------------- CBeamLineJig::CBeamLineJig () : AcEdJig (), mpEntity(NULL) { } CBeamLineJig::~CBeamLineJig () { } //----------------------------------------------------------------------------- AcEdJig::DragStatus CBeamLineJig::startJig (AcDbLine *pEntity ,AcGePoint3d ptStart) { //- Store the new entity pointer mpEntity = pEntity ; mPtStart=ptStart; mPtEnd=mPtStart; //- Setup each input prompt AcString inputPrompts =_T("\n请指定终点: " ); //- Setup kwords for each input AcString kwords = _T(""); bool appendOk =true ; AcEdJig::DragStatus status =AcEdJig::kNull ; //初始化 //- Loop the number of inputs setDispPrompt (inputPrompts) ; //- Setup the keywords required setKeywordList (kwords) ; bool quit =false ; //- Lets now do the input status =drag () ; if ( status != kNormal ) { //- If it's a keyword switch ( status ) { case kCancel: case kNull: quit =true ; break ; case kKW1: case kKW2: case kKW3: case kKW4: case kKW5: case kKW6: case kKW7: case kKW8: case kKW9: //- Do something break ; } } else { appendOk =true ; } //拖动结束 //- If the input went well if ( appendOk ) //- Append to the database append () ; else //- Clean up delete mpEntity ; return (status) ; } //----------------------------------------------------------------------------- //- Input sampler AcEdJig::DragStatus CBeamLineJig::sampler () { //- Setup the user input controls for each input AcEdJig::UserInputControls userInputControls [1] ={ /*AcEdJig::UserInputControls::*/(AcEdJig::UserInputControls)0 } ; //- Setup the cursor type for each input AcEdJig::CursorType cursorType [1] ={ /*AcEdJig::CursorType::*/(AcEdJig::CursorType)0 } ; //- Setup the user input controls for each sample setUserInputControls (userInputControls [0]) ; setSpecialCursorType (cursorType [0]) ; AcEdJig::DragStatus status =AcEdJig::kCancel ; //- Check the current input number to see which input to do status =GetStartPoint () ; return (status) ; } //----------------------------------------------------------------------------- //- Jigged entity update Adesk::Boolean CBeamLineJig::update () { //- Check the current input number to see which update to do mpEntity->setEndPoint(mPtEnd); return true ; } //----------------------------------------------------------------------------- //- Jigged entity pointer return AcDbEntity *CBeamLineJig::entity () const { return ((AcDbEntity *)mpEntity) ; } //----------------------------------------------------------------------------- //- Std input to get a point with no rubber band AcEdJig::DragStatus CBeamLineJig::GetStartPoint () { AcGePoint3d newPnt ; //- Get the point AcEdJig::DragStatus status =acquirePoint (newPnt,mPtStart) ; //- If valid input if ( status == AcEdJig::kNormal ) { //- If there is no difference if ( newPnt.isEqualTo (mPtEnd)) return (AcEdJig::kNoChange) ; //- Otherwise update the point mPtEnd =newPnt ; } return (status) ; }
调用示意
ads_point pt; if (RTNORM != acedGetPoint(NULL,_T("\n请指定起点: "),pt)) { return; } acdbUcs2Wcs(pt,pt,false); AcGePoint3d ptStart=asPnt3d(pt); CBeamLineJig *pJig=new CBeamLineJig(); AcDbLine*pLine=new AcDbLine(); pLine->setStartPoint(ptStart); pJig->startJig(pLine,ptStart); delete pJig; pJig=NULL;
这篇关于ObjectARX单点JIG正交简单例子的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-25【机器学习(二)】分类和回归任务-决策树(Decision Tree,DT)算法-Sentosa_DSML社区版
- 2024-11-23增量更新怎么做?-icode9专业技术文章分享
- 2024-11-23压缩包加密方案有哪些?-icode9专业技术文章分享
- 2024-11-23用shell怎么写一个开机时自动同步远程仓库的代码?-icode9专业技术文章分享
- 2024-11-23webman可以同步自己的仓库吗?-icode9专业技术文章分享
- 2024-11-23在 Webman 中怎么判断是否有某命令进程正在运行?-icode9专业技术文章分享
- 2024-11-23如何重置new Swiper?-icode9专业技术文章分享
- 2024-11-23oss直传有什么好处?-icode9专业技术文章分享
- 2024-11-23如何将oss直传封装成一个组件在其他页面调用时都可以使用?-icode9专业技术文章分享
- 2024-11-23怎么使用laravel 11在代码里获取路由列表?-icode9专业技术文章分享