KPlotting 5.109.0
kplotobject.h
1/* -*- C++ -*-
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2003 Jason Harris <kstars@30doradus.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KPLOTOBJECT_H
9#define KPLOTOBJECT_H
10
11#include <kplotting_export.h>
12
13#include <QColor>
14#include <QString>
15
16class QBrush;
17class QPainter;
18class QPen;
19class QPointF;
20class KPlotWidget;
21class KPlotPoint;
22
40class KPLOTTING_EXPORT KPlotObject
41{
42public:
52 enum PlotType {
53 UnknownType = 0,
54 Points = 1,
55 Lines = 2,
56 Bars = 4,
57 };
58 Q_DECLARE_FLAGS(PlotTypes, PlotType)
59
60
64 NoPoints = 0,
65 Circle = 1,
66 Letter = 2,
67 Triangle = 3,
68 Square = 4,
69 Pentagon = 5,
70 Hexagon = 6,
71 Asterisk = 7,
72 Star = 8,
73 UnknownPoint,
74 };
75
85 explicit KPlotObject(const QColor &color = Qt::white, PlotType otype = Points, double size = 2.0, PointStyle ps = Circle);
86
91
95 PlotTypes plotTypes() const;
96
101 void setShowPoints(bool b);
102
107 void setShowLines(bool b);
108
113 void setShowBars(bool b);
114
118 double size() const;
119
124 void setSize(double s);
125
130
136
142 const QPen &pen() const;
143
148 void setPen(const QPen &p);
149
153 const QPen &linePen() const;
154
159 void setLinePen(const QPen &p);
160
164 const QPen &barPen() const;
165
170 void setBarPen(const QPen &p);
171
175 const QPen &labelPen() const;
176
181 void setLabelPen(const QPen &p);
182
186 const QBrush brush() const;
187
192 void setBrush(const QBrush &b);
193
197 const QBrush barBrush() const;
198
203 void setBarBrush(const QBrush &b);
204
208 QList<KPlotPoint *> points() const;
209
218 void addPoint(const QPointF &p, const QString &label = QString(), double barWidth = 0.0);
219
226
237 void addPoint(double x, double y, const QString &label = QString(), double barWidth = 0.0);
238
243 void removePoint(int index);
244
249
256 void draw(QPainter *p, KPlotWidget *pw);
257
258private:
259 class Private;
260 Private *const d;
261
262 Q_DISABLE_COPY(KPlotObject)
263};
264Q_DECLARE_OPERATORS_FOR_FLAGS(KPlotObject::PlotTypes)
265
266#endif
Encapsulates a data set to be plotted in a KPlotWidget.
Definition kplotobject.h:41
void draw(QPainter *p, KPlotWidget *pw)
Draw this KPlotObject on the given QPainter.
const QPen & barPen() const
~KPlotObject()
Destructor.
PointStyle pointStyle() const
PlotTypes plotTypes() const
void setSize(double s)
Set the size for plotted points in this object, in pixels.
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.
PointStyle
The available shape styles for plotted points.
Definition kplotobject.h:63
void setBarPen(const QPen &p)
Set the pen to use for drawing bars for this object The pen to use.
void removePoint(int index)
Remove the QPointF at position index from the list of points.
const QPen & linePen() const
void setLinePen(const QPen &p)
Set the pen to use for drawing lines for this object The pen to use.
void setPointStyle(PointStyle p)
Set a new style for drawing the points in this object.
double size() const
void setPen(const QPen &p)
Set the default pen for this object The pen to use.
void setShowBars(bool b)
Set whether bars will be drawn for this object.
const QPen & labelPen() const
void addPoint(KPlotPoint *p)
Add a given KPlotPoint to the object's list of points.
void setBrush(const QBrush &b)
Set the default brush to use for this object The brush to use.
QList< KPlotPoint * > points() const
void clearPoints()
Remove and destroy the points of this object.
const QPen & pen() const
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.
const QBrush barBrush() const
void setBarBrush(const QBrush &b)
Set the brush to use for drawing bars 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.
PlotType
The type classification of the KPlotObject.
Definition kplotobject.h:52
const QBrush brush() const
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.
KPlotObject(const QColor &color=Qt::white, PlotType otype=Points, double size=2.0, PointStyle ps=Circle)
Constructor.
Encapsulates a point in the plot.
Definition kplotpoint.h:28
Generic data plotting widget.
Definition kplotwidget.h:68