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

TranspFillAttribute FillGeometryAttribute AttributeValue CCObject SimpleCCObject BitmapTranspFillAttribute ConicalTranspFillAttribute LinearTranspFillAttribute RadialTranspFillAttribute SquareTranspFillAttribute ThreeColTranspFillAttribute FractalTranspFillAttribute NoiseTranspFillAttribute FourColTranspFillAttribute List of all members.

Public Member Functions

 GradTranspFillAttribute ()
 Default Constuctor for fill attribute values.
 ~GradTranspFillAttribute ()
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 DocCoordGetStartPoint ()
virtual DocCoordGetEndPoint ()
virtual UINT32GetEndTransp ()
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 SetEndTransp (UINT32 *NewTransp)
 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.
virtual ColourFillAttributeMakeSimilarNonTranspFillGeometry (double TransparencyScale)
 Creates a non-transparent version of this transparent fill attribute. (The original use of this was so airbrushes could maintain their fill's transparency geometry).
virtual BOOL SupportsFillRamps ()
virtual BOOL SetTranspRamp (TransparencyRamp *pRamp)
 Sets this transparency ramp from pRamp passed in. If pRamp is NULL on entry this objects ramp will be emptied.
virtual TransparencyRampGetTranspRamp ()
TransparencyRampMakeNewTranspRamp ()
 Create a blank transparency ramp.
BOOL SameTransparencyRampAs (TransparencyRamp *pOtherRamp)
 Check whether this transparency ramp matches that of the attribute.
void DeleteTranspRamp ()

Public Attributes

DocCoord StartPoint
DocCoord EndPoint
UINT32 EndTransp

Protected Attributes

TransparencyRampm_pTranspRamp

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:
23/8/94
See also:
FillGeometryAttribute

Definition at line 1071 of file fillval.h.


Constructor & Destructor Documentation

GradTranspFillAttribute::GradTranspFillAttribute  ) 
 

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 4449 of file fillval.cpp.

04450 {                      
04451     EndTransp = 255;
04452 
04453     StartPoint = DocCoord(0,0);
04454     EndPoint = DocCoord(0,0);
04455 
04456     m_pTranspRamp = NULL;
04457 }

GradTranspFillAttribute::~GradTranspFillAttribute  ) 
 

Definition at line 4459 of file fillval.cpp.

04460 {
04461     DeleteTranspRamp();
04462 }


Member Function Documentation

BOOL GradTranspFillAttribute::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 9814 of file fillval.cpp.

09815 {
09816     return FillGeometryAttribute::Blend(pBlendParam);
09817 }

void GradTranspFillAttribute::DeleteTranspRamp  ) 
 

Definition at line 4464 of file fillval.cpp.

04465 {
04466     if (m_pTranspRamp!=NULL)
04467     {
04468         delete m_pTranspRamp;
04469         m_pTranspRamp=NULL;
04470     }
04471 }

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

Reimplemented from FillGeometryAttribute.

Reimplemented in BitmapTranspFillAttribute.

Definition at line 1084 of file fillval.h.

01084 { return &EndPoint; }

virtual UINT32* GradTranspFillAttribute::GetEndTransp  )  [inline, virtual]
 

Reimplemented from FillGeometryAttribute.

Reimplemented in BitmapTranspFillAttribute.

Definition at line 1085 of file fillval.h.

01085 { return &EndTransp; }

DocCoord GradTranspFillAttribute::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 ConicalTranspFillAttribute.

Definition at line 4611 of file fillval.cpp.

04612 {
04613     // This and all derived classes will inherit a linear coordinate space
04614     return DocCoord::PositionPointFromRatio(StartPoint,EndPoint,(double)pos);
04615 }

float GradTranspFillAttribute::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 ConicalTranspFillAttribute.

Definition at line 4631 of file fillval.cpp.

04632 {
04633     // ok we're a linear geometry so find the closest point to a line type of thing.
04634     // use a handy util written by that other fab bloke called Mike.
04635     DocCoord Coords[2];
04636     Coords[0] = StartPoint;
04637     Coords[1] = EndPoint;
04638     double p;
04639     PathUtil::SqrDistanceToLine(Coords, c, &p);
04640     return (float)p;
04641 }

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

Reimplemented from FillGeometryAttribute.

Reimplemented in BitmapTranspFillAttribute.

Definition at line 1083 of file fillval.h.

01083 { return &StartPoint; }

virtual TransparencyRamp* GradTranspFillAttribute::GetTranspRamp  )  [inline, virtual]
 

Reimplemented from FillGeometryAttribute.

Definition at line 1107 of file fillval.h.

01107 { return m_pTranspRamp; }

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

Reimplemented from FillGeometryAttribute.

Definition at line 1092 of file fillval.h.

01092 { return TRUE; }

TransparencyRamp * GradTranspFillAttribute::MakeNewTranspRamp  ) 
 

Create a blank transparency ramp.

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

Definition at line 4655 of file fillval.cpp.

04656 {
04657     DeleteTranspRamp();
04658     m_pTranspRamp=new TransparencyRamp();
04659     return m_pTranspRamp;
04660 }

ColourFillAttribute * GradTranspFillAttribute::MakeSimilarNonTranspFillGeometry double  TransparencyScale  )  [virtual]
 

Creates a non-transparent version of this transparent fill attribute. (The original use of this was so airbrushes could maintain their fill's transparency geometry).

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/02/97
Parameters:
TransparencyScale - Value between 0.0 and 1.0 which denotes by how much [INPUTS] the function will scale the transparency
Returns:
Pointer to the new attribute, or NULL if out of memory, problems, etc.
See also:
TranspFillAttribute::MakeSimilarNonTranspFillGeometry; AttrFlatFill FlatTranspFillAttribute::MakeSimilarNonTranspFillGeometry

Reimplemented from TranspFillAttribute.

Reimplemented in LinearTranspFillAttribute, RadialTranspFillAttribute, ConicalTranspFillAttribute, SquareTranspFillAttribute, BitmapTranspFillAttribute, NoiseTranspFillAttribute, FractalTranspFillAttribute, ThreeColTranspFillAttribute, and FourColTranspFillAttribute.

Definition at line 4760 of file fillval.cpp.

04761 {
04762     UINT32 *pStartTransp = GetStartTransp();
04763     UINT32 *pEndTransp = GetEndTransp();
04764 
04765     if(pStartTransp == NULL || pEndTransp == NULL)
04766         return NULL;
04767 
04768     // This one's a bit dodgy I think   
04769     GradFillAttribute *pNewAttr = new GradFillAttribute;    
04770     if (pNewAttr != NULL)
04771     {
04772         pNewAttr->SetStartPoint(GetStartPoint());
04773         pNewAttr->SetEndPoint(GetEndPoint());
04774 
04775         INT32 StartTransparency = 255 - (INT32)(((double)(255 - *pStartTransp)) * TransparencyScale);
04776         INT32 EndTransparency = 255 - (INT32)(((double)(255 - *pEndTransp)) * TransparencyScale);
04777 
04778         DocColour       colorStart(StartTransparency, StartTransparency, StartTransparency);
04779         DocColour       colorEnd(EndTransparency, EndTransparency, EndTransparency);
04780         pNewAttr->SetStartColour(&colorStart);
04781         pNewAttr->SetEndColour(&colorEnd);
04782     
04783         // if this transparency has a transparency ramp then make
04784         // a colour ramp version in pNewAttr
04785         if (m_pTranspRamp)
04786         {
04787             ColourRamp* pColRamp = pNewAttr->MakeNewColourRamp();
04788             if (pColRamp)
04789             {
04790                 INT32 Col;
04791                 TranspRampItem *pItem = m_pTranspRamp->GetFirstTransp();
04792                 while (pItem!=NULL)
04793                 {
04794                     Col = 255 - (INT32)(((double)(255 - pItem->GetTransparency())) * TransparencyScale);
04795                     DocColour colorEntry(Col,Col,Col);
04796                     pColRamp->AddEntry(pItem->GetPosition(), &colorEntry );
04797                     pItem=m_pTranspRamp->GetNextTransp(pItem);
04798                 }
04799             }
04800         }
04801     }
04802 
04803     return(pNewAttr);
04804 }

FillGeometryAttribute & GradTranspFillAttribute::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.

See also:
AttrFillGeometry::operator==; NodeAttribute::operator==

Reimplemented from TranspFillAttribute.

Reimplemented in RadialTranspFillAttribute, BitmapTranspFillAttribute, NoiseTranspFillAttribute, and FractalTranspFillAttribute.

Definition at line 4512 of file fillval.cpp.

04513 {
04514     return TranspFillAttribute::operator=(FillAttrib);
04515 }

INT32 GradTranspFillAttribute::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 TranspFillAttribute.

Reimplemented in RadialTranspFillAttribute, BitmapTranspFillAttribute, NoiseTranspFillAttribute, FractalTranspFillAttribute, ThreeColTranspFillAttribute, and FourColTranspFillAttribute.

Definition at line 4533 of file fillval.cpp.

04534 {
04535     if (GetRuntimeClass() != Attrib.GetRuntimeClass())
04536         return FALSE;
04537 
04538     GradTranspFillAttribute* pAttrib = (GradTranspFillAttribute*)&Attrib;
04539 
04540     if (IsPerspective())
04541     { 
04542         if (!pAttrib->IsPerspective())
04543             return FALSE;
04544 
04545         if (*GetEndPoint2() != *pAttrib->GetEndPoint2())
04546             return FALSE;
04547 
04548         if (*GetEndPoint3() != *pAttrib->GetEndPoint3())
04549             return FALSE;
04550     }
04551 
04552     // check the transparency ramp matches
04553     if (!SameTransparencyRampAs(pAttrib->GetTranspRamp()))
04554         return FALSE;
04555     
04556     // Are the Colours and Control points all the same ?
04557     return (
04558 
04559         Transp      == pAttrib->Transp      &&
04560         EndTransp   == pAttrib->EndTransp   &&
04561 
04562         TranspType  == pAttrib->TranspType  &&
04563 
04564         StartPoint  == pAttrib->StartPoint  &&
04565         EndPoint    == pAttrib->EndPoint
04566     );
04567 }

BOOL GradTranspFillAttribute::SameTransparencyRampAs TransparencyRamp pOtherRamp  ) 
 

Check whether this transparency ramp matches that of the attribute.

BOOL GradTranspFillAttribute::SameTransparencyRampAs(TransparencyRamp *pOtherRamp)

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

Definition at line 4484 of file fillval.cpp.

04485 {
04486     // Have we got a transparency ramp at the moment?
04487     if (m_pTranspRamp==NULL)
04488         return (pOtherRamp==NULL);
04489 
04490     if (pOtherRamp==NULL)
04491         return FALSE;
04492 
04493     return (!( m_pTranspRamp->IsDifferentTo(pOtherRamp)));
04494 }

void GradTranspFillAttribute::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 BitmapTranspFillAttribute.

Definition at line 4693 of file fillval.cpp.

04694 {
04695     if (Pos == NULL)
04696         EndPoint = DocCoord(0,0);
04697     else
04698         EndPoint = *Pos;
04699 }

void GradTranspFillAttribute::SetEndTransp UINT32 NewTransp  )  [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 BitmapTranspFillAttribute.

Definition at line 4712 of file fillval.cpp.

04713 {
04714     if (NewTransp == NULL)
04715         EndTransp = 255;
04716     else
04717         EndTransp = *NewTransp;
04718 }

void GradTranspFillAttribute::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 BitmapTranspFillAttribute.

Definition at line 4674 of file fillval.cpp.

04675 {
04676     if (Pos == NULL)
04677         StartPoint = DocCoord(0,0);
04678     else
04679         StartPoint = *Pos;
04680 }

BOOL GradTranspFillAttribute::SetTranspRamp TransparencyRamp pRamp  )  [virtual]
 

Sets this transparency ramp from pRamp passed in. If pRamp is NULL on entry this objects ramp will be emptied.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/3/97
Parameters:
pRamp,a pointer to a transparency ramp or NULL [INPUTS]

Reimplemented from FillGeometryAttribute.

Definition at line 4582 of file fillval.cpp.

04583 {
04584     DeleteTranspRamp();
04585     if (pRamp==NULL)
04586         return TRUE;
04587     
04588     m_pTranspRamp = new TransparencyRamp();
04589     if (m_pTranspRamp==NULL)
04590         return FALSE;
04591 
04592     *m_pTranspRamp = *pRamp;
04593     return TRUE;
04594 }

void GradTranspFillAttribute::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 RadialTranspFillAttribute, BitmapTranspFillAttribute, NoiseTranspFillAttribute, and FractalTranspFillAttribute.

Definition at line 4733 of file fillval.cpp.

04734 {
04735     *(this) = *((FillGeometryAttribute*)pValue);
04736 }

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

Reimplemented from FillGeometryAttribute.

Reimplemented in ThreeColTranspFillAttribute.

Definition at line 1105 of file fillval.h.

01105 { return TRUE; }


Member Data Documentation

DocCoord GradTranspFillAttribute::EndPoint
 

Definition at line 1100 of file fillval.h.

UINT32 GradTranspFillAttribute::EndTransp
 

Definition at line 1101 of file fillval.h.

TransparencyRamp* GradTranspFillAttribute::m_pTranspRamp [protected]
 

Definition at line 1114 of file fillval.h.

DocCoord GradTranspFillAttribute::StartPoint
 

Definition at line 1099 of file fillval.h.


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