BALL::VIEW::ColorRGBA Class Reference
[Different color classes]

ColorRGBA class. More...

#include <colorRGBA.h>

List of all members.


Public Member Functions

Constructors
ColorRGBA ()
Default Constructor.
ColorRGBA (const ColorRGBA &color)
Copy constructor.
ColorRGBA (const ColorHSV &color)
Constructor with ColorHSV.
ColorRGBA (const char *value) throw (Exception::InvalidRange, ColorUnit::NotInHexFormat)
Constructor with Parameter char*.
ColorRGBA (const String &value) throw (Exception::InvalidRange, ColorUnit::NotInHexFormat)
Constructor with Parameter string.
ColorRGBA (const ColorUnit &red_value, const ColorUnit &green_value, const ColorUnit &blue_value, const ColorUnit &alpha_value=(float) 1)
Detailed component initializing constructor.
ColorRGBA (const QColor &color, const ColorUnit &alpha=(float) 1)
Assignment from a QT QColor.
Destructors
~ColorRGBA ()
Destructor.
void clear ()
Explicit default initialization.
Converters
operator String () const
Conversion to string.
Assignment methods
void set (const ColorRGBA &color)
Assignment.
const ColorRGBA & operator= (const ColorRGBA &color)
Assignment operator.
void set (const ColorHSV &color)
Assignment with ColorHSV.
const ColorRGBA & operator= (const ColorHSV &color)
Assignment operator with ColorHSV.
void get (ColorHSV &color) const
Copying to ColorHSV.
void set (const char *value) throw (Exception::InvalidRange, ColorUnit::NotInHexFormat)
Assignment with char*.
const ColorRGBA & operator= (const char *value) throw (Exception::InvalidRange, ColorUnit::NotInHexFormat)
Assignment operator with char*.
void get (char *value) const
Copying to char*.
void set (const String &value) throw (Exception::InvalidRange, ColorUnit::NotInHexFormat)
Assign the color represented by a String.
const ColorRGBA & operator= (const String &value) throw (Exception::InvalidRange, ColorUnit::NotInHexFormat)
Assign the color represented by the string value to this colorRGBA.
void get (String &value) const
Copying to string.
void get (QColor &color) const
Assign to a QT QColor.
bool set (const QColor &color)
Assign from a QT QColor.
QColor getQColor () const
Get a QColor representing this color.
void swap (ColorRGBA &color)
Swapping of colorRGBAs.
Accessors: inspectors and mutators
void setRed (const ColorUnit &red_value)
Changes the value of the red component.
ColorUnit & getRed ()
Mutable inspection of the red component.
const ColorUnit & getRed () const
Non-mutable inspection of the red component.
void setGreen (const ColorUnit &green_value)
Changes the value of the green component.
ColorUnit & getGreen ()
Mutable inspection of the green component.
const ColorUnit & getGreen () const
Non-mutable inspection of the green component.
void setBlue (const ColorUnit &blue_value)
Changes the value of the blue component.
ColorUnit & getBlue ()
Mutable inspection of the blue component.
const ColorUnit & getBlue () const
Non-mutable inspection of the blue component.
void setAlpha (const ColorUnit &alpha_value)
Changes the value of the alpha component.
ColorUnit & getAlpha ()
Mutable inspection of the alpha component.
const ColorUnit & getAlpha () const
Non-mutable inspection of the alpha component.
void set (const ColorUnit &red_value, const ColorUnit &green_value, const ColorUnit &blue_value, const ColorUnit &alpha_value=(float) 1)
Changes the values of the red, green, blue and alpha component.
void get (ColorUnit &red_value, ColorUnit &green_value, ColorUnit &blue_value, ColorUnit &alpha_value) const
Inspection of the colorRGBA's components.
void get (ColorUnit &red_value, ColorUnit &green_value, ColorUnit &blue_value) const
Inspection of the colorRGBA's components.
ColorRGBA getInverseColor () const
Predicates
bool operator== (const ColorRGBA &color) const
Equality test.
bool operator!= (const ColorRGBA &color) const
Unequality test.
bool operator< (const ColorRGBA &color) const
Smaller test.
bool operator<= (const ColorRGBA &color) const
Smaller or equal test.
bool operator> (const ColorRGBA &color) const
Greater test.
bool operator>= (const ColorRGBA &color) const
Greater or equal test.
debuggers and diagnostics
void dump (std::ostream &s=std::cout, Size depth=0) const
Internal value dump.

Friends

Class friends


class ColorHSV
Storers
std::istream & operator>> (std::istream &s, ColorRGBA &color)
Friendly stream input.
std::ostream & operator<< (std::ostream &s, const ColorRGBA &color)
Friendly stream output.

Detailed Description

ColorRGBA class.

An instance of ColorRGBA represents a color consisting of the components red, green, blue and alpha. The components are ColorUnit 's, which allow many types of input parameters. See description of this class for further informations.


Constructor & Destructor Documentation

BALL::VIEW::ColorRGBA::ColorRGBA ( )

Default Constructor.

Initialized with color black (red=0, green=0, blue=0, alpha=1).

BALL::VIEW::ColorRGBA::ColorRGBA ( const ColorHSV & color )

Constructor with ColorHSV.

See also:
ColorHSV

BALL::VIEW::ColorRGBA::ColorRGBA ( const char * value ) throw (Exception::InvalidRange, ColorUnit::NotInHexFormat)

Constructor with Parameter char*.

Constructs new colorRGBA by initialising its value with the given pointer to a string representing a color value in hex format. The length of the string can either be 6 or 8 characters depending whether the alpha component should be considered. If the string is only 6 characters long the alpha component will be set to 1.0.

Parameters:
value the pointer to a string representing a color
Exceptions:
InvalidRange if string length != 6 && string length != 8
NotInHexFormat if the string is not a valid hex format string
Returns:
ColorRGBA new constructed colorRGBA

BALL::VIEW::ColorRGBA::ColorRGBA ( const String & value ) throw (Exception::InvalidRange, ColorUnit::NotInHexFormat)

Constructor with Parameter string.

Same as constructor with parameter char*.

Parameters:
value a string representing a color
Exceptions:
InvalidRange if string length != 6 && string length != 8
NotInHexFormat if the string is not a valid hex format string
Returns:
ColorRGBA new constructed colorRGBA

BALL::VIEW::ColorRGBA::ColorRGBA ( const ColorUnit & red_value,
const ColorUnit & green_value,
const ColorUnit & blue_value,
const ColorUnit & alpha_value = (float) 1
)

Detailed component initializing constructor.

Parameters:
red_value the red component.
green_value the green component.
blue_value the blue component.
alpha_value the alpha component. Default value 1.0
See also:
ColorUnit

Member Function Documentation

void BALL::VIEW::ColorRGBA::clear ( )

Explicit default initialization.

Sets the color of this colorRGBA to the default color (black). The value of this colorRGBA is:

  • red component is zero (0)
  • green component is zero (0)
  • blue component is zero (0)
  • alpha component is 1 (1.0)

void BALL::VIEW::ColorRGBA::dump ( std::ostream & s = std::cout,
Size depth = 0
) const

Internal value dump.

Dumps the current color of this colorRGBA to the output ostream s with dumping depth depth.

Parameters:
s output stream where to output the color of this colorRGBA
depth the dumping depth
See also:
ColorUnit::dump

void BALL::VIEW::ColorRGBA::get ( ColorUnit & red_value,
ColorUnit & green_value,
ColorUnit & blue_value
) const

Inspection of the colorRGBA's components.

Accesses only the red, green and blue components of this colorRGBA by using ColorUnit's.

Parameters:
red_value the colorUnit receiving the red component of this colorRGBA
green_value the colorUnit receiving the green component of this colorRGBA
blue_value the colorUnit receiving the blue component of this colorRGBA
See also:
set

ColorUnit

void BALL::VIEW::ColorRGBA::get ( ColorUnit & red_value,
ColorUnit & green_value,
ColorUnit & blue_value,
ColorUnit & alpha_value
) const

Inspection of the colorRGBA's components.

Accesses all the components of this colorRGBA by using ColorUnit's.

Parameters:
red_value the colorUnit receiving the red component of this colorRGBA
green_value the colorUnit receiving the green component of this colorRGBA
blue_value the colorUnit receiving the blue component of this colorRGBA
alpha_value the colorUnit receiving the alpha component of this colorRGBA
See also:
set

ColorUnit

void BALL::VIEW::ColorRGBA::get ( String & value ) const

Copying to string.

Calls set. The format of the string is the same as the one given to the constructor.

Parameters:
value the string receiving the color in hex format
See also:
set

void BALL::VIEW::ColorRGBA::get ( char * value ) const

Copying to char*.

Copies the color to the string represented by a pointer. Calls set. At least 9 bytes must be allocated for the string. The format of the string is the same as the one given to the constructor.

Parameters:
value the pointer to string (at least 9 bytes long)
See also:
set

const ColorUnit& BALL::VIEW::ColorRGBA::getAlpha ( ) const

Non-mutable inspection of the alpha component.

For further information see ColorUnit& getAlpha().

ColorUnit& BALL::VIEW::ColorRGBA::getAlpha ( )

Mutable inspection of the alpha component.

Returns:
ColorUnit& mutable reference to the alpha component of this colorRGBA
See also:
setAlpha

const ColorUnit& BALL::VIEW::ColorRGBA::getBlue ( ) const

Non-mutable inspection of the blue component.

For further information see ColorUnit& getBlue()

ColorUnit& BALL::VIEW::ColorRGBA::getBlue ( )

Mutable inspection of the blue component.

See also:
setBlue

const ColorUnit& BALL::VIEW::ColorRGBA::getGreen ( ) const

Non-mutable inspection of the green component.

For further information see ColorUnit& getGreen().

ColorUnit& BALL::VIEW::ColorRGBA::getGreen ( )

Mutable inspection of the green component.

Returns:
ColorUnit& mutable reference to the green component of this colorRGBA
See also:
setGreen

ColorUnit& BALL::VIEW::ColorRGBA::getRed ( )

Mutable inspection of the red component.

Returns:
ColorUnit& mutable reference to the red component of this colorRGBA
See also:
setRed

BALL::VIEW::ColorRGBA::operator String ( ) const

Conversion to string.

This operator casts an instance of colorRGBA to the string type.

Returns:
a string with hex format "00000000"-"FFFFFFFF". The string has the same format as the one given to the constructor.
See also:
ColorRGBA::ColorRGBA

bool BALL::VIEW::ColorRGBA::operator< ( const ColorRGBA & color ) const

Smaller test.

Smaller means that all components of this are smaller than all the components of color colorRGBA.

bool BALL::VIEW::ColorRGBA::operator<= ( const ColorRGBA & color ) const

Smaller or equal test.

Smaller or equal means that all components of this are smaller or equal than all the components of color colorRGBA.

const ColorRGBA& BALL::VIEW::ColorRGBA::operator= ( const String & value ) throw (Exception::InvalidRange, ColorUnit::NotInHexFormat)

Assign the color represented by the string value to this colorRGBA.

Calls set. The color of this is initialized to the color represented by the string value. See constructor for format description.

Parameters:
value the color represented by a string
Exceptions:
InvalidRange if string length != 6 && string length != 8
NotInHexFormat if the string is not a valid hex format string
Returns:
ColorRGBA& this colorRGBA
See also:
set

const ColorRGBA& BALL::VIEW::ColorRGBA::operator= ( const char * value ) throw (Exception::InvalidRange, ColorUnit::NotInHexFormat)

Assignment operator with char*.

Calls set. See constructor for format description.

Parameters:
value the color represented by a string
Exceptions:
InvalidRange if string length != 6 && string length != 8
NotInHexFormat if the string is not a valid hex format string
Returns:
ColorRGBA& this colorRGBA

const ColorRGBA& BALL::VIEW::ColorRGBA::operator= ( const ColorHSV & color )

Assignment operator with ColorHSV.

Calls set.

const ColorRGBA& BALL::VIEW::ColorRGBA::operator= ( const ColorRGBA & color )

Assignment operator.

See also:
set

bool BALL::VIEW::ColorRGBA::operator== ( const ColorRGBA & color ) const

Equality test.

Tests if color is equal to this colorRGBA.

bool BALL::VIEW::ColorRGBA::operator> ( const ColorRGBA & color ) const

Greater test.

Greater means that all components of this are greater than all the components of color colorRGBA.

bool BALL::VIEW::ColorRGBA::operator>= ( const ColorRGBA & color ) const

Greater or equal test.

Greater or equal means that all components of this are greater or equal than all the components of color colorRGBA.

void BALL::VIEW::ColorRGBA::set ( const ColorUnit & red_value,
const ColorUnit & green_value,
const ColorUnit & blue_value,
const ColorUnit & alpha_value = (float) 1
)

Changes the values of the red, green, blue and alpha component.

Changes the values of of the red, green, blue and alpha component of this colorRGBA to the values represented by the parameters. See ColorUnit for further information concerning type conversions.

Parameters:
red_value the new red component of this colorRGBA
green_value the new green component of this colorRGBA
blue_value the new blue component of this colorRGBA
alpha_value the new alpha component of this colorRGBA. Default 1.0
See also:
get

ColorUnit

bool BALL::VIEW::ColorRGBA::set ( const QColor & color )

Assign from a QT QColor.

Aborts, if the QColor is invalid (see QColor::isValid()) and returns false. The alpha-value of this color is set to max.

void BALL::VIEW::ColorRGBA::set ( const String & value ) throw (Exception::InvalidRange, ColorUnit::NotInHexFormat)

Assign the color represented by a String.

See constructor for format description.

Parameters:
value the color represented by a string
Exceptions:
InvalidRange if string length != 6 && string length != 8
NotInHexFormat if the string is not a valid hex format string

void BALL::VIEW::ColorRGBA::set ( const char * value ) throw (Exception::InvalidRange, ColorUnit::NotInHexFormat)

Assignment with char*.

Assigns the color represented by the string value to this colorRGBA. See constructor for format description.

Parameters:
value the color represented by a string
Exceptions:
InvalidRange if string length != 6 && string length != 8
NotInHexFormat if the string is not a valid hex format string

void BALL::VIEW::ColorRGBA::set ( const ColorRGBA & color )

Assignment.

Parameters:
color the colorRGBA to be copied

void BALL::VIEW::ColorRGBA::setAlpha ( const ColorUnit & alpha_value )

Changes the value of the alpha component.

Parameters:
alpha_value the new alpha component of this colorRGBA
See also:
getAlpha

void BALL::VIEW::ColorRGBA::setBlue ( const ColorUnit & blue_value )

Changes the value of the blue component.

Parameters:
blue_value the new blue component of this colorRGBA
See also:
getBlue

void BALL::VIEW::ColorRGBA::setGreen ( const ColorUnit & green_value )

Changes the value of the green component.

Parameters:
green_value the new green component of this colorRGBA
See also:
getGreen

void BALL::VIEW::ColorRGBA::setRed ( const ColorUnit & red_value )

Changes the value of the red component.

See also:
getRed

void BALL::VIEW::ColorRGBA::swap ( ColorRGBA & color )

Swapping of colorRGBAs.

Parameters:
color the colorRGBA being swapped with this colorRGBA

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream & s,
const ColorRGBA & color
) [friend]

Friendly stream output.

Writes colorRGBA data to the output stream s and store the color of this. The color will be stored as an vector in integer format. The output will look like '(0-255, 0-255, 0-255, 0-255)'. This method is provided for convienience.

Parameters:
s output stream to where the color of this colorRGBA will be stored
color the colorRGBA from which the color will be stored

std::istream& operator>> ( std::istream & s,
ColorRGBA & color
) [friend]

Friendly stream input.

Reads colorRGBA data from the input stream s and restore the color of this. The red, green, blue and alpha component are read as integers from the input stream. THe method expects an vector as written as the one by the output stream operator. This method is provided for convienience.

Parameters:
s input stream from where to restore the color of this colorRGBA
color the colorRGBA to which the color will be restored

Generated on Thu Aug 6 18:30:51 2009 for BALL by doxygen 1.5.8