OpPenHandles Class Reference

This operation simply provides functions for other operations to use. It is not intended to be used as an operation in its own right. Most useful pen classes are derived from this. More...

#include <penedit.h>

Inheritance diagram for OpPenHandles:

Operation MessageHandler ListItem CCObject SimpleCCObject OpPenDragBlobs OpPenEditPath OpPenCreateInternal OpPenEditInternal OpPenAddElement OpPenClosePath OpPenCreatePath List of all members.

Public Member Functions

 OpPenHandles ()
 OpPenEorHandles constructor.

Protected Member Functions

void RenderHandles ()
 Render some drag control handles as the mouse moves around. These will spin around an anchor point.
void UpdateHandles (RenderRegion *)
 Render some drag control handles as the mouse moves around. These will spin around an anchor point. Their appearence and positioning is set by the flags variable hflags.
DocRect GetHandlesRect ()
 Calculate the bounding rect of the drag blobs.
void RecalcHandles (DocCoord, BOOL)
 Recalc handles, given a new drag position which is generally following the mouse pointer, will work out the relative positions of the drag handles. The drag handles can be made to follow the drag position absolutely, or reletively dependent on their start positions.
void SetDragHandles (HandleFlags, DocCoord, DocCoord, DocCoord, Spread *)
 Set up the initial positions of the drag handles. Note, the handles contain their own coordinates of where they think they are. These are separate from the drag mouse position. This allows the handles to represent a relation to the drag point and not an absolute position.
void ChangeTrackHandle (DocCoord, BOOL)
DocCoord GetTrackHandle () const
 Return the private track handle coordinate for reference by none inclass code.
DocCoord GetGhostHandle () const
DocCoord GetMidHandle () const
DocCoord CalcGhostEnd (DocCoord start, DocCoord end) const
 Calculate a ghost end coordinate given two input coordinates. ghost = point1 - (point2 - point1).
void RenderTestRect (DocRect, Spread *, StockColour)
 Render a black rectangle. Useful for checking render regions and clipping.
BOOL HasMouseMoved (DocCoord &OriginalPoint, DocCoord &PointerPos, double threshold=2)
 Checks to see whether two coordinates are the same. The current test also checks for movement of less than two pixels in the scaled view. If the mouse has moved less than threshold*ScaledPixelSize then the points are considered equivalent.

Protected Attributes

HandleFlags Hflags
DocCoord StartMousePos
DocCoord CurrentMousePos
SpreadStartSpread

Private Member Functions

void SetHandleEnds (DocCoord, DocCoord, DocCoord)

Private Attributes

DocCoord TrackEnd
DocCoord MidPoint
DocCoord GhostEnd

Detailed Description

This operation simply provides functions for other operations to use. It is not intended to be used as an operation in its own right. Most useful pen classes are derived from this.

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

Definition at line 229 of file penedit.h.


Constructor & Destructor Documentation

OpPenHandles::OpPenHandles  ) 
 

OpPenEorHandles constructor.

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

Definition at line 230 of file penedit.cpp.

00231 {
00232     // default constructor (do nothing)
00233 }


Member Function Documentation

DocCoord OpPenHandles::CalcGhostEnd DocCoord  start,
DocCoord  end
const [protected]
 

Calculate a ghost end coordinate given two input coordinates. ghost = point1 - (point2 - point1).

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/9/94
Parameters:
start = point 1 [INPUTS] end = point 2
Returns:
ghost doc coordinate

Definition at line 279 of file penedit.cpp.

00280 {
00281     DocCoord ghost;
00282     ghost.x = start.x - (end.x - start.x);
00283     ghost.y = start.y - (end.y - start.y);
00284 
00285     return ghost;
00286 }

void OpPenHandles::ChangeTrackHandle DocCoord  newpos,
BOOL  constrain
[protected]
 

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

Definition at line 527 of file penedit.cpp.

00528 {
00529     CurrentMousePos = newpos;
00530     RecalcHandles(newpos, constrain);
00531 }

DocCoord OpPenHandles::GetGhostHandle  )  const [protected]
 

Definition at line 254 of file penedit.cpp.

00255 {
00256     return GhostEnd;
00257 }

DocRect OpPenHandles::GetHandlesRect  )  [protected]
 

Calculate the bounding rect of the drag blobs.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/9/94
Returns:
DocRect,

Definition at line 301 of file penedit.cpp.

00302 {
00303     // just set it to be an empty rectangle
00304     DocRect BoundRect (0,0,0,0);
00305     DocView* pDocView = DocView::GetSelected();
00306     ERROR2IF(pDocView == NULL, BoundRect, 
00307              "No selected DocView in OpPenHandles::GetHandlesRect()");
00308 
00309     // Find the Rect around the drag blobs if there is any, otherwise return that bbox
00310     // of the start pos.
00311 
00312     OSRenderRegion::GetBlobRect(pDocView->GetViewScale(), TrackEnd, BT_SELECTEDLARGEST, &BoundRect);
00313     DocRect BlobRect;
00314     OSRenderRegion::GetBlobRect(pDocView->GetViewScale(), GhostEnd, BT_SELECTEDLARGEST, &BlobRect);
00315     BoundRect = BoundRect.Union(BlobRect);
00316     return BoundRect;
00317 }

DocCoord OpPenHandles::GetMidHandle  )  const [protected]
 

Definition at line 259 of file penedit.cpp.

00260 {
00261     return MidPoint;
00262 }

DocCoord OpPenHandles::GetTrackHandle  )  const [protected]
 

Return the private track handle coordinate for reference by none inclass code.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/9/94
Parameters:
- [INPUTS]
The current track handle coordinate [OUTPUTS]

Definition at line 249 of file penedit.cpp.

00250 {
00251     return TrackEnd;
00252 }

BOOL OpPenHandles::HasMouseMoved DocCoord OriginalPoint,
DocCoord PointerPos,
double  threshold = 2
[protected]
 

Checks to see whether two coordinates are the same. The current test also checks for movement of less than two pixels in the scaled view. If the mouse has moved less than threshold*ScaledPixelSize then the points are considered equivalent.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/9/94 Inputs OriginalPoint = usually the last mouse position recorded PointerPos = usually the current mouse position to check threshold = a value to multiply the scaled pixel size for the view by.

Definition at line 551 of file penedit.cpp.

00552 {
00553     if (OriginalPoint==PointerPos)
00554         return FALSE;
00555 
00556     INT32 dist = (INT32)(OriginalPoint.Distance(PointerPos)+0.5);
00557     
00558     FIXED16 ScaledPixelWidth,
00559             ScaledPixelHeight;
00560     GetWorkingView()->GetScaledPixelSize(&ScaledPixelWidth, &ScaledPixelHeight);
00561 
00562     INT32 PixWidth  = ScaledPixelWidth.MakeLong();
00563     INT32 PixHeight = ScaledPixelHeight.MakeLong();
00564 
00565     PixWidth    = (INT32)(PixWidth*threshold+0.5);
00566     PixHeight   = (INT32)(PixHeight*threshold+0.5);
00567 
00568     INT32 range;
00569     (PixWidth<PixHeight) ? (range=PixHeight) : (range=PixWidth);
00570 
00571     return (dist>range);
00572 }   

void OpPenHandles::RecalcHandles DocCoord  DragPos,
BOOL  constrain
[protected]
 

Recalc handles, given a new drag position which is generally following the mouse pointer, will work out the relative positions of the drag handles. The drag handles can be made to follow the drag position absolutely, or reletively dependent on their start positions.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/9/94
Parameters:
DragPos = New position to take as the drag position [INPUTS] constrain = TRUE the constrain the handle positions

Definition at line 336 of file penedit.cpp.

00337 {
00338 
00339     // Recalculate the position of the handle which is following the
00340     // mouse.
00341 
00342     DocCoord Constrain = DragPos;
00343     if (constrain)
00344         DocView::ConstrainToAngle(MidPoint, &Constrain);
00345 
00346     if (Hflags.TrackPointMoves)
00347             TrackEnd=Constrain;
00348     else if (Hflags.TrackPointSpins)
00349     {
00350         double Glen = TrackEnd.Distance(MidPoint);
00351         double Dlen = Constrain.Distance(MidPoint);
00352         DocCoord direction;
00353         direction.x = Constrain.x - MidPoint.x;
00354         direction.y = Constrain.y - MidPoint.y;
00355         if (Dlen!=0)
00356         {
00357             double ndx = direction.x / Dlen;
00358             double ndy = direction.y / Dlen;
00359             TrackEnd.x = MidPoint.x + (INT32)(Glen*ndx);
00360             TrackEnd.y = MidPoint.y + (INT32)(Glen*ndy);
00361         }
00362     }
00363 
00364     // Recalc the position of the handle opposite, the track handle accross
00365     // the midpoint.
00366 
00367     if (Hflags.GhostPointMoves)
00368     {
00369         GhostEnd.x = MidPoint.x - (Constrain.x - MidPoint.x);
00370         GhostEnd.y = MidPoint.y - (Constrain.y - MidPoint.y);
00371     }
00372     else if (Hflags.GhostPointSpins)
00373     {
00374         // if we're spinning, the ghost point will remain a set distance
00375         // from the midpoint, but just spin around coincident with
00376         // the drag pos.
00377         double Glen = GhostEnd.Distance(MidPoint);
00378         double Dlen = Constrain.Distance(MidPoint);
00379         DocCoord direction;
00380         direction.x = Constrain.x - MidPoint.x;
00381         direction.y = Constrain.y - MidPoint.y;
00382         if (Dlen!=0)
00383         {
00384             double ndx = direction.x / Dlen;
00385             double ndy = direction.y / Dlen;
00386             GhostEnd.x = MidPoint.x - (INT32)(Glen*ndx);
00387             GhostEnd.y = MidPoint.y - (INT32)(Glen*ndy);
00388         }
00389     }
00390 
00391 }

void OpPenHandles::RenderHandles  )  [protected]
 

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:
26/9/94

Definition at line 406 of file penedit.cpp.

00407 {
00408     DocRect Rect = GetHandlesRect();
00409     RenderRegion* pRegion = DocView::RenderOnTop( &Rect, StartSpread, ClippedEOR );
00410     while ( pRegion )
00411     {
00412         UpdateHandles(pRegion);
00413         pRegion = DocView::GetNextOnTop(NULL);
00414     }   
00415 }

void OpPenHandles::RenderTestRect DocRect  Rect,
Spread pSpread,
StockColour  colour
[protected]
 

Render a black rectangle. Useful for checking render regions and clipping.

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

Definition at line 586 of file penedit.cpp.

00587 {
00588     if (Error::IsUserName("Mike"))
00589     {
00590         TRACE( _T("RectLox=%d\n"),Rect.lo.x);
00591         TRACE( _T("RectLoy=%d\n"),Rect.lo.y);
00592         TRACE( _T("RectHix=%d\n"),Rect.hi.x);
00593         TRACE( _T("RectHiy=%d\n\n"),Rect.hi.y);
00594     }
00595 
00596     RenderRegion* pRegion = DocView::RenderOnTop( &Rect, pSpread, ClippedEOR );
00597     while ( pRegion )
00598     {
00599         pRegion -> SetFillColour(colour);
00600         pRegion -> DrawRect(&Rect);
00601         pRegion = DocView::GetNextOnTop(NULL);
00602     }
00603 }

void OpPenHandles::SetDragHandles HandleFlags  HandFlags,
DocCoord  Click,
DocCoord  Drag,
DocCoord  Ghost,
Spread pSpread
[protected]
 

Set up the initial positions of the drag handles. Note, the handles contain their own coordinates of where they think they are. These are separate from the drag mouse position. This allows the handles to represent a relation to the drag point and not an absolute position.

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

Definition at line 503 of file penedit.cpp.

00508 {
00509     StartMousePos = Click;
00510     CurrentMousePos = Click;
00511     StartSpread = pSpread;
00512     Hflags = HandFlags;
00513     SetHandleEnds(Click, Drag, Ghost);
00514 }

void OpPenHandles::SetHandleEnds DocCoord  ClickPos,
DocCoord  DragPos,
DocCoord  GhostPos
[private]
 

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

Definition at line 476 of file penedit.cpp.

00477 {
00478     MidPoint = ClickPos;
00479     TrackEnd = DragPos;
00480     GhostEnd = GhostPos;
00481 }

void OpPenHandles::UpdateHandles RenderRegion pRegion  )  [protected]
 

Render some drag control handles as the mouse moves around. These will spin around an anchor point. Their appearence and positioning is set by the flags variable hflags.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/9/94
Parameters:
pRegion = Pointer to a region to draw into [INPUTS]
See also:
Hflags

Definition at line 433 of file penedit.cpp.

00434 {
00435     pRegion->SetLineColour(COLOUR_BEZIERBLOB);
00436     pRegion->SetFillColour(COLOUR_TRANS);
00437     pRegion->DrawBlob(MidPoint, BT_SELECTED);
00438 
00439     if (TrackEnd != MidPoint)
00440     {
00441         pRegion->SetLineColour(COLOUR_BEZIERLINE);
00442         pRegion->SetFillColour(COLOUR_TRANS);
00443 
00444         if (Hflags.RenderTrackEnd && Hflags.RenderGhostEnd)
00445             pRegion->DrawLine(TrackEnd, GhostEnd);
00446         else
00447         {
00448             if (Hflags.RenderTrackEnd)
00449                 pRegion->DrawLine(TrackEnd,MidPoint);
00450             if (Hflags.RenderGhostEnd)
00451                 pRegion->DrawLine(GhostEnd,MidPoint);
00452         }
00453 
00454         pRegion -> SetLineColour(COLOUR_TRANS);
00455         pRegion -> SetFillColour(COLOUR_UNSELECTEDBLOB);
00456 
00457         if (Hflags.RenderTrackEnd)
00458             pRegion -> DrawBlob(TrackEnd, BT_UNSELECTED);
00459         if (Hflags.RenderGhostEnd)
00460             pRegion -> DrawBlob(GhostEnd, BT_UNSELECTED);
00461 
00462     }
00463 }


Member Data Documentation

DocCoord OpPenHandles::CurrentMousePos [protected]
 

Definition at line 254 of file penedit.h.

DocCoord OpPenHandles::GhostEnd [private]
 

Definition at line 262 of file penedit.h.

HandleFlags OpPenHandles::Hflags [protected]
 

Definition at line 251 of file penedit.h.

DocCoord OpPenHandles::MidPoint [private]
 

Definition at line 261 of file penedit.h.

DocCoord OpPenHandles::StartMousePos [protected]
 

Definition at line 253 of file penedit.h.

Spread* OpPenHandles::StartSpread [protected]
 

Definition at line 255 of file penedit.h.

DocCoord OpPenHandles::TrackEnd [private]
 

Definition at line 260 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