2
This file is part of the KDE project
4
Copyright (c) 2006 - 2009 John Tapsell <tapsell@kde.org>
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.
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.
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.
24
// SVG support causes it to crash at the moment :(
35
struct KSignalPlotterPrivate {
37
KSignalPlotterPrivate( KSignalPlotter * q_ptr );
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;
49
void recalculateMaxMinValueForSample(const QList<double>&sampleBuf, int time );
51
void updateDataBuffers();
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 */
60
void updateSvgBackground(const QRect &boundingBox);
61
static QHash<QString, Plasma::SVG *> sSvgRenderer;
65
QPixmap mBackgroundImage; ///A cache of the background of the widget. Contains the SVG or just white background with lines
67
QImage mScrollableImage; ///The scrollable image for the widget. Contains the SVG lines
69
QPixmap mScrollableImage; ///The scrollable image for the widget. Contains the SVG lines
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
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
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
84
double mScaleDownBy; /// @see setScaleDownBy
85
bool mUseAutoRange; /// @see setUseAutoRange
87
/** Whether to show a white line on the left and bottom of the widget, for a 3D effect */
90
bool mShowVerticalLines;
91
uint mVerticalLinesDistance;
92
bool mVerticalLinesScroll;
93
uint mVerticalLinesOffset;
94
uint mHorizontalScale;
95
int mHorizontalLinesCount;
97
bool mShowHorizontalLines;
99
bool mStackBeams; /// Set to add the beam values onto each other
100
int mFillOpacity; /// Fill the area underneath the beams
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
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
111
KLocalizedString mUnit;
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
117
bool mSmoothGraph; /// Whether to smooth the graph by averaging using the formula (value*2 + last_value)/3.
119
bool mAxisTextOverlapsPlotter; // Whether we need to redraw the axis text on every update
124
QList<KLocalizedString> mByteUnits;
125
QList<KLocalizedString> mBitUnits;