OpEditRegularShape Class Reference

This operation can be used to change the internal data members of NodeRegularShapes in an undoable way. It either changes one particular shape or all selected shapes. The data members are changed to those supplied by the parameter object. More...

#include <shapeops.h>

Inheritance diagram for OpEditRegularShape:

SelOperation UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpEditRegularShape ()
 OpEditRegularShape constructor - does nothing itself.
void DoWithParam (OpDescriptor *pOpDesc, OpParam *pEntryOpParam)
 Performs the edit regular shapes operation.

Static Public Member Functions

static BOOL Init ()
 OpEditRegularShape initialiser method.
static OpState GetState (String_256 *, OpDescriptor *)
 For finding the OpEditRegularShape's state.

Protected Member Functions

BOOL CarryOut (NodeRegularShape *ShapeToEdit, EditRegularShapeParam *pOpParam)
 Performs the edit regular shapes operation on one particular shape.
BOOL ShouldDoThisShape (NodeRegularShape *pShape, EditRegularShapeParam::AffectShape Allowance)
 Do decide wether or not the shape should be edited. The decision is based upon the Allowance mode.

Detailed Description

This operation can be used to change the internal data members of NodeRegularShapes in an undoable way. It either changes one particular shape or all selected shapes. The data members are changed to those supplied by the parameter object.

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

Definition at line 205 of file shapeops.h.


Constructor & Destructor Documentation

OpEditRegularShape::OpEditRegularShape  ) 
 

OpEditRegularShape constructor - does nothing itself.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/12/94

Definition at line 255 of file shapeops.cpp.

00255                                       : SelOperation()                              
00256 {                              
00257 }


Member Function Documentation

BOOL OpEditRegularShape::CarryOut NodeRegularShape ShapeToEdit,
EditRegularShapeParam NewShapeData
[protected]
 

Performs the edit regular shapes operation on one particular shape.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/12/94
Parameters:
ShapeToEdit points to the Shape to change. [INPUTS] NewShapeData points to the parameter object with the changes data.
Returns:
Errors: ERROR2 if there is no current DocView
See also:
EditRegularShapeParam, OpEditRegularShape::DoWithParam

Definition at line 413 of file shapeops.cpp.

00414 {
00415     // Create an action to will cause the shape to recalc its bounds
00416     if (RecalcBoundsAction::DoRecalc(this, &UndoActions, ShapeToEdit) == AC_FAIL)
00417     {
00418         return FALSE;
00419     }
00420 
00421     // See if we should change the polygon/circular flag
00422     if (NewShapeData->NewCircular != EditRegularShapeParam::CHANGE_DONTCARE)
00423     {
00424         if (ChangeShapeDataAction::DoToggle(this, &UndoActions, ShapeToEdit, ChangeShapeDataAction::CHANGE_CIRCULAR,
00425                                                 ShapeToEdit->IsCircular() ? 1.0 : 0.0) == AC_FAIL)
00426         {
00427             return FALSE;
00428         }
00429         ShapeToEdit->SetCircular(NewShapeData->NewCircular == EditRegularShapeParam::CHANGE_SETTRUE);
00430     }
00431 
00432     // See if we should change the stellated flag
00433     if (NewShapeData->NewStellated != EditRegularShapeParam::CHANGE_DONTCARE)
00434     {
00435 /*      // If were turning off stellation them we may need to fix the primary curvature ratio
00436         if (NewShapeData->NewStellated == EditRegularShapeParam::CHANGE_SETFALSE)
00437         {
00438             if (ShapeToEdit->GetPrimaryCurveToPrimary() > 0.5)
00439                 NewShapeData->NewPrimaryCurveToPrimary = 0.2;
00440         }
00441         else
00442         {
00443             // If we've turned on stellation them we may need to fix both curvature ratios
00444             if (ShapeToEdit->GetPrimaryCurveToPrimary()+ShapeToEdit->GetStellCurveToStell() > 1.0)
00445             {
00446                 NewShapeData->NewPrimaryCurveToPrimary = 0.2;
00447                 NewShapeData->NewStellCurveToStell = 0.2;
00448             }
00449         }*/
00450 
00451         if (ChangeShapeDataAction::DoToggle(this, &UndoActions, ShapeToEdit, ChangeShapeDataAction::CHANGE_STELLATED,
00452                                                  ShapeToEdit->IsStellated() ? 1.0 : 0.0) == AC_FAIL)
00453         {
00454             return FALSE;
00455         }
00456         ShapeToEdit->SetStellated(NewShapeData->NewStellated == EditRegularShapeParam::CHANGE_SETTRUE);
00457     }
00458 
00459     // See if we should change the primary curvature flag
00460     if (NewShapeData->NewPrimaryCurvature != EditRegularShapeParam::CHANGE_DONTCARE)
00461     {
00462         if (ChangeShapeDataAction::DoToggle(this, &UndoActions, ShapeToEdit, ChangeShapeDataAction::CHANGE_PRIMARYCURVATURE,
00463                                                  ShapeToEdit->IsPrimaryCurvature() ? 1.0 : 0.0) == AC_FAIL)
00464         {
00465             return FALSE;
00466         }
00467         ShapeToEdit->SetPrimaryCurvature(NewShapeData->NewPrimaryCurvature == EditRegularShapeParam::CHANGE_SETTRUE);
00468     }
00469 
00470     // See if we should change the stellation curvature flag
00471     if (NewShapeData->NewStellationCurvature != EditRegularShapeParam::CHANGE_DONTCARE)
00472     {
00473         if (ChangeShapeDataAction::DoToggle(this, &UndoActions, ShapeToEdit, ChangeShapeDataAction::CHANGE_STELLATIONCURVATURE,
00474                                                  ShapeToEdit->IsStellationCurvature() ? 1.0 : 0.0) == AC_FAIL)
00475         {
00476             return FALSE;
00477         }
00478         ShapeToEdit->SetStellationCurvature(NewShapeData->NewStellationCurvature == EditRegularShapeParam::CHANGE_SETTRUE);
00479     }
00480 
00481     // See if we should change the stellation offset
00482     if (NewShapeData->NewStellOffsetRatio != -1000.0)
00483     {
00484         if (ChangeShapeDataAction::DoToggle(this, &UndoActions, ShapeToEdit, 
00485                 ChangeShapeDataAction::CHANGE_STELLATIONOFFSET, ShapeToEdit->GetStellationRatio()) == AC_FAIL)
00486         {
00487             return FALSE;
00488         }
00489         ShapeToEdit->SetStellationRatio(NewShapeData->NewStellOffsetRatio);
00490     }
00491 
00492     // See if we should change the number of sides
00493     if (NewShapeData->NewNumSides != 0)
00494     {
00495         if (ChangeShapeDataAction::DoToggle(this, &UndoActions, ShapeToEdit, 
00496                 ChangeShapeDataAction::CHANGE_NUMSIDES, ShapeToEdit->GetNumSides()) == AC_FAIL)
00497         {
00498             return FALSE;
00499         }
00500         ShapeToEdit->SetNumSides(NewShapeData->NewNumSides);
00501     }
00502 
00503     // See if we should change the stellation radius ratio
00504     if (NewShapeData->NewStellRadiusToPrimary != -1.0)
00505     {
00506         if (ChangeShapeDataAction::DoToggle(this, &UndoActions, ShapeToEdit, 
00507                 ChangeShapeDataAction::CHANGE_STELLRADIUSTOPRIMARY, 
00508                                             ShapeToEdit->GetStellRadiusToPrimary()) == AC_FAIL)
00509         {
00510             return FALSE;
00511         }
00512         ShapeToEdit->SetStellRadiusToPrimary(NewShapeData->NewStellRadiusToPrimary);
00513     }
00514 
00515     // See if we should change the primary curvature ratio
00516     if (NewShapeData->NewPrimaryCurveToPrimary != -1.0)
00517     {
00518         double NewRatio = NewShapeData->NewPrimaryCurveToPrimary;
00519 /*      if (ShapeToEdit->IsStellated())
00520         {
00521             double StellRatio = ShapeToEdit->GetStellCurveToStell();
00522             if (NewShapeData->NewStellCurveToStell != -1.0)
00523                 StellRatio = NewShapeData->NewStellCurveToStell;    
00524 
00525             NewRatio = __min(1.0-StellRatio, NewShapeData->NewPrimaryCurveToPrimary); 
00526         }
00527         else
00528         {
00529             NewRatio = __min(0.5, NewShapeData->NewPrimaryCurveToPrimary); 
00530         }*/
00531         
00532         if (ChangeShapeDataAction::DoToggle(this, &UndoActions, ShapeToEdit, 
00533                 ChangeShapeDataAction::CHANGE_PRIMARYCURVETOPRIMARY, 
00534                                             ShapeToEdit->GetPrimaryCurveToPrimary()) == AC_FAIL)
00535         {
00536             return FALSE;
00537         }
00538         ShapeToEdit->SetPrimaryCurveToPrimary(NewRatio);
00539     }
00540 
00541     // See if we should bump the primary curvature ratio
00542     if (NewShapeData->AddPrimaryCurvature != -0.0)
00543     {
00544         double NewRatio = ShapeToEdit->GetPrimaryCurveToPrimary() + NewShapeData->AddPrimaryCurvature;
00545 /*      if (ShapeToEdit->IsStellated())
00546         {
00547             NewRatio = __min(1.0-ShapeToEdit->GetStellCurveToStell(), NewRatio);
00548         }
00549         else
00550         {
00551             NewRatio = __min(0.5, NewRatio); 
00552         }*/
00553         NewRatio = max( 0.0, NewRatio );
00554         
00555         if (ChangeShapeDataAction::DoToggle(this, &UndoActions, ShapeToEdit, 
00556                 ChangeShapeDataAction::CHANGE_PRIMARYCURVETOPRIMARY, 
00557                                             ShapeToEdit->GetPrimaryCurveToPrimary()) == AC_FAIL)
00558         {
00559             return FALSE;
00560         }
00561         ShapeToEdit->SetPrimaryCurveToPrimary(NewRatio);
00562     }
00563 
00564     // See if we should change the stellation curvature ratio
00565     if (NewShapeData->NewStellCurveToStell != -1.0)
00566     {
00567         double NewRatio = NewShapeData->NewStellCurveToStell;
00568         
00569 //      NewRatio = __min (1.0-ShapeToEdit->GetPrimaryCurveToPrimary(), NewShapeData->NewStellCurveToStell); 
00570 
00571         if (ChangeShapeDataAction::DoToggle(this, &UndoActions, ShapeToEdit, 
00572                 ChangeShapeDataAction::CHANGE_STELLCURVETOSTELL, 
00573                                             ShapeToEdit->GetStellCurveToStell()) == AC_FAIL)
00574         {
00575             return FALSE;
00576         }
00577         ShapeToEdit->SetStellCurveToStell(NewRatio);
00578     }
00579 
00580     // See if we should bump the stellation curvature ratio
00581     if (NewShapeData->AddStellationCurvature != 0.0)
00582     {
00583         double NewRatio = ShapeToEdit->GetStellCurveToStell() + NewShapeData->AddStellationCurvature;
00584 //      NewRatio = __min(1.0-ShapeToEdit->GetPrimaryCurveToPrimary(), NewRatio); 
00585         NewRatio = max( 0.0, NewRatio );
00586         
00587         if (ChangeShapeDataAction::DoToggle(this, &UndoActions, ShapeToEdit, 
00588                 ChangeShapeDataAction::CHANGE_PRIMARYCURVETOPRIMARY, 
00589                                             ShapeToEdit->GetStellCurveToStell()) == AC_FAIL)
00590         {
00591             return FALSE;
00592         }
00593         ShapeToEdit->SetStellCurveToStell(NewRatio);
00594     }
00595 
00596     // See if we should change the minor axes
00597 /*  if (NewShapeData->NewMinorAxes != DontCare)
00598     {
00599         if (ChangeShapePointAction::DoToggle(this, &UndoActions, ShapeToEdit, 
00600                         ChangeShapePointAction::CHANGE_MINOR, ShapeToEdit->GetMinorAxes()) == AC_FAIL)
00601         {
00602             return FALSE;
00603         }
00604         ShapeToEdit->SetMinorAxes(NewShapeData->NewMinorAxes);
00605     }
00606 
00607     // See if we should change the major axes
00608     if (NewShapeData->NewMajorAxes != DontCare)
00609     {
00610         if (ChangeShapePointAction::DoToggle(this, &UndoActions, ShapeToEdit, 
00611                         ChangeShapePointAction::CHANGE_MAJOR, ShapeToEdit->GetMajorAxes()) == AC_FAIL)
00612         {
00613             return FALSE;
00614         }
00615         ShapeToEdit->SetMajorAxes(NewShapeData->NewMajorAxes);
00616     }*/
00617 
00618     // See if we should change the size of the shape to a new length
00619     // OR see if we should change the size of the shape by a specified ammount
00620     if ((NewShapeData->SetRadiusLength != -1) || (NewShapeData->AddRadiusLength != -1) )
00621     {
00622         // Get scaling factor
00623         fixed16 ScaleFactor;
00624         const double CurrentLength = ShapeToEdit->GetCentrePoint().Distance(ShapeToEdit->GetMajorAxes()) ;
00625         if (CurrentLength != 0.0)
00626         {
00627             if (NewShapeData->SetRadiusLength != -1)
00628             {
00629                 double RequiredLength = NewShapeData->SetRadiusLength;
00630                 ScaleFactor = RequiredLength / CurrentLength;
00631             }
00632             else
00633             {
00634                 double RequiredAddition = NewShapeData->AddRadiusLength;
00635                 ScaleFactor = (RequiredAddition + CurrentLength) / CurrentLength;
00636             }       
00637         }
00638         else
00639             ScaleFactor = 1.0;
00640         
00641         // Translate to origin, scale and translate back
00642         Trans2DMatrix* TransOriginMat = new Trans2DMatrix(-ShapeToEdit->GetCentrePoint().x, -ShapeToEdit->GetCentrePoint().y);
00643         Trans2DMatrix* ScaleMat = new Trans2DMatrix(Matrix(ScaleFactor,ScaleFactor));
00644         Trans2DMatrix* TransBackMat = new Trans2DMatrix(ShapeToEdit->GetCentrePoint().x, ShapeToEdit->GetCentrePoint().y);
00645         if (!(DoTransformNode(ShapeToEdit, TransOriginMat) && DoTransformNode(ShapeToEdit, ScaleMat)
00646                                                             && DoTransformNode(ShapeToEdit, TransBackMat) ))
00647         {
00648             return FALSE;
00649         }
00650     }
00651 
00652     // See if we should change the MajorAxis of the shape to a new length
00653     // OR see if we should change the MajorAxis of the shape by a specified ammount
00654     if ((NewShapeData->SetMajorAxisLength != 0) || (NewShapeData->AddMajorAxisLength != 0) )
00655     {
00656         // Get scaling factor
00657         fixed16 ScaleFactor;
00658         const double CurrentLength = ShapeToEdit->GetCentrePoint().Distance(ShapeToEdit->GetMajorAxes()) ;
00659         if (CurrentLength != 0.0)
00660         {
00661             if (NewShapeData->SetMajorAxisLength != 0)
00662             {
00663                 double RequiredLength = NewShapeData->SetMajorAxisLength;
00664                 ScaleFactor = RequiredLength / CurrentLength;
00665             }
00666             else
00667             {
00668                 double RequiredAddition = NewShapeData->AddMajorAxisLength;
00669                 ScaleFactor = (RequiredAddition + CurrentLength) / CurrentLength;
00670             }       
00671         }
00672         else
00673             ScaleFactor = 1.0;
00674 
00675         if (ChangeShapePointAction::DoToggle(this, &UndoActions, ShapeToEdit, 
00676                         ChangeShapePointAction::CHANGE_MAJOR, ShapeToEdit->GetUTMajorAxes()) == AC_FAIL)
00677         {
00678             return FALSE;
00679         }
00680 
00681         // Scale the major axes relative to the centre point
00682         Matrix ScaleMatrix(FIXED16(1.0), ScaleFactor);
00683         DocCoord Offset = ShapeToEdit->GetUTMajorAxes() - ShapeToEdit->GetUTCentrePoint();
00684         ScaleMatrix.transform(&Offset);
00685         ShapeToEdit->SetMajorAxes(ShapeToEdit->GetUTCentrePoint() + Offset);
00686     }
00687 
00688     // See if we should change the MinorAxis of the shape to a new length
00689     // OR see if we should change the MinorAxis of the shape by a specified ammount
00690     if ((NewShapeData->SetMinorAxisLength != 0) || (NewShapeData->AddMinorAxisLength != 0) )
00691     {
00692         // Get scaling factor
00693         fixed16 ScaleFactor;
00694         const double CurrentLength = ShapeToEdit->GetCentrePoint().Distance(ShapeToEdit->GetMinorAxes()) ;
00695         if (CurrentLength != 0.0)
00696         {
00697             if (NewShapeData->SetMinorAxisLength != 0)
00698             {
00699                 double RequiredLength = NewShapeData->SetMinorAxisLength;
00700                 ScaleFactor = RequiredLength / CurrentLength;
00701             }
00702             else
00703             {
00704                 double RequiredAddition = NewShapeData->AddMinorAxisLength;
00705                 ScaleFactor = (RequiredAddition + CurrentLength) / CurrentLength;
00706             }       
00707         }
00708         else
00709             ScaleFactor = 1.0;
00710 
00711         if (ChangeShapePointAction::DoToggle(this, &UndoActions, ShapeToEdit, 
00712                         ChangeShapePointAction::CHANGE_MINOR, ShapeToEdit->GetUTMinorAxes()) == AC_FAIL)
00713         {
00714             return FALSE;
00715         }
00716 
00717         // Scale the minor axes relative to the centre point
00718         Matrix ScaleMatrix(ScaleFactor, FIXED16(1.0));
00719         DocCoord Offset = ShapeToEdit->GetUTMinorAxes() - ShapeToEdit->GetUTCentrePoint();
00720         ScaleMatrix.transform(&Offset);
00721         ShapeToEdit->SetMinorAxes(ShapeToEdit->GetUTCentrePoint() + Offset);
00722     }
00723 
00724     // See if we should change the size of the stellation radius to a new length
00725     // OR see if we should change the size of the stellation radius by a specified ammount
00726     if ((NewShapeData->SetStellationLength != -1) || (NewShapeData->AddStellationLength != -1) )
00727     {
00728         const double CurrentLength = ShapeToEdit->GetCentrePoint().Distance(ShapeToEdit->GetMajorAxes()) ;
00729         double NewRatio;
00730         if (NewShapeData->SetStellationLength != -1)
00731         {
00732             // Get the current length of the shape and get the ratio from that
00733             NewRatio = double( min( fabs( NewShapeData->SetStellationLength / CurrentLength ), 1.0 ) );
00734         }
00735         else
00736         {
00737             double NewLength = fabs(CurrentLength - NewShapeData->AddStellationLength);
00738             NewRatio = double( min( fabs( ( NewLength / CurrentLength ) - 1 + ShapeToEdit->GetStellRadiusToPrimary() ), 1.0 ) );
00739         }
00740 
00741         if (ChangeShapeDataAction::DoToggle(this, &UndoActions, ShapeToEdit, 
00742                 ChangeShapeDataAction::CHANGE_STELLRADIUSTOPRIMARY, 
00743                                             ShapeToEdit->GetStellRadiusToPrimary()) == AC_FAIL)
00744         {
00745             return FALSE;
00746         }
00747         ShapeToEdit->SetStellRadiusToPrimary(NewRatio);
00748     }
00749 
00750     // See if we should rotate the shape to a specific angle
00751     // OR see if we should rotate the shape by a specified ammount
00752     if ((NewShapeData->RotateTo != -1000.0) || (NewShapeData->RotateBy != -1000.0) )
00753     {
00754         // Get rotate matrix
00755         ANGLE RotateBy;
00756         const DocCoord MajorOrigin = ShapeToEdit->GetMajorAxes() - ShapeToEdit->GetCentrePoint();
00757         const double CurrentAngle = atan2((double)MajorOrigin.y, (double)MajorOrigin.x) ;
00758         if (NewShapeData->RotateTo != -1000.0)
00759         {
00760             RotateBy = -(CurrentAngle - NewShapeData->RotateTo) * (180/PI); 
00761         }
00762         else
00763         {                                                                  
00764             RotateBy = NewShapeData->RotateBy * (180/PI); 
00765         }       
00766         
00767         Trans2DMatrix* RotateMat = new Trans2DMatrix(ShapeToEdit->GetCentrePoint(), RotateBy);
00768         if (!DoTransformNode(ShapeToEdit, RotateMat))
00769         {
00770             return FALSE;
00771         }
00772     }
00773 
00774     // See if we should change the stellation offset to a new angle
00775     // OR see if we should change the stellation offset by a specified ammount
00776     if ((NewShapeData->SetStellationOffset != -1000.0) || (NewShapeData->AddStellationOffset != -1000.0) )
00777     {
00778         const UINT32 NumSides = ShapeToEdit->GetNumSides();
00779         const double OppositeRatio = 180.0/(360.0/NumSides);
00780         double NewRatio;
00781         if (NewShapeData->SetStellationOffset != -1000.0)
00782         {
00783             NewRatio = OppositeRatio * (NewShapeData->SetStellationOffset / 180.0);
00784         }
00785         else
00786         {
00787             double NewOffset = (ShapeToEdit->GetStellationRatio()/OppositeRatio)*180.0 + NewShapeData->AddStellationOffset;
00788 
00789             if (NewOffset < -180.0)
00790                 NewOffset = 180.0 + (NewOffset + 180.0);
00791             if (NewOffset > 180.0)
00792                 NewOffset = -180.0 + (NewOffset - 180.0);
00793             NewRatio = OppositeRatio * (NewOffset / 180.0);
00794         }
00795 
00796         if (ChangeShapeDataAction::DoToggle(this, &UndoActions, ShapeToEdit, 
00797                 ChangeShapeDataAction::CHANGE_STELLATIONOFFSET, ShapeToEdit->GetStellationRatio()) == AC_FAIL)
00798         {
00799             return FALSE;
00800         }
00801         ShapeToEdit->SetStellationRatio(NewRatio);
00802     }
00803 
00804     // See if we should change the centre point
00805 /*  if (NewShapeData->NewCentrePoint != DontCare)
00806     {
00807         if (ChangeShapePointAction::DoToggle(this, &UndoActions, ShapeToEdit, 
00808                     ChangeShapePointAction::CHANGE_CENTRE, ShapeToEdit->GetCentrePoint()) == AC_FAIL)
00809         {
00810             return FALSE;
00811         }
00812         ShapeToEdit->SetCentrePoint(NewShapeData->NewCentrePoint);
00813     }*/
00814 
00815     // See if we should translate the shape to an exact location
00816     if (NewShapeData->TranslateTo != DontCare)
00817     {
00818         DocCoord Offset = NewShapeData->TranslateTo - ShapeToEdit->GetCentrePoint() ;
00819 
00820         Trans2DMatrix* TransMat = new Trans2DMatrix(Offset.x, Offset.y);
00821         if (!DoTransformNode(ShapeToEdit, TransMat))
00822             return FALSE;
00823     }
00824 
00825     // See if we should translate the shape by an offset
00826     if (NewShapeData->TranslateBy != DontCare)
00827     {
00828         Trans2DMatrix* TransMat = new Trans2DMatrix(NewShapeData->TranslateBy.x, NewShapeData->TranslateBy.y);
00829         if (!DoTransformNode(ShapeToEdit, TransMat))
00830             return FALSE;
00831     }
00832 
00833     // See if we should change edge path one
00834     if (NewShapeData->NewEdgePath1 != NULL)
00835     {
00836         if (ChangeShapePathAction::DoReshape(this, &UndoActions, ShapeToEdit, 
00837                     ChangeShapePathAction::CHANGE_PATH1, &(ShapeToEdit->EdgePath1)) == AC_FAIL)
00838         {
00839             return FALSE;
00840         }
00841         ShapeToEdit->EdgePath1.ClearPath();
00842         ShapeToEdit->EdgePath1.CopyPathDataFrom(NewShapeData->NewEdgePath1);        
00843     }
00844 
00845     // See if we should change edge path two
00846     if (NewShapeData->NewEdgePath2 != NULL)
00847     {
00848         if (ChangeShapePathAction::DoReshape(this, &UndoActions, ShapeToEdit, 
00849                     ChangeShapePathAction::CHANGE_PATH2, &(ShapeToEdit->EdgePath2)) == AC_FAIL)
00850         {
00851             return FALSE;
00852         }
00853         ShapeToEdit->EdgePath2.ClearPath();
00854         ShapeToEdit->EdgePath2.CopyPathDataFrom(NewShapeData->NewEdgePath2);        
00855     }
00856 
00857     // Invalidate the shapes bounding rect as it's changed
00858     ShapeToEdit->InvalidateBoundingRect();
00859     ShapeToEdit->InvalidateCache();
00860 
00861     // Cause a redraw of the shape with its end bounds
00862     if (RecordBoundsAction::DoRecord(this, &UndoActions, ShapeToEdit) == AC_FAIL)
00863     {
00864         return FALSE;
00865     }
00866 
00867     return TRUE;
00868 }

void OpEditRegularShape::DoWithParam OpDescriptor pOpDesc,
OpParam pEntryOpParam
[virtual]
 

Performs the edit regular shapes operation.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/12/94
Parameters:
OpDescriptor (unused) [INPUTS] pOpParam - pointer to the parameter object.
Returns:
Errors: -
See also:
EditRegularShapeParam, OpEditRegularShape::CarryOut

Reimplemented from Operation.

Definition at line 332 of file shapeops.cpp.

00333 {   
00334     EditRegularShapeParam* pOpParam = (EditRegularShapeParam*)pEntryOpParam;
00335     
00336     // Tell the operation system its kickoff time.
00337     if (DoStartSelOp(FALSE))
00338     {
00339         BOOL Complete = TRUE;
00340 
00341         // Data used by AllowOp() to ask the node if it's ok to do the op
00342         ObjChangeFlags cFlags;
00343         ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
00344 
00345         // Either change just one shape or all selected shapes.
00346         if (pOpParam->ShapeToChange != NULL)
00347         {
00348             if (ShouldDoThisShape(pOpParam->ShapeToChange, pOpParam->ShapesToAffect))
00349             {
00350                 if (pOpParam->ShapeToChange->AllowOp(&ObjChange))                   // Will node allow the op?
00351                     Complete = CarryOut(pOpParam->ShapeToChange, pOpParam);
00352             }
00353         }
00354         else
00355         {
00356             // Obtain the current selections and the first node in the selection
00357             SelRange*   Selected = GetApplication()->FindSelection();
00358             Node*       pNode = Selected->FindFirst();
00359 
00360             while ((pNode != NULL) && Complete)
00361             {
00362                 if (IS_A(pNode,NodeRegularShape))
00363                 {
00364                     if (ShouldDoThisShape((NodeRegularShape*)pNode, pOpParam->ShapesToAffect))
00365                     {
00366                         if (pNode->AllowOp(&ObjChange))                             // Will node allow the op?
00367                             Complete = CarryOut((NodeRegularShape*)pNode, pOpParam);
00368                     }
00369                 }
00370                 pNode = Selected->FindNext(pNode);
00371             }
00372         }
00373 
00374         GetApplication()->FindSelection()->Update(FALSE);
00375     
00376         if (Complete)
00377         {
00378             // updated effected parents
00379             ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
00380             Complete = UpdateChangedNodes(&ObjChange);
00381         }
00382 
00383         // See if anything failed
00384         if (!Complete)
00385         {
00386             FailAndExecute();
00387         }
00388     }
00389     else
00390     {
00391         FailAndExecute();
00392     }
00393 
00394     End();
00395 }

OpState OpEditRegularShape::GetState String_256 UIDescription,
OpDescriptor
[static]
 

For finding the OpEditRegularShape's state.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/12/94
Returns:
The state of the OpEditRegularShape
See also:
-

Definition at line 310 of file shapeops.cpp.

00311 {
00312     OpState OpSt;
00313 
00314     return OpSt;                                 
00315 }

BOOL OpEditRegularShape::Init void   )  [static]
 

OpEditRegularShape initialiser method.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/12/94
Returns:
TRUE if the operation could be successfully initialised FALSE if no more memory could be allocated

Errors: ERROR will be called if there was insufficient memory to allocate the operation.

See also:
-

Reimplemented from SimpleCCObject.

Definition at line 275 of file shapeops.cpp.

00276 {
00277     BOOL Success = RegisterOpDescriptor(0, 
00278                                         _R(IDS_EDITREGULARSHAPEOP),
00279                                         CC_RUNTIME_CLASS(OpEditRegularShape), 
00280                                         OPTOKEN_EDITREGULARSHAPE,
00281                                         OpEditRegularShape::GetState);
00282 
00283     if (Success)
00284         Success = OpShapeToggleElipPoly::Init();
00285     if (Success)
00286         Success = OpShapeToggleStellation::Init();
00287     if (Success)
00288         Success = OpShapeToggleCurvature::Init();
00289     if (Success)
00290         Success = OpShapeToggleSetNumSides::Init();
00291     if (Success)
00292         Success = OpShapeMakeRegular::Init();
00293 
00294     return Success;
00295 }               

BOOL OpEditRegularShape::ShouldDoThisShape NodeRegularShape pShape,
EditRegularShapeParam::AffectShape  Allowance
[protected]
 

Do decide wether or not the shape should be edited. The decision is based upon the Allowance mode.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/03/95
Parameters:
pShape - points to a regular shape [INPUTS] Allowance - the current shape allowance mode
- [OUTPUTS]
Returns:
TRUE if this shape should be changed in this operation FALSE if this shape should not be changed

Errors: -

See also:
-

Definition at line 889 of file shapeops.cpp.

00890 {
00891     ERROR2IF(pShape == NULL, FALSE, "Can't edit a NULL shape!");
00892 
00893     switch (Allowance)
00894     {
00895         case EditRegularShapeParam::AFFECT_ALL:
00896             return TRUE;
00897             break;
00898         case EditRegularShapeParam::AFFECT_ELLIPSES:
00899             return pShape->IsCircular();
00900             break;
00901         case EditRegularShapeParam::AFFECT_RECTANGLES:
00902             return (!pShape->IsCircular() && (pShape->GetNumSides() == 4) );
00903             break;
00904         default:
00905             ERROR3("Allowance was not known");
00906             return FALSE;
00907     }
00908 }


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