ColourContextGreyT Class Reference

Object class representing colour contexts based upon the GreyT colour model (Greyscale intensity, Transparent). More...

#include <colcontx.h>

Inheritance diagram for ColourContextGreyT:

ColourContext ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 ColourContextGreyT (View *Scope)
 Constructor for an GreyT Colour context.
void ConvertToCIET (ColourGeneric *Source, DColourCIET *Result)
 Converts the given colour from our GreyT colourspace to CIET colourspace Notes: -.
void ConvertFromCIET (DColourCIET *Source, ColourGeneric *Result)
 Converts the given colour to our GreyT colourspace from CIET colourspace Notes: -.
void CreateExternalTransform ()
 Create an external transform to be used during colour conversions from Grey to the current RCS space. This function uses the Winoil CMS Manager to create the transform. Both forward and backward transforms use logical RGB descriptions.
virtual void GetModelName (StringBase *Result)
 Returns the name of this context's colour model Notes:.
virtual BOOL GetComponentName (INT32 ComponentID, StringBase *Result, BOOL LongName=FALSE)
 Returns the name of one of this context's colour components.
virtual UINT32 GetComponentCount ()
 Provides number of components in the colour context's colour model.
virtual void ApplyTint (ColourValue TintFraction, ColourGeneric *SourceAndResult)
 Tints a colour (mixes it with white).
virtual void ApplyShade (ColourValue XFraction, ColourValue YFraction, ColourGeneric *SourceAndResult)
 Shades a colour (tweaks the saturation and value in a relative way).
virtual void GetWhite (ColourGeneric *Result)
 An easy way to get a colour definition in this colour model which is white (paper colour).

Protected Member Functions

virtual UnitGroup ** GetComponentUnitGroups ()
 Provides an array of UnitGroups primarily for use by the base class (ColourContext) members Set/GetComponentUnitGroup().

Private Types

enum  { MAX_COMPONENTS = 3 }

Static Private Attributes

static UnitGroupm_pUnitGroupArray [MAX_COMPONENTS]

Friends

class DocColour
class ColourContextList
class GRenderRegion
class OSRenderRegion

Detailed Description

Object class representing colour contexts based upon the GreyT colour model (Greyscale intensity, Transparent).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/06/94
See also:
Colour; ColourModel; ColourContext; ColourContextGreyT::ColourContextGreyT Documentation: HowToUse.doc

Definition at line 1217 of file colcontx.h.


Member Enumeration Documentation

anonymous enum [private]
 

Enumerator:
MAX_COMPONENTS 

Definition at line 1248 of file colcontx.h.

01249     {
01250         MAX_COMPONENTS = 3                                  // Number of components in colour context
01251     };


Constructor & Destructor Documentation

ColourContextGreyT::ColourContextGreyT View Scope  ) 
 

Constructor for an GreyT Colour context.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/6/94
Parameters:
Scope - The view in which this context is to be used, or NULL [INPUTS]
- [OUTPUTS]
Returns:
-
Notes: Colour Contexts should not be created and used directly. See the notes in the SeeAlso's for instructions on proper care and use.

Returns:
Errors: -
See also:
ColourContext::ColourContext; ColourContextList::AddContext

Definition at line 3670 of file colcontx.cpp.

03671                   : ColourContext(Scope)
03672 {
03673     ColModel = COLOURMODEL_GREYT;
03674 
03675     CreateExternalTransform();
03676 }


Member Function Documentation

void ColourContextGreyT::ApplyShade ColourValue  XFraction,
ColourValue  YFraction,
ColourGeneric SourceAndResult
[virtual]
 

Shades a colour (tweaks the saturation and value in a relative way).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/8/95
Parameters:
XFraction - The fraction (as a FIXED24 ColourValue) by which the colour [INPUTS] should be saturated. This value is expected to lie between -1.0 and 1.0 inclusive Values below 0.0 mean tint towards 0, while values above mean tint towards 1. 0.0 means no tinting
YFraction - The fraction (as a FIXED24 ColourValue) by which the colour should be shaded. This value is expected to lie between -1.0 and 1.0 inclusive Values below 0.0 mean shade towards 0, while values above mean shade towards 1. 0.0 means no shading

SourceAndResult - The source colour to be tinted, as defined in this colour model

Parameters:
SourceAndResult is shaded by the given Fractions [OUTPUTS] Any invalid value is clipped to 0.0
Returns:
-
Notes: Contexts other than HSV currently convert the colour to and from HSV form in order to apply the shade. This is a tad inefficient, but a quick'n'easy bodge that will get it going nice and quickly.

Implements ColourContext.

Definition at line 4062 of file colcontx.cpp.

04064 {
04065     ColourHSVT HSVDef;
04066     ColourContext *cc = ColourContext::GetGlobalDefault(COLOURMODEL_HSVT);
04067     ERROR3IF(cc == NULL, "No default HSV colour context?!");
04068 
04069     cc->ConvertColour(this, SourceAndResult, (ColourGeneric *) &HSVDef);
04070     cc->ApplyShade(XFraction, YFraction,  (ColourGeneric *) &HSVDef);
04071     ConvertColour(cc, (ColourGeneric *) &HSVDef, SourceAndResult);
04072 }

void ColourContextGreyT::ApplyTint ColourValue  TintFraction,
ColourGeneric SourceAndResult
[virtual]
 

Tints a colour (mixes it with white).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/11/94
Parameters:
TintFraction - The fraction (as a FIXED24 ColourValue) by which the colour [INPUTS] should be tinted. This value is expected to lie between 0.0 and 1.0 inclusive
SourceAndResult - The source colour to be tinted, as defined in this colour model

Parameters:
SourceAndResult is tinted by the given TintFraction [OUTPUTS] If TintFraction <= 0.0, White is output If TintFraction >= 1.0, The source colour is output
Returns:
-
Notes: If the tinting value is out of range, either source-colour ow white (as appropriate) will be output.

Implements ColourContext.

Definition at line 4011 of file colcontx.cpp.

04012 {
04013     ColourGreyT *Result = (ColourGreyT *) SourceAndResult;
04014     
04015     if (TintFraction <= FIXED24(0.0))       // 0% tint = White
04016     {
04017         Result->Intensity = FIXED24(1.0);
04018         return;
04019     }
04020 
04021     if (TintFraction >= FIXED24(1.0))       // The Result colour is identical to the source
04022         return;
04023 
04024     // Otherwise, tint the colour...
04025     Result->Intensity = FIXED24(1.0) - (TintFraction - (Result->Intensity * TintFraction));
04026 }

void ColourContextGreyT::ConvertFromCIET DColourCIET Source,
ColourGeneric Result
[virtual]
 

Converts the given colour to our GreyT colourspace from CIET colourspace Notes: -.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/04/94
Parameters:
Source - A Colour defined in the CIET colourspace [INPUTS] Result - pointer to a structure to recieve the resulting colour as defined in the GreyT space described by this colour context.
- [OUTPUTS]
Returns:
-

Errors: -

See also:
ColourContextGreyT::ConvertToCIET

Implements ColourContext.

Definition at line 3793 of file colcontx.cpp.

03794 {
03795     ENSURE(UsageCount > 0, "Colour context being used when not initialised!");
03796 
03797 #ifndef NO_XARACMS
03798     // If we've got a CMS manager, use it, else use the version 1.1 bodge
03799     XaraCMS* lpCMSMan = GetApplication()->GetCMSManager();
03800 
03801     if (lpCMSMan != NULL)
03802     {
03803         CMSColour icol, ocol;
03804 
03805         icol.c0 = Source->X;
03806         icol.c1 = Source->Y;
03807         icol.c2 = Source->Z;
03808 
03809         // If we have no colour transform, or if we don't want the colour corrected/separated,
03810         // then we will just do a "logical" conversion.
03811         if (CMSTransform == NULL || (ColPlate != NULL && ColPlate->IsDisabled()))
03812             lpCMSMan->ConvCIEXYZtoRGB(icol, ocol);
03813         else
03814             lpCMSMan->GTransform(CMSTransform, cmsReverse, icol, ocol);
03815 
03816         // The loadings below are taken from Gerry, the expert on colour loadings
03817         // in this particular office. No expense was spared to research these
03818         // values properly... ;-)
03819         double inten;
03820         inten = (ocol.c0 * 0.305) + (ocol.c1 * 0.586) + (ocol.c2 * 0.109);
03821         ((ColourGreyT *)Result)->Intensity = inten;
03822     }
03823     else
03824 #endif
03825     {
03826         double R, G, B;
03827         R = Source->X;
03828         G = Source->Y;
03829         B = Source->Z;
03830 
03831         // The loadings below are taken from Gerry, the expert on colour loadings
03832         // in this particular office. No expense was spared to research these
03833         // values properly... ;-)
03834         ((ColourGreyT *)Result)->Intensity = (R * 0.305) + (G * 0.586) + (B * 0.109);
03835     }
03836 
03837     // Set the transparency field
03838     ((ColourGreyT *)Result)->Transparent = 0;//Source->Transparent;
03839 
03840     // And ensure that the reserved fields are cleared
03841     ((ColourGreyT *)Result)->Reserved1 = ((ColourGreyT *)Result)->Reserved2 = 0;
03842 }

void ColourContextGreyT::ConvertToCIET ColourGeneric Source,
DColourCIET Result
[virtual]
 

Converts the given colour from our GreyT colourspace to CIET colourspace Notes: -.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/6/94
Parameters:
Source - A Colour defined in this GreyT context [INPUTS] Result - pointer to a structure to recieve the resulting colour as defined in CIE space
- [OUTPUTS]
Returns:
-

Errors: -

See also:
ColourContextGreyT::ConvertFromCIET

Implements ColourContext.

Definition at line 3735 of file colcontx.cpp.

03736 {
03737     ENSURE(UsageCount > 0, "Colour context being used when not initialised!");
03738 
03739 #ifndef NO_XARACMS
03740     // If we've got a CMS manager, use it, else use the version 1.1 bodge
03741     XaraCMS* lpCMSMan = GetApplication()->GetCMSManager();
03742 
03743     if (lpCMSMan != NULL)
03744     {
03745         // The new colour calibration method
03746         CMSColour icol, ocol;
03747 
03748         icol.c2 = ((ColourGreyT *)Source)->Intensity.MakeDouble();
03749         icol.c0 = icol.c1 = icol.c2;
03750 
03751         // If we have no colour transform, or if we don't want the colour corrected/separated,
03752         // then we will just do a "logical" conversion.
03753         if (CMSTransform == NULL || (ColPlate != NULL && ColPlate->IsDisabled()))
03754             lpCMSMan->ConvRGBtoCIEXYZ(icol, ocol);
03755         else
03756             lpCMSMan->GTransform(CMSTransform, cmsForward, icol, ocol);
03757 
03758         Result->X = ocol.c0;
03759         Result->Y = ocol.c1;
03760         Result->Z = ocol.c2;
03761     }
03762     else
03763 #endif
03764     {
03765         // The old rgb system
03766         Result->X = Result->Y = Result->Z = ((ColourGreyT *)Source)->Intensity.MakeDouble();
03767     }
03768 
03769     Result->Transparent = 0.0;//((ColourGreyT *)Source)->Transparent;
03770 }

void ColourContextGreyT::CreateExternalTransform  )  [virtual]
 

Create an external transform to be used during colour conversions from Grey to the current RCS space. This function uses the Winoil CMS Manager to create the transform. Both forward and backward transforms use logical RGB descriptions.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/05/96
Parameters:
- [INPUTS]
Returns:
-

Reimplemented from ColourContext.

Definition at line 3695 of file colcontx.cpp.

03696 {
03697 #ifndef NO_XARACMS
03698     CMSColourSpace cmsSpace;
03699     XaraCMS* lpCMSMan = GetApplication()->GetCMSManager();
03700     
03701     if (lpCMSMan != NULL)
03702     {
03703         // first read our internal colour calibration space
03704         lpCMSMan->GetLogicalProfile(&cmsSpace);
03705 
03706         // set this as the active colour profile
03707         UINT32 err = lpCMSMan->SetProfile(cmsSpace);
03708 
03709         // if we haven't got an error, create that transform
03710         if (err==0)
03711             CMSTransform = lpCMSMan->CreateTransform(DISPLAY_RCS);
03712     }
03713 #endif
03714 }

UINT32 ColourContextGreyT::GetComponentCount  )  [virtual]
 

Provides number of components in the colour context's colour model.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/05/96
Returns:
The number of components

Implements ColourContext.

Definition at line 3979 of file colcontx.cpp.

03980 {
03981     return MAX_COMPONENTS;
03982 }

BOOL ColourContextGreyT::GetComponentName INT32  ComponentID,
StringBase Result,
BOOL  LongName = FALSE
[virtual]
 

Returns the name of one of this context's colour components.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/7/94
Parameters:
ComponentID - Index [1..4] of the component you want the name of [INPUTS] (Result is an output) LongName - TRUE to get the long name, FALSE to get the short name (e.g. "Magenta" vs "M", "Saturation" vs "Sat")
Result returns containing a String of the name of the given component [OUTPUTS] of colours defined in this context. This string is guaranteed to fit within a String_32 - this is the minimum size you should allocate. (Most names, in English at least, are shorter than this (10 chars max, e.g. 'Red' 'Hue' 'Saturation') so allow at least 10 chars of space in your displays as well)
Note that Result can be passed in NULL in order to only determine if the context supports a given component.

Returns:
FALSE if this component is not used by this model.
Notes: The components are given in the same order as they appear in the high-precision ColourXYZ structures defined in colmodel.h

Implements ColourContext.

Definition at line 3903 of file colcontx.cpp.

03904 {
03905     UINT32 StringID = 0;
03906     BOOL Used = TRUE;
03907 
03908     switch(ComponentID)
03909     {
03910         case 1:
03911             StringID = (LongName) ? _R(IDS_COLCOMPL_INTENSITY) : _R(IDS_COLCOMP_INTENSITY);
03912             break;
03913             
03914 #ifdef TRANSPARENTCOLOUR
03915         case 2:
03916         case 3:
03917             Used = FALSE;       // These components are not used
03918             break;
03919 
03920         default:
03921             StringID = _R(IDS_COLCOMP_TRANS);
03922             break;
03923 #else
03924         default:
03925             Used = FALSE;
03926             break;
03927 #endif
03928     }
03929 
03930     if (Result != NULL && StringID != 0)
03931         *Result = String_32(StringID);
03932 
03933     return(Used);
03934 }

UnitGroup ** ColourContextGreyT::GetComponentUnitGroups  )  [protected, virtual]
 

Provides an array of UnitGroups primarily for use by the base class (ColourContext) members Set/GetComponentUnitGroup().

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/05/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A pointer to the UnitGroup array

Errors: - See Also: ColourContext::GetComponentUnitGroup() ColourContext::SetComponentUnitGroup()

Implements ColourContext.

Definition at line 3955 of file colcontx.cpp.

03956 {
03957     return m_pUnitGroupArray;
03958 }

void ColourContextGreyT::GetModelName StringBase Result  )  [virtual]
 

Returns the name of this context's colour model Notes:.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/6/94
Parameters:
- [INPUTS]
Result returns continaing a String of the name of the context. [OUTPUTS] This string is guaranteed to fit within a String_32 - this is the minimum size you should allocate. (Most names, in English at least, are shorter than this (10 chars max, e.g. 'RGB' 'HSV' 'Greyscale') so allow at least 10 chars of space in your displays as well)
Returns:
-

Implements ColourContext.

Definition at line 3864 of file colcontx.cpp.

03865 {
03866     ENSURE(Result != NULL, "ColourContext::GetModelName called with NULL result pointer!");
03867 
03868     *Result = String_32(_R(IDS_COLMODEL_GREY));
03869 }

void ColourContextGreyT::GetWhite ColourGeneric Result  )  [virtual]
 

An easy way to get a colour definition in this colour model which is white (paper colour).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/6/96
Parameters:
Result - Will be filled in with White, however that is defined in [OUTPUTS] this context's colour model. (i.e. RGB(1,1,1) or CMYK(0,0,0,0), etc)

Implements ColourContext.

Definition at line 4091 of file colcontx.cpp.

04092 {
04093     ColourGreyT *grey = (ColourGreyT *) Result;
04094     grey->Intensity = 1.0;
04095 
04096     grey->Reserved1 = grey->Reserved2 = grey->Transparent = 0;
04097 }


Friends And Related Function Documentation

friend class ColourContextList [friend]
 

Reimplemented from ColourContext.

Definition at line 1220 of file colcontx.h.

friend class DocColour [friend]
 

Reimplemented from ColourContext.

Definition at line 1219 of file colcontx.h.

friend class GRenderRegion [friend]
 

Reimplemented from ColourContext.

Definition at line 1222 of file colcontx.h.

friend class OSRenderRegion [friend]
 

Reimplemented from ColourContext.

Definition at line 1223 of file colcontx.h.


Member Data Documentation

UnitGroup * ColourContextGreyT::m_pUnitGroupArray [static, private]
 

Initial value:

Definition at line 1252 of file colcontx.h.


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