ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

ObjectARX单点JIG正交简单例子

2021-12-24 23:33:50  阅读:186  来源: 互联网

标签:case JIG 单点 ObjectARX CBeamLineJig status AcEdJig input DragStatus


代码

//-----------------------------------------------------------------------------
//- 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;

标签:case,JIG,单点,ObjectARX,CBeamLineJig,status,AcEdJig,input,DragStatus
来源: https://www.cnblogs.com/edata/p/15729579.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有