我已经创建了一个项目,希望使用C ++这样的编程语言来创建点要素。
我已经创建了我的框架和模块。
我添加了一个与TIE_CATIAfrGeneralWksAddin绑定的组件。
然后我添加了create命令和创建的工具栏方法,并包括了支持文件。
然后我又添加了一个源文件,其中包括包含我的点创建代码的Activate方法。
在工具菜单上构建Catia后运行Catia时,我可以看到自定义按钮,该按钮将创建点,但是当我单击该按钮时,它应根据我的知识创建一个点并执行激活方法。
但是当我单击该按钮时,它显示错误“无法访问命令”
这是我的代码
// Module contains
////////////////////////////////////////// POintComponent.h
#include "CATBaseUnknown.h"
class CATCmdContainer;
class PointComponent: public CATBaseUnknown
{
CATDeclareClass;
public:
// Standard constructors and destructors for an implementation class
// -----------------------------------------------------------------
PointComponent ();
virtual ~PointComponent ();
void CreateCommands();
CATCmdContainer * CreateToolbars();
private:
-------------------------------------------------------------------
PointComponent (PointComponent &);
PointComponent& operator=(PointComponent&);
};
/////////////////////////////////////////PointComponent.cpp
#include "PointComponent.h"
// ApplicationFrame framework
#include "CATCreateWorkshop.h"
#include "CATCommandHeader.h"
MacDeclareHeader(PointComponentHeader);
#include "CATIAfrGeneralWksAddin.h"
CATImplementClass(PointComponent,
Implementation,
CATBaseUnknown,
CATnull );
//TIE or TIEchain definitions
#include "TIE_CATIAfrGeneralWksAddin.h"
TIE_CATIAfrGeneralWksAddin(PointComponent);
//-----------------------------------------------------------------------------
// PointComponent : constructor
//-----------------------------------------------------------------------------
PointComponent::PointComponent():
CATBaseUnknown()
{
}
//-----------------------------------------------------------------------------
// PointComponent : destructor
//-----------------------------------------------------------------------------
PointComponent::~PointComponent()
{
}
void PointComponent::CreateCommands ()
{
// Instantiates the command header for the command
new PointComponentHeader("CommandButtonCmd1", "PointComponent","Point", (void *)NULL);
}
//-----------------------------------------------------------------------------
// Implements CATIWorkbenchAddin::CreateToolbars
//-----------------------------------------------------------------------------
CATCmdContainer * PointComponent::CreateToolbars ()
{
NewAccess(CATCmdContainer,pToolbarContainer,PointComponentToolBar);
NewAccess(CATCmdStarter,pCommandStarter,PointComponentStarter);
SetAccessCommand(pCommandStarter,"CommandButtonCmd1");
SetAccessChild(pToolbarContainer,pCommandStarter);
AddToolbarView (pToolbarContainer,1,Top);
return pToolbarContainer;
}
//////////////////////////////////////Point.h
#include "CATCommand.h"
class Point
{
public:
Point();
~Point();
CATStatusChangeRC Point::Activate( CATCommand * iFromClient, CATNotification * iEvtDat)
};
//////////////////////////////////////////////Point.cpp
#include "Point.h"
// Dialog framework
#include "CATDlgNotify.h"
#include "CATFrmEditor.h"
#include "CATCreateExternalObject.h"
#include "CATDocument.h"
#include "CATIContainer.h"
#include "CATIGSMFactory.h"
#include "CATIPrtFactory.h"
#include "CATICkeParmFactory.h"
#include "CATIGSMPoint.h"
#include "CATISpecObject.h"
#include "CATIGSMProceduralView.h"
#include "CATApplicationFrame.h"
#include "CATIContainerOfDocument.h"
#include "CATIGSMPointCoord.h"
#include "CATPoint.h"
CATCreateClass(Point);
Point::Point() :
CATCommand(NULL, "Point")
{
RequestStatusChange(CATCommandMsgRequestExclusiveMode);
}
//-------------------------------------------------------------------------
// Destructor
//-------------------------------------------------------------------------
Point::~Point()
{
}
CATStatusChangeRC Point::Activate( CATCommand * iFromClient, CATNotification * iEvtDat)
{
CATFrmEditor* pEditor = CATFrmEditor::GetCurrentEditor();
if(pEditor == NULL)
{
printf("error getting the FRM editor");
}
CATDocument *pDoc = pEditor->GetDocument();
CATIContainerOfDocument_var spConODocs = pDoc;
CATIContainer* pSpecContainer = NULL;
HRESULT hr = spConODocs->GetSpecContainer(pSpecContainer);
if(spConODocs == NULL_var)
{
printf("error getting the container of documents");
}
CATIGSMFactory_var spGSMFactory = NULL_var;
CATIPrtFactory_var spPrtFactory = NULL_var;
CATICkeParmFactory_var spParmFactory = NULL_var;
spGSMFactory = pSpecContainer;
spPrtFactory = pSpecContainer;
spParmFactory = pSpecContainer;
double Coords[3];
Coords[0] = 0;
Coords[1] = 0;
Coords[2] = 0;
CATIGSMPoint_var spPoint1 = spGSMFactory->CreatePoint(Coords); //Creates a point
CATISpecObject_var spSpecPoint1 = spPoint1; //Casts the point as a CATISpecObject
spSpecPoint1->Update();
CATIGSMProceduralView_var spPntObj = spSpecPoint1;
spPntObj->InsertInProceduralView();
return (CATStatusChangeRCCompleted);
}
//////////////////////////////////////// imakefile.mk contains
BUILT_OBJECT_TYPE=SHARED LIBRARY
# DO NOT EDIT :: THE CAA2 WIZARDS WILL ADD CODE HERE
WIZARD_LINK_MODULES = JS0GROUP \
JS0FM JS0GROUP ApplicationFrame CATAfrUUID
# END WIZARD EDITION ZONE
LINK_WITH = $(WIZARD_LINK_MODULES) \
CATApplicationFrame \
CATGitInterfaces \
CATObjectSpecsModeler \
CATDialogEngine \
CATMathematics \
CATObjectModelerBase \
CATPartInterfaces \
CATMecModInterfaces \
//////////////////////////// identity.h file of framework contains
AddPrereqComponent ("ApplicationFrame", Public);
AddPrereqComponent ("Dialog" , Public);
AddPrereqComponent ("System", Public);
AddPrereqComponent ("GSMInterfaces", Public);
AddPrereqComponent ("ObjectModelerBase", Public);
AddPrereqComponent ("PartInterfaces", Public);
AddPrereqComponent ("KnowledgeInterfaces", Public);
AddPrereqComponent ("MecModInterfaces",Public);
AddPrereqComponent ("Visualization" , Public);
AddPrereqComponent ("GeometryVisualization" , Public);
AddPrereqComponent ("DialogEngine" , Public);
// INF Group - Base
AddPrereqComponent ("Mathematics" , Public);
AddPrereqComponent ("ObjectSpecsModeler" , Public);
AddPrereqComponent ("GeometricObjects" , Public);
/////////////////////////////////CNext msgcatlog contains CATNI & Rsc files folder contains
/ // / // / // / / PointComponent.CATNI contains
pointToolBar.Title = "Toolbar 1";
//////////////////// PointComponentHeader.CATNIs contains
PointComponentHeader.CommandButtonCmd1.Title = "cmd1";
PointComponentHeader.CommandButtonCmd1.Help = "cmd1 long help text";
PointComponentHeader.CommandButtonCmd1.ShortHelp = "cmd1 info";
/////////////////////////////////// PointComponentHeader.CATRsc contains
PointComponentHeader.CommandButtonCmd1.Icon.Normal="Point_I";