opfree.h

Go to the documentation of this file.
00001 // $Id: opfree.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 the Freehand operation
00099 
00100 #ifndef INC_OPFREE
00101 #define INC_OPFREE
00102 
00103 //#include "doccoord.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "selop.h"
00105 
00106 class NodeBlend;
00107 class OpState;
00108 class NodePath;
00109 class Path;
00110 class Cursor;
00111 class NodeGroup;
00112 struct FreeHandJoinInfo;
00113 
00114 #define OPTOKEN_FREEHAND _T("FreeHandTool")
00115 
00116 
00117 /********************************************************************************************
00118 
00119 <   CursorType
00120 
00121     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00122     Created:    9/5/94
00123     Comments:   Used by OpFreeHand to decide which cursor to use during its life.
00124                 Possible cases are NORMAL_CURSOR, JOIN_CURSOR, STRAIGHTLINE_CURSOR and
00125                 RUBOUT_CURSOR
00126 
00127 ********************************************************************************************/
00128 
00129 typedef enum
00130 {
00131     NORMAL_CURSOR,
00132     JOIN_CURSOR,
00133     STRAIGHTLINE_CURSOR,
00134     RUBOUT_CURSOR,
00135     MODIFY_CURSOR
00136 } CursorType;
00137 
00138 
00139 /********************************************************************************************
00140 
00141 <   SimpleJoinType
00142 
00143     Author:     Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
00144     Created:    21/3/2000
00145     Comments:   When we have a simple join, i.e. one end of a new path joins one end of an 
00146                 existing path, then it can be one of the following types:
00147 ********************************************************************************************/
00148 
00149 typedef enum
00150 {
00151     JOINTYPE_NONE,
00152     JOINTYPE_NEWSTART_TO_OLDSTART,
00153     JOINTYPE_NEWSTART_TO_OLDEND,
00154     JOINTYPE_NEWEND_TO_OLDSTART,
00155     JOINTYPE_NEWEND_TO_OLDEND
00156 } SimpleJoinType;
00157 /********************************************************************************************
00158 
00159 >   class OpFreeHand : public SelOperation
00160 
00161     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00162     Created:    1/7/93
00163     Purpose:    This is the FreeHand Operation that builds a smoothed curve
00164 
00165 ********************************************************************************************/
00166 
00167 class OpFreeHand : public SelOperation
00168 {
00169 
00170 CC_DECLARE_DYNCREATE(OpFreeHand);
00171 
00172 public:
00173     // Construction/Destruction
00174     OpFreeHand();
00175 
00176     // The all important Do functions
00177     void DoDrag(DocCoord Anchor, Spread*, INT32, FreeHandJoinInfo* pJoinInfo, Path* ToolPath);
00178     virtual BOOL SnappingDrag() { return FALSE;  }
00179     
00180     // We want to know about key presses so we can see when the modifers change if the
00181     // mouse is not moving
00182     virtual BOOL DragKeyPress(KeyPress* pKeyPress, BOOL bSolidDrag);
00183 
00184     // Virtual functions needed for the dragging operations to work
00185     virtual void DragPointerMove(DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag);
00186     virtual void DragPointerIdle(DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag);
00187     virtual void DragFinished(  DocCoord PointerPos, 
00188                                 ClickModifiers ClickMods, 
00189                                 Spread *, 
00190                                 BOOL Success, BOOL bSolidDrag);
00191 
00192 
00193     // Some Render functions to will draw the EORed path
00194     void RenderDragBlobs( DocRect, Spread*, BOOL bSolidDrag );
00195         
00196     // These functions required for the OpDescriptor class
00197     static BOOL Declare();
00198     static OpState GetState(String_256* Description, OpDescriptor*);
00199 
00200     virtual BOOL IsBrushOp() { return FALSE;}
00201 protected:
00202     // Functions to help with the cursors
00203     BOOL LoadCursors();
00204     void RemoveCursors();
00205     void SetCursorOnMove(ClickModifiers ClickMods, Spread* pSpread, DocCoord* PointerPos);
00206     virtual void SetCursorAndStatus(CursorType CurType);
00207  
00208     // Functions to help during a drag
00209     BOOL PrepareTrackDataPath();
00210     void RubOutPath(DocCoord Pos, Spread* pSpread);
00211     void AddPointsToPath(DocCoord Pos, Spread* pSpread);
00212     BOOL CheckMouseOverSelectedPath(DocCoord* Pos, Spread* pSpread, BOOL* IsNearEndpoint);
00213     BOOL AreSlotsInSameSubPath(INT32 Slot1, INT32 Slot2, Path* pPath);
00214     
00215     // Functions to help with the building of a smoothed path
00216     BOOL CompleteOperation();
00217     BOOL CreateNewPath(NodePath** pNewPath);
00218     BOOL SmoothNewCurve(NodePath* pNewNodePath);
00219     BOOL InsertSmoothCurveWithUndo(NodePath* pNewNodePath);
00220 
00221     // Functions to help with replacing sections of existing paths
00222     virtual BOOL TryToReplaceSection(NodePath* pNewNodePath);
00223     BOOL SplitAtPoint(const DocCoord& SplitPoint, INT32*, INT32*);
00224     BOOL ReplaceMiddleOfPath(NodePath* pNewPath, INT32 FirstChangedIndex, INT32 NumElements);
00225 
00226     // updates the timestamping and pressure lists of a brush 
00227     virtual BOOL EditBrushLists(NodePath* pNewPath, INT32 FirstChangedIndex, INT32 NumElements);
00228     virtual BOOL SimpleJoinBrush(NodePath* pNodePath, Path* pPath);
00229     virtual BOOL ReverseBrushPressure();
00230     // applies retro smoother to a brush
00231     virtual BOOL RetroSmoothBrush(NodePath* pNodePath);
00232 
00233     // Functions to help with the joining of paths
00234     BOOL TryToJoinNewPathWithOthers(NodePath* FreePath);
00235     BOOL SimpleJoin(NodePath* FreePath, NodePath* OldPath);
00236     BOOL ComplexJoin(NodePath* FreePath, NodePath* OldPath);
00237     BOOL ComplexToComplexJoin(NodePath* FreePath, NodePath* OldPath);
00238     BOOL VeryComplexToComplexJoin(NodePath* FreePath, NodePath* TopPath, NodePath* BotPath);
00239 
00240     // Functions to help with the creation of new paths
00241     virtual BOOL ApplyAttributes(NodePath* NewPath, Document *pDocument);
00242     BOOL AddPressureAttribute(NodePath *NewPath);
00243     NodePath* MakeCopy(Node* pOriginalNode);
00244     BOOL InsertNewNode(NodePath* pNewNode, DocRect& Invalid, Node* pOldNode, Node* pOtherOld = NULL);
00245     void SetRetroPath(NodePath* pNodePath, INT32 Start, INT32 Len);
00246 
00247     // Functions used in Straight Line Mode
00248     void AddStraightLine();
00249 
00250     void RenderLine(RenderRegion *pRender, Path *pPath, INT32 CoordIndex, BOOL StartCoord = FALSE);
00251     void RenderLine(DocRect* Rect, Spread* pSpread, Path *pPath, INT32 Index, BOOL StartCoord = FALSE);
00252 
00253     void RenderEorStraightLine(DocRect*, Spread* pSpread, DocCoord *Start=NULL, DocCoord *End=NULL);
00254     void RenderEorStraightLine(RenderRegion *pRender,
00255                                 DocCoord *pStart, INT32 StartWidth,
00256                                 DocCoord *pEnd, INT32 EndWidth);
00257 
00258     SimpleJoinType GetSimpleJoinType(Path* pNewPath, Path* ExistingPath);
00259     
00260     INT32 GetCurrentLineWidth(void);
00261 
00262     // DY 9/99 if we are editing the path of a blend on a path then this function
00263     // retrieves the parent NodeBlend of the NodeblendPath
00264     NodeGroup* GetParentOfNodePath();  
00265     BOOL InsertChangeBlendStepsAction(NodeBlend* pNodeBlend); 
00266     BOOL InvalidateBrushRegion(NodePath* pNodePath);
00267 
00268         // General data to help with the path fitting and joining
00269     Path*       TrackData;          // A Path to store the mouse moves in (part of the tool)
00270     DocCoord    StartPoint;         // The first point in the path
00271     Spread*     StartSpread;        // The spread we started on
00272     Spread*     PreviousSpread;     // The spread that the last point was over
00273     INT32       Smoothness;         // The current smoothing factor
00274 
00275     // Data that is maintained as we draw
00276     DocCoord    PreviousPoint;      // The most recently added point
00277     INT32       LineSegmentCount;   // Number of elements in the path.
00278     BOOL        CanLineJoin;        // TRUE if the line can be joined to its start
00279     BOOL        IsStraightLineMode;
00280     DocCoord    StraightLinePos;
00281 
00282     // Pressure info
00283     BOOL AddPressureToPath;         // TRUE is we should bother to add pressure info
00284     UINT32 FreeHandPressure;            // The current pen pressure
00285 
00286     // The paths that we are joined to, or NULL if we are joined to none
00287     FreeHandJoinInfo* pJoinInfo;
00288     NodePath*   StartPath;
00289     NodePath*   EndPath;
00290     INT32       CloseTo;            // Slot that the end path is near
00291     double      Mu;                 // The bezier distance along the segment to the closest point
00292     BOOL        IsEndNearEndpoint;
00293 
00294     // The Cursors used by this operation
00295     Cursor* pFreeHandCursor;        // Normal freehand cursor
00296     Cursor* pJoinCursor;            // Freehand join cursor
00297     Cursor* pRubOutCursor;          // Rub Out Mode Cursor
00298     Cursor* pStraightCursor;        // Straight Line Mode Cursor
00299     Cursor* pModifyCursor;          // Indicates the completion of a modify line
00300     Cursor* MyCurrentCursor;        // so I don't flip cursor too often
00301     INT32   CurrentCursorID;        // ID of the current cursor on the stack
00302         
00303 
00304     NodePath* m_pNewNodePath;
00305 
00306 
00307 private:
00308 
00309 };
00310 
00311 #endif  // INC_OPFREE

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