• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

Plasma

  • plasma
  • widgets
signalplotter.h
Go to the documentation of this file.
1/*
2 * KSysGuard, the KDE System Guard
3 *
4 * Copyright 1999 - 2001 Chris Schlaeger <cs@kde.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Library General Public License as
8 * published by the Free Software Foundation; either version 2, or
9 * (at your option) any later version.
10
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#ifndef PLASMA_SIGNALPLOTTER_H
23#define PLASMA_SIGNALPLOTTER_H
24
25#include <QtGui/QFont>
26#include <QtGui/QGraphicsWidget>
27#include <plasma/plasma_export.h>
28
29namespace Plasma
30{
31
32class SignalPlotterPrivate;
33
34struct PlotColor
35{
36 QColor color;
37 QColor darkColor;
38};
39
45class PLASMA_EXPORT SignalPlotter : public QGraphicsWidget
46{
47 Q_OBJECT
48 Q_PROPERTY(QString title READ title WRITE setTitle)
49 Q_PROPERTY(QString unit READ unit WRITE setUnit)
50 Q_PROPERTY(qreal scale READ scaledBy WRITE scale) // Note: The naming of the functions here is poor
51 Q_PROPERTY(bool useAutoRange READ useAutoRange WRITE setUseAutoRange)
52 Q_PROPERTY(uint horizontalScale READ horizontalScale WRITE setHorizontalScale)
53 Q_PROPERTY(bool showVerticalLines READ showVerticalLines WRITE setShowVerticalLines)
54 Q_PROPERTY(QColor verticalLinesColor READ verticalLinesColor WRITE setVerticalLinesColor)
55 Q_PROPERTY(uint verticalLinesDistance READ verticalLinesDistance WRITE setVerticalLinesDistance)
56 Q_PROPERTY(bool verticalLinesScroll READ verticalLinesScroll WRITE setVerticalLinesScroll)
57 Q_PROPERTY(bool showHorizontalLines READ showHorizontalLines WRITE setShowHorizontalLines)
58 Q_PROPERTY(QColor horizontalLinesColor READ horizontalLinesColor WRITE setHorizontalLinesColor)
59 Q_PROPERTY(QColor fontColor READ fontColor WRITE setFontColor)
60 Q_PROPERTY(QFont font READ font WRITE setFont)
61 Q_PROPERTY(uint horizontalLinesCount READ horizontalLinesCount WRITE setHorizontalLinesCount)
62 Q_PROPERTY(bool showLabels READ showLabels WRITE setShowLabels)
63 Q_PROPERTY(bool showTopBar READ showTopBar WRITE setShowTopBar)
64 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
65 Q_PROPERTY(QString svgBackground READ svgBackground WRITE setSvgBackground)
66 Q_PROPERTY(bool thinFrame READ thinFrame WRITE setThinFrame)
67 Q_PROPERTY(bool stackPlots READ stackPlots WRITE setStackPlots)
68
69public:
70 SignalPlotter(QGraphicsItem *parent = 0);
71 ~SignalPlotter();
72
79 Q_INVOKABLE void addPlot(const QColor &color);
80
87 Q_INVOKABLE void addSample(const QList<double> &samples);
88
102 Q_INVOKABLE void reorderPlots(const QList<uint>& newOrder);
103
108 Q_INVOKABLE void removePlot(uint pos);
109
115 QList<PlotColor> &plotColors();
116
121 void setTitle(const QString &title);
122
127 QString title() const;
128
134 void setUnit(const QString &unit);
135
140 QString unit() const;
141
149 void scale(qreal delta);
150
155 qreal scaledBy() const;
156
163 void setUseAutoRange(bool value);
164
170 bool useAutoRange() const;
171
185 void setVerticalRange(double min, double max);
186
191 double verticalMinValue() const;
192
197 double verticalMaxValue() const;
198
203 void setHorizontalScale(uint scale);
204
209 uint horizontalScale() const;
210
215 void setShowVerticalLines(bool value);
216
221 bool showVerticalLines() const;
222
227 void setVerticalLinesColor(const QColor &color);
228
233 QColor verticalLinesColor() const;
234
239 void setVerticalLinesDistance(uint distance);
240
245 uint verticalLinesDistance() const;
246
251 void setVerticalLinesScroll(bool value);
252
257 bool verticalLinesScroll() const;
258
263 void setShowHorizontalLines(bool value);
268 bool showHorizontalLines() const;
269
274 void setHorizontalLinesColor(const QColor &color);
275
280 QColor horizontalLinesColor() const;
281
286 void setFontColor(const QColor &color);
287
292 QColor fontColor() const;
293
298 void setFont(const QFont &font);
299
304 QFont font() const;
305
311 void setHorizontalLinesCount(uint count);
312
318 uint horizontalLinesCount() const;
319
324 void setShowLabels(bool value);
325
330 bool showLabels() const;
331
337 void setShowTopBar(bool value);
338
344 bool showTopBar() const;
345
351 void setBackgroundColor(const QColor &color);
352
358 QColor backgroundColor() const;
359
365 void setSvgBackground(const QString &filename);
366
372 QString svgBackground();
373
379 double lastValue(uint i) const;
380
386 QString lastValueAsString(uint i) const;
387
393 void setThinFrame(bool set);
394
400 bool thinFrame() const;
401
408 void setStackPlots(bool stack);
409
414 bool stackPlots() const;
415
424 QPixmap getSnapshotImage(uint width, uint height);
425
430 virtual void setGeometry(const QRectF &geometry);
431
432protected:
433 void updateDataBuffers();
434 void calculateNiceRange();
435
436 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
437
438 void drawWidget(QPainter *p, uint w, uint height, int horizontalScale);
439 void drawBackground(QPainter *p, int w, int h);
440 void drawThinFrame(QPainter *p, int w, int h);
441 void drawTopBarFrame(QPainter *p, int separatorX, int height);
442 void drawTopBarContents(QPainter *p, int x, int width, int height);
443 void drawVerticalLines(QPainter *p, int top, int w, int h);
444 void drawPlots(QPainter *p, int top, int w, int h, int horizontalScale);
445 void drawAxisText(QPainter *p, int top, int h);
446 void drawHorizontalLines(QPainter *p, int top, int w, int h);
447
448private:
449 SignalPlotterPrivate *const d;
450 Q_PRIVATE_SLOT(d, void themeChanged())
451};
452
453} // Plasma namespace
454
455#endif
Plasma::SignalPlotter::drawTopBarFrame
void drawTopBarFrame(QPainter *p, int separatorX, int height)
Definition signalplotter.cpp:756
Plasma::SignalPlotter::drawTopBarContents
void drawTopBarContents(QPainter *p, int x, int width, int height)
Definition signalplotter.cpp:768
Plasma::SignalPlotter::useAutoRange
bool useAutoRange
Definition signalplotter.h:51
Plasma::SignalPlotter::verticalMaxValue
double verticalMaxValue() const
Get the max value of the vertical axis.
Definition signalplotter.cpp:323
Plasma::SignalPlotter::drawHorizontalLines
void drawHorizontalLines(QPainter *p, int top, int w, int h)
Definition signalplotter.cpp:1077
Plasma::SignalPlotter::setSvgBackground
void setSvgBackground(const QString &filename)
The filename of the svg background.
Definition signalplotter.cpp:497
Plasma::SignalPlotter::getSnapshotImage
QPixmap getSnapshotImage(uint width, uint height)
Render the graph to the specified width and height, and return it as an image.
Definition signalplotter.cpp:571
Plasma::SignalPlotter::setVerticalLinesScroll
void setVerticalLinesScroll(bool value)
Whether the vertical lines move with the data.
Definition signalplotter.cpp:386
Plasma::SignalPlotter::setHorizontalLinesColor
void setHorizontalLinesColor(const QColor &color)
The color of the horizontal grid lines.
Definition signalplotter.cpp:424
Plasma::SignalPlotter::reorderPlots
Q_INVOKABLE void reorderPlots(const QList< uint > &newOrder)
Reorder the plots into the order given.
Definition signalplotter.cpp:222
Plasma::SignalPlotter::verticalMinValue
double verticalMinValue() const
Get the min value of the vertical axis.
Definition signalplotter.cpp:318
Plasma::SignalPlotter::horizontalLinesCount
uint horizontalLinesCount
Definition signalplotter.h:61
Plasma::SignalPlotter::showHorizontalLines
bool showHorizontalLines
Definition signalplotter.h:57
Plasma::SignalPlotter::scaledBy
qreal scaledBy() const
Amount scaled down by.
Definition signalplotter.cpp:287
Plasma::SignalPlotter::svgBackground
QString svgBackground
Definition signalplotter.h:65
Plasma::SignalPlotter::setGeometry
virtual void setGeometry(const QRectF &geometry)
Overwritten to be notified of size changes.
Definition signalplotter.cpp:582
Plasma::SignalPlotter::font
QFont font
Definition signalplotter.h:60
Plasma::SignalPlotter::setShowLabels
void setShowLabels(bool value)
Whether to show the vertical axis labels.
Definition signalplotter.cpp:453
Plasma::SignalPlotter::lastValue
double lastValue(uint i) const
Return the last value that we have for plot i.
Definition signalplotter.cpp:1087
Plasma::SignalPlotter::setShowVerticalLines
void setShowVerticalLines(bool value)
Whether to draw the vertical grid lines.
Definition signalplotter.cpp:344
Plasma::SignalPlotter::drawWidget
void drawWidget(QPainter *p, uint w, uint height, int horizontalScale)
Definition signalplotter.cpp:606
Plasma::SignalPlotter::stackPlots
bool stackPlots
Definition signalplotter.h:67
Plasma::SignalPlotter::title
QString title
Definition signalplotter.h:48
Plasma::SignalPlotter::unit
QString unit
Definition signalplotter.h:49
Plasma::SignalPlotter::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Definition signalplotter.cpp:589
Plasma::SignalPlotter::plotColors
QList< PlotColor > & plotColors()
Return the list of plot colors, in the order that the plots were added (or later reordered).
Definition signalplotter.cpp:258
Plasma::SignalPlotter::removePlot
Q_INVOKABLE void removePlot(uint pos)
Removes the plot at the specified index.
Definition signalplotter.cpp:263
Plasma::SignalPlotter::SignalPlotter
SignalPlotter(QGraphicsItem *parent=0)
Definition signalplotter.cpp:116
Plasma::SignalPlotter::drawPlots
void drawPlots(QPainter *p, int top, int w, int h, int horizontalScale)
Definition signalplotter.cpp:807
Plasma::SignalPlotter::addPlot
Q_INVOKABLE void addPlot(const QColor &color)
Add a new line to the graph plotter, with the specified color.
Definition signalplotter.cpp:169
Plasma::SignalPlotter::drawAxisText
void drawAxisText(QPainter *p, int top, int h)
Definition signalplotter.cpp:1038
Plasma::SignalPlotter::updateDataBuffers
void updateDataBuffers()
Definition signalplotter.cpp:558
Plasma::SignalPlotter::showVerticalLines
bool showVerticalLines
Definition signalplotter.h:53
Plasma::SignalPlotter::setUseAutoRange
void setUseAutoRange(bool value)
Set the minimum and maximum values on the vertical axis automatically from the data available.
Definition signalplotter.cpp:306
Plasma::SignalPlotter::addSample
Q_INVOKABLE void addSample(const QList< double > &samples)
Add data to the graph, and advance the graph by one time period.
Definition signalplotter.cpp:182
Plasma::SignalPlotter::drawBackground
void drawBackground(QPainter *p, int w, int h)
Definition signalplotter.cpp:699
Plasma::SignalPlotter::setBackgroundColor
void setBackgroundColor(const QColor &color)
The color to set the background.
Definition signalplotter.cpp:519
Plasma::SignalPlotter::verticalLinesScroll
bool verticalLinesScroll
Definition signalplotter.h:56
Plasma::SignalPlotter::showTopBar
bool showTopBar
Definition signalplotter.h:63
Plasma::SignalPlotter::backgroundColor
QColor backgroundColor
Definition signalplotter.h:64
Plasma::SignalPlotter::drawThinFrame
void drawThinFrame(QPainter *p, int w, int h)
Definition signalplotter.cpp:709
Plasma::SignalPlotter::lastValueAsString
QString lastValueAsString(uint i) const
Return a translated string like: "34 %" or "100 KB" for plot i.
Definition signalplotter.cpp:1095
Plasma::SignalPlotter::setVerticalRange
void setVerticalRange(double min, double max)
Change the minimum and maximum values drawn on the graph.
Definition signalplotter.cpp:251
Plasma::SignalPlotter::setTitle
void setTitle(const QString &title)
Set the title of the graph.
Definition signalplotter.cpp:292
Plasma::SignalPlotter::setHorizontalLinesCount
void setHorizontalLinesCount(uint count)
The number of horizontal lines to draw.
Definition signalplotter.cpp:438
Plasma::SignalPlotter::drawVerticalLines
void drawVerticalLines(QPainter *p, int top, int w, int h)
Definition signalplotter.cpp:799
Plasma::SignalPlotter::horizontalLinesColor
QColor horizontalLinesColor
Definition signalplotter.h:58
Plasma::SignalPlotter::setUnit
void setUnit(const QString &unit)
Set the units.
Definition signalplotter.cpp:164
Plasma::SignalPlotter::thinFrame
bool thinFrame
Definition signalplotter.h:66
Plasma::SignalPlotter::setFont
void setFont(const QFont &font)
The font used for the axis.
Definition signalplotter.cpp:481
Plasma::SignalPlotter::fontColor
QColor fontColor
Definition signalplotter.h:59
Plasma::SignalPlotter::setThinFrame
void setThinFrame(bool set)
Whether to show a white line on the left and bottom of the widget, for a 3D effect.
Definition signalplotter.cpp:533
Plasma::SignalPlotter::scale
qreal scale
Definition signalplotter.h:50
Plasma::SignalPlotter::setVerticalLinesColor
void setVerticalLinesColor(const QColor &color)
The color of the vertical grid lines.
Definition signalplotter.cpp:358
Plasma::SignalPlotter::setVerticalLinesDistance
void setVerticalLinesDistance(uint distance)
The horizontal distance between the vertical grid lines.
Definition signalplotter.cpp:372
Plasma::SignalPlotter::setShowHorizontalLines
void setShowHorizontalLines(bool value)
Whether to draw the horizontal grid lines.
Definition signalplotter.cpp:400
Plasma::SignalPlotter::setShowTopBar
void setShowTopBar(bool value)
Whether to show the title etc at the top.
Definition signalplotter.cpp:467
Plasma::SignalPlotter::setFontColor
void setFontColor(const QColor &color)
The color of the font used for the axis.
Definition signalplotter.cpp:414
Plasma::SignalPlotter::verticalLinesDistance
uint verticalLinesDistance
Definition signalplotter.h:55
Plasma::SignalPlotter::setStackPlots
void setStackPlots(bool stack)
Whether to stack the plots on top of each other.
Definition signalplotter.cpp:547
Plasma::SignalPlotter::horizontalScale
uint horizontalScale
Definition signalplotter.h:52
Plasma::SignalPlotter::setHorizontalScale
void setHorizontalScale(uint scale)
Set the number of pixels horizontally between data points.
Definition signalplotter.cpp:328
Plasma::SignalPlotter::showLabels
bool showLabels
Definition signalplotter.h:62
Plasma::SignalPlotter::calculateNiceRange
void calculateNiceRange()
Definition signalplotter.cpp:718
Plasma::SignalPlotter::verticalLinesColor
QColor verticalLinesColor
Definition signalplotter.h:54
QGraphicsWidget
QStyleOptionGraphicsItem
QWidget
Plasma
Namespace for everything in libplasma.
Definition abstractdialogmanager.cpp:25
plasma_export.h
Plasma::PlotColor
Definition signalplotter.h:35
Plasma::PlotColor::color
QColor color
Definition signalplotter.h:36
Plasma::PlotColor::darkColor
QColor darkColor
Definition signalplotter.h:37
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 17 2025 00:00:00 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal