CAA二次开发 跨文档选择数据

前言

跨文档选择数据最常见的例子是原生功能中在工程图选择需要投影的视图平面及方向等,具体例子参考投影视图的创建

核心接口

需要使用的两个接口 CATMultiDocumentCommand与 CATOtherDocumentAgent
官方说明

具体流程

实现CATMultiDocumentCommand子类

SelectProductCmd.h头文件

// COPYRIGHT Dassault Systemes 2012
//===================================================================
//
// SelectProductCmd.h
// The state chart based command: SelectProductCmd
//
//===================================================================
//
// Usage notes:
//
//===================================================================
//CAA2 Wizard Generation Report
//   STATECOMMAND
//End CAA2 Wizard Generation Report
//
//  Dec 2012  Creation: Code generated by the CAA wizard  Administrator
//===================================================================
#ifndef SelectProductCmd_H
#define SelectProductCmd_H

#include "CATMultiDocumentCommand.h"
#include "CATBoolean.h"
#include "CATPathElementAgent.h"

class CATPathElementAgent;

//----------------------------------------------------------------------

/**
 * Describe your command here.
 * <p>
 * Using this prefered syntax will enable mkdoc to document your class.
 * <p>
 * refer to programming resources of Dialog engine framework.
 * (consult base class description).
 */
class SelectProductCmd: public CATMultiDocumentCommand
{
  // Allows customization/internationalization of command's messages
  // ---------------------------------------------------------------
  CmdDeclareResource( SelectProductCmd, CATMultiDocumentCommand )

  public:

  SelectProductCmd();
  virtual ~SelectProductCmd();

    /**
     * Defines the command automata.
     * <br>
     * <i>(states, transitions and agents)</i>
     */
  virtual void     BuildGraph();
private:

	// Copy constructor, not implemented
	// Set as private to prevent from compiler automatic creation as public.
	SelectProductCmd(const SelectProductCmd &iObjectToCopy);

	// Assignment operator, not implemented
	// Set as private to prevent from compiler automatic creation as public.
	SelectProductCmd & operator = (const SelectProductCmd &iObjectToCopy);
	/**
	* Action associated to state transitions.
	*/
	virtual CATBoolean  ActionOne(void * data);

private:

	CATPathElementAgent			m_SelectAgent;
};

//----------------------------------------------------------------------

#endif

cpp

// COPYRIGHT Dassault Systemes 2012
//===================================================================
//
// SelectProductCmd.cpp
// The state chart based command: SelectProductCmd
//
//===================================================================
//
// Usage notes:
//
//===================================================================
//
//  Dec 2012  Creation: Code generated by the CAA wizard  Administrator
//===================================================================
#include "SelectProductCmd.h"
#include "CATIndicationAgent.h"
#include "CATMathPlane.h"
#include "CATOtherDocumentAgent.h"

#include "CATCreateExternalObject.h"
CATCreateClass( SelectProductCmd);


//-------------------------------------------------------------------------
// Constructor
//-------------------------------------------------------------------------
SelectProductCmd::SelectProductCmd() :
  //CATStateCommand ("SelectProductCmd", CATDlgEngOneShot, CATCommandModeExclusive) 
//  Valid states are CATDlgEngOneShot and CATDlgEngRepeat
  m_SelectAgent("SelectProductCmdId")
{
}

//-------------------------------------------------------------------------
// Destructor
//-------------------------------------------------------------------------
SelectProductCmd::~SelectProductCmd()
{
}


//-------------------------------------------------------------------------
// BuildGraph()
//-------------------------------------------------------------------------
void SelectProductCmd::BuildGraph()
{


  // TODO: Define the StateChart 
  // ---------------------------
	if( NULL != _fromCommand )
	{
		m_SelectAgent.SetBehavior(_fromCommand->GetBehavior());
	}
	else
	{
		m_SelectAgent.SetBehavior(CATDlgEngWithPSOHSO);
	}
	m_SelectAgent.SetElementType("CATIProduct");
	//m_SelectAgent.SetElementType("CATIPrtPart");

	CATDialogState * gsmState = GetInitialState("请选择零部件");
	gsmState->AddDialogAgent(&m_SelectAgent); 

	AddTransition( gsmState, NULL, NULL,
		Action ((ActionMethod) &SelectProductCmd::ActionOne));
}


//-------------------------------------------------------------------------
// ActionOne ()
//-------------------------------------------------------------------------
CATBoolean SelectProductCmd::ActionOne( void *data )
{
  // TODO: Define the action associated with the transition 
  // ------------------------------------------------------
	if (m_SelectAgent.GetBehavior() & CATDlgEngMultiAcquisition)
	{
		ReturnListOfValues(m_SelectAgent.GetListOfValues());
	}
	else
	{
		ReturnValue(m_SelectAgent.GetValue());
	}
  return TRUE;
}

在需要使用CATOtherDocumentAgent

m_SelectOtherDocAgent = new CATOtherDocumentAgent("FeatureSelectAgent", "SelectProductCmd", "CATPathElementAgent");
	m_SelectOtherDocAgent -> SetBehavior( CATDlgEngWithPSOHSO | CATDlgEngWithPrevaluation | CATDlgEngRepeat | CATDlgEngNewHSOManager );
	m_SelectOtherDocAgent -> AddElementType("CATIProduct");
	
	//获取选择的数据
	//CATPathElement *pEle = m_SelectOtherDocAgent -> GetValue();
	//m_SelectOtherDocAgent -> InitializeAcquisition();

注意构造CATOtherDocumentAgent中第二个参数 "SelectProductCmd"为上一步构造出的cmd名称
选择类型Addtype需要对上

结束补全

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值