#include <paths.h>
Public Member Functions | |
| Path () | |
| constructor - just sets a few things to sensible values | |
| ~Path () | |
| Destructor - releases the memory that the path has been using to store coords in. | |
| BOOL | CopyPathDataFrom (Path *SrcPath) |
| Copy the coords, verbs and flags from the SrcPath to this path. You must already have initialised this path by calling Path::Initialise(). Pass it an Initial size big enough the hold the path you want to copy. | |
| BOOL | CopyPathDataFrom (DocCoord *Coords, PathVerb *Verbs, INT32 NumCoords, BOOL Filled=FALSE, BOOL Stroked=TRUE) |
| Copy the specified coords and verbs to this path. The path's flags will be the defaults as specified in the constructors. You must already have initialised this path by calling Path::Initialise(). Pass it an Initial size big enough to hold the path you want to copy. | |
| BOOL | CreatePathFromDocRect (DocRect *pRect) |
| Creates a filled path from a given DocRect. | |
| BOOL | Initialise (INT32 InitialSize=24, INT32 BlockSize=12) |
| Allocates memory in the path for the three arrays - The Verbs, Coordinates and the Flags. | |
| BOOL | FindStartOfPath () |
| Sets Pos to the first element in the path. | |
| void | FindStartOfSubPath () |
| Searches backwards from the current position until it finds the start of the sub path that the current position is in. | |
| void | FindStartOfSubPath (INT32 *Index) const |
| Searches backwards from the current position from Index until it find the start of the subpath (always a moveto). | |
| void | FindEndOfSubPath () |
| Searches forwards until it finds the end of the current sub-path. ie pos will point at the last element in the sub path. | |
| void | FindEndOfSubPath (INT32 *Index) const |
| Searches forwards until it finds the end of the current sub-path. ie Index will point at the last element in the sub path. | |
| void | FindEndElOfSubPath (INT32 *Index) const |
| Searches forwards until it finds the last element of the current sub-path. ie 0 1 2 3 {MT,CT,CT,CT} => Index = 3. See Also: FindEndOfSubPath (Note equivelent). | |
| void | ExpandRange (INT32 *start, INT32 *end, INT32 num) |
| given the region [*start, *end] expand the region in both directions by num elements. The region will not be expanded beyond its outer limits described by the set {moveto,.....,endofsubpath}. | |
| BOOL | FindNext () |
| Finds the next path element in this path. The position will become invalid if you try to search past the start of the path. This can be checked by using Pos->IsValid. | |
| BOOL | FindNext (INT32 *Index) const |
| Finds the next path element in this path. The position will become invalid if you try to search past the start of the path. This can be checked by using Pos->IsValid. | |
| BOOL | FindPrev () |
| Finds the prev path element in this path starting the search from CurrentPos. | |
| BOOL | FindPrev (INT32 *Index) const |
| Finds the previous path element in this path starting from the value (index). | |
| BOOL | FindPrevEndPoint (INT32 *index) const |
| Finds the previous path endpoint in this path. | |
| BOOL | FindNextEndPoint (INT32 *index) const |
| Finds the next path endpoint in this path. | |
| BOOL | GetSubPathEnds (DocCoord *start, DocCoord *end) |
| This function returns whether the path is open or closed. This is independent of the IsFilled flag, because some programs allow open paths to be filled. Basically, if there's no gap in the subpath, it's closed, otherwise it's open. These are the same rules as ArtWorks followed. Initial implementation just scans the subpath and checks the last element in the subpath. | |
| BOOL | FindNearestPoint (DocCoord pos, UINT32 flags, INT32 *position) |
| This function searches for a point in the path which is both selected and lies inside the largest blob bounding rectangle surrounding 'pos'. Points checked for are as follows... if ENDPOINTS is set check all selected endpoints in this path. if CONTROLPOINTS is set check all control points lying directly next to selected endpoints The rules are that control points are only enabled when a single end point is selected and hence a maximum of 2 control points will be checked. If any of these points are close enough to be clicked on, the function returns TRUE, with position holding the index to the point that was clicked. | |
| BOOL | PointCloseToLine (DocCoord pos, INT32 *position) |
| This function takes the coordinate pos, and sees if it is close to a line (close enough to drag the line around). It returns TRUE if the point is close enough, and position is an index to the element that it was closest to. | |
| BOOL | ClosestSelectedEndpoint (DocCoord pos, INT32 *position, double *distance) |
| This function finds the closest selected line end to the cursor position passed in. If the path has no selected line ends, the function returns FALSE. | |
| BOOL | FindNextSelected (INT32 *Index) |
| Searches the point set {*index, usedslots-1} for a selected end point and returns its index if found. | |
| BOOL | FindSelectionLimits (INT32 index, INT32 *p, INT32 *q) |
| Finds the next connected region of selected control handles. | |
| INT32 | FindOppositeControlPoint (INT32 ThisIndex) |
| Given a bezier control point, this function returns the index of the control point that is opposite this one (with an endpoint between). This routine takes closed paths into account. | |
| INT32 | FindPrevControlPoint (INT32 position) |
| This routine will scan back from an endpoint to find the attached bezier control point. It takes account of closed and open paths and complex paths, and will wrap around the path if necessary. | |
| INT32 | FindNextControlPoint (INT32 position) |
| This routine will scan forwards from an endpoint to find the attached bezier control point. It takes account of closed and open paths and complex paths, and will wrap around the path if necessary. | |
| double | SqrDistanceToPoint (const DocCoord pt, INT32 *NearEl, double *mu) |
| Finds the distance to the closest point on the path. For efficiency it does not evaluate the closest point. Use this routine in conjunction with ClosestPoint to find the actual closest point. | |
| DocCoord | ClosestPointTo (const double t, const INT32 index) |
| This function returns the point at which the closest distance on the path occurs. | |
| BOOL | IsPointCloseTo (const DocCoord ICoord, INT32 range, INT32 *NearElement, double *mu) |
| This routine can be used to determin whether a point is close enough to a path to allow some action to occur. The range input parameter can be used to determin the size of the sensitive area. | |
| double | SqrLength () |
| Find the length of a path in millipoints. The length is calculated by flattening the path and finding straight line segment lengths and so is a discrete numeric approximation to a line integral. | |
| double | GetPathLength (double dFlatness=64.0) |
| Find the length of a path in millipoints. | |
| double | DistReparameterise (const double sqrdist, INT32 *Element) |
| DocCoord | ConvSqrDistToCoord (const double sqrdist) |
| Finds the coordinate which is dist units along 'this' path. | |
| INT32 | BreakInTwo (Path *pChildPath) |
| Tests a path to see if it is valid. This is only built into DEBUG versions of Camelot so always surround calls to it with an ifdef _DEBUG block. If the path is not valid in some way, this function will dump an explanation to the debug terminal and return FALSE.This function will attempt to break the current path at its first selected point. All selected points should still be in place in both parent and child. | |
| INT32 | NumSplinters () |
| Returns the number of splinters a selected path will be broken into when calls to BreakPath is called. Splinters include opened subpaths, ie if the algorithm will open a closed subpath, this is classed as a spinter along with breaking a path in two. | |
| BOOL | DistanceTo (INT32 index, double t, double *distance, double dFlatness=64.0) |
| This function takes a description of a point lying on a path. The point is described by (i,t) where i is the index of the element t lies in, and t is a parametric variable 0<=t<=1. The function calculates the distance along this path to the point described by (i,t). This routine complements SqrDistanceToPoint() which calculates the pair (i,t) for a given coordinate close to the path. | |
| BOOL | DistanceTo (DocCoord Coord, double *dist, double dFlatness=64.0) |
| This function takes as input a coordinate (usually a mouse click point). It will calculate the closest point on the path to this coordinate and return the distance along the path from its start point to this coordinate. | |
| BOOL | SplitAtPoint (const DocCoord &SplitPoint, INT32 *SplitAt, INT32 *NewElements) |
| This function takes a coordinate (typically not on but) close to this path and splits the path at a calculated point on the path which happens to be closest to the input coord. By Split I mean a new coordinate in will appear in the path, but the path will not have changed its shape in anyway. | |
| BOOL | GetPointAtDistance (MILLIPOINT Distance, DocCoord *pPoint, double *pTangent=NULL, UINT32 *pPressure=NULL) |
| Gets the coordinate of a point a certain distance along this path. | |
| BOOL | GetDistanceToPoint (DocCoord Point, MILLIPOINT *Distance) |
| Gets the distance along the path for a given point. | |
| void | Scale (const DocCoord dcOrigin, const double dDPI=96.0) |
| This function is called on a path specified in DocCoords, to convert it into pixel coordinates. | |
| INT32 | GetPathPosition () |
| Find out where in the path we are. | |
| void | SetPathPosition (INT32) |
| Sets the current path position to the value supplied. This represents the Coord number in the path. | |
| BOOL | IsInPath () |
| Determine if the path current position is still inside the path. | |
| PathVerb | GetVerb () const |
| finds the verb associated with the path position | |
| DocCoord | GetCoord () const |
| finds the DocCoord associated with the path position | |
| PathFlags | GetFlags () const |
| finds the flags associated with the path position | |
| PathWidth | GetWidth () const |
| Fetches width values from the path. | |
| PathTypeEnum | GetPathType () const |
| This determines whether the path is a line or a shape. It does this by seeing if it has a PT_CLOSEFIGURE bit set in its last verb. | |
| INT32 | GetPathByteLength () const |
| Calculates the length of the path in bytes. This figures includes the size of the 3 arrays (Coordinates, Verbs and Flags) only. | |
| INT32 | GetNumElements () const |
| This function counts the number of elements in the path. This ignores MoveTos, hence giving you the total number of visible path elements (i.e. all the lines and curves). | |
| INT32 | GetNumCoords () const |
| This returns the number of coordinates that make the path up. | |
| INT32 | GetNumEndPoints () const |
| Goes through the path and counts all open ends in the path. For example, a straight line has 2 open ends, a closed shape has no open ends and a complex path could have any number of open ends. You should use this function before calling GetAllOpenEnds that will fill an array for their coords for you. | |
| INT32 | GetAllOpenEnds (INT32 MaxElements, DocCoord *EndCoords) const |
| Goes through the path and copies the coordinates of all the Open ends of the path into the array, until MaxElements elements have been added to the array. Call GetNumEndPoints to find out how big to make your array in the first place. | |
| INT32 | GetNumSelEndPoints () const |
| determine how many selected endpoints there are within this path. Useful indirectly for finding whether there's a subselection. | |
| INT32 | GetNumSubpaths () const |
| Gets the number of subpaths in this path. | |
| DocRect | GetBoundingRect () const |
| Calculates the bounding rectangle of the paths coordinates. This is calculated on the fly, so don't over use it. | |
| DocRect | GetBlobRect () const |
| Calculates the bounding rectangle of the paths coordinates expanded by the current blob size. This is calculated on the fly, so don't over use it. | |
| BOOL | GetTrueBoundingRect (DocRect *pRect, MILLIPOINT LineWidth=0, CCAttrMap *pAttrMap=NULL) |
| Calculate the bounding rectangle of a path using GDraw. | |
| DocCoord | GetEndPoint () |
| Finds the endpoint of a given path element and returns it. For MoveTos and LineTos, the point returned will be its associated coord, but for a CurveTo the last coord will be returned. | |
| DocCoord | GetControl1 () |
| Finds the first control point of a bezier. | |
| DocCoord | GetControl2 () |
| Finds the second control point of a Bezier. | |
| DocCoord * | GetCoordArray () const |
| Gives you access to the coordinate array. This array is simply a list of all the coordinates in the path, in order. This should be very useful if you need to perform transformations or other actions that effect all the coordinates. The coordinates are in the corect order for the NT PolyDraw() function handle. | |
| PathVerb * | GetVerbArray () const |
| This array holds a list of all the path elements used in the path. The structure used is the same as the NT structure and can in fact be passed striaght on to the NT PolyDraw function. The verbs must be one of the following PC_MoveTo, PC_LineTo or PC_CurveTo. LineTo and CurveTo verbs can be combined with a ClosePath Flag. | |
| PathFlags * | GetFlagArray () const |
| This array holds a set of flags for each and every coordinate in the path. These flags are used to record information specific to each coordinate, such as its selection state, to determine if it should smooth this part of the path etc. | |
| PathWidth * | GetWidthArray () |
| The array holds the width of all the points in the path. DO NOT MODIFY THE CONTENTS OF THE ARRAY. | |
| void | GetPathArrays (PathVerb **pV, DocCoord **pC=NULL, PathFlags **pF=NULL) |
| Easy way of getting the path pointers into variables. Combines three function calls into one. | |
| void | GetFlags (PathFlags *NewFlags) |
| returns all the flags for the current path position | |
| void | SetFlags (const PathFlags &NewFlags) |
| Sets the flags at the current path position to the flags provided. | |
| void | InitialiseFlags () |
| This generates a legal path flags array based on the all path verbs. It sets all flags to default values and then scans all end points setting their end point flag to TRUE. | |
| void | InitialiseFlags (const INT32 Startindex, const INT32 Len) |
| This generates a legal path flags array based on the path verbs within the specified region. It sets all flags to default values and then scans all end points setting their end point flag to TRUE. | |
| void | InitialiseFlags (PathVerb *pVerbs, PathFlags *pFlags, const INT32 Len) |
| This generates a legal path flags array based on the path verbs in pVerbs within the specified region. It sets all flags in pFlags to default values and then scans all end points setting their end point flag to TRUE. | |
| BOOL | InsertMoveTo (DocCoord p1, PathFlags *NewFlags=NULL) |
| Inserts a MoveTo element into the middle of the Path and asks for extra memory if we need it. It will return FALSE if we fail to get the memory. | |
| BOOL | InsertLineTo (DocCoord p1, PathFlags *NewFlags=NULL) |
| Inserts a LineTo into the path at the Current Path Position. | |
| BOOL | InsertCurveTo (DocCoord p1, DocCoord p2, DocCoord p3, PathFlags *NewFlags=NULL) |
| Inserts a Curve into the path at the Current Path Position. | |
| BOOL | CloseSubPath () |
| To indicate that a path is closed with a line, you should call CloseSubPath with the Current Path Position indicator somewhere inside the sub-path that you want closed. This function will adjust the verb of the last line segment in the sub-path by adding the PT_CLOSEFIGURE element into as described in the NT Prog Reference guides for the PolyDraw() function (page 304 of book 4 at last count) The Current Path Position is left on the element at the end of the subpath. | |
| BOOL | InsertSection (INT32 StartSlot, INT32 NumSlots) |
| This routine is the corollary to DeleteSection - it inserts a section into the path at a given position and a given size, but does not put any data into the path. Note that this routine is likely to move the path data around in memory, so after calling it you should re-read any pointers to the path you might have had. | |
| BOOL | AddMoveTo (DocCoord p1, PathFlags *NewFlags=NULL) |
| Adds a new MoveTo to the end of the path. | |
| BOOL | AddLineTo (DocCoord p1, PathFlags *NewFlags=NULL) |
| Adds a new LineTo to the end of the path. | |
| BOOL | AddCurveTo (DocCoord p1, DocCoord p2, DocCoord p3, PathFlags *NewFlags=NULL) |
| Adds a Curve to the end of the path. | |
| BOOL | AddCurveTo (DocCoord p1, PathFlags *NewFlags=NULL) |
| Adds a straight line version of a curve to the end of the path. The control points are positioned 1/3 and 2/3 along the line between its end points. | |
| BOOL | DeleteSection (INT32 StartSlot, INT32 NumSlots) |
| Deletes sections out of the middle of the path. Used by DeleteElement and for Deleting sub paths etc. | |
| BOOL | DeleteElement () |
| Deletes the element at the Current Path Position. May free some memory if the path gets to have too much unused space in the path. The Current Path Position points at the slot before the one being deleted. | |
| BOOL | DeleteFromElement (INT32 ElementNum) |
| Deletes all the elements in the path from ElementNum to the end of the path. | |
| BOOL | ClearPath () |
| Empties the path of all its entries and tries to free up excessive amounts of unused memory left over at the end. It does keep some memory though, ready for a new path to be put into it. It also now resets CurrentPos back to zero. | |
| BOOL | ClearPath (BOOL compress) |
| Empties the path of all its entries. If compress is TRUE the routine will try to free up excessive amounts of unused memory left over at the end. It also now resets CurrentPos back to zero. | |
| BOOL | Compact () |
| Removes any extraneous unused slots in a path. It will a maximum of 2n-1 slots free where n is the size of an allocation chunk when increasing the buffer (see Path::Initialise). | |
| BOOL | IsSelected () |
| return the Selected flag for the coordinate | |
| BOOL | IsSmooth () |
| returns the Smooth flag for the Current Path Position | |
| BOOL | IsRotate () |
| returns the Rotate flag for the coordinate | |
| BOOL | IsEndPoint () |
| return the IsEndPoint flag for the coordinate | |
| BOOL | IsSubSelection () |
| determine if the path has a subselection | |
| BOOL | IsNearOpenEnd (const DocRect &BlobRect, INT32 *SlotNum) |
| Determines if the Coordinate is near any of the path open ends. This function looks through all the open ends in complex paths and returns TRUE if any of them are near the TestCoord. | |
| BOOL | IsOpenEnd (const INT32 index) |
| Tests to see if the index provided specifies either the first or last element in an open subpath. ie the index is a true end point. | |
| BOOL | IsComplexPath () |
| Tests to see if the path is a complex path (ie it has multiple sub-paths). | |
| BOOL | IsIsometric (const Path &OtherPath, Matrix *pTransform, const double &Tolerance=1.0) const |
| Determines whether two paths are isometric. In this context, isometric does not include true isomtric paths with different starting points. This can then be used to provide a transformation of this path, resulting in the given otherPath. | |
| INT32 | CalcCRC () |
| Calculates a cyclic redundancy check value for a path. This CRC is invariant under translation only. It can be used to determine whether a new path matches that of an old path whose CRC we already know, whether the new path has been translated or not. | |
| INT32 | CalcRegionCRC (const INT32 StartIndex, const INT32 EndIndex) |
| Calculates a cyclic redundancy check value for a path region. This CRC is only invariant under translation. It can be used to determine whether a new path matches that of an old path whose CRC we already know, whether the new path has been translated or not. | |
| INT32 | CalcSelectedCRC () |
| Calculates a cyclic redundancy check value for a paths selected coordinates. This CRC is invariant under translation only. It can be used to determine whether a new path matches that of an old path whose CRC we already know, whether the new path has been translated or not. | |
| INT32 | CalcSelPointsCRC (const INT32 StartIndex, const INT32 EndIndex) |
| Calculates a cyclic redundancy check value for a paths selected coordinates. This CRC is invariant under translation only. It can be used to determine whether a new path matches that of an old path whose CRC we already know, whether the new path has been translated or not. | |
| XLONG | CalcArea () |
| Calculate the area of this path. | |
| INT32 | ComparePathToPath (Path *pComparePath, BOOL QuickCheck=TRUE) |
| Compares athis path to a passed in path. It firswt does a quick check on the number of coords and if they are equal does a more thoughour check on the verb array and coord array. | |
| void | DumpPath () |
| Dumps the whole path out to the debug terminal. | |
| void | GetDebugDetails (StringBase *Str) |
| Dumps the whole path out during tree display debugging. | |
| void | RenderPathBlobs (Spread *pSpread) |
| Draws all the selection blobs for a path. Useful for putting the blobs on or taking them back off again. This goes into its own RenderOnTop loop and calls RenderPathBlobs(RenderRegion* pRender). | |
| void | RenderPathBlobs (RenderRegion *pRender) |
| Draws all the selection blobs for a path. Useful for putting the blobs on or taking them back off again. | |
| void | RenderPathControlBlobs (Spread *Spread, INT32 EndPtIndex) |
| Draws the control points selection blobs for an endpoint on a path. Used by RenderPathBlobs and also the Bezier tool. This goes into its own RenderOnTop loop. | |
| void | RenderPathControlBlobs (RenderRegion *pRender, INT32 EndPtIndex) |
| Draws all the control points selection blobs for a path. Used by RenderPathBlobs and also the Bezier tool. | |
| void | RenderPathSelectedControlBlobs (Spread *pSpread, BOOL Removing=TRUE) |
| Draws all the control points selection blobs for an entire path. If you are to change the selection flags on a path then call this to remove all selection blobs, do your change, then call this again to draw the new blobs. This goes into its own RenderOnTop loop. | |
| void | RenderPathSelectedControlBlobs (Spread *pSpread, RenderRegion *pRender) |
| Draws all the control points selection blobs for an entire path into a specified render region. Called by the above function. | |
| void | RenderSelectedControlBlobsToPendingRegions (Spread *pSpread) |
| Draws all the control points selection blobs for an entire path into all the pending render regions. | |
| void | RenderPathPenBlobs (Spread *pSpread) |
| Draws all the selection blobs and pen blobs for a path. Useful for putting the blobs on or taking them back off again. | |
| void | RenderPathPenBlobs (RenderRegion *pRegion) |
| Draws all the selection blobs and pen blobs for a path. Useful for putting the blobs on or taking them back off again. | |
| void | DrawBlob (RenderRegion *, const DocCoord &, BOOL) |
| Draws a single blob, either selected or un-selected. | |
| void | DrawControlBlob (RenderRegion *, const DocCoord &) |
| Draws a blob for a Bezier control point. | |
| void | DrawControlLine (RenderRegion *, const DocCoord &, const DocCoord &) |
| Draws a line from the Bezier control point to its endpoint. | |
| void | ClearSubSelection () |
| Goes through the path and sets all the IsSelected flags to FALSE, clearing any selected control points in the path. | |
| void | SetAllSubSelection () |
| Goes through the path and sets all the IsSelected flags to TRUE, also selecting all control points in the path. | |
| void | EnsureSelection (BOOL UseStarts) |
| Goes through the path ensuring that the selection status of the ends/starts of subpaths equal the selection state of the start/ends of that subpath Also selects/deselectes control points as appropiate. | |
| void | SmoothCurve (BOOL SetRenderFlags=FALSE, BOOL SnapEnds=FALSE, INT32 SnapIndex=0) |
| Smooths the path on the areas that have the IsSmooth flag set to TRUE. This can change any or all of the path. | |
| void | CalcDoubleCurve (DocCoord &, DocCoord &, DocCoord &, DocCoord *, DocCoord *) |
| Calculates the position of the two control points on either side of p2, using the position of the coords of either side of it to help (p1 & p3). | |
| void | CalcPointCurve (DocCoord &, DocCoord &, DocCoord &, DocCoord *) |
| Calculates the position of the control point adjacent to p2 between p2 and p3, using the position of the coords of either side of it to help (p1 & p3). | |
| void | CalcPointLine (DocCoord &, DocCoord &, DocCoord &, DocCoord *) |
| Calculates the position of the control point that appears after p2, which is part of the curve ending at p3. The control point should be colinear with p1 & p2 and 1/3 the distance between p2 & p3 from p2! | |
| void | CalcPointEnd (DocCoord &, DocCoord &, DocCoord *) |
| Calculates the position of the last control point in the sub-path. | |
| void | CalcRotate (DocCoord &, DocCoord *, DocCoord *, DocCoord &) |
| void | Reverse () |
| Reverses this path, so that it is rendered and traversed etc in the other direction. This involves reversing the order of all the coords etc in the path. | |
| void | ReverseSection (INT32 StartSlot, INT32 SubPathLen) |
| Reverses the direction of the section of the path specified. This is typically used to reverse subpaths of a complex path. It is also called by Reverse, to reverse the entire path. | |
| void | TryToClose () |
| Tries to close the path. If the start coord and the end coord are the same, it will close the path with a PT_CLOSEFIGURE and set the IsFilled flag. It searches all the sub-paths in the path and if any of them are closed, the whole path is marked as filled. | |
| void | RotateElementsLeft (const INT32 Start, const INT32 End, INT32 Rotate) |
| Rotates the specified elements in a path by the number of positions indicated. Elements will be rotated from right to left. | |
| BOOL | MergeTwoPaths (const Path &Other) |
| Combines the two paths into a single complex path. | |
| BOOL | MergeTwoPaths (DocCoord *OtherCoords, PathVerb *OtherVerbs, PathFlags *OtherFlags, INT32 Length, BOOL Filled) |
| Appends the data in the three given arrays to the arrays in this path. | |
| BOOL | SplitAtPoint (const DocCoord SplitPt, INT32 *SplitElement, UINT32 *NumElements, PathVerb *Verbs, DocCoord *Coords) |
| This function finds the element (line or curve) on which the closest point to SplitPt occurs. A parameter t describes the point on this element and is used to split the element into two distinct pieces. The verbs and coordinates of these pieces are returned to the caller in the output lists. NumElements will describe how many path components have been created and stored in the lists This will be a value of 2 for lines and 6 for curves. | |
| BOOL | ChangeStartElement (INT32 StartIndex) |
| This will rotate the path so that the element that was at StartIndex is now at index 0. You should only call this for closed paths that don't contain subpaths. | |
| void | Translate (const INT32 x, const INT32 y) |
| Translate all coordinate within 'this' path. | |
| void | Translate (const DocCoord &coord) |
| Translate all coordinate within 'this' path. | |
| INT32 | ClipPathToPath (const Path &Src, Path *const pDest, UINT32 Flags, UINT32 Tolerance=100, double SrcFlatness=750.0, double ClipFlatness=750.0) |
| This is an interface to Gavin's ClipPathToPath. | |
| BOOL | StrokePathToPath (MILLIPOINT LineWidth=250, LineCapType LineCap=LineCapButt, JointType JoinStyle=MitreJoin, DashType *pDash=NULL, Path *pDest=NULL, double Flatness=200.0, BOOL Close=FALSE) |
| Strokes the path, and places result in pDest. If pDest == NULL, the result is placed back in this path. | |
| double | CalculateFlatnessValueFromPath (double DividerValue=375.0, double LowerLimit=1.0, double UpperLimit=375.0) |
| To calculate a suitable flatness value to be used with Contouring, Clipping and Stroking. The value is based on the actual size of the paths dimensions. | |
| INT32 | InitializeContourValues (UINT32 Width, JoinStyles JoinS=JOIN_ROUND, BOOL IsAnOuterContour=TRUE, double Flatness=200.0, BOOL ClosePath=TRUE, BOOL UseContourMode=TRUE, CapStyles CapS=CAPS_ROUND, UINT32 MitreLimit=751941) |
| INT32 | GetContourForStep (Path *pDest, double StepValue=1.0) |
| void | ClearNeedToRender () |
| Sets the NeedToRender flags on all of the path elements to FALSE. | |
| BOOL | CopySectionFrom (const Path &Other, INT32 StartIndex, INT32 NumToCopy) |
| Copies a specified section from a path to the end of this one. | |
| BOOL | CopySectionTo (Path *Dest, INT32 StartIndex, INT32 NumToCopy) |
| Copies a specified section from this path to the end of another path. | |
| BOOL | MergeSectionFrom (INT32 DestinPos, const Path &Source, INT32 SourcePos, INT32 Length) |
| Copies a specified section from a source path to a specified position in this path. | |
| BOOL | MergeSectionTo (INT32 SourcePos, INT32 Length, Path *Destin, INT32 DestinPos) |
| Copies a specified section from this path to a specific position within another path. A gap is created if necessary to copy the data into. | |
| BOOL | MakePathFromSection (const INT32 Start, const INT32 Length, Path *pDestin) |
| Copies a specified section from this path to a specific position within another path. A gap is created if necessary to copy the data into. | |
| BOOL | MakePathFromSubPath (const INT32 lSubpathIndex, Path *pDestin) |
| Makes a subpath into a path in its own right. | |
| BOOL | CloneFrom (const Path &Other) |
| Replace the data within this path with that of Other path. | |
| BOOL | SimpleJoin (Path *Other, INT32 *, BOOL *, BOOL *Reversed=NULL) |
| Joins two paths to form a new, longer path. Both the paths invloved are simple (ie not complex). | |
| BOOL | ComplexJoin (Path *Other, INT32 *, BOOL *) |
| Tries to Join the New Path (must be simple) to a complex path. | |
| BOOL | ComplexToSameComplexJoin (Path *Other, INT32 *, BOOL *) |
| This path is assumed to be complex and Other is assumed to be a simple path. The start and end point of the Simple Path must be the same as the start or end point of one of the sub paths of this complex path. The function Moves the two sub paths that are touched by the simple path to the end of the path, and inserts the simple path between them. This means that the two touched sub-paths and the new simple path are combined into a single sub path. This may also mean that this complex path is no longer complex. | |
| BOOL | FindJoinedSubPathInfo (const DocCoord &JoinCoord, INT32 *Start, INT32 *Length, BOOL *JoinAtStart) |
| This function searchs the path, compareing JoinCoord with the start and end points of each of the Sub-paths in the path. If it is the same as one of the start or end points, then the output params are filled and TRUE is returned. | |
| BOOL | JoinToAnother (Path *OtherPath, INT32 MainIndex, INT32 OtherIndex) |
| This routine is used to join the end of a line to the end of another line. It will cope with the various possiblities: That both subpaths are in the same complex paths, that one or other of the subpaths are in different complex paths, and that one of the paths might need reversing. The other path is left untouched. This path will contain all subpaths from that one. This routine assumes that the two subpaths are different - it will not join the start and end of the same subpath. | |
| BOOL | RetroReplaceSection (INT32 StartSlot, INT32 NumSlots, Path *NewPath, BOOL KeepStart) |
| Deletes all the elements in the path from StartSlot to StartSlot+NumSlots and then inserts the whole of NewPath into the hole. If the hole is not big enough, then it is made bigger and if it is too big, then it is shrunk. | |
| BOOL | SmoothRegions (const double error, BOOL smoothall, BOOL reselect) |
| Given a path, search for regions of interest and smooth these regions. Regions are defined by sequences of connected selected points ie. | |
| BOOL | SmoothSection (INT32 index1, INT32 *index2, const double error, INT32 selection) |
| Given a path, search for regions of interest and smooth these regions. Regions are defined by (start/end) selected points with any number of none selected points inbetween. If smoothall is true or there are no selected regions within the path, the whole path is smoothed. You should call this function with a path which you do not mind being corrupted, ie changed in an unpredictable way. The function may successfully smooth a number of regions within the path, then fail on one particular region. The result will be a path with m out of n regions smoothed.Smooth a path between the given section delimited by [index1,index2]. | |
| BOOL | Smooth (const double error) |
| Smooth a path, using the fitcurve function, which may turn out to be NOT the way to do it but I'll give it a try. You should generally call this funcion with a copy of the path you want to smooth. This smooth function will corrupt the path if it fails. Call the function SmoothSection() describing your entire path if you wish to smooth a path without corrupting anything on failure. | |
| BOOL | Quantise (const double threshold, Path *pOutput) |
| Quantise a path. All curves within the path will be approximated by straight lines. pOutput may point at 'this' path ie a path can be quantised to itself. If the quantising fails for some reason, the output path will be unaffected EVEN if you're quantising a path to itself. Note, Quantising differs from flattening in that it will approximate straight lines within a path, generating n colinear points for each line it meets. Whereas flattening does nothing with lines. | |
| BOOL | Flatten (const double flatness, Path *pOutput) |
| Flatten a path. All curves within the path will be approximated by straight lines. pOutput may point at 'this' path ie a path can be flattened to itself. If the flattening fails for some reason, the output path will be unaffected even if you are flattening a path to itself. | |
| BOOL | CreateFlatPath (const ProcessFlags &PFlags, const double flatness, Path *pOutput) |
| Flatten a path. All curves within the path will be approximated by straight lines. pOutput may point at 'this' path ie a path can be flattened to itself. If the flattening fails for some reason, the output path will be unaffected even if you're flattening a path to itself. | |
| BOOL | MakeSpaceInPath (INT32 NumSlots) |
| Checks to see if there is already enough memory available to make the insertion and if not will try to allocate some more memory. If this works it will move the path (after the position indicated by the path class variable CurrentPos) along to make room for the correct number of slots at that point. | |
| BOOL | MakeSpaceInPath (INT32 NumSlots, INT32 Position) |
| Checks to see if there is already enough memory available to make the insertion and if not will try to allocate some more memory. If this works it will move the path after the position indicated by Position along to make room for the correct number of slots at that point. | |
| BOOL | MakeSpaceAtEnd (INT32 NumSlots) |
| Will make enough room for NumSlots unused slots at the end of the path. | |
| BOOL | OpenGap (INT32 NumSlots) |
| Will open a gap of NumSlots size in this path. The gap is positioned at CurrentPos (A path class variable). | |
| BOOL | OpenGap (INT32 NumSlots, INT32 Position) |
| Will open up a gap of NumSlots at the position Position within the path. If Position is set to the end of the path ie the same value as usedslots, no data will be moved. FALSE will ofcourse always be returned if there is not enough free space in the form of unused slots on the end of the path for the gap to open. Use MakeSpaceInPath() if you know there isn't enough room. See Also: MakeSpaceInPath, MakeSpaceAtEnd. | |
| BOOL | EnsureVolume (INT32 NumSlots) |
| This function ensures there are >= NumSlots in the path arrays. It may try to alter the size of the path arrays by increasing the number of unused slots to satisfy the request. It will never decrease the size of the arrays, if NumSlots < UsedSlots+UnusedSlots then the volume is automatically ensured. This allows path buffers to be resized ready for cloning. | |
| BOOL | ExternalArraysAdded (const INT32 Added) |
| A hidden function to adjust the number of elements in a path. This has been added by me as a last resort and should not be used by others. (Hence hidden from the documentation). It is required to cope with changes in the path data external to the path class. This occurs when doing really nasty things like moulding paths. | |
| BOOL | ExternalArraysReplaced (const INT32 Size) |
| A hidden function to adjust the number of elements in a path. This has been added by me as a last resort and should not be used by others. (Hence hidden from the documentation). | |
| BOOL | HasWidth () |
| To determine if the path has any width information. | |
| void | MapWidth (ChannelIndex) |
| Alters the mapping of the Width Information to one of the ExtraInfo channels. | |
| BOOL | InitExtraInfo (ChannelIndex) |
| Allocates memory in the path for the extra info arrays. | |
| BOOL | AddExtraInfo (ChannelIndex, INT32) |
| Adds an extra Info Value at the current path position. | |
| void | SyncExtraInfo () |
| Sets the Extra Info Ptr to the current Path Position. | |
| void | NextExtraInfo () |
| DocCoord | SmoothControlPoint (INT32 Index, BOOL StartAndEndSnapped=FALSE, BOOL JoinedToAnother=FALSE, BOOL OtherIsCurve=TRUE, const DocCoord &OtherCoord=DocCoord(0, 0)) |
| This function will handle the smoothing of a path. It is designed to take account of all the possibilities that might occur (hence the huge list of parameters). The various places where this function might be needed are:Calculates the smoothed position of a control point in a path. The smoothing is calculated based on the endpoint to which the control point is attached, and the endpoints on either side of this point. Since we are guaranteed that one of these segments is a curve (that's where the control point comes from) the other possibilities are: The curve just terminates (at the end of a path); The curve is attached to another curve; It is attached to a line; It is at the end, but the end joins the start of the same path, which could be a line or a curve; and the curve could be at the end, but snapping to a completely separate path segment which might either be a line or curve (this is what the JoinedToAnother, OtherIsCurve and OtherCoord parameters indicate. | |
| BOOL | IsSubPathClosed (INT32 Index) |
| Scans to the end of this subpath to see if it has the PT_CLOSEFIGURE flag set. | |
| BOOL | IsClosed () |
| Tells you whether all subpaths of this path are closed. | |
| BOOL | EnsureValid (BOOL *ChangesMade=NULL) |
| Will attempt to make a path into a correct state. Checks are :- 1. All subpaths must start with a MoveTo 2. Consecutive MoveTos are removed 3. Zero element paths are unrepairable 4. MoveTos at the end of the path are removed 5. Should be three BezierTos in a row, only the last can be CloseFigure 6. A LineTo to the same location as the previous point is removed. | |
| INT32 | GetUsedSlots () |
Public Attributes | |
| BOOL | IsFilled |
| BOOL | IsStroked |
Private Member Functions | |
| BOOL | InsertSectionAtEnd (const Path *Other, INT32 StartPos, INT32 NumSlots) |
| Copies a section (usually a sub-path) of a path to the end of another path. This is used extensivly to Join Paths together. If there is not enougth space in this path, then the operation will fail - It will NOT try to make the path bigger. It is up to the caller to ensure that there are sufficent UnUsedSlots in the path before calling. | |
Private Attributes | |
| INT32 | m_ContourWidth |
| JoinStyles | m_ContourJoinS |
| CapStyles | m_ContourCapS |
| double | m_ContourFlatness |
| UINT32 | m_ContourMitreLimit |
| UINT32 | m_ContourLength |
| BOOL | m_IsAnOuterContour |
| BOOL | m_DoClosePath |
| BOOL | m_UseContourMode |
| MHANDLE | VerbHandle |
| MHANDLE | CoordHandle |
| MHANDLE | FlagsHandle |
| PathExtraInfo * | ExtraInfo |
| INT32 | UnUsedSlots |
| INT32 | UsedSlots |
| INT32 | SlotAllocSize |
| INT32 | SlotInitSize |
| INT32 | CurrentPos |
Definition at line 253 of file paths.h.
|
|
constructor - just sets a few things to sensible values
Definition at line 182 of file paths.cpp. 00183 { 00184 // We do not have any memory yet 00185 UnUsedSlots = 0; 00186 UsedSlots = 0; 00187 SlotInitSize = 0; 00188 SlotAllocSize = 0; 00189 00190 // set all the handles to bad in case they are used 00191 VerbHandle = BAD_MHANDLE; 00192 CoordHandle = BAD_MHANDLE; 00193 FlagsHandle = BAD_MHANDLE; 00194 00195 // Set the path flags 00196 IsFilled = FALSE; 00197 IsStroked = TRUE; 00198 00199 // Set the current path position 00200 CurrentPos = 0; 00201 00202 // Setup the Extra Info Channels 00203 ExtraInfo = NULL; 00204 00205 #if !defined(EXCLUDE_FROM_XARLIB) 00206 // Set up the contouring variables 00207 // m_pGPC = NULL; 00208 // m_pGSC = NULL; 00209 m_ContourLength = 0; 00210 m_IsAnOuterContour = true; 00211 m_DoClosePath = false; 00212 00213 // MRH New! 00214 m_ContourWidth = 100; 00215 m_ContourJoinS = JOIN_MITER; 00216 m_ContourCapS = CAPS_BUTT; 00217 m_ContourFlatness = 200.0; 00218 00219 // Set the mitre limit to 10 shifted 16. It`s done in two parts as it can cause overflow 00220 // problems if done as one call. 00221 m_ContourMitreLimit = 10; 00222 m_ContourMitreLimit <<= 16; 00223 m_UseContourMode = TRUE; 00224 #endif 00225 }
|
|
|
Destructor - releases the memory that the path has been using to store coords in.
Definition at line 238 of file paths.cpp. 00239 { 00240 // Free the memory that the path is using to store its data in 00241 if (VerbHandle != BAD_MHANDLE) 00242 ReleaseBlock(VerbHandle); 00243 00244 if (CoordHandle != BAD_MHANDLE) 00245 ReleaseBlock(CoordHandle); 00246 00247 if (FlagsHandle != BAD_MHANDLE) 00248 ReleaseBlock(FlagsHandle); 00249 00250 if (ExtraInfo != NULL) 00251 delete ExtraInfo; 00252 /* 00253 if(m_pGPC != NULL) 00254 { 00255 delete m_pGPC; 00256 m_pGPC = NULL; 00257 } 00258 00259 if(m_pGSC != NULL) 00260 { 00261 delete m_pGSC; 00262 m_pGSC = NULL; 00263 } 00264 */ 00265 }
|
|
||||||||||||
|
Adds a straight line version of a curve to the end of the path. The control points are positioned 1/3 and 2/3 along the line between its end points.
Definition at line 2008 of file paths.cpp. 02009 { 02010 ERROR1IF( UsedSlots==0,FALSE,"No previous path elements when calling Path::AddCurveTo()" ); 02011 // set the current pos. 02012 CurrentPos = UsedSlots; 02013 02014 // Find the coord of the last point in the path 02015 DocCoord* Coords = (DocCoord*) DescribeHandle(CoordHandle); 02016 DocCoord prev = Coords[CurrentPos-1]; 02017 02018 // Create some temp coords 02019 DocCoord p1,p2; 02020 02021 // calculate the intermediary control points 02022 p1.x = (2*prev.x + p3.x)/3; 02023 p1.y = (2*prev.y + p3.y)/3; 02024 p2.x = (prev.x + 2*p3.x)/3; 02025 p2.y = (prev.y + 2*p3.y)/3; 02026 02027 return InsertCurveTo(p1,p2,p3,NewFlags); 02028 }
|
|
||||||||||||||||||||
|
Adds a Curve to the end of the path.
Definition at line 1986 of file paths.cpp. 01987 { 01988 CurrentPos = UsedSlots; 01989 return InsertCurveTo(p1,p2,p3,NewFlags); 01990 }
|
|
||||||||||||
|
Adds an extra Info Value at the current path position.
Definition at line 8215 of file paths.cpp. 08216 { 08217 ENSURE(ExtraInfo != NULL, "ExtraInfo Pointer is NULL in AddExtraInfo"); 08218 return ExtraInfo->Add(Index, ExtraValue); 08219 }
|
|
||||||||||||
|
Adds a new LineTo to the end of the path.
Definition at line 1961 of file paths.cpp. 01962 { 01963 CurrentPos = UsedSlots; 01964 return InsertLineTo(p1, NewFlags); 01965 }
|
|
||||||||||||
|
Adds a new MoveTo to the end of the path.
Definition at line 1933 of file paths.cpp. 01934 { 01935 // Sadly there is no way for the outside world to set the insert position 01936 // to the end of the path!! SetPathPosition() for instance sets the currentpos to 01937 // usedslots-1, when passed usedslots which means you can never ever call InsertLineTo 01938 // and expect a line to be added to the pathend, it will be inserted before the element 01939 // which is the last in the path. Ok so this function does the job. 01940 01941 CurrentPos = UsedSlots; 01942 return InsertMoveTo(p1, NewFlags); 01943 }
|
|
|
Tests a path to see if it is valid. This is only built into DEBUG versions of Camelot so always surround calls to it with an ifdef _DEBUG block. If the path is not valid in some way, this function will dump an explanation to the debug terminal and return FALSE.This function will attempt to break the current path at its first selected point. All selected points should still be in place in both parent and child.
Definition at line 8780 of file paths.cpp. 08781 { 08782 // Get arrays of flags,verbs and points. 08783 08784 PathFlags* Flags = (PathFlags*) DescribeHandle(FlagsHandle); 08785 PathVerb* Verbs = (PathVerb*) DescribeHandle(VerbHandle); 08786 DocCoord* Coords = (DocCoord*) DescribeHandle(CoordHandle); 08787 08788 // p,q indexes to selected point and endof(sub)path 08789 INT32 p = -1; 08790 INT32 q = -1; 08791 INT32 s = 0; 08792 08793 // vp,vq local verb holders 08794 PathVerb vp; 08795 PathVerb vq; |