PPR Hub |
Product Modeler |
Enabling Cut, Copy and Paste Operations on New Features in a Product DocumentCutting, Copying and Pasting new features |
Use Case | ||
CAAPstIntegrateNewFeatures > CAAPstINFBuildCatalog > CAAPstINFCreateDocument > CAAPstINFInitCont > CAAPstINFNavigate > CAAPstINFVisu > CAAPstINFGraphicalProperties > CAAPstINFEdit > CAAPstINFCCP > CAAPstINFDelete > CAAPstINFUpdate |
AbstractThis article discusses the CAAPstINFCCP use case. This use case explains how to implement cut, copy and paste operations on features created in applicative containers in a Product document. |
This use case is intended to illustrate how to program the necessary tasks that allow features to be cut or copied and pasted on to another root. In this example, the paste operation takes place within the same applicative container but on a different root. There are basically two different tasks to be programmed:
In order to accomplish these tasks, it is necessary to create an extension class of the existing CATICutAndPastable adapter class called ObjectCCP_Spec.
You should already be familiar with the CAAPstIntegrateNewFeatures use case article [1] in order to more easily understand the context of this particular use case. A general pre-requisite knowledge of the Feature Modeler may be required to fully understand this sample. You may want to review the basics of the Feature Modeler by looking over the "Feature Modeler Overview" technical article [2]. You may also want to look over the "Working with Cut, Copy and Paste Operations" use case of the Feature Modeler [3].
[Top]
The CAAPstINFCCP a use case that is part of the CAAPstIntegrateNewFeatures use case defined in the CAAProductStructure.edu framework that illustrates the integration of ObjectSpecsModer, ObjectModelerBase and ApplicationFrame framework capabilities in the scope of a Product document.
[Top]
This use case shows how to enable cut, copy and paste operations on features in applicative containers. It also shows how to enable the cut, copy and paste operations in the contextual menu for these features as well.
The ObjectCCP_Spec adapter of CATICutAndPastable is used to perform the cut, copy and paste operations. However, since these features are particular "from scratch" features created in applicative containers, some specific tasks need to be overridden.
There are two CATICsoFilter implementations as well. The first filters the operations available on the "CAAPstINFRoot" features which enable only the "Paste" operation to be selected. The second filters the operations available on the other features which can be cut or copied but not pasted.
[Top]
See the section entitled "How to Launch the CAAPstIntegrateNewFeatures Use Case" in the "Integrating New Features in a Product Structure" use case for a detailed description of how this use case should be launched.
Specifically, the code described in this article is executed during the following scenario:
Launch CATIA. When the application is ready, follow the scenario described below:
Select File + Open and select the CAAPstINFDocument.CATProduct
in the CAAProductStructure.edu/CNext/resources/graphic
directory or select the document you created yourself by executing the batch
program described in the previous step.
Collapse the "CAAPstINFRoot1" node by selecting the "+" symbol: notice that this root aggregates seven features of which five are of type "CAAPstINFPoint", one "CAAPstINFLine" and one "CAAPstINFWire".
Display the contextual menu on the "CAAPstINFPoint1" feature.
Select "Copy".
Display the contextual menu on the "CAAPstINFRoot2" feature.
Select "Paste". Notice that a new feature, "CAAPstINFPoint1.1" has been aggregated to the "CAAPstINFRoot2" feature by copy/paste. The new point has the same coordinate values as the point it is copied from, so its geometry cannot be visualized.
The CAAPstINFDocument.CATProduct document that can be found in the CNext/resources/graphic directory of the CAAProductStructure.edu framework.
[Top]
This use case describes the implementation class of the CATICutAndPastable interface on the one hand for the "CAAPstINFRoot" feature, called CAAEPstINFCCPRoot, which is found in the CAAEPstINFCCPRoot.cpp source file and CAAEPstINFCCPRoot.h header file and on the other hand for the "CAAPstINFPoint", "CAAPstINFLine" and "CAAPstINFWire" features, called CAAEPstINFCCPFeature, which is found in the CAAEPstINFCCPFeature.cpp source file and CAAEPstINFCCPFeature.h header file. Both of these implementations can be found in the CAAPstINFModeler.m shared library. It also describes the implementation of the CATICSOFilter interface, on the one hand for the "CAAPstINFRoot" feature called CAAEPstINFCSORoot, which is found in the CAAEPstINFCSORoot.cpp source file and CAAEPstINFCSORoot.h header file and on the other hand for all the other geometrical objects called CAAEPstINFCSOFeature which is found in the CAAEPstINFCSOFeature.cpp source file and CAAEPstINFCSOFeature.h header file. Both of these implementations can be found in the CAAPstINFCommands.m shared library.
Windows | InstallRootDirectory\CAAProductStructure.edu\CAAPstINFModeler.m
and CAAPstINFCommands.m |
Unix | InstallRootDirectory/CAAProductStructure.edu/CAAPstINFModeler.m
and CAAPstINFCommands.m |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
There are three logical steps in CAAPstINFCCP:
We will now comment each of these sections by looking at the code.
[Top]
Implementing the CATICutAndPastable Interface for Root Features
1. Overriding the BoundaryExtract
method of ObjectCCP_Spec.
int CAAEPstINFCCPRoot::BoundaryExtract (ListOfVarBaseUnknown &pObjectsAlreadyInBoundary, const ListOfVarBaseUnknown *pObjectsToAdd, const CATFormat *pAnImposedFormat) const { cout <<"******CAAEPstINFCCPRoot::BoundaryExtract"<<endl; // Retrieve a list of the root's children int num = 0; CAAIPstINFRoot *piRoot = NULL; CATBaseUnknown *pRoot = (CATBaseUnknown*) this; HRESULT rc = pRoot -> QueryInterface(IID_CAAIPstINFRoot, (void**) &piRoot); if (FAILED(rc)) return num; CATListValCATBaseUnknown_var *pList = NULL; rc = piRoot -> GetChildren(&pList); piRoot->Release(); piRoot = NULL; if (SUCCEEDED(rc) && pList) { for (int i=1; i<=pList->Size(); i++) { pObjectsAlreadyInBoundary.Append((*pList)[i]); num ++; } } else cout << "Error in GetChildren." << endl; delete pList; pList = NULL; return num; } ... |
This method is called whenever a cut or copy has been requested on a "CAAPstINFPoint", "CAAPstINFLine" or "CAAPstINFWire" feature in order to add the new feature to the list of extracted objects that need to be pasted on the root.
First of all, a CAAIPstINFRoot pointer is retrieved on
the current object. Remember that the CAAIPstINFRoot interface handles
the retrieving and setting of data on the "CAAPstINFRoot" feature.
This interface is described in detail in the "Creating New Features
"From Scratch" in a Product Document" use case [4].
Using the pointer to CAAIPstINFRoot, we can call the GetChildren
method to retrieve the list of the features already aggregated to this root.
Then, we can append the features selected to be pasted to the new root.
[Top]
2. Overriding the BoundaryRemove
and Remove
methods of ObjectCCP_Spec.
int CAAEPstINFCCPRoot::BoundaryRemove (ListOfVarBaseUnknown &pObjectsAlreadyInBoundary, const ListOfVarBaseUnknown *pObjectsToRemove, const CATFormat *pAnImposedFormat) const { cout <<"******CAAEPstINFCCPRoot::BoundaryRemove"<<endl; return 0; // prohibit the removal of the root } int CAAEPstINFCCPRoot::Remove (ListOfVarBaseUnknown &pObjectToRemove, const CATFormat *pAnImposedFormat) { cout <<"******CAAEPstINFCCPRoot::Remove"<<endl; return 0; // prohibit the removal of the root } |
These methods are empty. Nevertheless, they need to be overridden in order to prevent the root node from being deleted.
[Top]
Implementing the CATICutAndPastable Interface for Point, Line and Wire Features
int CAAEPstINFCCPFeature::Update (CATBaseUnknown_Associations &pAssociationOfObjects, const CATFormat *pAnImposedFormat , ListOfVarBaseUnknown *pToCurObjects) { cout << "*********** CAAEPstINFCCPFeature::Update" << endl; //Add this object to the root HRESULT rc; int num = 0; // As long as the list is not null, search for the root node if ((NULL != pToCurObjects) && (pToCurObjects->Size())) { CATPathElement *pPath = (CATPathElement*)(CATBaseUnknown*)(*pToCurObjects)[1]; CAAIPstINFRoot *piRoot = NULL; if (NULL != pPath) { rc = pPath -> Search(IID_CAAIPstINFRoot, (void**) &piRoot); } if (SUCCEEDED(rc)) { // Paste the object under the root CATISpecObject *piSpecObjectOnThis = NULL; rc = this -> QueryInterface (IID_CATISpecObject, (void**) &piSpecObjectOnThis); if (SUCCEEDED(rc)) { piRoot -> AddChild (piSpecObjectOnThis); piSpecObjectOnThis -> Release(); piSpecObjectOnThis = NULL; } piRoot->Release(); piRoot = NULL; num = 1; } } // Update num = ObjectCCP_SPEC::Update(pAssociationOfObjects, pAnImposedFormat, pToCurObjects); return num; } |
This method is executed on a "CAAPstINFPoint", "CAAPstINFLine" or "CAAPstINFWire" feature that is to be pasted to a new root node.
In this method, the root node to be pasted is searched for in
the list of objects passed as an argument. When it is found, the new feature to
be pasted is aggregated to it using the AddChild
method of the CAAIPstINFRoot
local interface. Then, the Update method of ObjectCCP_Spec is called to
perform the necessary internal tasks relating to the Update operation of the CCP
mechanism.
[Top]
Implementing the CATICSOFilter Interface for Root Features
HRESULT CAAEPstINFCSORoot::CommandIsAvailable (const char *pHeaderID, const CATCSO *pCSO) { cout << "******CAAEPstINFCSORoot::CommandIsAvailable" << endl; HRESULT result; result = E_FAIL; if (!strcmp(pHeaderID, "Paste")) result = S_OK; return result; } |
The implementation of the CATICSOFilter interface on the "CAAPstINFRoot" feature defines which operations of the contextual menu are available for this particular feature type. Because this is a root feature, the only operation allowed is the "Paste".
[Top]
Implementing the CATICSOFilter Interface for Point, Line and Wire Features
HRESULT CAAEPstINFCSO::CommandIsAvailable (const char *pHeaderID, const CATCSO *pCSO) { cout << "******CAAEPstINFCSO::CommandIsAvailable" << endl; return S_OK; } |
By providing an empty implementations, all of the contextual menu operations are made available for the features implementing this interface.
[Top]
The CAAPstINFCCP use case has shown you how to program the cut, copy and paste operations for features created "from scratch" in applicative containers. You have seen how to derive from the ObjectCCP_Spec adapter of CATICutAndPastable in order to override certain methods to perform specific tasks related to these features. You have also seen how to make the cut, copy and paste operations available in the contextual menu of these features by implementing the CATICSOFilter interface.
[Top]
[1] | Integrating New Features in a Product Document |
[2] | Feature Modeler Overview |
[3] | Working with Cut, Copy and Paste Operations |
[4] | Creating New Features "From Scratch" in a Product Document |
[Top] |
Version: 1 [June 2002] | Document created |
[Top] |
Copyright © 2002, Dassault Systèmes. All rights reserved.