#include <shapeops.h>
Inheritance diagram for OpShapeMakeRegular:
Public Member Functions | |
OpShapeMakeRegular () | |
void | DoMakeRegular (NodeRegularShape *pShape, DocCoord RegularPoint) |
Makes a QuickShape regular, ie 100% aspect ratio, no skew, shear etc... | |
Static Public Member Functions | |
static OpState | GetState (String_256 *, OpDescriptor *) |
Returns the state of this operation. | |
static BOOL | Init () |
Registers this op. | |
Protected Member Functions | |
BOOL | DoActions (NodeRegularShape *pShape, DocCoord RegularPoint) |
Makes a QuickShape regular, ie 100% aspect ratio, no skew, shear etc... |
Definition at line 833 of file shapeops.h.
|
Definition at line 838 of file shapeops.h.
|
|
Makes a QuickShape regular, ie 100% aspect ratio, no skew, shear etc...
Definition at line 4277 of file shapeops.cpp. 04278 { 04279 ERROR2IF(pShape == NULL, FALSE, "Shape pointer was NULL"); 04280 ERROR3IF(!pShape->IsCircular(), "Make regular not implemented for non-circular QuickShapes"); 04281 04282 BOOL ok = DoStartSelOp(FALSE, FALSE); 04283 04284 // Get required variables 04285 DocCoord ShapeCentre = pShape->GetCentrePoint(); 04286 DocCoord UTShapeCentre = pShape->GetUTCentrePoint(); 04287 const double RequiredLength = ShapeCentre.Distance(RegularPoint); 04288 const double MajorLength = pShape->GetUTMajorAxes().Distance(UTShapeCentre); 04289 const double MinorLength = pShape->GetUTMinorAxes().Distance(UTShapeCentre); 04290 const double RequiredAngle = atan2((double)(RegularPoint.y-ShapeCentre.y),(double)(RegularPoint.x-ShapeCentre.x)); 04291 const double MajorAxisAngle = atan2((double)(pShape->GetUTMajorAxes().y-UTShapeCentre.y), 04292 (double)(pShape->GetUTMajorAxes().x-UTShapeCentre.x)); 04293 Matrix ShapeMat; 04294 pShape->GetTransformMatrix(&ShapeMat); 04295 Trans2DMatrix* Translation = new Trans2DMatrix(ShapeMat); 04296 Translation->Invert(); 04297 04298 // Translate shape to origin 04299 if (ok) 04300 *Translation *= Trans2DMatrix(-UTShapeCentre.x, -UTShapeCentre.y); 04301 04302 // Rotate so major axis points along +ve x-axis (not y!) 04303 if (ok) 04304 *Translation *= Trans2DMatrix(Matrix(-ANGLE(MajorAxisAngle*(180/PI)))); 04305 04306 // Scale it so it is regular 04307 if (ok) 04308 *Translation *= Trans2DMatrix(Matrix(FIXED16(RequiredLength/MajorLength), FIXED16(RequiredLength/MinorLength))); 04309 04310 // Rotate so major axis is under click point 04311 if (ok) 04312 *Translation *= Trans2DMatrix(Matrix(ANGLE(RequiredAngle*(180/PI)))); 04313 04314 // Translate shape to old centre point 04315 if (ok) 04316 *Translation *= Trans2DMatrix(ShapeCentre.x, ShapeCentre.y); 04317 04318 ObjChangeParam ObjChange(OBJCHANGE_STARTING,ObjChangeFlags(), NULL, this); 04319 if (pShape->AllowOp(&ObjChange)) 04320 { 04321 // Record the bounds 04322 if (ok) 04323 ok = (RecalcBoundsAction::DoRecalc(this, &UndoActions, pShape) != AC_FAIL); 04324 04325 // Now actually transform the shape in the document 04326 if (ok) 04327 ok = DoTransformNode(pShape, Translation); 04328 04329 // And redraw its final state 04330 if (ok) 04331 ok = (RecordBoundsAction::DoRecord(this, &UndoActions, pShape) != AC_FAIL); 04332 04333 GetApplication()->FindSelection()->Update(); 04334 04335 // Say we have finished 04336 if (ok) 04337 { 04338 ObjChange.Define(OBJCHANGE_FINISHED,ObjChangeFlags(),NULL,this); 04339 ok = UpdateChangedNodes(&ObjChange); 04340 } 04341 } 04342 04343 return ok; 04344 }
|
|
Makes a QuickShape regular, ie 100% aspect ratio, no skew, shear etc...
Definition at line 4249 of file shapeops.cpp. 04250 { 04251 if (!DoActions(pShape, RegularPoint)) 04252 { 04253 InformError(); 04254 FailAndExecute(); 04255 } 04256 04257 End(); 04258 }
|
|
Returns the state of this operation.
Definition at line 4200 of file shapeops.cpp. 04201 { 04202 OpState Blobby; 04203 04204 return Blobby; 04205 }
|
|
Registers this op.
Reimplemented from SimpleCCObject. Definition at line 4223 of file shapeops.cpp. 04224 { 04225 return RegisterOpDescriptor(0, 04226 _R(IDS_QUICKSHAPE_MAKEREGULAR), 04227 CC_RUNTIME_CLASS(OpShapeMakeRegular), 04228 OPTOKEN_QUICKSHAPE_MAKEREGULAR, 04229 OpShapeMakeRegular::GetState); 04230 }
|