TransformNodeAction Class Reference

When executed this action will transform a range of NodeRenderableInk nodes. It also creates another TransformNodeAction to 'undo' the transformation just performed. It adds this action to the opposite action list. More...

#include <ops.h>

Inheritance diagram for TransformNodeAction:

Action ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 TransformNodeAction ()
 TransformNodeAction constructor.
 ~TransformNodeAction ()
void Slaughter ()
 destructor which gets called when an operation is deleted
virtual ActionCode Execute ()
 Executes the TransformNodeAction which transforms the range of nodes. It also creates another TransformNodeAction passing it the inverse of the transform.
void CombineWith (TransformNodeAction *pMatrixTransformAction)
 This function can only be called on a TransformNodeAction with a Trans2DMatrix Transform. The transform's matrix is multiplied by the matrix in the pTransformAction therby combining the transforms.
TransformBaseGetTransform ()
 Used to find the transform within the TransformNodeAction.
const RangeGetActionRange () const

Static Public Member Functions

static ActionCode Init (Operation *const pOp, ActionList *pActionList, Range NodeRangeIn, TransformBase *Trans, List *pNodeList, Action **NewAction)
 To check that there is sufficient room for the action in the operation history, and if there is, then to add the action to the operations action list.

Private Attributes

Range NodeRange
Listm_pNodeList
TransformBasepTrans

Detailed Description

When executed this action will transform a range of NodeRenderableInk nodes. It also creates another TransformNodeAction to 'undo' the transformation just performed. It adds this action to the opposite action list.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/9/93
See also:
-

Definition at line 1127 of file ops.h.


Constructor & Destructor Documentation

TransformNodeAction::TransformNodeAction  ) 
 

TransformNodeAction constructor.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/9/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 4584 of file ops.cpp.

04585 {
04586     m_pNodeList = NULL;
04587     pTrans = NULL;
04588 }

TransformNodeAction::~TransformNodeAction  ) 
 

Definition at line 4590 of file ops.cpp.

04591 {
04592     if (m_pNodeList)
04593     {
04594         m_pNodeList->DeleteAll();
04595         delete m_pNodeList;
04596         m_pNodeList = NULL;
04597     }
04598 
04599     if (pTrans)
04600     {
04601         delete pTrans;
04602         pTrans = NULL;
04603     }
04604 }   


Member Function Documentation

void TransformNodeAction::CombineWith TransformNodeAction pMatrixTransformAction  ) 
 

This function can only be called on a TransformNodeAction with a Trans2DMatrix Transform. The transform's matrix is multiplied by the matrix in the pTransformAction therby combining the transforms.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/11/94
Parameters:
pMatrixTransformAction,: A pointer to a TransformNodeAction containing a [INPUTS] Trans2DMatrix Transform
- [OUTPUTS]
Returns:
-

Errors: An Error3 will occur if either this Transform or the pMatrixTransformAction do not contain Trans2DMatrix transforms.

See also:
-

Definition at line 4849 of file ops.cpp.

04850 {
04851     // First lets make sure that we can combine the transforms
04852     ERROR3IF(!(pMatrixTransformAction->GetTransform()->IS_KIND_OF(Trans2DMatrix)), 
04853              "Cannot combine Transform actions");
04854     ERROR3IF(!(GetTransform()->IS_KIND_OF(Trans2DMatrix)), 
04855              "Cannot combine transform actions");
04856     
04857     Trans2DMatrix* Trans1 = ((Trans2DMatrix*)GetTransform()); 
04858     Trans2DMatrix* Trans2 = ((Trans2DMatrix*)(pMatrixTransformAction->GetTransform()));
04859     (*Trans1)*=(*Trans2);        
04860 }

ActionCode TransformNodeAction::Execute  )  [virtual]
 

Executes the TransformNodeAction which transforms the range of nodes. It also creates another TransformNodeAction passing it the inverse of the transform.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/8/93
Parameters:
- [INPUTS]
ActionCode indicating if the action was successfully executed or not [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from Action.

Definition at line 4624 of file ops.cpp.

04625 {  
04626     // DMc - changed 17/8/99
04627     // It didn't work in its old state with compound nodes as the node range seemed to
04628     // be corrupted in the transformations
04629     // Thus, made it more robust by having a node list of the range which is first passed in
04630 
04631     // Further comment. Looks like things have been fiddled with too much to rely on the
04632     // range to be correct when redoing the op (check beveled shapes with text stories)
04633     // So I tidied up Daves node lists and corrected his transform matrix (sjk 9/8/00)
04634     TransformNodeAction* TransformNodeAct;  
04635     ActionCode ActCode;  
04636 
04637     Trans2DMatrix * pTransform = new Trans2DMatrix((const Trans2DMatrix&) *pTrans);
04638     pTransform->Invert();
04639     
04640     // Create an action to transform the node back to its initial position
04641     if ( (ActCode = TransformNodeAction::Init(pOperation, 
04642                                               pOppositeActLst, 
04643                                               NodeRange, 
04644                                               pTransform,
04645                                               m_pNodeList,
04646                                               (Action**)(&TransformNodeAct)))
04647         != AC_FAIL)  
04648     {   
04649         NodeListItem * pItem = (NodeListItem *)m_pNodeList->GetHead();
04650         Node * pNode = NULL;
04651 
04652         while (pItem)
04653         {
04654             pNode = pItem->pNode;
04655             
04656             if (((NodeRenderable *)pNode)->IsNodeRenderableClass())
04657             {       
04658                 ((NodeRenderable *)pNode)->Transform(*pTrans);              
04659                 // set the parent layer as having being edited
04660                 pNode->SetParentLayerAsEdited();
04661             }
04662 
04663             pItem = (NodeListItem *)m_pNodeList->GetNext(pItem);
04664         }       
04665     };  
04666                     
04667     return (ActCode);                   
04668 }     

const Range* TransformNodeAction::GetActionRange  )  const [inline]
 

Definition at line 1147 of file ops.h.

01149 {return &NodeRange;}

TransformBase * TransformNodeAction::GetTransform  ) 
 

Used to find the transform within the TransformNodeAction.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/11/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 4824 of file ops.cpp.

04825 {
04826     return (pTrans);    
04827 } 

ActionCode TransformNodeAction::Init Operation *const   pOp,
ActionList pActionList,
Range  NodeRangeIn,
TransformBase Trans,
List pNodeList,
Action **  NewAction
[static]
 

To check that there is sufficient room for the action in the operation history, and if there is, then to add the action to the operations action list.

Parameters:
pOp,: The operation to which the action should be added [INPUTS]
pActionList: The action list in the operation object

NodeRange: The range of nodes to transform

Trans: The Transform to apply to the nodes in the range

Parameters:
NewAction,: A pointer to the action if it could be allocated. [OUTPUTS]
Returns:
AC_FAIL: There was not enough room in the operation history for the action and the user did not wish to continue. Usually End() should be called in this situation.
AC_NORECORD: There was not enough room in the operation history for the action, but the user requested that he wished to continue without undo.

AC_OK : The action was successfully initialised and added to the operation.

The function calls the Action::Init function passing the runtime class of a TransformNodeAction.

Returns:
Errors: -
See also:
Action::Init

Definition at line 4714 of file ops.cpp.

04720 { 
04721     ActionCode Ac = (Action::Init(pOp,
04722                                   pActionList,
04723                                   sizeof(TransformNodeAction),
04724                                   CC_RUNTIME_CLASS(TransformNodeAction), 
04725                                   NewAction));   
04726                            
04727     if (Ac != AC_FAIL)
04728     {
04729         if (*NewAction != NULL)  
04730         {
04731             // Store the range and transform in the action 
04732             ((TransformNodeAction*)(*NewAction))->NodeRange = NodeRangeIn;
04733             ((TransformNodeAction*)(*NewAction))->pTrans = Trans;
04734             if (((TransformNodeAction*)(*NewAction))->m_pNodeList)
04735             {
04736                 ((TransformNodeAction*)(*NewAction))->m_pNodeList->DeleteAll();
04737                 delete ((TransformNodeAction*)(*NewAction))->m_pNodeList;
04738                 ((TransformNodeAction*)(*NewAction))->m_pNodeList = NULL;
04739             }
04740 
04741             // run through the original node range, collecting all the selected nodes
04742         
04743             ((TransformNodeAction*)(*NewAction))->m_pNodeList = new List;
04744             if (pNodeList == NULL)
04745             {
04746                 Node *pNode = ((TransformNodeAction*)(*NewAction))->NodeRange.FindFirst();                      
04747                 while (pNode)                                           
04748                 {                                                       
04749                     if (((NodeRenderable *)pNode)->IsNodeRenderableClass())
04750                     {
04751                         TRACEUSER( "SimonK", _T("trans node : %s\n"), (LPCTSTR) pNode->GetRuntimeClass()->GetClassName() );
04752 
04753                         NodeListItem * pItem = new NodeListItem(pNode);
04754                         if (pItem)
04755                             ((TransformNodeAction*)(*NewAction))->m_pNodeList->AddTail(pItem);
04756                     }
04757                     pNode = ((TransformNodeAction*)(*NewAction))->NodeRange.FindNext(pNode, FALSE);                     
04758                 }
04759             }
04760             else
04761             {
04762                 NodeListItem * pItem = (NodeListItem *)(pNodeList->GetHead());
04763                 Node * pNode = NULL;
04764 
04765                 while (pItem)
04766                 {
04767                     pNode = pItem->pNode;
04768                     
04769                     if (((NodeRenderable *)pNode)->IsNodeRenderableClass())
04770                     {                       
04771                         NodeListItem * pItem = new NodeListItem(pNode);
04772                         if (pItem)
04773                             ((TransformNodeAction*)(*NewAction))->m_pNodeList->AddTail(pItem);
04774                     }
04775 
04776                     pItem = (NodeListItem *)pNodeList->GetNext(pItem);
04777                 }       
04778             }
04779         }
04780 
04781     }            
04782     return (Ac); 
04783 } 

void TransformNodeAction::Slaughter void   )  [virtual]
 

destructor which gets called when an operation is deleted

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/7/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
Action::Slaughter

Reimplemented from Action.

Definition at line 4801 of file ops.cpp.

04802 {         
04803     // Destroy the Trans object      
04804     delete pTrans;
04805     pTrans = NULL;
04806     Action::Slaughter(); // Call base class to destroy this 
04807 }   


Member Data Documentation

List* TransformNodeAction::m_pNodeList [private]
 

Definition at line 1154 of file ops.h.

Range TransformNodeAction::NodeRange [private]
 

Definition at line 1151 of file ops.h.

TransformBase* TransformNodeAction::pTrans [private]
 

Definition at line 1156 of file ops.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:02:13 2007 for Camelot by  doxygen 1.4.4