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

Plasma

  • sources
  • kde-4.12
  • kdelibs
  • 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 
29 namespace Plasma
30 {
31 
32 class SignalPlotterPrivate;
33 
34 struct PlotColor
35 {
36  QColor color;
37  QColor darkColor;
38 };
39 
45 class 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 
69 public:
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 
432 protected:
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 
448 private:
449  SignalPlotterPrivate *const d;
450  Q_PRIVATE_SLOT(d, void themeChanged())
451 };
452 
453 } // Plasma namespace
454 
455 #endif
Plasma::PlotColor::darkColor
QColor darkColor
Definition: signalplotter.h:37
QWidget
Plasma::SignalPlotter
Provides a signal plotter for plasma.
Definition: signalplotter.h:45
QStyleOptionGraphicsItem
Plasma::PlotColor::color
QColor color
Definition: signalplotter.h:36
Plasma::PlotColor
Definition: signalplotter.h:34
plasma_export.h
QGraphicsWidget
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:34 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



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