OpDragOrigin Class Reference

defines an operation for dragging perspective mould vanishing points around More...

#include <moldedit.h>

Inheritance diagram for OpDragOrigin:

UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpDragOrigin ()
 Constructs an Operation that allows the user to drag vanishing points of a perspective mould.
void DoDragVanishPoint (Spread *, const DocCoord &, ClickModifiers, NodeMould *, BOOL)
 Starts a drag of one of the perspective moulds vanishing points. Note, a lot of effort has been put into the redraw of perspectives when dragging vanishing points. We must make sure the vanishing point rectangles are redrawn separately to the actual mould contents. If not it is v likely that you will get a huge rectangle as a result of the union. Redrawing this area is very bad. Also note, we do not drag a copy of the envelope or perspective control polygon but the control polygon itself. This means we must make sure when we scroll we prevent the mould object from attempting to eor its blobs on, this has the tendancy to leave large amounts of unsightly eor all over the place.
virtual void DragPointerMove (DocCoord Pos, ClickModifiers Mods, Spread *pSpread, BOOL bSolidDrag)
 Called while the vanishing point is being dragged around. Erases it from its old position and redraws it at its new position.
virtual void DragFinished (DocCoord Pos, ClickModifiers Mods, Spread *pSpread, BOOL Success, BOOL bSolidDrag)
 Update the perspective mould object with the final resting place of this mould vanishing point.
virtual void RenderDragBlobs (DocRect, Spread *, BOOL bSolidDrag)
 Draws the drag path and new vanishing point positions.
virtual void GetOpName (String_256 *OpName)
 The GetOpName fn is overridden so that we return back a description appropriate to this type of operation.

Static Public Member Functions

static BOOL Init ()
 Registers the rotation centre drag Operation.
static OpState GetState (String_256 *Description, OpDescriptor *)
 Controls whether the rotation-centre mouse drag operation is available or not. Currently, is always available (the internal logic of the selector tool & info-bar handle this really).

Private Member Functions

 CC_DECLARE_DYNCREATE (OpDragOrigin)
DocRect CalcBlobClipRect ()
 Constructs a rectangle that surrounds the objects we are eoring.

Private Attributes

SpreadStartSpread
NodeMouldpEditMould
NodeMouldPathpEditMouldPath
PathpEditPath
MouldPerspectivepEditGeometry
DocRect EditRect
DocCoord Blob

Detailed Description

defines an operation for dragging perspective mould vanishing points around

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/01/95

Definition at line 363 of file moldedit.h.


Constructor & Destructor Documentation

OpDragOrigin::OpDragOrigin  ) 
 

Constructs an Operation that allows the user to drag vanishing points of a perspective mould.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/01/95

Definition at line 1574 of file moldedit.cpp.

01575 {
01576     StartSpread     = NULL;
01577     pEditMould      = NULL;
01578     pEditMouldPath  = NULL;
01579     pEditPath       = NULL;
01580     pEditGeometry   = NULL;
01581 }


Member Function Documentation

DocRect OpDragOrigin::CalcBlobClipRect  )  [private]
 

Constructs a rectangle that surrounds the objects we are eoring.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/01/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A clipping rectangle for use by RenderDragBlobs.

Definition at line 1922 of file moldedit.cpp.

01923 {
01924     // get the current vanish point clip rects
01925     DocRect Rect0 = pEditGeometry->GetBlobBoundingRect();
01926     DocRect Rect1 = pEditMouldPath->GetBlobBoundingRect();
01927 
01928     return Rect0.Union(Rect1);
01929 }

OpDragOrigin::CC_DECLARE_DYNCREATE OpDragOrigin   )  [private]
 

void OpDragOrigin::DoDragVanishPoint Spread pSpread,
const DocCoord dcPos,
ClickModifiers  mods,
NodeMould pMould,
BOOL  WhichBlob
 

Starts a drag of one of the perspective moulds vanishing points. Note, a lot of effort has been put into the redraw of perspectives when dragging vanishing points. We must make sure the vanishing point rectangles are redrawn separately to the actual mould contents. If not it is v likely that you will get a huge rectangle as a result of the union. Redrawing this area is very bad. Also note, we do not drag a copy of the envelope or perspective control polygon but the control polygon itself. This means we must make sure when we scroll we prevent the mould object from attempting to eor its blobs on, this has the tendancy to leave large amounts of unsightly eor all over the place.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/01/95
Parameters:
pSpread = the spread containing the rotation centre blob [INPUTS] dcPos = the initial position of the blob mods = the mouse button click modifiers (eg ctrl click etc) pMould = a pointer to the mould we will drag
- [OUTPUTS]
Returns:
-

Definition at line 1684 of file moldedit.cpp.

01689 {
01690     ERROR3IF(pMould==NULL,"DoDragVanishPoint() given a null mould object");
01691     DocCoord v0,v1;
01692 
01693     // Remember the starting positions etc and initiate a drag.
01694     StartSpread = pSpread;
01695     pEditMould  = pMould;
01696 
01697     // try to find the geometry
01698     MouldGeometry* pGeometry = pMould->GetGeometry();
01699     if (!pGeometry->IsKindOf(CC_RUNTIME_CLASS(MouldPerspective)))
01700     {
01701         ERROR3("DoDragVanishPoint() called on an illegal geometry");
01702         goto Failed;
01703     }
01704 
01705     pEditGeometry = (MouldPerspective*)pGeometry;
01706 
01707     // read the current vanishing point positions for this mould.
01708     pEditGeometry->GetVanishingPoints(v0,v1);
01709     WhichBlob ? (Blob=v1) : (Blob=v0);
01710 
01711     // get hold of the moulds nodepath object
01712     pEditMouldPath = pMould->GetPathShape();
01713     if (!pEditMouldPath)
01714         goto Failed;
01715 
01716     // cache the actual path shape
01717     pEditPath = &(pEditMouldPath->InkPath);
01718 
01719     // record an action to redraw the node in its current state during undo/redo
01720     // we use our own special action to do this RecordBoundsAction uses the nasty
01721     // GetUnionBlobBounds() which unions the vanishing points in there too.
01722     // PS.. Pass FALSE into this function to avoid redraw at this stage
01723     if (RedrawBoundsAction::DoRecord(this,pEditMould,FALSE)==AC_FAIL)
01724         goto Failed;
01725     
01726     // Save the current rectangular bounds to redraw after the dragop has finished
01727     OpDragOrigin::EditRect = pMould->GetChildrensBounds();
01728 
01729     // record the current path data, ie its flags,verbs & coords
01730     if ((pEditMould->StartSaveContext(this, REC_REBUILD | REC_BLOBS | REC_GEOMCONTEXT | REC_PATHARRAYS)) == CC_FAIL)
01731         goto Failed;
01732 
01733 /*  if (SavePathArraysAction::DoRecord(this, &UndoActions, pEditPath) == AC_FAIL)
01734         goto Failed;
01735 
01736     // record the current mould shape on the undo and any blob rectangles
01737     if (pEditMould->SaveContext(this)==CC_FAIL)
01738         goto Failed;
01739 */
01740     // turn the display blobs off to prevent the mould from drawing them on
01741     // during a scroll.
01742     pEditMould->DisableBlobs();
01743 
01744     // start off the drag and get ready
01745     StartDrag(DRAGTYPE_AUTOSCROLL);
01746     return;
01747 
01748 Failed:
01749     FailAndExecute();
01750     End();
01751 }

void OpDragOrigin::DragFinished DocCoord  dcPos,
ClickModifiers  mods,
Spread pSpread,
BOOL  success,
BOOL  bSolidDrag
[virtual]
 

Update the perspective mould object with the final resting place of this mould vanishing point.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/01/95
Parameters:
PointerPos = final position of the mouse [INPUTS] ClickMods = the click modifiers. pSpread = spread containing the mouse success = whether the drag was cancelled or not
- [OUTPUTS]
Returns:
-

Reimplemented from Operation.

Definition at line 1815 of file moldedit.cpp.

01820 {
01821     EndDrag();
01822     Document* pDoc = Document::GetCurrent();
01823     NodeAttribute* pNA = NULL;
01824 
01825     // Make sure the nodes blob rendering is enabled again
01826     pEditMould->EnableBlobs();
01827 
01828     // Act on the termination status of the drag operation.
01829     if (!success)
01830     {
01831         // Get rid of what ever new stuff we have, the unwind handler will
01832         // cause our original stuff to be replaced.
01833         RenderDragBlobs(CalcBlobClipRect(), StartSpread, bSolidDrag);
01834         goto Failed;
01835     }
01836 
01837     // Turn that hourglass on
01838     BeginSlowJob();
01839 
01840     // Make sure we invalidate the edit object
01841     pEditMouldPath->InvalidateBoundingRect();
01842 
01843     // Force a redraw on the original position. 
01844     // Note, we cannot do this before we start dragging as EORing goes mad!
01845     if (pDoc)
01846         pDoc->ForceRedraw( StartSpread, OpDragOrigin::EditRect, FALSE, pEditMould);
01847 
01848     if (pEditMould->RemouldAll(this)==CC_FAIL)
01849         goto Failed;
01850 
01851     // Ilan 7/5/00
01852     // Inform geom linked attrs of the change. Nb outside the normal AllowOp mechanism
01853     pNA = pEditMould->FindFirstGeometryLinkedAttr();
01854     while(pNA)
01855     {
01856         pNA->LinkedNodeGeometryHasChanged(this);
01857         pNA = pNA->FindNextGeometryLinkedAttr();
01858     }
01859 
01860     if ((pEditMould->EndSaveContext(this, REC_REBUILD | REC_BLOBS | REC_GEOMCONTEXT | REC_PATHARRAYS)) == CC_FAIL)
01861         goto Failed;
01862 
01863     // record an action to redraw the state of the mould (but not vanishpoints)
01864     if (RedrawBoundsAction::DoRecord(this,pEditMould,TRUE)==AC_FAIL)
01865         goto Failed;
01866 
01867     // record the vanish points separately (important to avoid unionblobbounds()!)
01868     if (pEditGeometry->RecordBlobs(this,StartSpread)==CC_FAIL)
01869         goto Failed;
01870 
01871     End();
01872     return;
01873 
01874 Failed:
01875     FailAndExecute();
01876     End();
01877     return;
01878 }

void OpDragOrigin::DragPointerMove DocCoord  dcPos,
ClickModifiers  mods,
Spread pSpread,
BOOL  bSolidDrag
[virtual]
 

Called while the vanishing point is being dragged around. Erases it from its old position and redraws it at its new position.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/01/95
Parameters:
dcPos = the current mouse position [INPUTS] pSpread = the spread containing the mouse
- [OUTPUTS]
Returns:
-

Reimplemented from Operation.

Definition at line 1770 of file moldedit.cpp.

01771 {   
01772     // If the mouse has moved outside the spread the drag was started on then we must
01773     // account for this.
01774     if (pSpread != StartSpread)
01775         dcPos = MakeRelativeToSpread(StartSpread, pSpread, dcPos);
01776 
01777     // Erase the old blobs.
01778     RenderDragBlobs(CalcBlobClipRect(), StartSpread, bSolidDrag);
01779 
01780     if (pEditGeometry->MoveVanishingPoint(Blob,dcPos))
01781     {
01782         Blob=dcPos;
01783         // Update the new shape in the path.
01784         DocCoord* pCoords = pEditPath->GetCoordArray();
01785         pEditGeometry->CopyShape(pCoords);
01786     }   
01787 
01788     // Draw on the new blobs
01789     RenderDragBlobs(CalcBlobClipRect(), StartSpread, bSolidDrag);
01790 }

void OpDragOrigin::GetOpName String_256 OpName  )  [virtual]
 

The GetOpName fn is overridden so that we return back a description appropriate to this type of operation.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/01/95
Parameters:
- [INPUTS]
The undo string for the operation [OUTPUTS]
Returns:

Reimplemented from Operation.

Definition at line 1649 of file moldedit.cpp.

01650 {
01651     *OpName = String_256(_R(IDS_UNDO_DRAGVPOINT));
01652 }

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

Controls whether the rotation-centre mouse drag operation is available or not. Currently, is always available (the internal logic of the selector tool & info-bar handle this really).

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/01/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
Returns a default OpState.

Errors: -

See also:
-

Definition at line 1628 of file moldedit.cpp.

01629 {
01630     OpState os;
01631     return os;
01632 }

BOOL OpDragOrigin::Init void   )  [static]
 

Registers the rotation centre drag Operation.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/01/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the op is correctly registered.

Errors: -

See also:
-

Reimplemented from SimpleCCObject.

Definition at line 1598 of file moldedit.cpp.

01599 {
01600     return RegisterOpDescriptor(0, /* _R(IDS_DRAGOriginOP), */ 
01601                                 _R(IDS_DRAGORIGINOP),
01602                                 CC_RUNTIME_CLASS(OpDragOrigin),
01603                                 OPTOKEN_DRAGVANISHPOINT, 
01604                                 OpDragOrigin::GetState,
01605                                 0,
01606                                 _R(IDBBL_DRAGORIGINOP));
01607 }

void OpDragOrigin::RenderDragBlobs DocRect  Clip,
Spread pSpread,
BOOL  bSolidDrag
[virtual]
 

Draws the drag path and new vanishing point positions.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/01/95
Parameters:
Clip = clipping rectangle for output [INPUTS] pSpread = the spread to render into
- [OUTPUTS]
Returns:
-

Reimplemented from Operation.

Definition at line 1895 of file moldedit.cpp.

01896 {
01897     RenderRegion* pRegion = DocView::RenderOnTop(&Clip, pSpread, ClippedEOR);
01898     while (pRegion != NULL)
01899     {
01900         // Get the edit path to render itself
01901         pEditMouldPath->RenderObjectBlobs(pRegion);
01902         pEditGeometry->RenderControlBlobs(pRegion);
01903 
01904         pRegion = DocView::GetNextOnTop(&Clip);
01905     }
01906 }


Member Data Documentation

DocCoord OpDragOrigin::Blob [private]
 

Definition at line 389 of file moldedit.h.

DocRect OpDragOrigin::EditRect [private]
 

Definition at line 388 of file moldedit.h.

MouldPerspective* OpDragOrigin::pEditGeometry [private]
 

Definition at line 387 of file moldedit.h.

NodeMould* OpDragOrigin::pEditMould [private]
 

Definition at line 384 of file moldedit.h.

NodeMouldPath* OpDragOrigin::pEditMouldPath [private]
 

Definition at line 385 of file moldedit.h.

Path* OpDragOrigin::pEditPath [private]
 

Definition at line 386 of file moldedit.h.

Spread* OpDragOrigin::StartSpread [private]
 

Definition at line 383 of file moldedit.h.


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