zoukankan      html  css  js  c++  java
  • 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;
    

  • 相关阅读:
    UrlRewriter配置IIS支持伪静态
    Linux 安装PAE内核
    Tmux入门教程
    Tmux与Oh-my-zsh环境整合
    MySQL Route负载均衡与读写分离Docker环境使用
    MySQL数据表的基本操作
    Git安全配置
    GitLab使用自定义端口
    Gitlab搭建安装及使用中遇到的问题。
    执行Docker命令报错解决办法
  • 原文地址:https://www.cnblogs.com/edata/p/15729579.html
Copyright © 2011-2022 走看看