ChangeShapeDataAction Class Reference

An action to toggle a (Boolean or double) value of a regular shape. More...

#include <shapeops.h>

Inheritance diagram for ChangeShapeDataAction:

Action ListItem CCObject SimpleCCObject List of all members.

Public Types

enum  ChangeItem {
  CHANGE_NUMSIDES, CHANGE_CIRCULAR, CHANGE_STELLATED, CHANGE_PRIMARYCURVATURE,
  CHANGE_STELLATIONCURVATURE, CHANGE_STELLRADIUSTOPRIMARY, CHANGE_PRIMARYCURVETOPRIMARY, CHANGE_STELLCURVETOSTELL,
  CHANGE_STELLATIONOFFSET
}

Public Member Functions

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

Static Public Member Functions

static ActionCode Init (Operation *pOp, ActionList *pActionList, NodeRegularShape *pShape, enum ChangeItem NewItem, double 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, double 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
double NewValue

Detailed Description

An action to toggle a (Boolean or double) value of a regular shape.

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

Definition at line 369 of file shapeops.h.


Member Enumeration Documentation

enum ChangeShapeDataAction::ChangeItem
 

Enumerator:
CHANGE_NUMSIDES 
CHANGE_CIRCULAR 
CHANGE_STELLATED 
CHANGE_PRIMARYCURVATURE 
CHANGE_STELLATIONCURVATURE 
CHANGE_STELLRADIUSTOPRIMARY 
CHANGE_PRIMARYCURVETOPRIMARY 
CHANGE_STELLCURVETOSTELL 
CHANGE_STELLATIONOFFSET 

Definition at line 376 of file shapeops.h.


Constructor & Destructor Documentation

ChangeShapeDataAction::ChangeShapeDataAction  ) 
 

Constructor for the action to toggle a data item of a regular state. Initialises the data members to sensible defaults.

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

Errors: -

See also:
-

Definition at line 932 of file shapeops.cpp.

00933 {
00934     pToggleShape = NULL;
00935     ChangeItemID = CHANGE_NUMSIDES;
00936     NewValue = 0.0;
00937 }


Member Function Documentation

ActionCode ChangeShapeDataAction::DoToggle Operation pOp,
ActionList pActionList,
NodeRegularShape pShape,
enum ChangeItem  NewItem,
double  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 1016 of file shapeops.cpp.

01021 {
01022     // Get the runtime class info on this object and create a pointer to another object of the same type 
01023     ChangeShapeDataAction* NewAction; 
01024 
01025     // Now call the init function to set everything up
01026     ActionCode Act = ChangeShapeDataAction::Init(pOp, pActionList, pShape, NewItem, NewData, (Action**)&NewAction);
01027     return Act;
01028 }

ActionCode ChangeShapeDataAction::Execute  )  [virtual]
 

Changes a data item in a Regular shape, createing another ChangeShapeDataAction 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 1048 of file shapeops.cpp.

01049 {
01050     ERROR3IF(pToggleShape == NULL, "Pointer to shape was NULL.  Did you call Init/DoToggle OR handle their failure?");
01051 
01052     // Get the runtime class info on this object and create a pointer to another object of the same type 
01053     ChangeShapeDataAction *ReAction; 
01054     ActionCode Act = AC_FAIL;
01055     double ReData = 0.0;
01056 
01057     switch (ChangeItemID)
01058     {
01059         case CHANGE_NUMSIDES:
01060             ReData = pToggleShape->GetNumSides();
01061             break;
01062         case CHANGE_CIRCULAR:
01063             ReData = pToggleShape->IsCircular() ? 1.0 : 0.0;    
01064             break;
01065         case CHANGE_STELLATED:
01066             ReData = pToggleShape->IsStellated() ? 1.0 : 0.0;   
01067             break;
01068         case CHANGE_STELLRADIUSTOPRIMARY:
01069             ReData = pToggleShape->GetStellRadiusToPrimary();   
01070             break;
01071         case CHANGE_PRIMARYCURVATURE:
01072             ReData = pToggleShape->IsPrimaryCurvature() ? 1.0 : 0.0;    
01073             break;
01074         case CHANGE_STELLATIONCURVATURE:
01075             ReData = pToggleShape->IsStellationCurvature() ? 1.0 : 0.0; 
01076             break;
01077         case CHANGE_PRIMARYCURVETOPRIMARY:
01078             ReData = pToggleShape->GetPrimaryCurveToPrimary();  
01079             break;
01080         case CHANGE_STELLCURVETOSTELL:
01081             ReData = pToggleShape->GetStellCurveToStell();  
01082             break;
01083         case CHANGE_STELLATIONOFFSET:
01084             ReData = pToggleShape->GetStellationRatio();    
01085             break;
01086         default:
01087             ERROR2(Act, "What was that Change ID?!");
01088             break;
01089     }
01090     
01091     // Create a redo action for this action
01092     if (pToggleShape != NULL)
01093     {
01094         Act = ChangeShapeDataAction::Init(pOperation, pOppositeActLst, pToggleShape, ChangeItemID, 
01095                                                                             ReData, (Action**)(&ReAction));
01096 
01097         if (Act == AC_FAIL)
01098             return AC_FAIL;
01099 
01100         // Now do the actual action
01101         switch (ChangeItemID)
01102         {
01103             case CHANGE_NUMSIDES:
01104                 pToggleShape->SetNumSides((UINT32)NewValue);
01105                 break;
01106             case CHANGE_CIRCULAR:
01107                 pToggleShape->SetCircular(NewValue == 1.0 ? TRUE : FALSE);
01108                 break;
01109             case CHANGE_STELLATED:
01110                 pToggleShape->SetStellated(NewValue == 1.0 ? TRUE : FALSE);
01111                 break;
01112             case CHANGE_STELLRADIUSTOPRIMARY:
01113                 pToggleShape->SetStellRadiusToPrimary(NewValue);
01114                 break;
01115             case CHANGE_PRIMARYCURVATURE:
01116                 pToggleShape->SetPrimaryCurvature(NewValue == 1.0 ? TRUE : FALSE);
01117                 break;
01118             case CHANGE_STELLATIONCURVATURE:
01119                 pToggleShape->SetStellationCurvature(NewValue == 1.0 ? TRUE : FALSE);
01120                 break;
01121             case CHANGE_PRIMARYCURVETOPRIMARY:
01122                 pToggleShape->SetPrimaryCurveToPrimary(NewValue);
01123                 break;
01124             case CHANGE_STELLCURVETOSTELL:
01125                 pToggleShape->SetStellCurveToStell(NewValue);
01126                 break;
01127             case CHANGE_STELLATIONOFFSET:
01128                 pToggleShape->SetStellationRatio(NewValue);
01129                 break;
01130             default:
01131                 ERROR3("What was that Change ID?!");
01132                 break;
01133         }
01134         pToggleShape->InvalidateBoundingRect();
01135         pToggleShape->InvalidateCache();
01136     }
01137 
01138     return Act;
01139 }

ActionCode ChangeShapeDataAction::Init Operation pOp,
ActionList pActionList,
NodeRegularShape pShape,
enum ChangeItem  NewItem,
double  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 971 of file shapeops.cpp.

00977 {
00978     UINT32 ActSize = sizeof(ChangeShapeDataAction);         
00979 
00980     ActionCode Ac = Action::Init( pOp, pActionList, ActSize, CC_RUNTIME_CLASS(ChangeShapeDataAction), NewAction);
00981     if ((Ac == AC_OK) && (*NewAction != NULL))
00982     {
00983         ((ChangeShapeDataAction*)*NewAction)->pToggleShape = pShape;
00984         ((ChangeShapeDataAction*)*NewAction)->ChangeItemID = NewItem;
00985         ((ChangeShapeDataAction*)*NewAction)->NewValue = NewData;
00986     }
00987     return Ac;
00988 }


Member Data Documentation

enum ChangeItem ChangeShapeDataAction::ChangeItemID [private]
 

Definition at line 396 of file shapeops.h.

double ChangeShapeDataAction::NewValue [private]
 

Definition at line 397 of file shapeops.h.

NodeRegularShape* ChangeShapeDataAction::pToggleShape [private]
 

Definition at line 395 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