OpRotateTrans Class Reference

The operation that performs the interactive EORed dragging during a rotation. More...

#include <oprotate.h>

Inheritance diagram for OpRotateTrans:

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

Public Member Functions

 OpRotateTrans ()
 Constructor. Does nothing.

Static Public Member Functions

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

Private Member Functions

 CC_DECLARE_DYNCREATE (OpRotateTrans)
virtual void InitTransformImmediate (OpParam *)
 Sets up the transform ready for an immediate rotation. This is called from DoWithParam().
virtual BOOL ShouldPointerBeOffset ()
 Tells the base class of the operation that we want our mouse coords to be left alone.
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 void UpdateTransformBoundingData ()
 Override the base class version of this fn to ensure that new bounds are calculated and placed in the BoundingData structure.
ANGLE AngleFromCoord (DocCoord)
 Finds the angle from the centre of rotation that the coord is.

Private Attributes

ANGLE StartAngle
ANGLE ConstrainedStartAngle
ANGLE CurrentAngle
BOOL IsConstrained

Detailed Description

The operation that performs the interactive EORed dragging during a rotation.

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

Definition at line 118 of file oprotate.h.


Constructor & Destructor Documentation

OpRotateTrans::OpRotateTrans  ) 
 

Constructor. Does nothing.

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

Definition at line 137 of file oprotate.cpp.

00137                             : TransOperation()
00138 {
00139     // Set status help text
00140     StatusHelpID = _R(IDS_ROTATETRANS_STATUS1);
00141     StatusHelpID2 = _R(IDS_ROTATETRANS_STATUS2);
00142     CanScaleLines = FALSE;
00143 }


Member Function Documentation

ANGLE OpRotateTrans::AngleFromCoord DocCoord  Pos  )  [private]
 

Finds the angle from the centre of rotation that the coord is.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/01/94
Parameters:
Pos - The coord to find the angle to [INPUTS]
Returns:
the angle to the coord Scope: Private

Definition at line 188 of file oprotate.cpp.

00189 {
00190     // find the difference between the centre of rotation and the point
00191     INT32 dx = Pos.x - CentreOfTrans.x;
00192     INT32 dy = Pos.y - CentreOfTrans.y;
00193 
00194     if ((dx==0) && (dy==0))
00195     {
00196         // Oh no, the mouse is directly over the centre of rotation
00197         return StartAngle;
00198     }
00199 
00200     // go find the angle to the cursor position from the centre of rotation
00201     double Angle = atan2((double)dy, (double)dx);
00202 
00203     // convert it to degrees and return it
00204     Angle = (Angle/(2*PI)) * 360.0;
00205 
00206     return (ANGLE)(Angle);
00207 }

void OpRotateTrans::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 325 of file oprotate.cpp.

00326 {
00327     // Build a matrix to transform the objects at render time by the required offsets
00328     // First off, work out the angle to rotate by
00329     ANGLE  RotateBy;
00330     if (IsConstrained)
00331         RotateBy = CurrentAngle - ConstrainedStartAngle;
00332     else
00333         RotateBy = CurrentAngle - StartAngle;
00334 
00335     // Translate to the origin
00336     Transform = Matrix(-CentreOfTrans.x, -CentreOfTrans.y);
00337 
00338     // Rotate by the angle
00339     Matrix RotateIt(RotateBy);
00340 
00341     // translate back again
00342     Matrix TransFromOrigin(CentreOfTrans.x, CentreOfTrans.y);
00343 
00344     // Combine the 3 of them into a single matrix
00345     Transform *= RotateIt;
00346     Transform *= TransFromOrigin;
00347 }

OpRotateTrans::CC_DECLARE_DYNCREATE OpRotateTrans   )  [private]
 

void OpRotateTrans::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 366 of file oprotate.cpp.

00367 {
00368     // Rotate want to use the constrain to angle variation of the constrain system
00369     DocView::ConstrainToAngle(CentreOfTrans, PointerPos);
00370 }

BOOL OpRotateTrans::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 384 of file oprotate.cpp.

00385 {
00386     return (RegisterOpDescriptor(
00387                                 0, 
00388                                 _R(IDS_ROTATESPIN),
00389                                 CC_RUNTIME_CLASS(OpRotateTrans),
00390                                 OPTOKEN_ROTATE,
00391                                 TransOperation::GetState)); 
00392 }

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

Sets up the transform ready for an immediate rotation. 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 162 of file oprotate.cpp.

00163 {
00164     // Do a rotation right now
00165     StartAngle = (ANGLE)0;
00166     
00167     // Rotate by the number of degrees pointed to by Param2
00168     CurrentAngle = * ((ANGLE*)( PVOID(pOpParam->Param2) ) );
00169     IsConstrained = FALSE;
00170 }

void OpRotateTrans::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 242 of file oprotate.cpp.

00243 {
00244     // Make sure that the angle is correctly set taking into account that the
00245     // start position may be in the same place as the Centre of Rotation (or along
00246     // one of its axis
00247     StartAngle = AngleFromCoord(PointerPos);
00248 
00249     // Work out the constrained start angle as well (just in case we need it)
00250     DocCoord ConstrainedCoord = PointerPos;
00251     DocView::ConstrainToAngle(CentreOfTrans, &ConstrainedCoord);
00252     ConstrainedStartAngle = AngleFromCoord(ConstrainedCoord);
00253 
00254     // Constrain the mouse position if required (45 degrees until we get a better system)
00255     if (ClickMods.Constrain)
00256     {
00257         CurrentAngle = ConstrainedStartAngle;
00258         IsConstrained = TRUE;
00259     }
00260     else
00261     {   
00262         CurrentAngle = StartAngle;
00263         IsConstrained = FALSE;
00264     }
00265 }

BOOL OpRotateTrans::ShouldPointerBeOffset  )  [private, 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 223 of file oprotate.cpp.

00224 {
00225     return FALSE;
00226 }

void OpRotateTrans::UpdateTransformBoundingData  )  [private, virtual]
 

Override the base class version of this fn to ensure that new bounds are calculated and placed in the BoundingData structure.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
04/9/94

Reimplemented from TransOperation.

Definition at line 407 of file oprotate.cpp.

00408 {
00409 #ifndef STANDALONE
00410     ComputeNewBounds();
00411 
00412     // Tell the tool about the current transform bounding data
00413     pSelTool->DragMove(&BoundingData);
00414 #endif
00415 }

void OpRotateTrans::UpdateTransformOnDrag DocCoord  PointerPos,
Spread pClickSpread,
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] Spread - The spread the that mouse is over ClickModifiers - The click modifiers that were in place at this point on the drag

Reimplemented from TransOperation.

Definition at line 286 of file oprotate.cpp.

00288 {
00289     // Make sure that the cursor does not wrap around at the edge of spreads
00290     if (pClickSpread != StartSpread)
00291         PointerPos = MakeRelativeToSpread(StartSpread, pClickSpread, PointerPos);
00292 
00293     // Calc the new angle, based on the new mouse position
00294     CurrentAngle = AngleFromCoord(PointerPos);
00295 
00296     // See if the constrain key is in use
00297     if (ClickMods.Constrain)
00298     {
00299         IsConstrained = TRUE;
00300         BoundingData.Rotation = CurrentAngle - ConstrainedStartAngle;
00301     }
00302     else
00303     {
00304         BoundingData.Rotation = CurrentAngle - StartAngle;
00305         IsConstrained = FALSE;
00306     }
00307 
00308     BoundingData.RotateChanged = TRUE;
00309     // See also UpdateTransformBoundingData function in this file.
00310 }


Member Data Documentation

ANGLE OpRotateTrans::ConstrainedStartAngle [private]
 

Definition at line 147 of file oprotate.h.

ANGLE OpRotateTrans::CurrentAngle [private]
 

Definition at line 148 of file oprotate.h.

BOOL OpRotateTrans::IsConstrained [private]
 

Definition at line 151 of file oprotate.h.

ANGLE OpRotateTrans::StartAngle [private]
 

Definition at line 146 of file oprotate.h.


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