OpNodePathEditControlBlob Class Reference

This operation is started by the NodePath when it receives a drag message from one of the tools. It uses it to drag one of the paths Bezier control points around the screen to edit the path. As the control points are dragged about the new version of the path, corosponding to the new blob positions, will be EOR rendered to the window. This class is derived from OpNodePathEditBlob which drags the normal selected points around. This drags the Bezier control points around of one of the selected points on the curve. Most of the functions are not needed as it uses the base class versions. More...

#include <pathedit.h>

Inheritance diagram for OpNodePathEditControlBlob:

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

Public Member Functions

 OpNodePathEditControlBlob ()
void DoStartDragEdit (NodePath *, DocCoord Anchor, Spread *pSpread, INT32)
 This is called when a Drag operation has been started on a control point of a path.
virtual void DragPointerMove (DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL bSolidDrag)
 This is called every time the mouse moves, during a drag.
virtual void RenderDragBlobs (DocRect, Spread *, BOOL bSolidDrag)
 Renders the new version of the path to the window. It calls to the base class function to render the path, then renders some blobs itself.

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.

Protected Member Functions

BOOL BuildEditPath ()
 Builds a copy of the path that we can edit, without destroying the original data. Also sets the NeedToRenderFlags for the EOR rendering during the drag. The parts of the path need to be rendered during the drag are the segment that contains this control point and the segment with the opposite control point if the rotate flag is set on the endpoint.
void RecalculatePath (DocCoord Offset)
 Will move the control point in question and then re-calculate the whole path setting the redraw flag where needed.
virtual void RenderDraggingBlobs (DocRect, Spread *)
 Call this function to render all the blobs on screen from this operation.
void RenderPathEditControlBlobs (DocRect Rect, Spread *pSpread)
 Renders the new version of the path to the window. It calls to the base class function to render the path, then renders some blobs itself.
void SetStatusLineHelp ()
 Updates the status line message to reflect the current situation.

Protected Attributes

INT32 Index
INT32 EndPointIndex
INT32 OppositeIndex

Detailed Description

This operation is started by the NodePath when it receives a drag message from one of the tools. It uses it to drag one of the paths Bezier control points around the screen to edit the path. As the control points are dragged about the new version of the path, corosponding to the new blob positions, will be EOR rendered to the window. This class is derived from OpNodePathEditBlob which drags the normal selected points around. This drags the Bezier control points around of one of the selected points on the curve. Most of the functions are not needed as it uses the base class versions.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/7/93

Definition at line 270 of file pathedit.h.


Constructor & Destructor Documentation

OpNodePathEditControlBlob::OpNodePathEditControlBlob  )  [inline]
 

Definition at line 277 of file pathedit.h.

00277 : OpNodePathEditBlob() { };


Member Function Documentation

BOOL OpNodePathEditControlBlob::BuildEditPath  )  [protected]
 

Builds a copy of the path that we can edit, without destroying the original data. Also sets the NeedToRenderFlags for the EOR rendering during the drag. The parts of the path need to be rendered during the drag are the segment that contains this control point and the segment with the opposite control point if the rotate flag is set on the endpoint.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> - later attacked by Peter
Date:
17/02/94
Returns:
TRUE if it managed to build the path, FALSE if it failed

Errors: If it runs out of memory then it will return FALSE

Reimplemented from OpNodePathEditBlob.

Definition at line 3584 of file pathedit.cpp.

03585 {
03586     // Make a copy of the original path and clear its need to render flags
03587     const INT32 NumCoords = OriginalPath->InkPath.GetNumCoords();
03588     if (!EditPath.Initialise(NumCoords, 24))
03589         return FALSE;
03590     if (!EditPath.CopyPathDataFrom(&(OriginalPath->InkPath)))
03591         return FALSE;
03592     EditPath.ClearNeedToRender();
03593 
03594     PathFlags* Flags = EditPath.GetFlagArray();
03595 
03596     // Set the render flag on the endpoint after the dragged control point so that segment renders
03597     if (Flags[Index-1].IsEndPoint)
03598         Flags[Index+2].NeedToRender = TRUE;
03599     else
03600         Flags[Index+1].NeedToRender = TRUE;
03601 
03602     // Now do the same for the opposite control point, if the Rotate flag is set on the endpoint
03603     if (Flags[EndPointIndex].IsRotate && OppositeIndex>=0 && OppositeIndex<NumCoords)
03604     {   
03605         if (Flags[OppositeIndex-1].IsEndPoint)
03606             Flags[OppositeIndex+2].NeedToRender = TRUE;
03607         else
03608             Flags[OppositeIndex+1].NeedToRender = TRUE;
03609     }
03610 
03611     // Set the endpoints smooth flag to FALSE
03612     Flags[EndPointIndex].IsSmooth = FALSE;
03613 
03614     return TRUE;
03615 }

void OpNodePathEditControlBlob::DoStartDragEdit NodePath OrigPath,
DocCoord  Anchor,
Spread pSpread,
INT32  ControlIndex
 

This is called when a Drag operation has been started on a control point of a path.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/7/93
Parameters:
OrigPath - The original Node path object [INPUTS] Anchor - The position of the mouse at the start of the Drag pSpread - the spread that the drag started on ControlIndex - The Coord number of the control point that we are dragging

Definition at line 3403 of file pathedit.cpp.

03405 {
03406     // We had better take a note of the starting point of the drag
03407     LastMousePos = Anchor;
03408     StartMousePos = Anchor;
03409     StartSpread  = pSpread;
03410     OriginalPath = OrigPath;
03411     Index = ControlIndex;
03412     BOOL ok = TRUE;
03413 
03414     PathFlags* Flags = OrigPath->InkPath.GetFlagArray();
03415     PathVerb* Verbs = OrigPath->InkPath.GetVerbArray();
03416     DocCoord* Coords = OrigPath->InkPath.GetCoordArray();
03417 
03418     // Find the index of the end point that this control point is attached to
03419     if (Flags[Index-1].IsEndPoint)
03420         EndPointIndex = Index-1;
03421     else
03422         EndPointIndex = Index+1;
03423     ConstrainPoint = Coords[EndPointIndex];
03424     ConstrainPrevPoint = ConstrainPoint;
03425     ConstrainNextPoint = ConstrainPoint;
03426 
03427     // Find the opposite index
03428     OppositeIndex = OrigPath->InkPath.FindOppositeControlPoint(Index);
03429 
03430     // We also need to make a version of the path that we can change
03431     if (ok)
03432         ok = BuildEditPath();
03433 
03434     // Create and send a change message about this path edit
03435     if (ok)
03436         ok = EditObjChange.ObjChangeStarting(OrigPath,this,&EditPath,StartSpread,TRUE) == CC_OK;
03437 
03438     if (ok)
03439         ok = CreateCursors();
03440     if (ok)
03441         ChangeCursor(pCrossHairCursor);
03442 
03443     // Since we're editing control points, we have to clear the IsSmooth flags on this,
03444     // the adjacent point and the endpoint
03445     if (ok)
03446     {
03447         Flags = EditPath.GetFlagArray();
03448         Verbs = EditPath.GetVerbArray();
03449 
03450         Flags[ControlIndex].IsSmooth = FALSE;
03451         if (OppositeIndex >= 0)
03452             Flags[OppositeIndex].IsSmooth = FALSE;
03453         Flags[EndPointIndex].IsSmooth = FALSE;
03454     }
03455 
03456     // Render the bits of the path that are different
03457     if (ok)
03458     {
03459         DocRect EditPathBBox = EditPath.GetBoundingRect();
03460         RenderPathEditControlBlobs(EditPathBBox, pSpread);
03461         DragStarted = TRUE;
03462 
03463         // And tell the Dragging system that we need drags to happen
03464         ok = StartDrag(DRAGTYPE_AUTOSCROLL, &EditPathBBox, &LastMousePos);
03465     }
03466 
03467     if (!ok)
03468     {
03469         InformError();
03470         FailAndExecute();
03471         End();
03472     }
03473 }

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

This is called every time the mouse moves, during a drag.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/7/93
Parameters:
PointerPos - The current position of the mouse in Doc Coords [INPUTS] ClickMods - Which key modifiers are being pressed pSpread - the spread that the cursor is over now
See also:
ClickModifiers

Reimplemented from OpNodePathEditBlob.

Definition at line 3493 of file pathedit.cpp.

03494 {
03495     EndSnapped = FALSE;     // Always false in this operation
03496     
03497     // If drag has moved onto a different spread, convert the coord to be relative to the
03498     // original spread.
03499     if (pSpread != StartSpread)
03500         PointerPos = MakeRelativeToSpread(StartSpread, pSpread, PointerPos);
03501 
03502     Path TempPath;
03503 
03504     // inform the parent a change is happening
03505     if (EditObjChange.ChangeMask.EorBlobs)
03506     {
03507         ChangeCode Chge=EditObjChange.RenderCurrentBlobs(OriginalPath,this,&EditPath,StartSpread,TRUE);
03508         if (Chge!=CC_OK)
03509             return;
03510         // Create a local copy of the edit path
03511         if (!TempPath.Initialise(EditPath.GetNumCoords(), 12))
03512             return;
03513         TempPath.CopyPathDataFrom(&EditPath);
03514     }
03515 
03516     // Optionally constrain the new position
03517     ERROR3IF(ConstrainPoint == DocCoord(-1,-1),"ConstrainPoint wasn't set");
03518     if (ClickMods.Constrain)
03519         DocView::ConstrainToAngle(ConstrainPoint, &PointerPos);
03520     DocView::SnapCurrent(StartSpread, &PointerPos);
03521 
03522     // Rub out the old EORed version of the path
03523     RenderPathEditControlBlobs( EditPath.GetBoundingRect(), StartSpread );
03524 
03525     // This is the bit where we go off and re-calculate the paths position,
03526     // based on how much the mouse has moved
03527     DocCoord Offset;
03528     Offset.x = PointerPos.x - LastMousePos.x;
03529     Offset.y = PointerPos.y - LastMousePos.y;
03530     RecalculatePath( Offset );
03531 
03532     if (EditObjChange.ChangeMask.EorBlobs)
03533     {
03534         ChangeCode Chge=EditObjChange.RenderChangedBlobs(OriginalPath,this,&EditPath,StartSpread,TRUE);
03535         if (Chge!=CC_OK)
03536         {
03537             // replace the old edit path
03538             EditPath.CopyPathDataFrom(&TempPath);
03539             RenderPathEditControlBlobs( EditPath.GetBoundingRect(), StartSpread );
03540             return;
03541         }
03542     }
03543 
03544     // Update the last mouse position and draw in the new version of the path
03545     LastMousePos = PointerPos;
03546     RenderPathEditControlBlobs( EditPath.GetBoundingRect(), StartSpread );
03547 
03548     // Now we want to update the Line tool infobar if the position of control point being 
03549     // dragged is being shown.
03550     PathFlags* Flags = EditPath.GetFlagArray();
03551 //  DocCoord* Coords = EditPath.GetCoordArray();
03552     INT32  CurrentIndex;
03553 
03554     if (Flags[Index+1].IsEndPoint)
03555     {
03556         CurrentIndex = Index+1;
03557     }
03558     else
03559     {
03560         CurrentIndex = Index-1;
03561     }
03562 
03563     // We'll broadcast a message about the edit, thus hopping over the kernel/tool DLL boundary
03564     BROADCAST_TO_ALL(PathEditedMsg(&EditPath, pSpread, CurrentIndex));
03565 
03566     SetStatusLineHelp();
03567 }

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

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

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/7/93
Parameters:
Description - GetState fills this string with an approriate description [OUTPUTS] of the current state of the selector tool
Returns:
The state of the operation, so that menu items (ticks and greying can be done properly

Reimplemented from OpNodePathEditBlob.

Definition at line 3777 of file pathedit.cpp.

03778 {
03779     OpState Blobby;
03780     
03781     return Blobby;
03782 }

BOOL OpNodePathEditControlBlob::Init void   )  [static]
 

Adds the operation to the list of all known operations.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/7/93
Returns:
TRUE if all went OK, False otherwise

Reimplemented from OpNodePathEditBlob.

Definition at line 3748 of file pathedit.cpp.

03749 {
03750     PORTNOTETRACE("other","OpNodePathEditControlBlob::Init - do nothing");
03751     return (RegisterOpDescriptor(
03752                                     0, 
03753                                     _R(IDS_NODEPATH_EDIT),
03754                                     CC_RUNTIME_CLASS(OpNodePathEditControlBlob), 
03755                                     OPTOKEN_NODEPATH,
03756                                     OpNodePathEditControlBlob::GetState,
03757                                     0,                                          // help ID
03758                                     _R(IDBBL_NODEPATHOP),
03759                                     0 ) );                                      // bitmap ID
03760 }

void OpNodePathEditControlBlob::RecalculatePath DocCoord  Offset  )  [protected]
 

Will move the control point in question and then re-calculate the whole path setting the redraw flag where needed.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/11/93
Parameters:
Offset - The Amount to move the selected blobs by before re-calcing everything [INPUTS] Scope: Private

Definition at line 3632 of file pathedit.cpp.

03633 {
03634     // Find the coords in the path
03635     DocCoord* Coords = EditPath.GetCoordArray();
03636     PathFlags* Flags = EditPath.GetFlagArray();
03637     INT32 NumCoords = EditPath.GetNumCoords();
03638     if (Flags[EndPointIndex].IsRotate && OppositeIndex >=0 && OppositeIndex < NumCoords)
03639     {
03640         EditPath.CalcRotate(Coords[EndPointIndex], &Coords[Index], &Coords[OppositeIndex], Offset);
03641     }
03642     else
03643     {
03644         Coords[Index].x += Offset.x;
03645         Coords[Index].y += Offset.y;
03646     }
03647 }

void OpNodePathEditControlBlob::RenderDragBlobs DocRect  Rect,
Spread pSpread,
BOOL  bSolidDrag
[virtual]
 

Renders the new version of the path to the window. It calls to the base class function to render the path, then renders some blobs itself.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/8/94

Reimplemented from OpNodePathEditBlob.

Definition at line 3661 of file pathedit.cpp.

03662 {
03663     // Don't render anything if the last mouse position is the same as the start point
03664     if (LastMousePos == StartMousePos) return;
03665 
03666     // Now render the current edit path
03667     RenderPathEditControlBlobs(Rect,pSpread);
03668 
03669     // And report the change to our parents.
03670     if (EditObjChange.ChangeMask.EorBlobs)
03671         EditObjChange.RenderCurrentBlobs(OriginalPath,this,&EditPath,StartSpread,TRUE);
03672 }

void OpNodePathEditControlBlob::RenderDraggingBlobs DocRect  Rect,
Spread pSpread
[protected, virtual]
 

Call this function to render all the blobs on screen from this operation.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/5/95

Reimplemented from OpNodePathEditBlob.

Definition at line 3683 of file pathedit.cpp.

03684 {
03685     RenderPathEditControlBlobs(Rect, pSpread);
03686 }

void OpNodePathEditControlBlob::RenderPathEditControlBlobs DocRect  Rect,
Spread pSpread
[protected]
 

Renders the new version of the path to the window. It calls to the base class function to render the path, then renders some blobs itself.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/01/95
Parameters:
Rect = a doc rect rectangle [INPUTS] pSpread = a pointer to a spread to render into

Definition at line 3703 of file pathedit.cpp.

03704 {
03705     if (LastMousePos == StartMousePos)
03706         return;
03707 
03708     DocCoord* Coords = EditPath.GetCoordArray();
03709     PathFlags* Flags = EditPath.GetFlagArray();
03710 //  PathVerb* Verbs = EditPath.GetVerbArray();
03711     INT32 NumCoords = EditPath.GetNumCoords();
03712 
03713 //  BOOL PrevIsEndPoint;
03714     DocCoord StartCoord = Coords[0];
03715 
03716     // And this bit actually draws the path we have just made
03717     RenderRegion* pRegion = DocView::RenderOnTop( NULL, StartSpread, ClippedEOR );
03718     while ( pRegion )
03719     {
03720         OpNodePathEditBlob::RenderPathEditBlobs(Rect, pSpread);
03721 
03722         EditPath.DrawControlBlob(pRegion, Coords[Index]);
03723         EditPath.DrawControlLine(pRegion, Coords[Index], Coords[EndPointIndex]);
03724         if (Flags[EndPointIndex].IsRotate && OppositeIndex>=0 && OppositeIndex<NumCoords && Flags[Index].IsSelected)
03725         {
03726             
03727             EditPath.DrawControlBlob(pRegion, Coords[OppositeIndex]);
03728             EditPath.DrawControlLine(pRegion, Coords[OppositeIndex], Coords[EndPointIndex]);
03729         }           
03730 
03731         // Get the Next render region
03732         pRegion = DocView::GetNextOnTop( &Rect );
03733         
03734     }
03735 }

void OpNodePathEditControlBlob::SetStatusLineHelp  )  [protected, virtual]
 

Updates the status line message to reflect the current situation.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/1/96

Reimplemented from OpNodePathEditBlob.

Definition at line 3793 of file pathedit.cpp.

03794 {
03795     String_256 HelpString(_R(IDS_PATHDRAGFINISHCONTROL));
03796     GetApplication()->UpdateStatusBarText(&HelpString, FALSE);
03797 }


Member Data Documentation

INT32 OpNodePathEditControlBlob::EndPointIndex [protected]
 

Definition at line 300 of file pathedit.h.

INT32 OpNodePathEditControlBlob::Index [protected]
 

Definition at line 299 of file pathedit.h.

INT32 OpNodePathEditControlBlob::OppositeIndex [protected]
 

Definition at line 301 of file pathedit.h.


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