This abstract class is communicated to by the PixelCanvas to perform color operations. The information in this file should not be needed to support applications programmers, and is provided for the future maintainer of the Display library.
A Major role of the PixelCanvasColorTable is to dynamically allocate space out of its own colortable allocation from the underlying graphics library for its registered Colormaps. It talks to its ColormapManager to return the Colormap information needed to properly scale data values to color. An application must know the size of the colormap to determine the color resolution available to value-related data.
The mapToColor functions will be needed by most image drawing and colored vector display drawing calls to transform quantized values into color indices.
The PixelCanvasColorTable is distinguished from the
Colormap by its functionality. There is one and only one
PixelCanvasColorTable for each
Resize the hardware colormap.
Install colors into the color table. Offset is zero-based. Colors
are installed into the PixelCanvasColorTable until the vectors run out
or until the end of the colortable is reached. This has no effect if
in real/pseudo RGB/HSV modes. Values are clamped to [0.0,1.0].
Return the number of colors used to make the map.
Return the number of colors per component used in the map. Fails
for non-HSV/RGB modes.
Return the depth of the map in bits
Return the number of colors that are still unallocated
Virtual destructor
Add and remove resize callbacks
PixelCanvasColorTableResizeCB is of type:
Function that issues resize callbacks
Register a colormap to be managed by the pixel canvas' color table
Register the cmap Colormap on the
PixelCanvasColorTable, replacing the cmapToReplace<src>
Colormap if possible.
Unregister a data colormap reference previously added
Return the allocation size of some Colormap
map [0,N-1] into colorpixels, where N is the current colormap size
The values are returned as unsigned integers in their respective
array.
same as above except the matrix is operated on in place. Only unsigned
values make sense here. I don't really know what to include here. Maybe
ask the code cop.
Functions for dealing with multi-channel mapping
(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().
Functions for dealing with multi-channel mapping
This one maps values between 0 and the integer
maximum value for each channel into a single
output image suitable for PixelCanvas::drawImage().
(Multichannel Color)
Transform arrays from the passed color model into
the colormodel of the XPCCT.
Does nothing if colorModel is Display::Index.
It is assumed that input arrays are in the range of [0,1]
Return whether or not a data colormap is used by this pixel canvas
Return the default map. This map is only used if no other colormaps
are registered AND if we're in INDEX mode.
Colormap * defaultColormap() const { return defaultColormap_; }
Set the default colormap
Return the colormapManager used by this PCCT
Return the color model for multichannel color
Abstract base class
Motivation
Needed to abstract the concepts involved in color resource allocation from
the
PixelCanvas user.
Example
see the PixelCanvas test programs
To Do
To Do
Member Description
virtual Bool staticSize()
Is the hardware colormap resizeable? ie. is it write-only?
Default is to return true, and derived classes should generally
override this function.
virtual Bool resize(uInt newSize) = 0
virtual Bool resize(uInt nReds, uInt nGreens, uInt nBlues) = 0
virtual Bool installRGBColors(const Vector<Float> & r, const Vector<Float> & g, const Vector<Float> & b, uInt offset = 0) = 0
virtual uInt nColors() const = 0
virtual void nColors(uInt &n1, uInt &n2, uInt &n3) const = 0
virtual uInt depth() const = 0
virtual uInt nSpareColors() const = 0
virtual ~PixelCanvasColorTable()
void addResizeCallback(PixelCanvasColorTableResizeCB cb, void * clientData)
void removeResizeCallback(PixelCanvasColorTableResizeCB cb, void * clientData)
void (*)(class PixelCanvasColorTable * pcctbl, uInt newSize, void * clientData, Display::RefreshReason reason)
void doResizeCallbacks(const Display::RefreshReason &reason = Display::ColorTableChange)
void registerColormap(Colormap * cmap, Float weight = 1.0)
void registerColormap(Colormap *cmap, Colormap *cmapToReplace)
void unregisterColormap(Colormap * cmap)
uInt getColormapSize(const Colormap * cmap) const
virtual void mapToColor(const Colormap * map, Array<uChar> & outArray, const Array<uChar> & inArray, Bool rangeCheck = True) const = 0
virtual void mapToColor(const Colormap * map, Array<uShort> & outArray, const Array<uShort> & inArray, Bool rangeCheck = True) const = 0
virtual void mapToColor(const Colormap * map, Array<uInt> & outArray, const Array<uInt> & inArray, Bool rangeCheck = True) const = 0
virtual void mapToColor(const Colormap * map, Array<uLong> & outArray, const Array<uLong> & inArray, Bool rangeCheck = True) const = 0
uChar type may not have enough bits
to hold the pixel index on some high-end graphics systems
uShort type may not have enough bits
to hold the pixel index on some high-end graphics systems
virtual void mapToColor(const Colormap * map, Array<uChar> & inOutArray, Bool rangeCheck = True) const = 0
virtual void mapToColor(const Colormap * map, Array<uShort> & inOutArray, Bool rangeCheck = True) const = 0
virtual void mapToColor(const Colormap * map, Array<uInt> & inOutArray, Bool rangeCheck = True) const = 0
virtual void mapToColor(const Colormap * map, Array<uLong> & inOutArray, Bool rangeCheck = True) const = 0
virtual void mapToColor3(Array<uLong> & out, const Array<Float> & chan1in, const Array<Float> & chan2in, const Array<Float> & chan3in) = 0
virtual void mapToColor3(Array<uLong> & out, const Array<Double> & chan1in, const Array<Double> & chan2in, const Array<Double> & chan3in) = 0
virtual void mapToColor3(Array<uLong> & out, const Array<uShort> & chan1in, const Array<uShort> & chan2in, const Array<uShort> & chan3in) = 0
virtual void mapToColor3(Array<uLong> & out, const Array<uInt> & chan1in, const Array<uInt> & chan2in, const Array<uInt> & chan3in) = 0
virtual Bool colorSpaceMap(Display::ColorModel, const Array<Float> & chan1in, const Array<Float> & chan2in, const Array<Float> & chan3in, Array<Float> & chan1out, Array<Float> & chan2out, Array<Float> & chan3out) = 0
Bool member(const Colormap * cmap) const
void setDefaultColormap(const Colormap * map)
ColormapManager & colormapManager()
virtual Display::ColorModel colorModel() const = 0
void registerPixelCanvas(const class PixelCanvas * pc)
register a pixel canvas on this pcct
void doRefreshCallbacks()
Colormap* defaultColormap()
uInt getColormapOffset(const Colormap * map) const
return the offset of a particular colormap. This information is not
made available to the outside caller. Rather a function to map
values to color is made available.
PixelCanvasColorTable()