admin 发表于 2017-4-17 21:57:51

Catia二次开发源码分享:选择对象的方式


Catia二次开发源码分享:选择对象的方式


#include "CAARCSelectObject.h"
#include "CATIndicationAgent.h"
#include "CATMathPlane.h"

#include "CATCreateExternalObject.h"

#include "CATIGSMPlane.h"

#include "CATIGSMPoint.h"

#include "CATPathElementAgent.h"

#include "CATPathElement.h"

#include "CATISpecObject.h"

#include "CATApplicationFrame.h"

#include "CATDlgWindow.h"

#include "CATDlgNotify.h"

CATCreateClass( CAARCSelectObject);


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

//-------------------------------------------------------------------------
// Destructor
//-------------------------------------------------------------------------
CAARCSelectObject::~CAARCSelectObject()
{

}


//-------------------------------------------------------------------------
// BuildGraph()
//-------------------------------------------------------------------------
void CAARCSelectObject::BuildGraph()
{
_daPathEltObject = new CATPathElementAgent("SpecObject");
_daPathEltObject->AddElementType(IID_CATIGSMPlane);
_daPathEltObject->SetBehavior( CATDlgEngWithPSOHSO | CATDlgEngWithPrevaluation | CATDlgEngWithUndo);

AddCSOClient(_daPathEltObject);

CATDialogState *stGetObject = GetInitialState("选择任意对象");
stGetObject->AddDialogAgent(_daPathEltObject);

CATDialogTransition *pFirstTransition = AddTransition
    (
    stGetObject,
    NULL,
    IsOutputSetCondition(_daPathEltObject),                  
    Action((ActionMethod) & CAARCSelectObject::ActionOne)
    );

}


//-------------------------------------------------------------------------
// ActionOne ()
//-------------------------------------------------------------------------
CATBoolean CAARCSelectObject::ActionOne( void *data )
{
CATPathElement* pObject = _daPathEltObject->GetValue();

//如果选择对象不为空的处理
if (pObject && pObject->GetSize())
{
    int objectSize = pObject->GetSize() - 1;
    CATBaseUnknown *sProduct = (*pObject);
    for (int i = 0; i<objectSize;i++)
    {
      CATBaseUnknown *sProduct = (*pObject);
    }

    CATISpecObject *spObject;
    sProduct->QueryInterface(IID_CATISpecObject, (void**)&spObject);

    CATUnicodeString displayName = spObject->GetName();

    CATApplicationFrame *pApplication = CATApplicationFrame::GetFrame();

    if (NULL != pApplication) {

      CATDlgWindow * pMainWindow = pApplication->GetMainWindow();

      CATDlgNotify *pNotifyDlg = new CATDlgNotify
      (pMainWindow, "提示", CATDlgNfyOK);

      if (NULL != pNotifyDlg) {
      pNotifyDlg->DisplayBlocked
          (displayName,
          "选择的类型为:");

      pNotifyDlg->RequestDelayedDestruction();
      }
    }

}

return TRUE;
}

1211523676 发表于 2019-11-13 16:49:02

谢谢分享,收藏学习一下
页: [1]
查看完整版本: Catia二次开发源码分享:选择对象的方式