Qt Jambi Home

com.trolltech.qt.opengl
Class QGLColormap

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.opengl.QGLColormap
All Implemented Interfaces:
QtJambiInterface

public class QGLColormap
extends QtJambiObject

The QGLColormap class is used for installing custom colormaps into QGLWidgets.

QGLColormap provides a platform independent way of specifying and installing indexed colormaps into QGLWidgets. 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.

Under Windows 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:

    #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();
    }

See Also:
QGLWidget::setColormap, QGLWidget::colormap

Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Constructor Summary
QGLColormap()
          Construct a QGLColormap.
QGLColormap(QGLColormap arg__1)
          Construct a shallow copy of arg__1.
 
Method Summary
 QColor entryColor(int idx)
          Returns the QRgb value in the colorcell with index idx.
 int entryRgb(int idx)
          Returns the QRgb value in the colorcell with index idx.
 int find(int color)
          Returns the index of the color color.
 int findNearest(int color)
          Returns the index of the color that is the closest match to color color.
static QGLColormap fromNativePointer(QNativePointer nativePointer)
          This function returns the QGLColormap instance pointed to by nativePointer
protected  long handle()
          
 boolean isEmpty()
          Returns true if the colormap is empty; otherwise returns false.
static QNativePointer nativePointerArray(QGLColormap[] array)
          This function returns a QNativePointer that is pointing to the specified QGLColormap array.
 void setEntries(int[] colors)
          This is an overloaded method provided for convenience.
 void setEntries(int[] colors, int base)
          Sets an array of cells in this color map, where colors is the array of colors, and base is the starting index.
 void setEntry(int idx, int color)
          Set cell at index idx in the colormap to color color.
 void setEntry(int idx, QColor color)
          Set the cell with index idx in the colormap to color color.
protected  void setHandle(long ahandle)
          
 int size()
          Returns the number of colorcells in the colormap.
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QGLColormap

public QGLColormap()

Construct a QGLColormap.


QGLColormap

public QGLColormap(QGLColormap arg__1)

Construct a shallow copy of arg__1.

Method Detail

entryColor

public final QColor entryColor(int idx)

Returns the QRgb value in the colorcell with index idx.


entryRgb

public final int entryRgb(int idx)

Returns the QRgb value in the colorcell with index idx.


find

public final int find(int color)

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


findNearest

public final int findNearest(int color)

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


handle

protected final long handle()

See Also:
setHandle

isEmpty

public final boolean isEmpty()

Returns true if the colormap is empty; otherwise returns false. A colormap with no color values set is considered to be empty.


setEntry

public final void setEntry(int idx,
                           QColor color)

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


setEntry

public final void setEntry(int idx,
                           int color)

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


setHandle

protected final void setHandle(long ahandle)

See Also:
handle

size

public final int size()

Returns the number of colorcells in the colormap.


fromNativePointer

public static QGLColormap fromNativePointer(QNativePointer nativePointer)
This function returns the QGLColormap instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

nativePointerArray

public static QNativePointer nativePointerArray(QGLColormap[] array)
This function returns a QNativePointer that is pointing to the specified QGLColormap array.

Parameters:
array - the array that the returned pointer will point to.
Returns:
a QNativePointer that is pointing to the specified array.

setEntries

public final void setEntries(int[] colors,
                             int base)
Sets an array of cells in this color map, where colors is the array of colors, and base is the starting index.


setEntries

public final void setEntries(int[] colors)
This is an overloaded method provided for convenience.


Qt Jambi Home