KPlotObject
#include <kplotobject.h>
Public Types | |
enum | PlotType { UnknownType = 0 , Points = 1 , Lines = 2 , Bars = 4 } |
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 } |
Public Member Functions | |
KPlotObject (const QColor &color=Qt::white, PlotType otype=Points, double size=2.0, PointStyle ps=Circle) | |
~KPlotObject () | |
void | addPoint (const QPointF &p, const QString &label=QString(), double barWidth=0.0) |
void | addPoint (double x, double y, const QString &label=QString(), double barWidth=0.0) |
void | addPoint (KPlotPoint *p) |
const QBrush | barBrush () const |
const QPen & | barPen () const |
const QBrush | brush () const |
void | clearPoints () |
void | draw (QPainter *p, KPlotWidget *pw) |
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) |
void | setBarBrush (const QBrush &b) |
void | setBarPen (const QPen &p) |
void | setBrush (const QBrush &b) |
void | setLabelPen (const QPen &p) |
void | setLinePen (const QPen &p) |
void | setPen (const QPen &p) |
void | setPointStyle (PointStyle p) |
void | setShowBars (bool b) |
void | setShowLines (bool b) |
void | setShowPoints (bool b) |
void | setSize (double s) |
double | size () const |
Detailed Description
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.
- Note
- KPlotObject will take care of the points added to it, so when clearing the points list (eg with clearPoints()) any previous reference to a KPlotPoint already added to a KPlotObject will be invalid.
- Version
- 1.1
Definition at line 42 of file kplotobject.h.
Member Typedef Documentation
◆ PlotTypes
Definition at line 60 of file kplotobject.h.
Member Enumeration Documentation
◆ PlotType
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.
- Note
- points should be added in order of increasing x-coordinate when using Bars.
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 |
Definition at line 54 of file kplotobject.h.
◆ PointStyle
The available shape styles for plotted points.
Definition at line 65 of file kplotobject.h.
Constructor & Destructor Documentation
◆ KPlotObject()
|
explicit |
Constructor.
- Parameters
-
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
Definition at line 40 of file kplotobject.cpp.
◆ ~KPlotObject()
|
default |
Destructor.
Member Function Documentation
◆ addPoint() [1/3]
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.
- Parameters
-
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
- Note
- if
- Parameters
-
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.
Definition at line 175 of file kplotobject.cpp.
◆ addPoint() [2/3]
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.
- Parameters
-
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
- Note
- if
- Parameters
-
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.
Definition at line 188 of file kplotobject.cpp.
◆ addPoint() [3/3]
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.
- Parameters
-
p pointer to the KPlotPoint to add.
Definition at line 180 of file kplotobject.cpp.
◆ barBrush()
const QBrush KPlotObject::barBrush | ( | ) | const |
- Returns
- the brush to use for filling bars for this Object.
Definition at line 160 of file kplotobject.cpp.
◆ barPen()
const QPen & KPlotObject::barPen | ( | ) | const |
- Returns
- the pen to use for drawing bars for this Object.
Definition at line 130 of file kplotobject.cpp.
◆ brush()
const QBrush KPlotObject::brush | ( | ) | const |
- Returns
- the default Brush to use for this Object.
Definition at line 150 of file kplotobject.cpp.
◆ clearPoints()
void KPlotObject::clearPoints | ( | ) |
Remove and destroy the points of this object.
Definition at line 203 of file kplotobject.cpp.
◆ draw()
void KPlotObject::draw | ( | QPainter * | p, |
KPlotWidget * | pw ) |
Draw this KPlotObject on the given QPainter.
- Parameters
-
p The QPainter to draw on pw the KPlotWidget to draw on (this is needed for the KPlotWidget::mapToWidget() function)
Definition at line 209 of file kplotobject.cpp.
◆ labelPen()
const QPen & KPlotObject::labelPen | ( | ) | const |
- Returns
- the pen to use for drawing labels for this Object.
Definition at line 140 of file kplotobject.cpp.
◆ linePen()
const QPen & KPlotObject::linePen | ( | ) | const |
- Returns
- the pen to use for drawing lines for this Object.
Definition at line 120 of file kplotobject.cpp.
◆ pen()
const QPen & KPlotObject::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).
Definition at line 110 of file kplotobject.cpp.
◆ plotTypes()
KPlotObject::PlotTypes KPlotObject::plotTypes | ( | ) | const |
- Returns
- the plot flags of the object
Definition at line 58 of file kplotobject.cpp.
◆ points()
QList< KPlotPoint * > KPlotObject::points | ( | ) | const |
- Returns
- the list of KPlotPoints that make up this object
Definition at line 170 of file kplotobject.cpp.
◆ pointStyle()
KPlotObject::PointStyle KPlotObject::pointStyle | ( | ) | const |
- Returns
- the style used for drawing the points in this object
Definition at line 100 of file kplotobject.cpp.
◆ removePoint()
void KPlotObject::removePoint | ( | int | index | ) |
Remove the QPointF at position index from the list of points.
- Parameters
-
index the index of the point to be removed.
Definition at line 193 of file kplotobject.cpp.
◆ setBarBrush()
void KPlotObject::setBarBrush | ( | const QBrush & | b | ) |
Set the brush to use for drawing bars for this object The brush to use.
Definition at line 165 of file kplotobject.cpp.
◆ setBarPen()
void KPlotObject::setBarPen | ( | const QPen & | p | ) |
Set the pen to use for drawing bars for this object The
pen to use.
Definition at line 135 of file kplotobject.cpp.
◆ setBrush()
void KPlotObject::setBrush | ( | const QBrush & | b | ) |
Set the default brush to use for this object The brush to use.
Definition at line 155 of file kplotobject.cpp.
◆ setLabelPen()
void KPlotObject::setLabelPen | ( | const QPen & | p | ) |
Set the pen to use for labels for this object The
pen to use.
Definition at line 145 of file kplotobject.cpp.
◆ setLinePen()
void KPlotObject::setLinePen | ( | const QPen & | p | ) |
Set the pen to use for drawing lines for this object The
pen to use.
Definition at line 125 of file kplotobject.cpp.
◆ setPen()
void KPlotObject::setPen | ( | const QPen & | p | ) |
Set the default pen for this object The
pen to use.
Definition at line 115 of file kplotobject.cpp.
◆ setPointStyle()
void KPlotObject::setPointStyle | ( | PointStyle | p | ) |
Set a new style for drawing the points in this object.
- Parameters
-
p the new style
Definition at line 105 of file kplotobject.cpp.
◆ setShowBars()
void KPlotObject::setShowBars | ( | bool | b | ) |
Set whether bars will be drawn for this object.
- Parameters
-
b if true, bars will be drawn
Definition at line 81 of file kplotobject.cpp.
◆ setShowLines()
void KPlotObject::setShowLines | ( | bool | b | ) |
Set whether lines will be drawn for this object.
- Parameters
-
b if true, lines will be drawn
Definition at line 72 of file kplotobject.cpp.
◆ setShowPoints()
void KPlotObject::setShowPoints | ( | bool | b | ) |
Set whether points will be drawn for this object.
- Parameters
-
b if true, points will be drawn
Definition at line 63 of file kplotobject.cpp.
◆ setSize()
void KPlotObject::setSize | ( | double | s | ) |
Set the size for plotted points in this object, in pixels.
- Parameters
-
s the new size
Definition at line 95 of file kplotobject.cpp.
◆ size()
double KPlotObject::size | ( | ) | const |
- Returns
- the size of the plotted points in this object, in pixels
Definition at line 90 of file kplotobject.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:00:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.