Developer Documentation

QtColorTranslator.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42
43
44
45
46 //=============================================================================
47 //
48 // CLASS QtColorTranslator
49 //
50 //=============================================================================
51
52
53 #ifndef ACG_QTCOLORTRANSLATOR_HH
54 #define ACG_QTCOLORTRANSLATOR_HH
55
56
57 //== INCLUDES =================================================================
58
59 #include <QGLContext>
60
61 #include "../Config/ACGDefines.hh"
62
63 //== NAMESPACES ===============================================================
64
65 namespace ACG {
66
67
68 //== CLASS DEFINITION =========================================================
69
70
80 class ACGDLLEXPORT QtColorTranslator
81 {
82 public:
83
85 QtColorTranslator() : initialized_(false),
86 redBits_(0), greenBits_(0), blueBits_(0),
87 redMask_(0), greenMask_(0), blueMask_(0),
88 redShift_(0), greenShift_(0), blueShift_(0),
89 redRound_(0), greenRound_(0), blueRound_(0)
90 {};
91
93 explicit QtColorTranslator(QGLContext& _context)
94 { initialize(_context); }
95
97 ~QtColorTranslator(){};
98
99
101 void initialize();
102
104 void initialize(QGLContext& _context)
105 { _context.makeCurrent(); initialize(); }
106
108 bool initialized() const { return initialized_; }
109
110
112 bool index2color( unsigned int _idx, QRgb& _col ) const;
114 bool index2color( unsigned int _idx,
115 QRgb& _frontColor,
116 QRgb& _backColor ) const;
117
118
120 int color2index( QRgb _c ) const;
122 int color2index( QRgb _frontColor, QRgb _backColor ) const;
123
124
126 unsigned int maxIndex() const;
127
128
129 private:
130
131 bool initialized_;
132 GLint redBits_, greenBits_, blueBits_;
133 GLuint redMask_, greenMask_, blueMask_,
134 redShift_, greenShift_, blueShift_,
135 redRound_, greenRound_, blueRound_;
136 };
137
138
139 //=============================================================================
140 } // namespace ACG
141 //=============================================================================
142 #endif // ACG_QTCOLORTRANSLATOR_HH defined
143 //=============================================================================
144
ACG
Namespace providing different geometric functions concerning angles.
Definition: BaseObjectData.hh:68
ACG::QtColorTranslator::initialized
bool initialized() const
has it been initialized?
Definition: QtColorTranslator.hh:108
ACG::QtColorTranslator::QtColorTranslator
QtColorTranslator(QGLContext &_context)
construct with QGLcontext
Definition: QtColorTranslator.hh:93
ACG::QtColorTranslator::initialize
void initialize(QGLContext &_context)
init with given QGLcontext
Definition: QtColorTranslator.hh:104
ACG::QtColorTranslator::~QtColorTranslator
~QtColorTranslator()
Destructor.
Definition: QtColorTranslator.hh:97
ACG::QtColorTranslator
Definition: QtColorTranslator.hh:80
ACG::QtColorTranslator::QtColorTranslator
QtColorTranslator()
Default constructor.
Definition: QtColorTranslator.hh:85