CHSVChanger Class Reference

Similar to its parent class but adds the following options: More...

#include <cnamecol.h>

Inheritance diagram for CHSVChanger:

CNamedColourReplacer CCObject SimpleCCObject List of all members.

Public Member Functions

 CHSVChanger ()
 default constructor
 CHSVChanger (ColourFillAttribute *, DocColour *)
 default constructor
 ~CHSVChanger ()
 destructor
virtual BOOL ReplaceColours ()
 This function asks the colour fill for its colours one by one, checks to see if they are named, or if they were created by a named colour. If so it copies them and stores them. It then replaces them with our replacement colour.
virtual BOOL RestoreColours ()
 Restores the colours that were changed.
BOOL ChangeHSVValues ()
 The raison d'etre of this object. Changes the HSV values of the member fill.
BOOL ShouldChangeHSV ()
 does a few checks to see if it is worth changing hsv values, currently we only use the multipliers so it just checks to see if they are default or not
virtual BOOL IsInitialised ()
void ChangeColour (DocColour *pCol)
 Simply changes the values in this one colour alone, in case you're fed up of worrying about attributes and the like.
double GetHueMultiplier ()
 Access.
BOOL SetHueMultiplier (double Value)
 Sets the Hue multiplier, also calculates the value that will be added/subtracted from the colour.
double GetSaturationMultiplier ()
 Access.
BOOL SetSaturationMultiplier (double Value)
 Sets the saturation multiplier, also calculates the addition/subtraction value.

Protected Member Functions

void ApplyIncrements (DocColour *pCol)
 Takes a colour, extracts its HSV values, adds (or subtracts) the increment value.

Protected Attributes

double m_HueMultiplier
double m_SaturationMultiplier
double m_ValueMultiplier
INT32 m_HueIncrement
INT32 m_SatIncrement
DocColour m_OrigStartCol
DocColour m_OrigEndCol1
DocColour m_OrigEndCol2
DocColour m_OrigEndCol3

Detailed Description

Similar to its parent class but adds the following options:

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/4/2000
Notes: This works by taking a multiplier value and calculating a fixed value that will be added or subtracted from each colour value. Values are in the range 0 - 255, however Hue values can 'wrap - around' due to the colour wheel effect.

Definition at line 177 of file cnamecol.h.


Constructor & Destructor Documentation

CHSVChanger::CHSVChanger  ) 
 

default constructor

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000

Definition at line 385 of file cnamecol.cpp.

00385                          : CNamedColourReplacer()
00386 {
00387     m_HueMultiplier         = 1.0;
00388     m_SaturationMultiplier  = 1.0;
00389     m_ValueMultiplier       = 1.0;
00390     m_HueIncrement          = 0;
00391     m_SatIncrement          = 0;
00392 }

CHSVChanger::CHSVChanger ColourFillAttribute pFill,
DocColour pCol
 

default constructor

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000

Definition at line 406 of file cnamecol.cpp.

00406                                                                     : CNamedColourReplacer(pFill, pCol)
00407 {
00408     m_HueMultiplier         = 1.0;
00409     m_SaturationMultiplier  = 1.0;
00410     m_ValueMultiplier       = 1.0;
00411     m_HueIncrement          = 0;
00412     m_SatIncrement          = 0;
00413 
00414 }

CHSVChanger::~CHSVChanger  ) 
 

destructor

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000

Definition at line 427 of file cnamecol.cpp.

00428 {
00429 //  PORTNOTETRACE("other","CHSVChanger::~CHSVChanger - do nothing");
00430 //#ifndef EXCLUDE_FROM_XARALX
00431     // have to do a hack here to ensure that we don't decrement the usage count on 
00432     // indexed colours which we never incremented in the first place
00433     m_OrigStartCol.HackColReplacerPreDestruct();
00434     m_OrigEndCol1.HackColReplacerPreDestruct();
00435     m_OrigEndCol2.HackColReplacerPreDestruct();
00436     m_OrigEndCol3.HackColReplacerPreDestruct();
00437 //#endif
00438 }


Member Function Documentation

void CHSVChanger::ApplyIncrements DocColour pCol  )  [protected]
 

Takes a colour, extracts its HSV values, adds (or subtracts) the increment value.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
pCol - the colour to be incremented [INPUTS]
Returns:
-

Definition at line 633 of file cnamecol.cpp.

00634 {
00635 //  PORTNOTETRACE("other","CHSVChanger::ApplyIncrements - do nothing");
00636 //#ifndef EXCLUDE_FROM_XARALX
00637     if (pCol == NULL)
00638     {
00639         ERROR3("Colour pointer is NULL in CHSVChanger::ApplyIncrements");
00640         return;
00641     }
00642 
00643     INT32 Hue;
00644     INT32 Sat;
00645     INT32 Dummy;
00646 
00647     pCol->GetHSVValue(&Hue, &Sat, &Dummy);
00648     //TRACEUSER( "Diccon", _T("Original Sat = %d, "), Sat);
00649     //TRACEUSER( "Diccon", _T("Original Hue = %d, "), Hue);
00650     Hue += m_HueIncrement;
00651     if (Hue < 0)
00652         Hue += MAX_HUE_VALUE;
00653     else if (Hue > MAX_HUE_VALUE)
00654         Hue -= MAX_HUE_VALUE;
00655 
00656     Sat -= abs(m_SatIncrement);
00657         if (Sat < 0)
00658         Sat = 1;
00659     else if (Sat > MAX_SAT_VALUE)
00660         Sat = MAX_SAT_VALUE;
00661     
00662 //  TRACEUSER( "Diccon", _T("SatIncr = %d, New Sat = %d\n"), m_SatIncrement, Sat);
00663 //  TRACEUSER( "Diccon", _T("Hue Incr = %d, New Hue = %d\n"), m_HueIncrement, Hue);
00664     pCol->SetHSVValue(Hue, Sat, Dummy);
00665 //#endif
00666 }

void CHSVChanger::ChangeColour DocColour pCol  ) 
 

Simply changes the values in this one colour alone, in case you're fed up of worrying about attributes and the like.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
pCol - pointer to the colour we wish to change [INPUTS]
Colour with changed values [OUTPUTS]
Returns:
-

Definition at line 766 of file cnamecol.cpp.

00767 {
00768     if (pCol == NULL)
00769         return;
00770     ApplyIncrements(pCol);
00771 }

BOOL CHSVChanger::ChangeHSVValues  ) 
 

The raison d'etre of this object. Changes the HSV values of the member fill.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
- [INPUTS]
Returns:
TRUE if all went well, FALSE if something went wrong

Definition at line 476 of file cnamecol.cpp.

00477 {
00478     if (m_pColourFill == NULL)
00479     {
00480         ERROR3("Colour fill is NULL in CHSVChanger::ChangeHSVValues");
00481         return FALSE;
00482     }
00483     
00484     // we need to ask for the colours one by one
00485     DocColour* pStartCol = NULL;
00486     if (m_pReplaceColour != NULL)
00487         pStartCol = m_pReplaceColour;
00488     else
00489         pStartCol = m_pColourFill->GetStartColour();
00490     
00491     if (pStartCol != NULL)
00492     {
00493         m_OrigStartCol = *pStartCol;
00494         ApplyIncrements(pStartCol);
00495         m_pColourFill->SetStartColour(pStartCol);
00496     }
00497 
00498     DocColour* pEndCol1 = m_pColourFill->GetEndColour();
00499     if (pEndCol1 != NULL) 
00500     {
00501         // first record our original values
00502         m_OrigEndCol1 = *pEndCol1;
00503         ApplyIncrements(pEndCol1);
00504     }
00505     
00506     DocColour* pEndCol2 = m_pColourFill->GetEndColour2();
00507     if (pEndCol2 != NULL) 
00508     {
00509         // first record our original values
00510         m_OrigEndCol2 = *pEndCol2;
00511         ApplyIncrements(pEndCol2);
00512     }
00513 
00514     DocColour* pEndCol3 = m_pColourFill->GetEndColour3();
00515     if (pEndCol3 != NULL)
00516     {
00517         // first record our original values
00518         m_OrigEndCol3 = *pEndCol3;
00519         ApplyIncrements(pEndCol3);
00520     }
00521     
00522     return TRUE;
00523 }

double CHSVChanger::GetHueMultiplier  ) 
 

Access.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
the hue multiplier, duh

Definition at line 682 of file cnamecol.cpp.

00683 {
00684     return m_HueMultiplier;
00685 }

double CHSVChanger::GetSaturationMultiplier  ) 
 

Access.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
the Saturation multiplier, duh

Definition at line 723 of file cnamecol.cpp.

00724 {
00725     return m_SaturationMultiplier;
00726 }

BOOL CHSVChanger::IsInitialised  )  [virtual]
 

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
- [INPUTS]
Returns:
true, if this object was initialised in any way

Reimplemented from CNamedColourReplacer.

Definition at line 591 of file cnamecol.cpp.

00592 {
00593     BOOL Init = m_pReplaceColour != NULL ||
00594                 m_HueMultiplier != 1.0 || 
00595                 m_SaturationMultiplier != 1.0;
00596 
00597     return Init;
00598 }

BOOL CHSVChanger::ReplaceColours  )  [virtual]
 

This function asks the colour fill for its colours one by one, checks to see if they are named, or if they were created by a named colour. If so it copies them and stores them. It then replaces them with our replacement colour.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
- [INPUTS]
Returns:
TRUE if all went well, FALSE if something went wrong

Reimplemented from CNamedColourReplacer.

Definition at line 455 of file cnamecol.cpp.

00456 {
00457     // if we also want to replace colours then do that first
00458     if (m_pReplaceColour != NULL)
00459         return CNamedColourReplacer::ReplaceColours();
00460 
00461     return TRUE;
00462 }

BOOL CHSVChanger::RestoreColours  )  [virtual]
 

Restores the colours that were changed.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
- [INPUTS]
Returns:
TRUE if all went well, FALSE if something went wrong

Reimplemented from CNamedColourReplacer.

Definition at line 538 of file cnamecol.cpp.

00539 {
00540     if (m_pColourFill == NULL)
00541         return FALSE;
00542 
00543     // here we restore any named colours we replaced
00544     if (m_pReplaceColour != NULL)
00545         return CNamedColourReplacer::RestoreColours();
00546 
00547     // we need to ask for the colours one by one
00548     DocColour* pStartCol = m_pColourFill->GetStartColour();
00549     if (pStartCol != NULL)
00550     {
00551         *pStartCol = m_OrigStartCol;
00552     }
00553 
00554     DocColour* pEndCol1 = m_pColourFill->GetEndColour();
00555     if (pEndCol1 != NULL) 
00556     {
00557         *pEndCol1 = m_OrigEndCol1;
00558 
00559     }
00560     
00561     DocColour* pEndCol2 = m_pColourFill->GetEndColour2();
00562     if (pEndCol2 != NULL) 
00563     {
00564         *pEndCol2 = m_OrigEndCol2;
00565     }
00566 
00567     DocColour* pEndCol3 = m_pColourFill->GetEndColour3();
00568     if (pEndCol3 != NULL)
00569     {
00570         *pEndCol3 = m_OrigEndCol3;
00571     }
00572     
00573     return TRUE;    
00574 
00575 
00576 
00577 }

BOOL CHSVChanger::SetHueMultiplier double  Value  ) 
 

Sets the Hue multiplier, also calculates the value that will be added/subtracted from the colour.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
the hue multiplier, duh [INPUTS]
- [OUTPUTS]
Returns:
always TRUE at the moment

Definition at line 702 of file cnamecol.cpp.

00703 {
00704     m_HueMultiplier = Value;
00705     m_HueIncrement = (INT32)Value; // * (double)MAX_HUE_VALUE);
00706     //TRACEUSER( "Diccon", _T("Hue Increment = %d\n"), m_HueIncrement);
00707     return TRUE;
00708 }

BOOL CHSVChanger::SetSaturationMultiplier double  Value  ) 
 

Sets the saturation multiplier, also calculates the addition/subtraction value.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
the Saturation multiplier, as you might expect [INPUTS]
- [OUTPUTS]
Returns:
TRUE

Definition at line 742 of file cnamecol.cpp.

00743 {
00744     m_SaturationMultiplier = Value;
00745 
00746     m_SatIncrement = (INT32)(Value * (double)MAX_SAT_VALUE);
00747     
00748     //TRACEUSER( "Diccon", _T("Sat increment = %d\n"), m_SatIncrement);
00749     return TRUE;
00750 }

BOOL CHSVChanger::ShouldChangeHSV  ) 
 

does a few checks to see if it is worth changing hsv values, currently we only use the multipliers so it just checks to see if they are default or not

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
- [INPUTS]
Returns:
true, if ChangeHSV should be called, FALSE otherwise

Definition at line 612 of file cnamecol.cpp.

00613 {
00614     BOOL bShouldReplace = (m_HueIncrement != 0 || m_SatIncrement != 0);
00615 
00616     return bShouldReplace;
00617 }


Member Data Documentation

INT32 CHSVChanger::m_HueIncrement [protected]
 

Definition at line 216 of file cnamecol.h.

double CHSVChanger::m_HueMultiplier [protected]
 

Definition at line 212 of file cnamecol.h.

DocColour CHSVChanger::m_OrigEndCol1 [protected]
 

Definition at line 222 of file cnamecol.h.

DocColour CHSVChanger::m_OrigEndCol2 [protected]
 

Definition at line 223 of file cnamecol.h.

DocColour CHSVChanger::m_OrigEndCol3 [protected]
 

Definition at line 224 of file cnamecol.h.

DocColour CHSVChanger::m_OrigStartCol [protected]
 

Definition at line 221 of file cnamecol.h.

INT32 CHSVChanger::m_SatIncrement [protected]
 

Definition at line 217 of file cnamecol.h.

double CHSVChanger::m_SaturationMultiplier [protected]
 

Definition at line 213 of file cnamecol.h.

double CHSVChanger::m_ValueMultiplier [protected]
 

Definition at line 214 of file cnamecol.h.


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