#include <oprotate.h>
Inheritance diagram for OpRotateTrans:
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 |
Definition at line 118 of file oprotate.h.
|
Constructor. Does nothing.
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 }
|
|
Finds the angle from the centre of rotation that the coord is.
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 }
|
|
Builds the transform matrix required to rotate the selection about the point CentreOfRot by the required number of degrees.
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 }
|
|
|
|
Will constrain the mouse position to lie along rays from the centre of rotation at the constrain angle apart (45 degrees by default).
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 }
|
|
Adds the operation to the list of all known operations.
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 }
|
|
Sets up the transform ready for an immediate rotation. This is called from 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 }
|
|
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.
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 }
|
|
Tells the base class of the operation that we want our mouse coords to be left alone.
Reimplemented from TransOperation. Definition at line 223 of file oprotate.cpp. 00224 { 00225 return FALSE; 00226 }
|
|
Override the base class version of this fn to ensure that new bounds are calculated and placed in the BoundingData structure.
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 }
|
|
Does the calculations needed when the mouse moves to keep all the params needed to build the rotation matrix up to date.
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 }
|
|
Definition at line 147 of file oprotate.h. |
|
Definition at line 148 of file oprotate.h. |
|
Definition at line 151 of file oprotate.h. |
|
Definition at line 146 of file oprotate.h. |