casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
casa::GLPixelCanvasColorTable Class Reference

#include <GLPixelCanvasColorTable.h>

Inheritance diagram for casa::GLPixelCanvasColorTable:
casa::PixelCanvasColorTable

List of all members.

Public Types

enum  FILLMODE {
  FILLRGB,
  FILLRBG,
  FILLGRB,
  FILLGBR,
  FILLBRG,
  FILLBGR
}

Public Member Functions

 GLPixelCanvasColorTable ()
 ~GLPixelCanvasColorTable ()
 GLPixelCanvasColorTable (::XDisplay *dpy, Display::ColorModel mapType=Display::RGB, Float percent=90.0, XVisualInfo *visInfo=NULL)
Bool allocCells (uInt nCells)
 allocate cells for colormaps
Bool deallocCells ()
 deallocate cells for colormaps
Bool allocColorCube ()
 Allocate the best color cube given the map.
Bool allocColorCube (uInt n1, uInt n2, uInt n3)
 Allocate a color cube of a specific size.
Bool allocColorCubeMinMax (uInt n1min, uInt n2min, uInt n3min, uInt n1max, uInt n2max, uInt n3max)
 Allocate a color cube within the ranges of sizes.
void copyColorCube (const GLPixelCanvasColorTable &mapRef)
 Copy color cube info from the mapRef.
void fillColorCubeRGB ()
 Fill a color cube with an RGB spectrum.
void fillColorCubeHSV ()
 Fill a color cube with an HSV spectrum.
void mapToColor3 (Array< uLong > &out, const Array< Float > &chan1in, const Array< Float > &chan2in, const Array< Float > &chan3in)
 Merge separate channel data into an output image.
void mapToColor3 (Array< uLong > &out, const Array< Double > &chan1in, const Array< Double > &chan2in, const Array< Double > &chan3in)
void mapToColor3 (Array< uLong > &out, const Array< uShort > &chan1in, const Array< uShort > &chan2in, const Array< 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().
void mapToColor3 (Array< uLong > &out, const Array< uInt > &chan1in, const Array< uInt > &chan2in, const Array< uInt > &chan3in)
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)
 (Multichannel Color) Transform arrays from the passed color model into the colormodel of the XPCCT.
void mapToColor (const Colormap *map, Array< uChar > &outArray, const Array< uChar > &inArray, 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.
void mapToColor (const Colormap *map, Array< uShort > &outArray, const Array< uShort > &inArray, Bool rangeCheck=True) const
void mapToColor (const Colormap *map, Array< uInt > &outArray, const Array< uInt > &inArray, Bool rangeCheck=True) const
void mapToColor (const Colormap *map, Array< uLong > &outArray, const Array< uLong > &inArray, Bool rangeCheck=True) const
void mapToColor (const Colormap *map, Array< uChar > &inOutArray, Bool rangeCheck=True) const
 same as above except the matrix is operated on in place.
void mapToColor (const Colormap *map, Array< uShort > &inOutArray, Bool rangeCheck=True) const
void mapToColor (const Colormap *map, Array< uInt > &inOutArray, Bool rangeCheck=True) const
void mapToColor (const Colormap *map, Array< uLong > &inOutArray, Bool rangeCheck=True) const
virtual Bool staticSize ()
 Is the hardware colormap resizeable? ie.
Bool resize (uInt newSize)
 resize the map if allowed.
Bool resize (uInt nReds, uInt nGreens, uInt nBlues)
Bool installRGBColors (const Vector< Float > &r, const Vector< Float > &g, const Vector< Float > &b, uInt offset=0)
 Install colors into the color table.
uInt nColors () const
 Return the total number of RW colors currently in use.
virtual void nColors (uInt &n1, uInt &n2, uInt &n3) const
 Return the number of colors per component in the map.
uInt depth () const
 Return the depth in bits of the colors.
uInt nSpareColors () const
 Return the number of colors that are still unallocated.
::XDisplay * display () const
 Return pointer to display that is being used.
Screen * screen () const
 Return pointer to screen that is being used.
Visual * visual () const
 Return pointer to visual that is being used.
XVisualInfo * visualInfo () const
 Return pointer to visual info that is being used.
XColormap xcmap () const
 Return XID of X "virtual colormap" being used.
Bool indexMode () const
 Return True if the table is in colorIndex mode.
Bool rgbMode () const
 Return True if the table is in RGB mode.
Bool hsvMode () const
 Return True if the table is in HSV mode.
Bool rigid () const
 Return True if the colortable can be resized.
Display::ColorModel colorModel () const
 Return the color model for multichannel color.
Bool readOnly () const
Bool decomposedIndex () const
uInt QueryColorsAvailable (const Bool contig) const
 Return the number of currently unallocated cells that can be allocated RW.
virtual uInt QueryHWColorsAvailable (const Bool contig) const
Bool virtualToPhysical (const unsigned long vindex, unsigned long &pindex) const
 Convert a virtual index to a physical pixel.
void storeColor (const uInt index, const float r, const float g, const float b)
 Store an RGB value at index.
void pixelToComponents (const uLong pixel, Float &r, Float &g, Float &b)
 Convert a pixel to color components.
void indexToRGB (const uInt index, float &r, float &g, float &b)
 Returns the color values for the index.

Static Public Member Functions

static void colorFillRGB (Vector< Float > &r, Vector< Float > &g, Vector< Float > &b, uInt nr, uInt ng, uInt nb, FILLMODE mode=FILLRGB)
static void colorFillRGB (Vector< Float > &r, Vector< Float > &g, Vector< Float > &b, uInt ncolors, FILLMODE mode=FILLRGB)
static XVisualInfo * getVisualInfo (::XDisplay *dpy, const Display::ColorModel colormodel)
 Return a GL capable visual that supports the colormodel or NULL.

Private Member Functions

Bool isPow2 (uInt n, uInt &log2n)
 Return the log power 2 of n and return True if n is a power of two.
void setupColorCube (uLong n1, uLong n2, uLong n3, uLong n1m, uLong n2m, uLong n3m)
 (Multi-Channel)
void setupStandardMapping (const XStandardColormap *mapInfo)
 (Multi-Channel)
Bool initVisual (XVisualInfo *vi=NULL)
void checkVisual ()
virtual void storeHWColor (const uLong pindex, const float r, const float g, const float b)
 Write an RGB value to hardware colormap at physical index.
void HSV2RGB (const uLong H, const uLong S, const uLong V, uLong &R, uLong &G, uLong &B)
 Convert from integer HSV components to RGB pixel components.
uInt HSV2Index (float h, float s, float v)
Valid only for multi channel color modes (RGB, HSV, etc)) If true

Private Attributes

::XDisplay * display_
 A pointer to the XDisplay.
Screen * screen_
 A pointer the the X Screen.
Visual * visual_
 A pointer to the X Visual.
XVisualInfo * visualInfo_
XColormap xcmap_
 A pointer to the XColormap (X Hardware colormap)
uInt depth_
 (Valid Always) number of bits of depth
uInt nColors_
 (Valid Always) number of total colors available for RW.
uLongcolors_
 (Valid only when implementation uses a PseudoColor or a StaticColor visual).
uShort vcmapLength_
GLVColorTableEntryvcmap_
 (& HW map if it exists)
Bool rigid_
 (Valid Always) True if the table may not be resized, such as when a standard XColormap is used.
True if the colormap is read
only *Bool 
readOnly_
Bool decomposedIndex_
 True if TrueColor or DirectColor.
unsigned short red_shift_
 Shift counts, masks, and max values used to build pixels for decomposed index colormaps.
unsigned short green_shift_
unsigned short blue_shift_
unsigned short red_max_
unsigned short green_max_
unsigned short blue_max_
unsigned long red_mask_
unsigned long green_mask_
unsigned long blue_mask_
Valid only for multi channel
color then the color cube s
sides are powers of 
two
Display::ColorModel colorModel_
 (Valid Always) The colormodel that this GLPixelCanvasColorTable has been configured as.
uLong baseColor_
 (Valid only for multi-channel color modes (RGB, HSV, etc)) Represents the first cell used for the color cube.
uInt n1_
 (Valid only for multi-channel color modes (RGB, HSV, etc)) Specifies the color resolution for each side of the color cube.
uInt n2_
uInt n3_
uInt n1Mult_
uInt n2Mult_
uInt n3Mult_
uInt n1Shift_
 (Valid only for multi-channel color modes (RGB, HSV, etc)) and when pow2Mapping is true.
uInt n2Shift_
uInt n3Shift_

Friends

ostream & operator<< (ostream &os, const GLPixelCanvasColorTable &pcc)
 print details of class to ostream

Detailed Description

Definition at line 103 of file GLPixelCanvasColorTable.h.


Member Enumeration Documentation

Enumerator:
FILLRGB 
FILLRBG 
FILLGRB 
FILLGBR 
FILLBRG 
FILLBGR 

Definition at line 135 of file GLPixelCanvasColorTable.h.


Constructor & Destructor Documentation

casa::GLPixelCanvasColorTable::GLPixelCanvasColorTable ( ::XDisplay *  dpy,
Display::ColorModel  mapType = Display::RGB,
Float  percent = 90.0,
XVisualInfo *  visInfo = NULL 
)

Member Function Documentation

allocate cells for colormaps

Allocate the best color cube given the map.

Allocate a color cube of a specific size.

Bool casa::GLPixelCanvasColorTable::allocColorCubeMinMax ( uInt  n1min,
uInt  n2min,
uInt  n3min,
uInt  n1max,
uInt  n2max,
uInt  n3max 
)

Allocate a color cube within the ranges of sizes.

static void casa::GLPixelCanvasColorTable::colorFillRGB ( Vector< Float > &  r,
Vector< Float > &  g,
Vector< Float > &  b,
uInt  nr,
uInt  ng,
uInt  nb,
FILLMODE  mode = FILLRGB 
) [static]
static void casa::GLPixelCanvasColorTable::colorFillRGB ( Vector< Float > &  r,
Vector< Float > &  g,
Vector< Float > &  b,
uInt  ncolors,
FILLMODE  mode = FILLRGB 
) [static]

Return the color model for multichannel color.

Implements casa::PixelCanvasColorTable.

Definition at line 274 of file GLPixelCanvasColorTable.h.

References colorModel_.

Bool casa::GLPixelCanvasColorTable::colorSpaceMap ( Display::ColorModel  ,
const Array< Float > &  chan1in,
const Array< Float > &  chan2in,
const Array< Float > &  chan3in,
Array< Float > &  chan1out,
Array< Float > &  chan2out,
Array< Float > &  chan3out 
) [virtual]

(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]

Implements casa::PixelCanvasColorTable.

Copy color cube info from the mapRef.

deallocate cells for colormaps

Definition at line 276 of file GLPixelCanvasColorTable.h.

References decomposedIndex_.

Return the depth in bits of the colors.

Implements casa::PixelCanvasColorTable.

Return pointer to display that is being used.

Fill a color cube with an HSV spectrum.

Fill a color cube with an RGB spectrum.

static XVisualInfo* casa::GLPixelCanvasColorTable::getVisualInfo ( ::XDisplay *  dpy,
const Display::ColorModel  colormodel 
) [static]

Return a GL capable visual that supports the colormodel or NULL.

uInt casa::GLPixelCanvasColorTable::HSV2Index ( float  h,
float  s,
float  v 
) [private]
void casa::GLPixelCanvasColorTable::HSV2RGB ( const uLong  H,
const uLong  S,
const uLong  V,
uLong R,
uLong G,
uLong B 
) [private]

Convert from integer HSV components to RGB pixel components.

Return True if the table is in HSV mode.

Definition at line 268 of file GLPixelCanvasColorTable.h.

References colorModel_, and casa::Display::HSV.

Return True if the table is in colorIndex mode.

Definition at line 264 of file GLPixelCanvasColorTable.h.

References colorModel_, and casa::Display::Index.

void casa::GLPixelCanvasColorTable::indexToRGB ( const uInt  index,
float &  r,
float &  g,
float &  b 
)

Returns the color values for the index.

(Inverse of installRGBColors()).

Bool casa::GLPixelCanvasColorTable::initVisual ( XVisualInfo *  vi = NULL) [private]
Bool casa::GLPixelCanvasColorTable::installRGBColors ( const Vector< Float > &  r,
const Vector< Float > &  g,
const Vector< Float > &  b,
uInt  offset = 0 
) [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. This only has an effect if the ColorModel is Index. Values are clamped to [0.0,1.0].

Implements casa::PixelCanvasColorTable.

Bool casa::GLPixelCanvasColorTable::isPow2 ( uInt  n,
uInt log2n 
) [private]

Return the log power 2 of n and return True if n is a power of two.

Otherwise return false.

void casa::GLPixelCanvasColorTable::mapToColor ( const Colormap map,
Array< uChar > &  outArray,
const Array< uChar > &  inArray,
Bool  rangeCheck = True 
) const [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: uChar type may not have enough bits to hold the pixel index on some high-end graphics systems

Warning: uShort type may not have enough bits to hold the pixel index on some high-end graphics systems

Implements casa::PixelCanvasColorTable.

void casa::GLPixelCanvasColorTable::mapToColor ( const Colormap map,
Array< uShort > &  outArray,
const Array< uShort > &  inArray,
Bool  rangeCheck = True 
) const [virtual]
void casa::GLPixelCanvasColorTable::mapToColor ( const Colormap map,
Array< uInt > &  outArray,
const Array< uInt > &  inArray,
Bool  rangeCheck = True 
) const [virtual]
void casa::GLPixelCanvasColorTable::mapToColor ( const Colormap map,
Array< uLong > &  outArray,
const Array< uLong > &  inArray,
Bool  rangeCheck = True 
) const [virtual]
void casa::GLPixelCanvasColorTable::mapToColor ( const Colormap map,
Array< uChar > &  inOutArray,
Bool  rangeCheck = True 
) const [virtual]

same as above except the matrix is operated on in place.

Only unsigned values make sense here.

Implements casa::PixelCanvasColorTable.

void casa::GLPixelCanvasColorTable::mapToColor ( const Colormap map,
Array< uShort > &  inOutArray,
Bool  rangeCheck = True 
) const [virtual]
void casa::GLPixelCanvasColorTable::mapToColor ( const Colormap map,
Array< uInt > &  inOutArray,
Bool  rangeCheck = True 
) const [virtual]
void casa::GLPixelCanvasColorTable::mapToColor ( const Colormap map,
Array< uLong > &  inOutArray,
Bool  rangeCheck = True 
) const [virtual]
void casa::GLPixelCanvasColorTable::mapToColor3 ( Array< uLong > &  out,
const Array< Float > &  chan1in,
const Array< Float > &  chan2in,
const Array< Float > &  chan3in 
) [virtual]

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.

void casa::GLPixelCanvasColorTable::mapToColor3 ( Array< uLong > &  out,
const Array< Double > &  chan1in,
const Array< Double > &  chan2in,
const Array< Double > &  chan3in 
) [virtual]
void casa::GLPixelCanvasColorTable::mapToColor3 ( Array< uLong > &  out,
const Array< uShort > &  chan1in,
const Array< uShort > &  chan2in,
const Array< uShort > &  chan3in 
) [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.

void casa::GLPixelCanvasColorTable::mapToColor3 ( Array< uLong > &  out,
const Array< uInt > &  chan1in,
const Array< uInt > &  chan2in,
const Array< uInt > &  chan3in 
) [virtual]
Valid only for multi channel color casa::GLPixelCanvasColorTable::modes ( RGB  ,
HSV  ,
etc   
) [private]

Return the total number of RW colors currently in use.

Implements casa::PixelCanvasColorTable.

virtual void casa::GLPixelCanvasColorTable::nColors ( uInt n1,
uInt n2,
uInt n3 
) const [virtual]

Return the number of colors per component in the map.

Throws an exception if this is not an HSV or RGB ColorTable.

Implements casa::PixelCanvasColorTable.

Return the number of colors that are still unallocated.

Implements casa::PixelCanvasColorTable.

void casa::GLPixelCanvasColorTable::pixelToComponents ( const uLong  pixel,
Float r,
Float g,
Float b 
)

Convert a pixel to color components.

If decomposed index (eg TC), the pixel contains the color information. Otherwise, (eg. PseudoColor), The information is looked up in the virtual colormap.

Return the number of currently unallocated cells that can be allocated RW.

virtual uInt casa::GLPixelCanvasColorTable::QueryHWColorsAvailable ( const Bool  contig) const [virtual]

Definition at line 275 of file GLPixelCanvasColorTable.h.

References readOnly_.

resize the map if allowed.

Returns True if resize was accepted

Implements casa::PixelCanvasColorTable.

Bool casa::GLPixelCanvasColorTable::resize ( uInt  nReds,
uInt  nGreens,
uInt  nBlues 
) [virtual]

Return True if the table is in RGB mode.

Definition at line 266 of file GLPixelCanvasColorTable.h.

References colorModel_, and casa::Display::RGB.

Return True if the colortable can be resized.

Definition at line 271 of file GLPixelCanvasColorTable.h.

References rigid_.

Return pointer to screen that is being used.

void casa::GLPixelCanvasColorTable::setupColorCube ( uLong  n1,
uLong  n2,
uLong  n3,
uLong  n1m,
uLong  n2m,
uLong  n3m 
) [private]

(Multi-Channel)

void casa::GLPixelCanvasColorTable::setupStandardMapping ( const XStandardColormap *  mapInfo) [private]

(Multi-Channel)

virtual Bool casa::GLPixelCanvasColorTable::staticSize ( ) [inline, virtual]

Is the hardware colormap resizeable? ie.

is it write-only?

Reimplemented from casa::PixelCanvasColorTable.

Definition at line 223 of file GLPixelCanvasColorTable.h.

References decomposedIndex_, and readOnly_.

void casa::GLPixelCanvasColorTable::storeColor ( const uInt  index,
const float  r,
const float  g,
const float  b 
)

Store an RGB value at index.

For RGV visuals, only the virtual colormap is updated.

virtual void casa::GLPixelCanvasColorTable::storeHWColor ( const uLong  pindex,
const float  r,
const float  g,
const float  b 
) [private, virtual]

Write an RGB value to hardware colormap at physical index.

(Called by storeColor()).

Bool casa::GLPixelCanvasColorTable::virtualToPhysical ( const unsigned long  vindex,
unsigned long &  pindex 
) const

Convert a virtual index to a physical pixel.

Return pointer to visual that is being used.

XVisualInfo* casa::GLPixelCanvasColorTable::visualInfo ( ) const [inline]

Return pointer to visual info that is being used.

Definition at line 259 of file GLPixelCanvasColorTable.h.

References visualInfo_.

Return XID of X "virtual colormap" being used.


Friends And Related Function Documentation

ostream& operator<< ( ostream &  os,
const GLPixelCanvasColorTable pcc 
) [friend]

print details of class to ostream


Member Data Documentation

(Valid only for multi-channel color modes (RGB, HSV, etc)) Represents the first cell used for the color cube.

baseColor_ is zero for PseudoColor/StaticColor implementations because they use a table.

Definition at line 372 of file GLPixelCanvasColorTable.h.

Definition at line 349 of file GLPixelCanvasColorTable.h.

unsigned short casa::GLPixelCanvasColorTable::blue_max_ [private]

Definition at line 348 of file GLPixelCanvasColorTable.h.

Definition at line 347 of file GLPixelCanvasColorTable.h.

(Valid Always) The colormodel that this GLPixelCanvasColorTable has been configured as.

Definition at line 366 of file GLPixelCanvasColorTable.h.

Referenced by colorModel(), hsvMode(), indexMode(), and rgbMode().

(Valid only when implementation uses a PseudoColor or a StaticColor visual).

Table of color indices available.

Definition at line 325 of file GLPixelCanvasColorTable.h.

True if TrueColor or DirectColor.

Definition at line 339 of file GLPixelCanvasColorTable.h.

Referenced by decomposedIndex(), and staticSize().

(Valid Always) number of bits of depth

Definition at line 320 of file GLPixelCanvasColorTable.h.

A pointer to the XDisplay.

Definition at line 310 of file GLPixelCanvasColorTable.h.

Definition at line 349 of file GLPixelCanvasColorTable.h.

Definition at line 348 of file GLPixelCanvasColorTable.h.

Definition at line 347 of file GLPixelCanvasColorTable.h.

(Valid only for multi-channel color modes (RGB, HSV, etc)) Specifies the color resolution for each side of the color cube.

index = n1Mult_*R + n2Mult_*G + n3Mult_*B for RGB in the range of <[0,n1_-1],[0,n2_-1],[0,n3_-1]>

Definition at line 380 of file GLPixelCanvasColorTable.h.

Definition at line 384 of file GLPixelCanvasColorTable.h.

(Valid only for multi-channel color modes (RGB, HSV, etc)) and when pow2Mapping is true.

index = (R << n1Shift_) | (G << n2Shift_) | (B << n3Shift_) for RGB the range of <[0,n1_-1],[0,n2_-1],[0,n3_-1]>

Definition at line 394 of file GLPixelCanvasColorTable.h.

Definition at line 381 of file GLPixelCanvasColorTable.h.

Definition at line 385 of file GLPixelCanvasColorTable.h.

Definition at line 395 of file GLPixelCanvasColorTable.h.

Definition at line 382 of file GLPixelCanvasColorTable.h.

Definition at line 386 of file GLPixelCanvasColorTable.h.

Definition at line 396 of file GLPixelCanvasColorTable.h.

(Valid Always) number of total colors available for RW.

Definition at line 322 of file GLPixelCanvasColorTable.h.

True if the colormap is read only* Bool casa::GLPixelCanvasColorTable::readOnly_ [private]

Definition at line 337 of file GLPixelCanvasColorTable.h.

Referenced by readOnly(), and staticSize().

Definition at line 349 of file GLPixelCanvasColorTable.h.

unsigned short casa::GLPixelCanvasColorTable::red_max_ [private]

Definition at line 348 of file GLPixelCanvasColorTable.h.

Shift counts, masks, and max values used to build pixels for decomposed index colormaps.

Definition at line 347 of file GLPixelCanvasColorTable.h.

(Valid Always) True if the table may not be resized, such as when a standard XColormap is used.

Generally this is set to True unless the visual is PseudoColor/StaticColor and the color model is Display::Index.

Definition at line 334 of file GLPixelCanvasColorTable.h.

Referenced by rigid().

A pointer the the X Screen.

Definition at line 312 of file GLPixelCanvasColorTable.h.

Valid only for multi channel color then the color cube s sides are powers of casa::GLPixelCanvasColorTable::two [private]

Definition at line 357 of file GLPixelCanvasColorTable.h.

(& HW map if it exists)

Definition at line 328 of file GLPixelCanvasColorTable.h.

Definition at line 326 of file GLPixelCanvasColorTable.h.

A pointer to the X Visual.

Definition at line 314 of file GLPixelCanvasColorTable.h.

Definition at line 315 of file GLPixelCanvasColorTable.h.

Referenced by visualInfo().

A pointer to the XColormap (X Hardware colormap)

Definition at line 317 of file GLPixelCanvasColorTable.h.


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