Avogadro  1.1.0
Public Types | Public Member Functions
Avogadro::PlotObject Class Reference

Encapsulates a data set to be plotted in a PlotWidget. More...

#include <avogadro/plotobject.h>

List of all members.

Public Types

enum  PlotType { UnknownType = 0, Points = 1, Lines = 2, Bars = 4 }
enum  PointStyle {
  NoPoints = 0, Circle = 1, Letter = 2, Triangle = 3,
  Square = 4, Pentagon = 5, Hexagon = 6, Asterisk = 7,
  Star = 8, UnknownPoint
}

Public Member Functions

 PlotObject (const QColor &color=Qt::white, PlotType otype=Points, double size=2, PointStyle ps=Circle)
 ~PlotObject ()
PlotTypes plotTypes () const
void setShowPoints (bool b)
void setShowLines (bool b)
void setShowBars (bool b)
double size () const
void setSize (double s)
PointStyle pointStyle () const
void setPointStyle (PointStyle p)
const QPenpen () const
void setPen (const QPen &p)
const QPenlinePen () const
void setLinePen (const QPen &p)
const QPenbarPen () const
void setBarPen (const QPen &p)
const QPenlabelPen () const
void setLabelPen (const QPen &p)
const QBrush brush () const
void setBrush (const QBrush &b)
const QBrush barBrush () const
void setBarBrush (const QBrush &b)
QList< PlotPoint * > points () const
PlotPointaddPoint (const QPointF &p, const QString &label=QString(), double barWidth=0.0)
PlotPointaddPoint (PlotPoint *p)
PlotPointaddPoint (double x, double y, const QString &label=QString(), double barWidth=0.0)
void removePoint (int index)
PlotPointat (int index)
void clearPoints ()
void draw (QPainter *p, PlotWidget *pw)
void drawImage (QPainter *painter, QRect *pixRect, QRectF *dataRect)

Detailed Description

Encapsulates a data set to be plotted in a PlotWidget.

Think of a PlotObject as a set of data displayed as a group in the plot. Each PlotObject consists of a list of PlotPoints, a "type" controlling how the data points are displayed (some combination of Points, Lines, or Bars), a color, and a size. There is also a parameter which controls the shape of the points used to display the PlotObject.

Note:
PlotObject will take care of the points added to it, so when clearing the points list (eg with clearPoints()) any previous reference to a PlotPoint already added to a PlotObject will be invalid.
Author:
Jason Harris
Version:
1.1

Member Enumeration Documentation

The type classification of the PlotObject.

These are bitmask values that can be OR'd together, so that a set of points can be represented in the plot in multiple ways.

Note:
points should be added in order of increasing x-coordinate when using Bars.
Enumerator:
Points 

each PlotPoint is represented with a drawn point

Lines 

each PlotPoint is connected with a line

Bars 

each PlotPoint is shown as a vertical bar

The available shape styles for plotted points.


Constructor & Destructor Documentation

Avogadro::PlotObject::PlotObject ( const QColor color = Qt::white,
PlotType  otype = Points,
double  size = 2,
PointStyle  ps = Circle 
) [explicit]

Constructor.

Parameters:
colorThe color for plotting this object. By default this sets the color for Points, Lines and Bars, but there are functions to override any of these.
otypethe PlotType for this object (Points, Lines or Bars)
sizethe size to use for plotted points, in pixels
psThe PointStyle describing the shape for plotted points

References brush(), pen(), setBarBrush(), setBarPen(), setBrush(), setLabelPen(), setLinePen(), setPen(), setPointStyle(), and setSize().

Destructor.


Member Function Documentation

PlotPoint * Avogadro::PlotObject::addPoint ( const QPointF p,
const QString label = QString(),
double  barWidth = 0.0 
)

Add a point to the object's list of points, using input data to construct a PlotPoint.

Parameters:
pthe QPointF to add.
labelthe optional text label for this point
barWidththe width of the bar, if this object is to be drawn with bars
Returns:
a reference to the PlotPoint added.
Note:
if
Parameters:
barWidthis left at its default value of 0.0, then the width will be automatically set to the distance between this point and the one to its right.

References QPointF::x(), and QPointF::y().

Referenced by addPoint().

Add a given PlotPoint to the object's list of points.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
ppointer to the PlotPoint to add.
Returns:
a reference to the PlotPoint added.
PlotPoint * Avogadro::PlotObject::addPoint ( double  x,
double  y,
const QString label = QString(),
double  barWidth = 0.0 
)

Add a point to the object's list of points, using input data to construct a PlotPoint.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
xthe X-coordinate of the point to add.
ythe Y-coordinate of the point to add.
labelthe optional text label
barWidththe width of the bar, if this object is to be drawn with bars
Returns:
a reference to the PlotPoint added.
Note:
if
Parameters:
barWidthis left at its default value of 0.0, then the width will be automatically set to the distance between this point and the one to its right.

References addPoint().

Return a reference to the PlotPoint at the specified index.

Parameters:
indindex of point to be returned
Returns:
the brush to use for filling bars for this Object.

Referenced by draw(), and drawImage().

Returns:
the pen to use for drawing bars for this Object.

Referenced by draw(), and drawImage().

Returns:
the default Brush to use for this Object.

Referenced by draw(), drawImage(), and PlotObject().

Remove and destroy the points of this object

void Avogadro::PlotObject::drawImage ( QPainter painter,
QRect pixRect,
QRectF dataRect 
)
Returns:
the pen to use for drawing labels for this Object.

Referenced by draw().

Returns:
the pen to use for drawing lines for this Object.

Referenced by draw(), and drawImage().

const QPen & Avogadro::PlotObject::pen ( ) const
Returns:
the default pen for this Object. If no other pens are set, this pen will be used for points, lines, bars and labels (this pen is always used for points).

Referenced by draw(), drawImage(), and PlotObject().

PlotObject::PlotTypes Avogadro::PlotObject::plotTypes ( ) const
Returns:
the plot flags of the object
Returns:
the list of PlotPoints that make up this object

Referenced by Avogadro::PlotWidget::pointNearestPoint(), Avogadro::PlotWidget::pointsUnderPoint(), and Avogadro::PlotWidget::scaleLimits().

Returns:
the style used for drawing the points in this object

Referenced by draw(), and drawImage().

void Avogadro::PlotObject::removePoint ( int  index)

Remove the QPointF at position index from the list of points

Parameters:
indexthe index of the point to be removed.

Set the brush to use for drawing bars for this object The brush to use

Referenced by PlotObject().

Set the pen to use for drawing bars for this object The pen to use

Referenced by PlotObject().

Set the default brush to use for this object The brush to use

Referenced by PlotObject().

Set the pen to use for labels for this object The pen to use

Referenced by PlotObject().

Set the pen to use for drawing lines for this object The pen to use

Referenced by PlotObject().

void Avogadro::PlotObject::setPen ( const QPen p)

Set the default pen for this object The pen to use

Referenced by PlotObject().

Set a new style for drawing the points in this object

Parameters:
pthe new style

Referenced by PlotObject().

Set whether bars will be drawn for this object

Parameters:
bif true, bars will be drawn

References Bars.

Set whether lines will be drawn for this object

Parameters:
bif true, lines will be drawn

References Lines.

Set whether points will be drawn for this object

Parameters:
bif true, points will be drawn

References Points.

void Avogadro::PlotObject::setSize ( double  s)

Set the size for plotted points in this object, in pixels

Parameters:
sthe new size

Referenced by PlotObject().

double Avogadro::PlotObject::size ( ) const
Returns:
the size of the plotted points in this object, in pixels

Referenced by draw(), and drawImage().


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