Qt 4.8
qglcolormap.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtOpenGL module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QGLCOLORMAP_H
43 #define QGLCOLORMAP_H
44 
45 #include <QtGui/qcolor.h>
46 #include <QtCore/qvector.h>
47 
49 
51 
53 
55 {
56 public:
57  QGLColormap();
58  QGLColormap(const QGLColormap &);
59  ~QGLColormap();
60 
61  QGLColormap &operator=(const QGLColormap &);
62 
63  bool isEmpty() const;
64  int size() const;
65  void detach();
66 
67  void setEntries(int count, const QRgb * colors, int base = 0);
68  void setEntry(int idx, QRgb color);
69  void setEntry(int idx, const QColor & color);
70  QRgb entryRgb(int idx) const;
71  QColor entryColor(int idx) const;
72  int find(QRgb color) const;
73  int findNearest(QRgb color) const;
74 
75 protected:
76  Qt::HANDLE handle() { return d ? d->cmapHandle : 0; }
77  void setHandle(Qt::HANDLE ahandle) { d->cmapHandle = ahandle; }
78 
79 private:
80  struct QGLColormapData {
84  };
85 
87  static struct QGLColormapData shared_null;
88  static void cleanup(QGLColormapData *x);
89  void detach_helper();
90 
91  friend class QGLWidget;
92  friend class QGLWidgetPrivate;
93 };
94 
95 inline void QGLColormap::detach()
96 {
97  if (d->ref != 1)
98  detach_helper();
99 }
100 
102 
104 
105 #endif // QGLCOLORMAP_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
QVector< QRgb > * cells
Definition: qglcolormap.h:82
unsigned int QRgb
Definition: qrgb.h:53
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_OPENGL_EXPORT
Definition: qglobal.h:1455
static const uint base
Definition: qurl.cpp:268
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QGLColormapData * d
Definition: qglcolormap.h:86
static bool isEmpty(const char *str)
void detach()
Detaches this QGLColormap from the shared block.
Definition: qglcolormap.h:95
void * HANDLE
Definition: qnamespace.h:1671
The QGLColormap class is used for installing custom colormaps into a QGLWidget.
Definition: qglcolormap.h:54
The QGLWidget class is a widget for rendering OpenGL graphics.
Definition: qgl.h:474
static void cleanup()
Definition: qpicture.cpp:1508
Qt::HANDLE handle()
Returns the handle for this color map.
Definition: qglcolormap.h:76
void setHandle(Qt::HANDLE ahandle)
Sets the handle for this color map to handle.
Definition: qglcolormap.h:77
#define class
#define QT_END_HEADER
Definition: qglobal.h:137