OpSquashTrans Class Reference

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

#include <opsquash.h>

Inheritance diagram for OpSquashTrans:

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

Public Member Functions

 OpSquashTrans ()
 Constructor. Does nothing.

Static Public Member Functions

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

Private Types

enum  SquashFlags { SQUASH_UP, SQUASH_LEFT, SQUASH_RIGHT, SQUASH_DOWN }

Private Member Functions

 CC_DECLARE_DYNCREATE (OpSquashTrans)
virtual void InitTransformImmediate (OpParam *)
 Sets up the transform ready for an immediate rotation. 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. Note by Phil: This algorithm needs four cases because the scale factors involved must be positive whether dragging the left or right handle. It should only go negative when the pointer crosses a line through the transform origin.
virtual void BuildMatrix ()
 Builds the transform matrix required to Shear the selection about the point CentreOfRot.
virtual void SetStartBlob (INT32 StartBlob)
 Allows the operations to know how it was started. This operation is interested in the horizontal / vertical nature of the transform.
virtual void UpdateTransformBoundingData ()
 Override the base class version of this fn to ensure that new bounds are calculated and placed in the BoundingData structure.

Private Attributes

INT32 SelWidth
INT32 SelHeight
enum OpSquashTrans::SquashFlags SquashType
FIXED16 XScale
FIXED16 YScale
DocCoord LastPos

Detailed Description

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

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

Definition at line 118 of file opsquash.h.


Member Enumeration Documentation

enum OpSquashTrans::SquashFlags [private]
 

Enumerator:
SQUASH_UP 
SQUASH_LEFT 
SQUASH_RIGHT 
SQUASH_DOWN 

Definition at line 147 of file opsquash.h.


Constructor & Destructor Documentation

OpSquashTrans::OpSquashTrans  ) 
 

Constructor. Does nothing.

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

Definition at line 136 of file opsquash.cpp.

00136                             : TransOperation()
00137 {
00138     // Reset all the infomation about things
00139     SelWidth = SelHeight = 0;
00140 
00141     // Default to horizontal
00142     SquashType = SQUASH_RIGHT;
00143 
00144     // Set the default scale factors
00145     XScale =  YScale = FIXED16(1.0);
00146 
00147     // Set status help
00148     StatusHelpID = _R(IDS_SQUASHTRANS_STATUS1);
00149     StatusHelpID2 = _R(IDS_SQUASHTRANS_STATUS2);
00150 }


Member Function Documentation

void OpSquashTrans::BuildMatrix  )  [private, virtual]
 

Builds the transform matrix required to Shear the selection about the point CentreOfRot.

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

Reimplemented from TransOperation.

Definition at line 386 of file opsquash.cpp.

00387 {
00388     // Translate to the origin
00389     Transform = Matrix(-CentreOfTrans.x, -CentreOfTrans.y);
00390 
00391     // We will need a matrix to put the Scale in
00392     Matrix Squash(XScale, YScale);
00393 
00394     // translate back again
00395     Matrix TransFromOrigin(CentreOfTrans.x, CentreOfTrans.y);
00396 
00397     // Combine the 3 of them into a single matrix
00398     Transform *= Squash;
00399     Transform *= TransFromOrigin;
00400 }

OpSquashTrans::CC_DECLARE_DYNCREATE OpSquashTrans   )  [private]
 

BOOL OpSquashTrans::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 416 of file opsquash.cpp.

00417 {
00418     return (RegisterOpDescriptor(
00419                                 0, 
00420                                 _R(IDS_SQUASHTRANS),
00421                                 CC_RUNTIME_CLASS(OpSquashTrans),
00422                                 OPTOKEN_SQUASH,
00423                                 TransOperation::GetState)); 
00424 }

void OpSquashTrans::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 166 of file opsquash.cpp.

00167 {
00168     // Depending on the which way we are scaling this object
00169     switch (SquashType)
00170     {
00171         case SQUASH_UP :
00172         case SQUASH_DOWN :
00173         {
00174             // Stretch it vertically
00175             XScale = FIXED16(1.0);
00176             YScale = *((FIXED16*)PVOID(pOpParam->Param2));
00177             break;
00178         }
00179 
00180         case SQUASH_LEFT :
00181         case SQUASH_RIGHT :
00182         {
00183             // Stretch it horizintally
00184             XScale = *((FIXED16*)PVOID(pOpParam->Param2));
00185             YScale = FIXED16(1.0);
00186             break;
00187         }
00188     }
00189 }

void OpSquashTrans::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 255 of file opsquash.cpp.

00256 {
00257     // Make a note of the latest position of the mouse
00258     LastPos = PointerPos;
00259 
00260     // At the start of the drag the Squash factor will always by none
00261     XScale = FIXED16(1);
00262     YScale = FIXED16(1);
00263 
00264     // Use the Width and Height of the object AS PASSED IN from the caller
00265     // (If we just use the width/height of the selection, we may get it all horribly wrong, as
00266     // they may want to scale with or without including the effects of attributes, which
00267     // can significantly affect the size of the bounding rectangle to be used)
00268     SelWidth  = BoundingData.Width;
00269     SelHeight = BoundingData.Height;
00270 }

void OpSquashTrans::SetStartBlob INT32  StartBlob  )  [private, virtual]
 

Allows the operations to know how it was started. This operation is interested in the horizontal / vertical nature of the transform.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/7/94
Parameters:
StartBlob - the Number of the blob that the operation was initiated on, [INPUTS] if applicabale. They are numbered as follows :- MonoOn 1 2 3 4 5 6 7 8 MonoOff All operations that were not started from one of the 8 blobs should use 0

Reimplemented from TransOperation.

Definition at line 213 of file opsquash.cpp.

00214 {
00215     switch (StartBlob)
00216     {
00217         case 2:
00218             SquashType = SQUASH_UP;
00219             break;
00220 
00221         case 4:
00222             SquashType = SQUASH_LEFT;
00223             break;
00224 
00225         case 5:
00226             SquashType = SQUASH_RIGHT;
00227             break;
00228 
00229         case 7:
00230             SquashType = SQUASH_DOWN;
00231             break;
00232 
00233         default:
00234             ERROR3("OpSquashTrans started from a blob that it should not have done");
00235             break;
00236     }
00237 }

void OpSquashTrans::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 439 of file opsquash.cpp.

00440 {
00441 #ifndef STANDALONE
00442     if (pSelTool != NULL)
00443     {
00444         ComputeNewBounds();
00445 
00446         // Tell the tool about the current transform bounding data
00447         pSelTool->DragMove(&BoundingData);
00448     }
00449 #endif
00450 }

void OpSquashTrans::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. Note by Phil: This algorithm needs four cases because the scale factors involved must be positive whether dragging the left or right handle. It should only go negative when the pointer crosses a line through the transform origin.

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

Reimplemented from TransOperation.

Definition at line 292 of file opsquash.cpp.

00293 {
00294     // Make sure that the cursor does not wrap around at the edge of spreads
00295     if (pClickSpread != StartSpread)
00296         PointerPos = MakeRelativeToSpread(StartSpread, pClickSpread, PointerPos);
00297 
00298     // Apply snapping to the pointer pos
00299     if (!ClickMods.Constrain)
00300         DocView::SnapSelected(pClickSpread, &PointerPos, FALSE, TRUE);
00301 
00302     // Make a note of the latest position of the mouse
00303     LastPos = PointerPos;
00304     INT32 Offset;
00305 
00306     // copy the height anf width params so that we can party on them
00307     INT32 WorkingHeight = SelHeight;
00308     INT32 WorkingWidth = SelWidth;
00309 
00310     // if Adjust is being used, adjust the height and width so that scaling still works
00311     if (ClickMods.Adjust)
00312     {
00313         WorkingHeight /= 2;
00314         WorkingWidth /= 2;
00315     }
00316 
00317     // Avoid fp div zero bugs.
00318     if (WorkingHeight == 0)
00319         WorkingHeight = 1;
00320     if (WorkingWidth == 0)
00321         WorkingWidth = 1;
00322 
00323     // Work out the shear factor
00324     switch (SquashType)
00325     {
00326         case SQUASH_UP:
00327             Offset = LastPos.y - CentreOfTrans.y;
00328             YScale = FIXED16( (double)Offset / (double)WorkingHeight);
00329         break;
00330 
00331         case SQUASH_LEFT:
00332             Offset = CentreOfTrans.x - LastPos.x;
00333             XScale = FIXED16( (double)Offset / (double)WorkingWidth);
00334         break;
00335 
00336         case SQUASH_RIGHT:
00337             Offset = LastPos.x - CentreOfTrans.x;
00338             XScale = FIXED16( (double)Offset / (double)WorkingWidth);
00339         break;
00340 
00341         case SQUASH_DOWN:
00342             Offset = CentreOfTrans.y - LastPos.y;
00343             YScale = FIXED16( (double)Offset / (double)WorkingHeight);
00344         break;
00345 
00346     }
00347 
00348     // Deal with Constrain...
00349     // This has to be done in here and not in the ConstrainDrag function because it has to
00350     // modify the scale factors computed by the switch statement above.
00351     if (ClickMods.Constrain)
00352     {
00353         // Constrained squash forces scale to whole number multiple of original size...
00354         FIXED16 Sign;
00355 
00356         Sign = (XScale<0 ? -1 : 1);                 // Compute sign of pure scale
00357         XScale+=FIXED16((double)0.5);               // Round scale to nearest integer
00358         XScale = XScale.MakeShort();
00359         if (XScale==0) XScale = Sign;               // Prevent scale from being zero by setting
00360                                                     // it to +/- 1 depending on sign of pure scale.
00361         Sign = (YScale<0 ? -1 : 1);
00362         YScale+=FIXED16((double)0.5);
00363         YScale = YScale.MakeShort();
00364         if (YScale==0) YScale = Sign;
00365     }
00366 
00367     BoundingData.XScale = XScale;
00368     BoundingData.YScale = YScale;
00369     BoundingData.ScaleChanged = TRUE;
00370     // See also, UpdateTransformBoundingData below!
00371 }


Member Data Documentation

DocCoord OpSquashTrans::LastPos [private]
 

Definition at line 154 of file opsquash.h.

INT32 OpSquashTrans::SelHeight [private]
 

Definition at line 144 of file opsquash.h.

INT32 OpSquashTrans::SelWidth [private]
 

Definition at line 143 of file opsquash.h.

enum OpSquashTrans::SquashFlags OpSquashTrans::SquashType [private]
 

FIXED16 OpSquashTrans::XScale [private]
 

Definition at line 150 of file opsquash.h.

FIXED16 OpSquashTrans::YScale [private]
 

Definition at line 151 of file opsquash.h.


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