Machining

NC Review

Changing Command Headers in the Tool Path Editor

Create your own menu of tool path in the tool path editor
Use Case

Abstract

This article discusses the CAAMfgTPEUserCommandHeaders use case.


What You Will Learn With This Use Case

This use case is intended to help you create your own contextual menu for tool path.

[Top]

The CAAMfgTPEUserCommandHeaders Use Case

CAAMfgTPEUserCommandHeaders is a use case of the CAAToolPathEditorItf.edu framework that illustrates ToolPathEditorInterfaces framework capabilities.

[Top]

What Does CAAMfgTPEUserCommandHeaders Do

CAAMfgTPEUserCommandHeaders builds and customize the contextual menu of tool path as shown on Fig.1.

Fig. 1: The tool path contextual menu

[Top]

How to Launch CAAMfgTPEUserCommandHeaders

To launch CAAMfgTPEUserCommandHeaders, you will need to:

# Decomment this line into file ToolPathEditor.edu.dico to run CAAMfgTPEAddToolBar Sample
# CAAMfgTPEM3xAddin CATISmgProgramAddin libCAAMfgTPEAddToolBar
# Decomment these lines into file ToolPathEditor.edu.dico to run CAAMfgTPEUserCommandHeaders Sample
# MfgCompoundTraject CATIMfgToolPathEditorUserHeader libCAAMfgTPEUserCommandHeaders
# MfgTPMultipleMotion CATIMfgToolPathEditorUserHeader libCAAMfgTPEUserCommandHeaders

Set up the run time environment:

[Top]

Where to Find the CAAMfgTPEUserCommandHeaders Code

The CAAMfgTPEUserCommandHeaders use case is made of a class named CAAMfgTPEUserCommandHeaders located in the CAAMfgTPEUserCommandHeaders.m module of the CAAToolPathEditorItf.edu framework:

Windows InstallRootDirectory\CAADoc\CAAToolPathEditorItf.edu\CAAMfgTPEUserCommandHeaders.m
Unix InstallRootDirectory/CAADoc/CAAToolPathEditorItf.edu/CAAMfgTPEUserCommandHeaders.m

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

[Top]

Step-by-Step

There is one logical steps in CAAMfgTPEDisplayToolPathCommand:

We now comment these section by looking at the code.

[Top]

Creating the Implementation of the CATIMfgToolPathUserHeader

The class that will implement the command is named CAAMfgTPEUserCommandHeaders. Create the CAAMfgTPEUserCommandHeaders class header file:

class ExportedByCAAMfgTPEUserCommandHeadersEnv CAAMfgTPEUserCommandHeaders : public CATBaseUnknown
{
  CATDeclareClass;
public:
 
  CAAMfgTPEUserCommandHeaders();
  virtual ~CAAMfgTPEUserCommandHeaders();
   //Give the list of headers of command in the tool path editor.
	virtual HRESULT GetHeaders( CATListValCATString &ioHeadersList );
   //Say if the header of command is available for a given set of object
	virtual HRESULT IsHeadersAvailable( CATListValCATString& ioHeadersList , CATCSO* iCSO );
private :
	// The copy constructor and the equal operator must not be implemented
	// -------------------------------------------------------------------
	CAAMfgTPEUserCommandHeaders (CAAMfgTPEUserCommandHeaders &);
	CAAMfgTPEUserCommandHeaders& operator=(CAAMfgTPEUserCommandHeaders&);
	// ------------------
	// HeaderAvailability
	// ------------------
	void HeaderAvailability(const CATString& HeaderName, CATBoolean isON);
};

The CAAMfgTPEUserCommandHeaders class C++-derives from CATBaseUnknown. The class has a constructor, a destructor, and the two methods of the interface CATIMfgToolPathUserHeaders.

First you have to implement the method GetHeaders, which will provide you with getting the standard headers and to give the application yours own headers of command.

HRESULT CAAMfgTPEUserCommandHeaders::GetHeaders( CATListValCATString &ioHeadersList)
{
	HRESULT hRes= S_OK;
	// Default list of Headers of command in the Tool path Editor.
	// Each empty string is displayed as a separator in the menu.
	// TPEPointModification
	// TPEAreaModification 
	// "" 
	// TPETranslate
	// TPERotate
	// TPEMirror
	// ""
	// TPEReverse
	// TPEConnect
	// TPEApproachRetract
	// ""
	// TPEToolLength
	CATIMfgToolPathEditorHeader_var spTPEHeaders = GetImpl();
	if (!!spTPEHeaders)
		spTPEHeaders->GetHeaders(ioHeadersList);
	int index=8;
	ioHeadersList.InsertBefore(index,CATString("TPESplitToolPath"));
	index=1;
	ioHeadersList.Replace ( index, CATString("TPEDisplayToolPath"));
	// User's list of Headers of command.
	ioHeadersList.Append(CATString("TPEDisplayDistance"));
	return hRes;
}

First, we get the standard headers of the tool path editor ( if there are used ) by a call to the method GetHeaders of interface CATIMfgToolPathEditorHeader. (Note that an empty string in the list is equivalent to a separator.) Then we customize this list replacing, suppressing or adding command headers.

Now we implement the method IsHeadersAvailable.

HRESULT CAAMfgTPEUserCommandHeaders::IsHeadersAvailable( CATListValCATString& ioHeadersList , CATCSO* iCSO )
{
	HRESULT hRes= S_OK;
	if (NULL == iCSO) return E_FAIL;
	int nbSelectedItems = iCSO->GetSize();
	// if several objects are selected, the contextual menu isn't the same.
	// Two items are disabled
	if ( nbSelectedItems > 1 ) {
		// Get the CATIMfgToolPathEditorHeader interface
		CATIMfgToolPathEditorHeader_var spTPEHeaders = GetImpl();
		if (!!spTPEHeaders)
			spTPEHeaders->IsHeadersAvailable(ioHeadersList,iCSO);
		HeaderAvailability(CATString("TPESplitToolPath"), CATFalse);
	}
	return hRes;
}

First, we call the method IsHeadersAvailable of interface CATIMfgToolPathEditorHeader, if we have any standard command header of the tool path editor.

Then we can activate or deactivate our own headers. For example, if a command doesn't work for a multiple selection of tool path, it should be deactivated

[Top]


In Short

This article provides an example on how to customize the contextual menu of an object of type tool path.

[Top]


References

[1] Building and Launching a CAA V5 Use Case
[2] Dump of Tool Path Content Command
[Top]

History

Version: 1 [March 2002] Document created
[Top]

Copyright © 2002, Dassault Systèmes. All rights reserved.