transop.h

Go to the documentation of this file.
00001 // $Id: transop.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 // The base class for all the transformation operations
00099 
00100 /*
00101  * */ 
00102 
00103 
00104 #ifndef INC_TRANSOP
00105 #define INC_TRANSOP         
00106 
00107 //#include "binds.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 //#include "undoop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 
00110 // Karim MacDonald 14/10/1999
00111 // we don't hold a pointer to a SelectorTool any more - it's now a pointer to a DragTool.
00112 // class SelectorTool;
00113 class DragTool;
00114 
00115 /********************************************************************************************
00116 
00117 <   struct TransformData
00118 
00119     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00120     Created:    19/7/94
00121     Purpose:    Holds the flags and additional data for the transform operations that are
00122                 started by the Selector Tool.
00123                 MonoOn
00124                     DocCoord CentreOfTrans; // The centre of the transform
00125                     INT32 StartBlob;            // The blob that the transform was started from
00126                     BOOL LockAspect;        // Should the aspect ratio be locked
00127                     BOOL LeaveCopy;         // Should we leave a copy of the selection
00128                     BOOL ScaleLines;        // Should line widths be scaled as well
00129                     BOOL TransFills;        // Should fills be transformed as well
00130                     Range* pRange;          // range to transform; if NULL, use the selection
00131                 MonoOff
00132 
00133 
00134 ********************************************************************************************/
00135 
00136 struct TransformData
00137 {
00138     // The Centre of Transformation and which blob was clicked on (0 for none)
00139     DocCoord CentreOfTrans;
00140     INT32    StartBlob;
00141     Range*   pRange;            // range to transform; if NULL, use the selection
00142 
00143     // Various flags that effect the transform
00144     UINT32 LockAspect : 1;
00145     UINT32 LeaveCopy  : 1;
00146     UINT32 ScaleLines : 1;
00147     UINT32 TransFills : 1;
00148 };
00149 
00150 
00151 
00152 /********************************************************************************************
00153 
00154 <   struct TransformBoundingData
00155 
00156     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00157     Created:    26/8/94
00158     Purpose:    This structure holds information about the position of the selection as
00159                 well as the current scale and angles
00160                 MonoOn
00161                     // Position and size
00162                     INT32   x;
00163                     INT32   y;
00164                     INT32   Width;
00165                     INT32   Height;
00166 
00167                     // Scale
00168                     FIXED16 XScale;
00169                     FIXED16 YScale;
00170 
00171                     // Rotation angles
00172                     ANGLE   Rotation;
00173                     ANGLE   Shear;
00174                 MonoOff
00175 
00176 ********************************************************************************************/
00177 
00178 struct TransformBoundingData
00179 {
00180     // Position and size
00181     INT32   x;
00182     INT32   y;
00183     INT32   Width;
00184     INT32   Height;
00185 
00186     // Scale
00187     FIXED16 XScale;
00188     FIXED16 YScale;
00189 
00190     // Rotation angles
00191     ANGLE   Rotation;
00192     ANGLE   Shear;
00193 
00194     // Bools giving current state of control flags
00195     UINT32  ScaleLines          : 1;
00196     UINT32  LeaveCopy           : 1;
00197     UINT32  TransFills          : 1;
00198 
00199     // Bools to show which of these params have changed
00200     UINT32  XYChanged           : 1;
00201     UINT32  WHChanged           : 1;
00202     UINT32  ScaleChanged        : 1;
00203     UINT32  RotateChanged       : 1;
00204     UINT32  ShearChanged        : 1;
00205     UINT32  ScaleLinesChanged   : 1;
00206     UINT32  LeaveCopyChanged    : 1;
00207     UINT32  TransFillsChanged   : 1;
00208 
00209 };
00210 
00211 
00212 
00213 /********************************************************************************************
00214 
00215 >   class TransOperation : public UndoableOperation
00216 
00217     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> / Rik
00218     Created:    15/2/94
00219     Purpose:    The base class for all the Transform Operations. This class should provide
00220                 most of the functionality for all the transform operations such as handling
00221                 the eored drag events etc. At the end of the day it will transform the
00222                 selection is some way (depending on the derived class)
00223 
00224 ********************************************************************************************/
00225 
00226 class CCAPI TransOperation : public UndoableOperation
00227 {
00228     CC_DECLARE_DYNCREATE(TransOperation)
00229 
00230 public: 
00231     // Constructor / destructor things
00232     TransOperation(); 
00233     virtual ~TransOperation(); 
00234                                                                                 
00235     // Function to call at the start of a transOperation and at the end
00236     BOOL DoStartTransOp(BOOL RecordSelTwice, Node* NodeToTransform = NULL,
00237                         Range* RangeToTransform = NULL);
00238     virtual void End(); 
00239 
00240     virtual Matrix GetCurrentMatrix() { return Transform; };
00241 //  Node* GetNode() { return TransformNode; }
00242     Range* GetTransformRange() { return m_pTransformRange; }
00243 
00244     // Entry point to start an instant version of the transform
00245     virtual void DoWithParam(OpDescriptor*, OpParam* pOpParam);
00246 
00247     // Entry point to start an interactive version of the transform
00248     //-----------------------------------------------------------------
00249     // Karim MacDonald 14/10/1999
00250     // 
00251     //  Previous use of SelectorTool* in the prototype below replaced
00252     //  with DragTool*, to allow for changes to TransOperation
00253     //  involving pSelTool.
00254     //-----------------------------------------------------------------
00255     virtual void DragStarted(TransformData*, DragTool*, TransformBoundingData*,
00256                              DocCoord, Spread*, ClickModifiers,
00257                              DocCoord ClickOffset = DocCoord(0, 0),
00258                              Node* NodeToTrans = NULL,
00259                              DragType dragtype = DRAGTYPE_AUTOSCROLL,
00260                              BOOL bSolidDrag = FALSE);
00261 
00262     // Functions to handle a drag
00263     virtual BOOL ShouldPointerBeOffset();
00264     virtual void DragPointerMove(DocCoord, ClickModifiers, Spread*, BOOL bSolidDrag);
00265     virtual void DragPointerIdle(DocCoord, ClickModifiers, Spread*, BOOL bSolidDrag);
00266     virtual void DragFinished(DocCoord, ClickModifiers, Spread*, BOOL, BOOL bSolidDrag);
00267     virtual BOOL DragKeyPress(KeyPress* pKeyPress, BOOL bSolidDrag);
00268     virtual void DragModeChanged(BOOL bSolidDrag);
00269 
00270     //Graham: Functions to handle clicks while dragging
00271     virtual void OnClickWhileDragging(OilCoord PointerPos, ClickType Click, ClickModifiers Mods, BOOL bSolidDrag);
00272     BOOL DragCopyAction(BOOL bSolidDrag);
00273     BOOL DropCopy(BOOL bSolidDrag);
00274     BOOL SetLeaveCopy();
00275 
00276     // Virtual rendering functions
00277     virtual void RenderDragBlobs(DocRect ClipRect, Spread *ParentSpread, BOOL bSolidDrag);
00278 
00279     // Function that actually does the transforming and builds undo
00280     BOOL CompleteTransformation();
00281 
00282     // Function that applies the matrix to the OriginalBounds to produce new ones
00283     void ComputeNewBounds();
00284 
00285     //Set preferences
00286     static BOOL DeclarePrefs();
00287 
00288     // These functions required for the OpDescriptor class
00289     static BOOL Declare();
00290     static OpState GetState(String_256* Description, OpDescriptor*);
00291 
00292     //Graham 30/9/96: A list of nodes that we need to select at the end of the operation
00293     //Not exactly elegant code this, I'm afraid.
00294     List lstNodesToSelect;  
00295     void SelectNodeAfterDrag (Node* NodeToSelect);
00296     void ClearNodesToSelect ();
00297 
00298     // Karim 21/01/2000 - see UndoableOperation base implementation.
00299     virtual BOOL MayChangeNodeBounds() const { return TRUE; }
00300 
00301 protected:
00302     DocCoord GetStartPos();
00303 
00304 private:
00305     // Functions to help at the start of an immediate transform
00306     virtual void InitTransformImmediate(OpParam*);
00307 
00308     // Functions to help with the dragging
00309     virtual void InitTransformOnDrag(DocCoord, ClickModifiers);
00310     virtual void UpdateTransformOnDrag(DocCoord, Spread*, ClickModifiers&);
00311     virtual void ConstrainDrag(DocCoord*);
00312     virtual void SetStartBlob(INT32 StartBlob);
00313     virtual void UpdateTransformBoundingData();
00314     virtual void DragInputChanged(DocCoord, ClickModifiers, Spread*);
00315     virtual void DragSolidChanged(DocCoord PointerPos,
00316                                   ClickModifiers ClickMods,
00317                                   Spread* pSpread,
00318                                   BOOL bForceRecopy = FALSE);
00319     virtual BOOL CanChangeSpread();
00320 
00321     // function to build the appropriate transform matrix
00322     virtual void BuildMatrix();
00323 
00324     // Function to help separate out the code that builds the undo information
00325     BOOL LeaveCopyOfSelection();
00326 
00327     // Called by End()
00328     BOOL DoEndTransOp();
00329     BOOL DoSmartInvalidate();
00330 
00331     virtual BOOL GetStatusLineText(String_256*, Spread*, DocCoord, ClickModifiers);
00332 
00333     void FigureStatusText(String_256*);
00334 
00335     BOOL SolidDragTransform(BOOL bForceRecopy = FALSE, BOOL bForceRedraw = TRUE);
00336     BOOL SetTransformRange(Range* pTransformRange, Node* pTransformNode);
00337 
00338     BOOL TransformOverlapsOriginal();
00339 
00340 protected:
00341     // Member vars
00342     // The transforms are always started from the SelectorTool and we need to talk to it
00343     // changed by Karim MacDonald 14/10/1999 - pSelTool is now a DragTool*,
00344     // so that we can talk to SliceTool too if we need to.
00345 //  SelectorTool* pSelTool;
00346     DragTool* pSelTool;
00347 
00348     // The current position, size, angle etc of the selection being dragged
00349     TransformBoundingData BoundingData;
00350 
00351     // The original bounding coordinates expressed as an array of four coords
00352     // so that it's faster to compute the transformed bounds
00353     Coord OriginalBounds[4];
00354 
00355     DocCoord    StartPos;               // The coord where the drag started (including offset)
00356     DocCoord    MagStartPos;            // The magnetically snapped coord where drag started
00357     DocCoord    RawStartPos;            // The raw coord from the event that started the drag
00358     DocCoord    RawPos;                 // The current drag coord
00359     DocCoord    LastRawPos;             // The last coord the drag was at
00360 
00361     DocCoord    CentreOfTrans;
00362     Spread*     StartSpread;
00363     Spread*     CurrentSpread;
00364     DocCoord    Offset;
00365     BOOL        MagneticGripPoint;      // The grip point of the drag is magnetically significant
00366 
00367     // If Adjust is held down we use the centre of the objects as the centre of the
00368     // transform. We need to note the old value of the centre of transform
00369     DocCoord BoundingCentre;
00370     DocCoord OriginalCentre;
00371 
00372     // The transform matrix and info about the equivalent scale factor of the transform
00373     Matrix  Transform;
00374     Matrix  OriginalTransform;
00375 
00376     // Cached ptr to the global selection object
00377 //  Range*  Selection;
00378     BOOL    RecordTwice;
00379 
00380     // TransformNode specifies the Node that is going to be transformed. When NULL the
00381     // entire selection will be transformed. This is specified in DoStartTransOp
00382 //  Node* TransformNode; 
00383     Node* ObjectUnderCursor;
00384 
00385     // TransformRange allows the user to specify a range other than the selection.
00386 //  Range* TransformRange;
00387 
00388     // Pointer to a local copy of the range being transformed
00389     Range* m_pTransformRange;
00390 
00391     // A pointer to a selection state object required by RestoreSelections actions. 
00392     // Created in DoStartSelectionOp()  
00393     SelectionState* SelState;
00394 
00395     // Flags to indicate the type of extra things we might need to be doing
00396     BOOL LockAspect;
00397     BOOL LeaveCopy;
00398     BOOL ScaleLines;
00399     BOOL TransFills;
00400     BOOL MouseHasMoved;
00401     BOOL CanScaleLines;
00402 
00403     //Graham: If AbortTransAtEnd is set, there will be no transformation when the drag ends
00404     //See TransOperation::OnClickWhileDragging
00405     BOOL AbortTransAtEnd;
00406 
00407     //Preference variable: sets what happens if the user clicks during a drag
00408     static INT32 ClickWhileDragFunc;
00409 
00410     // String resource ID of status line help text
00411     UINT32 StatusHelpID;
00412 
00413     //Graham 27/6/96: ID of help text for SHIFT-drag, CTRL-drag etc
00414     UINT32 StatusHelpID2;
00415 
00416     // David Mc 12/5/99
00417     // The selection when entering DoStartTransOp
00418     List* m_pSelList;
00419 
00420     // This range represents the copied and transformed nodes that are used when solid dragging
00421     Range* m_pDraggedRange;
00422 
00423     // This is the spread that contains m_pDraggedRange
00424     Spread* m_pDragSpread;
00425 
00426     BOOL m_bFirstRedraw;
00427     BOOL m_bShowDraggedOutlines;
00428     MonotonicTime m_timeIdle;
00429     BOOL m_bShowOriginalOutlines;
00430     BOOL m_bRangeCacheTransformed;
00431     BOOL m_bRangeFullyTransformed;
00432 
00433     // Members to help solid dragging work efficiently and accurately...
00434     Trans2DMatrix m_PrevTransform;
00435     DocRect m_AccuracyTestRect;
00436 
00437 };                            
00438  
00439 #endif 
00440      

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