VariableWidthAttrValue Class Reference

VariableWidth attribute value VariableWidth attributes describe the width characteristics for a path. More...

#include <strkattr.h>

Inheritance diagram for VariableWidthAttrValue:

AttributeValue CCObject SimpleCCObject List of all members.

Public Member Functions

 VariableWidthAttrValue (ValueFunction *pValueFunction=NULL)
 Constuctor for VariableWidthAttrValue.
 ~VariableWidthAttrValue ()
 Destructor for VariableWidthAttrValue.
virtual void Render (RenderRegion *pRegion, BOOL Temp=FALSE)
 Sets the VariableWidthAttrValue attribute for the given render region.
virtual void Restore (RenderRegion *pRegion, BOOL Temp)
 Restores the VariableWidthAttrValue attribute for the given render region.
virtual void SimpleCopy (AttributeValue *pValue)
 See AttributeValue::SimpleCopy.
virtual NodeAttributeMakeNode ()
 Make a new attribute node for this type of attr value - see base class.
virtual BOOL IsDifferent (AttributeValue *pAttr)
 Determines if this AttrValue is different from the given one.
virtual VariableWidthAttrValueoperator= (VariableWidthAttrValue &Attrib)
 Assignment operator.
virtual INT32 operator== (const VariableWidthAttrValue &Attrib)
 Comparison operator.
void SetWidthFunction (VariableWidthID PredefinedFuncID)
 To set the width function used in stroking.
void SetWidthFunction (ValueFunction *pNewFunction)
 To set the width function used in stroking.
ValueFunctionGetWidthFunction (void)
VariableWidthID GetWidthFunctionID (void)

Static Public Member Functions

static BOOL Init (void)
 Registers a default attribute of this type with the attribute manager.

Private Attributes

VariableWidthID PredefinedFunctionID
ValueFunctionWidthFunction

Detailed Description

VariableWidth attribute value VariableWidth attributes describe the width characteristics for a path.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97

Definition at line 275 of file strkattr.h.


Constructor & Destructor Documentation

VariableWidthAttrValue::VariableWidthAttrValue ValueFunction pValueFunction = NULL  ) 
 

Constuctor for VariableWidthAttrValue.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Parameters:
pValueFunction - NULL (for simple constant-width "line") or a ValueFunction [INPUTS] describing the variable width of paths affected by this attr.
NOTE that this object now BELONGS to the new attr, and will be deleted automatically when this object is destructed

Definition at line 1400 of file strkattr.cpp.

01401 {
01402     WidthFunction = pValueFunction;
01403     PredefinedFunctionID = VarWidth_NotPredefined;
01404 }

VariableWidthAttrValue::~VariableWidthAttrValue  ) 
 

Destructor for VariableWidthAttrValue.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97

Definition at line 1419 of file strkattr.cpp.

01420 {
01421     if (WidthFunction != NULL)
01422         delete WidthFunction;
01423 }


Member Function Documentation

ValueFunction* VariableWidthAttrValue::GetWidthFunction void   )  [inline]
 

Definition at line 303 of file strkattr.h.

00303 { return(WidthFunction); };

VariableWidthID VariableWidthAttrValue::GetWidthFunctionID void   )  [inline]
 

Definition at line 304 of file strkattr.h.

00304 { return(PredefinedFunctionID); };

BOOL VariableWidthAttrValue::Init void   )  [static]
 

Registers a default attribute of this type with the attribute manager.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Returns:
TRUE if it initilised successfully

Reimplemented from SimpleCCObject.

Definition at line 1440 of file strkattr.cpp.

01441 {
01442     // The default attribute is one that has no effect (i.e. produces constant-width "lines")
01443     VariableWidthAttrValue *pAttr = new VariableWidthAttrValue;
01444     if (pAttr == NULL)
01445         return FALSE;
01446 
01447     UINT32 ID = AttributeManager::RegisterDefaultAttribute(CC_RUNTIME_CLASS(VariableWidthAttrValue),
01448                                                             pAttr);
01449 
01450     ERROR2IF(ID == ATTR_BAD_ID, FALSE, "Bad ID when Initialising VariableWidthAttrValue");
01451 
01452     return(TRUE);
01453 }

BOOL VariableWidthAttrValue::IsDifferent AttributeValue pAttr  )  [virtual]
 

Determines if this AttrValue is different from the given one.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Returns:
Errors: ERROR3 if the two attributes are not of the same type
See also:
AttributeValue::IsDifferent

Reimplemented from AttributeValue.

Definition at line 1577 of file strkattr.cpp.

01578 {
01579     ERROR3IF(!pAttr->IsKindOf(CC_RUNTIME_CLASS(VariableWidthAttrValue)),
01580                 "Different attribute types in VariableWidthAttrValue::IsDifferent()");
01581 
01582     // Check they are NOT the same using the == operator
01583     return ( !(*((VariableWidthAttrValue *)pAttr) == *this) );
01584 }

NodeAttribute * VariableWidthAttrValue::MakeNode  )  [virtual]
 

Make a new attribute node for this type of attr value - see base class.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Returns:
Pointer to the new node, or NULL if out of memory.
See also:
AttributeValue::MakeNode

Reimplemented from AttributeValue.

Definition at line 1546 of file strkattr.cpp.

01547 {
01548     // Create new attribute node
01549     AttrVariableWidth *pAttr = new AttrVariableWidth();
01550     if (pAttr == NULL)
01551         return NULL;
01552 
01553     // Copy attribute value (if any) into the new node.
01554     if (pAttr->GetAttributeValue() != NULL)
01555         pAttr->GetAttributeValue()->SimpleCopy(this);
01556 
01557     return(pAttr);
01558 }

VariableWidthAttrValue & VariableWidthAttrValue::operator= VariableWidthAttrValue Attrib  )  [virtual]
 

Assignment operator.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Parameters:
Attrib - the attribute to copy [INPUTS]

Definition at line 1601 of file strkattr.cpp.

01602 {
01603     // Delete our existing WidthFunction (if any)
01604     if (WidthFunction != NULL)
01605         delete WidthFunction;
01606     WidthFunction = NULL;
01607 
01608     // Try to clone the other attribute's width function. If this fails, we'll just
01609     // end up as a constant-width line (NULL ValueFunction pointer)
01610     if (Attrib.GetWidthFunction() != NULL)
01611         WidthFunction = Attrib.GetWidthFunction()->Clone();
01612 
01613     // And copy its ID member across too
01614     PredefinedFunctionID = Attrib.PredefinedFunctionID;
01615 
01616     return(*this);
01617 }

INT32 VariableWidthAttrValue::operator== const VariableWidthAttrValue Attrib  )  [virtual]
 

Comparison operator.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Parameters:
Attrib - the attribute to compare this attribute with [INPUTS]
Returns:
TRUE if the attributes are considered equal

Definition at line 1636 of file strkattr.cpp.

01637 {
01638     ERROR3IF(!Attrib.IsKindOf(CC_RUNTIME_CLASS(VariableWidthAttrValue)),
01639                 "Other attribute value isn't an VariableWidthAttrValue");
01640 
01641 //  VariableWidthAttrValue *Other = (VariableWidthAttrValue *) &Attrib;
01642 
01643     // If both width functions are NULL, we are equal
01644     if (WidthFunction == NULL && Attrib.WidthFunction == NULL)
01645         return(TRUE);
01646 
01647     // If only one function is NULL, we ca't be considered equal
01648     if (WidthFunction == NULL || Attrib.WidthFunction == NULL)
01649         return(FALSE);
01650 
01651     // Finally, if both have a valid width function, ask them if they're equal
01652     return(!WidthFunction->IsDifferent(Attrib.WidthFunction));
01653 }

void VariableWidthAttrValue::Render RenderRegion pRegion,
BOOL  Temp = FALSE
[virtual]
 

Sets the VariableWidthAttrValue attribute for the given render region.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Parameters:
pRegion - the render region to render this attribute into. [INPUTS]
Notes: This attribute is so simple that its state can be read directly off the render region's stack. Thus, there is minimal special render region support for this attribute - we just stack and unstack it directly here.

Implements AttributeValue.

Definition at line 1474 of file strkattr.cpp.

01475 {
01476     pRegion->SetVariableWidth(this, Temp);
01477 }

void VariableWidthAttrValue::Restore RenderRegion pRegion,
BOOL  Temp
[virtual]
 

Restores the VariableWidthAttrValue attribute for the given render region.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Parameters:
pRegion - the render region to restore the attribute into. [INPUTS] Temp - TRUE if this is a temporary attribute, FALSE if it is permanent (e.g. it's in a document tree).
Notes: This attribute is so simple that its state can be read directly off the render region's stack. Thus, there is minimal special render region support for this attribute - we just stack and unstack it directly here.

Implements AttributeValue.

Definition at line 1500 of file strkattr.cpp.

01501 {
01502     pRegion->RestoreVariableWidth(this, Temp);
01503 }

void VariableWidthAttrValue::SetWidthFunction ValueFunction pNewFunction  ) 
 

To set the width function used in stroking.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Parameters:
pNewFunction - The new value function to use for variable-width strokes [INPUTS] affected by this attribute. May be NULL, in which case all strokes will be simple constant-width strokes.
NOTE that this object now belongs to this Attr, and will be automatically deleted upon destruction of the attr.

Notes: See the alternative form of this method - it uses predefined function "shapes", which save in a more compact format.

Definition at line 1678 of file strkattr.cpp.

01679 {
01680     if (WidthFunction != NULL)
01681         delete WidthFunction;
01682 
01683     WidthFunction = pNewFunction;
01684     PredefinedFunctionID = VarWidth_NotPredefined;
01685 }

void VariableWidthAttrValue::SetWidthFunction VariableWidthID  PredefinedFuncID  ) 
 

To set the width function used in stroking.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Parameters:
PredefinedFuncID - The ID of which predefined width function type you [INPUTS] wish to use. Predefined types are used to save space in the file format when exporting simple variable width attributes.

Definition at line 1704 of file strkattr.cpp.

01705 {
01706     ERROR3IF(PredefinedFuncID == VarWidth_NotPredefined, "You what?!");
01707 
01708     // get rid of any old width function
01709     if (WidthFunction != NULL)
01710     {
01711         delete WidthFunction;
01712         WidthFunction = NULL;
01713     }
01714 
01715     // Remember the new predefined-width-function identifier, so that we
01716     // know that our width is a spaecial predefined form which can be saved
01717     // in a much simpler & smaller format
01718     PredefinedFunctionID = PredefinedFuncID;
01719 
01720     switch(PredefinedFunctionID)
01721     {
01722         case VarWidth_Constant:
01723             WidthFunction = new ValueFunctionConstant(1.0);
01724             break;
01725 
01726         case VarWidth_LinRamp:
01727             WidthFunction = new ValueFunctionRampLinear(1.0, 0.0);
01728             break;
01729 
01730         case VarWidth_SRamp:
01731             WidthFunction = new ValueFunctionRampS(1.0, 0.0);
01732             break;
01733 
01734         default:
01735             ERROR3("Unsupported predefined width function");
01736             break;
01737     }
01738 }

void VariableWidthAttrValue::SimpleCopy AttributeValue pValue  )  [virtual]
 

See AttributeValue::SimpleCopy.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/1/97
Parameters:
pValue - pointer to the AttributeValue to copy [INPUTS]

Implements AttributeValue.

Definition at line 1520 of file strkattr.cpp.

01521 {
01522     ERROR3IF(!IS_A(pValue, VariableWidthAttrValue),
01523                 "Invalid Attribute value passed to VariableWidthAttrValue::SimpleCopy");
01524 
01525     // Just uses the assignment operator
01526     *this = *((VariableWidthAttrValue *) pValue);
01527 }


Member Data Documentation

VariableWidthID VariableWidthAttrValue::PredefinedFunctionID [private]
 

Definition at line 304 of file strkattr.h.

ValueFunction* VariableWidthAttrValue::WidthFunction [private]
 

Definition at line 308 of file strkattr.h.


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