#include <pathedit.h>
Inheritance diagram for ModifyPathAction:
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 |
NodePath * | ChangedPath |
PathVerb * | ChangedVerbs |
PathFlags * | ChangedFlags |
DocCoord * | ChangedCoords |
INT32 * | ChangedIndices |
Definition at line 631 of file pathedit.h.
|
Constructor for the action to undo path modification.
Definition at line 8611 of file pathedit.cpp. 08612 { 08613 ChangedVerbs = NULL; 08614 ChangedFlags = NULL; 08615 ChangedCoords = NULL; 08616 ChangedIndices = NULL; 08617 }
|
|
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 }
|
|
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.
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 }
|
|
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.
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 }
|
|
This function initialises the array pointers in this action. Note that the variable NumElements is initialised in the Init function.
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 }
|
|
Definition at line 652 of file pathedit.h. |
|
Definition at line 651 of file pathedit.h. |
|
Definition at line 653 of file pathedit.h. |
|
Definition at line 649 of file pathedit.h. |
|
Definition at line 650 of file pathedit.h. |
|
Definition at line 648 of file pathedit.h. |