casa
5.7.0-16
|
Implementation of PixelCanvasColorTable for PostScript device. More...
#include <PSPixelCanvasColorTable.h>
Public Types | |
enum | { INDEXBPC, RGBBPC, INDEXCOLORS, RGBCOLORS } |
enum | { NUMROCOLORS, NUMRWCOLORS } |
The last NUMROCOLORS of the table are reserved for RO values. More... | |
enum | { BMASK, RGBMASK, INDEXMASK } |
enum | { RSHIFT, GSHIFT, BSHIFT } |
Amount to shift components when mapping RGB. More... | |
Public Member Functions | |
PSPixelCanvasColorTable (PSDriver *ps, const Display::ColorModel=Display::Index) | |
virtual | ~PSPixelCanvasColorTable () |
virtual casacore::Bool | resize (casacore::uInt newSize) |
Resize the map if allowed. More... | |
virtual casacore::Bool | resize (casacore::uInt nReds, casacore::uInt nGreens, casacore::uInt nBlues) |
virtual casacore::Bool | installRGBColors (const casacore::Vector< casacore::Float > &r, const casacore::Vector< casacore::Float > &g, const casacore::Vector< casacore::Float > &b, const casacore::Vector< casacore::Float > &alpha, casacore::uInt offset=0) |
Install colors into the color table. More... | |
virtual casacore::uInt | nColors () const |
Return the number of colors used to make the map. More... | |
virtual void | nColors (casacore::uInt &n1, casacore::uInt &n2, casacore::uInt &n3) const |
Return the number of colors per component. More... | |
casacore::uInt | maxColors () const |
Maximum number of colors in color table. More... | |
virtual casacore::uInt | depth () const |
Return the depth in bits of the colors. More... | |
virtual casacore::uInt | nSpareColors () const |
Return the number of colors that are still unallocated. More... | |
virtual void | mapToColor (const Colormap *map, casacore::Array< casacore::uChar > &outArray, const casacore::Array< casacore::uChar > &inArray, casacore::Bool rangeCheck=true) const |
map [0,N-1] into colorpixels, where N is the current colormap size The values are returned as unsigned integers in their respective array. More... | |
virtual void | mapToColor (const Colormap *map, casacore::Array< casacore::uShort > &outArray, const casacore::Array< casacore::uShort > &inArray, casacore::Bool rangeCheck=true) const |
virtual void | mapToColor (const Colormap *map, casacore::Array< casacore::uInt > &outArray, const casacore::Array< casacore::uInt > &inArray, casacore::Bool rangeCheck=true) const |
virtual void | mapToColor (const Colormap *map, casacore::Array< casacore::uLong > &outArray, const casacore::Array< casacore::uLong > &inArray, casacore::Bool rangeCheck=true) const |
virtual void | mapToColor (const Colormap *map, casacore::Array< casacore::uChar > &inOutArray, casacore::Bool rangeCheck=true) const |
Same as above except the matrix is operated on in place. More... | |
virtual void | mapToColor (const Colormap *map, casacore::Array< casacore::uShort > &inOutArray, casacore::Bool rangeCheck=true) const |
virtual void | mapToColor (const Colormap *map, casacore::Array< casacore::uInt > &inOutArray, casacore::Bool rangeCheck=true) const |
virtual void | mapToColor (const Colormap *map, casacore::Array< casacore::uLong > &inOutArray, casacore::Bool rangeCheck=true) const |
virtual void | mapToColor3 (casacore::Array< casacore::uLong > &out, const casacore::Array< casacore::Float > &chan1in, const casacore::Array< casacore::Float > &chan2in, const casacore::Array< casacore::Float > &chan3in) |
(Multichannel Color) Merge separate channel data into an output image. More... | |
virtual void | mapToColor3 (casacore::Array< casacore::uLong > &out, const casacore::Array< casacore::Double > &chan1in, const casacore::Array< casacore::Double > &chan2in, const casacore::Array< casacore::Double > &chan3in) |
virtual void | mapToColor3 (casacore::Array< casacore::uLong > &out, const casacore::Array< casacore::uShort > &chan1in, const casacore::Array< casacore::uShort > &chan2in, const casacore::Array< casacore::uShort > &chan3in) |
This one maps values between 0 and the integer maximum value for each channel into a single output image suitable for PixelCanvas::drawImage(). More... | |
virtual void | mapToColor3 (casacore::Array< casacore::uLong > &out, const casacore::Array< casacore::uInt > &chan1in, const casacore::Array< casacore::uInt > &chan2in, const casacore::Array< casacore::uInt > &chan3in) |
void | mapFromColor3 (const casacore::Array< casacore::uLong > &inArray, casacore::Array< casacore::uShort > &outArray) const |
Convert from a packed array of RGB triples to an array of color values. More... | |
virtual casacore::Bool | colorSpaceMap (Display::ColorModel, const casacore::Array< casacore::Float > &chan1in, const casacore::Array< casacore::Float > &chan2in, const casacore::Array< casacore::Float > &chan3in, casacore::Array< casacore::Float > &chan1out, casacore::Array< casacore::Float > &chan2out, casacore::Array< casacore::Float > &chan3out) |
(Multichannel Color) Transform arrays from the passed color model into the colormodel of the PSPCCT. More... | |
Display::ColorModel | colorModel () const |
Return the color model for multichannel color. More... | |
casacore::uInt | numComponents () const |
Returns the current # of color components (1 for Indexed, 3 for RGB/HSV). More... | |
virtual void | setColorModel (const Display::ColorModel) |
Changeable at any time. More... | |
PSDriver * | getPSDriver () const |
casacore::Bool | queryColor (const int index, float &r, float &g, float &b) |
Return contents of colormap at the given index. More... | |
casacore::Bool | storeColor (const int index, const float r, const float g, const float b) |
Sets the contents of colormap at the given index. More... | |
casacore::Bool | allocColor (const float r, const float g, const float b, int &index) |
Allocate the color value in the color table. More... | |
casacore::Bool | allocColor (const casacore::String &name, int &index) |
casacore::Bool | allocColor (const char *name, int &index) |
casacore::Bool | annotate () const |
Whether to put tracing comments in the output. More... | |
void | annotate (const casacore::Bool a) |
Public Member Functions inherited from casa::PixelCanvasColorTable | |
virtual casacore::Bool | staticSize () |
Is the hardware colormap resizeable? ie. More... | |
virtual | ~PixelCanvasColorTable () |
Virtual destructor. More... | |
void | addResizeCallback (PixelCanvasColorTableResizeCB cb, void *clientData) |
Add and remove resize callbacks PixelCanvasColorTableResizeCB is of type: void (*)(class PixelCanvasColorTable * pcctbl, casacore::uInt newSize, void * clientData, Display::RefreshReason reason) More... | |
void | removeResizeCallback (PixelCanvasColorTableResizeCB cb, void *clientData) |
void | doResizeCallbacks (const Display::RefreshReason &reason=Display::ColorTableChange) |
casacore::Function that issues resize callbacks More... | |
void | registerColormap (Colormap *cmap, casacore::Float weight=1.0) |
Register a colormap to be managed by the pixel canvas' color table. More... | |
void | registerColormap (Colormap *cmap, Colormap *cmapToReplace) |
Register the cmap Colormap on the PixelCanvasColorTable, replacing the cmapToReplace Colormap if possible. More... | |
void | unregisterColormap (Colormap *cmap) |
Unregister a data colormap reference previously added. More... | |
casacore::uInt | getColormapSize (const Colormap *cmap) const |
Return the allocation size of some Colormap. More... | |
virtual void | mapToColorRGB (const Colormap *map, casacore::Array< casacore::uInt > &outArray, const casacore::Array< casacore::uInt > &inArrayRed, const casacore::Array< casacore::uInt > &inArrayGreen, const casacore::Array< casacore::uInt > &inArrayBlue) const |
casacore::Bool | member (const Colormap *cmap) const |
Return whether or not a data colormap is used by this pixel canvas. More... | |
void | setDefaultColormap (const Colormap *map) |
Return the default map. More... | |
ColormapManager & | colormapManager () |
Return the colormapManager used by this PCCT. More... | |
void | registerPixelCanvas (const class PixelCanvas *pc) |
void | doRefreshCallbacks () |
*Colormap * | defaultColormap () |
Static Public Member Functions | |
static casacore::Bool | parseColor (const char *name, float &red, float &green, float &blue) |
X11 emulation routines. More... | |
static casacore::Bool | parseColor (const casacore::String &name, float &red, float &green, float &blue) |
static void | pixelToComponents (const casacore::uLong pixel, casacore::uShort &r, casacore::uShort &g, casacore::uShort &b) |
Convert a packed pixel (from mapToColor3) to three color components. More... | |
static void | componentsToPixel (const casacore::uShort r, const casacore::uShort g, casacore::uShort &b, casacore::uLong &pixel) |
Pack RGB or HSV color components into a single unsigned long. More... | |
Private Member Functions | |
PSPixelCanvasColorTable () | |
void | pspcinit (PSDriver *ps, const Display::ColorModel) |
casacore::Bool | lookupROColor (const float r, const float g, const float b, int &index) |
Finds the index of a color triple coming 'close' to the RGB args. More... | |
casacore::Bool | lookupRWColor (const float r, const float g, const float b, int &index) |
int | allocColor_ (const float r, const float g, const float b, int &index) |
void | deallocate (casacore::uLong index) |
Mark a RO color as unallocated. More... | |
Private Attributes | |
casacore::uInt | nColors_ |
(Valid Always) number of total colors available. More... | |
casacore::uInt | bpc_ |
Number of bits/per component. More... | |
Display::ColorModel | colorModel_ |
(Valid Always) The colormodel that this PSPixelCanvasColorTable is currently configured as. More... | |
PSDriver * | ps |
PS. More... | |
float | red_ [INDEXCOLORS] |
Copies of the color table. More... | |
float | blue_ [INDEXCOLORS] |
float | green_ [INDEXCOLORS] |
casacore::Bool | allocated_ [NUMROCOLORS] |
true if index has been allocated. More... | |
casacore::Bool | annotate_ |
Friends | |
casacore::ostream & | operator<< (casacore::ostream &os, const PSPixelCanvasColorTable &pcc) |
print details of class to ostream More... | |
Additional Inherited Members | |
Protected Member Functions inherited from casa::PixelCanvasColorTable | |
casacore::uInt | getColormapOffset (const Colormap *map) const |
return the offset of a particular colormap. More... | |
PixelCanvasColorTable () | |
Abstract base class. More... | |
Implementation of PixelCanvasColorTable for PostScript device.
To create a PSPixelCanvasColorTable, just pass the constructor a pointer to a PSDriver and, optionally, supplying a color model. (The default is Index).
Tip: Unlike the X11PixelCanvasColorTable, PSPixelCanvasColorTable allows changing the color model on the fly;
PSPixelCanvasColorTable is not likely to be explicitly used by other than Display Library developers, particularly those creating "WorldCanvasApp"s. One exception is using PSPixelCanvasColorTable in non Index mode. Since PSWorldCanvasApp creates its PSPixelCanvasColorTable in Index mode, it will be necessary to get a pointer to the object and explicitly change to different color modes.
See Display/test/dMultichannelRaster.cc for an example.
Tip: PostScript supports a 4096 entry color table for indexed color; PSPixelCanvasColorTable logically breaks this into two parts; One part is used for the changable colors; The other part is reserved for read only colors; (Those allocated by name); The number of read only colors is 512;
Internal
Definition at line 98 of file PSPixelCanvasColorTable.h.
anonymous enum |
Enumerator | |
---|---|
INDEXBPC | |
RGBBPC | |
INDEXCOLORS | |
RGBCOLORS |
Definition at line 103 of file PSPixelCanvasColorTable.h.
anonymous enum |
The last NUMROCOLORS of the table are reserved for RO values.
Enumerator | |
---|---|
NUMROCOLORS | |
NUMRWCOLORS |
Definition at line 108 of file PSPixelCanvasColorTable.h.
anonymous enum |
Enumerator | |
---|---|
BMASK | |
RGBMASK | |
INDEXMASK |
Definition at line 109 of file PSPixelCanvasColorTable.h.
anonymous enum |
Amount to shift components when mapping RGB.
Enumerator | |
---|---|
RSHIFT | |
GSHIFT | |
BSHIFT |
Definition at line 113 of file PSPixelCanvasColorTable.h.
casa::PSPixelCanvasColorTable::PSPixelCanvasColorTable | ( | PSDriver * | ps, |
const Display::ColorModel | = Display::Index |
||
) |
|
virtual |
|
private |
casacore::Bool casa::PSPixelCanvasColorTable::allocColor | ( | const float | r, |
const float | g, | ||
const float | b, | ||
int & | index | ||
) |
Allocate the color value in the color table.
index is set to the index allocated. Returns true for success, else false.
casacore::Bool casa::PSPixelCanvasColorTable::allocColor | ( | const casacore::String & | name, |
int & | index | ||
) |
casacore::Bool casa::PSPixelCanvasColorTable::allocColor | ( | const char * | name, |
int & | index | ||
) |
|
private |
|
inline |
Whether to put tracing comments in the output.
This may be helpful when trying to decipher the PostScript file.
Definition at line 290 of file PSPixelCanvasColorTable.h.
References annotate_.
|
inline |
Definition at line 293 of file PSPixelCanvasColorTable.h.
References annotate_.
|
virtual |
Return the color model for multichannel color.
Implements casa::PixelCanvasColorTable.
|
virtual |
(Multichannel Color) Transform arrays from the passed color model into the colormodel of the PSPCCT.
Does nothing if colorModel is Display::Index. It is assumed that input arrays are in the range of [0,1]
Implements casa::PixelCanvasColorTable.
|
inlinestatic |
|
private |
Mark a RO color as unallocated.
|
virtual |
Return the depth in bits of the colors.
Implements casa::PixelCanvasColorTable.
|
inline |
Definition at line 244 of file PSPixelCanvasColorTable.h.
References ps.
|
virtual |
Install colors into the color table.
Offset is zero-based. Colors are installed into the PixelCanvasColorTable until the Arrays run out or until the end of the colortable is reached. Can be called in any mode, but only affects graphics drawn in Index mode. Values are clamped to [0.0,1.0].h3>Thrown Exceptions
the number of RW colors in the colormap.
Implements casa::PixelCanvasColorTable.
|
private |
Finds the index of a color triple coming 'close' to the RGB args.
Returns: true if a match is found, else false. If lookROColor finds a match with a deallocated cell, it reallocates it.
|
private |
void casa::PSPixelCanvasColorTable::mapFromColor3 | ( | const casacore::Array< casacore::uLong > & | inArray, |
casacore::Array< casacore::uShort > & | outArray | ||
) | const |
Convert from a packed array of RGB triples to an array of color values.
The output array needs to be 3 times as long as the input array. Used by PSPixelCanvas to convert from D.L. RGB format to an array the PostScript driver can use.
|
virtual |
map [0,N-1] into colorpixels, where N is the current colormap size The values are returned as unsigned integers in their respective array.
Warning: casacore::uChar type doesn't have enough bits to hold the pixel index;
Warning: casacore::uChar and casacore::uShort don't have enough bits to hold RGB or HSV values;
Implements casa::PixelCanvasColorTable.
|
virtual |
Implements casa::PixelCanvasColorTable.
|
virtual |
Implements casa::PixelCanvasColorTable.
|
virtual |
Implements casa::PixelCanvasColorTable.
|
virtual |
Same as above except the matrix is operated on in place.
Only unsigned values make sense here.
Implements casa::PixelCanvasColorTable.
|
virtual |
Implements casa::PixelCanvasColorTable.
|
virtual |
Implements casa::PixelCanvasColorTable.
|
virtual |
Implements casa::PixelCanvasColorTable.
|
virtual |
(Multichannel Color) Merge separate channel data into an output image.
This function maps floating values between 0 and 1 into a output image suitable for PixelCanvas::drawImage().
Implements casa::PixelCanvasColorTable.
|
virtual |
Implements casa::PixelCanvasColorTable.
|
virtual |
This one maps values between 0 and the integer maximum value for each channel into a single output image suitable for PixelCanvas::drawImage().
Implements casa::PixelCanvasColorTable.
|
virtual |
Implements casa::PixelCanvasColorTable.
casacore::uInt casa::PSPixelCanvasColorTable::maxColors | ( | ) | const |
Maximum number of colors in color table.
|
virtual |
Return the number of colors used to make the map.
Implements casa::PixelCanvasColorTable.
|
virtual |
Return the number of colors per component.
For RGB/HSV, returns the number of colors/component supported by PostScript. For Index, returns the number of colors/component for the lookup table. (Limited by D.L. spec).
Implements casa::PixelCanvasColorTable.
|
virtual |
Return the number of colors that are still unallocated.
Implements casa::PixelCanvasColorTable.
casacore::uInt casa::PSPixelCanvasColorTable::numComponents | ( | ) | const |
Returns the current # of color components (1 for Indexed, 3 for RGB/HSV).
|
static |
X11 emulation routines.
See XParseColor for more information.
|
static |
|
inlinestatic |
|
private |
casacore::Bool casa::PSPixelCanvasColorTable::queryColor | ( | const int | index, |
float & | r, | ||
float & | g, | ||
float & | b | ||
) |
Return contents of colormap at the given index.
Returns false if the index is out of range. The valid range of index is 0..4095.
|
virtual |
Resize the map if allowed.
Returns true if resize was accepted
Implements casa::PixelCanvasColorTable.
|
virtual |
Implements casa::PixelCanvasColorTable.
|
virtual |
Changeable at any time.
casacore::Bool casa::PSPixelCanvasColorTable::storeColor | ( | const int | index, |
const float | r, | ||
const float | g, | ||
const float | b | ||
) |
Sets the contents of colormap at the given index.
Returns false if the index is out of range. The valid range of index is 0..nColors(). (Can't change read only values).
|
friend |
print details of class to ostream
|
private |
true if index has been allocated.
Definition at line 345 of file PSPixelCanvasColorTable.h.
|
private |
Definition at line 346 of file PSPixelCanvasColorTable.h.
Referenced by annotate().
|
private |
Definition at line 341 of file PSPixelCanvasColorTable.h.
|
private |
Number of bits/per component.
Determined by colorModel_.
Definition at line 331 of file PSPixelCanvasColorTable.h.
|
private |
(Valid Always) The colormodel that this PSPixelCanvasColorTable is currently configured as.
Definition at line 336 of file PSPixelCanvasColorTable.h.
|
private |
Definition at line 341 of file PSPixelCanvasColorTable.h.
|
private |
(Valid Always) number of total colors available.
Changed by resize.
Definition at line 329 of file PSPixelCanvasColorTable.h.
|
private |
|
private |
Copies of the color table.
Definition at line 341 of file PSPixelCanvasColorTable.h.