OpTranslateTrans Class Reference

This is the interactive and immediate Translate operation. When doing an immediate transform the params to DoWithParams() are as follows :- Param1 - All the standard transform data Param2 - A pointer to a DocCoord that holds to offset translate by. More...

#include <tranlate.h>

Inheritance diagram for OpTranslateTrans:

TransOperation UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject OpNudge OpPullOntoGrid List of all members.

Public Member Functions

 OpTranslateTrans ()
 Constructor. Does nothing.
virtual BOOL ShouldPointerBeOffset ()
 Tells the base class of the operation that we want our mouse coords to be left alone.

Static Public Member Functions

static BOOL Declare ()
 Adds the operation to the list of all known operations.

Private Member Functions

 CC_DECLARE_DYNCREATE (OpTranslateTrans)
virtual void InitTransformImmediate (OpParam *)
 Sets up the transform ready for an immediate translation. This is called from DoWithParam().
virtual void InitTransformOnDrag (DocCoord, ClickModifiers)
 Sets up the parameters needed to build the transform matrix at the start of the drag. This base class version of this function does nothing.
virtual void UpdateTransformOnDrag (DocCoord, Spread *, ClickModifiers &)
 Does the calculations needed when the mouse moves to keep all the params needed to build the rotation matrix up to date.
virtual void BuildMatrix ()
 Builds the transform matrix required to rotate the selection about the point CentreOfRot by the required number of degrees.
virtual void ConstrainDrag (DocCoord *)
 Will constrain the mouse position to lie along rays from the centre of rotation at the constrain angle apart (45 degrees by default).
virtual BOOL CanChangeSpread ()
 Tell the baseclass functions whether to draw drag feedback only on the start spread or to allow drag rendering to be done on other spreads too.

Private Attributes

DocCoord LastPos
DocCoord OriginalGridOffset

Detailed Description

This is the interactive and immediate Translate operation. When doing an immediate transform the params to DoWithParams() are as follows :- Param1 - All the standard transform data Param2 - A pointer to a DocCoord that holds to offset translate by.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94

Definition at line 122 of file tranlate.h.


Constructor & Destructor Documentation

OpTranslateTrans::OpTranslateTrans  ) 
 

Constructor. Does nothing.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/93

Definition at line 134 of file tranlate.cpp.

00134                                   : TransOperation()
00135 {
00136     //Set status line help
00137     StatusHelpID = _R(IDS_TRANSLTRANS_STATUS1);
00138     StatusHelpID2 = _R(IDS_TRANSLTRANS_STATUS2);
00139     CanScaleLines = FALSE;
00140 }


Member Function Documentation

void OpTranslateTrans::BuildMatrix  )  [private, virtual]
 

Builds the transform matrix required to rotate the selection about the point CentreOfRot by the required number of degrees.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/94

Reimplemented from TransOperation.

Definition at line 300 of file tranlate.cpp.

00301 {
00302     // Build a translation matrix by takeing the offset from the last mouse position
00303     // to the start mouse position
00304         Transform = Matrix(LastPos.x-GetStartPos().x, LastPos.y-GetStartPos().y);
00305 }

BOOL OpTranslateTrans::CanChangeSpread  )  [private, virtual]
 

Tell the baseclass functions whether to draw drag feedback only on the start spread or to allow drag rendering to be done on other spreads too.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
05/June/2006
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if this transform allows the drag to be transferred to another spread

Reimplemented from TransOperation.

Definition at line 283 of file tranlate.cpp.

00284 {
00285     return TRUE;
00286 }

OpTranslateTrans::CC_DECLARE_DYNCREATE OpTranslateTrans   )  [private]
 

void OpTranslateTrans::ConstrainDrag DocCoord PointerPos  )  [private, virtual]
 

Will constrain the mouse position to lie along rays from the centre of rotation at the constrain angle apart (45 degrees by default).

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/94
Parameters:
PointerPos - The current position of the mouse that needs to be constrained [INPUTS]
PointerPos - The position of the mouse after it has been constrained [OUTPUTS]

Reimplemented from TransOperation.

Definition at line 342 of file tranlate.cpp.

00343 {
00344     // Lock the mouse to move along the axis or diagonally
00345     DocCoord Blobby = GetStartPos();
00346     DocView::ConstrainToAngle(Blobby, PointerPos);
00347 }

BOOL OpTranslateTrans::Declare  )  [static]
 

Adds the operation to the list of all known operations.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/7/93
Returns:
TRUE if all went OK, False otherwise

Reimplemented from TransOperation.

Definition at line 361 of file tranlate.cpp.

00362 {
00363     return (RegisterOpDescriptor(0, _R(IDS_SELECTOR_MOVE), CC_RUNTIME_CLASS(OpTranslateTrans),
00364                                 OPTOKEN_TRANSLATE, TransOperation::GetState)); 
00365 }

void OpTranslateTrans::InitTransformImmediate OpParam pOpParam  )  [private, virtual]
 

Sets up the transform ready for an immediate translation. This is called from DoWithParam().

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/7/94
Parameters:
pOpParam - The parameters that were passed into the operation [INPUTS]
See also:
TransOperation::DoWithParam()

Reimplemented from TransOperation.

Definition at line 158 of file tranlate.cpp.

00159 {
00160     // Set the initial position
00161     StartPos = DocCoord(0,0);
00162     RawStartPos = StartPos;
00163     MagStartPos = StartPos;
00164 
00165     // and copy the offset to translate by from Param2
00166     DocCoord* Offset = (DocCoord*)( PVOID(pOpParam->Param2) );
00167     LastPos.x = Offset->x;
00168     LastPos.y = Offset->y;
00169 
00170     OriginalGridOffset.x=0;
00171     OriginalGridOffset.y=0;
00172 }

void OpTranslateTrans::InitTransformOnDrag DocCoord  PointerPos,
ClickModifiers  ClickMods
[private, virtual]
 

Sets up the parameters needed to build the transform matrix at the start of the drag. This base class version of this function does nothing.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/94
Parameters:
PointerPos - The position of the mouse at the start of the drag [INPUTS] ClickMods - the keyboard modifiers that were active at the start of the drag

Reimplemented from TransOperation.

Definition at line 188 of file tranlate.cpp.

00189 {
00190     // make a note of the current mouse position
00191     LastPos = PointerPos;
00192 
00193     // Record the offset from the mouse pos to the grid
00194     OriginalGridOffset = GetStartPos();
00195     DocView::ForceSnapToGrid(StartSpread, &OriginalGridOffset);
00196     OriginalGridOffset = GetStartPos() - OriginalGridOffset;
00197 }

BOOL OpTranslateTrans::ShouldPointerBeOffset  )  [virtual]
 

Tells the base class of the operation that we want our mouse coords to be left alone.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/9/94
Returns:
FALSE

Reimplemented from TransOperation.

Definition at line 321 of file tranlate.cpp.

00322 {
00323     return FALSE;
00324 }

void OpTranslateTrans::UpdateTransformOnDrag DocCoord  PointerPos,
Spread pSpread,
ClickModifiers ClickMods
[private, virtual]
 

Does the calculations needed when the mouse moves to keep all the params needed to build the rotation matrix up to date.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/94
Parameters:
PointerPos - The latest position of the mouse [INPUTS]

Reimplemented from TransOperation.

Definition at line 215 of file tranlate.cpp.

00216 {
00217     if (!ClickMods.Constrain)
00218     {
00219         // Apply snapping to the pointer pos
00220         // First apply magnetic snapping alone
00221         if (MagneticGripPoint && DocView::SnapSelected(pSpread, &PointerPos, TRUE, FALSE))
00222         {
00223             // Magnetic snapping worked!
00224         }
00225         else
00226         {
00227             // Magnetic snapping failed!
00228             // If magnetic snapping failed then try grid snapping
00229             // on the adjusted coordinate
00230             if (ClickMods.Alternative1)
00231             {
00232                 PointerPos = PointerPos - OriginalGridOffset;
00233                 DocView::SnapSelected(pSpread, &PointerPos, FALSE, TRUE);
00234                 PointerPos = PointerPos + OriginalGridOffset;
00235             }
00236             else
00237             {
00238                 DocCoord Offset = PointerPos - LastPos;
00239                 DocRect Bounds( BoundingData.x, BoundingData.y,
00240                                 BoundingData.x+BoundingData.Width, BoundingData.y+BoundingData.Height
00241                                );
00242                 Bounds.lo = Bounds.lo + Offset;
00243                 Bounds.hi = Bounds.hi + Offset;
00244                 DocRect SnappedBounds = Bounds;
00245                 DocView::SnapSelected(pSpread,&SnappedBounds,LastRawPos,RawPos);
00246                 PointerPos = PointerPos + (SnappedBounds.lo - Bounds.lo);
00247             }
00248         }
00249     }
00250 
00251     // Work out the offset from the last mouse pos
00252     INT32 dx = PointerPos.x - LastPos.x;
00253     INT32 dy = PointerPos.y - LastPos.y;
00254 
00255     // Add the offset into the structure
00256     BoundingData.x += dx;
00257     BoundingData.y += dy;
00258     BoundingData.XYChanged = TRUE;
00259 
00260     // Make a mental note of the current position
00261     LastPos = PointerPos;
00262 
00263     // Update the current spread (must do this if CanChangeSpread returns TRUE)
00264     CurrentSpread = pSpread;
00265 }


Member Data Documentation

DocCoord OpTranslateTrans::LastPos [private]
 

Definition at line 148 of file tranlate.h.

DocCoord OpTranslateTrans::OriginalGridOffset [private]
 

Definition at line 149 of file tranlate.h.


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