LineWidthAttribute Class Reference

Represent a line width of a path. This may be a simple stroking operator such as a constant line width, or a complex one such as variable line widths or an airbrush stroke operator. More...

#include <attrval.h>

Inheritance diagram for LineWidthAttribute:

AttributeValue CCObject SimpleCCObject List of all members.

Public Member Functions

 LineWidthAttribute ()
 LineWidthAttribute (MILLIPOINT NewLineWidth)
virtual void Restore (RenderRegion *, BOOL)
 Restores the line width attribute for the given render region. i.e. all lines drawn will now be drawn with this line width.
virtual void Render (RenderRegion *, BOOL Temp=FALSE)
 Sets the line width attribute for the given render region. i.e. all lines drawn will now be drawn with this line width.
virtual NodeAttributeMakeNode ()
 Make a AttrLineWidth node from this line width attribute.
BOOL IsDifferent (AttributeValue *pAttr)
 See base class version.
virtual void SimpleCopy (AttributeValue *)
 See AttributeValue::SimpleCopy.
virtual BOOL Blend (BlendAttrParam *pBlendParam)
 Blends this attr val with the attr val held in pBlendParam.
virtual BOOL RenderStroke (RenderRegion *, Path *)
virtual AttributeValueMouldIntoStroke (PathStrokerVector *pMoulder, double TransScale=1.0)
 Helper function for the PathStrokerVector class, which "moulds" clipart subtrees to lie along an arbitrary path.

Static Public Member Functions

static BOOL Init ()
 Registers line width attribute, and provides a default attribute to give 0.25pt lines.

Public Attributes

MILLIPOINT LineWidth

Detailed Description

Represent a line width of a path. This may be a simple stroking operator such as a constant line width, or a complex one such as variable line widths or an airbrush stroke operator.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/06/94
See also:
FillColourAttribute; StrokeColourAttribute; StartArrowAttribute; EndArrowAttribute; StartCapAttribute; EndCapAttribute; JoinTypeAttribute; MitreLimitAttribute; WindingRuleAttribute; DashPatternAttribute

Definition at line 193 of file attrval.h.


Constructor & Destructor Documentation

LineWidthAttribute::LineWidthAttribute  ) 
 

Definition at line 386 of file attr.cpp.

00387 {
00388     LineWidth = 500 + 1;  // BODGE The 1 added by Simon 25/10/95, so that the default attr 
00389                           // is different from the current attr. That way line scaling at 
00390                           // least works in simple cases.
00391 }

LineWidthAttribute::LineWidthAttribute MILLIPOINT  NewLineWidth  )  [inline]
 

Definition at line 198 of file attrval.h.

00198 { LineWidth = NewLineWidth; }


Member Function Documentation

BOOL LineWidthAttribute::Blend BlendAttrParam pBlendParam  )  [virtual]
 

Blends this attr val with the attr val held in pBlendParam.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/10/94
Parameters:
pBlendParam = ptr to param holding all data needed for the attr val to blend [INPUTS]
if TRUE returned, pBlendParam->GetBlendedAttrVal() will get ptr to the blended attr val [OUTPUTS] if FALSE returned, pBlendParam->GetBlendedAttrVal() will return NULL
Returns:
TRUE if successful, FALSE otherwaie
See also:
-

Reimplemented from AttributeValue.

Definition at line 542 of file attr.cpp.

00543 {
00544     // Check entry param
00545     ERROR3IF(pBlendParam == NULL,"NULL entry param");
00546     if (pBlendParam == NULL) return FALSE;
00547 
00548     LineWidthAttribute* pOtherLineAttr = (LineWidthAttribute*) pBlendParam->GetOtherAttrVal();
00549 
00550     // Check that the other line attr val is not NULL, and is a LineWidthAttribute
00551     ERROR3IF(pOtherLineAttr == NULL,"NULL other attr val");
00552     ERROR3IF(!IS_A(pOtherLineAttr,LineWidthAttribute),"other attr val not a line width attr");
00553     if (pOtherLineAttr == NULL || !IS_A(pOtherLineAttr,LineWidthAttribute)) return FALSE;
00554 
00555     // Get a new LineWidthAttribute to hold the blended version, (return FALSE if this fails)
00556     LineWidthAttribute* pBlendedLineAttr = new LineWidthAttribute;
00557     if (pBlendedLineAttr == NULL) return FALSE;
00558 
00559     // The blended line width is done by linearly tending the start line width to the
00560     // end line width, proportionally to the blend ration (0.0 to 1.0)
00561 
00562     // DeltaWidth is the amount to subtract from this LineWidth, and is proportional to BlendRatio
00563     MILLIPOINT DeltaWidth = INT32((LineWidth - pOtherLineAttr->LineWidth) * pBlendParam->GetBlendRatio());
00564 
00565     pBlendedLineAttr->LineWidth = LineWidth - DeltaWidth;
00566 
00567     // Store the ptr to the new blended line width attr val
00568     pBlendParam->SetBlendedAttrVal(pBlendedLineAttr);
00569 
00570     return TRUE;
00571 }

BOOL LineWidthAttribute::Init void   )  [static]
 

Registers line width attribute, and provides a default attribute to give 0.25pt lines.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/04/94
Returns:
TRUE - initialised ok; FALSE if not.

Errors: Out of memory.

See also:
AttributeManager

Reimplemented from SimpleCCObject.

Definition at line 468 of file attr.cpp.

00469 {
00470     // Default to 0.25pt lines
00471     LineWidthAttribute *pAttr = new LineWidthAttribute;
00472     if (pAttr == NULL)
00473         return FALSE;
00474 
00475     UINT32 ID = AttributeManager::RegisterDefaultAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), 
00476                                                          pAttr);
00477     if (ID == ATTR_BAD_ID)
00478         return FALSE;
00479     ENSURE(ID == ATTR_LINEWIDTH, "Incorrect ID for attribute!");
00480     return TRUE;
00481 }

BOOL LineWidthAttribute::IsDifferent AttributeValue pAttr  )  [virtual]
 

See base class version.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/04/94
Returns:
Errors: The two attributes are not of the same type.
See also:
AttributeValue::IsDifferent

Reimplemented from AttributeValue.

Definition at line 520 of file attr.cpp.

00521 {
00522     ENSURE(GetRuntimeClass() == pAttr->GetRuntimeClass(), 
00523            "Different attribute types in AttributeValue::IsDifferent()");
00524     return ((LineWidthAttribute *) pAttr)->LineWidth != LineWidth;
00525 }

NodeAttribute * LineWidthAttribute::MakeNode  )  [virtual]
 

Make a AttrLineWidth node from this line width attribute.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/04/94
Returns:
Pointer to the new node, or NULL if out of memory.

Errors: Out of memory

See also:
AttributeValue::MakeNode

Reimplemented from AttributeValue.

Definition at line 496 of file attr.cpp.

00497 {
00498     // Create new attribute node
00499     AttrLineWidth *pAttr = new AttrLineWidth();
00500 
00501     // Copy attribute value into the new node.
00502     pAttr->Value.SimpleCopy(this);
00503 
00504     // Return the new node
00505     return pAttr;
00506 }

AttributeValue * LineWidthAttribute::MouldIntoStroke PathStrokerVector pMoulder,
double  TransScale = 1.0
[virtual]
 

Helper function for the PathStrokerVector class, which "moulds" clipart subtrees to lie along an arbitrary path.

Parameters:
pMoulder - A PathStrokerVector which knows how to translate points to "mould" them [INPUTS] (May be NULL, in which case moulding of points does not occur)
TransScale - A fraction between 0.0 and 1.0, by which any transparency values in this geometry will be scaled, allowing the caller to effectively apply a flat transparency level to everything that is moulded. Use 1.0 to leave transparency unaltered.

Returns:
NULL if there is no need to mould this attribute (so you should just render the original attribute), else A pointer to a copy of this object, suitably moulded and adjusted for the transparency scaling. The caller must delete the copy when finished with it.
This function is called to mould attributes, so that: Fill/Trans geometries can be moulded Line Widths can be scaled to an appropriate value A global flat transparency can be applied etc

Notes: The base class does nothing (it returns NULL - by default, attrs assume that they will work OK when moulded without being changed)

Reimplemented from AttributeValue.

Definition at line 608 of file attr.cpp.

00609 {
00610 #ifdef VECTOR_STROKING // Neville 6/8/97
00611     LineWidthAttribute* pMouldedAttr = new LineWidthAttribute;
00612     if (pMouldedAttr != NULL)
00613     {
00614         double ScaledWidth = pMoulder->GetScaleFactor() * (double)LineWidth;
00615         if (ScaledWidth < 1.0)
00616             ScaledWidth = 1.0;
00617         else if (pMouldedAttr->LineWidth > 1000000.0)
00618             ScaledWidth = 1000000.0;
00619         pMouldedAttr->LineWidth = (INT32)ScaledWidth;
00620     }
00621 
00622     return(pMouldedAttr);
00623 #else
00624     return NULL;
00625 #endif
00626 }

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

Sets the line width attribute for the given render region. i.e. all lines drawn will now be drawn with this line width.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
03/02/94
Parameters:
pRegion - the render region to render this attribute into. [INPUTS]
See also:
LineWidthAttribute; RenderStack; AttributeValue; NodeAttribute; LineWidthAttribute::Restore; LineWidthAttribute::SimpleCopy; AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy

Implements AttributeValue.

Definition at line 408 of file attr.cpp.

00409 {
00410     pRegion->SetLineWidth(this, Temp);
00411 }

virtual BOOL LineWidthAttribute::RenderStroke RenderRegion ,
Path
[inline, virtual]
 

Definition at line 209 of file attrval.h.

00209 { return FALSE; }

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

Restores the line width attribute for the given render region. i.e. all lines drawn will now be drawn with this line width.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
03/02/94
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).
See also:
LineWidthAttribute; RenderStack; AttributeValue; NodeAttribute; LineWidthAttribute::Render; LineWidthAttribute::SimpleCopy; AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy

Implements AttributeValue.

Definition at line 430 of file attr.cpp.

00431 {
00432     pRegion->RestoreLineWidth(this, Temp);
00433 }

void LineWidthAttribute::SimpleCopy AttributeValue pValue  )  [virtual]
 

See AttributeValue::SimpleCopy.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
03/02/94
Parameters:
pAttr - pointer to the AttributeValue to copy. [INPUTS]
See also:
LineWidthAttribute; RenderStack; AttributeValue; NodeAttribute; LineWidthAttribute::Render; LineWidthAttribute::Restore; AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy

Implements AttributeValue.

Definition at line 449 of file attr.cpp.

00450 {
00451     LineWidth = ((LineWidthAttribute *) pValue)->LineWidth;
00452 }


Member Data Documentation

MILLIPOINT LineWidthAttribute::LineWidth
 

Definition at line 212 of file attrval.h.


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