KPlotting 5.109.0
|
Encapsulates a data set to be plotted in a KPlotWidget. More...
#include <kplotobject.h>
Public Types | |
enum | PlotType { UnknownType = 0 , Points = 1 , Lines = 2 , Bars = 4 } |
The type classification of the KPlotObject. More... | |
typedef QFlags< PlotType > | PlotTypes |
enum | PointStyle { NoPoints = 0 , Circle = 1 , Letter = 2 , Triangle = 3 , Square = 4 , Pentagon = 5 , Hexagon = 6 , Asterisk = 7 , Star = 8 , UnknownPoint } |
The available shape styles for plotted points. More... | |
Public Member Functions | |
KPlotObject (const QColor &color=Qt::white, PlotType otype=Points, double size=2.0, PointStyle ps=Circle) | |
Constructor. | |
~KPlotObject () | |
Destructor. | |
void | 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 KPlotPoint. | |
void | 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 KPlotPoint. | |
void | addPoint (KPlotPoint *p) |
Add a given KPlotPoint to the object's list of points. | |
const QBrush | barBrush () const |
const QPen & | barPen () const |
const QBrush | brush () const |
void | clearPoints () |
Remove and destroy the points of this object. | |
void | draw (QPainter *p, KPlotWidget *pw) |
Draw this KPlotObject on the given QPainter. | |
const QPen & | labelPen () const |
const QPen & | linePen () const |
const QPen & | pen () const |
PlotTypes | plotTypes () const |
QList< KPlotPoint * > | points () const |
PointStyle | pointStyle () const |
void | removePoint (int index) |
Remove the QPointF at position index from the list of points. | |
void | setBarBrush (const QBrush &b) |
Set the brush to use for drawing bars for this object The brush to use. | |
void | setBarPen (const QPen &p) |
Set the pen to use for drawing bars for this object The pen to use. | |
void | setBrush (const QBrush &b) |
Set the default brush to use for this object The brush to use. | |
void | setLabelPen (const QPen &p) |
Set the pen to use for labels for this object The pen to use. | |
void | setLinePen (const QPen &p) |
Set the pen to use for drawing lines for this object The pen to use. | |
void | setPen (const QPen &p) |
Set the default pen for this object The pen to use. | |
void | setPointStyle (PointStyle p) |
Set a new style for drawing the points in this object. | |
void | setShowBars (bool b) |
Set whether bars will be drawn for this object. | |
void | setShowLines (bool b) |
Set whether lines will be drawn for this object. | |
void | setShowPoints (bool b) |
Set whether points will be drawn for this object. | |
void | setSize (double s) |
Set the size for plotted points in this object, in pixels. | |
double | size () const |
Encapsulates a data set to be plotted in a KPlotWidget.
Think of a KPlotObject as a set of data displayed as a group in the plot. Each KPlotObject consists of a list of KPlotPoints, 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 KPlotObject.
The type classification of the KPlotObject.
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.
Enumerator | |
---|---|
Points | each KPlotPoint is represented with a drawn point |
Lines | each KPlotPoint is connected with a line |
Bars | each KPlotPoint is shown as a vertical bar |
The available shape styles for plotted points.
|
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 |
KPlotObject::~KPlotObject | ( | ) |
Destructor.
void KPlotObject::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 KPlotPoint.
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. |
void KPlotObject::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 KPlotPoint.
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. |
void KPlotObject::addPoint | ( | KPlotPoint * | p | ) |
Add a given KPlotPoint 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.
p | pointer to the KPlotPoint to add. |
const QBrush KPlotObject::barBrush | ( | ) | const |
const QPen & KPlotObject::barPen | ( | ) | const |
const QBrush KPlotObject::brush | ( | ) | const |
void KPlotObject::clearPoints | ( | ) |
Remove and destroy the points of this object.
void KPlotObject::draw | ( | QPainter * | p, |
KPlotWidget * | pw | ||
) |
Draw this KPlotObject on the given QPainter.
p | The QPainter to draw on |
pw | the KPlotWidget to draw on (this is needed for the KPlotWidget::mapToWidget() function) |
const QPen & KPlotObject::labelPen | ( | ) | const |
const QPen & KPlotObject::linePen | ( | ) | const |
const QPen & KPlotObject::pen | ( | ) | const |
PlotTypes KPlotObject::plotTypes | ( | ) | const |
QList< KPlotPoint * > KPlotObject::points | ( | ) | const |
PointStyle KPlotObject::pointStyle | ( | ) | const |
void KPlotObject::removePoint | ( | int | index | ) |
Remove the QPointF at position index from the list of points.
index | the index of the point to be removed. |
void KPlotObject::setBarBrush | ( | const QBrush & | b | ) |
Set the brush to use for drawing bars for this object The brush to use.
void KPlotObject::setBarPen | ( | const QPen & | p | ) |
Set the pen to use for drawing bars for this object The
pen to use.
void KPlotObject::setBrush | ( | const QBrush & | b | ) |
Set the default brush to use for this object The brush to use.
void KPlotObject::setLabelPen | ( | const QPen & | p | ) |
Set the pen to use for labels for this object The
pen to use.
void KPlotObject::setLinePen | ( | const QPen & | p | ) |
Set the pen to use for drawing lines for this object The
pen to use.
void KPlotObject::setPen | ( | const QPen & | p | ) |
Set the default pen for this object The
pen to use.
void KPlotObject::setPointStyle | ( | PointStyle | p | ) |
Set a new style for drawing the points in this object.
p | the new style |
void KPlotObject::setShowBars | ( | bool | b | ) |
Set whether bars will be drawn for this object.
b | if true, bars will be drawn |
void KPlotObject::setShowLines | ( | bool | b | ) |
Set whether lines will be drawn for this object.
b | if true, lines will be drawn |
void KPlotObject::setShowPoints | ( | bool | b | ) |
Set whether points will be drawn for this object.
b | if true, points will be drawn |
void KPlotObject::setSize | ( | double | s | ) |
Set the size for plotted points in this object, in pixels.
s | the new size |
double KPlotObject::size | ( | ) | const |