Machining

NC Review

Cutting a Tool Path by a Point

Manipulating a tool path
Use Case

Abstract

This article discusses the CAAMfgTPEOnePointSelectionUserCom use case.


What You Will Learn With This Use Case

This use case is intended to help you manipulate the tool path structure. This involves the following:

[Top]

The CAAMfgTPEOnePointSelectionUserCom Use Case

CAAMfgTPEOnePointSelectionUserCom is a use case of the CAAToolPathEditorItf.edu framework that illustrates ToolPathEditor framework capabilities.

[Top]

What Does CAAMfgTPEOnePointSelectionUserCom Do

CAAMfgTPEOnePointSelectionUserCom runs with the document CAAMfgToolPath.CATPart shown on Fig.1

Fig. 1: Cutting a tool path by a point

[Top]

How to Launch CAAMfgTPEOnePointSelectionUserCom

[Top]

Where to Find the CAAMfgTPEOnePointSelectionUserCom Code

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

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

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

[Top]

Step-by-Step

There are four logical steps in CAAMfgTPEOnePointSelectionUserCom:

  1. Creating a Command
  2. Selecting a Tool Path
  3. Selecting a Point
  4. Giving the Selected Point to the Tool Path Editor

We now comment each of those sections by looking at the code.

[Top]

Creating a Command

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

class ExportedByCAAMfgTPEAddCmdInCutAreaToolBar CAAMfgTPEOnePointSelectionUserCom : public CATStateCommand
{
  public:
    DeclareResource(CAAMfgTPEOnePointSelectionUserCom,CATStateCommand)
    CAAMfgTPEOnePointSelectionUserCom (void* ipCutAreasEditor);
    virtual ~CAAMfgTPEOnePointSelectionUserCom ();
    void BuildGraph();
    CATStatusChangeRC Activate (CATCommand*, CATNotification*);
    CATStatusChangeRC Cancel (CATCommand*, CATNotification*);
    CATStatusChangeRC Desactivate (CATCommand*, CATNotification*);
    void PreActivate (CATCommand* c1, CATNotification* c2, CATCommandClientData c3);
    void Move (CATCommand* c1, CATNotification* c2, CATCommandClientData c3);
    void EndPreActivate (CATCommand*, CATNotification*, CATCommandClientData);
    CATBoolean SelectPoint (void*);
    CATBoolean HasPoint (void*);
  private:
    CATIMfgTPECutAreasEditor* _pCutAreasEditor;
    CATDialogAgent* _PointAgent;
    CATSelector* _Selector;
    CATMathPoint _CurrentPoint;
    CAT3DViewer* _Viewer;
    CATCallback _PreactivateCB;
    CATCallback _MoveCB; 
    CATCallback _EndPreactivateCB;
    CATBoolean _HasPoint;
};

The CAAMfgTPEOnePointSelectionUserCom class C++-derives from CATStateCommand. The DeclareResource macro declares that the ressource file is CAAMfgTPEOnePointSelectionUserCom.CATNls. The class has a constructor, a destructor, a SelectPoint method to give the selected point to the tool path editor, several methods to manage the user's interaction and the representation of the tool path, and a copy constructor.

This command will communicate with the tool path editor by the interface CATIMfgTPECutAreasEditor.

[Top]

Selecting a Tool Path

First you have to create a selector which must work with the representation of the tool path. This last one can be retrieved by a call to the method GetToolPathRep of the interface CATIMfgTPECutAreasEditor. The first argument of the constructor is used to get the interface CATIMfgTPECutAreasEditor. This is done in the constructor.

CAAMfgTPEOnePointSelectionUserCom::CAAMfgTPEOnePointSelectionUserCom (void* ipCutAreasEditor)
        : CATStateCommand("TPESelectionUserOnePoint", NULL, CATCommandModeShared),
          _Selector(NULL), _Viewer(NULL),
          _pCutAreasEditor((CATIMfgTPECutAreasEditor*) ipCutAreasEditor),
          _HasPoint(CATFalse), _PointAgent(NULL),
          _PreactivateCB(NULL),
          _MoveCB(NULL),
          _EndPreactivateCB(NULL)
{
  CAT3DViewer* viewer3D = NULL;
          
  CATFrmLayout* ptrFrmLayout = CATFrmLayout::GetCurrentLayout();
  if ( ptrFrmLayout) {
    const CATFrmWindow * ptrFrmWindow = ptrFrmLayout->GetCurrentWindow () ;
    if (ptrFrmWindow && ptrFrmWindow->IsAKindOf(CATFrmGraphAnd3DWindow::ClassName()) ) {
      CATFrmGraphAnd3DWindow* ptr3DWindow = (CATFrmGraphAnd3DWindow*)ptrFrmWindow;
      CATViewer * viewer = ptr3DWindow->GetGraphicViewer();
      if( viewer && viewer->IsAKindOf(CAT3DViewer::ClassName()) )
        _Viewer = (CAT3DViewer*)viewer;
    }
  }
  //Creation of the selector. Tool path can be pointed.
  CATRep* Rep = NULL;
  if (NULL != _pCutAreasEditor)
    Rep = _pCutAreasEditor->GetToolPathRep();
  _Selector = new CATSelector(this,"ToolPathSelector", Rep);
  _PreactivateCB    = AddAnalyseNotificationCB (_Selector,
                                                _Selector->GetCATPreactivate(),
                                                (CATCommandMethod)&CAAMfgTPEOnePointSelectionUserCom::PreActivate,NULL);
  _MoveCB           = AddAnalyseNotificationCB (_Selector,
                                                _Selector->GetCATMove(),
                                                (CATCommandMethod)&CAAMfgTPEOnePointSelectionUserCom::Move,NULL);
  _EndPreactivateCB = AddAnalyseNotificationCB (_Selector,
                                                _Selector->GetCATEndPreactivate(),
                                                (CATCommandMethod)&CAAMfgTPEOnePointSelectionUserCom::EndPreActivate,NULL);
}

Now the method BuildGraph is implemented. It gets the selected point and the double-click to terminate the command.

void CAAMfgTPEOnePointSelectionUserCom::BuildGraph()
{
  _PointAgent = new CATDialogAgent("Point");
  if (NULL != _Selector)
    _PointAgent->AcceptOnNotify(_Selector, _Selector->GetCATActivate());
  // Dialog States
  CATDialogState* InitState = GetInitialState("OnePointModification");
  if (NULL != InitState)
    InitState->AddDialogAgent(_PointAgent);
  // Transitions
  AddTransition (InitState,NULL, 
  AndCondition ( Condition ( (ConditionMethod) &CAAMfgTPEOnePointSelectionUserCom::HasPoint),
  IsOutputSetCondition(_PointAgent)),
  Action((ActionMethod)& CAAMfgTPEOnePointSelectionUserCom::SelectPoint));
  SetRepeatMode(OFF);
}

[Top]

Selecting a Point

The method PreActivate selects the point.

void CAAMfgTPEOnePointSelectionUserCom::PreActivate (CATCommand* c1, CATNotification* c2, CATCommandClientData c3)
{
  // Erase of the last preview
  EndPreActivate (c1,c2,c3);
  // Get the point.
  CATGraphicElementIntersection* Intersection = NULL;
  if (NULL != _Selector)
    Intersection = (CATGraphicElementIntersection*) _Selector->SendCommandSpecificObject (CATGraphicElementIntersection::ClassName(), c2);
  if ( Intersection) {
    CATMathPoint aPoint;
    aPoint = Intersection->point;
    Intersection->Release();
    _CurrentPoint = aPoint;
    _HasPoint = CATTrue;
  }
}

[Top]

Giving the Selected Point to the Tool Path Editor

The next step is to give the point to the tool path editor which will manage the highlight of the part of the tool path. This is done by a call to the method LoadOnePointCuttingPoint of the interface CATIMfgTPECutAreasEditor.

CATBoolean CAAMfgTPEOnePointSelectionUserCom::SelectPoint (void* Data)
{
  // The point is given to the interface CATIMfgTPECutAreasEditor.
  if (_pCutAreasEditor != NULL && HasPoint(NULL) )
    _pCutAreasEditor->LoadOneCuttingPoint(_CurrentPoint);
  return CATTrue;
}

Then the tool path editor manage this part of the tool path with all the actions of the cut area tool bar.

[Top]


In Short

This article provides an example on how to add and to manage in the cut area toolbar a command that cut a tool path by a point.

[Top]


References

[1] Building and Launching a CAA V5 Use Case
[2] Use case CAAMfgTPECutAreasUserHeader
[Top]

History

Version: 1 [Jan 2003] Document created
[Top]

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