ACF $AcfVersion:0$
Public Types | Public Member Functions | List of all members
icmm::IColorModel Class Referenceabstract

Common interface for color model definitions in the ACF color management system. More...

#include <IColorModel.h>

Inheritance diagram for icmm::IColorModel:
istd::IChangeable istd::IPolymorphic icmm::CCieLabColorModel icmm::CRgbColorModel icmm::CSpectralColorModel icmm::ISubstractiveColorModel icmm::CRgbaColorModel icmm::CSubstractiveColorModelBase icmm::CCmyColorModel icmm::CSubstractiveColorModel icmm::CCmykColorModel

Public Types

enum  ModelType {
  MT_HSI , MT_HSV , MT_HSL , MI_YIQ ,
  MI_YUV , MI_YCBCR , MT_RGB , MT_COLORANTS ,
  MT_LUV , MT_LAB , MT_LCH , MT_XYZ ,
  MT_YXY , MI_SPECTRAL , MI_USER = 1024
}
 
enum  ModelClass { MC_DEVICE_DEPENDENT , MC_DEVICE_INDEPENDENT }
 
enum  ColorSpaceClass { CSC_ADDITIVE , CSC_SUBSTRACTIVE , CSC_PERCEPTUAL }
 
- Public Types inherited from istd::IChangeable
enum  ChangeFlags {
  CF_ACF_INTERNAL = 0 , CF_ALL_DATA , CF_ANY , CF_DESTROYING ,
  CF_DELEGATED , CF_NO_UNDO
}
 Data model change notification flags. More...
 
enum  SupportedOperations {
  SO_NONE = 0 , SO_OBSERVE = 1 << 0 , SO_COPY = 1 << 1 , SO_CLONE = 1 << 2 ,
  SO_COMPARE = 1 << 3 , SO_RESET = 1 << 4
}
 Flags for supported operations. More...
 
enum  CompatibilityMode { CM_STRICT , CM_WITHOUT_REFS , CM_WITH_REFS , CM_CONVERT }
 Control how relationship betweeen objects are interpreted. More...
 
typedef QMultiMap< QByteArray, QVariant > ChangeInfoMap
 

Public Member Functions

virtual ModelType GetModelType () const =0
 Gets the type of the color model.
 
virtual ModelClass GetModelClass () const =0
 Gets the classification of the color model.
 
virtual ColorSpaceClass GetColorSpaceClass () const =0
 Gets the classification of the color space defined by this model.
 
virtual int GetColorSpaceDimensionality () const =0
 Gets the dimensionality (number of components) of the color space.
 
virtual const imath::IUnitInfoGetColorSpaceComponentInfo (int componentIndex) const =0
 Gets mathematical unit information for a color model component.
 
virtual QString GetColorSpaceComponentName (int componentIndex) const =0
 Gets the human-readable name of a color model component.
 
virtual const icmm::IColorTransformationCreateColorTranformation (const IColorModel &otherColorModel, const QByteArray &transformationId=QByteArray()) const =0
 Creates a color transformation for conversion to another color model.
 
virtual IColorSpecification::ConstColorSpecPtr GetSpecification () const
 Gets the color specification for this model, if available.
 
- Public Member Functions inherited from istd::IChangeable
virtual int GetSupportedOperations () const
 Get set of flags for supported operations.
 
virtual bool CopyFrom (const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS)
 Copy this object from another one.
 
virtual bool IsEqual (const IChangeable &object) const
 Compare this object with another object.
 
virtual istd::TUniqueInterfacePtr< istd::IChangeableCloneMe (CompatibilityMode mode=CM_WITHOUT_REFS) const
 Make a copy of this object.
 
virtual bool ResetData (CompatibilityMode mode=CM_WITHOUT_REFS)
 Reset data to its default state.
 
virtual void BeginChanges (const ChangeSet &changeSet)
 Starts the change transaction.
 
virtual void EndChanges (const ChangeSet &changeSet)
 Ends the change transaction.
 
virtual void BeginChangeGroup (const ChangeSet &changeSet)
 Starts group of changes.
 
virtual void EndChangeGroup (const ChangeSet &changeSet)
 Ends group of changes.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Additional Inherited Members

- Static Public Member Functions inherited from istd::IChangeable
static const ChangeSetGetNoChanges ()
 Get empty set of changes.
 
static const ChangeSetGetAnyChange ()
 Get anonymous change set.
 
static const ChangeSetGetAllChanges ()
 Get anonymous change set.
 
static const ChangeSetGetDelegatedChanges ()
 Get delegated change set.
 
- Protected Member Functions inherited from istd::IChangeable
virtual void OnBeginChanges ()
 Callback function for begin change event.
 
virtual void OnEndChanges (const ChangeSet &changeSet)
 Callback function for end change event.
 

Detailed Description

Common interface for color model definitions in the ACF color management system.

Purpose

IColorModel defines the abstract interface for color models (color spaces) in ACF. A color model represents a mathematical system for representing colors as tuples of numbers (typically 3-4 components). Examples include RGB, CMYK, HSV, CIE Lab, etc. This interface provides metadata about the color space and enables color transformations between different models.

Color Model Types

ACF supports various color model types through the ModelType enumeration:

Device-Dependent Models:**

Model Classifications

Color models are classified along two dimensions:

Model Class:**

Usage Examples

// Example 1: Query model properties
void InspectColorModel(const icmm::IColorModel* model)
{
// Get model type
if (type == IColorModel::MT_RGB) {
qDebug() << "This is an RGB color model";
}
// Check if device-dependent
IColorModel::ModelClass modelClass = model->GetModelClass();
if (modelClass == IColorModel::MC_DEVICE_DEPENDENT) {
qDebug() << "Colors will vary by device";
}
// Get color space class
if (spaceClass == IColorModel::CSC_ADDITIVE) {
qDebug() << "Additive color mixing (light-based)";
}
// Get dimensionality (typically 3 or 4)
int dimensions = model->GetColorSpaceDimensionality();
qDebug() << "Color space has" << dimensions << "dimensions";
// List component names
for (int i = 0; i < dimensions; ++i) {
QString name = model->GetColorSpaceComponentName(i);
qDebug() << "Component" << i << ":" << name;
}
}
// Example 2: Create color transformation
void ConvertRgbToLab(const icmm::IColorModel* rgbModel,
const icmm::IColorModel* labModel,
const icmm::CVarColor& rgbColor)
{
// Create transformation from RGB to Lab
const IColorTransformation* transform =
rgbModel->CreateColorTranformation(*labModel);
if (transform) {
// Apply transformation
icmm::CVarColor labColor;
if (transform->Calculate(rgbColor, labColor)) {
qDebug() << "Converted to Lab:"
<< labColor.GetElement(0) << ","
<< labColor.GetElement(1) << ","
<< labColor.GetElement(2);
}
delete transform;
}
}
// Example 3: Working with RGB model
void UseRgbModel()
{
// RGB has 3 dimensions
int dims = rgbModel.GetColorSpaceDimensionality(); // 3
// Component names: "Red", "Green", "Blue"
QString redName = rgbModel.GetColorSpaceComponentName(0); // "Red"
// All components range from 0.0 to 1.0
const imath::IUnitInfo* redUnit = rgbModel.GetColorSpaceComponentInfo(0);
// redUnit->GetMinValue() returns 0.0
// redUnit->GetMaxValue() returns 1.0
}
// Example 4: Custom color space conversions
void ConvertBetweenSpaces(const icmm::CVarColor& color,
{
// Create transformation
const IColorTransformation* transform =
fromModel->CreateColorTranformation(*toModel);
if (transform) {
if (transform->Calculate(color, result)) {
// Use converted color
ProcessColor(result);
}
delete transform;
} else {
qDebug() << "No direct transformation available";
// May need intermediate conversion (e.g., through XYZ)
}
}
// Example 5: Check model compatibility
bool CanConvert(const IColorModel* from, const IColorModel* to)
{
const IColorTransformation* transform =
from->CreateColorTranformation(*to);
bool canConvert = (transform != nullptr);
delete transform;
return canConvert;
}
Concrete RGB color model implementation.
virtual QString GetColorSpaceComponentName(int componentIndex) const override
Gets the human-readable name of a color model component.
virtual int GetColorSpaceDimensionality() const override
Gets the dimensionality (number of components) of the color space.
virtual const imath::IUnitInfo * GetColorSpaceComponentInfo(int componentIndex) const override
Gets mathematical unit information for a color model component.
Generic color implementation with variable number of color components.
Definition CVarColor.h:176
Common interface for color model definitions in the ACF color management system.
virtual ModelType GetModelType() const =0
Gets the type of the color model.
virtual ColorSpaceClass GetColorSpaceClass() const =0
Gets the classification of the color space defined by this model.
virtual ModelClass GetModelClass() const =0
Gets the classification of the color model.
virtual const imath::IUnitInfo * GetColorSpaceComponentInfo(int componentIndex) const =0
Gets mathematical unit information for a color model component.
virtual const icmm::IColorTransformation * CreateColorTranformation(const IColorModel &otherColorModel, const QByteArray &transformationId=QByteArray()) const =0
Creates a color transformation for conversion to another color model.
virtual QString GetColorSpaceComponentName(int componentIndex) const =0
Gets the human-readable name of a color model component.
virtual int GetColorSpaceDimensionality() const =0
Gets the dimensionality (number of components) of the color space.
double GetElement(int index) const
Get element at specified index.
Definition CVarVector.h:409
Common interface to get information about a measurement unit.
Definition IUnitInfo.h:22
std::shared_ptr< const IColorModel > ConstColorModelPtr

Color Transformations

Color transformations convert colors from one model to another. Not all transformations are available directly:

Best Practices

See also
icmm::IColorObject, icmm::IColorTransformation, icmm::CVarColor, icmm::CRgbColorModel, icmm::CCmykColorModel, icmm::CSpectralColorModel

Definition at line 183 of file IColorModel.h.

Member Enumeration Documentation

◆ ColorSpaceClass

Enumerator
CSC_ADDITIVE 
CSC_SUBSTRACTIVE 
CSC_PERCEPTUAL 

Definition at line 224 of file IColorModel.h.

◆ ModelClass

Enumerator
MC_DEVICE_DEPENDENT 
MC_DEVICE_INDEPENDENT 

Definition at line 218 of file IColorModel.h.

◆ ModelType

Enumerator
MT_HSI 
MT_HSV 
MT_HSL 
MI_YIQ 
MI_YUV 
MI_YCBCR 
MT_RGB 
MT_COLORANTS 

Substractive color model based on generic list of colorants.

This includes CMYK, CMY, combinations with spot colors and ECG.

MT_LUV 
MT_LAB 
MT_LCH 
MT_XYZ 
MT_YXY 
MI_SPECTRAL 

Color model is defined by a set of spectral values.

MI_USER 

Base value for the user-defined model types.

Definition at line 186 of file IColorModel.h.

Member Function Documentation

◆ CreateColorTranformation()

virtual const icmm::IColorTransformation * icmm::IColorModel::CreateColorTranformation ( const IColorModel otherColorModel,
const QByteArray &  transformationId = QByteArray() 
) const
pure virtual

Creates a color transformation for conversion to another color model.

Constructs and returns a transformation object that can convert colors from this model to the specified target model. The transformation may be direct or may internally use intermediate color spaces (typically XYZ).

Parameters
otherColorModelThe target color model to convert to
transformationIdOptional identifier for a specific transformation algorithm. Empty (default) uses the standard transformation.
Returns
Pointer to the created IColorTransformation, or nullptr if no transformation is available. Caller owns the returned pointer and must delete it when done.
Note
The returned transformation is newly allocated. Delete it after use.
Returns nullptr if no transformation path exists between the models.
For repeated conversions, cache the transformation for performance.
// Create RGB to Lab transformation
const IColorTransformation* transform =
rgbModel.CreateColorTranformation(labModel);
if (transform) {
// Use transformation
icmm::CVarColor rgbColor(3);
rgbColor.SetElement(0, 1.0); // Red
rgbColor.SetElement(1, 0.0); // Green
rgbColor.SetElement(2, 0.0); // Blue
icmm::CVarColor labColor;
transform->Calculate(rgbColor, labColor);
delete transform; // Clean up
}
CCieLabColorModel implements the CIE Lab color model.
virtual const icmm::IColorTransformation * CreateColorTranformation(const IColorModel &otherColorModel, const QByteArray &transformationId) const override
Creates a color transformation for conversion to another color model.
Basic interface for color transformations between color models.
See also
IColorTransformation, CVarColor

Implemented in icmm::CRgbColorModel, icmm::CCieLabColorModel, icmm::CSpectralColorModel, and icmm::CSubstractiveColorModelBase.

◆ GetColorSpaceClass()

virtual ColorSpaceClass icmm::IColorModel::GetColorSpaceClass ( ) const
pure virtual

Gets the classification of the color space defined by this model.

Indicates the physical basis of color mixing: additive (light-based), subtractive (pigment-based), or perceptual (human perception-based).

Returns
ColorSpaceClass classification
See also
ColorSpaceClass, GetModelType()

Implemented in icmm::CCieLabColorModel, icmm::CRgbColorModel, icmm::CSpectralColorModel, and icmm::CSubstractiveColorModelBase.

◆ GetColorSpaceComponentInfo()

virtual const imath::IUnitInfo * icmm::IColorModel::GetColorSpaceComponentInfo ( int  componentIndex) const
pure virtual

Gets mathematical unit information for a color model component.

Returns information about the mathematical unit, range, and properties of the specified component (axis) in the color space.

Parameters
componentIndexZero-based index of the component (0 to dimensionality-1)
Returns
Pointer to IUnitInfo describing the component's unit, or nullptr if index is invalid. The pointer is owned by the color model.
Note
Most color components range from 0.0 to 1.0, but some (like Lab) have different ranges (L: 0-100, a: -128 to 127, b: -128 to 127).
const imath::IUnitInfo* info = model->GetColorSpaceComponentInfo(0);
if (info) {
double minVal = info->GetMinValue();
double maxVal = info->GetMaxValue();
QString unit = info->GetUnitName();
}
virtual QString GetUnitName() const =0
Get name of unit.
See also
GetColorSpaceComponentName(), GetColorSpaceDimensionality()

Implemented in icmm::CCieLabColorModel, icmm::CRgbaColorModel, icmm::CRgbColorModel, icmm::CSpectralColorModel, and icmm::CSubstractiveColorModelBase.

◆ GetColorSpaceComponentName()

virtual QString icmm::IColorModel::GetColorSpaceComponentName ( int  componentIndex) const
pure virtual

Gets the human-readable name of a color model component.

Returns the name of the component at the specified index, such as "Red", "Green", "Blue" for RGB, or "Lightness", "a*", "b*" for Lab.

Parameters
componentIndexZero-based index of the component
Returns
Component name as a QString, or empty string if index is invalid
// Get RGB component names
QString name0 = rgb.GetColorSpaceComponentName(0); // "Red"
QString name1 = rgb.GetColorSpaceComponentName(1); // "Green"
QString name2 = rgb.GetColorSpaceComponentName(2); // "Blue"
See also
GetColorSpaceComponentInfo(), GetColorSpaceDimensionality()

Implemented in icmm::CCieLabColorModel, icmm::CRgbaColorModel, icmm::CRgbColorModel, icmm::CSpectralColorModel, and icmm::CSubstractiveColorModelBase.

◆ GetColorSpaceDimensionality()

virtual int icmm::IColorModel::GetColorSpaceDimensionality ( ) const
pure virtual

Gets the dimensionality (number of components) of the color space.

Returns the number of values needed to represent a color in this model. Common values are 3 (RGB, HSV, Lab) or 4 (CMYK). Spectral models may have higher dimensionality.

Returns
Number of components/dimensions in the color space
// RGB has 3 components
int dims = rgbModel.GetColorSpaceDimensionality(); // returns 3
// CMYK has 4 components
dims = cmykModel.GetColorSpaceDimensionality(); // returns 4
CMYK color model implementation for four-color printing.
virtual int GetColorSpaceDimensionality() const override
Gets the dimensionality (number of components) of the color space.
See also
GetColorSpaceComponentName(), GetColorSpaceComponentInfo()

Implemented in icmm::CCieLabColorModel, icmm::CRgbaColorModel, icmm::CRgbColorModel, icmm::CSpectralColorModel, and icmm::CSubstractiveColorModelBase.

◆ GetModelClass()

virtual ModelClass icmm::IColorModel::GetModelClass ( ) const
pure virtual

Gets the classification of the color model.

Indicates whether the color model is device-dependent or device-independent. Device-dependent models (RGB, CMYK) produce different colors on different devices, while device-independent models (XYZ, Lab) represent absolute colors.

Returns
ModelClass classification
See also
ModelClass, GetModelType()

Implemented in icmm::CCieLabColorModel, icmm::CRgbColorModel, icmm::CSpectralColorModel, and icmm::CSubstractiveColorModelBase.

◆ GetModelType()

virtual ModelType icmm::IColorModel::GetModelType ( ) const
pure virtual

Gets the type of the color model.

Returns the specific type identifier for this color model (e.g., MT_RGB, MT_CMYK). This identifies the mathematical representation and component structure.

Returns
The ModelType enumeration value identifying this color model
See also
ModelType, GetModelClass(), GetColorSpaceClass()

Implemented in icmm::CCieLabColorModel, icmm::CRgbColorModel, icmm::CSpectralColorModel, and icmm::CSubstractiveColorModelBase.

◆ GetSpecification()

virtual IColorSpecification::ConstColorSpecPtr icmm::IColorModel::GetSpecification ( ) const
inlinevirtual

Gets the color specification for this model, if available.

Returns additional specification information about the color model, such as white point, primaries (for RGB), or viewing conditions (for Lab). Not all models have specifications.

Returns
Shared pointer to the color specification, or empty pointer if no specification is available
Note
This is optional metadata. Most basic operations don't require it.
See also
IColorSpecification

Reimplemented in icmm::CCieLabColorModel, icmm::CRgbColorModel, and icmm::CSpectralColorModel.

Definition at line 402 of file IColorModel.h.


The documentation for this class was generated from the following file: