ColourRamp Class Reference

This class holds a list of colour records, each of which describe a colour position in a colour ramp. The list contains the usual add/delete entry members and other suitable interfaces to allow colour ramps to be edited. The list is used inside GradFillAttribute to describe multicoloured fills. More...

#include <fillramp.h>

Inheritance diagram for ColourRamp:

FillRamp List CCObject SimpleCCObject List of all members.

Public Member Functions

virtual ~ColourRamp ()
 This class holds a list of colour records, each of which describe a colour position in a colour ramp. The list contains the usual add/delete entry members and other suitable interfaces to allow colour ramps to be edited. The list is used inside GradFillAttribute to describe multicoloured fills.
ColRampItemAddEntry (float pos, DocColour *pCol)
 Add a new colour ramp entry. Its selected state is FALSE.
ColRampItemGetFirstCol () const
ColRampItemGetLastCol () const
ColRampItemGetNextCol (ColRampItem *pItem) const
ColRampItemGetPrevCol (ColRampItem *pItem) const
ColourRampoperator= (const ColourRamp &other)
 Assign this colour ramp the same values as those refered to in other.
DocColourGetFirstSelectedColour ()
 Set all selected items in the colour ramp to the colour specified.
DocColourEnumerateColourFields (UINT32 index)
 Enumerates all colour fields in the colour ramp. This linear searching is not so quick. We might need to keep a static context pointer here.
BOOL IsDifferentTo (ColourRamp *pRamp)
 Another matching function. See if this colour ramp is different to that pointed to by pRamp See Also: ColourRamp::operator==.
INT32 operator== (const ColourRamp &other) const
 Dumps the data held in the fill ramp to the debug outputTry to match this colour ramp with another colour ramp. We simply check the numbers in the list, and if the same call the colour ramp entry eqivalence operator agains each list entry.
void DeleteAll ()
 Deletes all members of the colour ramp list. This is an internal private function which is used by other operations in this class.
BOOL SetItemColour (UINT32 index, DocColour *pCol)
 Set the colour of an existing colour ramp entry to a new value.
INT32 SetSelectedColours (DocColour *pCol)
 Set all selected items in the colour ramp to the colour specified.
BOOL CopyComponentData (BaseDocument *SrcDoc, BaseDocument *NodesDoc)
 If the attribute contains any DocColours which are indexed then a copy of the indexed colour is made and added to the NodesDoc ColourListComponent.
BOOL WriteColourDefinitions (BaseCamelotFilter *pFilter)
 Writes out colour definitions for this fill.
void Dump ()

Detailed Description

This class holds a list of colour records, each of which describe a colour position in a colour ramp. The list contains the usual add/delete entry members and other suitable interfaces to allow colour ramps to be edited. The list is used inside GradFillAttribute to describe multicoloured fills.

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

Definition at line 334 of file fillramp.h.


Constructor & Destructor Documentation

ColourRamp::~ColourRamp  )  [virtual]
 

This class holds a list of colour records, each of which describe a colour position in a colour ramp. The list contains the usual add/delete entry members and other suitable interfaces to allow colour ramps to be edited. The list is used inside GradFillAttribute to describe multicoloured fills.

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

Definition at line 1698 of file fillramp.cpp.

01699 {
01700     DeleteAll();
01701 }


Member Function Documentation

ColRampItem * ColourRamp::AddEntry float  pos,
DocColour pCol
 

Add a new colour ramp entry. Its selected state is FALSE.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/2/97
Parameters:
pos = the position this doc colour occupies in the colour ramp 0..1 [INPUTS] pCol = the doc colour to add
- [OUTPUTS]
Returns:
ColRampItem* , a pointer to the list entry created or NULL if out of memory

Definition at line 1738 of file fillramp.cpp.

01739 {
01740     ERROR2IF(((pos<0.0)||(pos>1.0)), NULL, "position out of range!");
01741     ERROR2IF(pCol==NULL, NULL, "no colour passed to ColourRamp::AddEntry()");
01742 
01743     // create ourselves a new colour ramp item
01744     ColRampItem *pNewItem = new ColRampItem(pos,pCol);
01745     if (pNewItem)
01746         // insert it in the list
01747         InsertNewItem(pNewItem);
01748 
01749     // return the item pointer
01750     return pNewItem;
01751 }

BOOL ColourRamp::CopyComponentData BaseDocument SrcDoc,
BaseDocument NodesDoc
 

If the attribute contains any DocColours which are indexed then a copy of the indexed colour is made and added to the NodesDoc ColourListComponent.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/9/2000
Parameters:
SrcDoc,: The document from where this node was copied [INPUTS] NodesDoc: The document where this node lives
- [OUTPUTS]
Returns:
FALSE if unable to copy data

Errors: -

See also:
AttrFillGeometry::CopyComponentData
NOTE: This is the companion function to the one in AttrFillGeometry.

Definition at line 1967 of file fillramp.cpp.

01968 {
01969     // Get the colour list component
01970     ColourListComponent *pComponent = 
01971         (ColourListComponent *) NodesDoc->GetDocComponent(CC_RUNTIME_CLASS(ColourListComponent));
01972 
01973     ENSURE (pComponent != NULL, "Could not find ColourListComponent");
01974     
01975     ColRampItem *pItem = GetFirstCol();
01976     
01977     // Copy across all DocColours
01978 
01979     while (pItem!=NULL)
01980     {
01981         DocColour* pDocCol = pItem->GetColourAddr ();
01982 
01983         if (pDocCol) if (pComponent->CopyColourAcross(pDocCol) == CCCOPY_FAILED) { return (FALSE); }
01984         
01985         pItem = GetNextCol(pItem);
01986     }
01987     
01988     return (TRUE);
01989 }

void ColourRamp::DeleteAll  )  [virtual]
 

Deletes all members of the colour ramp list. This is an internal private function which is used by other operations in this class.

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

Reimplemented from List.

Definition at line 1716 of file fillramp.cpp.

01717 {
01718     ColRampItem* pItem;
01719     while ((pItem=((ColRampItem*)RemoveTail()))!=NULL)
01720         delete pItem;
01721 }

void ColourRamp::Dump  )  [inline]
 

Definition at line 366 of file fillramp.h.

00366 { } ;

DocColour * ColourRamp::EnumerateColourFields UINT32  real_index  ) 
 

Enumerates all colour fields in the colour ramp. This linear searching is not so quick. We might need to keep a static context pointer here.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/3/97
Parameters:
real_index = an unbiased index [0..n-1] [INPUTS]
Returns:
A pointer to the colour record held in this indexed item or NULL

Definition at line 2069 of file fillramp.cpp.

02070 {
02071     RampItem *pItem = GetIndexedItem(real_index);
02072     if (pItem)
02073         return ((ColRampItem*)pItem)->GetColourAddr();
02074     return NULL;
02075 }

ColRampItem * ColourRamp::GetFirstCol  )  const [inline]
 

Definition at line 373 of file fillramp.h.

00374 {
00375     return (ColRampItem*)GetHead();
00376 }

DocColour * ColourRamp::GetFirstSelectedColour  ) 
 

Set all selected items in the colour ramp to the colour specified.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/3/97
Parameters:
col = the doc colour to set [INPUTS]
Returns:
the number of colours set.

Definition at line 2044 of file fillramp.cpp.

02045 {
02046     ColRampItem *pItem = GetFirstCol();
02047     while (pItem!=NULL)
02048     {
02049         if (pItem->IsSelected())
02050             return pItem->GetColourAddr();
02051         pItem = GetNextCol(pItem);
02052     }
02053     return NULL;
02054 }

ColRampItem * ColourRamp::GetLastCol  )  const [inline]
 

Definition at line 379 of file fillramp.h.

00380 {
00381     return (ColRampItem*)GetTail();
00382 }

ColRampItem * ColourRamp::GetNextCol ColRampItem pItem  )  const [inline]
 

Definition at line 385 of file fillramp.h.

00386 {
00387     return (ColRampItem*)GetNext(pItem);
00388 }

ColRampItem * ColourRamp::GetPrevCol ColRampItem pItem  )  const [inline]
 

Definition at line 391 of file fillramp.h.

00392 {
00393     return (ColRampItem*)GetPrev(pItem);
00394 }

BOOL ColourRamp::IsDifferentTo ColourRamp pRamp  ) 
 

Another matching function. See if this colour ramp is different to that pointed to by pRamp See Also: ColourRamp::operator==.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/2/97
Parameters:
pRamp = the ramp to check against [INPUTS]
- [OUTPUTS]
Returns:
TRUE if other is different to this

Definition at line 1840 of file fillramp.cpp.

01841 {
01842     ERROR3IF(this==NULL, "NULL 'this' object in ColourRamp::IsDifferentTo()");
01843     if (pRamp==NULL)
01844         return TRUE;
01845     return (!((*this)==(*pRamp)));
01846 }

ColourRamp & ColourRamp::operator= const ColourRamp other  ) 
 

Assign this colour ramp the same values as those refered to in other.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/2/97
Parameters:
other = a colour ramp reference [INPUTS]
- [OUTPUTS]
Returns:
A reference to this colour ramp

Definition at line 1862 of file fillramp.cpp.

01863 {
01864     // the main problem we need to deal with here is 'what happens
01865     // when we fail to copy the entire list? Well, it makes no sense
01866     // to keep the old list as we've not then assigned anything
01867     // i.e. C=A=B not assigning A and C anything is a bit weird.
01868     // so we go ahead and toast whatever was in list A and copy B to
01869     // it (as much as we can at least). If afterwards A!=B then we
01870     // know we're out of memory
01871 
01872     // toast all colours in our list
01873     DeleteAll();
01874     BOOL ok = TRUE;
01875 
01876     ColRampItem *pThisItem, *pOtherItem = other.GetFirstCol();
01877     while (pOtherItem && ok)
01878     {
01879         pThisItem = new ColRampItem(*pOtherItem);
01880         ok = (pThisItem != NULL);
01881         if (ok)
01882         {
01883             // Add the new colour to our list
01884             AddTail(pThisItem);
01885             pOtherItem = other.GetNextCol(pOtherItem);
01886         }
01887     }
01888 
01889     // run a debug check.
01890     ERROR3IF(!ok, "ColourRamp::operator= failed to copy the complete ColourRamp");
01891 
01892     return (*this);
01893 }

INT32 ColourRamp::operator== const ColourRamp other  )  const
 

Dumps the data held in the fill ramp to the debug outputTry to match this colour ramp with another colour ramp. We simply check the numbers in the list, and if the same call the colour ramp entry eqivalence operator agains each list entry.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/2/97
Parameters:
other = a colour ramp reference [INPUTS]
- [OUTPUTS]
Returns:
TRUE if other is equivalent to this

Definition at line 1805 of file fillramp.cpp.

01806 {
01807     if (GetCount() != other.GetCount())
01808         return FALSE;
01809 
01810     ColRampItem *pThisItem = GetFirstCol();
01811     ColRampItem *pThatItem = other.GetFirstCol();
01812 
01813     BOOL ok=TRUE;
01814     while (pThisItem && ok)
01815     {
01816         ok = ((*pThisItem)==(*pThatItem));
01817         pThisItem = GetNextCol(pThisItem);
01818         pThatItem = other.GetNextCol(pThatItem);
01819     }
01820 
01821     return ok;
01822 }

BOOL ColourRamp::SetItemColour UINT32  index,
DocColour pCol
 

Set the colour of an existing colour ramp entry to a new value.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/3/97
Parameters:
index = the index of the ramp entry [INPUTS] pCol = the doc colour to set
Returns:
TRUE if the colour has been set

Definition at line 1909 of file fillramp.cpp.

01910 {
01911     RampItem *pItem = GetValidIndexedItem(index);
01912     if (pItem!=NULL)
01913         ((ColRampItem*)pItem)->SetColour(pCol);
01914     return (pItem!=NULL);
01915 }

INT32 ColourRamp::SetSelectedColours DocColour pCol  ) 
 

Set all selected items in the colour ramp to the colour specified.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/3/97
Parameters:
col = the doc colour to set [INPUTS]
Returns:
the number of colours set.

Definition at line 1929 of file fillramp.cpp.

01930 {
01931     INT32 c=0;
01932     ColRampItem *pItem = GetFirstCol();
01933     while (pItem!=NULL)
01934     {
01935         if (pItem->IsSelected())
01936         {
01937             pItem->SetColour(pCol);
01938             c++;
01939         }
01940         pItem = GetNextCol(pItem);
01941     }
01942     return c;
01943 }

BOOL ColourRamp::WriteColourDefinitions BaseCamelotFilter pFilter  ) 
 

Writes out colour definitions for this fill.

> virtual BOOL ColourRamp::WriteColourDefinitions (BaseCamelotFilter* pFilter)

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/9/2000
Parameters:
pFilter = ptr to the filter [INPUTS]
Returns:
TRUE if record is written, FALSE if not
See also:
BaseCamelotFilter::WriteRemainingAtomicTagDefinitions () Layer::WriteAtomicNodesColourRefs ()

Definition at line 2006 of file fillramp.cpp.

02007 {
02008     BOOL ok = TRUE;
02009 
02010     ColRampItem *pItem = GetFirstCol();
02011 
02012     while (pItem!=NULL)
02013     {
02014         DocColour* pDocCol = pItem->GetColourAddr ();
02015         INT32 ColRef = pFilter->WriteRecord(pDocCol);
02016 
02017         ok = (ColRef != 0);
02018 
02019         if (ok)
02020         {
02021             pItem = GetNextCol(pItem);
02022         }
02023         else
02024         {
02025             pItem = NULL;
02026         }
02027     }
02028 
02029     return (ok);
02030 }


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