#include <opscale.h>
Inheritance diagram for OpScaleTrans:
Public Member Functions | |
OpScaleTrans () | |
Constructor. Does nothing. | |
virtual FIXED16 | GetScalar () |
Returns the Transforms idea of the equivalent scale factor for the transform. This is mainly used to help with the scaling of line widths to save them trying to extract the scale factor from the matrix. | |
Static Public Member Functions | |
static BOOL | Declare () |
Adds the operation to the list of all known operations. | |
Protected Member Functions | |
virtual void | InitTransformImmediate (OpParam *) |
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. | |
virtual void | SetStartBlob (INT32 ThisStartBlob) |
Allows the operations to know how it was started. Some operation do different things depending on if they are going vertically or horizontally and this will allow you to figure that out. Overide this function if you need to deal with this situation (ie the Shear operation). The base class version does nothing. This function is called from the DragStarted() function. | |
Private Member Functions | |
CC_DECLARE_DYNCREATE (OpScaleTrans) | |
Private Attributes | |
FIXED16 | XScaleFactor |
FIXED16 | YScaleFactor |
INT32 | UnitWidth |
INT32 | UnitHeight |
DocCoord | PointerStart |
DocCoord | BoundsStartPoint |
INT32 | StartBlob |
Definition at line 120 of file opscale.h.
|
Constructor. Does nothing.
Definition at line 137 of file opscale.cpp. 00137 : TransOperation() 00138 { 00139 StatusHelpID = _R(IDS_SCALETRANS_STATUS1); 00140 StatusHelpID2 = _R(IDS_SCALETRANS_STATUS2); 00141 }
|
|
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 366 of file opscale.cpp. 00367 { 00368 // Build a matrix to scale by the correct amount and one to translate back from the origin 00369 Matrix ScaleBy(XScaleFactor, YScaleFactor); 00370 Matrix TransFromOrigin(CentreOfTrans.x, CentreOfTrans.y); 00371 00372 // First translate the centre of scaling to the origin, then scale, then translate back 00373 Transform = Matrix(-CentreOfTrans.x, -CentreOfTrans.y); 00374 Transform *= ScaleBy; 00375 Transform *= TransFromOrigin; 00376 }
|
|
|
|
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 395 of file opscale.cpp. 00396 { 00397 // Constrain the mouse movement to hoizontal, vertical or diagonal 00398 DocView::ConstrainToAngle(CentreOfTrans, PointerPos); 00399 }
|
|
Adds the operation to the list of all known operations.
Reimplemented from TransOperation. Definition at line 413 of file opscale.cpp. 00414 { 00415 return (RegisterOpDescriptor(0, _R(IDS_SCALETRANS), CC_RUNTIME_CLASS(OpScaleTrans), 00416 OPTOKEN_SCALE, TransOperation::GetState)); 00417 }
|
|
Returns the Transforms idea of the equivalent scale factor for the transform. This is mainly used to help with the scaling of line widths to save them trying to extract the scale factor from the matrix.
Definition at line 461 of file opscale.cpp. 00462 { 00463 // Just return the current value of the scale factor 00464 return YScaleFactor; 00465 }
|
|
Reimplemented from TransOperation. Definition at line 162 of file opscale.cpp. 00163 { 00164 00165 FIXED16* pfx = (FIXED16*) PVOID(pParam->Param2); 00166 XScaleFactor = *pfx; 00167 YScaleFactor = *(pfx + 1); 00168 00169 00170 if (XScaleFactor == 0) 00171 XScaleFactor = 1.0; 00172 00173 if (YScaleFactor == 0) 00174 YScaleFactor = 1.0; 00175 00176 }
|
|
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 196 of file opscale.cpp. 00197 { 00198 // WEBSTER - markn 14/2/97 00199 // Rewritten so it will work when "snap to the grid" is on 00200 00201 // Note the pointer pos at the beginning of the drag 00202 PointerStart.x = PointerPos.x; 00203 PointerStart.y = PointerPos.y; 00204 00205 // Note the width & height of the original bounds - used to calc scale factors 00206 UnitWidth = BoundingData.Width; 00207 UnitHeight = BoundingData.Height; 00208 00209 // Work out which x point of the bounds to take, based on the blob that was clicked on 00210 switch (StartBlob) 00211 { 00212 case 3: 00213 case 8: BoundsStartPoint.x = BoundingData.x + BoundingData.Width; 00214 break; 00215 case 1: 00216 case 6: BoundsStartPoint.x = BoundingData.x; 00217 UnitWidth = -UnitWidth; // if low x, then we need -ve x scale factors 00218 break; 00219 00220 default: ERROR3("Unrecognised blob values"); break; 00221 } 00222 00223 // Work out which x point of the bounds to take, based on the blob that was clicked on 00224 switch (StartBlob) 00225 { 00226 case 1: 00227 case 3: BoundsStartPoint.y = BoundingData.y + BoundingData.Height; 00228 break; 00229 case 6: 00230 case 8: BoundsStartPoint.y = BoundingData.y; 00231 UnitHeight = -UnitHeight; // if low y, then we need -ve y scale factors 00232 break; 00233 00234 default: ERROR3("Unrecognised blob values"); break; 00235 } 00236 00237 // Make sure that they are not zero 00238 if (UnitWidth==0) UnitWidth = 1; 00239 if (UnitHeight==0) UnitHeight = 1; 00240 00241 // Set the scale factors to 1 (ie no scale) 00242 XScaleFactor = FIXED16(1); 00243 YScaleFactor = FIXED16(1); 00244 }
|
|
Allows the operations to know how it was started. Some operation do different things depending on if they are going vertically or horizontally and this will allow you to figure that out. Overide this function if you need to deal with this situation (ie the Shear operation). The base class version does nothing. This function is called from the DragStarted() function.
Reimplemented from TransOperation. Definition at line 145 of file opscale.h. 00145 { StartBlob = ThisStartBlob; }
|
|
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 432 of file opscale.cpp. 00433 { 00434 #ifndef STANDALONE 00435 if (pSelTool != NULL) 00436 { 00437 00438 ComputeNewBounds(); 00439 // Tell the tool about the current transform bounding data 00440 pSelTool->DragMove(&BoundingData); 00441 } 00442 #endif 00443 }
|
|
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 263 of file opscale.cpp. 00264 { 00265 // Make sure that the cursor does not wrap around at the edge of spreads 00266 if (pClickSpread != StartSpread) 00267 PointerPos = MakeRelativeToSpread(StartSpread, pClickSpread, PointerPos); 00268 00269 // Snap the pointer position 00270 if (!ClickMods.Constrain) 00271 DocView::SnapSelected(pClickSpread, &PointerPos, FALSE, TRUE); 00272 00273 // If the Adjust key is down then we should adjust the Unit sizes to compensate 00274 // for the moving centre of transform 00275 INT32 WorkingHeight = UnitHeight; 00276 INT32 WorkingWidth = UnitWidth; 00277 00278 // if Adjust is being used, adjust the height and width so that scaling still works 00279 if (ClickMods.Adjust) 00280 { 00281 WorkingHeight /= 2; 00282 WorkingWidth /= 2; 00283 } 00284 00285 // WEBSTER - markn 14/2/97 00286 // Rewritten so it will work when "snap to the grid" is on 00287 00288 // Work out how far the pointer has moved compared with the initial pointer pos 00289 INT32 pdx = PointerPos.x - PointerStart.x; 00290 INT32 pdy = PointerPos.y - PointerStart.y; 00291 00292 // Move the bounds point by the distance the mouse pointer has moved and 00293 // calc the snapped version of the new bounds pos 00294 DocCoord SnappedBoundsPoint(BoundsStartPoint.x + pdx,BoundsStartPoint.y + pdy); 00295 00296 if (!ClickMods.Constrain) 00297 DocView::SnapSelected(StartSpread, &SnappedBoundsPoint, FALSE, TRUE); 00298 00299 // Calc the proportion the bounds have changed compared with the original working dimensions 00300 INT32 dx = (SnappedBoundsPoint.x - BoundsStartPoint.x) + WorkingWidth; 00301 INT32 dy = (SnappedBoundsPoint.y - BoundsStartPoint.y) + WorkingHeight; 00302 00303 // Calc the scale factors as a fraction of the change between the origin & scaled dimensions 00304 XScaleFactor = FIXED16(double(dx) / double(WorkingWidth)); 00305 YScaleFactor = FIXED16(double(dy) / double(WorkingHeight)); 00306 00307 // Deal with the aspect ratio being locked 00308 if (LockAspect) 00309 { 00310 // If the aspect ratio is locked, X and Y should be the same. 00311 // Always take the greatest scale factor. 00312 // But be careful to retain the sign of the scale factors - only make their 00313 // magnitudes equal! (Sorry about the yucky implementation of this!) 00314 if (YScaleFactor > XScaleFactor) 00315 { 00316 FIXED16 AbsY = (YScaleFactor < 0 ? -YScaleFactor : YScaleFactor); 00317 XScaleFactor = (XScaleFactor < 0 ? -AbsY : AbsY); 00318 } 00319 else 00320 { 00321 FIXED16 AbsX = (XScaleFactor < 0 ? -XScaleFactor : XScaleFactor); 00322 YScaleFactor = (YScaleFactor < 0 ? -AbsX : AbsX); 00323 } 00324 } 00325 00326 // Deal with constrain. 00327 // Constrain scale factors to be whole numbers. 00328 // This has to be done here instead of overriding the ConstrainDrag function. 00329 if (ClickMods.Constrain) 00330 { 00331 // Constrained squash forces scale to whole number multiple of original size... 00332 FIXED16 Sign; 00333 00334 Sign = (XScaleFactor<0 ? -1 : 1); // Compute sign of pure scale 00335 XScaleFactor+=FIXED16((double)0.5); // Round scale to nearest integer 00336 XScaleFactor = XScaleFactor.MakeShort(); 00337 if (XScaleFactor==0) XScaleFactor = Sign; // Prevent scale from being zero by setting 00338 // it to +/- 1 depending on sign of pure scale. 00339 Sign = (YScaleFactor<0 ? -1 : 1); 00340 YScaleFactor+=FIXED16((double)0.5); 00341 YScaleFactor = YScaleFactor.MakeShort(); 00342 if (YScaleFactor==0) YScaleFactor = Sign; 00343 } 00344 00345 // Update information for the user... 00346 // Must update x,y,w,h,scale and possible angle. 00347 BoundingData.XScale = XScaleFactor; 00348 BoundingData.YScale = YScaleFactor; 00349 BoundingData.ScaleChanged = TRUE; 00350 // See also UpdateTransformBoundingData function in this file... 00351 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|