OpPenEditPath Class Reference

This operation is started by the pen tool when it receives a click on a document and needs to create a new path. The idea is, it will drag edit a path until such time as the user lets go of the mouse. and then add the path to the tree. The operation handles the internals of rendering the eor path. More...

#include <penedit.h>

Inheritance diagram for OpPenEditPath:

OpPenHandles Operation MessageHandler ListItem CCObject SimpleCCObject OpPenAddElement OpPenClosePath OpPenCreatePath List of all members.

Public Member Functions

 OpPenEditPath ()
 OpPenEditPath constructor.
BOOL DoPenDragPath ()
virtual void DragPointerMove (DocCoord Pos, ClickModifiers Mods, Spread *pSpread, BOOL bSolidDrag)
 This is called every time the mouse moves, during a drag.
virtual void DragFinished (DocCoord Pos, ClickModifiers Mods, Spread *pSpread, BOOL Success, BOOL bSolidDrag)
 This is called when a drag operation finishes.
virtual void RenderDragBlobs (DocRect, Spread *, BOOL bSolidDrag)
 Render some drag control handles as the mouse moves around. These will spin around an anchor point.

Static Public Member Functions

static BOOL Init ()
 Declares a preference that allows you to clear memory in delete().
static OpState GetState (String_256 *, OpDescriptor *)

Protected Member Functions

DocRect GetBoundingRect ()
 Find the bounding box of the edit path and the drag handles.
void ConvertToLine (const INT32 index)
 Convert the currently edited curve element into a line.
void RemoveRotateEnd (const INT32 index)
 Remove any rotate bits from a bezier element, starting at index.
BOOL InsertBezier (DocCoord pt1, DocCoord pt2, DocCoord pt3)
 Add a specific curve at the end of the path.
BOOL InsertCurvedLine (DocCoord pt1, DocCoord pt2)
 Add a specific curve at the end of the path. The curve is made of colinear points.
BOOL InsertGhostedBezier (DocCoord pt1, DocCoord pt2, DocCoord pt3)
 Add a specific curve at the end of the path. The curve control points are made up of { pt2, Ghost(pt1,pt2), LinIntpl(Ghost,pt3), pt3 }.
BOOL ConvertPathEnd (Path *pDocPath)
 Common code to convert an edited element to a line, or remove its rotation bits. This should happen when the user simply clicks and does not perform a drag. The built curve element should be replaced by either a none smoothed curve or a line.
void SetWobbleIndex (WobbleFlags wibble, const INT32 index)
 Set the control handle index of our edit curve which will follow the dragging control handles.
void WobbleCoords ()
 Moves the control handles around dependent on the classes wobble flags.

Protected Attributes

PathpEditPath
INT32 WobbleIndex
WobbleFlags Wobble

Detailed Description

This operation is started by the pen tool when it receives a click on a document and needs to create a new path. The idea is, it will drag edit a path until such time as the user lets go of the mouse. and then add the path to the tree. The operation handles the internals of rendering the eor path.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/9/94

Definition at line 371 of file penedit.h.


Constructor & Destructor Documentation

OpPenEditPath::OpPenEditPath  ) 
 

OpPenEditPath constructor.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/9/94
See also:
-

Definition at line 1058 of file penedit.cpp.

01059 {
01060 }


Member Function Documentation

BOOL OpPenEditPath::ConvertPathEnd Path pDocPath  )  [protected]
 

Common code to convert an edited element to a line, or remove its rotation bits. This should happen when the user simply clicks and does not perform a drag. The built curve element should be replaced by either a none smoothed curve or a line.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/10/94
Parameters:
- [INPUTS]

Definition at line 1384 of file penedit.cpp.

01385 {
01386     BOOL converted = FALSE;
01387 
01388     // set the path position and read the coordinate data
01389     INT32 LastEl    = pDocPath->GetNumCoords();
01390     pDocPath->SetPathPosition(LastEl-1);
01391 
01392     DocCoord  CtrlPtC = pDocPath->GetCoord();
01393     PathVerb  CtrlPtV = (pDocPath->GetVerb()) & ~PT_CLOSEFIGURE;
01394     PathFlags CtrlPtF = pDocPath->GetFlags();
01395 
01396     // now create an element dependent on the control point type
01397 
01398     switch (CtrlPtV)
01399     {
01400         case PT_BEZIERTO:
01401             if (CtrlPtF.IsRotate)
01402                 RemoveRotateEnd(1);
01403             else
01404                 ConvertToLine(1);
01405                 converted=TRUE;
01406             break;
01407 
01408         case PT_LINETO:
01409             ConvertToLine(1);
01410             converted=TRUE;
01411             break;
01412     }
01413     return converted;
01414 }

void OpPenEditPath::ConvertToLine const INT32  index  )  [protected]
 

Convert the currently edited curve element into a line.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/9/94
Parameters:
index = index of element to remove from. [INPUTS]

Definition at line 1240 of file penedit.cpp.

01241 {
01242     // remove the curve element, then stick a none smooth line
01243     // segment in there.
01244 
01245     pEditPath->DeleteFromElement(index);
01246     PathFlags tempflags;
01247     tempflags.IsSelected = TRUE;
01248     pEditPath->InsertLineTo(GetMidHandle(), &tempflags);
01249 }

BOOL OpPenEditPath::DoPenDragPath  ) 
 

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/9/94
Parameters:
pEditPath = pointer a path to begin editing. [INPUTS]
Returns:
TRUE if able to start the drag, FALSE otherwise

-

Definition at line 1100 of file penedit.cpp.

01101 {   
01102     // Tell the Dragging system that we need drags to happen
01103     DocRect HandlesRect = GetBoundingRect();
01104     return StartDrag(DRAGTYPE_AUTOSCROLL, &HandlesRect, &CurrentMousePos);
01105 }

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

This is called when a drag operation finishes.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/9/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.

Reimplemented in OpPenCreatePath, OpPenAddElement, and OpPenClosePath.

Definition at line 1434 of file penedit.cpp.

01436 {
01437     // terminate the drag and operation
01438     EndDrag();      
01439 }

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

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

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

Reimplemented from Operation.

Reimplemented in OpPenClosePath.

Definition at line 1159 of file penedit.cpp.

01162 {
01163     // If drag has moved onto a different spread, convert the coord to be relative to the
01164     // original spread.
01165     if (pSpread != StartSpread)
01166         PointerPos = MakeRelativeToSpread(StartSpread, pSpread, PointerPos);
01167 
01168     // Make sure we get the grid snapping involved
01169     DocCoord SnapPos = PointerPos;
01170     DocView::SnapCurrent(pSpread,&SnapPos);
01171 
01172     if (CurrentMousePos != SnapPos)
01173     {
01174 
01175         // Rub out the old EORed version of the path and stick a new one on
01176         DocRect Rect = OpPenEditPath::GetBoundingRect();
01177         RenderDragBlobs(Rect, StartSpread, bSolidDrag);
01178 
01179         Rect.IncludePoint(SnapPos);
01180 
01181         // Alter the curve drag handles
01182         ChangeTrackHandle(SnapPos, ClickMods.Constrain);
01183         
01184         // make sure we wobble all the coordinates around this control point
01185         // correctly.
01186         WobbleCoords();
01187 
01188         // Now render the blobs back on again
01189         Rect = Rect.Union(OpPenEditPath::GetBoundingRect());
01190         RenderDragBlobs(Rect, StartSpread, bSolidDrag);
01191     }
01192 
01193 }

DocRect OpPenEditPath::GetBoundingRect  )  [protected]
 

Find the bounding box of the edit path and the drag handles.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/9/94
Parameters:
- [INPUTS]

Definition at line 1208 of file penedit.cpp.

01209 {
01210 
01211     DocRect Rect;   
01212     DocView* pDocView = DocView::GetSelected();
01213     ENSURE( pDocView != NULL, "There was no selected docview when getting the bounding box" );
01214 
01215     if ( pDocView != NULL )
01216     {
01217         DocRect BlobRect;
01218         DocCoord Coord;
01219         Rect = pEditPath->GetBoundingRect();
01220         Rect = Rect.Union(OpPenHandles::GetHandlesRect());
01221         // inflate by 1/4 of an inch to avoid eor problems
01222         Rect.Inflate(72000>>2);
01223     }
01224 
01225     return Rect;
01226 }

static OpState OpPenEditPath::GetState String_256 ,
OpDescriptor
[static]
 

Reimplemented in OpPenCreatePath, OpPenAddElement, and OpPenClosePath.

static BOOL OpPenEditPath::Init void   )  [static]
 

Declares a preference that allows you to clear memory in delete().

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/4/94
Returns:
TRUE if it worked OK, FALSE if not

Reimplemented from SimpleCCObject.

Reimplemented in OpPenCreatePath, OpPenAddElement, and OpPenClosePath.

BOOL OpPenEditPath::InsertBezier DocCoord  pt1,
DocCoord  pt2,
DocCoord  pt3
[protected]
 

Add a specific curve at the end of the path.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/9/94
Parameters:
pt1,pt2,pt3 = coords of control points for bezier [INPUTS]

Definition at line 1285 of file penedit.cpp.

01286 {
01287     // insert a particular type of curve
01288     PathFlags tempflags;
01289     tempflags.IsRotate = TRUE;
01290     BOOL done = pEditPath->InsertCurveTo(pt1, pt2, pt3, &tempflags);
01291 
01292     if (done)
01293     {
01294         INT32 npts = pEditPath->GetNumCoords();
01295         PathFlags* Flags = pEditPath->GetFlagArray();
01296         Flags[npts-1].IsSelected = TRUE;
01297     }
01298     return done;
01299 }

BOOL OpPenEditPath::InsertCurvedLine DocCoord  pt1,
DocCoord  pt2
[protected]
 

Add a specific curve at the end of the path. The curve is made of colinear points.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/10/94
Parameters:
pt1,pt2 = coords of the end control points for the bezier [INPUTS]

Definition at line 1315 of file penedit.cpp.

01316 {
01317 
01318     BOOL ok = pEditPath->InsertMoveTo(pt1, NULL);
01319     if (ok)
01320     {
01321         DocCoord Cpt1;
01322         Cpt1.x = (2*pt1.x + pt2.x)/3;
01323         Cpt1.y = (2*pt1.y + pt2.y)/3;
01324 
01325         DocCoord Cpt2;
01326         Cpt2.x = (pt1.x + 2*pt2.x)/3;
01327         Cpt2.y = (pt1.y + 2*pt2.y)/3;
01328 
01329         ok = InsertBezier(Cpt1, Cpt2, pt2);
01330 
01331     }
01332     return ok;
01333 } 

BOOL OpPenEditPath::InsertGhostedBezier DocCoord  pt1,
DocCoord  pt2,
DocCoord  pt3
[protected]
 

Add a specific curve at the end of the path. The curve control points are made up of { pt2, Ghost(pt1,pt2), LinIntpl(Ghost,pt3), pt3 }.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/10/94
Parameters:
pt1,pt2 = coords of the end control points of a previous bezier [INPUTS] pt3 = coordinate for new end point of inserted bezier

Definition at line 1350 of file penedit.cpp.

01351 {
01352     BOOL ok = pEditPath->InsertMoveTo(pt2, NULL);
01353     if (ok)
01354     {
01355         DocCoord Cpt1;
01356         Cpt1.x = pt2.x - (pt1.x - pt2.x);
01357         Cpt1.y = pt2.y - (pt1.y - pt2.y);
01358 
01359         DocCoord Cpt2;
01360         Cpt2.x = (Cpt1.x + 2*pt3.x)/3;
01361         Cpt2.y = (Cpt1.y + 2*pt3.y)/3;
01362 
01363         ok = InsertBezier(Cpt1, Cpt2, pt3);
01364     }
01365     return ok;
01366 }

void OpPenEditPath::RemoveRotateEnd const INT32  index  )  [protected]
 

Remove any rotate bits from a bezier element, starting at index.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/9/94
Parameters:
index = index of bezierto element [INPUTS]

Definition at line 1264 of file penedit.cpp.

01265 {
01266     // Remove all rotate values from the end curve element
01267     PathFlags* Flags = pEditPath->GetFlagArray();
01268     Flags[index].IsRotate = FALSE;
01269     Flags[index+1].IsRotate = FALSE;
01270     Flags[index+2].IsRotate = FALSE;
01271 }

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

Render some drag control handles as the mouse moves around. These will spin around an anchor point.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/9/94

Reimplemented from Operation.

Definition at line 1454 of file penedit.cpp.

01455 {
01456 
01457     RenderRegion* pRegion = DocView::RenderOnTop( &Rect, StartSpread, ClippedEOR );
01458     while ( pRegion )
01459     {
01460         // Get the edit path to render itself
01461         pRegion -> SetLineColour(COLOUR_XOREDIT);
01462         pRegion -> SetLineWidth(0);
01463         pRegion -> DrawPath(pEditPath);
01464 
01465         // Render the drag handles on top
01466         OpPenHandles::UpdateHandles(pRegion);
01467 
01468         pRegion = DocView::GetNextOnTop(NULL);
01469     }
01470 }

void OpPenEditPath::SetWobbleIndex WobbleFlags  wibble,
const INT32  index
[protected]
 

Set the control handle index of our edit curve which will follow the dragging control handles.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/9/94
Parameters:
wibble = wobble flags indicating which control handles will follow those [INPUTS] of the drag handles. index = the index into our edit curve of the endpoint handle whose brother and sister handles are being dragged around.
- [OUTPUTS]
See also:
-

Definition at line 1079 of file penedit.cpp.

01080 {
01081     Wobble = wibble;
01082     WobbleIndex = index;
01083 }

void OpPenEditPath::WobbleCoords  )  [protected]
 

Moves the control handles around dependent on the classes wobble flags.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/10/94
Parameters:
[INPUTS] 

Definition at line 1120 of file penedit.cpp.

01121 {
01122     DocCoord* Coords = pEditPath->GetCoordArray();
01123 
01124     if (Wobble.PrevBrother)
01125         Coords[WobbleIndex-1] = GetGhostHandle();
01126 
01127     if (Wobble.PrevSister)
01128     {
01129         Coords[WobbleIndex-2].x = (2*Coords[WobbleIndex-3].x + Coords[WobbleIndex-1].x)/3;
01130         Coords[WobbleIndex-2].y = (2*Coords[WobbleIndex-3].y + Coords[WobbleIndex-1].y)/3;
01131     }
01132 
01133     if (Wobble.NextBrother)
01134         Coords[WobbleIndex+1] = GetTrackHandle();
01135 
01136     if (Wobble.NextSister)
01137     {
01138         Coords[WobbleIndex+2].x = (Coords[WobbleIndex+1].x + 2*Coords[WobbleIndex+3].x)/3;
01139         Coords[WobbleIndex+2].y = (Coords[WobbleIndex+1].y + 2*Coords[WobbleIndex+3].y)/3;
01140     }
01141 }


Member Data Documentation

Path* OpPenEditPath::pEditPath [protected]
 

Definition at line 396 of file penedit.h.

WobbleFlags OpPenEditPath::Wobble [protected]
 

Definition at line 398 of file penedit.h.

INT32 OpPenEditPath::WobbleIndex [protected]
 

Definition at line 397 of file penedit.h.


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