Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | Class Members | Related Pages

PlotMM::Curve Class Reference

Inheritance diagram for PlotMM::Curve:

Inheritance graph
[legend]
List of all members.

Detailed Description

A class which draws curves.

This class can be used to display data as a curve in the x-y plane. It supports different display styles and symbols.

Usage
A. Assign curve properties
When a curve is created, it is configured to draw black solid lines with CURVE_LINES and no symbols. You can change this by calling Curve::set_pen(), Curve::set_style() and Curve::set_symbol().
B. Assign or change data.
use one of the provided Curve::set_data() functions. The curve's x and y data are assigned by copying from different data structures.
C. Draw
Curve::draw() maps the data into pixel coordinates and paints them.
Example:
see examples/curvdemo
See also:
Symbol, DoubleIntMap


Public Member Functions

 Curve (const Glib::ustring &title="")
 Curve (const Curve &c)
virtual ~Curve ()
virtual void set_enabled (bool b)
virtual bool enabled ()
const Curveoperator= (const Curve &c)
virtual void set_data (const double *xData, const double *yData, int size)
virtual void set_data (const std::vector< double > &xData, const std::vector< double > &yData)
virtual void set_data (const Glib::ArrayHandle< DoublePoint > &data)
virtual int data_size () const
double x (int i) const
double y (int i) const
virtual DoubleRect bounding_rect () const
double min_x_value () const
double max_x_value () const
double min_y_value () const
double max_y_value () const
virtual void set_options (CurveOptions t)
virtual CurveOptions options () const
virtual void set_title (const Glib::ustring &title)
virtual const Glib::ustring & title () const
virtual void set_baseline (double ref)
virtual double baseline () const
virtual void set_curve_style (CurveStyleID style, CurveOptions options=CURVE_AUTO)
virtual CurveStyleID curve_style () const
virtual Glib::RefPtr< Paintpaint () const
virtual void set_symbol (const Glib::RefPtr< Symbol > &s)
virtual Glib::RefPtr< Symbolsymbol () const
virtual void draw (const Glib::RefPtr< Gdk::Drawable > &p, const DoubleIntMap &xMap, const DoubleIntMap &yMap, int from=0, int to=-1)

Public Attributes

SigC::Signal0< void > signal_curve_changed

Protected Member Functions

virtual void init (const Glib::ustring &title)
virtual void copy (const Curve &c)
virtual void draw_curve_ (const Glib::RefPtr< Gdk::Drawable > &p, int style, const DoubleIntMap &xMap, const DoubleIntMap &yMap, int from, int to)
virtual void draw_symbols_ (const Glib::RefPtr< Gdk::Drawable > &p, const Glib::RefPtr< Symbol > &, const DoubleIntMap &xMap, const DoubleIntMap &yMap, int from, int to)
virtual void draw_lines_ (const Glib::RefPtr< Gdk::Drawable > &p, const DoubleIntMap &xMap, const DoubleIntMap &yMap, int from, int to)
virtual void draw_sticks_ (const Glib::RefPtr< Gdk::Drawable > &p, const DoubleIntMap &xMap, const DoubleIntMap &yMap, int from, int to)
virtual void draw_dots_ (const Glib::RefPtr< Gdk::Drawable > &p, const DoubleIntMap &xMap, const DoubleIntMap &yMap, int from, int to)
virtual void draw_lsteps_ (const Glib::RefPtr< Gdk::Drawable > &p, const DoubleIntMap &xMap, const DoubleIntMap &yMap, int from, int to)
virtual void draw_csteps_ (const Glib::RefPtr< Gdk::Drawable > &p, const DoubleIntMap &xMap, const DoubleIntMap &yMap, int from, int to)
virtual void draw_rsteps_ (const Glib::RefPtr< Gdk::Drawable > &p, const DoubleIntMap &xMap, const DoubleIntMap &yMap, int from, int to)
virtual void close_polyline_ (const DoubleIntMap &, const DoubleIntMap &, std::vector< Gdk::Point > &) const
virtual void curve_changed ()
virtual int verify_range (int &i1, int &i2)


Constructor & Destructor Documentation

Curve::Curve const Glib::ustring &  title = ""  ) 
 

Ctor.

Parameters:
title title of the curve

Curve::Curve const Curve c  ) 
 

Copy Constructor.

Curve::~Curve  )  [virtual]
 

Destructor.


Member Function Documentation

double Curve::baseline  )  const [virtual]
 

Return the value of the baseline.

See also:
Curve::set_baseline

DoubleRect Curve::bounding_rect  )  const [virtual]
 

Returns the bounding rectangle of the curve data. If there is no bounding rect, like for empty data the rectangle is invalid: DoubleRect.is_valid() == FALSE

void Curve::close_polyline_ const DoubleIntMap xMap,
const DoubleIntMap yMap,
std::vector< Gdk::Point > &  pa
const [protected, virtual]
 

Complete a polygon to be a closed polygon including the area between the original polygon and the baseline.

Parameters:
xMap X map
yMap Y map
pa Polygon to be completed

void Curve::copy const Curve c  )  [protected, virtual]
 

Copy the contents of a curve into another curve.

Reimplemented in PlotMM::ErrorCurve.

void Curve::curve_changed  )  [protected, virtual]
 

Notify a change of attributes. This virtual function is called when an attribute of the curve has changed. It can be redefined by derived classes. The default implementation does nothing.

CurveStyleID Curve::curve_style  )  const [virtual]
 

Return the current style.

See also:
Curve::set_style

int Curve::data_size  )  const [virtual]
 

Return the size of the data arrays

void Curve::draw const Glib::RefPtr< Gdk::Drawable > &  painter,
const DoubleIntMap xMap,
const DoubleIntMap yMap,
int  from = 0,
int  to = -1
[virtual]
 

Draw an intervall of the curve.

Parameters:
painter Painter
xMap maps x-values into pixel coordinates.
yMap maps y-values into pixel coordinates.
from index of the first point to be painted
to index of the last point to be painted. If to < 0 the curve will be painted to its last point.
See also:
Curve::draw_curve_, Curve::draw_dots_, Curve::draw_lines_, Curve::draw_symbols_, Curve::draw_lsteps_, Curve::draw_csteps_, Curve::draw_rsteps_, Curve::draw_sticks_

Reimplemented in PlotMM::ErrorCurve.

void Curve::draw_csteps_ const Glib::RefPtr< Gdk::Drawable > &  painter,
const DoubleIntMap xMap,
const DoubleIntMap yMap,
int  from,
int  to
[protected, virtual]
 

Draw step function.

Parameters:
painter Painter
xMap x map
yMap y map
from index of the first point to be painted
to index of the last point to be painted
See also:
Curve::draw, Curve::draw_curve_, Curve::draw_dots_, Curve::draw_lines_, Curve::draw_sticks_

void Curve::draw_curve_ const Glib::RefPtr< Gdk::Drawable > &  painter,
int  style,
const DoubleIntMap xMap,
const DoubleIntMap yMap,
int  from,
int  to
[protected, virtual]
 

Draw the line part (without symbols) of a curve interval.

Parameters:
painter Painter
style curve style, see CurveStyleID
xMap x map
yMap y map
from index of the first point to be painted
to index of the last point to be painted
See also:
Curve::draw

void Curve::draw_dots_ const Glib::RefPtr< Gdk::Drawable > &  painter,
const DoubleIntMap xMap,
const DoubleIntMap yMap,
int  from,
int  to
[protected, virtual]
 

Draw dots.

Parameters:
painter Painter
xMap x map
yMap y map
from index of the first point to be painted
to index of the last point to be painted
See also:
Curve::draw

void Curve::draw_lines_ const Glib::RefPtr< Gdk::Drawable > &  painter,
const DoubleIntMap xMap,
const DoubleIntMap yMap,
int  from,
int  to
[protected, virtual]
 

Draw lines.

Parameters:
painter Painter
xMap x map
yMap y map
from index of the first point to be painted
to index of the last point to be painted
See also:
Curve::draw

void Curve::draw_lsteps_ const Glib::RefPtr< Gdk::Drawable > &  painter,
const DoubleIntMap xMap,
const DoubleIntMap yMap,
int  from,
int  to
[protected, virtual]
 

Draw step function.

Parameters:
painter Painter
xMap x map
yMap y map
from index of the first point to be painted
to index of the last point to be painted
See also:
Curve::draw

void Curve::draw_rsteps_ const Glib::RefPtr< Gdk::Drawable > &  painter,
const DoubleIntMap xMap,
const DoubleIntMap yMap,
int  from,
int  to
[protected, virtual]
 

Draw step function.

Parameters:
painter Painter
xMap x map
yMap y map
from index of the first point to be painted
to index of the last point to be painted
See also:
Curve::draw, Curve::draw_curve_, Curve::draw_dots_, Curve::draw_lines_, Curve::draw_sticks_

void Curve::draw_sticks_ const Glib::RefPtr< Gdk::Drawable > &  painter,
const DoubleIntMap xMap,
const DoubleIntMap yMap,
int  from,
int  to
[protected, virtual]
 

Draw sticks.

Parameters:
painter Painter
xMap x map
yMap y map
from index of the first point to be painted
to index of the last point to be painted
See also:
Curve::draw

void Curve::draw_symbols_ const Glib::RefPtr< Gdk::Drawable > &  painter,
const Glib::RefPtr< Symbol > &  symbol,
const DoubleIntMap xMap,
const DoubleIntMap yMap,
int  from,
int  to
[protected, virtual]
 

Draw symbols.

Parameters:
painter Painter
symbol Curve symbol
xMap x map
yMap y map
from index of the first point to be painted
to index of the last point to be painted

virtual bool PlotMM::Curve::enabled  )  [virtual]
 

Query if this curve is enabled for drawing.

void Curve::init const Glib::ustring &  title  )  [protected, virtual]
 

Initialize data members.

Reimplemented in PlotMM::ErrorCurve.

const Curve & Curve::operator= const Curve c  ) 
 

Copy Assignment.

CurveOptions Curve::options  )  const [virtual]
 

Return the current style options.

See also:
Curve::set_options

Glib::RefPtr< Paint > Curve::paint  )  const [virtual]
 

Return a reference to the Paint the curve is drawn with

void Curve::set_baseline double  ref  )  [virtual]
 

Set the value of the baseline.

The baseline is needed for filling the curve with a brush or the CURVE_STICKS drawing style. The default value is 0.0. The interpretation of the baseline depends on the style options. With CURVE_Y_FX, the baseline is interpreted as a horizontal line at y = baseline(), with Curve::Yfy, it is interpreted as a vertical line at x = baseline().

Parameters:
ref baseline
See also:
Curve::set_brush(), Curve::set_style(), Curve::set_options()

void Curve::set_curve_style CurveStyleID  cStyle,
CurveOptions  options = CURVE_AUTO
[virtual]
 

Set the curve's drawing style.

Valid styles are:

CURVE_NONE
Don't draw a curve. Note: This doesn't affect the symbol.
CURVE_LINES
Connect the points with straight lines.
CURVE_STICKS
Draw vertical sticks from a baseline which is defined by set_baseline().
Curve::Steps
Connect the points with a step function. The step function is drawn from the left to the right or vice versa, depending on the 'CURVE_INVERTED' option.
Curves::CURVE_DOTS
Draw dots at the locations of the data points. Note: This is different from a dotted line (see set_pen()).
Curve::UserCurve ...
Styles >= Curve::UserCurve are reserved for derived classes of Curve that overload Curve::draw() with additional application specific curve types.
See also:
Curve::paint()

void Curve::set_data const Glib::ArrayHandle< DoublePoint > &  data  )  [virtual]
 

Initialize data with an array of points (explicitly shared).

Parameters:
data Data
Todo:
test if this method really works

Reimplemented in PlotMM::ErrorCurve.

void Curve::set_data const std::vector< double > &  xData,
const std::vector< double > &  yData
[virtual]
 

Initialize data with x- and y-arrays (explicitly shared).

Parameters:
xData x data
yData y data
Todo:
handle unevenly sized arrays correctly

Reimplemented in PlotMM::ErrorCurve.

void Curve::set_data const double *  xData,
const double *  yData,
int  size
[virtual]
 

Set data by copying x- and y-values from specified memory blocks Contrary to Plot::set_curveRawData, this function makes a 'deep copy' of the data.

Parameters:
xData pointer to x values
yData pointer to y values
size size of xData and yData
See also:
QwData::set_data.
Todo:
handle null pointers correctly

Reimplemented in PlotMM::ErrorCurve.

virtual void PlotMM::Curve::set_enabled bool  b  )  [virtual]
 

Enable or disable this curve for drawing.

void Curve::set_options CurveOptions  opt  )  [virtual]
 

Specify options for the drawing style.

The options can be used to modify the drawing style. Options can be or-combined. The following options are defined:

CURVE_AUTO
The default setting. This means that y is regarded as a function of x.
CURVE_Y_FX
Draws y as a function of x (the default). The baseline is interpreted as a horizontal line with y = baseline().
CURVE_X_FY
Draws x as a function of y. The baseline is interpreted as a vertical line with x = baseline().
CURVE_INVERTED
For Curve::Steps only. Draws a step function from the right to the left.

Parameters:
opt new options /sa Curve::options()

void Curve::set_symbol const Glib::RefPtr< Symbol > &  s  )  [virtual]
 

Assign a symbol.

Parameters:
s symbol
See also:
Symbol

void Curve::set_title const Glib::ustring &  title  )  [virtual]
 

Assign a title to a curve.

Parameters:
title new title

Glib::RefPtr< Symbol > Curve::symbol  )  const [virtual]
 

Return the current symbol.

See also:
Curve::set_symbol

const Glib::ustring & Curve::title  )  const [virtual]
 

Return the title.

See also:
Curve::set_title

int Curve::verify_range int &  i1,
int &  i2
[protected, virtual]
 

Checks if a range of indices is valid and corrects it if necessary.

Parameters:
i1 Index 1
i2 Index 2

double PlotMM::Curve::x int  i  )  const
 

Parameters:
i index
Returns:
x-value at position i

double PlotMM::Curve::y int  i  )  const
 

Parameters:
i index
Returns:
y-value at position i


Member Data Documentation

SigC::Signal0<void> PlotMM::Curve::signal_curve_changed
 

Signals that this curve has changed in some way or the other.


Generated on Thu Nov 10 15:26:22 2005 for PlotMM by  doxygen 1.4.4