OpShearTrans Class Reference

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

#include <opshear.h>

Inheritance diagram for OpShearTrans:

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

Public Member Functions

 OpShearTrans ()
 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 (OpShearTrans)
virtual void InitTransformImmediate (OpParam *pParam)
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 &ClickMods)
 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 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 ConstrainDrag (DocCoord *)
 Constrains the drag by the constrain angle. If the angle becomes too shallow (eg 90 degrees) the constrain will stop constraining and let it move freely.

Private Attributes

INT32 SelWidth
INT32 SelHeight
BOOL IsHorizontal
BOOL IsNegative
FIXED16 ShearBy
DocCoord LastPos

Detailed Description

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

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

Definition at line 118 of file opshear.h.


Constructor & Destructor Documentation

OpShearTrans::OpShearTrans  ) 
 

Constructor. Does nothing.

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

Definition at line 137 of file opshear.cpp.

00137                           : TransOperation()
00138 {
00139     // Reset all the infomation about things
00140     SelWidth = SelHeight = 0;
00141 
00142     // Default to horizontal
00143     IsHorizontal = TRUE;
00144 
00145     // Start off with no shearing at all
00146     ShearBy = FIXED16(0);
00147 
00148     // Set status help text
00149     StatusHelpID = _R(IDS_SHEARTRANS_STATUS1);
00150     StatusHelpID2=_R(IDS_SHEARTRANS_STATUS2);
00151 }


Member Function Documentation

void OpShearTrans::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 392 of file opshear.cpp.

00393 {
00394     // Translate to the origin
00395     Transform = Matrix(-CentreOfTrans.x, -CentreOfTrans.y);
00396 
00397     // We will need a matrix to put the shear in
00398     Matrix Shear;
00399 
00400     // Work out how much to shear the selection by
00401     if (IsHorizontal)
00402     {
00403         // Build the shear matrix for a horizontal shear
00404         Shear = Matrix(FIXED16(1), FIXED16(0), FIXED16(ShearBy), FIXED16(1), 0, 0);
00405     }
00406     else
00407     {
00408         // Build the shear matrix for a vertical shear
00409         Shear = Matrix(FIXED16(1), FIXED16(ShearBy), FIXED16(0), FIXED16(1), 0, 0);
00410     }
00411 
00412     // Apply the shear
00413     Transform *= Shear;
00414 
00415     // Translate back again
00416     Transform *= Matrix(CentreOfTrans.x, CentreOfTrans.y);
00417 }

OpShearTrans::CC_DECLARE_DYNCREATE OpShearTrans   )  [private]
 

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

Constrains the drag by the constrain angle. If the angle becomes too shallow (eg 90 degrees) the constrain will stop constraining and let it move freely.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/94
Parameters:
PointerPos - Adjusts the mouse position so that it is constrained [OUTPUTS]

Reimplemented from TransOperation.

Definition at line 333 of file opshear.cpp.

00334 {
00335     // Make a copy of the coord in case we want to put it back
00336     DocCoord WorkingCopy = *PointerPos;
00337     BOOL UseWorkingCopy = FALSE;
00338 
00339     // Snap the pointer coord so that it runs along one of the rays
00340     DocView::ConstrainToAngle(CentreOfTrans, &WorkingCopy);
00341 
00342     // find out the x & y distance from the centre
00343     INT32 dx = WorkingCopy.x - CentreOfTrans.x;
00344     INT32 dy = WorkingCopy.y - CentreOfTrans.y;
00345 
00346     if (IsHorizontal)
00347     {
00348         if (dy!=0)
00349         {
00350             // This is a horizontal drag, so make sure that the pointer pos
00351             // lies on the horizon line level with the starting position
00352             // We need 64 bit numbers in the middle of the calculation so
00353             // use something that does it for us.
00354             dx = Mul32Div32(dx, StartPos.y-CentreOfTrans.y, dy);
00355 
00356             // only need to change the x component as that is all that is used
00357             WorkingCopy.x = CentreOfTrans.x + dx;
00358             WorkingCopy.y = StartPos.y;
00359             UseWorkingCopy = TRUE;
00360         }
00361     }
00362     else
00363     {
00364         if (dx!=0)
00365         {
00366             // Same but in the other axis
00367             dy = Mul32Div32(dy, StartPos.x-CentreOfTrans.x, dx) ;
00368 
00369             // Only change the y component this time
00370             WorkingCopy.y = CentreOfTrans.y + dy;
00371             WorkingCopy.x = StartPos.x;
00372             UseWorkingCopy = TRUE;
00373         }
00374     }
00375 
00376     // See if the constrain was valid
00377     if (UseWorkingCopy)
00378         *PointerPos = WorkingCopy;
00379 }

BOOL OpShearTrans::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 433 of file opshear.cpp.

00434 {
00435     return (RegisterOpDescriptor(
00436                                 0, 
00437                                 _R(IDS_SHEARTRANS),
00438                                 CC_RUNTIME_CLASS(OpShearTrans),
00439                                 OPTOKEN_SHEAR,
00440                                 TransOperation::GetState)); 
00441 }

void OpShearTrans::InitTransformImmediate OpParam pParam  )  [private, virtual]
 

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/11/94
Parameters:
pParam --- pointer an OpParam whose Param2 member is a pointer [INPUTS] to a FIXED16 that represents the angle in degrees to shear by.
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from TransOperation.

Definition at line 207 of file opshear.cpp.

00208 {
00209     FIXED16 pDegreesShearAngle = *((FIXED16*)PVOID(pParam->Param2));
00210     double ShearAngle = pDegreesShearAngle.MakeDouble();
00211 
00212     if (ShearAngle < -89.0)                     // Clip the shear angle to a sensible range
00213         ShearAngle = -89.0;
00214 
00215     if (ShearAngle > 89.0)
00216         ShearAngle = 89.0;
00217 
00218     ShearAngle = (ShearAngle*2*PI)/360.0;       // Convert to Radians
00219     ShearBy = (FIXED16)(tan(ShearAngle));       // And get the Shear distance to bung in the matrix
00220 }

void OpShearTrans::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 238 of file opshear.cpp.

00239 {
00240     // Make a note of the latest position of the mouse
00241     LastPos = PointerPos;
00242 
00243     // At the start of the drag the Shear factor will always by none
00244     ShearBy = FIXED16(0);
00245 
00246     // Find out how big the selection is
00247 //  SelRange* Selection = GetApplication()->FindSelection();
00248 //  DocRect SelRect = Selection->GetBoundingRect();
00249 
00250     // Find the width and the height of the selection
00251 //  SelWidth = SelRect.Width();
00252 //  SelHeight = SelRect.Height();
00253 
00254     // Use the Width and Height of the object AS PASSED IN from the caller
00255     // (If we just use the width/height of the selection, we may get it all horribly wrong, as
00256     // they may want to scale with or without including the effects of attributes, which
00257     // can significantly affect the size of the bounding rectangle to be used)
00258     SelWidth  = BoundingData.Width;
00259     SelHeight = BoundingData.Height;
00260 }

void OpShearTrans::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 174 of file opshear.cpp.

00175 {
00176     // Only blobs 2, 7, 4 and 5 are relavant. All others are a problem
00177     ENSURE( (StartBlob==2) || (StartBlob==4) || (StartBlob==5) || (StartBlob==7),
00178             "Shear started a blob that it should not have done");
00179 
00180     // blobs 2 and 7 are the Middle Top and Middle Bottom blobs
00181     // and would suggest horizontal shearing
00182     if ((StartBlob==2) || (StartBlob==7))
00183         IsHorizontal = TRUE;
00184     else
00185         IsHorizontal = FALSE;
00186 
00187 }

void OpShearTrans::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 mouse is over - not used Clickmodifiers in place - not used

Reimplemented from TransOperation.

Definition at line 279 of file opshear.cpp.

00280 {
00281     // Make sure that the cursor does not wrap around at the edge of spreads
00282     if (pClickSpread != StartSpread)
00283         PointerPos = MakeRelativeToSpread(StartSpread, pClickSpread, PointerPos);
00284 
00285     if (!ClickMods.Constrain)
00286         DocView::SnapSelected(pClickSpread, &PointerPos, FALSE, TRUE);
00287 
00288     // Make a note of the latest position of the mouse
00289     LastPos = PointerPos;
00290 
00291     double dx = PointerPos.x - CentreOfTrans.x;
00292     double dy = PointerPos.y - CentreOfTrans.y;
00293 
00294     // Work out the shear factor and angle
00295     double ShearAngle;
00296     if (IsHorizontal)
00297     {
00298         // Work out the horizontal shearing
00299         dy = StartPos.y - CentreOfTrans.y;
00300         ShearBy = FIXED16( dx / dy);
00301         ShearAngle = atan2(dx, dy);
00302     }
00303     else
00304     {
00305         // Work out the vertical shearing
00306         dx = StartPos.x - CentreOfTrans.x;
00307         ShearBy = FIXED16( dy / dx);
00308         ShearAngle = atan2(dy, dx);
00309     }
00310 
00311     // Update the boundingdata infomation about the constrain
00312     ShearAngle = (ShearAngle / (2.0*PI)) * 360.0;
00313     BoundingData.Shear = (ANGLE) ShearAngle;
00314     BoundingData.ShearChanged = TRUE;
00315 }


Member Data Documentation

BOOL OpShearTrans::IsHorizontal [private]
 

Definition at line 145 of file opshear.h.

BOOL OpShearTrans::IsNegative [private]
 

Definition at line 148 of file opshear.h.

DocCoord OpShearTrans::LastPos [private]
 

Definition at line 154 of file opshear.h.

INT32 OpShearTrans::SelHeight [private]
 

Definition at line 142 of file opshear.h.

INT32 OpShearTrans::SelWidth [private]
 

Definition at line 141 of file opshear.h.

FIXED16 OpShearTrans::ShearBy [private]
 

Definition at line 151 of file opshear.h.


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