Avogadro
1.1.0
|
Encapsulates a data set to be plotted in a PlotWidget. More...
#include <avogadro/plotobject.h>
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 QPen & | pen () const |
void | setPen (const QPen &p) |
const QPen & | linePen () const |
void | setLinePen (const QPen &p) |
const QPen & | barPen () const |
void | setBarPen (const QPen &p) |
const QPen & | labelPen () 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 |
PlotPoint * | addPoint (const QPointF &p, const QString &label=QString(), double barWidth=0.0) |
PlotPoint * | addPoint (PlotPoint *p) |
PlotPoint * | addPoint (double x, double y, const QString &label=QString(), double barWidth=0.0) |
void | removePoint (int index) |
PlotPoint * | at (int index) |
void | clearPoints () |
void | draw (QPainter *p, PlotWidget *pw) |
void | drawImage (QPainter *painter, QRect *pixRect, QRectF *dataRect) |
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.
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.
The available shape styles for plotted points.
Avogadro::PlotObject::PlotObject | ( | const QColor & | color = Qt::white , |
PlotType | otype = Points , |
||
double | size = 2 , |
||
PointStyle | ps = Circle |
||
) | [explicit] |
Constructor.
color | The 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. |
otype | the PlotType for this object (Points, Lines or Bars) |
size | the size to use for plotted points, in pixels |
ps | The PointStyle describing the shape for plotted points |
References brush(), pen(), setBarBrush(), setBarPen(), setBrush(), setLabelPen(), setLinePen(), setPen(), setPointStyle(), and setSize().
Destructor.
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.
p | the QPointF to add. |
label | the optional text label for this point |
barWidth | the width of the bar, if this object is to be drawn with bars |
barWidth | is 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().
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.
x | the X-coordinate of the point to add. |
y | the Y-coordinate of the point to add. |
label | the optional text label |
barWidth | the width of the bar, if this object is to be drawn with bars |
barWidth | is 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().
PlotPoint * Avogadro::PlotObject::at | ( | int | index | ) |
Return a reference to the PlotPoint at the specified index.
ind | index of point to be returned |
const QBrush Avogadro::PlotObject::barBrush | ( | ) | const |
Referenced by draw(), and drawImage().
const QPen & Avogadro::PlotObject::barPen | ( | ) | const |
Referenced by draw(), and drawImage().
const QBrush Avogadro::PlotObject::brush | ( | ) | const |
Referenced by draw(), drawImage(), and PlotObject().
void Avogadro::PlotObject::clearPoints | ( | ) |
Remove and destroy the points of this object
void Avogadro::PlotObject::draw | ( | QPainter * | p, |
PlotWidget * | pw | ||
) |
Draw this PlotObject on the given QPainter
p | The QPainter to draw on |
pw | the PlotWidget to draw on (this is needed for the PlotWidget::mapToWidget() function) |
References barBrush(), barPen(), Bars, brush(), QRect::contains(), QPainter::drawEllipse(), QPainter::drawLine(), QPainter::drawPolygon(), QPainter::drawRect(), QPainter::drawText(), QString::isEmpty(), QPointF::isNull(), Avogadro::PlotPoint::label(), labelPen(), QString::left(), linePen(), Lines, Avogadro::PlotWidget::mapToWidget(), Avogadro::PlotWidget::maskAlongLine(), Avogadro::PlotWidget::maskRect(), pen(), Avogadro::PlotWidget::pixRect(), Avogadro::PlotWidget::placeLabel(), Points, pointStyle(), Avogadro::PlotPoint::position(), QPainter::setBrush(), QPainter::setPen(), size(), QPointF::toPoint(), QPointF::x(), and QPointF::y().
Referenced by Avogadro::PlotWidget::paintEvent().
void Avogadro::PlotObject::drawImage | ( | QPainter * | painter, |
QRect * | pixRect, | ||
QRectF * | dataRect | ||
) |
Draw this PlotObject on the given QPainter
p | The QPainter to draw on |
pixRect | the QRect that defines the actual plot area. Needed conversion between data and image coordinates. |
dataRect | QRect containing the plot limits in data units |
References barBrush(), barPen(), Bars, brush(), QRect::contains(), QPainter::drawEllipse(), QPainter::drawLine(), QPainter::drawPolygon(), QPainter::drawRect(), QPainter::drawText(), QRect::height(), QRectF::height(), QPointF::isNull(), Avogadro::PlotPoint::label(), QRect::left(), QString::left(), linePen(), Lines, pen(), Points, pointStyle(), Avogadro::PlotPoint::position(), QPainter::setBrush(), QPainter::setPen(), size(), QRect::top(), QRectF::width(), QRect::width(), QRectF::x(), QPointF::x(), QRectF::y(), and QPointF::y().
Referenced by Avogadro::PlotWidget::saveImage().
const QPen & Avogadro::PlotObject::labelPen | ( | ) | const |
Referenced by draw().
const QPen & Avogadro::PlotObject::linePen | ( | ) | const |
Referenced by draw(), and drawImage().
const QPen & Avogadro::PlotObject::pen | ( | ) | const |
Referenced by draw(), drawImage(), and PlotObject().
PlotObject::PlotTypes Avogadro::PlotObject::plotTypes | ( | ) | const |
QList< PlotPoint * > Avogadro::PlotObject::points | ( | ) | const |
Referenced by Avogadro::PlotWidget::pointNearestPoint(), Avogadro::PlotWidget::pointsUnderPoint(), and Avogadro::PlotWidget::scaleLimits().
Referenced by draw(), and drawImage().
void Avogadro::PlotObject::removePoint | ( | int | index | ) |
Remove the QPointF at position index from the list of points
index | the index of the point to be removed. |
void Avogadro::PlotObject::setBarBrush | ( | const QBrush & | b | ) |
Set the brush to use for drawing bars for this object The brush to use
Referenced by PlotObject().
void Avogadro::PlotObject::setBarPen | ( | const QPen & | p | ) |
Set the pen to use for drawing bars for this object The
pen to use
Referenced by PlotObject().
void Avogadro::PlotObject::setBrush | ( | const QBrush & | b | ) |
Set the default brush to use for this object The brush to use
Referenced by PlotObject().
void Avogadro::PlotObject::setLabelPen | ( | const QPen & | p | ) |
Set the pen to use for labels for this object The
pen to use
Referenced by PlotObject().
void Avogadro::PlotObject::setLinePen | ( | const QPen & | p | ) |
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
p | the new style |
Referenced by PlotObject().
void Avogadro::PlotObject::setShowBars | ( | bool | b | ) |
Set whether bars will be drawn for this object
b | if true, bars will be drawn |
References Bars.
void Avogadro::PlotObject::setShowLines | ( | bool | b | ) |
Set whether lines will be drawn for this object
b | if true, lines will be drawn |
References Lines.
void Avogadro::PlotObject::setShowPoints | ( | bool | b | ) |
Set whether points will be drawn for this object
b | if true, points will be drawn |
References Points.
void Avogadro::PlotObject::setSize | ( | double | s | ) |
Set the size for plotted points in this object, in pixels
s | the new size |
Referenced by PlotObject().
double Avogadro::PlotObject::size | ( | ) | const |
Referenced by draw(), and drawImage().