ChangeShapePointAction Class Reference

An action to change a point in a regular shape. More...

#include <shapeops.h>

Inheritance diagram for ChangeShapePointAction:

Action ListItem CCObject SimpleCCObject List of all members.

Public Types

enum  ChangeItem { CHANGE_MAJOR, CHANGE_CENTRE, CHANGE_MINOR }

Public Member Functions

 ChangeShapePointAction ()
 Constructor for the action to change a point in a regular shape. Initialises the data members to sensible defaults.
virtual ActionCode Execute ()
 Changes a data item in a Regular shape, createing another ChangeShapePointAction to undo the change.

Static Public Member Functions

static ActionCode Init (Operation *pOp, ActionList *pActionList, NodeRegularShape *pShape, enum ChangeItem NewItem, DocCoord NewData, 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.
static ActionCode DoToggle (Operation *pOp, ActionList *pActionList, NodeRegularShape *pShape, enum ChangeItem NewItem, DocCoord NewData)
 This static function makes it a little easier to use this action. It creates an instance of this action and appends it to the action list.

Private Attributes

NodeRegularShapepToggleShape
enum ChangeItem ChangeItemID
DocCoord NewValue

Detailed Description

An action to change a point in a regular shape.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/12/94
See also:
ChangeShapeDataAction

Definition at line 413 of file shapeops.h.


Member Enumeration Documentation

enum ChangeShapePointAction::ChangeItem
 

Enumerator:
CHANGE_MAJOR 
CHANGE_CENTRE 
CHANGE_MINOR 

Definition at line 419 of file shapeops.h.


Constructor & Destructor Documentation

ChangeShapePointAction::ChangeShapePointAction  ) 
 

Constructor for the action to change a point in a regular shape. Initialises the data members to sensible defaults.

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

Errors: -

See also:
-

Definition at line 1162 of file shapeops.cpp.

01163 {
01164     pToggleShape = NULL;
01165     ChangeItemID = CHANGE_MAJOR;
01166     NewValue = DocCoord(0,0);
01167 }


Member Function Documentation

ActionCode ChangeShapePointAction::DoToggle Operation pOp,
ActionList pActionList,
NodeRegularShape pShape,
enum ChangeItem  NewItem,
DocCoord  NewData
[static]
 

This static function makes it a little easier to use this action. It creates an instance of this action and appends it to the action list.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/12/94
Parameters:
pOp is the currently running operation. [INPUTS] pActionList is a pointer ot the action list to which the action should be appended. pShape is a pointer to the NodeRegularShape to change. NewItem identifes the data item that shoudl be changed NewData is the value this action should set the data item to
- [OUTPUTS]
Returns:
Action code which indicates success or failure to create the action

Errors: -

See also:
-

Definition at line 1246 of file shapeops.cpp.

01251 {
01252     // Get the runtime class info on this object and create a pointer to another object of the same type 
01253     ChangeShapePointAction* NewAction; 
01254 
01255     // Now call the init function to set everything up
01256     ActionCode Act = ChangeShapePointAction::Init(pOp, pActionList, pShape, NewItem, NewData, (Action**)&NewAction);
01257     return Act;
01258 }

ActionCode ChangeShapePointAction::Execute  )  [virtual]
 

Changes a data item in a Regular shape, createing another ChangeShapePointAction to undo the change.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/12/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
ActionCode, either AC_OK, AC_NORECORD or AC_FAIL

Errors: ERROR3 if the internal shape pointer was NULL. ERROR2 checks on individual changes.

See also:
-

Reimplemented from Action.

Definition at line 1278 of file shapeops.cpp.

01279 {
01280     ERROR3IF(pToggleShape == NULL, "Pointer to shape was NULL.  Did you call Init/DoToggle OR handle their failure?");
01281 
01282     // Get the runtime class info on this object and create a pointer to another object of the same type 
01283     ChangeShapePointAction *ReAction; 
01284     ActionCode Act = AC_FAIL;
01285     DocCoord ReData(0,0);
01286 
01287     switch (ChangeItemID)
01288     {
01289         case CHANGE_MINOR:
01290             ReData = pToggleShape->GetUTMinorAxes();
01291             break;
01292         case CHANGE_MAJOR:
01293             ReData = pToggleShape->GetUTMajorAxes();
01294             break;
01295         case CHANGE_CENTRE:
01296             ReData = pToggleShape->GetUTCentrePoint();
01297             break;
01298         default:
01299             ERROR2(Act, "What was that Change ID?!");
01300             break;
01301     }
01302     
01303     // Create a redo action for this action
01304     if (pToggleShape != NULL)
01305     {
01306         Act = ChangeShapePointAction::Init(pOperation, pOppositeActLst, pToggleShape, ChangeItemID, 
01307                                                                             ReData, (Action**)(&ReAction));
01308 
01309         if (Act == AC_FAIL)
01310             return AC_FAIL;
01311 
01312         // Now do the actual action
01313         switch (ChangeItemID)
01314         {
01315             case CHANGE_MINOR:
01316                 pToggleShape->SetMinorAxes(NewValue);
01317                 break;
01318             case CHANGE_MAJOR:
01319                 pToggleShape->SetMajorAxes(NewValue);
01320                 break;
01321             case CHANGE_CENTRE:
01322                 pToggleShape->SetCentrePoint(NewValue);
01323                 break;
01324         }
01325         pToggleShape->InvalidateBoundingRect();
01326         pToggleShape->InvalidateCache();
01327     }
01328 
01329     return Act;
01330 }

ActionCode ChangeShapePointAction::Init Operation pOp,
ActionList pActionList,
NodeRegularShape pShape,
enum ChangeItem  NewItem,
DocCoord  NewData,
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:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/12/94
Parameters:
pOp is the pointer to the operation to which this action belongs [INPUTS] pShape is a pointer to the NodeRegularShape to change NewItem identifes the data item that shoudl be changed NewData is the value this action should set the data item to pActionList is the action list to which this action should be added
NewAction is a pointer to a pointer to an action, allowing the function to [OUTPUTS] return 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 1201 of file shapeops.cpp.

01207 {
01208     UINT32 ActSize = sizeof(ChangeShapePointAction);            
01209 
01210     ActionCode Ac = Action::Init( pOp, pActionList, ActSize, CC_RUNTIME_CLASS(ChangeShapePointAction), NewAction);
01211     if ((Ac == AC_OK) && (*NewAction != NULL))
01212     {
01213         ((ChangeShapePointAction*)*NewAction)->pToggleShape = pShape;
01214         ((ChangeShapePointAction*)*NewAction)->ChangeItemID = NewItem;
01215         ((ChangeShapePointAction*)*NewAction)->NewValue = NewData;
01216     }
01217     return Ac;
01218 }


Member Data Documentation

enum ChangeItem ChangeShapePointAction::ChangeItemID [private]
 

Definition at line 438 of file shapeops.h.

DocCoord ChangeShapePointAction::NewValue [private]
 

Definition at line 439 of file shapeops.h.

NodeRegularShape* ChangeShapePointAction::pToggleShape [private]
 

Definition at line 437 of file shapeops.h.


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