Avogadro  1.1.0
Signals | Public Member Functions | Protected Attributes
Avogadro::Color Class Reference

Map a primitive (atom, bond, etc.) to a OpenGL red, green, blue, alpha color. More...

#include <avogadro/color.h>

Inheritance diagram for Avogadro::Color:
Inheritance graph
[legend]

List of all members.

Signals

void changed ()

Public Member Functions

 Color (float red, float green, float blue, float alpha=1.0)
 Color (const Primitive *p)
virtual void apply ()
virtual void applyAsMaterials ()
virtual void applyAsFlatMaterials ()
QColor color () const
float red () const
float green () const
float blue () const
float alpha () const
virtual void setName (const QString &name)
virtual QString name () const
virtual QString identifier () const
virtual Plugin::Type type () const
Set Color Methods

These methods assign a color based on a primitive, index value (int), or gradient (float/double). They are the main use of color plugins.

virtual void setFromPrimitive (const Primitive *p)
virtual void setFromIndex (const unsigned int index)
virtual void setFromGradient (const double value, const double lo, const double mid, const double hi)
Explicit Color Methods

These methods assign a color based on explicit assignment.

virtual void setFromRgba (float red, float green, float blue, float alpha=1.0)
virtual void setFromQColor (const QColor &color)
virtual void setToSelectionColor ()
virtual void setAlpha (double alpha)

Protected Attributes

float m_channels [4]
QString m_name
ColorPrivate * d

Detailed Description

Map a primitive (atom, bond, etc.) to a OpenGL red, green, blue, alpha color.

Author:
Benoit Jacob
Geoff Hutchison

Color plugins are used to provide custom coloring for engines -- mapping atoms and residues. Provide new plugins based on atomic or residue properties


Constructor & Destructor Documentation

Avogadro::Color::Color ( float  red,
float  green,
float  blue,
float  alpha = 1.0 
)

This constructor sets the four components of the color individually. Each one ranges from 0.0 (lowest intensity) to 1.0 (highest intensity). For the alpha component, 0.0 means totally transparent and 1.0 (the default) means totally opaque.

Parameters:
redThe red component of the color
greenThe green component
blueThe blue component
alphaThe opacity of the color
See also:
set()

References alpha(), blue(), green(), m_channels, and red().

Avogadro::Color::Color ( const Primitive p)

Set the color based on the supplied Primitive. If NULL is passed do nothing.

Parameters:
pthe color is derived from this primitive.

References setFromPrimitive().


Member Function Documentation

float Avogadro::Color::alpha ( ) const [inline]
Returns:
the alpha component of the color.

Referenced by Color(), setAlpha(), Avogadro::GLPainter::setColor(), and setFromRgba().

void Avogadro::Color::apply ( ) [virtual]

Sets this color to be the one used by OpenGL for rendering when lighting is disabled.

References m_channels.

Applies an OpenGL material more appropriate for flat surfaces.

References m_channels.

Applies nice OpenGL materials using this color as the diffuse color while using different shades for the ambient and specular colors. This is only useful if lighting is enabled.

References m_channels.

float Avogadro::Color::blue ( ) const [inline]
Returns:
the blue component of the color.

Referenced by Color(), Avogadro::GLPainter::setColor(), and setFromRgba().

void Avogadro::Color::changed ( ) [signal]

Signals that something has been changed and the engine needs to render after these changes were made.

QColor Avogadro::Color::color ( ) const [inline]
Returns:
the color as a QColor.

References QColor::setRgbF().

float Avogadro::Color::green ( ) const [inline]
Returns:
the green component of the color.

Referenced by Color(), Avogadro::GLPainter::setColor(), and setFromRgba().

QString Avogadro::Color::identifier ( ) const [virtual]
Returns:
the untranslated identifier of this color plugin

Implements Avogadro::Plugin.

QString Avogadro::Color::name ( ) const [virtual]
Returns:
the translated name of this instance of the class.

Implements Avogadro::Plugin.

References QString::isEmpty(), and m_name.

Referenced by setName().

float Avogadro::Color::red ( ) const [inline]
Returns:
the red component of the color.

Referenced by Color(), Avogadro::GLPainter::setColor(), and setFromRgba().

void Avogadro::Color::setAlpha ( double  alpha) [virtual]

Set the alpha component of the color, 0.0 means totally transparent and 1.0 means totally opaque.

Parameters:
alphaThe opacity of the color

References alpha(), and m_channels.

void Avogadro::Color::setFromGradient ( const double  value,
const double  lo,
const double  mid,
const double  hi 
) [virtual]

Set the color based on the supplied floating point value (e.g., a gradient).

Parameters:
valuethe floating point number to consider
lothe low point of the range
midthe middle point of the range (e.g., 0.0)
hithe high point of the range
void Avogadro::Color::setFromIndex ( const unsigned int  index) [virtual]

Set the color based on the supplied index (e.g., in an indexed color table).

Parameters:
indexthe color is derived from this value
void Avogadro::Color::setFromPrimitive ( const Primitive p) [virtual]

Set the color based on the supplied Primitive. If NULL is passed do nothing.

Parameters:
pthe color is derived from this primitive.

Referenced by Color().

void Avogadro::Color::setFromQColor ( const QColor color) [virtual]

Set the color explicitly based on a QColor, copying RGB and Alpha levels.

Parameters:
colorThe explicit color to use.

References QColor::alphaF(), QColor::blueF(), QColor::greenF(), m_channels, and QColor::redF().

void Avogadro::Color::setFromRgba ( float  red,
float  green,
float  blue,
float  alpha = 1.0 
) [virtual]

Set the four components of the color individually. Each one ranges from 0.0 (lowest intensity) to 1.0 (highest intensity). For the alpha component, 0.0 means totally transparent and 1.0 (the default) means totally opaque.

Parameters:
redThe red component of the color
greenThe green component
blueThe blue component
alphaThe opacity of the color

References alpha(), blue(), green(), m_channels, and red().

void Avogadro::Color::setName ( const QString name) [virtual]

Set the name of this instance of the class.

References m_name, and name().

Set the color to the selection color. By default, the selection color is (0.3, 0.6, 1.0, 0.7). which is a light transparent blue

References m_channels.

virtual Plugin::Type Avogadro::Color::type ( ) const [inline, virtual]
Returns:
the type of the Color class.

Implements Avogadro::Plugin.


Member Data Documentation

ColorPrivate* Avogadro::Color::d [protected]

The d-pointer used to preserve binary compatibility.

The components of the color ranging from 0 to 1.

Referenced by apply(), applyAsFlatMaterials(), applyAsMaterials(), Color(), setAlpha(), setFromQColor(), setFromRgba(), and setToSelectionColor().

The name of the class instance.

Referenced by name(), and setName().


The documentation for this class was generated from the following files: