2014-09-21 16:28:52|?次阅读|上传:wustguangh【已有?条评论】发表评论
关键词:C/C++, CAA, CATIA|来源:唯设编程网
状态转换函数BuildGraph中实现了代理定义,状态定义和状态转换的定义:
void CAAPadCreateStCmd::BuildGraph() { //--------------------------------- //1. 定义代理 //--------------------------------- //1.1 草图选择代理 _pSelSketchAgent = new CATPathElementAgent("SelSketch"); _pSelSketchAgent->AddElementType("CATISketch"); _pSelSketchAgent->SetBehavior(CATDlgEngWithPSOHSO); //1.2 初始化确定按钮代理 _pDlgOKAgent = new CATDialogAgent("OKAgent"); _pDlgOKAgent->AcceptOnNotify(_pDlgInput, _pDlgInput->GetDiaOKNotification()); //--------------------------------- //2. 定义状态 //--------------------------------- //2.1 选择草图 CATDialogState* pSelSketchState = GetInitialState("选择一个草图"); pSelSketchState->AddDialogAgent(_pSelSketchAgent); //2.2 点击确定 CATDialogState* pClickOKState = AddDialogState("输入拉伸长度并点击确定"); pClickOKState->AddDialogAgent(_pDlgOKAgent); //--------------------------------- //3. 定义转换 //--------------------------------- AddTransition(pSelSketchState, pClickOKState, IsOutputSetCondition(_pSelSketchAgent), Action((ActionMethod)&CAAPadCreateStCmd::SelectSketch)); AddTransition(pClickOKState, NULL, IsOutputSetCondition(_pDlgOKAgent), Action((ActionMethod)&CAAPadCreateStCmd::CreatePad)); }
关于状态命令的相关介绍参考第一章的基本命令使用部分内容,这里不再详细介绍。
//结束当前命令 void CAAPadCreateStCmd::ExitCommand(CATCommand * iCommand, CATNotification * iNotification, CATCommandClientData iUsefulData){ this->RequestDelayedDestruction(); }
//选择草图 CATBoolean CAAPadCreateStCmd::SelectSketch(void* data){ //1. 获取选择对象 CATBaseUnknown* pBaseUnknown = _pSelSketchAgent->GetElementValue(); _pSelSketchAgent->InitializeAcquisition(); //2. 将选择对象赋值给草图对象 _spSketchObj = pBaseUnknown; if(NULL_var == _spSketchObj) return CATFalse; //3. 获取编辑框指针 CATDlgEditor* pEditor = _pDlgInput->GetEditorControl(1); if(NULL == pEditor) return CATFalse; //4. 获取对象别名 CATIAlias_var spAliasObj = _spSketchObj; if(NULL_var == spAliasObj) return CATFalse; CATUnicodeString strSketchName = spAliasObj->GetAlias(); //5. 将别名显示到编辑框 pEditor->SetText(strSketchName); return CATTrue; }