ValueFunctionBlip Class Reference

Provides an interface by which the caller can obtain the value of a given function at a given "position". More...

#include <valfunc.h>

Inheritance diagram for ValueFunctionBlip:

ValueFunction ListItem CCObject SimpleCCObject ValueFunctionEllipse ValueFunctionTeardrop ValueFunctionTeardropCurvedEnd ValueFunctionThumbtack List of all members.

Public Member Functions

 ValueFunctionBlip (double MaxPosition=0.50)
 Constructor.
virtual double GetValue (double Position)
 To read the value of this function at a given position.
virtual ValueFunctionClone (void)
 Clone operator. Creates an exact copy of this object.
virtual BOOL IsDifferent (ValueFunction *pOther)
 Comparator. Determines if 2 different ValueFunction objects are considered different.
virtual CamelotFileRecordWriteFileRecord (INT32 RecordTag, INT32 ExtraBytes, BaseCamelotFilter *pFilter)
 Saves a ValueFunction object to a Xara file. This function will create a new variable-sized record with the given record tag, and will write out whatever data is needed to save this ValueFunction's state to the file.
virtual ValueFunctionID GetUniqueID (void)

Protected Member Functions

virtual ValueFunctionCreateAndReadFileRecord (CXaraFileRecord *pInputRecord)
 Loads a ValueFunction object from a record which was saved into a file using the WriteFileRecord call. This is called by the base class loader routine ReadFileRecord, which finds an appropriate instance of a derived class to call to load the data in question.
virtual ValueFunctionBlipCreateInstance (void)
 Creates a new blank object of the same type as this one. Internal function used in ValueFunctionBlip & ValueFunctionBlipS.

Protected Attributes

double MaxPos

Private Member Functions

 CC_DECLARE_DYNAMIC (ValueFunctionBlip)

Detailed Description

Provides an interface by which the caller can obtain the value of a given function at a given "position".

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/12/96
This derived class returns a basic Blip shape: ______ __---- ----__ ____--- ---____

Classes derived from this override the "blip" with different shapes

In all cases, the constructor takes a "maxposition" value which indicates at which position the maximum function value occurs, as some blips are not symmetrical.

Definition at line 662 of file valfunc.h.


Constructor & Destructor Documentation

ValueFunctionBlip::ValueFunctionBlip double  MaxPosition = 0.50  ) 
 

Constructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/2/97
Parameters:
MaxPosition - The position at which the function should reach [INPUTS] its maximum value. Normally this is at 0.5, but for asymmetrical blips, values like 0.2 are better

Definition at line 2279 of file valfunc.cpp.

02280 {
02281     ERROR3IF(MaxPosition <= 0.0 || MaxPosition >= 1.0, "Silly MaxPosition value");
02282     MaxPos = MaxPosition;
02283 }


Member Function Documentation

ValueFunctionBlip::CC_DECLARE_DYNAMIC ValueFunctionBlip   )  [private]
 

ValueFunction * ValueFunctionBlip::Clone void   )  [virtual]
 

Clone operator. Creates an exact copy of this object.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/2/97
Returns:
NULL if it failed, else an exact copy of this object

Implements ValueFunction.

Definition at line 2336 of file valfunc.cpp.

02337 {
02338     ValueFunctionBlip *pClone = CreateInstance();
02339 
02340     if (pClone != NULL)
02341         pClone->MaxPos = MaxPos;
02342 
02343     return(pClone);
02344 }

ValueFunction * ValueFunctionBlip::CreateAndReadFileRecord CXaraFileRecord pInputRecord  )  [protected, virtual]
 

Loads a ValueFunction object from a record which was saved into a file using the WriteFileRecord call. This is called by the base class loader routine ReadFileRecord, which finds an appropriate instance of a derived class to call to load the data in question.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/2/97
Parameters:
pInputRecord - The file record to read [INPUTS]
Returns:
NULL if it failed, else a pointer to new ValueFunction object representing whatever was saved in that record.
This method creates a new instance of this particular ValueFunction class and then loads whatever information is necessary from the file to initialise itself properly. The record read-pointer is left pointing at the end of the ValueFunction-saved data so that the caller can continue reading their extra bytes of data after loading the ValueFunction.

See also:
ValueFunctionBlip::WriteFileRecord; ValueFunctionBlip::ReadFileRecord

Implements ValueFunction.

Definition at line 2479 of file valfunc.cpp.

02480 {
02481     ERROR3IF(pInputRecord == NULL, "Illegal NULL param");
02482 
02483     float MaxPosition = (float)0.5;
02484     pInputRecord->ReadFLOAT(&MaxPosition);
02485 
02486     ValueFunctionBlip *pBlip = CreateInstance();
02487     if (pBlip != NULL)
02488         pBlip->MaxPos = MaxPosition;
02489 
02490     return(pBlip);
02491 }

ValueFunctionBlip * ValueFunctionBlip::CreateInstance void   )  [protected, virtual]
 

Creates a new blank object of the same type as this one. Internal function used in ValueFunctionBlip & ValueFunctionBlipS.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/2/97
Returns:
NULL if it failed, else a pointer to new ValueFunctionBlip object of the same type as "this" one. Used to allow derived Blip classes to use all the base class code, and merely override the GetValue method.
Notes: Called by ValueFunctionBlip::Clone and CreateAndReadFileRecord, as this is the only action in those functions that depends on the type of the class that is being used

Reimplemented in ValueFunctionTeardrop, ValueFunctionTeardropCurvedEnd, ValueFunctionEllipse, and ValueFunctionThumbtack.

Definition at line 2515 of file valfunc.cpp.

02516 {   
02517     return(new ValueFunctionBlip);
02518 }

virtual ValueFunctionID ValueFunctionBlip::GetUniqueID void   )  [inline, virtual]
 

Implements ValueFunction.

Reimplemented in ValueFunctionTeardrop, ValueFunctionTeardropCurvedEnd, ValueFunctionEllipse, and ValueFunctionThumbtack.

Definition at line 675 of file valfunc.h.

00675 { return(ValueFunctionID_Blip); };

double ValueFunctionBlip::GetValue double  Position  )  [virtual]
 

To read the value of this function at a given position.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/2/97
Parameters:
Position - A value between 0.0 and 1.0 [INPUTS]
Returns:
A value representing the value of the function at the given Position.
Notes: This Blip is a 360 degree sine wave from 0.0 to 1.0 and back again. However, because the midpoint is adjustable, it is a piecewise function

Implements ValueFunction.

Reimplemented in ValueFunctionTeardrop, ValueFunctionTeardropCurvedEnd, ValueFunctionEllipse, and ValueFunctionThumbtack.

Definition at line 2304 of file valfunc.cpp.

02305 {
02306     double Value;
02307     if (Position < MaxPos)
02308     {
02309         Position /= MaxPos;
02310         Value = sin(Position * (Pi / 2.0));
02311     }
02312     else
02313     {
02314         Position = (Position - MaxPos) / (1.0 - MaxPos);
02315         Value = cos(Position * (Pi / 2.0));
02316     }
02317 
02318     return(Value);
02319 }

BOOL ValueFunctionBlip::IsDifferent ValueFunction pOther  )  [virtual]
 

Comparator. Determines if 2 different ValueFunction objects are considered different.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/2/97
Parameters:
pOther - Another ValueFunction object to compare this one to [INPUTS]
Returns:
TRUE if the objects are considered different, FALSE if they are considered identical
Notes: Calls the base class to see if they are different classes, and then compares identical classes by checking member vars

Reimplemented from ValueFunction.

Definition at line 2369 of file valfunc.cpp.

02370 {
02371     if (ValueFunction::IsDifferent(pOther))
02372         return(TRUE);
02373     
02374     // Both objects are instances of this class, so compare them more carefully
02375     return(MaxPos != ((ValueFunctionBlip *)pOther)->MaxPos);
02376 }

CamelotFileRecord * ValueFunctionBlip::WriteFileRecord INT32  RecordTag,
INT32  ExtraBytes,
BaseCamelotFilter pFilter
[virtual]
 

Saves a ValueFunction object to a Xara file. This function will create a new variable-sized record with the given record tag, and will write out whatever data is needed to save this ValueFunction's state to the file.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/2/97
Parameters:
RecordTag - the tag to write this record under [INPUTS] ExtraBytes - The number of extra bytes of information the caller will write into the record after caling this function (Space for this many extra bytes will be reserved by this function when it creates the new file record) This may be 0 or more bytes. pFilter - The filter to write to
Returns:
NULL if it failed, else a pointer to a record which saves the state of this valueFunction object. Once the caller has written the record, they MUST DELETE it.
"ExtraBytes" bytes will be added to the record size to reserve space at the end of the record for the caller to add their own data. This is to allow ValueFunctions to be saved embedded in other object's record structures (e.g. inside different types of attributes).

All ValueFunction record data has 3 sections, whiich are recorded as follows: 1. ValueFunction header, identifying which type of VF is being saved INT32 ValueFunctionUniqueID (4 bytes) 2. Derived-class-data (0 or more bytes). This particular class adds: float MaxPosition (4 bytes) 3. Caller data. This is written by the caller to the returned record object. This data must be ExtraBytes (0 or more) bytes in length.

See also:
ValueFunctionBlip::CreateAndReadFileRecord

Implements ValueFunction.

Definition at line 2422 of file valfunc.cpp.

02424 {
02425     ERROR3IF(pFilter == NULL, "Illegal NULL param");
02426     ERROR3IF(ExtraBytes < 0, "Stupid ExtraBytes request in ValueFunction::WriteFileRecord");
02427 
02428     // Calculate how many bytes of information this VF will write. We do not include
02429     // the header info written by the base class or the ExtraInfo desired by the caller -
02430     // the base class adds all that in for us.
02431     const INT32 MyRecordSize = 4;
02432 
02433     // Create an appropriate record, and write our data to it
02434     CamelotFileRecord *pRec = CreateAndWriteFileRecord(RecordTag, MyRecordSize, ExtraBytes, pFilter);
02435 
02436     if (pRec != NULL)
02437     {
02438         // Write out our ValueFunction's specific data. If it fails, then we'll return NULL
02439         if (!pRec->WriteFLOAT((float)MaxPos))
02440         {
02441             delete pRec;
02442             pRec = NULL;
02443         }
02444     }
02445 
02446     return(pRec);
02447 }


Member Data Documentation

double ValueFunctionBlip::MaxPos [protected]
 

Definition at line 685 of file valfunc.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:02:46 2007 for Camelot by  doxygen 1.4.4