ModifyPathAction Class Reference

An action which undoes the modification of path data. This action can be used for undoing changing coordinates or flags or verbs. Other actions will exist for adding or deleting elements from paths. This action is useful for undoing large amounts of path editing (e.g. dragging several points around) but is less useful for undoing the alteration of single coordinates. Another Action might be created later for undoing single element alterations. More...

#include <pathedit.h>

Inheritance diagram for ModifyPathAction:

Action ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 ModifyPathAction ()
 Constructor for the action to undo path modification.
 ~ModifyPathAction ()
virtual ActionCode Execute ()
 This is the virtual function that is called when the action is executed by the Undo/Redo system. This is the function that actually undoes the modifypath action by replacing the indicated sections of the path with data from itself, and records redo information from the current state of the path.
void StoreArrays (PathVerb *Verbs, PathFlags *Flags, DocCoord *Coords, INT32 *Indices, NodePath *WhichPath)
 This function initialises the array pointers in this action. Note that the variable NumElements is initialised in the Init function.

Static Public Member Functions

static ActionCode Init (Operation *pOp, ActionList *pActionList, INT32 NumChangedElements, Action **NewAction)
 This is the function which creates an instance of this action. If there is no room in the undo buffer (which is determined by the base class Init function called within) the function will either return AC_NO_RECORD which means the operation can continue, but no undo information needs to be stored, or AC_OK which means the operation should continue AND record undo information. If the function returns AC_FAIL, there was not enough memory to record the undo information, and the user has decided not to continue with the operation.

Protected Attributes

INT32 NumElements
NodePathChangedPath
PathVerbChangedVerbs
PathFlagsChangedFlags
DocCoordChangedCoords
INT32 * ChangedIndices

Detailed Description

An action which undoes the modification of path data. This action can be used for undoing changing coordinates or flags or verbs. Other actions will exist for adding or deleting elements from paths. This action is useful for undoing large amounts of path editing (e.g. dragging several points around) but is less useful for undoing the alteration of single coordinates. Another Action might be created later for undoing single element alterations.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/5/94
See also:
-

Definition at line 631 of file pathedit.h.


Constructor & Destructor Documentation

ModifyPathAction::ModifyPathAction  ) 
 

Constructor for the action to undo path modification.

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

Errors: -

See also:
-

Definition at line 8611 of file pathedit.cpp.

08612 {
08613     ChangedVerbs = NULL;
08614     ChangedFlags = NULL;
08615     ChangedCoords = NULL;
08616     ChangedIndices = NULL;
08617 }

ModifyPathAction::~ModifyPathAction  ) 
 

Definition at line 8791 of file pathedit.cpp.

08792 {
08793     if (ChangedVerbs)
08794         CCFree(ChangedVerbs);
08795     if (ChangedCoords)
08796         CCFree(ChangedCoords);
08797     if (ChangedFlags)
08798         CCFree(ChangedFlags);
08799     if (ChangedIndices)
08800         CCFree(ChangedIndices);
08801 }


Member Function Documentation

ActionCode ModifyPathAction::Execute  )  [virtual]
 

This is the virtual function that is called when the action is executed by the Undo/Redo system. This is the function that actually undoes the modifypath action by replacing the indicated sections of the path with data from itself, and records redo information from the current state of the path.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/7/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
Action code, one of AC_OK, AC_NORECORD or AC_FAIL.

Errors: -

See also:
-

Reimplemented from Action.

Definition at line 8717 of file pathedit.cpp.

08718 {
08719     // Here we're undoing the modify, so we have to write the list of changed array entries
08720     // back into the path. We also have to build undo information for the redo. Usefully,
08721     // We can use the existing arrays, swapping the data in the undo action for the data 
08722     // in the path, then passing the arrays on to the redo record. We have to make sure 
08723     // we don't try and de-allocate the arrays after we've done this, so we'll put a check in
08724     // the destructor for null pointers
08725     
08726     ModifyPathAction* ModAction;
08727     
08728     ActionCode Act;
08729     Act = ModifyPathAction::Init(pOperation, pOppositeActLst, NumElements, (Action**)(&ModAction));
08730     if (Act == AC_FAIL)
08731         return AC_FAIL;
08732 
08733     // Force a re-draw of the place where the path used to be
08734     Document* pDoc = GetWorkingDoc();
08735     ERROR2IF( pDoc == NULL, AC_FAIL, "There was no current document when undoing modifypath" );
08736     Spread* pSpread = ChangedPath->FindParentSpread();
08737     DocRect Invalid = ChangedPath->GetUnionBlobBoundingRect();
08738     pDoc->ForceRedraw( pSpread, Invalid, FALSE, ChangedPath );
08739 
08740     // Get pointers to all the arrays of the path
08741 
08742     PathVerb* Verbs = ChangedPath->InkPath.GetVerbArray();
08743     DocCoord* Coords = ChangedPath->InkPath.GetCoordArray();
08744     PathFlags* Flags = ChangedPath->InkPath.GetFlagArray();
08745 
08746     // Now modify the data, swapping data from the two sets of arrays
08747 
08748     PathVerb TempVerb;
08749     DocCoord TempCoord;
08750     PathFlags TempFlag;
08751     
08752     for (INT32 i=0;i<NumElements;i++)
08753     {
08754         TempVerb = Verbs[ChangedIndices[i]];
08755         TempCoord = Coords[ChangedIndices[i]];
08756         TempFlag = Flags[ChangedIndices[i]];
08757         Verbs[ChangedIndices[i]] = ChangedVerbs[i];
08758         Coords[ChangedIndices[i]] = ChangedCoords[i];
08759         Flags[ChangedIndices[i]] = ChangedFlags[i];
08760         ChangedVerbs[i] = TempVerb;
08761         ChangedCoords[i] = TempCoord;
08762         ChangedFlags[i] = TempFlag;
08763 
08764     }
08765 
08766     // Now, the path in the document has been changed, the arrays now contain what was in the path
08767     // so we tell the action where the arrays are.
08768 
08769     if (Act==AC_OK && ModAction!=NULL)
08770         ModAction->StoreArrays(ChangedVerbs, ChangedFlags, ChangedCoords, ChangedIndices, ChangedPath);
08771 
08772     // And set the array pointers to NULL so the destructor doesn't try and deallocate them
08773 
08774     ChangedVerbs = NULL;
08775     ChangedCoords = NULL;
08776     ChangedFlags = NULL;
08777     ChangedIndices = NULL;
08778 
08779     ChangedPath->InvalidateBoundingRect();
08780 
08781     // Now cause a redraw of the new paths position
08782     Invalid = ChangedPath->GetUnionBlobBoundingRect();
08783     pDoc->ForceRedraw( pSpread, Invalid, FALSE, ChangedPath );
08784 
08785     return Act;
08786 }

ActionCode ModifyPathAction::Init Operation pOp,
ActionList pActionList,
INT32  NumChangedElements,
Action **  NewAction
[static]
 

This is the function which creates an instance of this action. If there is no room in the undo buffer (which is determined by the base class Init function called within) the function will either return AC_NO_RECORD which means the operation can continue, but no undo information needs to be stored, or AC_OK which means the operation should continue AND record undo information. If the function returns AC_FAIL, there was not enough memory to record the undo information, and the user has decided not to continue with the operation.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/5/94
Parameters:
pOp is the pointer to the operation to which this action belongs [INPUTS] pActionList is the action list to which this action should be added NumChangedElements is the number of elements in the path that are going to change. This tells the action how much memory the total action is going to take
NewAction is a pointer to a pointer to an action, allowing the function to return [OUTPUTS] a pointer to the created action
Returns:
ActionCode, one of AC_OK, AC_NO_RECORD or AC_FAIL

Errors: -

See also:
Action::Init()

Definition at line 8650 of file pathedit.cpp.

08654 {
08655     UINT32 ActSize = sizeof(ModifyPathAction) +
08656                     NumChangedElements * (sizeof(PathVerb)+sizeof(PathFlags)+sizeof(DocCoord)+sizeof(INT32));
08657 
08658     ActionCode Ac = Action::Init( pOp, pActionList, ActSize, CC_RUNTIME_CLASS(ModifyPathAction), NewAction);
08659     if ((Ac==AC_OK) && (*NewAction != NULL))
08660         ((ModifyPathAction*)*NewAction)->NumElements = NumChangedElements;
08661 
08662 //  if (IsUserName("Jim")) TRACE( _T("Creating ModifyPathAction"));
08663 
08664     return Ac;
08665 }

void ModifyPathAction::StoreArrays PathVerb Verbs,
PathFlags Flags,
DocCoord Coords,
INT32 *  Indices,
NodePath WhichPath
 

This function initialises the array pointers in this action. Note that the variable NumElements is initialised in the Init function.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/5/94
Parameters:
Verbs is a pointer to an array of path verbs [INPUTS] Flags is a pointer to an array of path flags Coords is a pointer to an array of DocCoords Indices is a pointer to an array of indices into the path
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 8687 of file pathedit.cpp.

08689 {
08690     ChangedPath = WhichPath;
08691     ChangedVerbs = Verbs;
08692     ChangedFlags = Flags;
08693     ChangedCoords = Coords;
08694     ChangedIndices = Indices;
08695 }


Member Data Documentation

DocCoord* ModifyPathAction::ChangedCoords [protected]
 

Definition at line 652 of file pathedit.h.

PathFlags* ModifyPathAction::ChangedFlags [protected]
 

Definition at line 651 of file pathedit.h.

INT32* ModifyPathAction::ChangedIndices [protected]
 

Definition at line 653 of file pathedit.h.

NodePath* ModifyPathAction::ChangedPath [protected]
 

Definition at line 649 of file pathedit.h.

PathVerb* ModifyPathAction::ChangedVerbs [protected]
 

Definition at line 650 of file pathedit.h.

INT32 ModifyPathAction::NumElements [protected]
 

Definition at line 648 of file pathedit.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:56:15 2007 for Camelot by  doxygen 1.4.4