PathExtraInfo Class Reference

Creation, manipulation and use of extra information on paths, eg. Pressure. A path will have a pointer to an instance of this class if it has some extra information associated with it. The extra info is stored as a number of channels, each of which is an array of 'PathExtraElements' (currently UINTs). These channels can then be mapped to one of the known 'provider data' types, eg, Line Width, Colour etc. More...

#include <paths.h>

List of all members.

Public Member Functions

 PathExtraInfo ()
 Constructor for PathExtraInfo class.
 ~PathExtraInfo ()
 Destructor for PathExtraInfo class.
BOOL Init (ChannelIndex, INT32)
 Allocates memory in the path for the extra info arrays.
BOOL Add (ChannelIndex, INT32)
 Adds an extra Info Value at the current path position. The value stored will be scaled so that it is between 0 and 65536.
void Sync (INT32)
 Sets the Extra Info Ptr to the current Path Postion.
void Next ()
BOOL HasWidthInfo ()
 To determine if the path has any width information.
void MapWidthInfo (ChannelIndex)
 Alters the mapping of the Width Information to one of the ExtraInfo channels.
PathWidth GetWidthInfo ()
 Get the width at the current path position.
PathWidthGetWidthArray ()
 The array holds the width of the path.

Private Member Functions

BOOL IncreaseExtraBlocks (INT32)
 Allocates more memory for extra info.
BOOL DecreaseExtraBlocks (INT32)
 De-allocates memory used for extra info.
void ShiftUpExtraInfo (INT32, INT32, INT32)
 Shifts up the ExtraInfo memory to make room for more.
void ShiftDownExtraInfo (INT32, INT32, INT32)
 Shifts down the ExtraInfo memory when it gets shrunk.
void CopyExtraInfo (PathExtraInfo *)
 Copies all the ExtraInfo from another path.

Private Attributes

MHANDLE ExtraInfoHandles [NUMEXTRACHANNELS]
FIXED16 Scaling [NUMEXTRACHANNELS]
INT32 CurrentExtraPos
ChannelIndex WidthChannel

Friends

class Path


Detailed Description

Creation, manipulation and use of extra information on paths, eg. Pressure. A path will have a pointer to an instance of this class if it has some extra information associated with it. The extra info is stored as a number of channels, each of which is an array of 'PathExtraElements' (currently UINTs). These channels can then be mapped to one of the known 'provider data' types, eg, Line Width, Colour etc.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/06/94

Definition at line 150 of file paths.h.


Constructor & Destructor Documentation

PathExtraInfo::PathExtraInfo  ) 
 

Constructor for PathExtraInfo class.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/06/94
Parameters:
- [INPUTS]
Returns:
-

Errors: -

Definition at line 8350 of file paths.cpp.

08351 {
08352     CurrentExtraPos = 0;
08353     WidthChannel = CI_PRESSURE;     // Default mapping of Pressure to Width
08354 
08355     INT32 i;
08356     for (i = 0; i < NUMEXTRACHANNELS; ++i)
08357         ExtraInfoHandles[i] = BAD_MHANDLE;      // Clear all the handles.
08358 
08359     for (i = 0; i < NUMEXTRACHANNELS; ++i)
08360         Scaling[i] = 1;                         // Clear all the scaling values.
08361 
08362 // WEBSTER - markn 25/4/97
08363 // No pen stuff required in Webster
08364 // Taken out by vector stroking code Neville 2/10/97
08365 #ifdef VECTOR_STROKING
08366     // Set the Pressure scaling so that the Maximum pressure is always stored as EXTRAVALUEMAX
08367     //if ((Camelot.GetPressurePen())->IsPressureOn())
08368     //  Scaling[CI_PRESSURE] = fixed16((INT32)EXTRAVALUEMAX/((INT32)(Camelot.GetPressurePen())->GetPressureMax()));
08369 #endif // VECTOR_STROKING
08370 }

PathExtraInfo::~PathExtraInfo  ) 
 

Destructor for PathExtraInfo class.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/06/94
Parameters:
- [INPUTS]
Returns:
-

Errors: -

Definition at line 8385 of file paths.cpp.

08386 {
08387     // Scan thru all the extra channels that we know of, and release and blocks
08388     // that we have claimed.
08389     for (INT32 Index = 0; Index < NUMEXTRACHANNELS; ++Index)
08390     {
08391         // Have we claimed a block for this channel ?
08392         if (ExtraInfoHandles[Index] != BAD_MHANDLE)
08393         {
08394             ReleaseBlock(ExtraInfoHandles[Index]);
08395             TRACEUSER( "Will", _T("Released Block with Index=%d\n"),Index);
08396         }
08397     }
08398 }


Member Function Documentation

BOOL PathExtraInfo::Add ChannelIndex  Index,
INT32  ExtraValue
 

Adds an extra Info Value at the current path position. The value stored will be scaled so that it is between 0 and 65536.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/06/94
Parameters:
The channel to add to, and the value to add. [INPUTS]
Returns:
TRUE if all went well, FALSE if not

Errors: -

Definition at line 8442 of file paths.cpp.

08443 {
08444     TRACEUSER( "Will", _T("AddExtraInfo, Index=%d, Value=%d\n"),Index, ExtraValue);
08445     ENSURE(Index <= NUMEXTRACHANNELS, "Index out of range in PathExtraInfo::Add()");
08446 
08447     // get pointer to info array
08448     PathExtraElement* Info = (PathExtraElement*) DescribeHandle(ExtraInfoHandles[Index]);
08449 
08450     // Wop the info in the array at the postion coresponding to the last point inserted.
08451     Info[CurrentExtraPos] = XLONG(ExtraValue) * Scaling[Index];
08452 
08453     return TRUE;
08454 }

void PathExtraInfo::CopyExtraInfo PathExtraInfo SrcInfo  )  [private]
 

Copies all the ExtraInfo from another path.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/06/94
Returns:
-

Definition at line 8591 of file paths.cpp.

08592 {
08593     ENSURE(FALSE, "Warning. Path Extra Info lost in CopyExtraInfo()");
08594 }

BOOL PathExtraInfo::DecreaseExtraBlocks INT32  SlotsLost  )  [private]
 

De-allocates memory used for extra info.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/06/94
Returns:
TRUE is the Blocks were increase correctly.

Definition at line 8511 of file paths.cpp.

08512 {
08513     TRACEUSER( "Will", _T("DecreaseExtraBlocks, Slots=%d\n"),SlotsLost);
08514 
08515     // Scan thru all our channels and decrease their size by 'SlotsNeeded'.
08516     for (INT32 Index = 0; Index < NUMEXTRACHANNELS; ++Index)
08517     {
08518         if (ExtraInfoHandles[Index] != BAD_MHANDLE)
08519             if (!DecreaseBlock(ExtraInfoHandles[Index], sizeof(PathExtraElement)*SlotsLost))
08520                 return FALSE;
08521     }
08522     return TRUE;
08523 }

PathWidth * PathExtraInfo::GetWidthArray  ) 
 

The array holds the width of the path.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/06/94
Returns:
A pointer to an array of Path Width Information

Definition at line 8645 of file paths.cpp.

08646 {
08647     // de-reference an Extra Info array
08648     return (PathWidth*) DescribeHandle(ExtraInfoHandles[WidthChannel]);
08649 }

PathWidth PathExtraInfo::GetWidthInfo  ) 
 

Get the width at the current path position.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/06/94
Returns:
-

Definition at line 8626 of file paths.cpp.

08627 {
08628     // de-reference the Extra Info array
08629     PathExtraElement* WidthInfo = (PathExtraElement*) DescribeHandle(ExtraInfoHandles[WidthChannel]);
08630 
08631     return (PathWidth)WidthInfo[CurrentExtraPos];   
08632 }

BOOL PathExtraInfo::HasWidthInfo  ) 
 

To determine if the path has any width information.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/06/94
Returns:
TRUE if width information is available.

Definition at line 8662 of file paths.cpp.

08663 {
08664     return (WidthChannel!=-1);
08665 }

BOOL PathExtraInfo::IncreaseExtraBlocks INT32  SlotsNeeded  )  [private]
 

Allocates more memory for extra info.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/06/94
Returns:
TRUE is the Blocks were increase correctly.

Definition at line 8486 of file paths.cpp.

08487 {
08488     TRACEUSER( "Will", _T("IncreaseExtraBlocks, Slots=%d\n"),SlotsNeeded);
08489 
08490     // Scan thru all our channels and increase their size by 'SlotsNeeded'.
08491     for (INT32 Index = 0; Index < NUMEXTRACHANNELS; ++Index)
08492     {
08493         if (ExtraInfoHandles[Index] != BAD_MHANDLE)
08494             if (!IncreaseBlock(ExtraInfoHandles[Index], sizeof(PathExtraElement)*SlotsNeeded))
08495                 return FALSE;
08496     }
08497     return TRUE;
08498 }

BOOL PathExtraInfo::Init ChannelIndex  Index,
INT32  SlotInitSize
 

Allocates memory in the path for the extra info arrays.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/06/94
Parameters:
The Index of the channel to Init, and the initial size for it. [INPUTS]
Returns:
TRUE if we got all the memory we needed, FALSE if not

Errors: Can fail if it runs out of memory

Definition at line 8413 of file paths.cpp.

08414 {
08415     TRACEUSER( "Will", _T("InitExtraInfo, Index=%d\n"), Index );
08416     ENSURE(Index <= NUMEXTRACHANNELS, "Index out of range in InitExtraInfo");
08417                         
08418     if (ExtraInfoHandles[Index] != BAD_MHANDLE)
08419         return TRUE;                                // Already Initialised
08420 
08421     // Claim an initial block of memory for this Index.
08422     ExtraInfoHandles[Index] = ClaimBlock(sizeof(PathExtraElement)*SlotInitSize);
08423 
08424     // Check that the block claimed ok.
08425     return (ExtraInfoHandles[Index] != BAD_MHANDLE);
08426 }

void PathExtraInfo::MapWidthInfo ChannelIndex  Index  ) 
 

Alters the mapping of the Width Information to one of the ExtraInfo channels.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/06/94
Returns:
-

Definition at line 8609 of file paths.cpp.

08610 {
08611     ENSURE(Index <= NUMEXTRACHANNELS, "Index out of range in MapWidthInfo()");
08612     WidthChannel = Index;
08613 }

void PathExtraInfo::Next  )  [inline]
 

Definition at line 162 of file paths.h.

00162 { CurrentExtraPos++; }

void PathExtraInfo::ShiftDownExtraInfo INT32  StartSlot,
INT32  NumSlots,
INT32  SlotsToMove
[private]
 

Shifts down the ExtraInfo memory when it gets shrunk.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/06/94
Returns:
-

Definition at line 8563 of file paths.cpp.

08564 {
08565     TRACEUSER( "Will", _T("ShiftDownExtraInfo, Start=%d, NumSlots=%d, SlotsToMove=%d\n"),
08566             StartSlot, NumSlots, SlotsToMove);
08567 
08568     // The channel data has been resized and so we need to shift it around a bit.
08569     for (INT32 Index = 0; Index < NUMEXTRACHANNELS; ++Index)
08570     {
08571         if (ExtraInfoHandles[Index] != BAD_MHANDLE)
08572         {
08573             PathExtraElement* ExtraInfoPtr = (PathExtraElement*) DescribeHandle(ExtraInfoHandles[Index]);
08574             memmove( (void*)&ExtraInfoPtr[StartSlot], (void*)&ExtraInfoPtr[StartSlot+NumSlots], SlotsToMove*sizeof(PathExtraElement) );
08575         }
08576     }
08577 
08578 }

void PathExtraInfo::ShiftUpExtraInfo INT32  CurrentPos,
INT32  NumSlots,
INT32  SlotsToMove
[private]
 

Shifts up the ExtraInfo memory to make room for more.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/06/94
Returns:
-

Definition at line 8536 of file paths.cpp.

08537 {
08538     TRACEUSER( "Will", _T("ShiftUpExtraInfo, NumSlots=%d, SlotsToMove=%d\n"),NumSlots, SlotsToMove);
08539 
08540     // The channel data has been resized and so we need to shift it around a bit.
08541     for (INT32 Index = 0; Index < NUMEXTRACHANNELS; ++Index)
08542     {
08543         if (ExtraInfoHandles[Index] != BAD_MHANDLE)
08544         {
08545             PathExtraElement* ExtraInfoPtr = (PathExtraElement*) DescribeHandle(ExtraInfoHandles[Index]);
08546             memmove( (void*)&ExtraInfoPtr[CurrentPos+NumSlots], (void*)&ExtraInfoPtr[CurrentPos], SlotsToMove*sizeof(PathExtraElement) );
08547         }
08548     }
08549 
08550 }

void PathExtraInfo::Sync INT32  CurrentPos  ) 
 

Sets the Extra Info Ptr to the current Path Postion.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/06/94
Parameters:
The path position to set the extrainfo ptr to. [INPUTS]
Returns:
-

Errors: -

Definition at line 8469 of file paths.cpp.

08470 {
08471     TRACEUSER( "Will", _T("SyncExtraInfo, Pos=%d\n"),CurrentPos);
08472     CurrentExtraPos = CurrentPos;
08473 }


Friends And Related Function Documentation

friend class Path [friend]
 

Definition at line 152 of file paths.h.


Member Data Documentation

INT32 PathExtraInfo::CurrentExtraPos [private]
 

Definition at line 189 of file paths.h.

MHANDLE PathExtraInfo::ExtraInfoHandles[NUMEXTRACHANNELS] [private]
 

Definition at line 185 of file paths.h.

FIXED16 PathExtraInfo::Scaling[NUMEXTRACHANNELS] [private]
 

Definition at line 187 of file paths.h.

ChannelIndex PathExtraInfo::WidthChannel [private]
 

Definition at line 192 of file paths.h.


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