OpMakeSegmentsCurves Class Reference

This class will change all the selected segments in all selected paths from lines into curves (ignoring segments that are already curves!). More...

#include <pathops.h>

Inheritance diagram for OpMakeSegmentsCurves:

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

Public Member Functions

 OpMakeSegmentsCurves ()
 OpMakeSegmentsCurves constructor - does nothing itself.

Static Public Member Functions

static BOOL Init ()
 OpMakeSegmentsCurves initialiser method.
static OpState GetState (String_256 *, OpDescriptor *)
static BOOL CarryOut (INT32, INT32, NodePath *, UndoableOperation *, ActionList *pActions)

Protected Member Functions

virtual INT32 GetProcessPathType ()
virtual INT32 GetPathType ()
virtual BOOL ProcessSegment (NodePath *pPath, INT32 *Index, INT32 PrevIndex)
 Performs the make selected segments into lines operation.

Detailed Description

This class will change all the selected segments in all selected paths from lines into curves (ignoring segments that are already curves!).

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/9/94
See also:
OpMakeSegmentsLines

Definition at line 186 of file pathops.h.


Constructor & Destructor Documentation

OpMakeSegmentsCurves::OpMakeSegmentsCurves  ) 
 

OpMakeSegmentsCurves constructor - does nothing itself.

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

Definition at line 524 of file pathops.cpp.

00525 {                              
00526 }


Member Function Documentation

BOOL OpMakeSegmentsCurves::CarryOut INT32  ,
INT32  ,
NodePath ,
UndoableOperation ,
ActionList pActions
[static]
 

Definition at line 618 of file pathops.cpp.

00620 {
00621 #ifndef STANDALONE
00622 
00623     ERROR2IF(pOp == NULL,FALSE, "Operation pointer was NULL");
00624     ERROR2IF(ThisPath == NULL,FALSE, "Path pointer was NULL");
00625 
00626     DocCoord* Coords = ThisPath->InkPath.GetCoordArray();
00627 //  PathFlags* Flags = ThisPath->InkPath.GetFlagArray();
00628     PathVerb* Verbs = ThisPath->InkPath.GetVerbArray();
00629 
00630     DocCoord    First;
00631     DocCoord    Second;
00632     PathFlags   NewFlags;
00633     NewFlags.IsEndPoint = FALSE; 
00634     NewFlags.NeedToRender = FALSE; 
00635     NewFlags.IsSelected = TRUE;
00636     NewFlags.IsSmooth = TRUE;
00637     NewFlags.IsRotate = TRUE;
00638 
00639 //  By default position the control points one-third of the way along the line between the
00640 //  first and second endpoints (changing the line into an identical line).  At the end of the 
00641 //  make curves operation we can go round and smooth the entire path.
00642     First.x = Coords[PrevPos].x-(Coords[PrevPos].x-Coords[Count].x)/3;    
00643     First.y = Coords[PrevPos].y-(Coords[PrevPos].y-Coords[Count].y)/3;
00644     Second.x = Coords[PrevPos].x-((Coords[PrevPos].x-Coords[Count].x)/3)*2;   
00645     Second.y = Coords[PrevPos].y-((Coords[PrevPos].y-Coords[Count].y)/3)*2;
00646 
00647     PathVerb EndVerb = Verbs[Count];
00648     DocCoord EndCoord = Coords[Count];
00649 
00650     ERROR2IF((EndVerb & ~PT_CLOSEFIGURE) != PT_LINETO, FALSE, "Attempt to convert a non-line to a curve!");
00651 
00652     EndVerb = ((EndVerb & PT_CLOSEFIGURE) | PT_BEZIERTO) ;
00653 
00654     // After any of these actions the path must be OK.  
00655     BOOL DoneOK  = TRUE;
00656 
00657     // Insert a curve into the path
00658     if (DoneOK)
00659     {
00660         if ((PrevPos+2) >= ThisPath->InkPath.GetNumCoords())
00661         {
00662             DoneOK = ThisPath->InkPath.AddCurveTo(First, Second, EndCoord, &NewFlags);
00663         }
00664         else
00665         {
00666             ThisPath->InkPath.SetPathPosition(PrevPos+2);
00667             DoneOK = ThisPath->InkPath.InsertCurveTo(First, Second, EndCoord, &NewFlags);
00668         }
00669     }
00670 
00671     // Correct the end verb
00672     if (DoneOK)
00673     {
00674         Verbs = ThisPath->InkPath.GetVerbArray();
00675         Verbs[PrevPos+4] = EndVerb;
00676     }
00677 
00678     // Now insert an action to remove the curve
00679     if (DoneOK)
00680     {
00681         Action* UnAction;           
00682         ActionCode Act;             
00683         Act = RemovePathElementAction::Init(pOp, pActions, 3, PrevPos+2, (Action**)(&UnAction));
00684         if (Act == AC_OK)
00685             ((RemovePathElementAction*)UnAction)->RecordPath(ThisPath);
00686         DoneOK = !(Act == AC_FAIL);
00687     }
00688 
00689     // Finally delete the line
00690     if (DoneOK)
00691         DoneOK = pOp->DoDeletePathSection(ThisPath, PrevPos+1, 1, FALSE);
00692 
00693     return DoneOK;
00694 
00695 #else
00696     return TRUE;
00697 #endif
00698 }

virtual INT32 OpMakeSegmentsCurves::GetPathType  )  [inline, protected, virtual]
 

Reimplemented from OpBaseConvertPathSegment.

Definition at line 198 of file pathops.h.

00198 {return PT_BEZIERTO;}

virtual INT32 OpMakeSegmentsCurves::GetProcessPathType  )  [inline, protected, virtual]
 

Reimplemented from OpBaseConvertPathSegment.

Definition at line 197 of file pathops.h.

00197 {return PT_LINETO;}

OpState OpMakeSegmentsCurves::GetState String_256 ,
OpDescriptor
[static]
 

Definition at line 558 of file pathops.cpp.

00559 {
00560       return OpBaseConvertPathSegment::BaseGetState(PT_BEZIERTO);
00561 }

BOOL OpMakeSegmentsCurves::Init void   )  [static]
 

OpMakeSegmentsCurves initialiser method.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/9/94
Returns:
TRUE if the operation could be successfully initialised FALSE if no more memory could be allocated

Errors: ERROR will be called if there was insufficient memory to allocate the operation.

See also:
-

Reimplemented from SimpleCCObject.

Definition at line 544 of file pathops.cpp.

00545 {
00546     return (RegisterOpDescriptor(   0, 
00547                                     _R(IDS_MAKECURVES),
00548                                     CC_RUNTIME_CLASS(OpMakeSegmentsCurves), 
00549                                     OPTOKEN_MAKECURVESOP,
00550                                     OpMakeSegmentsCurves::GetState,
00551                                     0,  /* help ID */
00552                                     _R(IDBBL_MAKELINES),
00553                                     0   /* bitmap ID */));
00554 }               

BOOL OpMakeSegmentsCurves::ProcessSegment NodePath pPath,
INT32 *  Index,
INT32  PrevIndex
[protected, virtual]
 

Performs the make selected segments into lines operation.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/8/95
Parameters:
pPath - points to the path to process [INPUTS] Index - index of the PT_LINETO segment to change into lines PrevIndex - index of the previous endpoint (other end of the segment to process)
Index is changed to point to the new index of the end of the segment [OUTPUTS]
Returns:
TRUE/FALSE for success/failure

Errors: -

See also:
OpBaseConvertPathSegment::Do

Reimplemented from OpBaseConvertPathSegment.

Definition at line 579 of file pathops.cpp.

00580 {
00581     // Get the path pointers
00582     PathVerb* Verbs;
00583     PathFlags* Flags;
00584     DocCoord* Coords;
00585     pPath->InkPath.GetPathArrays(&Verbs, &Coords, &Flags);
00586 
00587     // Quick check
00588     ERROR2IF(((Verbs[*Index] & ~PT_CLOSEFIGURE) != PT_LINETO), FALSE, "Unknown segment encountered");
00589     ERROR2IF(((PrevIndex+1) != *Index), FALSE, "Points between segment start and end");
00590 
00591     BOOL ok = CarryOut(*Index, PrevIndex, pPath, this, &UndoActions);
00592     *Index = PrevIndex + 3;
00593 
00594     return ok;
00595 }


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