GradFillAttribute Class Reference

Base class for a graduated fill attribute to be derived from. It includes one vector (stored as two coordinates) to represent the basic direction of the fill. Some fills will need more vectors (e.g. radial fills) but they can just add data fields in their derived classes. More...

#include <fillval.h>

Inheritance diagram for GradFillAttribute:

ColourFillAttribute FillGeometryAttribute AttributeValue CCObject SimpleCCObject BitmapFillAttribute ConicalFillAttribute LinearFillAttribute RadialFillAttribute SquareFillAttribute ThreeColFillAttribute FractalFillAttribute NoiseFillAttribute FourColFillAttribute List of all members.

Public Member Functions

 GradFillAttribute ()
 Default Constuctor for fill attribute values.
 ~GradFillAttribute ()
 All new destructor used to delete a colour ramp.
virtual FillGeometryAttributeoperator= (FillGeometryAttribute &Attrib)
 Make the Attribute the same as the other.
virtual INT32 operator== (const FillGeometryAttribute &Attrib)
 A virtual comparison operator. See NodeAttribute::operator== for a description of why it's required.
virtual void SimpleCopy (AttributeValue *)
 See AttributeValue::SimpleCopy.
virtual BOOL RenderFill (RenderRegion *, Path *)
 Render the fill, if poss. (override to do something different).
virtual DocCoordGetStartPoint ()
virtual DocCoordGetEndPoint ()
virtual DocColourGetEndColour ()
virtual void SetStartPoint (DocCoord *Pos)
 Sets the Start Point of this fill.
virtual void SetEndPoint (DocCoord *Pos)
 Sets the End Point of this fill.
virtual void SetEndColour (DocColour *NewCol)
 Sets the End Colour of this fill.
virtual BOOL Blend (BlendAttrParam *pBlendParam)
 Blends between two graduated fill attributes. This current calls the general fill blend function. (See FillGeometryAttribute::Blend).
virtual BOOL IsAGradFill ()
virtual DocCoord GetGeometryCoord (float pos) const
 Find the absolute position in geometry coordinate space for the given parameter.
virtual float GetGeometryParam (const DocCoord &c) const
 Find the parameter for the closest point to c on this geometry.
ColourRampGetColourRamp ()
virtual BOOL SupportsFillRamps ()
virtual BOOL SetColourRamp (ColourRamp *pRamp)
 Set this colour ramp to the version passed in. If pRamp is NULL, the colour ramp in this object will be emptied.
ColourRampMakeNewColourRamp ()
 Set this colour ramp to the version passed in. If pRamp is NULL, the colour ramp in this object will be emptied.
BOOL SameColourRampAs (ColourRamp *pOtherRamp)
 Check whether this colour ramp matches that pointed to by pOtherRamp.
void DeleteColourRamp ()
 Function to remove the colour ramp from this grad fill.

Public Attributes

DocColour EndColour
DocCoord StartPoint
DocCoord EndPoint

Protected Attributes

ColourRampm_pColourRamp

Detailed Description

Base class for a graduated fill attribute to be derived from. It includes one vector (stored as two coordinates) to represent the basic direction of the fill. Some fills will need more vectors (e.g. radial fills) but they can just add data fields in their derived classes.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/07/94
See also:
FillGeometryAttribute

Definition at line 442 of file fillval.h.


Constructor & Destructor Documentation

GradFillAttribute::GradFillAttribute  ) 
 

Default Constuctor for fill attribute values.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/94
See also:
AttrFillGeometry::AttrFillGeometry

Definition at line 1066 of file fillval.cpp.

01067 {
01068 //  AttributeManager::FindDefaultColour(ColourManager::GetCurrentColourList(),
01069 //                                      _R(IDS_WHITENAME), &EndColour);
01070     AttributeManager::FindDefaultColour(NULL,
01071                                         _R(IDS_WHITENAME), &EndColour);
01072 
01073     StartPoint = DocCoord(0,0);
01074     EndPoint   = DocCoord(0,0);
01075     
01076     m_pColourRamp = NULL;
01077 }

GradFillAttribute::~GradFillAttribute  ) 
 

All new destructor used to delete a colour ramp.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/3/97

Definition at line 1089 of file fillval.cpp.

01090 {
01091     DeleteColourRamp();
01092 }


Member Function Documentation

BOOL GradFillAttribute::Blend BlendAttrParam pBlendParam  )  [virtual]
 

Blends between two graduated fill attributes. This current calls the general fill blend function. (See FillGeometryAttribute::Blend).

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/11/94
Returns:
TRUE - Blend went ok, the blended attr val is valid; FALSE if not.

Errors: Out of memory.

See also:
FillGeometryAttribute::Blend; FillGeometryAttribute::BlendFillColours; FillGeometryAttribute::BlendFillTransp; FillGeometryAttribute::BlendControlPoints; FlatFillAttribute::Blend

Reimplemented from FillGeometryAttribute.

Definition at line 9789 of file fillval.cpp.

09790 {
09791     return FillGeometryAttribute::Blend(pBlendParam);
09792 }

void GradFillAttribute::DeleteColourRamp  ) 
 

Function to remove the colour ramp from this grad fill.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/3/97
Parameters:
- [INPUTS]

Definition at line 1105 of file fillval.cpp.

01106 {
01107     if (m_pColourRamp!=NULL)
01108     {
01109         delete m_pColourRamp;
01110         m_pColourRamp=NULL;
01111     }
01112 }

ColourRamp* GradFillAttribute::GetColourRamp  )  [inline, virtual]
 

Reimplemented from FillGeometryAttribute.

Definition at line 470 of file fillval.h.

00470 { return m_pColourRamp; }

virtual DocColour* GradFillAttribute::GetEndColour  )  [inline, virtual]
 

Reimplemented from FillGeometryAttribute.

Reimplemented in BitmapFillAttribute, NoiseFillAttribute, and FractalFillAttribute.

Definition at line 458 of file fillval.h.

00458 { return &EndColour; }

virtual DocCoord* GradFillAttribute::GetEndPoint  )  [inline, virtual]
 

Reimplemented from FillGeometryAttribute.

Reimplemented in BitmapFillAttribute.

Definition at line 457 of file fillval.h.

00457 { return &EndPoint; }

DocCoord GradFillAttribute::GetGeometryCoord float  pos  )  const [virtual]
 

Find the absolute position in geometry coordinate space for the given parameter.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/3/97
Parameters:
pos = a parameter between 0 and 1 [INPUTS]
Returns:
A coordinate which relates the input parameter to a coordinate space on this geometry. For instance a linear fill would have a linear parameter space, 0 at the start coordinate, increasing to 1 at the end coordinate

Reimplemented from FillGeometryAttribute.

Reimplemented in ConicalFillAttribute.

Definition at line 1203 of file fillval.cpp.

01204 {
01205     // This and all derived classes will inherit a linear coordinate space
01206     return DocCoord::PositionPointFromRatio(StartPoint,EndPoint,(double)pos);
01207 }

float GradFillAttribute::GetGeometryParam const DocCoord c  )  const [virtual]
 

Find the parameter for the closest point to c on this geometry.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/3/97
Parameters:
c = a coordinate [INPUTS]
Returns:
A parameter p, 0<=p<=1, such that GetGeometryCoord(p) is the closest coordinate in the geometry to the input c.

Reimplemented from FillGeometryAttribute.

Reimplemented in ConicalFillAttribute.

Definition at line 1223 of file fillval.cpp.

01224 {
01225     // ok we're a linear geometry so find the closest point to a line type of thing.
01226     // use a handy util written by that other fab bloke called Mike.
01227     DocCoord Coords[2];
01228     Coords[0] = StartPoint;
01229     Coords[1] = EndPoint;
01230     double p;
01231     PathUtil::SqrDistanceToLine(Coords, c, &p);
01232     return (float)p;
01233 }

virtual DocCoord* GradFillAttribute::GetStartPoint  )  [inline, virtual]
 

Reimplemented from FillGeometryAttribute.

Reimplemented in BitmapFillAttribute.

Definition at line 456 of file fillval.h.

00456 { return &StartPoint; }

virtual BOOL GradFillAttribute::IsAGradFill  )  [inline, virtual]
 

Reimplemented from FillGeometryAttribute.

Definition at line 466 of file fillval.h.

00466 { return TRUE; }

ColourRamp * GradFillAttribute::MakeNewColourRamp  ) 
 

Set this colour ramp to the version passed in. If pRamp is NULL, the colour ramp in this object will be emptied.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/3/97
Parameters:
- [INPUTS]
Returns:
TRUE if the colour ramp was set, FALSE if not

Definition at line 1180 of file fillval.cpp.

01181 {
01182     DeleteColourRamp();
01183     m_pColourRamp = new ColourRamp();
01184     return m_pColourRamp;
01185 }

FillGeometryAttribute & GradFillAttribute::operator= FillGeometryAttribute FillAttrib  )  [virtual]
 

Make the Attribute the same as the other.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/8/94
Parameters:
FillAttrib - the attribute to copy, which must be an AttrFillGeometry [INPUTS]
Returns:
Usual semantics for equality.

Errors: An ENSURE failure will occur if Attrib does not have a AttrFlatGeometry runtime class.

Reimplemented from ColourFillAttribute.

Reimplemented in RadialFillAttribute, BitmapFillAttribute, NoiseFillAttribute, and FractalFillAttribute.

Definition at line 1251 of file fillval.cpp.

01252 {
01253     return ColourFillAttribute::operator=(FillAttrib);
01254 }

INT32 GradFillAttribute::operator== const FillGeometryAttribute Attrib  )  [virtual]
 

A virtual comparison operator. See NodeAttribute::operator== for a description of why it's required.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/8/94
Parameters:
Attrib - the attribute to compare, which must be an AttrFillGeometry [INPUTS]
Returns:
Usual semantics for equality.

Errors: An ENSURE failure will occur if Attrib does not have a AttrFlatGeometry runtime class.

See also:
NodeAttribute::operator==

Reimplemented from ColourFillAttribute.

Reimplemented in RadialFillAttribute, ThreeColFillAttribute, FourColFillAttribute, BitmapFillAttribute, NoiseFillAttribute, and FractalFillAttribute.

Definition at line 1272 of file fillval.cpp.

01273 {
01274     if (GetRuntimeClass() != Attrib.GetRuntimeClass())
01275         return FALSE;
01276 
01277     GradFillAttribute* pAttrib = (GradFillAttribute*)&Attrib;
01278 
01279     if (IsPerspective())
01280     { 
01281         if (!pAttrib->IsPerspective())
01282             return FALSE;
01283 
01284         if (*GetEndPoint2() != *pAttrib->GetEndPoint2())
01285             return FALSE;
01286 
01287         if (*GetEndPoint3() != *pAttrib->GetEndPoint3())
01288             return FALSE;
01289     }
01290     
01291     // check the colour ramps match
01292     if (!SameColourRampAs(pAttrib->GetColourRamp()))
01293         return FALSE;
01294     
01295     // Are the Colours and Control points all the same ?
01296     return (
01297     
01298         Colour      == pAttrib->Colour      &&
01299         EndColour   == pAttrib->EndColour   &&
01300 
01301         StartPoint  == pAttrib->StartPoint  &&
01302         EndPoint    == pAttrib->EndPoint
01303     );
01304 }

BOOL GradFillAttribute::RenderFill RenderRegion pRegion,
Path pPath
[virtual]
 

Render the fill, if poss. (override to do something different).

Author:
Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/8/96
Parameters:
pRegion - the render region of interest [INPUTS] pPath - the path to fill.
Returns:
FALSE => let the Render region fill the path, TRUE = we have done it.

Reimplemented from FillGeometryAttribute.

Reimplemented in BitmapFillAttribute.

Definition at line 1322 of file fillval.cpp.

01323 {
01324     if ( pRegion->IsKindOf(CC_RUNTIME_CLASS(GRenderRegion)) )
01325     {
01326         // Safe to cast now
01327         GRenderRegion *gRnd = (GRenderRegion*)pRegion;
01328 
01329         // Do the rendering
01330         return gRnd->RenderGradFillPath(pPath, this);
01331     }
01332     else if ( pRegion->IsKindOf(CC_RUNTIME_CLASS(OSRenderRegion)) )
01333     {
01334         // Safe to cast now
01335         OSRenderRegion *oRnd = (OSRenderRegion*)pRegion;
01336 
01337         // Do the rendering
01338         return oRnd->RenderGradFillPath(pPath, this);
01339     }
01340     return FALSE;
01341 }

BOOL GradFillAttribute::SameColourRampAs ColourRamp pOtherRamp  ) 
 

Check whether this colour ramp matches that pointed to by pOtherRamp.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/3/97
Parameters:
pOtherRamp = the colour ramp to match this one agains [INPUTS]
Returns:
TRUE if the colour ramps are the same FALSE if not

Definition at line 1127 of file fillval.cpp.

01128 {
01129     // Have we got a transparency ramp at the moment?
01130     if (m_pColourRamp==NULL)
01131         return (pOtherRamp==NULL);
01132 
01133     if (pOtherRamp==NULL)
01134         return FALSE;
01135 
01136     return (!(m_pColourRamp->IsDifferentTo(pOtherRamp)));
01137 }

BOOL GradFillAttribute::SetColourRamp ColourRamp pRamp  )  [virtual]
 

Set this colour ramp to the version passed in. If pRamp is NULL, the colour ramp in this object will be emptied.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/3/97
Parameters:
pRamp = a pointer to a colour ramp [INPUTS]
Returns:
TRUE if the colour ramp was set, FALSE if not

Reimplemented from FillGeometryAttribute.

Definition at line 1152 of file fillval.cpp.

01153 {
01154     DeleteColourRamp();
01155     if (pRamp==NULL)
01156         return TRUE;
01157     
01158     m_pColourRamp = new ColourRamp();
01159     if (m_pColourRamp==NULL)
01160         return FALSE;
01161 
01162     *m_pColourRamp = *pRamp;
01163     return TRUE;
01164 }

void GradFillAttribute::SetEndColour DocColour NewCol  )  [virtual]
 

Sets the End Colour of this fill.

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

Reimplemented from FillGeometryAttribute.

Reimplemented in BitmapFillAttribute, NoiseFillAttribute, and FractalFillAttribute.

Definition at line 1393 of file fillval.cpp.

01394 {
01395     if (NewCol == NULL)
01396     {
01397         AttributeManager::FindDefaultColour(ColourManager::GetCurrentColourList(),
01398                                             _R(IDS_BLACKNAME), &EndColour);
01399     }
01400     else
01401         EndColour = *NewCol;
01402 }

void GradFillAttribute::SetEndPoint DocCoord Pos  )  [virtual]
 

Sets the End Point of this fill.

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

Reimplemented from FillGeometryAttribute.

Reimplemented in BitmapFillAttribute.

Definition at line 1374 of file fillval.cpp.

01375 {
01376     if (Pos == NULL)
01377         EndPoint = DocCoord(0,0);
01378     else
01379         EndPoint = *Pos;
01380 }

void GradFillAttribute::SetStartPoint DocCoord Pos  )  [virtual]
 

Sets the Start Point of this fill.

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

Reimplemented from FillGeometryAttribute.

Reimplemented in BitmapFillAttribute.

Definition at line 1355 of file fillval.cpp.

01356 {
01357     if (Pos == NULL)
01358         StartPoint = DocCoord(0,0);
01359     else
01360         StartPoint = *Pos;
01361 }

void GradFillAttribute::SimpleCopy AttributeValue pValue  )  [virtual]
 

See AttributeValue::SimpleCopy.

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

Reimplemented from FillGeometryAttribute.

Reimplemented in RadialFillAttribute, BitmapFillAttribute, NoiseFillAttribute, and FractalFillAttribute.

Definition at line 1417 of file fillval.cpp.

01418 {
01419     *(this) = *((FillGeometryAttribute*)pValue);
01420 }

virtual BOOL GradFillAttribute::SupportsFillRamps  )  [inline, virtual]
 

Reimplemented from FillGeometryAttribute.

Reimplemented in ThreeColFillAttribute.

Definition at line 480 of file fillval.h.

00480 { return TRUE; }


Member Data Documentation

DocColour GradFillAttribute::EndColour
 

Definition at line 474 of file fillval.h.

DocCoord GradFillAttribute::EndPoint
 

Definition at line 476 of file fillval.h.

ColourRamp* GradFillAttribute::m_pColourRamp [protected]
 

Definition at line 488 of file fillval.h.

DocCoord GradFillAttribute::StartPoint
 

Definition at line 475 of file fillval.h.


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