OpDragRegularShape Class Reference

This operation is started by a NodeRegularShape when someone drags on one of its control points. As the control point is dragged about the new version of the shape, corosponding to the new blob positions, will be EOR rendered to the window. More...

#include <shapeops.h>

Inheritance diagram for OpDragRegularShape:

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

Public Member Functions

 OpDragRegularShape ()
 Constructor. This sets a few of the operation variables.
void DoStartDragEdit (NodeRegularShape *, DocCoord, Spread *, DragType, BOOL QuickShape)
void DoStartDragEditCurve (NodeRegularShape *, DocCoord, Spread *, DragType, DocCoord Start, DocCoord End)
 This is called to start a drag operation on a regular shape.
virtual BOOL SnappingDrag ()
virtual void DragPointerMove (DocCoord Pos, ClickModifiers Mods, Spread *pSpread, BOOL bSolidDrag)
 This is called every time the mouse moves, during a drag. We need to render off the shape in its current position, calculate any changes to apply to it then render it back on.
virtual void DragFinished (DocCoord Pos, ClickModifiers Mods, Spread *pSpread, BOOL Success, BOOL bSolidDrag)
 This is called when a drag operation finishes. If the drag was sucessful then the OriginalShape in the document is updated.
virtual void RenderDragBlobs (DocRect, Spread *, BOOL bSolidDrag)
 Renders the current version of the shape to the window.

Static Public Member Functions

static BOOL Init ()
 Adds the operation to the list of all known operations.
static OpState GetState (String_256 *Description, OpDescriptor *)
 Find out the state of the operation at the specific time.

Private Types

enum  DragType {
  DRAG_CENTRE, DRAG_ELLIPSE, DRAG_PRIMARY, DRAG_STELLATION,
  DRAG_PRIMARYCURVE, DRAG_STELLATIONCURVE
}

Private Member Functions

BOOL ProcessCentre (DocCoord Pos, ClickModifiers Mods)
 This is called to update the EditShape after a mouse movement in a centre point drag. The shape is being translated. Constrain works from angles from the original centre point of the shape.
BOOL ProcessPrimary (DocCoord Pos, ClickModifiers Mods)
 This is called to update the EditShape after a mouse movement in a primary point drag.
BOOL ProcessRectangle (DocCoord Pos, ClickModifiers Mods)
 This is called to update a rectangular EditShape after a mouse movement during a drag on one if its corners.
BOOL ProcessRectangleDiagonal (DocCoord Pos, ClickModifiers Mods)
 This is called to update a rectangular EditShape after a mouse movement during a drag on one if its corners. The rectangle is resized about the opposite corner to the drag corner.
BOOL ProcessRectangleEdge (DocCoord Pos, DocCoord OtherEnd)
 This is called during a rectangle drag to resize the rectangle about either edge.
BOOL ProcessEllipse (DocCoord Pos, ClickModifiers Mods)
 This is called to update the ellipitical EditShape after a mouse movement during a drag.
BOOL ProcessStellation (DocCoord Pos, ClickModifiers Mods)
 This is called to update the EditShape after a mouse movement in a stellation point drag.
BOOL ProcessRadius (DocCoord Pos, ClickModifiers Mods)
 This is called to process drags on the primary points and on the major axes.
BOOL ProcessPrimaryCurve (DocCoord Pos)
 This is called to update the EditShape after a mouse movement in a primary curvature point drag.
BOOL ProcessStellationCurve (DocCoord Pos)
 This is called to update the EditShape after a mouse movement in a stellation curvature point drag.
void WheelConstrain (DocCoord *PointerPos, const DocCoord StartPos)
 This is called to constrain a point to a steering-wheel shape. The wheel is centred on the centre of OriginalShape. It has radius of the distance from the centre to StartPos. The other constrain line is the line passing through the centre point and StartPos.
DocCoord GetUTPosition (DocCoord TransedPos)
 This is called to convert a current mouse postion to untransform back to the coordinates used by the untranslated OriginalShape.
BOOL IsJoinAcute (const DocCoord *pJoin, const DocCoord *pOtherEndOfJoin, const DocCoord *pOtherPoint)
 For seeing the perpendicual distance from pOtherPoint to the line pJoin-pOtherEndOfJoin end on the line or before pJoin. Used when dragging along a line to see if the drag point has gon back beyond the start of the line.

Private Attributes

DocCoord LastMousePos
DocCoord StartMousePos
SpreadStartSpread
NodeRegularShapeOriginalShape
NodeRegularShapeEditShape
CursorpCursor
INT32 CurrentCursorID
DragType DragObject
DocCoord LineStart
DocCoord LineEnd
Matrix transMat
DocCoord RectangleArray [4]
BOOL DragAroundCentre

Detailed Description

This operation is started by a NodeRegularShape when someone drags on one of its control points. As the control point is dragged about the new version of the shape, corosponding to the new blob positions, will be EOR rendered to the window.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/12/94

Definition at line 235 of file shapeops.h.


Member Enumeration Documentation

enum OpDragRegularShape::DragType [private]
 

Enumerator:
DRAG_CENTRE 
DRAG_ELLIPSE 
DRAG_PRIMARY 
DRAG_STELLATION 
DRAG_PRIMARYCURVE 
DRAG_STELLATIONCURVE 

Definition at line 240 of file shapeops.h.


Constructor & Destructor Documentation

OpDragRegularShape::OpDragRegularShape  ) 
 

Constructor. This sets a few of the operation variables.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/12/94

Definition at line 1532 of file shapeops.cpp.

01533 {
01534     pCursor = NULL;
01535     StartSpread = NULL;
01536     OriginalShape = NULL;
01537     EditShape = NULL;
01538 }


Member Function Documentation

void OpDragRegularShape::DoStartDragEdit NodeRegularShape ,
DocCoord  ,
Spread ,
DragType  ,
BOOL  QuickShape
 

Definition at line 1563 of file shapeops.cpp.

01565 {
01566     // Adjust anchor point so this is the actual point on the shape that the drag starts from
01567     INT32 DragPointNumber = -1;
01568     pShape->DetermineClickEffect(&Anchor, pSpread, &DragPointNumber);
01569 
01570     // Take note of the drag parameters
01571     DragObject = DragThing;
01572     LastMousePos = Anchor;
01573     StartMousePos = Anchor;
01574     StartSpread  = pSpread;
01575     OriginalShape = pShape;
01576     DragAroundCentre = QuickShape;
01577 
01578     // We also need to make a version of the shape that we can change
01579     EditShape = (NodeRegularShape*) OriginalShape->SimpleCopy();
01580     BOOL Success = (EditShape != NULL);
01581 
01582     if (Success)
01583     {
01584         // Create the cursors and display it (if it was created ok)
01585         pCursor = new Cursor(TOOLID_BEZTOOL, _R(IDC_MOVEBEZIERCURSOR));
01586 
01587         if ( pCursor != NULL && pCursor->IsValid())
01588         {   // Select the cursor
01589             CurrentCursorID = CursorStack::GPush(pCursor);
01590         }
01591         else
01592         {   // Set cursor pointer to NULL to indicate its non appearence
01593             if (pCursor != NULL)
01594                 delete pCursor;
01595             pCursor = NULL;
01596         }
01597 
01598         // And tell the Dragging system that we need drags to happen
01599         Success = StartDrag(DRAGTYPE_AUTOSCROLL, NULL, &LastMousePos, FALSE);
01600 
01601         // Render the initial shape
01602         if (Success)
01603             RenderDragBlobs(DocRect(), pSpread, FALSE);
01604     }
01605 
01606     // Do special rectangle setup
01607     if (Success && (DragObject == DRAG_PRIMARY) && OriginalShape->IsARectangle())
01608     {
01609         if (DragPointNumber == -1)
01610         {
01611             ERROR3("Couldn't find the rectangle drag point");
01612             Success = FALSE;
01613         }
01614 
01615         // Get the significant points
01616         DocCoord* PointsArray = NULL;
01617         INT32 NumberPoints = 0;
01618         Success = OriginalShape->BuildPolygonPoints(&PointsArray, &NumberPoints);
01619 
01620         // Transform the significant points to document space
01621         if (Success)
01622         {
01623             // Get the shape matrix and its inverse
01624             Matrix ShapeMat;
01625             OriginalShape->GetTransformMatrix(&ShapeMat);
01626             ShapeMat.transform((Coord*)PointsArray,NumberPoints);
01627         }
01628 
01629         // Get the points opposite to the drag point, the stationary point
01630         INT32 Opposite = 0;
01631         if (Success)
01632             Opposite = (DragPointNumber + ((NumberPoints-2)/2)) % (NumberPoints-2);
01633 
01634         // Copy the points into the array.  ) is the opposite point, 2 is the drag point
01635         if (Success)
01636         {
01637             INT32 Increment = (NumberPoints-2)/4;
01638             INT32 Copy = 0;
01639             for (INT32 i = Opposite; Copy < 4; i+=Increment)
01640                 RectangleArray[Copy++] = PointsArray[i%(NumberPoints-2)];
01641             
01642             // Make the array go clockwise
01643             DocCoord temp = RectangleArray[1];
01644             RectangleArray[1] = RectangleArray[3];
01645             RectangleArray[3] = temp;
01646         }
01647 
01648         delete PointsArray;
01649     }
01650 
01651     if (!Success)
01652     {
01653         InformError();
01654         FailAndExecute();
01655         End();
01656     }
01657 }

void OpDragRegularShape::DoStartDragEditCurve NodeRegularShape pShape,
DocCoord  Anchor,
Spread pSpread,
DragType  DragThing,
DocCoord  Start,
DocCoord  End
 

This is called to start a drag operation on a regular shape.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/12/94
Parameters:
pShape - Pointer to the shape we are about to edit [INPUTS] Anchor - The position of the mouse at the start of the Drag pSpread - The spread that the shape is on DragThing - the object on the shape that should be dragged Start - the start of the line along which the curvature point is to be dragged End - the end of the line along which the curvature point is to be dragged.
Returns:
Errors: If there was not enought memory for the setup then the user is informed and the op is aborted

Definition at line 1680 of file shapeops.cpp.

01682 {
01683     DoStartDragEdit(pShape, Anchor, pSpread, DragThing, TRUE);
01684 
01685     // Take note of the additional drag parameters
01686     LineStart = Start;
01687     LineEnd = End;
01688 }

void OpDragRegularShape::DragFinished DocCoord  PointerPos,
ClickModifiers  ClickMods,
Spread pSpread,
BOOL  Success,
BOOL  bSolidDrag
[virtual]
 

This is called when a drag operation finishes. If the drag was sucessful then the OriginalShape in the document is updated.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/14/94
Parameters:
PointerPos - The position of the mouse at the end of the drag [INPUTS] ClickMods - the key modifiers being pressed Success - TRUE if the drag was terminated properly, FALSE if it was ended with the escape key being pressed
See also:
ClickModifiers

Reimplemented from Operation.

Definition at line 1819 of file shapeops.cpp.

01821 {
01822     // Do some tidying up
01823     RenderDragBlobs( DocRect(), StartSpread, bSolidDrag );
01824     if (pCursor != NULL)
01825     {
01826         CursorStack::GPop(CurrentCursorID);
01827         delete pCursor;
01828         CurrentCursorID = 0;
01829         pCursor = NULL;
01830     }
01831     EndDrag();
01832     BeginSlowJob();
01833 
01834     if ( Success )
01835     {
01836         BOOL Failed = !DoStartSelOp(FALSE, TRUE, FALSE, TRUE);
01837         
01838         //DocView* pDocView = DocView::GetSelected();
01839         //ERROR3IF( pDocView == NULL, "There was no selected docview when editing a shape" );
01840 
01841         // Will the original shape allow the op to happen?
01842         ObjChangeFlags cFlags;
01843         cFlags.TransformNode = TRUE;
01844         ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,OriginalShape,this);
01845         Failed = !OriginalShape->AllowOp(&ObjChange);
01846 
01847         if (!Failed)
01848             Failed = (RecalcBoundsAction::DoRecalc(this, &UndoActions, OriginalShape) == AC_FAIL);
01849 
01850         // Now update the shape depending on the dragtype
01851         if (!Failed)
01852         {
01853             switch (DragObject)
01854             {
01855                 case DRAG_CENTRE:
01856                 {
01857                     // Construct a transformation matrix to move the shape
01858                     Trans2DMatrix* TransMat = new Trans2DMatrix(EditShape->GetCentrePoint().x - OriginalShape->GetCentrePoint().x,
01859                                             EditShape->GetCentrePoint().y - OriginalShape->GetCentrePoint().y);
01860                     DoTransformNode(OriginalShape, TransMat);
01861                     break;
01862                 }
01863                 case DRAG_ELLIPSE:
01864                 case DRAG_PRIMARY:
01865                 {   // Transform shape using the matrix
01866                     Trans2DMatrix* tm = new Trans2DMatrix(transMat);
01867                     Failed = ! DoTransformNode(OriginalShape, tm) ;
01868                     Failed |= !ChangeShapePointAction::DoToggle(this, &UndoActions, OriginalShape, 
01869                                                 ChangeShapePointAction::CHANGE_CENTRE, 
01870                                                             OriginalShape->GetUTCentrePoint());
01871                     OriginalShape->SetCentrePoint(EditShape->GetUTCentrePoint());
01872                     Failed |= !ChangeShapePointAction::DoToggle(this, &UndoActions, OriginalShape, 
01873                                                 ChangeShapePointAction::CHANGE_MINOR, 
01874                                                             OriginalShape->GetUTMinorAxes());
01875                     OriginalShape->SetMinorAxes(EditShape->GetUTMinorAxes());
01876                     Failed |= !ChangeShapePointAction::DoToggle(this, &UndoActions, OriginalShape, 
01877                                                 ChangeShapePointAction::CHANGE_MAJOR, 
01878                                                             OriginalShape->GetUTMajorAxes());
01879                     OriginalShape->SetMajorAxes(EditShape->GetUTMajorAxes());
01880                     break;
01881                 }
01882                 case DRAG_STELLATION:
01883                     Failed = !ChangeShapeDataAction::DoToggle(this, &UndoActions, OriginalShape, 
01884                                                 ChangeShapeDataAction::CHANGE_STELLRADIUSTOPRIMARY, 
01885                                                             OriginalShape->GetStellRadiusToPrimary() );
01886                     OriginalShape->SetStellRadiusToPrimary(EditShape->GetStellRadiusToPrimary());
01887                     Failed = !ChangeShapeDataAction::DoToggle(this, &UndoActions, OriginalShape, 
01888                                                 ChangeShapeDataAction::CHANGE_STELLATIONOFFSET, 
01889                                                             OriginalShape->GetStellationRatio() );
01890                     OriginalShape->SetStellationRatio(EditShape->GetStellationRatio());
01891                     break;
01892                 case DRAG_PRIMARYCURVE:
01893                     Failed = !ChangeShapeDataAction::DoToggle(this, &UndoActions, OriginalShape, 
01894                                                 ChangeShapeDataAction::CHANGE_PRIMARYCURVETOPRIMARY, 
01895                                                             OriginalShape->GetPrimaryCurveToPrimary() );
01896                     OriginalShape->SetPrimaryCurveToPrimary(EditShape->GetPrimaryCurveToPrimary());
01897                     break;
01898                 case DRAG_STELLATIONCURVE:
01899                     Failed = !ChangeShapeDataAction::DoToggle(this, &UndoActions, OriginalShape, 
01900                                                     ChangeShapeDataAction::CHANGE_STELLCURVETOSTELL, 
01901                                                             OriginalShape->GetStellCurveToStell() );
01902                     OriginalShape->SetStellCurveToStell(EditShape->GetStellCurveToStell());
01903                     break;
01904                 default:
01905                     ERROR3("What was that drag type?");
01906                     break;
01907             }
01908         }
01909 
01910         // Recalculate the path's bounding box
01911         OriginalShape->InvalidateBoundingRect();
01912         OriginalShape->InvalidateCache();
01913         
01914         // tell the world that something in the selection has changed so that selection bounds are updated
01915         SelRange *Sel = GetApplication()->FindSelection();
01916         Sel->Update();
01917 
01918         // Try to expand the pasteboard if necessary to include the new bounds of the object
01919         DocRect NewBounds = Sel->GetBoundingRect();
01920         ERROR3IF(pSpread == NULL, "Unexpectedly NULL Spread pointer");
01921         pSpread->ExpandPasteboardToInclude(NewBounds);
01922 
01923         if (!Failed)
01924         {
01925             // Update effected parents
01926             ObjChange.Define(OBJCHANGE_FINISHED,cFlags,OriginalShape,this);
01927             Failed = !UpdateChangedNodes(&ObjChange);
01928         }
01929 
01930         if (!Failed && OriginalShape->FindParentSpread()!=NULL)
01931             Failed = (RecordBoundsAction::DoRecord(this, &UndoActions, OriginalShape) == AC_FAIL) ;
01932 
01933         // If any of the above failed the kill the op
01934         if (Failed)
01935         {
01936 //          PATRACE( _T("An action failed!\n"));
01937             FailAndExecute();
01938         }
01939     }
01940     else
01941     {
01942         // Set up the flags that say it all went wrong
01943         FailAndExecute();
01944     }
01945 
01946     delete (EditShape);
01947     End();
01948 }

void OpDragRegularShape::DragPointerMove DocCoord  PointerPos,
ClickModifiers  ClickMods,
Spread pSpread,
BOOL  bSolidDrag
[virtual]
 

This is called every time the mouse moves, during a drag. We need to render off the shape in its current position, calculate any changes to apply to it then render it back on.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/12/94
Parameters:
PointerPos - The current position of the mouse in Doc Coords [INPUTS] ClickMods - Which key modifiers are being pressed pSpread - The spread containing PointerPos
See also:
ClickModifiers

Reimplemented from Operation.

Definition at line 1722 of file shapeops.cpp.

01723 {
01724     // If the PointerPois is the same as the last one, then dont bother doing anything
01725     if (PointerPos == LastMousePos)
01726         return;
01727     
01728     // If drag has moved onto a different spread, convert the coord to be relative to the
01729     // original spread.
01730     if (pSpread != StartSpread)
01731         PointerPos = MakeRelativeToSpread(StartSpread, pSpread, PointerPos);
01732 
01733     // Rub out the old EORed version of the path
01734     RenderDragBlobs( DocRect(), StartSpread, bSolidDrag);
01735 
01736     // Now apply the changes to the EditShape, depending on the drag type
01737     BOOL Success = FALSE;
01738     switch (DragObject)
01739     {
01740         case DRAG_CENTRE:
01741         {
01742             Success = ProcessCentre(PointerPos, ClickMods);
01743             break;
01744         }
01745         case DRAG_ELLIPSE:
01746         {
01747             if (DragAroundCentre)
01748                 Success = ProcessPrimary(PointerPos, ClickMods);
01749             else
01750                 Success = ProcessEllipse(PointerPos, ClickMods);
01751             break;
01752         }
01753         case DRAG_PRIMARY:
01754         {
01755             if (EditShape->IsARectangle() && !DragAroundCentre)
01756                 Success = ProcessRectangle(PointerPos, ClickMods);
01757             else
01758                 Success = ProcessPrimary(PointerPos, ClickMods);
01759             break;
01760         }
01761         case DRAG_STELLATION:
01762         {
01763             Success = ProcessStellation(PointerPos, ClickMods);
01764             break;
01765         }
01766         case DRAG_PRIMARYCURVE:
01767         {
01768             Success = ProcessPrimaryCurve(PointerPos);
01769             break;
01770         }
01771         case DRAG_STELLATIONCURVE:
01772         {
01773             Success = ProcessStellationCurve(PointerPos);
01774             break;
01775         }
01776         default:
01777             ERROR3("What was the drag type?");
01778             break;
01779     }
01780 
01781     if (Success)
01782     {
01783         // Draw in the new version of the path
01784         RenderDragBlobs( DocRect(), StartSpread, bSolidDrag);
01785 
01786         // Update the Last Mouse Position
01787         LastMousePos = PointerPos;
01788 
01789         // Tell anyone that's interested
01790         BROADCAST_TO_ALL(ShapeEditedMsg(EditShape, pSpread));
01791     }
01792     else
01793     {
01794         InformError();
01795         EndDrag();
01796         FailAndExecute();
01797         End();
01798     }
01799 }

OpState OpDragRegularShape::GetState String_256 Description,
OpDescriptor
[static]
 

Find out the state of the operation at the specific time.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/12/94
Parameters:
- [OUTPUTS]
Returns:
The state of the operation, so that menu items (ticks and greying can be done properly

Definition at line 2757 of file shapeops.cpp.

02758 {
02759     OpState Blobby;
02760     
02761     return Blobby;
02762 }

DocCoord OpDragRegularShape::GetUTPosition DocCoord  TransedPos  )  [private]
 

This is called to convert a current mouse postion to untransform back to the coordinates used by the untranslated OriginalShape.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/2/95
Parameters:
TransedPos - A position in the OriginalShape's translated space [INPUTS]
- [OUTPUTS]
Returns:
The position untranslated back to the OriginalShape
See also:
-

Definition at line 2660 of file shapeops.cpp.

02661 {
02662     Matrix TransMat;
02663     OriginalShape->GetTransformMatrix(&TransMat);
02664     TransMat = TransMat.Inverse();
02665     TransMat.transform(&TransedPos);
02666 
02667     return TransedPos;
02668 }

BOOL OpDragRegularShape::Init void   )  [static]
 

Adds the operation to the list of all known operations.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/12/94
Returns:
TRUE if all went OK, False otherwise

Reimplemented from SimpleCCObject.

Definition at line 2734 of file shapeops.cpp.

02735 {
02736     return (RegisterOpDescriptor(   0, 
02737                                     _R(IDS_EDITREGULARSHAPEOP),
02738                                     CC_RUNTIME_CLASS(OpDragRegularShape), 
02739                                     OPTOKEN_DRAGREGULARSHAPE,
02740                                     OpDragRegularShape::GetState));
02741 }

BOOL OpDragRegularShape::IsJoinAcute const DocCoord pJoin,
const DocCoord pOtherEndOfJoin,
const DocCoord pOtherPoint
[private]
 

For seeing the perpendicual distance from pOtherPoint to the line pJoin-pOtherEndOfJoin end on the line or before pJoin. Used when dragging along a line to see if the drag point has gon back beyond the start of the line.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/12/95
Parameters:
pJoin - the coordinate where two lines join [INPUTS] pOtherEndOfJoin - another point that with pJoin defines a line pOtherPoint - another point that with pJoin defines another line
- [OUTPUTS]
Returns:
TRUE if the angle between the two lines is an acute angle

Definition at line 2716 of file shapeops.cpp.

02717 {
02718     return DocCoord::IsJoinAcute(pJoin, pOtherEndOfJoin, pOtherPoint);
02719 }

BOOL OpDragRegularShape::ProcessCentre DocCoord  PointerPos,
ClickModifiers  ClickMods
[private]
 

This is called to update the EditShape after a mouse movement in a centre point drag. The shape is being translated. Constrain works from angles from the original centre point of the shape.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/12/94
Parameters:
PointerPos - The current position of the mouse in Doc Coords [INPUTS] ClickMods - Which key modifiers are being pressed
See also:
OpDragRegularShape::DragPointerMove

Definition at line 2493 of file shapeops.cpp.

02494 {
02495     // Constrain and snap the mouse point if required
02496     DocCoord OldCentre = OriginalShape->GetCentrePoint();
02497     if (ClickMods.Constrain)
02498         DocView::ConstrainToAngle(OldCentre, &PointerPos);
02499     DocView::SnapCurrent(StartSpread,&PointerPos);
02500 
02501     // Translate shape based on the movement.
02502     DocCoord Offset = PointerPos - EditShape->GetCentrePoint();                                                     
02503     Trans2DMatrix Trans(Offset.x, Offset.y);
02504     EditShape->Transform(Trans);
02505 
02506     return TRUE;
02507 }

BOOL OpDragRegularShape::ProcessEllipse DocCoord  PointerPos,
ClickModifiers  Mods
[private]
 

This is called to update the ellipitical EditShape after a mouse movement during a drag.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/04/95
Parameters:
PointerPos - The current position of the mouse in Doc Coords [INPUTS] Mods - the drag modifiers
See also:
OpDragRegularShape::DragPointerMove, OpDragRegularShape::ProcessRectangle

Definition at line 2184 of file shapeops.cpp.

02185 {
02186     // If this is an adjust drag then work around the centre
02187     if (Mods.Adjust)
02188     {
02189         if (Mods.Constrain)
02190             WheelConstrain(&PointerPos, StartMousePos);
02191 
02192         return ProcessRadius(PointerPos, Mods);
02193     }
02194 
02195     // Snap the mouse point to the active grid
02196     DocView::SnapCurrent(StartSpread,&PointerPos);
02197 
02198     // Untransform the current pointer pos
02199     DocCoord UTPointerPos = GetUTPosition(PointerPos);
02200     const DocCoord UTCentre = OriginalShape->GetUTCentrePoint();
02201     const DocCoord Centre = OriginalShape->GetCentrePoint();
02202     Matrix OriginalMat;
02203     OriginalShape->GetTransformMatrix(&OriginalMat);
02204     DocCoord UTStartPos = GetUTPosition(StartMousePos);
02205     DocCoord UTOppositePos = DocCoord::PositionPointFromRatio(UTCentre, UTStartPos, -1.0);
02206     DocCoord OppositePos = UTOppositePos;
02207     OriginalMat.transform(&OppositePos);
02208 
02209     // Get rotation of original and current dragging points
02210     DocCoord StartDragPoint = StartMousePos - OppositePos;
02211     double OrigRotation = atan2((double)StartDragPoint.y, (double)StartDragPoint.x);
02212 
02213     // Get the scaling factor
02214     const double OriginalLength = OppositePos.Distance(StartMousePos);
02215     const double Ax = (StartMousePos.x-OppositePos.x);
02216     const double Ay = (StartMousePos.y-OppositePos.y);
02217     const double Bx = (PointerPos.x-OppositePos.x);
02218     const double By = (PointerPos.y-OppositePos.y);
02219     const double NewLength = ((Ax*Bx) + (Ay*By)) / sqrt((Ax*Ax) + (Ay*Ay));
02220     double ScaleFactor = NewLength/OriginalLength;
02221 
02222     // Transform to origin, rotate so drag point to opposite lies on the origin,
02223     // scale, rotate back to current rotation, then transform back
02224     Matrix Transform(-OppositePos.x, -OppositePos.y);
02225     Transform*= Matrix(ANGLE(-(OrigRotation*(180/PI))));
02226     Transform*= Matrix(fixed16(ScaleFactor),fixed16(1.0));
02227     Transform*= Matrix(ANGLE(OrigRotation*(180/PI)));
02228     Transform*= Matrix(OppositePos.x, OppositePos.y);
02229     Trans2DMatrix   Trans(Transform);
02230 
02231     // Copy the original shape then apply the transform
02232     delete EditShape;
02233     EditShape = (NodeRegularShape*)OriginalShape->SimpleCopy();
02234     if (EditShape != NULL)
02235     {
02236         EditShape->Transform(Trans);
02237         transMat = Transform;
02238         return TRUE;
02239     }
02240     else
02241         return FALSE;
02242 }

BOOL OpDragRegularShape::ProcessPrimary DocCoord  PointerPos,
ClickModifiers  Mods
[private]
 

This is called to update the EditShape after a mouse movement in a primary point drag.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/1/94
Parameters:
PointerPos - The current position of the mouse in Doc Coords [INPUTS]
See also:
OpDragRegularShape::DragPointerMove, OpDragRegularShape::ProcessRadius

Definition at line 2158 of file shapeops.cpp.

02159 {
02160     if (Mods.Constrain)
02161     {
02162         WheelConstrain(&PointerPos, StartMousePos);
02163     }
02164 
02165     return ProcessRadius(PointerPos, Mods);
02166 }

BOOL OpDragRegularShape::ProcessPrimaryCurve DocCoord  PointerPos  )  [private]
 

This is called to update the EditShape after a mouse movement in a primary curvature point drag.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/1/94
Parameters:
PointerPos - The current position of the mouse in Doc Coords [INPUTS]
See also:
OpDragRegularShape::DragPointerMove

Definition at line 1965 of file shapeops.cpp.

01966 {
01967     // Untransform the various things
01968     Matrix Mat;
01969     EditShape->GetTransformMatrix(&Mat);
01970     Mat = Mat.Inverse();
01971     DocCoord UTLineStart = LineStart;
01972     DocCoord UTLineEnd = LineEnd;
01973     DocCoord UTPointerPos = PointerPos;
01974     Mat.transform(&UTLineStart);
01975     Mat.transform(&UTLineEnd);
01976     Mat.transform(&UTPointerPos);
01977 
01978     // Move the point along the edge line to get new ratio
01979     double c = UTLineStart.Distance(UTPointerPos);
01980     double b = fabs(DocCoord::DistanceFromLine(UTLineStart, UTLineEnd, UTPointerPos));
01981     double a = sqrt(c*c - b*b);
01982     double NewRatio = a/EditShape->GetUTMajorAxes().Distance(EditShape->GetUTCentrePoint());
01983 
01984     // Detect a zero ratio case (otherwise the point moves back along the line)
01985     if (!IsJoinAcute(&UTLineStart, &UTLineEnd, &UTPointerPos))
01986     {
01987         NewRatio = 0.0;
01988     }
01989     else
01990     {
01991         // Restrict to fit with along the edge
01992         if (EditShape->IsStellated())
01993         {
01994             // Get the position of the stellation curvature point and its distance
01995             const double OuterMajorLength = OriginalShape->GetMajorRadiusSize();
01996             const double StellationCurvatureLength = OuterMajorLength * OriginalShape->GetStellCurveToStell();
01997             const double AvailableLength = (UTLineStart.Distance(UTLineEnd)) - StellationCurvatureLength;
01998 
01999             double top = a;
02000             if ( (AvailableLength - a) < 1.0)
02001                 top = AvailableLength;
02002 
02003             NewRatio = top/EditShape->GetUTMajorAxes().Distance(EditShape->GetUTCentrePoint());
02004         }
02005         else
02006         {
02007             // We need to limit the drag to halfway along the drag line
02008             const double MaxLength = UTLineStart.Distance(UTLineEnd)/2.0;
02009             if (a > MaxLength)
02010                 NewRatio = MaxLength/EditShape->GetUTMajorAxes().Distance(EditShape->GetUTCentrePoint());
02011         }
02012     }
02013 
02014     EditShape->SetPrimaryCurveToPrimary(NewRatio);
02015 
02016     return TRUE;
02017 }

BOOL OpDragRegularShape::ProcessRadius DocCoord  Pos,
ClickModifiers  Mods
[private]
 

This is called to process drags on the primary points and on the major axes.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/2/95
Parameters:
PointerPos - The current position of the mouse in Doc Coords [INPUTS] ClickMods - Which key modifiers are being pressed
See also:
-

Definition at line 2524 of file shapeops.cpp.

02525 {
02526     // Snap the mouse point to the active grid
02527     DocView::SnapCurrent(StartSpread,&Pos);
02528 
02529     // Untransform the current pointer pos
02530     DocCoord UTPointerPos = GetUTPosition(Pos);
02531     const DocCoord UTCentre = OriginalShape->GetUTCentrePoint();
02532     const DocCoord Centre = OriginalShape->GetCentrePoint();
02533 
02534     // Get rotation of original and current primary points
02535     DocCoord CurrentPrimary = StartMousePos - Centre;
02536     DocCoord NewPrimary = Pos - Centre;
02537     double OrigPrimaryRotation = atan2((double)CurrentPrimary.y, (double)CurrentPrimary.x);
02538     double NewPrimaryRotation = atan2((double)NewPrimary.y, (double)NewPrimary.x);
02539     ANGLE RotBy(-(OrigPrimaryRotation - NewPrimaryRotation)*(180/PI));
02540 
02541     // Get the scaling factor
02542     double NewLength = Pos.Distance(Centre);
02543     double CurrentLength = StartMousePos.Distance(Centre);
02544     double ScaleFactor = (CurrentLength != 0.0) ? (NewLength/CurrentLength) : 0.001;
02545 
02546     // Transform to origin, scale, rotate then transform back
02547     Matrix Transform(-Centre.x, -Centre.y);
02548     Transform*= Matrix(RotBy);
02549     Transform*= Matrix(fixed16(ScaleFactor),fixed16(ScaleFactor));
02550     Transform*= Matrix(Centre.x, Centre.y);
02551     Trans2DMatrix   Trans(Transform);
02552 
02553     // Copy the original shape then apply the transform
02554     delete EditShape;
02555     EditShape = (NodeRegularShape*)OriginalShape->SimpleCopy();
02556     if (EditShape != NULL)
02557     {
02558         EditShape->Transform(Trans);
02559         transMat = Transform;
02560         return TRUE;
02561     }
02562     else
02563         return FALSE;
02564 }

BOOL OpDragRegularShape::ProcessRectangle DocCoord  PointerPos,
ClickModifiers  Mods
[private]
 

This is called to update a rectangular EditShape after a mouse movement during a drag on one if its corners.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/04/95
Parameters:
PointerPos - The current position of the mouse in Doc Coords [INPUTS] Mods - the drag modifiers
See also:
OpDragRegularShape::DragPointerMove, OpDragRegularShape::ProcessEllipse

Definition at line 2260 of file shapeops.cpp.

02261 {
02262     // If this is an adjust drag then work around the centre
02263     if (Mods.Adjust)
02264     {
02265         if (Mods.Constrain)
02266             WheelConstrain(&PointerPos, StartMousePos);
02267 
02268         return ProcessRadius(PointerPos, Mods);
02269     }
02270 
02271     // See which line the mouse is nearest to determine the type of the drag
02272     if (Mods.Constrain)
02273     {
02274         double Diagonal = DocCoord::DistanceFromLine(RectangleArray[2], RectangleArray[0], PointerPos);
02275         double Prev = DocCoord::DistanceFromLine(RectangleArray[2], RectangleArray[1], PointerPos);
02276         double Next = DocCoord::DistanceFromLine(RectangleArray[2], RectangleArray[3], PointerPos);
02277 
02278         if ((Diagonal <= Prev) && (Diagonal <= Next))
02279             return ProcessRectangleDiagonal(PointerPos, Mods);
02280         else
02281         {
02282             if (Prev <= Next)
02283                 return ProcessRectangleEdge(PointerPos, RectangleArray[1]);
02284             else
02285                 return ProcessRectangleEdge(PointerPos, RectangleArray[3]);
02286         }
02287     }
02288     else
02289         return ProcessRectangleDiagonal(PointerPos, Mods);
02290 }

BOOL OpDragRegularShape::ProcessRectangleDiagonal DocCoord  PointerPos,
ClickModifiers  Mods
[private]
 

This is called to update a rectangular EditShape after a mouse movement during a drag on one if its corners. The rectangle is resized about the opposite corner to the drag corner.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/95
Parameters:
PointerPos - The current position of the mouse in Doc Coords [INPUTS] Mods - the drag modifiers
See also:
OpDragRegularShape::ProcessRectangleEdge

Definition at line 2306 of file shapeops.cpp.

02307 {
02308     // Constrain the mouse so the aspect of the shape is maintained
02309     if (Mods.Constrain)
02310     {
02311         // Get the scaling factor
02312         const double RectDiagonal = RectangleArray[0].Distance(RectangleArray[2]);
02313         const double Ax = (RectangleArray[2].x-RectangleArray[0].x);
02314         const double Ay = (RectangleArray[2].y-RectangleArray[0].y);
02315         const double Bx = (PointerPos.x-RectangleArray[0].x);
02316         const double By = (PointerPos.y-RectangleArray[0].y);
02317         const double NewLength = ((Ax*Bx) + (Ay*By)) / sqrt((Ax*Ax) + (Ay*Ay));
02318         double ratio = NewLength/RectDiagonal;
02319 
02320         // reposition the pointer
02321         PointerPos = DocCoord::PositionPointFromRatio(RectangleArray[0], RectangleArray[2], ratio);
02322     }
02323 
02324     // Snap the mouse point to the active grid
02325     DocView::SnapCurrent(StartSpread,&PointerPos);
02326 
02327     // Get the shape matrix and its inverse
02328     Matrix ShapeMat;
02329     OriginalShape->GetTransformMatrix(&ShapeMat);
02330     Matrix InvShapeMat = ShapeMat;