CAA创建基于草图拉伸(Pad) 的状态命令

2014-09-21 16:28:52|?次阅读|上传:wustguangh【已有?条评论】发表评论

关键词:C/C++, CAA, CATIA|来源:唯设编程网

3.  在命令类PadStateCmd添加成员变量

下面是命令类CAApadCreateStCmd的头文件:

class CAAPadCreateStCmd: public CATStateCommand
{

    //省略其它向导生成代码

    //结束当前命令
    void ExitCommand();
    //选择草图
    CATBoolean SelectSketch(void* data);
    //创建拉伸体
    CATBoolean CreatePad(void* data);
    //验证用户输入
    CATBoolean ValidateInput();

private:

    //参数输入对话框
    PadParamInputDlg*       _pDlgInput;
    //草图选择代理
    CATPathElementAgent*    _pSelSketchAgent;
    //输入对话框确定按钮代理
    CATDialogAgent*     _pDlgOKAgent;
    //保存草图对象
    CATISpecObject_var  _spSketchObj;
    //第一方向偏移长度
    double              _fOffset1;
    //第二方向偏移长度
    double              _fOffset2;

};

在构造函数对相关成员进行初始化:

CAAPadCreateStCmd::CAAPadCreateStCmd() :
CATStateCommand ("CAAPadCreateStCmd", CATDlgEngOneShot, CATCommandModeExclusive)
//  Valid states are CATDlgEngOneShot and CATDlgEngRepeat
,_pDlgInput(NULL)
,_pSelSketchAgent(NULL)
,_pDlgOKAgent(NULL)
,_spSketchObj(NULL_var)
,_fOffset1(0.0)
,_fOffset2(0.0)
{

    //初始化对话框
    _pDlgInput = new PadParamInputDlg();
    _pDlgInput->Build();
    _pDlgInput->SetVisibility(CATDlgShow);

    //添加创建直线对话框的消息回调函数
    AddAnalyseNotificationCB(_pDlgInput,
        _pDlgInput->GetWindCloseNotification(),
        (CATCommandMethod)&CAAPadCreateStCmd::ExitCommand,
        (void*)NULL);

    AddAnalyseNotificationCB(_pDlgInput,
        _pDlgInput->GetDiaCANCELNotification(),
        (CATCommandMethod)&CAAPadCreateStCmd::ExitCommand,
        (void*)NULL);

}

在析构函数添加相应资源释放的代码:

CAAPadCreateStCmd::~CAAPadCreateStCmd()
{

    //析构对话框
    if(NULL != _pDlgInput){
        _pDlgInput->RequestDelayedDestruction();
        _pDlgInput = NULL;
    }

    //析构草图选择代理
    if(NULL != _pSelSketchAgent){
        _pSelSketchAgent->RequestDelayedDestruction();
        _pSelSketchAgent = NULL;
    }

    //析构对话框确定按钮代理
    if(NULL != _pDlgOKAgent){
        _pDlgOKAgent->RequestDelayedDestruction();
        _pDlgOKAgent = NULL;
    }
}
发表评论0条 】
网友评论(共?条评论)..
CAA创建基于草图拉伸(Pad) 的状态命令