~ubuntu-branches/ubuntu/vivid/knemo/vivid

« back to all changes in this revision

Viewing changes to src/knemod/ksignalplotter_p.h

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2013-05-11 18:56:39 UTC
  • mfrom: (2.2.5 experimental)
  • Revision ID: package-import@ubuntu.com-20130511185639-br5lb3qjrxtec0zf
Tags: 0.7.6-2
* Upload to unstable.
* Use canonical Vcs-Svn URI.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    This file is part of the KDE project
3
 
 
4
 
    Copyright (c) 2006 - 2009 John Tapsell <tapsell@kde.org>
5
 
 
6
 
    This program is free software; you can redistribute it and/or
7
 
    modify it under the terms of the GNU General Public
8
 
    License version 2 or at your option version 3 as published by
9
 
    the Free Software Foundation.
10
 
 
11
 
    This program is distributed in the hope that it will be useful,
12
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
    GNU General Public License for more details.
15
 
 
16
 
    You should have received a copy of the GNU General Public License
17
 
    along with this program; if not, write to the Free Software
18
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19
 
 
20
 
*/
21
 
 
22
 
//#define USE_QIMAGE
23
 
 
24
 
// SVG support causes it to crash at the moment :(
25
 
//#define SVG_SUPPORT
26
 
#ifdef SVG_SUPPORT
27
 
namespace Plasma
28
 
{
29
 
    class SVG;
30
 
}
31
 
#endif
32
 
 
33
 
class KSignalPlotter;
34
 
 
35
 
struct KSignalPlotterPrivate {
36
 
 
37
 
    KSignalPlotterPrivate( KSignalPlotter * q_ptr );
38
 
 
39
 
    void drawWidget(QPainter *p, const QRect &boundingBox, bool onlyDrawPlotter);
40
 
    void drawBackground(QPainter *p, const QRect & boundingBox) const;
41
 
    void drawThinFrame(QPainter *p, const QRect &boundingBox);
42
 
    void calculateNiceRange();
43
 
    void drawBeamToScrollableImage(QPainter *p, int index);
44
 
    void drawBeam(QPainter *p, const QRect &boundingBox, int horizontalScale, int index);
45
 
    void drawAxisText(QPainter *p, const QRect &boundingBox);
46
 
    void drawHorizontalLines(QPainter *p, const QRect &boundingBox) const;
47
 
    void drawVerticalLines(QPainter *p, const QRect &boundingBox, int correction=0) const;
48
 
 
49
 
    void recalculateMaxMinValueForSample(const QList<double>&sampleBuf, int time );
50
 
    void rescale();
51
 
    void updateDataBuffers();
52
 
    void setupStyle();
53
 
 
54
 
    /** Return the given value as a string, with the given precision */
55
 
    QString scaledValueAsString( double value, int precision) const;
56
 
    void addSample( const QList<double>& sampleBuf );
57
 
    /** We make the SVG renderer static so that an SVG renderer is shared among all of the images.  This is because a SVG renderer takes up a lot of memory, so we want to
58
 
     *  share them as much as we can */
59
 
#ifdef SVG_SUPPORT
60
 
    void updateSvgBackground(const QRect &boundingBox);
61
 
    static QHash<QString, Plasma::SVG *> sSvgRenderer;
62
 
#endif
63
 
    QString mSvgFilename;
64
 
 
65
 
    QPixmap mBackgroundImage;   ///A cache of the background of the widget. Contains the SVG or just white background with lines
66
 
#ifdef USE_QIMAGE
67
 
    QImage mScrollableImage;    ///The scrollable image for the widget.  Contains the SVG lines
68
 
#else
69
 
    QPixmap mScrollableImage;   ///The scrollable image for the widget.  Contains the SVG lines
70
 
#endif
71
 
    int mScrollOffset;          ///The scrollable image is, well, scrolled in a wrap-around window.  mScrollOffset determines where the left hand side of the mScrollableImage should be drawn relative to the right hand side of view.  0 <= mScrollOffset < mScrollableImage.width()
72
 
    double mMinValue;           ///The minimum value (unscaled) currently being displayed
73
 
    double mMaxValue;           ///The maximum value (unscaled) currently being displayed
74
 
 
75
 
    double mUserMinValue;               ///The minimum value (unscaled) set by changeRange().  This is the _maximum_ value that the range will start from.
76
 
    double mUserMaxValue;               ///The maximum value (unscaled) set by changeRange().  This is the _minimum_ value that the range will reach to.
77
 
    unsigned int mRescaleTime;          ///The number of data points passed since a value that is within 70% of the current maximum was found.  This is for scaling the graph
78
 
 
79
 
    double mNiceMinValue;       ///The minimum value rounded down to a 'nice' value
80
 
    double mNiceMaxValue;       ///The maximum value rounded up to a 'nice' value.  The idea is to round the value, say, 93 to 100.
81
 
    double mNiceRange;          /// mNiceMaxValue - mNiceMinValue
82
 
    int mPrecision;             ///The number of decimal place required to unambiguously label the axis
83
 
 
84
 
    double mScaleDownBy;        /// @see setScaleDownBy
85
 
    bool mUseAutoRange;         /// @see setUseAutoRange
86
 
 
87
 
    /**  Whether to show a white line on the left and bottom of the widget, for a 3D effect */
88
 
    bool mShowThinFrame;
89
 
 
90
 
    bool mShowVerticalLines;
91
 
    uint mVerticalLinesDistance;
92
 
    bool mVerticalLinesScroll;
93
 
    uint mVerticalLinesOffset;
94
 
    uint mHorizontalScale;
95
 
    int mHorizontalLinesCount;
96
 
 
97
 
    bool mShowHorizontalLines;
98
 
 
99
 
    bool mStackBeams;   /// Set to add the beam values onto each other
100
 
    int mFillOpacity;   /// Fill the area underneath the beams
101
 
 
102
 
    bool mShowAxis;
103
 
 
104
 
    QList < QList<double> > mBeamData; // Every item in the linked list contains a set of data points to plot.  The first item is the newest
105
 
    QList< QColor> mBeamColors;  //These colors match up against the QList<double>  in mBeamData
106
 
    QList< QColor> mBeamColorsDark;  //These colors match up against the QList<double> in mBeamData, and are darker than mBeamColors.  Done for gradient effects
107
 
 
108
 
    unsigned int mMaxSamples; //This is what mBeamData.size() should equal when full.  When we start off and have no data then mSamples will be higher.  If we resize the widget so it's smaller, then for a short while this will be smaller
109
 
    int mNewestIndex; //The index to the newest item added.  newestIndex+1   is the second newest, and so on
110
 
 
111
 
    KLocalizedString mUnit;
112
 
 
113
 
    int mAxisTextWidth;
114
 
    int mActualAxisTextWidth; // Sometimes there just is not enough room for all the requested axisTextWidth
115
 
    QRect mPlottingArea; /// The area in which the beams are drawn.  Saved to make update() more efficient
116
 
 
117
 
    bool mSmoothGraph; /// Whether to smooth the graph by averaging using the formula (value*2 + last_value)/3.
118
 
    KSignalPlotter *q;
119
 
    bool mAxisTextOverlapsPlotter; // Whether we need to redraw the axis text on every update
120
 
 
121
 
    bool mUseBitrate;
122
 
    int mMultiplier;
123
 
    int mVisibleBeams;
124
 
    QList<KLocalizedString> mByteUnits;
125
 
    QList<KLocalizedString> mBitUnits;
126
 
};