GTK+ IOStream  Beta
<< GTK+ >> add C++ IOStream operators to GTK+. Now with extra abilities ... like network serialisation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | Static Private Attributes | List of all members
ColourLineSpec Class Reference

encapsulates a method to specify colour and line or point plotting This class tries to encapsulate octave style colours and line type specification. See ColourLineSpec::ColourLineSpec for a description More...

#include <ColourLineSpec.H>

Collaboration diagram for ColourLineSpec:
Collaboration graph
[legend]

Public Member Functions

 ColourLineSpec (void)
 default constructor with blue colour Initiates the defaul blue line type of size 1 More...
 
 ColourLineSpec (const char *clsChar)
 use a octave like string to define the line/points or colour Speciy whether to use points or lines and the colour. For example, "r" means, plot red with lines, ":k" means plot black in points. Also you can specify size, eg : ":r10" means points, red, size 10 More...
 
bool wasSizeSpecified (void)
 
bool wasColourSpecified (void)
 
void setSize (int s)
 
int getSize (void)
 
void setColour (GdkColor c)
 
void setColour (const char *c)
 
GdkColor getColour (void)
 
gchar * getColourString (void)
 
void setColourAndLinesOrPoints (const char *clsChar)
 interprets the octave style line/colour spec. By default implements lines specify points using the ':' character. Understands the default octave colours. More...
 
ColourLineSpecoperator= (string &c)
 
ColourLineSpecoperator= (char *c)
 

Static Public Member Functions

static const char ** getColourLabels (void)
 

Public Attributes

bool linePlot
 The indication for lines or points plotting. More...
 

Private Attributes

bool sizeNotSpecified
 Set to true if the size was not specified ... i.e. "r" for red with no size. More...
 
bool colourNotSpecified
 Set to true if the colour was not specified ... i.e. "12" for size 12 with no colour. More...
 
int size
 The size of the line or point. More...
 
GdkColor colour
 The colour holder. More...
 

Static Private Attributes

static int colourCnt =10
 The number of colours defined in the following char ** variables. More...
 
static const char * shortColours [] = {(char *)"y",(char *)"m",(char *)"c",(char *)"r",(char *)"g",(char *)"b",(char *)"w",(char *)"k",(char *)"o",(char *)"a"}
 Default octave colours which match ColourLineSpec::X11Colours. More...
 
static const char * X11Colours [] = {(char *)"yellow", (char *)"magenta", (char *)"cyan", (char *)"red", (char *)"green", (char *)"blue", (char *)"white", (char *)"black", (char *)"orange", (char *)"gray"}
 Default X11 colours to match ColourLineSpec::shortColours. More...
 

Detailed Description

encapsulates a method to specify colour and line or point plotting This class tries to encapsulate octave style colours and line type specification. See ColourLineSpec::ColourLineSpec for a description

Additionally, as this is only a header file, you must put something like the following into your C++ source file :

setup the possible plot colours ... NOTE: if you want to use the Plot::grid method, you HAVE TO make sure that "a" is mapped to a colour - in this case, gray. int ColourLineSpec::colourCnt=10; // match this number with the number of colours below const char *ColourLineSpec::shortColours[]= {(char *)"y",(char *)"m",(char *)"c",(char *)"r",(char *)"g",(char *)"b",(char *)"w",(char *)"k",(char *)"o",(char *)"a"}; // standard colours const char *ColourLineSpec::X11Colours[]= {(char *)"yellow", (char *)"magenta", (char *)"cyan", (char *)"red", (char *)"green", (char *)"blue", (char *)"white", (char *)"black", (char *)"orange", (char *)"gray"};

This class allows you to specify plot spcifications like so : "c1" for a cyan plot of line width 1. Or "y2:" for a yellow dotted plot of size 2. i.e. : plot(x,y,x.size(),"y2");

Definition at line 27 of file ColourLineSpec.H.

Constructor & Destructor Documentation

ColourLineSpec::ColourLineSpec ( void  )
inline

default constructor with blue colour Initiates the defaul blue line type of size 1

Definition at line 41 of file ColourLineSpec.H.

ColourLineSpec::ColourLineSpec ( const char *  clsChar)
inline

use a octave like string to define the line/points or colour Speciy whether to use points or lines and the colour. For example, "r" means, plot red with lines, ":k" means plot black in points. Also you can specify size, eg : ":r10" means points, red, size 10

Definition at line 50 of file ColourLineSpec.H.

Member Function Documentation

GdkColor ColourLineSpec::getColour ( void  )
inline
Request the colour
Returns
the GdkColor

Definition at line 115 of file ColourLineSpec.H.

Here is the caller graph for this function:

static const char** ColourLineSpec::getColourLabels ( void  )
inlinestatic

Definition at line 182 of file ColourLineSpec.H.

gchar* ColourLineSpec::getColourString ( void  )
inline
Request the colour string
Returns
the GdkColor as a newly allocated string

Definition at line 122 of file ColourLineSpec.H.

Here is the caller graph for this function:

int ColourLineSpec::getSize ( void  )
inline
Request the size
Returns
the size

Definition at line 92 of file ColourLineSpec.H.

Here is the caller graph for this function:

ColourLineSpec& ColourLineSpec::operator= ( string &  c)
inline

Definition at line 165 of file ColourLineSpec.H.

ColourLineSpec& ColourLineSpec::operator= ( char *  c)
inline

Definition at line 173 of file ColourLineSpec.H.

void ColourLineSpec::setColour ( GdkColor  c)
inline
Manually specify the colour
Parameters
cthe GtkColor

Definition at line 99 of file ColourLineSpec.H.

void ColourLineSpec::setColour ( const char *  c)
inline
Manually specify the colour
Parameters
cthe char* color (could be something like "red" or "#b2b2b2")

Definition at line 107 of file ColourLineSpec.H.

void ColourLineSpec::setColourAndLinesOrPoints ( const char *  clsChar)
inline

interprets the octave style line/colour spec. By default implements lines specify points using the ':' character. Understands the default octave colours.

Definition at line 131 of file ColourLineSpec.H.

void ColourLineSpec::setSize ( int  s)
inline
Manually specify the size
Parameters
sthe size

Definition at line 84 of file ColourLineSpec.H.

bool ColourLineSpec::wasColourSpecified ( void  )
inline
Enquire whether the colour was specified as well as the size

For example:

ColourLineSpec cls("12"); // is size 12 without colour.
cls.wasColourSpecified(); // is false
Returns
true if the colour was specified, false otherwise

Definition at line 77 of file ColourLineSpec.H.

Here is the caller graph for this function:

bool ColourLineSpec::wasSizeSpecified ( void  )
inline
Enquire whether the size was specified as well as the colour.

For example:

ColourLineSpec cls("r"); // is red without size.
cls.wasSizeSpecified(); // is false
Returns
true if the size was specified, false otherwise

Definition at line 65 of file ColourLineSpec.H.

Here is the caller graph for this function:

Member Data Documentation

GdkColor ColourLineSpec::colour
private

The colour holder.

Definition at line 34 of file ColourLineSpec.H.

int ColourLineSpec::colourCnt =10
staticprivate

The number of colours defined in the following char ** variables.

Definition at line 28 of file ColourLineSpec.H.

bool ColourLineSpec::colourNotSpecified
private

Set to true if the colour was not specified ... i.e. "12" for size 12 with no colour.

Definition at line 32 of file ColourLineSpec.H.

bool ColourLineSpec::linePlot

The indication for lines or points plotting.

Definition at line 36 of file ColourLineSpec.H.

const char * ColourLineSpec::shortColours = {(char *)"y",(char *)"m",(char *)"c",(char *)"r",(char *)"g",(char *)"b",(char *)"w",(char *)"k",(char *)"o",(char *)"a"}
staticprivate

Default octave colours which match ColourLineSpec::X11Colours.

Definition at line 29 of file ColourLineSpec.H.

int ColourLineSpec::size
private

The size of the line or point.

Definition at line 33 of file ColourLineSpec.H.

bool ColourLineSpec::sizeNotSpecified
private

Set to true if the size was not specified ... i.e. "r" for red with no size.

Definition at line 31 of file ColourLineSpec.H.

const char * ColourLineSpec::X11Colours = {(char *)"yellow", (char *)"magenta", (char *)"cyan", (char *)"red", (char *)"green", (char *)"blue", (char *)"white", (char *)"black", (char *)"orange", (char *)"gray"}
staticprivate

Default X11 colours to match ColourLineSpec::shortColours.

Definition at line 30 of file ColourLineSpec.H.


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