kalzium
color.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef COLOR_H
00027 #define COLOR_H
00028
00029 #include <avogadro/global.h>
00030
00031 #include <QGLWidget>
00032 #include <QColor>
00033
00034 namespace Avogadro {
00035
00036 class Primitive;
00037 class ColorPrivate;
00038
00047 class A_EXPORT Color
00048 {
00049 public:
00050 Color();
00051 virtual ~Color();
00052
00058 Color( GLfloat red, GLfloat green, GLfloat blue,
00059 GLfloat alpha = 1.0 );
00060
00066 Color( const Primitive * );
00067
00072 Color& operator= (const QColor &);
00073
00079 virtual void set(GLfloat red, GLfloat green, GLfloat blue,
00080 GLfloat alpha = 1.0 );
00081
00086 virtual void setToSelectionColor();
00087
00093 virtual void set(const Primitive *);
00094
00099 virtual void setAlpha(double alpha);
00100
00105 inline virtual void apply()
00106 {
00107 glColor4fv( &m_red );
00108 }
00109
00115 virtual void applyAsMaterials();
00116
00120 virtual void applyAsFlatMaterials();
00121
00125 inline QColor color() { return QColor(static_cast<int>(m_red),
00126 static_cast<int>(m_blue),
00127 static_cast<int>(m_green),
00128 static_cast<int>(m_alpha)); }
00129
00133 inline float red() { return m_red; }
00137 inline float green() { return m_green; }
00141 inline float blue() { return m_blue; }
00145 inline float alpha() { return m_alpha; }
00146
00150 virtual void setName(const QString& name);
00154 virtual QString name() const;
00158 virtual QString type() const { return "Virtual Base Class"; }
00159
00163 virtual QWidget *settingsWidget() { return NULL; }
00164
00165 protected:
00182 GLfloat m_red, m_green, m_blue, m_alpha;
00183
00187 QString m_name;
00188
00192 ColorPrivate *d;
00193 };
00194
00195 }
00196
00197 #endif