QGLColormap Class

QGLColormap class is used for installing custom colormaps into a QGLWidget . 更多...

头: #include <QGLColormap>
qmake: QT += opengl

该类已过时。 提供它是为使旧源代码能继续工作。强烈建议不要在新代码中使用它。

公共函数

QGLColormap ()
QGLColormap (const QGLColormap & map )
~QGLColormap ()
QColor entryColor (int idx ) const
QRgb entryRgb (int idx ) const
int find (QRgb color ) const
int findNearest (QRgb color ) const
bool isEmpty () const
void setEntries (int count , const QRgb * colors , int base = 0)
void setEntry (int idx , QRgb color )
void setEntry (int idx , const QColor & color )
int size () const
QGLColormap & operator= (const QGLColormap & map )

详细描述

QGLColormap class is used for installing custom colormaps into a QGLWidget .

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.

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 隐式共享 as a memory and speed optimization.

用法范例:

#include <QApplication>
#include <QGLColormap>
int main()
{
    QApplication app(argc, argv);
    MySuperGLWidget widget;     // a QGLWidget in color-index mode
    QGLColormap colormap;
    // This will fill the colormap with colors ranging from
    // black to white.
    for (int i = 0; i < colormap.size(); i++)
        colormap.setEntry(i, qRgb(i, i, i));
    widget.setColormap(colormap);
    widget.show();
    return app.exec();
}
					

另请参阅 QGLWidget::setColormap () 和 QGLWidget::colormap ().

成员函数文档编制

QGLColormap:: QGLColormap ()

构造 QGLColormap .

QGLColormap:: QGLColormap (const QGLColormap & map )

Construct a shallow copy of map .

QGLColormap:: ~QGLColormap ()

解引用 QGLColormap and deletes it if this was the last reference to it.

QColor QGLColormap:: entryColor ( int idx ) const

返回 QRgb value in the colorcell with index idx .

QRgb QGLColormap:: entryRgb ( int idx ) const

返回 QRgb value in the colorcell with index idx .

int QGLColormap:: find ( QRgb color ) const

Returns the index of the color color 。若 color is not in the map, -1 is returned.

int QGLColormap:: findNearest ( QRgb color ) const

Returns the index of the color that is the closest match to color color .

bool QGLColormap:: isEmpty () const

返回 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.

比较 size () with zero to determine if the colormap is empty regardless of whether it is in use by a QGLWidget or not.

另请参阅 size ().

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.

void QGLColormap:: setEntry ( int idx , QRgb color )

Set cell at index idx in the colormap to color color .

void QGLColormap:: setEntry ( int idx , const QColor & color )

这是重载函数。

Set the cell with index idx in the colormap to color color .

int QGLColormap:: size () const

Returns the number of colorcells in the colormap.

QGLColormap &QGLColormap:: operator= (const QGLColormap & map )

Assign a shallow copy of map 到此 QGLColormap .