PaletteFilter Class Reference

Base class for all palette filters. More...

#include <coplfilr.h>

Inheritance diagram for PaletteFilter:

Filter ListItem CCObject SimpleCCObject AdobeColourSwatchFilter AdobeColourTableFilter CorelPaletteFilter JCWColourFilter MSPaletteFilter PaintShopProPaletteFilter List of all members.

Public Member Functions

 PaletteFilter ()
 Constructor for a base palette filter.
 ~PaletteFilter ()
 Destructor for a base palette filter.
virtual BOOL IsDefaultDocRequired (const TCHAR *pcszPathName)
 For determining wether this filter needs a document to be created to import into.
virtual BOOL DoImport (SelOperation *, CCLexFile *, Document *, BOOL AutoChosen=FALSE, ImportPosition *Pos=NULL, KernelBitmap **ppImportedBitmap=NULL, DocCoord *pPosTranslate=NULL, String_256 *=NULL)
 Base class for handling palette import.
BOOL DoExport (Operation *, CCLexFile *, PathName *, Document *, BOOL)

Static Public Member Functions

static double ClampZeroToOne (const double input)
static void ConvertLABToRGB (const Vector3D &icol, Vector3D *ocol)
 To convert the given Lab colour to a (near) equivelent RGB colour This uses the above conversion functions from Mike. They are *not* accurate but do give a reasonable approximation of the colour.

Protected Member Functions

virtual BOOL PreImport ()=0
virtual BOOL ImportPalette ()=0
virtual BOOL PostImport ()=0
BOOL StartPercentage (INT32 UpTo=-1)
 Starts a percentage delay indicator that runs from 0 to 100. If you don't know how many colours you are importing pass -1 and the length of the file is used.
BOOL SetPercentage (INT32 GotTo=-1)
 Continues a percentage delay indicator. Pass -1 to use the current import file position as a progress indicator.
BOOL ProcessRGBColour (double Red, double Green, double Blue, const StringBase *pColName=NULL)
 Generates a Camelot RGB colour and adds it to the imported colours list.
BOOL ProcessCMYKColour (double Cyan, double Magenta, double Yellow, double Key, const StringBase *pColName=NULL)
 Generates a Camelot CMYK colour and adds it to the imported colours list.
BOOL ProcessHSVColour (double Hue, double Sat, double Value, const StringBase *pColName=NULL)
 Generates a Camelot HSV colour and adds it to the imported colours list.
BOOL ProcessLabColour (double Luminance, double A, double B, const StringBase *pColName=NULL)
 Generates a name for this colour and adds it to the imported colours list N.B. Camelot does not support Lab colours so the colour is converted to RGB or greyscale.
BOOL ProcessGreyColour (double Intensity, const StringBase *pColName=NULL)
 Generates a Camelot greyscale colour and adds it to the imported colours list.
BOOL NameRGBColour (ColourRGBT *pColour, StringBase *pName)
 Generates a name for this RGB colour.
BOOL NameCMYKColour (ColourCMYK *pColour, StringBase *pName)
 Generates a name for this CMYK colour.
BOOL NameHSVColour (ColourHSVT *pColour, StringBase *pName)
 Generates a name for this CMYK colour.
BOOL NameGreyColour (ColourGreyT *pColour, StringBase *pName)
 Generates a name for this greyscale colour.
BOOL UsePercentageColour ()
 To see wether or not to use the precentage colour naming scheme.
BOOL AddColourToGallery (PalettePrefix Prefix, String_64 *Name, ColourGeneric *Definition, ColourModel Model, BOOL NewlineAfter=FALSE, BOOL IsSpotColour=FALSE)
 Sticks the given colour into the colour gallery.

Static Protected Member Functions

static void ConvertCIEtoXYZ (const Vector3D &icol, Vector3D &ocol)
 To convert the given x, y and Y to X, Y and Z in CIE XYZ space.
static void ConvertLABtoXYZ (const Vector3D &white, const Vector3D &icol, Vector3D &ocol)
 To convert colours from CIE LUV to CIE XYZ.
static void ConvertXYZToRGB (const Vector3D &icol, Vector3D &ocol)
 To convert colours from CIE XYZ to RGB.

Protected Attributes

ImportedColoursm_pNewColours
SelOperationm_pImportOp
CCLexFilem_pImportFile
Documentm_pImportDoc
BOOL ImportIntoGallery
SGDisplayLibColGroupCurrentGalleryGroup

Private Member Functions

 CC_DECLARE_DYNAMIC (PaletteFilter)
BOOL PrepareForImport ()
 Initialises the base class before import.
BOOL FinishImport (BOOL Success)
 Finialises colour import.

Detailed Description

Base class for all palette filters.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/4/96

Definition at line 135 of file coplfilr.h.


Constructor & Destructor Documentation

PaletteFilter::PaletteFilter  ) 
 

Constructor for a base palette filter.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/4/96
Parameters:
- [INPUTS]
Returns:
-
See also:
Filter

Definition at line 158 of file coplfilr.cpp.

00159 {
00160     m_pNewColours = NULL;
00161 
00162     ImportIntoGallery = TRUE;
00163     CurrentGalleryGroup = NULL;
00164 }

PaletteFilter::~PaletteFilter  ) 
 

Destructor for a base palette filter.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/4/96
Parameters:
- [INPUTS]
Returns:
-
See also:
Filter

Definition at line 177 of file coplfilr.cpp.

00178 {
00179     if (m_pNewColours != NULL)
00180     {
00181         m_pNewColours->DestroyColours();
00182         delete m_pNewColours;
00183         m_pNewColours = NULL;
00184     }
00185 }


Member Function Documentation

BOOL PaletteFilter::AddColourToGallery PalettePrefix  Prefix,
String_64 Name,
ColourGeneric Definition,
ColourModel  Model,
BOOL  NewlineAfter = FALSE,
BOOL  IsSpotColour = FALSE
[protected]
 

Sticks the given colour into the colour gallery.

Returns:
TRUE if it succeeeds

Definition at line 991 of file coplfilr.cpp.

00994 {
00995 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00996     if (CurrentGalleryGroup == NULL)
00997         return(FALSE);
00998 
00999     // Create a new DocColour for this colour
01000     DocColour NewCol(Model, Definition);
01001     
01002     if (Prefix == PalettePrefix_Pantone || Prefix == PalettePrefix_PantoneSpot)
01003     {
01004         // Set the "PANTONE bodge" flag which rounds the colour components to the nearest half percent.
01005         // This gets around errors introduced by storing the 200 possible half-percent values in a 0-255 BYTE
01006         NewCol.ForceRounding(TRUE);
01007     }
01008 
01009     SGDisplayLibColour *NewItem = new SGDisplayLibColour(&NewCol, Name, Prefix, NewlineAfter, IsSpotColour);
01010     if (NewItem == NULL)
01011         return(FALSE);
01012 
01013     CurrentGalleryGroup->AddItem(NewItem);
01014 #endif
01015     return(TRUE);
01016 }

PaletteFilter::CC_DECLARE_DYNAMIC PaletteFilter   )  [private]
 

static double PaletteFilter::ClampZeroToOne const double  input  )  [inline, static]
 

Definition at line 153 of file coplfilr.h.

00153 { return (input < 0 ? 0 : (input > 1 ? 1 : input)); }

void PaletteFilter::ConvertCIEtoXYZ const Vector3D icol,
Vector3D ocol
[static, protected]
 

To convert the given x, y and Y to X, Y and Z in CIE XYZ space.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/04/96
Parameters:
icol = (x,y) is the chromaticity value [INPUTS] YY is the corresponding luminance value
ocol = (X,Y,Z) coordinates in the CIE XYZ space [OUTPUTS]
Returns:
-

Definition at line 925 of file coplfilr.cpp.

00926 {
00927     double d = icol.z / icol.y;
00928 
00929     ocol.x = icol.x * d;
00930     ocol.y = icol.z;
00931     ocol.z = (1.0 - icol.x - icol.y) * d;
00932 }

void PaletteFilter::ConvertLABToRGB const Vector3D icol,
Vector3D ocol
[static]
 

To convert the given Lab colour to a (near) equivelent RGB colour This uses the above conversion functions from Mike. They are *not* accurate but do give a reasonable approximation of the colour.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/5/96
Parameters:
icol = (x, y, z) - Lab colour (0..100, -128..127, -128..127) [INPUTS]
ocol = (x, y, z) - RGB colour (0..1, 0..1, 0..1) [OUTPUTS]
Returns:
-

Definition at line 947 of file coplfilr.cpp.

00948 {
00949     // First calculate a XYZ white point
00950     Vector3D CIEWhite = Vector3D(0.3127, 0.3290, 1.0 );
00951     Vector3D XYZWhite;
00952     PaletteFilter::ConvertCIEtoXYZ(CIEWhite, XYZWhite);
00953 
00954     Vector3D LabAsXYZ;
00955     PaletteFilter::ConvertLABtoXYZ(XYZWhite, icol, LabAsXYZ);
00956 
00957     // Finally convert XYZ to RGB
00958     Vector3D RGB;
00959     PaletteFilter::ConvertXYZToRGB(LabAsXYZ, RGB);
00960 
00961     ocol->x = ClampZeroToOne( pow(RGB.x, 1.0/2.5) );
00962     ocol->y = ClampZeroToOne( pow(RGB.y, 1.0/2.5) );
00963     ocol->z = ClampZeroToOne( pow(RGB.z, 1.0/2.5) );
00964 }

void PaletteFilter::ConvertLABtoXYZ const Vector3D white,
const Vector3D icol,
Vector3D ocol
[static, protected]
 

To convert colours from CIE LUV to CIE XYZ.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/04/96
Parameters:
white = The (Xn, Yn, Zn) coordinates of the white colour in CIE XYZ space. [INPUTS] icol = CIE LAB colour
ocol = CIE XYZ colour [OUTPUTS]
Returns:
-

Definition at line 892 of file coplfilr.cpp.

00893 {
00894     double d,e;
00895     static double third = 1.0/3.0;
00896 
00897     if (icol.x < 7.9996248) 
00898         ocol.y = icol.x * white.y / 903.3;
00899     else 
00900         ocol.y = pow((double)((icol.x + 16.0) / 116.0), (double)3.0) * white.y;
00901 
00902     e = pow((double)(ocol.y / white.y), third);
00903     d = e + (double)(icol.y / 500);
00904     
00905     ocol.x = pow(d, (double)3.0) * white.x;
00906 
00907     d = e - (double)(icol.z / 200);
00908     
00909     ocol.z = pow(d, (double)3.0) * white.z;
00910 }

void PaletteFilter::ConvertXYZToRGB const Vector3D icol,
Vector3D ocol
[static, protected]
 

To convert colours from CIE XYZ to RGB.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/04/96
Parameters:
icon = The (Xn, Yn, Zn) coordinates of the white colour in CIE XYZ space. [INPUTS]
ocol = RGB colour (0..1) [OUTPUTS]
Returns:
-

Definition at line 867 of file coplfilr.cpp.

00868 {
00869     // Convert from HDTV Rec709 to RGB
00870     ocol.x = ( 3.240479*icol.x) + (-1.537150*icol.y) + (-0.498535*icol.z);
00871     ocol.y = (-0.969256*icol.x) + ( 1.875992*icol.y) + ( 0.041556*icol.z);
00872     ocol.z = ( 0.055648*icol.x) + (-0.204043*icol.y) + ( 1.057311*icol.z);
00873     
00874     ClampZeroToOne(ocol.x);
00875     ClampZeroToOne(ocol.y);
00876     ClampZeroToOne(ocol.z);
00877 }

BOOL PaletteFilter::DoExport Operation ,
CCLexFile ,
PathName ,
Document ,
BOOL 
[virtual]
 

Reimplemented from Filter.

Definition at line 304 of file coplfilr.cpp.

00307 {
00308     // For the moment palettes are not exported.
00309     return FALSE;
00310 }

BOOL PaletteFilter::DoImport SelOperation pOp,
CCLexFile pFile,
Document pDoc,
BOOL  AutoChosen = FALSE,
ImportPosition Pos = NULL,
KernelBitmap **  ppImportedBitmap = NULL,
DocCoord pPosTranslate = NULL,
String_256 URL = NULL
[virtual]
 

Base class for handling palette import.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/4/96
Parameters:
pOp - The operation this import is running under [INPUTS] pFile - The file to import from pDoc - The document to import into AutoChosen - TRUE if this filter was chosen by the system, FALSE if chosen by the user ImportPos - The position to import the file data at Pos - ppImportedBitmap - this is used mainly in the bitfltr.cpp for the HTML import filter. HTMLFilter::DoImport() needs a pointer to a kernel bitmap to set the background bitmap up into Camelot. pPosTranslate - This is used too by the HTMLFilter in order to do a formatting. URL - original URL of the imported file
Returns:
TRUE for successful import, FALSE if an error occured.
Notes: **** IMPORTANT ************************************************************** Palette filters can be called directly from the colour gallery (sgcolour.cpp) library groups to import palette files directly into the gallery. In this case, pOp and pDoc are NULL, and the member vars CurrentGalleryGroup and ImportIntoGallery are set up suitably. It is this important that these filters continue to be happy about not importing into a document!

See also:
Filter::DoImport

Reimplemented from Filter.

Definition at line 238 of file coplfilr.cpp.

00240 {
00241     BOOL ok = TRUE;
00242 
00243     // Copy parameters into member vars.
00244     // NOTE that we allow pOp and pDoc to be NULL, when we are importing into a gallery!
00245     ERROR2IF(pFile==NULL, FALSE, "NULL parameter passed");
00246     m_pImportOp = pOp;
00247     m_pImportFile = pFile;
00248     m_pImportDoc = pDoc;
00249 
00250     // Determine if this is really a huge bodge and we're importing directly into the colour gallery
00251 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00252     //ColourSGallery *ParentGal = (ColourSGallery *) OpDisplayColourGallery::FindGallery();
00253     ColourSGallery *ParentGal = ColourSGallery::GetInstance();
00254     if (ParentGal != NULL)
00255         CurrentGalleryGroup = ParentGal->GetCurrentImportGroup();
00256     else
00257 #endif
00258         CurrentGalleryGroup = NULL;
00259 
00260     ImportIntoGallery = (CurrentGalleryGroup != NULL);
00261     ERROR2IF(!ImportIntoGallery && (pDoc == NULL || pOp == NULL), FALSE, "NULL doc/op when not importing into gallery");
00262 
00263     // Initialise base class services
00264     if (ok)
00265         ok = PrepareForImport();
00266 
00267     // Call derived loading functions                                                                                   
00268     if (ok)
00269         ok = PreImport();
00270     if (ok)
00271         ok = ImportPalette();
00272     if (ok)
00273         ok = PostImport();
00274 
00275     // Finialise base class importation
00276     if (ok)
00277         ok = FinishImport(TRUE);
00278     else
00279         FinishImport(FALSE);
00280 
00281     CurrentGalleryGroup = NULL;
00282     ImportIntoGallery = FALSE;
00283 
00284     return ok;
00285 }

BOOL PaletteFilter::FinishImport BOOL  Success  )  [private]
 

Finialises colour import.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/5/96
Parameters:
Success - TRUE if import has been successful [INPUTS]
- [OUTPUTS]
Returns:
TRUE for success, FALSE if an error occured.

Definition at line 370 of file coplfilr.cpp.

00371 {
00372     BOOL ok = TRUE;
00373 
00374     if (!ImportIntoGallery)
00375     {
00376         // If we didn't even get to initialise, then return quietly.
00377         if (m_pNewColours == NULL)
00378             return FALSE;
00379 
00380         EndSlowJob();
00381         BeginSlowJob(-1, FALSE);
00382 
00383         // Import is finished, so add any outstanding colours to the document (if the
00384         // import was successful), and delete the colour table
00385         if (Success)
00386             ok = m_pNewColours->AddColoursToDocument();
00387         else
00388             m_pNewColours->DestroyColours();
00389 
00390         // Clean up claimed memory
00391         delete m_pNewColours;
00392         m_pNewColours = NULL;
00393     }
00394 
00395     return ok;
00396 }

virtual BOOL PaletteFilter::ImportPalette  )  [protected, pure virtual]
 

Implemented in MSPaletteFilter, PaintShopProPaletteFilter, AdobeColourTableFilter, AdobeColourSwatchFilter, CorelPaletteFilter, and JCWColourFilter.

BOOL PaletteFilter::IsDefaultDocRequired const TCHAR pcszPathName  )  [virtual]
 

For determining wether this filter needs a document to be created to import into.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/4/96
Parameters:
pcszPathName - pointer to the name of the file that is about to be imported [INPUTS]
Returns:
TRUE if a document is required to import this file into, FALSE if file supplies the document

Reimplemented from Filter.

Definition at line 199 of file coplfilr.cpp.

00200 {
00201     // Since palette files are unlikely to supply a document we will return TRUE.
00202     // Derived classes can still virtually override this function and return FALSE if required.
00203 
00204     return TRUE;
00205 }

BOOL PaletteFilter::NameCMYKColour ColourCMYK pColour,
StringBase pName
[protected]
 

Generates a name for this CMYK colour.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/5/96
Parameters:
pColour - the Camelot colour to name [INPUTS]
pName holds the generated name [OUTPUTS]
Returns:
TRUE for success, FALSE if an error occured.

Definition at line 687 of file coplfilr.cpp.

00688 {
00689     ERROR2IF(pColour==NULL || pName==NULL, FALSE, "NULL Pointer");
00690     
00691     if (UsePercentageColour())
00692     {
00693         pName->MakeMsg(_R(IDS_PALETTEIMPORT_CMYKPERCENT),
00694                                 (INT32)(pColour->Cyan.MakeDouble()*100+0.4999),
00695                                 (INT32)(pColour->Magenta.MakeDouble()*100+0.4999),
00696                                 (INT32)(pColour->Yellow.MakeDouble()*100+0.4999),
00697                                 (INT32)(pColour->Key.MakeDouble()*100+0.4999) );
00698     }
00699     else
00700     {
00701         pName->MakeMsg(_R(IDS_PALETTEIMPORT_CMYKVALUE),
00702                                 (INT32)(pColour->Cyan.MakeDouble()*255+0.4999),
00703                                 (INT32)(pColour->Magenta.MakeDouble()*255+0.4999),
00704                                 (INT32)(pColour->Yellow.MakeDouble()*255+0.4999),
00705                                 (INT32)(pColour->Key.MakeDouble()*255+0.4999) );
00706     }
00707 
00708     return TRUE;
00709 }

BOOL PaletteFilter::NameGreyColour ColourGreyT pColour,
StringBase pName
[protected]
 

Generates a name for this greyscale colour.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/5/96
Parameters:
pColour - the Camelot colour to name [INPUTS]
pName holds the generated name [OUTPUTS]
Returns:
TRUE for success, FALSE if an error occured.

Definition at line 755 of file coplfilr.cpp.

00756 {
00757     ERROR2IF(pColour==NULL || pName==NULL, FALSE, "NULL Pointer");
00758 
00759     if (pColour->Intensity.MakeDouble() <= 0.0)
00760         *pName = String_32(_R(IDS_PALETTEIMPORT_GREYBLACK));
00761     else if (pColour->Intensity.MakeDouble() >= 1.0)
00762             *pName = String_32(_R(IDS_PALETTEIMPORT_GREYWHITE));
00763         else
00764             pName->MakeMsg(_R(IDS_PALETTEIMPORT_GREYPERCENT), (INT32)(pColour->Intensity.MakeDouble()*100+0.4999));
00765 
00766     return TRUE;
00767 }

BOOL PaletteFilter::NameHSVColour ColourHSVT pColour,
StringBase pName
[protected]
 

Generates a name for this CMYK colour.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/5/96
Parameters:
pColour - the Camelot colour to name [INPUTS]
pName holds the generated name [OUTPUTS]
Returns:
TRUE for success, FALSE if an error occured.

Definition at line 722 of file coplfilr.cpp.

00723 {
00724     ERROR2IF(pColour==NULL || pName==NULL, FALSE, "NULL Pointer");
00725     
00726     if (UsePercentageColour())
00727     {
00728         pName->MakeMsg(_R(IDS_PALETTEIMPORT_HSVPERCENT),
00729                                 (INT32)(pColour->Hue.MakeDouble()*360+0.4999),
00730                                 (INT32)(pColour->Saturation.MakeDouble()*100+0.4999),
00731                                 (INT32)(pColour->Value.MakeDouble()*100+0.4999) );
00732     }
00733     else
00734     {
00735         pName->MakeMsg(_R(IDS_PALETTEIMPORT_HSVVALUE),
00736                                 (INT32)(pColour->Hue.MakeDouble()*360+0.4999),
00737                                 (INT32)(pColour->Saturation.MakeDouble()*255+0.4999),
00738                                 (INT32)(pColour->Value.MakeDouble()*255+0.4999) );
00739     }
00740 
00741     return TRUE;
00742 }

BOOL PaletteFilter::NameRGBColour ColourRGBT pColour,
StringBase pName
[protected]
 

Generates a name for this RGB colour.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/5/96
Parameters:
pColour - the Camelot colour to name [INPUTS]
pName holds the generated name [OUTPUTS]
Returns:
TRUE for success, FALSE if an error occured.

Definition at line 654 of file coplfilr.cpp.

00655 {
00656     ERROR2IF(pColour==NULL || pName==NULL, FALSE, "NULL Pointer");
00657 
00658     if (UsePercentageColour())
00659     {
00660         pName->MakeMsg(_R(IDS_PALETTEIMPORT_RGBPERCENT),
00661                                 (INT32)(pColour->Red.MakeDouble()*100+0.4999),
00662                                 (INT32)(pColour->Green.MakeDouble()*100+0.4999),
00663                                 (INT32)(pColour->Blue.MakeDouble()*100+0.4999) );
00664     }
00665     else
00666     {
00667         pName->MakeMsg(_R(IDS_PALETTEIMPORT_RGBVALUE),
00668                                 (INT32)(pColour->Red.MakeDouble()*255+0.4999),
00669                                 (INT32)(pColour->Green.MakeDouble()*255+0.4999),
00670                                 (INT32)(pColour->Blue.MakeDouble()*255+0.4999) );
00671     }
00672 
00673     return TRUE;
00674 }

virtual BOOL PaletteFilter::PostImport  )  [protected, pure virtual]
 

Implemented in MSPaletteFilter, PaintShopProPaletteFilter, AdobeColourTableFilter, AdobeColourSwatchFilter, CorelPaletteFilter, and JCWColourFilter.

virtual BOOL PaletteFilter::PreImport  )  [protected, pure virtual]
 

Implemented in MSPaletteFilter, PaintShopProPaletteFilter, AdobeColourTableFilter, AdobeColourSwatchFilter, CorelPaletteFilter, and JCWColourFilter.

BOOL PaletteFilter::PrepareForImport  )  [private]
 

Initialises the base class before import.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/5/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE for success, FALSE if an error occured.

Definition at line 323 of file coplfilr.cpp.

00324 {
00325     if (!ImportIntoGallery)
00326     {
00327         ERROR2IF(m_pImportDoc==NULL, FALSE, "NULL pointer");
00328 
00329         // Find the colour list document component
00330         ColourListComponent* pColours = NULL;
00331         DocComponent *pComponent = m_pImportDoc->EnumerateDocComponents(NULL);
00332         while (pComponent != NULL)
00333         {
00334             // If this is the colour component, remember it
00335             if (IS_A(pComponent, ColourListComponent))
00336                 pColours = (ColourListComponent*) pComponent;
00337 
00338             // Look for next doc component
00339             pComponent = m_pImportDoc->EnumerateDocComponents(pComponent);
00340         }
00341         ERROR2IF(pColours==NULL, FALSE, "Import document had no colour list");
00342 
00343         // Create a new imported colours manager
00344         ERROR3IF(m_pNewColours != NULL, "ColourImport manager already present\n");
00345         if (m_pNewColours != NULL)
00346         {
00347             m_pNewColours->DestroyColours();
00348             delete m_pNewColours;
00349         }
00350 
00351         m_pNewColours = new ImportedColours(pColours, FALSE);
00352         if ((m_pNewColours == NULL) || !m_pNewColours->Init())
00353             return FALSE;
00354     }
00355 
00356     return TRUE;
00357 }

BOOL PaletteFilter::ProcessCMYKColour double  Cyan,
double  Magenta,
double  Yellow,
double  Key,
const StringBase pColName = NULL
[protected]
 

Generates a Camelot CMYK colour and adds it to the imported colours list.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/96
Parameters:
Cyan - cyan value 0..1 [INPUTS] Magenta - green value 0..1 Yellow - blue value 0..1 Key - black value 0..1 pColName - name to give the colour (NULL if no name)
- [OUTPUTS]
Returns:
TRUE for success, FALSE if an error occured.

Definition at line 466 of file coplfilr.cpp.

00467 {
00468     // Ensure colour components are in range
00469     ERROR3IF(Cyan<0, "Cyan component less than 0");
00470     ERROR3IF(Cyan>1, "Cyan component greater than 1");
00471     ERROR3IF(Magenta<0, "Magenta component less than 0");
00472     ERROR3IF(Magenta>1, "Magenta component greater than 1");
00473     ERROR3IF(Yellow<0, "Yellow component less than 0");
00474     ERROR3IF(Yellow>1, "Yellow component greater than 1");
00475     ERROR3IF(Key<0, "Key component less than 0");
00476     ERROR3IF(Key>1, "Key component greater than 1");
00477     Cyan = ClampZeroToOne(Cyan);
00478     Magenta = ClampZeroToOne(Magenta);
00479     Yellow = ClampZeroToOne(Yellow);
00480     Key = ClampZeroToOne(Key);
00481 
00482     // Make a Camelot CMYK colour
00483     ColourCMYK NewColour;
00484     NewColour.Cyan = Cyan;
00485     NewColour.Magenta = Magenta;
00486     NewColour.Yellow = Yellow;
00487     NewColour.Key = Key;
00488 
00489     // Name the colour
00490     String_64 NewColourName;
00491     BOOL ok = TRUE;
00492     if (pColName==NULL || pColName->IsEmpty())
00493         ok = NameCMYKColour(&NewColour, &NewColourName);
00494     else
00495         NewColourName = *pColName;      
00496 
00497     if (ok)
00498     {
00499         if (ImportIntoGallery)
00500             ok = AddColourToGallery(PalettePrefix_None, &NewColourName, (ColourGeneric *)&NewColour, COLOURMODEL_CMYK);
00501         else
00502             ok = m_pNewColours->AddColour(&NewColourName, &NewColour);
00503     }
00504 
00505     return ok;
00506 }

BOOL PaletteFilter::ProcessGreyColour double  Intensity,
const StringBase pColName = NULL
[protected]
 

Generates a Camelot greyscale colour and adds it to the imported colours list.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/5/96
Parameters:
Intensity - 0..1 (black to white) [INPUTS] pColName - name to give the colour (NULL if no name)
- [OUTPUTS]
Returns:
TRUE for success, FALSE if an error occured.

Definition at line 610 of file coplfilr.cpp.

00611 {
00612     // Ensure colour components are in range
00613     ERROR3IF(Intensity<0, "Intensity component less than 0");
00614     ERROR3IF(Intensity>1, "Intensity component greater than 1");
00615     Intensity = ClampZeroToOne(Intensity);
00616 
00617     // Make a Camelot greyscale colour
00618     ColourGreyT NewColour;
00619     NewColour.Intensity = Intensity;
00620     NewColour.Reserved1 = 0;
00621     NewColour.Reserved2 = 0;
00622     NewColour.Transparent = 0;
00623 
00624     // Name the colour
00625     String_64 NewColourName;
00626     BOOL ok = TRUE;
00627     if (pColName==NULL || pColName->IsEmpty())
00628         ok = NameGreyColour(&NewColour, &NewColourName);
00629     else
00630         NewColourName = *pColName;      
00631 
00632     if (ok)
00633     {
00634         if (ImportIntoGallery)
00635             ok = AddColourToGallery(PalettePrefix_None, &NewColourName, (ColourGeneric *)&NewColour, COLOURMODEL_GREYT);
00636         else
00637             ok = m_pNewColours->AddColour(&NewColourName, &NewColour);
00638     }
00639 
00640     return ok;
00641 }

BOOL PaletteFilter::ProcessHSVColour double  Hue,
double  Sat,
double  Value,
const StringBase pColName = NULL
[protected]
 

Generates a Camelot HSV colour and adds it to the imported colours list.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/96
Parameters:
Hue - Hue value 0..1 [INPUTS] Sat - Saturation value 0..1 Value - Brightness value 0..1 pColName - name to give the colour (NULL if no name)
- [OUTPUTS]
Returns:
TRUE for success, FALSE if an error occured.

Definition at line 522 of file coplfilr.cpp.

00523 {
00524     // Ensure colour components are in range
00525     ERROR3IF(Hue<0, "Hue component less than 0");
00526     ERROR3IF(Hue>1, "Hue component greater than 1");
00527     ERROR3IF(Sat<0, "Saturation component less than 0");
00528     ERROR3IF(Sat>1, "Saturation component greater than 1");
00529     ERROR3IF(Value<0, "Value component less than 0");
00530     ERROR3IF(Value>1, "Value component greater than 1");
00531     Hue = ClampZeroToOne(Hue);
00532     Sat = ClampZeroToOne(Sat);
00533     Value = ClampZeroToOne(Value);
00534 
00535     // Make a Camelot HSV colour
00536     ColourHSVT NewColour;
00537     NewColour.Hue = Hue;
00538     NewColour.Saturation = Sat;
00539     NewColour.Value = Value;
00540     NewColour.Transparent = 0;
00541 
00542     // Name the colour
00543     String_64 NewColourName;
00544     BOOL ok = TRUE;
00545     if (pColName==NULL || pColName->IsEmpty())
00546         ok = NameHSVColour(&NewColour, &NewColourName);
00547     else
00548         NewColourName = *pColName;      
00549 
00550     if (ok)
00551     {
00552         if (ImportIntoGallery)
00553             ok = AddColourToGallery(PalettePrefix_None, &NewColourName, (ColourGeneric *)&NewColour, COLOURMODEL_HSVT);
00554         else
00555             ok = m_pNewColours->AddColour(&NewColourName, &NewColour);
00556     }
00557 
00558     return ok;
00559 }

BOOL PaletteFilter::ProcessLabColour double  Luminance,
double  A,
double  B,
const StringBase pColName = NULL
[protected]
 

Generates a name for this colour and adds it to the imported colours list N.B. Camelot does not support Lab colours so the colour is converted to RGB or greyscale.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/5/96
Parameters:
Luminance - Luminance value 0..100 (black to white) [INPUTS] A - a value +127..-128 (green to red) B - b value +127..-128 (blue to yellow) pColName - name to give the colour (NULL if no name)
- [OUTPUTS]
Returns:
TRUE for success, FALSE if an error occured.

Definition at line 577 of file coplfilr.cpp.

00578 {
00579     // Ensure colour components are in range
00580     ERROR3IF(Luminance<0, "Luminance component less than 0");
00581     ERROR3IF(Luminance>100, "Luminance component greater than 100");
00582     ERROR3IF(A<-128, "A component less than -128");
00583     ERROR3IF(A> 127, "A component greater than 127");
00584     ERROR3IF(B<-128, "B component less than -128");
00585     ERROR3IF(B> 127, "B component greater than 127");
00586     Luminance = __min(100, __max(0, Luminance));
00587     A = __min(127, __max(-128, A));
00588     B = __min(127, __max(-128, B));
00589 
00590     // Convert to RGB values
00591     Vector3D Lab(Luminance, A, B);
00592     Vector3D RGBResult;
00593     PaletteFilter::ConvertLABToRGB(Lab, &RGBResult);
00594 
00595     return ProcessRGBColour(RGBResult.x, RGBResult.y, RGBResult.z, pColName );
00596 }

BOOL PaletteFilter::ProcessRGBColour double  Red,
double  Green,
double  Blue,
const StringBase pColName = NULL
[protected]
 

Generates a Camelot RGB colour and adds it to the imported colours list.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/5/96
Parameters:
Red - red value 0..1 [INPUTS] Green - green value 0..1 Blue - blue value 0..1 pColName - name to give the colour (NULL if no name)
- [OUTPUTS]
Returns:
TRUE for success, FALSE if an error occured.

Definition at line 412 of file coplfilr.cpp.

00413 {
00414     // Ensure colour components are in range
00415     ERROR3IF(Red<0, "Red component less than 0");
00416     ERROR3IF(Red>1, "Red component greater than 1");
00417     ERROR3IF(Green<0, "Green component less than 0");
00418     ERROR3IF(Green>1, "Green component greater than 1");
00419     ERROR3IF(Blue<0, "Blue component less than 0");
00420     ERROR3IF(Blue>1, "Blue component greater than 1");
00421     Red = ClampZeroToOne(Red);
00422     Green = ClampZeroToOne(Green);
00423     Blue = ClampZeroToOne(Blue);
00424 
00425     // Make a Camelot RGB colour
00426     ColourRGBT NewColour;
00427     NewColour.Red = Red;
00428     NewColour.Green = Green;
00429     NewColour.Blue = Blue;
00430     NewColour.Transparent = 0;
00431 
00432     // Name the colour
00433     String_64 NewColourName;
00434     BOOL ok = TRUE;
00435     if (pColName==NULL || pColName->IsEmpty())
00436         ok = NameRGBColour(&NewColour, &NewColourName);
00437     else
00438         NewColourName = *pColName;      
00439 
00440     if (ok)
00441     {
00442         if (ImportIntoGallery)
00443             ok = AddColourToGallery(PalettePrefix_None, &NewColourName, (ColourGeneric *)&NewColour, COLOURMODEL_RGBT);
00444         else
00445             ok = m_pNewColours->AddColour(&NewColourName, &NewColour);
00446     }
00447 
00448     return ok;
00449 }

BOOL PaletteFilter::SetPercentage INT32  GotTo = -1  )  [protected]
 

Continues a percentage delay indicator. Pass -1 to use the current import file position as a progress indicator.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/5/96
Parameters:
GotTo - the current position [INPUTS]
- [OUTPUTS]
Returns:
TRUE for success, FALSE if an error occured.

Definition at line 839 of file coplfilr.cpp.

00840 {
00841 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00842     if (GotTo == -1)
00843     {
00844         if (m_pImportFile != NULL)
00845             ContinueSlowJob(m_pImportFile->tell());
00846         else
00847             ContinueSlowJob();
00848     }
00849     else
00850         ContinueSlowJob(GotTo);
00851 #endif
00852     return TRUE;
00853 }

BOOL PaletteFilter::StartPercentage INT32  UpTo = -1  )  [protected]
 

Starts a percentage delay indicator that runs from 0 to 100. If you don't know how many colours you are importing pass -1 and the length of the file is used.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/5/96
Parameters:
UpTo - the 100% value [INPUTS]
- [OUTPUTS]
Returns:
TRUE for success, FALSE if an error occured.

Definition at line 811 of file coplfilr.cpp.

00812 {
00813 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00814     if (UpTo == -1)
00815     {
00816         if (m_pImportFile != NULL)
00817             BeginSlowJob(m_pImportFile->Size());
00818         else
00819             BeginSlowJob();
00820     }
00821     else
00822         BeginSlowJob(UpTo);
00823 #endif
00824     return TRUE;
00825 }

BOOL PaletteFilter::UsePercentageColour  )  [protected]
 

To see wether or not to use the precentage colour naming scheme.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/5/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the colour editor preference is for percentages, FALSE if not

Definition at line 780 of file coplfilr.cpp.

00781 {
00782 // WEBSTER - markn 24/4/97
00783 #ifdef WEBSTER
00784     // Always use percentages for colour units in Webster
00785     return TRUE;
00786 #else
00787     #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00788         // Read what the colour editors preference is
00789         ScaleUnit* pUnit = UnitsTab::GetColourUnitPreference();
00790 
00791         return (pUnit == &StandardUnit::UnitPercent);
00792     #else
00793         return FALSE;
00794     #endif
00795 #endif // WEBSTER
00796 }


Member Data Documentation

SGDisplayLibColGroup* PaletteFilter::CurrentGalleryGroup [protected]
 

Definition at line 199 of file coplfilr.h.

BOOL PaletteFilter::ImportIntoGallery [protected]
 

Definition at line 198 of file coplfilr.h.

Document* PaletteFilter::m_pImportDoc [protected]
 

Definition at line 196 of file coplfilr.h.

CCLexFile* PaletteFilter::m_pImportFile [protected]
 

Definition at line 195 of file coplfilr.h.

SelOperation* PaletteFilter::m_pImportOp [protected]
 

Definition at line 194 of file coplfilr.h.

ImportedColours* PaletteFilter::m_pNewColours [protected]
 

Definition at line 193 of file coplfilr.h.


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