ValueFunctionSmoothStroke 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 ValueFunctionSmoothStroke:

ValueFunction ListItem CCObject SimpleCCObject ValueFunctionSS_Barb ValueFunctionSS_Cigar ValueFunctionSS_Cigar2 ValueFunctionSS_Cigar3 ValueFunctionSS_Comet ValueFunctionSS_Concave ValueFunctionSS_Convex ValueFunctionSS_Fallout ValueFunctionSS_Goldfish ValueFunctionSS_Iron ValueFunctionSS_Meteor ValueFunctionSS_Missile ValueFunctionSS_OceanLiner ValueFunctionSS_Petal ValueFunctionSS_Reed ValueFunctionSS_SlimBlip ValueFunctionSS_Torpedo ValueFunctionSS_Yacht List of all members.

Public Member Functions

 ValueFunctionSmoothStroke (double newValue1y, double newValue2x, double newValue2y, double newValue3x, double newValue3y, double newValue4y)
 Constructor.
virtual ~ValueFunctionSmoothStroke ()
virtual BOOL IsDifferent (ValueFunction *pOther)
 Comparator. Determines if 2 different ValueFunction objects are considered different.
virtual INT32 GetMinimumRecursionDepth ()
 Overriden function to indicate to the path stroker how many recursions to perform at minimum before declaring a line segment 'flat' enough.
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 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 ValueFunctionSmoothStrokeCreateInstance (void)
virtual double GetValue (double Position)
 To read the value of this function at a given position.
void MakeTable ()

Protected Attributes

double Value1y
double Value2x
double Value2y
double Value3x
double Value3y
double Value4y

Static Protected Attributes

static double xvalue [18][256]
static double yvalue [18][256]

Private Member Functions

 CC_DECLARE_DYNAMIC (ValueFunctionSmoothStroke)

Detailed Description

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

Author:
Priestley (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/10/2000

Definition at line 926 of file valfunc.h.


Constructor & Destructor Documentation

ValueFunctionSmoothStroke::ValueFunctionSmoothStroke double  newValue1y,
double  newValue2x,
double  newValue2y,
double  newValue3x,
double  newValue3y,
double  newValue4y
 

Constructor.

Author:
Priestley (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/10/2000

Definition at line 3434 of file valfunc.cpp.

03435 {
03436     Value1y = newValue1y;
03437     Value2x = newValue2x;
03438     Value2y = newValue2y;
03439     Value3x = newValue3x;
03440     Value3y = newValue3y;
03441     Value4y = newValue4y;
03442 }

ValueFunctionSmoothStroke::~ValueFunctionSmoothStroke  )  [virtual]
 

Definition at line 3444 of file valfunc.cpp.

03445 {
03446 }


Member Function Documentation

ValueFunctionSmoothStroke::CC_DECLARE_DYNAMIC ValueFunctionSmoothStroke   )  [private]
 

ValueFunction * ValueFunctionSmoothStroke::CreateAndReadFileRecord CXaraFileRecord pInputRecord  )  [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:
Priestley (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/10/2000
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.

Implements ValueFunction.

Definition at line 3563 of file valfunc.cpp.

03564 {
03565     ERROR3IF(pInputRecord == NULL, "Illegal NULL param");
03566 
03567     float newValue1y = 0.0;
03568     float newValue2x = 0.0;
03569     float newValue2y = 0.0;
03570     float newValue3x = 0.0;
03571     float newValue3y = 0.0;
03572     float newValue4y = 0.0;
03573 
03574     pInputRecord->ReadFLOAT(&newValue1y);
03575     pInputRecord->ReadFLOAT(&newValue2x);
03576     pInputRecord->ReadFLOAT(&newValue2y);
03577     pInputRecord->ReadFLOAT(&newValue3x);
03578     pInputRecord->ReadFLOAT(&newValue3y);
03579     pInputRecord->ReadFLOAT(&newValue4y);
03580 
03581 
03582     ValueFunctionSmoothStroke *pSStroke = CreateInstance();
03583     if (pSStroke != NULL)
03584     {
03585         pSStroke->Value1y = newValue1y;
03586         pSStroke->Value2x = newValue2x;
03587         pSStroke->Value2y = newValue2y;
03588         pSStroke->Value3x = newValue3x;
03589         pSStroke->Value3y = newValue3y;
03590         pSStroke->Value4y = newValue4y;
03591     }
03592 
03593     return(pSStroke);
03594 }

ValueFunctionSmoothStroke * ValueFunctionSmoothStroke::CreateInstance void   )  [virtual]
 

Author:
Priestley (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/10/2000
Returns:
NULL if it failed, else a pointer to new ValueFunctionSmoothStroke object of the same type as "this" one.

Reimplemented in ValueFunctionSS_Yacht, ValueFunctionSS_Iron, ValueFunctionSS_Reed, ValueFunctionSS_Meteor, ValueFunctionSS_Petal, ValueFunctionSS_Comet, ValueFunctionSS_Fallout, ValueFunctionSS_Torpedo, ValueFunctionSS_Missile, ValueFunctionSS_Convex, ValueFunctionSS_Concave, ValueFunctionSS_Cigar, ValueFunctionSS_Cigar2, ValueFunctionSS_Cigar3, ValueFunctionSS_SlimBlip, ValueFunctionSS_OceanLiner, ValueFunctionSS_Goldfish, and ValueFunctionSS_Barb.

Definition at line 3609 of file valfunc.cpp.

03610 {
03611     //You shouldn't really be calling this base class CreateInstance() so Fail!
03612     return NULL;
03613 }

INT32 ValueFunctionSmoothStroke::GetMinimumRecursionDepth  )  [virtual]
 

Overriden function to indicate to the path stroker how many recursions to perform at minimum before declaring a line segment 'flat' enough.

Author:
Priestley (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/10/2000

Reimplemented from ValueFunction.

Definition at line 3628 of file valfunc.cpp.

03629 {
03630     return 2;
03631 }

double ValueFunctionSmoothStroke::GetValue double  Position  )  [virtual]
 

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

Author:
Priestley (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/10/2000
Parameters:
Position - A value between 0.0 and 1.0 [INPUTS]
Returns:
A value (between Value1 and Value2 given in the constructor) representing the value of the function at the given Position.

Implements ValueFunction.

Definition at line 3650 of file valfunc.cpp.

03651 {
03652     //Which ValueFunction are we looking at?
03653     INT32 index = (INT32)GetUniqueID();
03654     index -= (INT32)ValueFunctionID_BevelEnds + 1;
03655 
03656 
03657     INT32 counter;
03658 
03659     //Find the first xvalue which is greater than or equal to our position
03660     for (counter = 0; counter < 256; counter++)
03661     {
03662         if (xvalue[index][counter] >= Position)
03663         {
03664             //Stop looking through the array when we have found it!
03665             break;
03666         }
03667     }
03668         
03669     if (counter > 0)
03670     {
03671         counter -= 1;
03672     }
03673 
03674     //Work out how far through between xvalue[counter] and xvalue[counter+1] we are, then multiply
03675     //this by the vertical difference of the two coordinates, then add on yvalue[counter] to get the
03676     //approximate value at this Position...
03677     double xdifference = xvalue[index][counter+1] - xvalue[index][counter];
03678     double ydifference = yvalue[index][counter+1] - yvalue[index][counter];
03679 
03680     //Now just check to make sure that we aren't about to divide by zero!
03681     if (xdifference == 0.0)
03682     {
03683         //Set to a very small number...
03684         xdifference = 0.0000000000000001;
03685     }
03686 
03687     double value = yvalue[index][counter] + (((Position - xvalue[index][counter]) / xdifference) * ydifference);
03688 
03689     return value;
03690 }

BOOL ValueFunctionSmoothStroke::IsDifferent ValueFunction pOther  )  [virtual]
 

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

Author:
Priestley (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/10/2000
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 3469 of file valfunc.cpp.

03470 {
03471     if (ValueFunction::IsDifferent(pOther))
03472     {
03473         return(true);
03474     }
03475         // Both objects are instances of this class, so compare them more carefully
03476         return( (Value1y != ((ValueFunctionSmoothStroke *)pOther)->Value1y) ||
03477                 (Value2x != ((ValueFunctionSmoothStroke *)pOther)->Value2x) ||
03478                 (Value2y != ((ValueFunctionSmoothStroke *)pOther)->Value2y) ||
03479                 (Value3x != ((ValueFunctionSmoothStroke *)pOther)->Value3x) ||
03480                 (Value3y != ((ValueFunctionSmoothStroke *)pOther)->Value3y) ||
03481                 (Value4y != ((ValueFunctionSmoothStroke *)pOther)->Value4y) ) ;
03482 }

void ValueFunctionSmoothStroke::MakeTable  ) 
 

Definition at line 3695 of file valfunc.cpp.

03696 {
03697     //Which ValueFunction are we creating tbe table for?
03698     INT32 index = (INT32)GetUniqueID();
03699     index -= (INT32)ValueFunctionID_BevelEnds + 1;
03700 
03701 
03702     //Make the four control points of the Bezier...
03703     DocCoord p1;
03704     p1.x = 0; p1.y = INT32(Value1y*100000);
03705     DocCoord p2;
03706     p2.x = INT32(Value2x*100000); p2.y = INT32(Value2y*100000);
03707     DocCoord p3;
03708     p3.x = INT32(Value3x*100000); p3.y = INT32(Value3y*100000);
03709     DocCoord p4;
03710     p4.x = 100000; p4.y = INT32(Value4y*100000);
03711 
03712     //Create the Bezier curve path denoted by the four control points
03713     Path strokePath;
03714     strokePath.Initialise();
03715     strokePath.InsertMoveTo(p1, NULL);
03716     strokePath.InsertCurveTo(p2, p3, p4, NULL);
03717 
03718     //Find out how long the path is...
03719     double pathlength = strokePath.GetPathLength();
03720     DocCoord* pPoint = new DocCoord;
03721 
03722     TRACEUSER( "Matt", _T("\nStarting to make Bezier table...\n"));
03723     for (INT32 counter = 0; counter < 256; counter++)
03724     {
03725         //At even intervals along the length of the curve, record the x and y coordinate
03726         MILLIPOINT Distance = (INT32(pathlength)/256)*counter;
03727         strokePath.GetPointAtDistance(Distance, pPoint, NULL, NULL);
03728 
03729         xvalue[index][counter] = double(pPoint->x) / 100000.0;
03730         yvalue[index][counter] = double(pPoint->y) / 100000.0;
03731 
03732 //      TRACEUSER( "Matt", _T("xvalue[%d] = %f; yvalue[%d] = %f;\n"),counter,xvalue[counter],counter,yvalue[counter]);
03733     }
03734     TRACEUSER( "Matt", _T("Finished table...\n\n"));
03735 
03736     delete pPoint;
03737 }

CamelotFileRecord * ValueFunctionSmoothStroke::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:
Priestley (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/10/2000
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.

Implements ValueFunction.

Definition at line 3512 of file valfunc.cpp.

03514 {
03515     ERROR3IF(pFilter == NULL, "Illegal NULL param");
03516     ERROR3IF(ExtraBytes < 0, "Stupid ExtraBytes request in ValueFunction::WriteFileRecord");
03517 
03518     const INT32 MyRecordSize = 24;
03519 
03520     // Create an appropriate record, and write our data to it
03521     CamelotFileRecord *pRec = CreateAndWriteFileRecord(RecordTag, MyRecordSize, ExtraBytes, pFilter);
03522 
03523     if (pRec != NULL)
03524     {
03525         BOOL ok = TRUE;
03526         if (ok)     ok = pRec->WriteFLOAT((FLOAT) Value1y);
03527         if (ok)     ok = pRec->WriteFLOAT((FLOAT) Value2x);
03528         if (ok)     ok = pRec->WriteFLOAT((FLOAT) Value2y);
03529         if (ok)     ok = pRec->WriteFLOAT((FLOAT) Value3x);
03530         if (ok)     ok = pRec->WriteFLOAT((FLOAT) Value3y);
03531         if (ok)     ok = pRec->WriteFLOAT((FLOAT) Value4y);
03532 
03533         if (!ok)            // If we failed, clean up & return NULL
03534         {
03535             delete pRec;
03536             pRec = NULL;
03537         }
03538     }
03539 
03540     return(pRec);
03541 }


Member Data Documentation

double ValueFunctionSmoothStroke::Value1y [protected]
 

Definition at line 943 of file valfunc.h.

double ValueFunctionSmoothStroke::Value2x [protected]
 

Definition at line 944 of file valfunc.h.

double ValueFunctionSmoothStroke::Value2y [protected]
 

Definition at line 945 of file valfunc.h.

double ValueFunctionSmoothStroke::Value3x [protected]
 

Definition at line 946 of file valfunc.h.

double ValueFunctionSmoothStroke::Value3y [protected]
 

Definition at line 947 of file valfunc.h.

double ValueFunctionSmoothStroke::Value4y [protected]
 

Definition at line 948 of file valfunc.h.

double ValueFunctionSmoothStroke::xvalue [static, protected]
 

Definition at line 950 of file valfunc.h.

double ValueFunctionSmoothStroke::yvalue [static, protected]
 

Definition at line 951 of file valfunc.h.


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