pathedit.h

Go to the documentation of this file.
00001 // $Id: pathedit.h 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // Header file for path editing routines
00099 
00100 #ifndef INC_PATHEDIT
00101 #define INC_PATHEDIT
00102 
00103 //#include "paths.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "rndrgn.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "selop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 #include "objchge.h"
00107 
00108 #define OPTOKEN_JOINSHAPEOP     _T("JoinShapes")
00109 #define OPTOKEN_BREAKSHAPEOP    _T("BreakShapes")
00110 #define OPTOKEN_DELETEPOINTSOP  _T("DeletePoints")
00111 
00112 #define OPTOKEN_ADDENDPOINT     _T("AddEndpoint")
00113 #define OPTOKEN_AUTOCLOSEPATHS  _T("AutoClosePaths")
00114 
00115 class NodePath;
00116 class Document; 
00117 class OperationHistory;
00118 class SelectionState;     
00119 class Spread;
00120 class Node;
00121 class NodeHidden;
00122 class TransformBase;
00123 class BezierTool;
00124 class Cursor;
00125 class AttrBrushType;
00126 class NodeBlend;
00127 class NodeGroup;
00128 
00129 /********************************************************************************************
00130 
00131 >   class OpNodePathEditBlob : public SelOperation
00132 
00133     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00134     Created:    1/7/93
00135     Purpose:    This operation is started by the NodePath when it receives a drag message
00136                 from one of the tools. It uses it to drag one (or many) of the paths control
00137                 points around the screen to edit the path. As the control points are dragged
00138                 about the new version of the path, corosponding to the new blob positions,
00139                 will be EOR rendered to the window.
00140 
00141 ********************************************************************************************/
00142 
00143 class OpNodePathEditBlob : public SelOperation
00144 {
00145 
00146 CC_DECLARE_DYNCREATE(OpNodePathEditBlob)
00147 
00148 public:
00149     // Construction/Destruction
00150     OpNodePathEditBlob();
00151 
00152     // The all important Do functions
00153     void DoStartDragEdit( NodePath*, DocCoord Anchor, Spread *);
00154     
00155     // Virtual functions needed for the dragging operations to work
00156     virtual void DragPointerMove( DocCoord Pos, ClickModifiers Mods, Spread* pSpread, BOOL bSolidDrag);
00157     virtual void DragFinished(  DocCoord Pos, ClickModifiers Mods, Spread* pSpread, BOOL Success, BOOL bSolidDrag);
00158 
00159     // Some Render functions to draw the EORed path
00160     virtual void RenderDragBlobs (DocRect, Spread*, BOOL bSolidDrag);       // Called by camelot
00161 
00162     // These functions required for the OpDescriptor class
00163     static BOOL Init();
00164     static OpState GetState(String_256* Description, OpDescriptor*);
00165 
00166 protected:
00167     // Functions to build and keep the path smooth during editing
00168     BOOL BuildEditPath();
00169     BOOL BuildEditPaths();      // CGS 19/4/2000
00170     BOOL CopyEditedPathBack();
00171     BOOL CopyEditedPathBack(NodePath* pOrigPath, Path* pEditPath);          // CGS 20/4/2000
00172     BOOL CopyNeedToRenderFlags();
00173     BOOL CopyNeedToRenderFlags(NodePath* pOrigPath, Path* pEditPath);       // CGS 20/4/2000
00174     void RecalculatePath(DocCoord Offset, BOOL SnapEnds = FALSE, INT32 SnapIndex = 0);
00175     void RecalculatePaths(Path* pEditPath, DocCoord Offset, BOOL SnapEnds = FALSE, INT32 SnapIndex = 0);    // CGS 20/4/2000
00176     void SnapEndsTogether();
00177     void SnapEndsTogether(Path* pEditPath);
00178     BOOL JoinWithOtherPath();
00179     BOOL JoinWithOtherPath(NodePath** pOrigPath);
00180     BOOL FillPathIfEndsSnapped();
00181     BOOL FillPathIfEndsSnapped(NodePath* pOrigPath);
00182     virtual void RenderDraggingBlobs (DocRect, Spread*);    // Called by this/derived operation
00183     virtual void RenderDraggingBlobs (Path* pEditPath, Spread*);    // Called by this/derived operation // CGS 20/4/2000
00184     void RenderPathEditBlobs( DocRect Rect, Spread *pSpread );
00185     void RenderPathEditBlobs( Path* pEditPath, /*DocRect Rect,*/ Spread *pSpread );     //CGS 20/4/2000
00186     virtual void SetStatusLineHelp();
00187 
00188     // DY 9/99 if we are editing the path of a blend on a path then this function
00189     // retrieves the parent NodeBlend of the NodeblendPath
00190     NodeGroup* GetGroupParentOfCurve();  
00191     NodeGroup* GetGroupParentOfCurve(NodePath* pOrigPath);              // CGS 20/4/2000
00192     BOOL InsertChangeBlendStepsAction(NodeBlend* pNodeBlend); 
00193     AttrBrushType* GetAppliedBrush();
00194 
00195 
00196     virtual BOOL EditBrushAttribute(INT32 FirstIndex, INT32 LastIndex, AttrBrushType* pAttrBrush); 
00197     MILLIPOINT GetLengthOfPathSection(Path* pPath, INT32 FirstIndex, INT32 LastIndex);
00198     MILLIPOINT GetDistanceToPathIndex(Path* pPath, INT32 Index);
00199 
00200     Spread*  StartSpread;       // The spread that the drag started on
00201     DocCoord StartMousePos;     // Mouse position of initial click
00202     DocCoord LastMousePos;      // The position of the mouse at the last mouse move message
00203     DocCoord ConstrainPoint;    // The coord around which to constrain the drag
00204     DocCoord ConstrainPrevPoint;    // The coordinate of the previous point on the path
00205     DocCoord ConstrainNextPoint;    // The coordinate of the next point on the path
00206 
00207     // The original path and a copy of it that we can change
00208     NodePath*   OriginalPath;
00209     Path        EditPath;
00210 
00211     // The original node paths and a copies of them that we can change
00212     List    OriginalPaths;
00213     List    EditPaths;
00214     List    PathsDragStarted;
00215 
00216     BOOL    MultiplePaths;      // whether were dealing with multiple paths
00217     
00218     // Two flags to determine how we're snapping. We can either snap to
00219     // the other end of the path, or to the end of another path, or neither
00220     // but never both.  
00221     BOOL        EndSnapped;     // if the start snapped to the end
00222     BOOL        SnapToAnother;  // If the end snapped to another end
00223     NodePath*   SnapToPath;     // Pointer to path we might be snapping to
00224     INT32       SnapToIndex;    // Index of element we're snapping to
00225     BOOL        SnapToLineOrCurve;  // TRUE is snapping to a curve, FALSE if line
00226     DocCoord    SnapToCoords[4];// Array of coords for the other snapping path
00227 
00228     Cursor* pMoveCursor;            
00229     Cursor* pCloseCursor;   
00230     Cursor* pCrossHairCursor;               
00231     Cursor* MyCurrentCursor;                // so I don't flip cursor too often
00232     INT32   CurrentCursorID;                // ID of the current cursor on the stack
00233     void    ChangeCursor(Cursor* cursor);   // function to change cursor
00234     BOOL    CreateCursors();
00235     void    DestroyCursors();
00236     
00237     ObjChangePathEdit EditObjChange;
00238 
00239     List    ObjChanges;                     // for the multiple case ....
00240 
00241     INT32   DragPoint;          // Two indexes to the point(s) currently being
00242     INT32   UpdatePoint;        // dragged
00243 
00244     BOOL    DragStarted;
00245 
00246 };
00247 
00248 
00249 
00250 
00251 
00252 /********************************************************************************************
00253 
00254 >   class OpNodePathEditControlBlob : public OpNodePathEditBlob
00255 
00256     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00257     Created:    1/7/93
00258     Purpose:    This operation is started by the NodePath when it receives a drag message
00259                 from one of the tools. It uses it to drag one of the paths Bezier control
00260                 points around the screen to edit the path. As the control points are dragged
00261                 about the new version of the path, corosponding to the new blob positions,
00262                 will be EOR rendered to the window.
00263                 This class is derived from OpNodePathEditBlob which drags the normal selected
00264                 points around. This drags the Bezier control points around of one of the 
00265                 selected points on the curve. Most of the functions are not needed as it
00266                 uses the base class versions.
00267 
00268 ********************************************************************************************/
00269 
00270 class OpNodePathEditControlBlob : public OpNodePathEditBlob
00271 {
00272 
00273 CC_DECLARE_DYNCREATE(OpNodePathEditControlBlob)
00274 
00275 public:
00276     // Construction/Destruction - Simply call the base class constructor
00277     OpNodePathEditControlBlob() : OpNodePathEditBlob() { };
00278 
00279     // The all important Do functions
00280     void DoStartDragEdit( NodePath*, DocCoord Anchor, Spread *pSpread, INT32);
00281 
00282     // Virtual functions needed for the dragging operations to work
00283     virtual void DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag);
00284     virtual void RenderDragBlobs(DocRect, Spread*, BOOL bSolidDrag);
00285             
00286     // These functions required for the OpDescriptor class
00287     static BOOL Init();
00288     static OpState GetState(String_256* Description, OpDescriptor*);
00289 
00290 protected:
00291     // Private functions that help out the functions above
00292     BOOL BuildEditPath();
00293     void RecalculatePath( DocCoord Offset );
00294     virtual void RenderDraggingBlobs (DocRect, Spread*);    // Called by this/derived operation
00295     void RenderPathEditControlBlobs( DocRect Rect, Spread *pSpread );
00296     void SetStatusLineHelp();
00297 
00298     // Private member vars
00299     INT32 Index;                // Index of the dragging control 
00300     INT32 EndPointIndex;        // Index of the nearest Endpoint
00301     INT32 OppositeIndex;        // Index of the control point opposite the endpoint
00302 };
00303 
00304 /********************************************************************************************
00305 
00306 >   class OpNodePathAddEndpoint : public OpNodePathEditBlob
00307 
00308     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00309     Created:    14/6/94
00310     Purpose:    This operation is started by the bezier editing tool when it wants to add
00311                 a point to the start or end of a particular path. It uses the normal dragging
00312                 of the base operation, but the action when the operation finishes is different.
00313                 This class is derived from OpNodePathEditBlob which drags the normal selected
00314                 points around. 
00315 
00316 ********************************************************************************************/
00317 
00318 class OpNodePathAddEndpoint : public OpNodePathEditBlob
00319 {
00320 
00321 CC_DECLARE_DYNCREATE(OpNodePathAddEndpoint)
00322 
00323 public:
00324     // Construction/Destruction - Simply call the base class constructor
00325     OpNodePathAddEndpoint() : OpNodePathEditBlob() {};
00326 
00327     // The all important Do functions
00328     void DoStartDragEdit( NodePath*, DocCoord Anchor, Spread *pSpread, ClickModifiers Mods, INT32 PathIndex, BOOL CurveOrLine, BOOL CloseThePath = FALSE, BOOL SmoothOrCusp= TRUE);
00329 
00330     // Virtual functions needed for the dragging operations to work
00331     // We don't need to override the normal dragging functions...
00332 
00333     //virtual void DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread* );
00334 
00335     // but we do need to override the DragFinished event in order to add the endpoint
00336     // before we put in the smoothed points
00337 
00338     virtual void DragFinished(  DocCoord Pos, ClickModifiers Mods, Spread* pSpread, BOOL Success, BOOL bSolidDrag);
00339                 
00340     // These functions required for the OpDescriptor class
00341     static BOOL Init();
00342     static OpState GetState(String_256* Description, OpDescriptor*);
00343 
00344 protected:
00345     // Private functions that help out the functions above
00346     BOOL BuildEditPath(DocCoord NewPoint);
00347 
00348     BOOL InsertElement(DocCoord NewPoint, Path* DestPath, INT32 InsPos, INT32* NewPosition,
00349                         BOOL RecordUndo = FALSE, NodePath* UndoPath = NULL);
00350     BOOL Complete(DocCoord AddElementPoint);
00351     BOOL CompleteThisPath(DocCoord AddElementPoint);
00352     virtual void SetStatusLineHelp();
00353     virtual BOOL EditBrushAttribute(INT32 FirstIndex, INT32 LastIndex, AttrBrushType* pAttrBrush); 
00354 
00355 
00356     // Private member vars
00357     INT32 NewPointIndex;        // Index of point added to temporary path
00358     INT32 InsertPosition;   // Index of point to which new point was added
00359     BOOL IsPathClosing;     // Tells the operation if the added segment should close the path
00360     BOOL AddCurveFlag;      // TRUE if adding curve, FALSE if adding line
00361     BOOL AddSmoothFlag;     // TRUE if adding smooth point, FALSE if adding cusp.
00362 
00363 };
00364 
00365 
00366 
00367 /********************************************************************************************
00368 >   class OpCloseNodePaths : public OpNodePathAddEndpoint
00369 
00370     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00371     Created:    19/12/95
00372     Purpose:    This operation is for closing all the open selected paths.
00373 ********************************************************************************************/
00374 class OpCloseNodePaths : public OpNodePathAddEndpoint
00375 {
00376     CC_DECLARE_DYNCREATE(OpCloseNodePaths)
00377 
00378 public:
00379     OpCloseNodePaths() : OpNodePathAddEndpoint() { };
00380 
00381     void DoWithParam(OpDescriptor* pOpDesc, OpParam* pOpParam);
00382     static BOOL Init();
00383     static OpState GetState(String_256* Description, OpDescriptor*);
00384 
00385 protected:
00386     static BOOL IsThisPathCloseable(NodePath* pPath);
00387     BOOL CloseThisPath(NodePath* pPath);
00388 };
00389 
00390 
00391 /********************************************************************************************
00392 
00393 >   class OpReshapeOrAddPoint : public OpNodePathEditBlob
00394 
00395     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00396     Created:    30/8/94
00397     Purpose:    This operation serves two purposes - while dragging, it will reshape a bezier
00398                 segment, changing the path on ending the drag. However, if the drag is 
00399                 released immediately after it is initiated, a point is added to the bezier
00400                 curve (or line) at the click point.
00401 
00402 ********************************************************************************************/
00403 
00404 class OpReshapeOrAddPoint : public OpNodePathEditBlob
00405 {
00406 
00407 CC_DECLARE_DYNCREATE(OpReshapeOrAddPoint)
00408 
00409 public:
00410     // Construction/Destruction 
00411     OpReshapeOrAddPoint();
00412 
00413     // The all important Do functions
00414     void DoStartDragEdit( NodePath*, DocCoord Anchor, Spread *pSpread, INT32, double);
00415 
00416     // Virtual functions needed for the dragging operations to work
00417     virtual void DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag);
00418             
00419     // We need to override the DragFinished event in order to add a point
00420     // if the mouse didn't move very much.
00421 
00422     virtual void DragFinished(  DocCoord Pos, ClickModifiers Mods, Spread* pSpread, BOOL Success, BOOL bSolidDrag);
00423                 
00424     // These functions required for the OpDescriptor class
00425     static BOOL Init();
00426     static OpState GetState(String_256* Description, OpDescriptor*);
00427 
00428 protected:
00429     // Private functions that help out the functions above
00430     BOOL BuildEditPath();
00431     void RecalculatePath( DocCoord Offset );
00432     BOOL DragFinishedAddPoint( );
00433     BOOL DragFinishedReshapeLine( );
00434     void SetStatusLineHelp();
00435 
00436     // Private member vars
00437     INT32 Index;                // Index of the dragging segment
00438     double paramdist;       // parametric distance along the segment from where we drag
00439     DocCoord OrigControl1;  // Coords of first control point on curve
00440     DocCoord OrigControl2;  // Coords of second ctrl pt on curve
00441     DocCoord FurthestPoint; // Coords of furthest drag point away from start
00442     BOOL HaveMadeCurve;     // True if the dragging segment started as a line
00443 };
00444 
00445 /********************************************************************************************
00446 
00447 >   class OpNewPath : public OpNodePathEditBlob
00448 
00449     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00450     Created:    18/7/94
00451     Purpose:    This operation will create a new path of a single line or curve and put it in
00452                 the tree. 
00453 
00454 ********************************************************************************************/
00455 
00456 class OpNewPath : public OpNodePathEditBlob
00457 {
00458 
00459 CC_DECLARE_DYNCREATE(OpNewPath)
00460 
00461 public:
00462     // Construction/Destruction - Simply call the base class constructor
00463     OpNewPath() : OpNodePathEditBlob() { };
00464 
00465     // The all important Do functions
00466     void DoStartDragEdit( DocCoord, DocCoord, Spread*, ClickModifiers Mods, BOOL MakeCurve, BOOL MakeSmooth);
00467 
00468     // Virtual functions needed for the dragging operations to work
00469     // We don't need to override the normal dragging functions...
00470     // but we do need to override the DragFinished event in order to add the endpoint
00471     // before we put in the smoothed points
00472 
00473     virtual void DragFinished(  DocCoord Pos, ClickModifiers Mods, Spread* pSpread, BOOL Success, BOOL bSolidDrag);
00474                 
00475     // These functions required for the OpDescriptor class
00476     static BOOL Init();
00477     static OpState GetState(String_256* Description, OpDescriptor*);
00478 
00479 protected:
00480     // Private functions that help out the functions above
00481     BOOL BuildEditPath(DocCoord FirstPoint, DocCoord LastPoint);
00482 
00483     // Private member vars
00484     INT32 NewPointIndex;        // Index of point added to temporary path
00485     INT32 InsertPosition;   // Index of point to which new point was added
00486     BezierTool* pBezTool;   // Pointer to tool which called the operation
00487     BOOL AddCurveFlag;      // TRUE if adding a curve, FALSE if adding a line
00488     BOOL AddSmoothFlag;     // TRUE to set rotate flags, FALSE to clear
00489 };
00490 
00491 /********************************************************************************************
00492 
00493 >   class OpToggleSmooth : public SelOperation
00494 
00495     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00496     Created:    30/6/94
00497     Purpose:    When a path point is double-clicked on, this operation is invoked to toggle
00498                 the smoothness of the point. This works much like the equivalent feature in 
00499                 ArtWorks except that making a smooth point into a cusp will change the position
00500                 of the control points.
00501 
00502 ********************************************************************************************/
00503 
00504 class OpToggleSmooth : public SelOperation
00505 {
00506 
00507 CC_DECLARE_DYNCREATE(OpToggleSmooth)
00508 
00509 public:
00510     // Construction/Destruction
00511     OpToggleSmooth();
00512 
00513     // The all important Do functions
00514     void DoTogglePoint( NodePath*, INT32 Index, Spread *, BOOL AllSmooth, BOOL DontMoveOnCusp);
00515         
00516     // These functions required for the OpDescriptor class
00517     static BOOL Init();
00518     static OpState GetState(String_256* Description, OpDescriptor*);
00519 
00520 protected:
00521     BOOL TogglePathPoints(NodePath* CurrentNode, INT32 Index, BOOL AllSmooth, BOOL DontMoveOnCusp);
00522     BOOL MakePointCusp(NodePath* CurrentNode, INT32 Index, BOOL DontMoveOnCusp);
00523     BOOL MakePointSmooth(NodePath* CurrentNode, INT32 Index);
00524 };
00525 
00526 /********************************************************************************************
00527 
00528 >   class OpJoinShapes : public SelOperation
00529 
00530     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00531     Created:    20/7/94
00532     Purpose:    This class takes two or more selected paths and combines them into one path
00533     SeeAlso:    -
00534 
00535 ********************************************************************************************/
00536 
00537 class OpJoinShapes: public SelOperation
00538 {         
00539 
00540     CC_DECLARE_DYNCREATE( OpJoinShapes )    
00541 
00542 public:
00543     OpJoinShapes();                             
00544     static BOOL     Init();             
00545     static OpState  GetState(String_256*, OpDescriptor*);       
00546     void            Do(OpDescriptor*);  
00547 
00548 };  
00549  
00550 
00551 /********************************************************************************************
00552 
00553 >   class OpBreakShapes : public SelOperation
00554 
00555     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00556     Created:    20/7/94
00557     Purpose:    This class will break compound paths into two or more simple paths. It will
00558                 work when there are one or more compound paths selected.
00559     SeeAlso:    -
00560 
00561 ********************************************************************************************/
00562 
00563 class OpBreakShapes: public SelOperation
00564 {         
00565 
00566     CC_DECLARE_DYNCREATE( OpBreakShapes )    
00567 
00568 public:
00569     OpBreakShapes();                                
00570     static BOOL     Init();             
00571     static OpState  GetState(String_256*, OpDescriptor*);       
00572     void            Do(OpDescriptor*);  
00573 
00574     // Karim 21/01/2000 - see UndoableOperation base implementation.
00575     virtual BOOL MayChangeNodeBounds() const { return FALSE; }
00576 };  
00577  
00578 
00579 /********************************************************************************************
00580 
00581 >   class OpDeletePoints : public SelOperation
00582 
00583     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00584     Created:    20/7/94
00585     Purpose:    This class will delete any selected points from selected paths.
00586     SeeAlso:    -
00587 
00588 ********************************************************************************************/
00589 
00590 class OpDeletePoints: public SelOperation
00591 {         
00592 
00593     CC_DECLARE_DYNCREATE( OpDeletePoints )    
00594 
00595 public:
00596     OpDeletePoints();                               
00597     static BOOL     Init();             
00598     static OpState  GetState(String_256*, OpDescriptor*);       
00599     void            Do(OpDescriptor*);  
00600 
00601 private:
00602     BOOL DeleteLineTo(NodePath* pPath, INT32 Index, BOOL* PathExists);
00603     BOOL DeleteMoveTo(NodePath* pPath, INT32 Index, BOOL* PathExists);
00604     BOOL DeleteBezierTo(NodePath* pPath, INT32 Index, BOOL* PathExists);
00605     
00606     // Functions to determine wether the entire path will be deleted or not
00607     static BOOL WillDeleteEntirePath(NodePath* pPath);
00608     static BOOL TryDeleteLineTo(NodePath* pPath, INT32 Index, BOOL* PathExists);
00609     static BOOL TryDeleteMoveTo(NodePath* pPath, INT32 Index, BOOL* PathExists);
00610     static BOOL TryDeleteBezierTo(NodePath* pPath, INT32 Index, BOOL* PathExists);
00611 };  
00612 
00613 
00614 
00615 /********************************************************************************************
00616 
00617 >   class ModifyPathAction : public Action
00618 
00619     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00620     Created:    6/5/94
00621     Purpose:    An action which undoes the modification of path data. This action can be
00622                 used for undoing changing coordinates or flags or verbs. Other actions will 
00623                 exist for adding or deleting elements from paths. This action is useful for
00624                 undoing large amounts of path editing (e.g. dragging several points around)
00625                 but is less useful for undoing the alteration of single coordinates. Another
00626                 Action might be created later for undoing single element alterations.
00627     SeeAlso:    -
00628 
00629 ********************************************************************************************/
00630 
00631 class ModifyPathAction : public Action
00632 {
00633 
00634 CC_DECLARE_DYNCREATE(ModifyPathAction)
00635 
00636 public:
00637     ModifyPathAction();
00638     ~ModifyPathAction();
00639     virtual ActionCode Execute();
00640     static ActionCode Init( Operation* pOp,
00641                             ActionList* pActionList,
00642                             INT32 NumChangedElements,
00643                             Action** NewAction);
00644     void StoreArrays(PathVerb* Verbs, PathFlags* Flags, DocCoord* Coords, 
00645                     INT32* Indices, NodePath* WhichPath);
00646 
00647 protected:
00648     INT32       NumElements;
00649     NodePath*   ChangedPath;
00650     PathVerb*   ChangedVerbs;
00651     PathFlags*  ChangedFlags;
00652     DocCoord*   ChangedCoords;
00653     INT32*      ChangedIndices;
00654 };
00655 
00656 
00657 /********************************************************************************************
00658 
00659 >   class RemovePathElementAction : public Action
00660 
00661     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00662     Created:    22/6/94
00663     Purpose:    An action which undoes the insertion of an element into path data (hence
00664                 removing that element from the path). 
00665     SeeAlso:    -
00666 
00667 ********************************************************************************************/
00668 
00669 class RemovePathElementAction : public Action
00670 {
00671       
00672 CC_DECLARE_DYNCREATE(RemovePathElementAction)
00673 
00674 public:
00675     RemovePathElementAction();
00676     ~RemovePathElementAction();
00677     virtual ActionCode Execute();
00678     static ActionCode Init( Operation* pOp,
00679                             ActionList* pActionList,
00680                             INT32 NumChangedElements,
00681                             INT32 ChangedIndex,
00682                             Action** NewAction);
00683     void RecordPath(NodePath* WhichPath);
00684 
00685 protected:
00686     INT32       NumElements;
00687     INT32       FirstChangedIndex;
00688     NodePath*   ChangedPath;
00689 };
00690 
00691 
00692 /********************************************************************************************
00693 
00694 >   class InsertPathElementAction : public Action
00695 
00696     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00697     Created:    22/6/94
00698     Purpose:    An action which undoes the removal of an element into path data (hence
00699                 replacing the deleted data).
00700     SeeAlso:    -
00701 
00702 ********************************************************************************************/
00703 
00704 class InsertPathElementAction : public Action
00705 {
00706 
00707 CC_DECLARE_DYNCREATE(InsertPathElementAction)
00708 
00709 public:
00710     InsertPathElementAction();
00711     ~InsertPathElementAction();
00712     virtual ActionCode Execute();
00713     static ActionCode Init( Operation* pOp,
00714                             ActionList* pActionList,
00715                             INT32 NumChangedElements,
00716                             INT32 ChangedIndex,
00717                             Action** NewAction);
00718     void RecordPath(PathVerb* Verbs, PathFlags* Flags, DocCoord* Coords, 
00719                     NodePath* WhichPath);
00720 
00721 protected:
00722     INT32       NumElements;
00723     INT32       InsertionPoint;
00724     NodePath*   ChangedPath;
00725 
00726     PathVerb*   ChangedVerbs;
00727     PathFlags*  ChangedFlags;
00728     DocCoord*   ChangedCoords;
00729 };
00730 
00731 
00732 /********************************************************************************************
00733 
00734 >   class ModifyElementAction : public Action
00735 
00736     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00737     Created:    23/6/94
00738     Purpose:    An action which undoes the modification of a single element of path data. This 
00739                 action can be used for undoing changing coordinates or flags or verbs. This action
00740                 is not really suitable if you have a lot of path data to change - ModifyPathAction 
00741                 is more efficient because it encodes multiple elements. This action was written because
00742                 for single elements, ModifyPathAction is too complicated to call.
00743     SeeAlso:    -
00744 
00745 ********************************************************************************************/
00746 
00747 class ModifyElementAction : public Action
00748 {
00749 
00750 CC_DECLARE_DYNCREATE(ModifyElementAction)
00751 
00752 public:
00753     ModifyElementAction();
00754     ~ModifyElementAction();
00755     virtual ActionCode Execute();
00756     static ActionCode Init( Operation* pOp,
00757                             ActionList* pActionList,
00758                             PathVerb Verb, 
00759                             PathFlags Flags, 
00760                             DocCoord Coord, 
00761                             INT32 Index, 
00762                             NodePath* WhichPath,
00763                             Action** NewAction);
00764 
00765     // Access functions for op merging
00766     NodePath* GetActionPath() const {return ChangedPath;}
00767     INT32 GetActionIndex() const {return ChangedIndex;}
00768 
00769 
00770 protected:
00771     NodePath*   ChangedPath;
00772     PathVerb    ChangedVerb;
00773     PathFlags   ChangedFlags;
00774     DocCoord    ChangedCoord;
00775     INT32       ChangedIndex;
00776 };
00777 
00778 /********************************************************************************************
00779 
00780 >   class ModifyFlagsAction : public Action
00781 
00782     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00783     Created:    19/7/94
00784     Purpose:    An action which undoes the modification of a path element's flags. This is a
00785                 smaller action that ModifyElementAction and is more economic for undoing 
00786                 selection change
00787     SeeAlso:    -
00788 
00789 ********************************************************************************************/
00790 
00791 class ModifyFlagsAction : public Action
00792 {
00793 
00794 CC_DECLARE_DYNCREATE(ModifyFlagsAction)
00795 
00796 public:
00797     ModifyFlagsAction();
00798     ~ModifyFlagsAction();
00799     virtual ActionCode Execute();
00800     static ActionCode Init( Operation* pOp,
00801                             ActionList* pActionList,
00802                             PathFlags Flags, 
00803                             INT32 Index, 
00804                             NodePath* WhichPath,
00805                             Action** NewAction);
00806 protected:
00807     NodePath*   ChangedPath;
00808     PathFlags   ChangedFlags;
00809     INT32       ChangedIndex;
00810 };
00811 
00812 
00813 /********************************************************************************************
00814 
00815 >   class ModifyFilledAction : public Action
00816 
00817     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00818     Created:    21/7/94
00819     Purpose:    An action which undoes the modification of a path's filled bit (or redoes it)
00820                 It can also be used to undo the IsStroked flag as well.
00821     SeeAlso:    -
00822 
00823 ********************************************************************************************/
00824 
00825 class ModifyFilledAction : public Action
00826 {
00827 
00828 CC_DECLARE_DYNCREATE(ModifyFilledAction)
00829 
00830 public:
00831     ModifyFilledAction();
00832     ~ModifyFilledAction();
00833     virtual ActionCode Execute();
00834     static ActionCode Init( Operation* pOp,
00835                             ActionList* pActionList,
00836                             BOOL UndoFillOrStroke,
00837                             BOOL FilledFlag,
00838                             NodePath* WhichPath,
00839                             Action** NewAction);
00840 protected:
00841     NodePath* ChangedPath;
00842     BOOL UndoFilled;        // TRUE if undoing filled, FALSE if undoing stroke
00843     BOOL OldFilledState;
00844 };
00845 
00846 
00847 /********************************************************************************************
00848 
00849 >   class RecalcBoundsAction : public Action
00850 
00851     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00852     Created:    11/7/94
00853     Purpose:    An action which records the bounding box of a node, and replaces it on Undo,
00854                 invalidating that area. This action should be added to the action list before 
00855                 modifying the object's bounding box. Please note that for undo and redo to work
00856                 correctly, after you have modified the bounding box, you should create a 
00857                 RecordBoundsAction object and append that to the action list. This action is the 
00858                 opposite action to Recalc, and the two should always be used in tandem.
00859     SeeAlso:    RecordBoundsAction
00860 
00861 ********************************************************************************************/
00862 
00863 class RecalcBoundsAction : public Action
00864 {
00865 
00866 CC_DECLARE_DYNCREATE(RecalcBoundsAction)
00867 
00868 public:
00869     RecalcBoundsAction();
00870     ~RecalcBoundsAction();
00871     virtual ActionCode Execute();
00872     static ActionCode Init( Operation* pOp,
00873                             ActionList* pActionList,
00874                             NodeRenderableBounded* WhichNode,
00875                             Action** NewAction);
00876     static ActionCode DoRecalc( Operation* pOp,
00877                                 ActionList* pActionList,
00878                                 NodeRenderableBounded* WhichNode,
00879                                 BOOL OptimiseRedraw = FALSE);      
00880     static BOOL CauseOptimisedRedraw(NodePath* pChangedPath, Document* pDoc, Spread* pSpread);
00881 
00882 protected:
00883     NodeRenderableBounded* ChangedNode;
00884     DocRect OldBounds;
00885 };
00886 
00887 /********************************************************************************************
00888 
00889 >   class RecordBoundsAction : public Action
00890 
00891     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00892     Created:    11/7/94
00893     Purpose:    An action which simply marks the fact that, when undone, it has to create a
00894                 RecalcBoundsAction, and invalidate the existing bounds. It is the opposite action 
00895                 to RecalcBounds and should be used after creating a Recalc object and modifying 
00896                 the bounding box. Even when executed, all the action does is invalidate the screen
00897                 and create a Recalc action.
00898     SeeAlso:    RecalcBoundsAction
00899 
00900 ********************************************************************************************/
00901 
00902 class RecordBoundsAction : public Action
00903 {
00904 
00905 CC_DECLARE_DYNCREATE(RecordBoundsAction)
00906 
00907 public:
00908     RecordBoundsAction();
00909     ~RecordBoundsAction();
00910     virtual ActionCode Execute();
00911     static ActionCode Init( Operation* pOp,
00912                             ActionList* pActionList,
00913                             NodeRenderableBounded* WhichNode,
00914                             Action** NewAction);
00915     static ActionCode DoRecord( Operation* pOp,
00916                                 ActionList* pActionList,
00917                                 NodeRenderableBounded* WhichNode,
00918                                 BOOL OptimiseRedraw = FALSE);
00919 protected:
00920     NodeRenderableBounded* ChangedNode;
00921 };
00922 
00923 
00924 /********************************************************************************************
00925 
00926 >   class SavePathArraysAction : public Action
00927 
00928     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00929     Created:    27/01/95
00930     Purpose:    Given a path, save the paths array data, ie all its verbs, coords and flags
00931                 on the undo.
00932                 Use DoRecord(Operation*, ActionList*,Path*) to save the path.
00933 
00934 ********************************************************************************************/
00935 
00936 class SavePathArraysAction : public Action
00937 {
00938 
00939     CC_DECLARE_DYNCREATE(SavePathArraysAction)
00940 
00941     public:
00942          SavePathArraysAction();
00943         ~SavePathArraysAction();
00944         virtual ActionCode Execute();
00945          static ActionCode DoRecord(Operation* pOp,
00946                                     ActionList* pActionList, 
00947                                     Path* pPath);
00948 
00949          static ActionCode Init(Operation* pOp,
00950                                 ActionList* pActionList,
00951                                 Path* Path,
00952                                 Action** NewAction,
00953                                 BOOL CreateArrays = TRUE);
00954 
00955     private:
00956         ActionCode SetUpArrays(Path* pPath, Operation* pOp);
00957         BOOL SavePathArrays(Path* pPath, 
00958                             Operation* pOp,
00959                             PathFlags** pFlags,
00960                             PathVerb** pVerbs,
00961                             DocCoord** pCoords);
00962         void SwapPathArrays();
00963 
00964     private:
00965         Path*       ChangedPath;
00966         PathVerb*   ChangedVerbs;
00967         PathFlags*  ChangedFlags;
00968         DocCoord*   ChangedCoords;
00969 
00970 };
00971 
00972 
00973 
00974 //********************************************************************************************
00975 //> class StorePathSubSelStateAction : public Action
00976 //
00977 //  Author:     Peter
00978 //  Created:    9/11/95
00979 //  Purpose:    Stores the sub-selection state of the path.  If your operation does not
00980 //              affect the selection state then you only need to insert one action.  If you
00981 //              do change the selection state you can either put one of these actions at the
00982 //              start and end of the op, or record the complete start at the start and use
00983 //              DoChangeSelection to store individual changes.
00984 //              Call DoRecord(Operation*, ActionList*, Path*) to store the selection state
00985 //  SeeAlso:    UndoableOperation::DoChangeSelection
00986 //********************************************************************************************/
00987 //class StorePathSubSelStateAction : public Action
00988 //{
00989 //  CC_DECLARE_DYNCREATE(StorePathSubSelStateAction)
00990 //
00991 //public:
00992 //  StorePathSubSelStateAction();
00993 //  ~StorePathSubSelStateAction();
00994 //  virtual ActionCode Execute();
00995 //  static ActionCode DoRecord(Operation* pOp, ActionList* pActionList, Path* pPath);
00996 //  static ActionCode Init(Operation* pOp, ActionList* pActionList, Path* Path, Action** NewAction);
00997 //
00998 //protected:
00999 //  Path*   pStatePath;         // Points to the path whose selection state is recorded
01000 //  UINT32* pIndexArray;        // Points to the array of path indexes
01001 //  UINT32  NumStoredIndexes;   // The number of indexes in the array
01002 //  BOOL    RecordingSelected;  // TRUE if the indexes are selected, FALSE if not
01003 //};
01004 
01005 
01006 #endif      // INC_PATHEDIT

Generated on Sat Nov 10 03:46:26 2007 for Camelot by  doxygen 1.4.4