Qt 4.8
|
The QGLColormap class is used for installing custom colormaps into a QGLWidget. More...
#include <qglcolormap.h>
Classes | |
struct | QGLColormapData |
Public Functions | |
void | detach () |
Detaches this QGLColormap from the shared block. More... | |
QColor | entryColor (int idx) const |
Returns the QRgb value in the colorcell with index idx. More... | |
QRgb | entryRgb (int idx) const |
Returns the QRgb value in the colorcell with index idx. More... | |
int | find (QRgb color) const |
Returns the index of the color color. More... | |
int | findNearest (QRgb color) const |
Returns the index of the color that is the closest match to color color. More... | |
bool | isEmpty () const |
Returns true if the colormap is empty or it is not in use by a QGLWidget; otherwise returns false. More... | |
QGLColormap & | operator= (const QGLColormap &) |
Assign a shallow copy of map to this QGLColormap. More... | |
QGLColormap () | |
Construct a QGLColormap. More... | |
QGLColormap (const QGLColormap &) | |
Construct a shallow copy of map. More... | |
void | setEntries (int count, const QRgb *colors, int base=0) |
Set an array of cells in this colormap. More... | |
void | setEntry (int idx, QRgb color) |
Set cell at index idx in the colormap to color color. More... | |
void | setEntry (int idx, const QColor &color) |
Set the cell with index idx in the colormap to color color. More... | |
int | size () const |
Returns the number of colorcells in the colormap. More... | |
~QGLColormap () | |
Dereferences the QGLColormap and deletes it if this was the last reference to it. More... | |
Protected Functions | |
Qt::HANDLE | handle () |
Returns the handle for this color map. More... | |
void | setHandle (Qt::HANDLE ahandle) |
Sets the handle for this color map to handle. More... | |
Private Functions | |
void | detach_helper () |
Static Private Functions | |
static void | cleanup (QGLColormapData *x) |
Properties | |
QGLColormapData * | d |
Static Private Attributes | |
static struct QGLColormapData | shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0 } |
Friends | |
class | QGLWidget |
class | QGLWidgetPrivate |
The QGLColormap class is used for installing custom colormaps into a QGLWidget.
OpenGL
QGLColormap provides a platform independent way of specifying and installing indexed colormaps for a QGLWidget. QGLColormap is especially useful when using the OpenGL color-index mode.
Under X11 you must use an X server that supports either a PseudoColor
or DirectColor
visual class. If your X server currently only provides a GrayScale
, TrueColor
, StaticColor
or StaticGray
visual, you will not be able to allocate colorcells for writing. If this is the case, try setting your X server to 8 bit mode. It should then provide you with at least a PseudoColor
visual. Note that you may experience colormap flashing if your X server is running in 8 bit mode.
The size() of the colormap is always set to 256 colors. Note that under Windows you can also install colormaps in child widgets.
This class uses implicit sharing as a memory and speed optimization.
Example of use:
Definition at line 54 of file qglcolormap.h.
QGLColormap::QGLColormap | ( | ) |
QGLColormap::QGLColormap | ( | const QGLColormap & | map | ) |
QGLColormap::~QGLColormap | ( | ) |
Dereferences the QGLColormap and deletes it if this was the last reference to it.
Definition at line 131 of file qglcolormap.cpp.
|
staticprivate |
Definition at line 137 of file qglcolormap.cpp.
Referenced by detach_helper(), operator=(), and ~QGLColormap().
|
inline |
Detaches this QGLColormap from the shared block.
Definition at line 95 of file qglcolormap.h.
Referenced by setEntries(), and setEntry().
|
private |
Definition at line 166 of file qglcolormap.cpp.
QColor QGLColormap::entryColor | ( | int | idx | ) | const |
Returns the QRgb value in the colorcell with index idx.
Definition at line 237 of file qglcolormap.cpp.
QRgb QGLColormap::entryRgb | ( | int | idx | ) | const |
Returns the QRgb value in the colorcell with index idx.
Definition at line 213 of file qglcolormap.cpp.
Referenced by qStoreColors().
int QGLColormap::find | ( | QRgb | color | ) | const |
Returns the index of the color color.
If color is not in the map, -1 is returned.
Definition at line 276 of file qglcolormap.cpp.
Referenced by findNearest().
int QGLColormap::findNearest | ( | QRgb | color | ) | const |
Returns the index of the color that is the closest match to color color.
Definition at line 287 of file qglcolormap.cpp.
|
inlineprotected |
Returns the handle for this color map.
Definition at line 76 of file qglcolormap.h.
bool QGLColormap::isEmpty | ( | ) | const |
Returns true if the colormap is empty or it is not in use by a QGLWidget; otherwise returns false.
A colormap with no color values set is considered to be empty. For historical reasons, a colormap that has color values set but which is not in use by a QGLWidget is also considered empty.
Compare size() with zero to determine if the colormap is empty regardless of whether it is in use by a QGLWidget or not.
Definition at line 258 of file qglcolormap.cpp.
QGLColormap & QGLColormap::operator= | ( | const QGLColormap & | map | ) |
void QGLColormap::setEntries | ( | int | count, |
const QRgb * | colors, | ||
int | base = 0 |
||
) |
Set an array of cells in this colormap.
count is the number of colors that should be set, colors is the array of colors, and base is the starting index. The first element in colors is set at base in the colormap.
Definition at line 198 of file qglcolormap.cpp.
Referenced by QGLContextPrivate::updateFormatVersion().
void QGLColormap::setEntry | ( | int | idx, |
QRgb | color | ||
) |
Set cell at index idx in the colormap to color color.
Definition at line 184 of file qglcolormap.cpp.
Referenced by setEntries(), and setEntry().
void QGLColormap::setEntry | ( | int | idx, |
const QColor & | color | ||
) |
Set the cell with index idx in the colormap to color color.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 229 of file qglcolormap.cpp.
|
inlineprotected |
Sets the handle for this color map to handle.
Definition at line 77 of file qglcolormap.h.
int QGLColormap::size | ( | ) | const |
Returns the number of colorcells in the colormap.
Definition at line 267 of file qglcolormap.cpp.
Referenced by findNearest(), qStoreColors(), and QGLWidgetPrivate::updateColormap().
Definition at line 91 of file qglcolormap.h.
|
friend |
Definition at line 92 of file qglcolormap.h.
|
private |
Definition at line 86 of file qglcolormap.h.
Referenced by detach_helper(), entryColor(), entryRgb(), find(), findNearest(), isEmpty(), operator=(), QGLColormap(), setEntries(), setEntry(), size(), and ~QGLColormap().
|
staticprivate |
Definition at line 87 of file qglcolormap.h.
Referenced by entryColor(), entryRgb(), and isEmpty().