Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
cfce88d5
Commit
cfce88d5
authored
Dec 28, 2010
by
lm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added variance calculation to plot window
parent
e45ffc80
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
2 deletions
+49
-2
LinechartPlot.cc
src/ui/linechart/LinechartPlot.cc
+27
-2
LinechartPlot.h
src/ui/linechart/LinechartPlot.h
+5
-0
LinechartWidget.cc
src/ui/linechart/LinechartWidget.cc
+16
-0
LinechartWidget.h
src/ui/linechart/LinechartWidget.h
+1
-0
No files found.
src/ui/linechart/LinechartPlot.cc
View file @
cfce88d5
...
...
@@ -198,6 +198,14 @@ double LinechartPlot::getMedian(QString id)
return
data
.
value
(
id
)
->
getMedian
();
}
/**
* @param id curve identifier
*/
double
LinechartPlot
::
getVariance
(
QString
id
)
{
return
data
.
value
(
id
)
->
getVariance
();
}
int
LinechartPlot
::
getAverageWindow
()
{
return
averageWindowSize
;
...
...
@@ -743,8 +751,9 @@ TimeSeriesData::TimeSeriesData(QwtPlot* plot, QString friendlyName, quint64 plot
maxValue
(
DBL_MIN
),
zeroValue
(
0
),
count
(
0
),
mean
(
0.00
),
median
(
0.00
),
mean
(
0.0
),
median
(
0.0
),
variance
(
0.0
),
averageWindow
(
50
)
{
this
->
plot
=
plot
;
...
...
@@ -802,6 +811,14 @@ void TimeSeriesData::append(quint64 ms, double value)
medianList
.
append
(
this
->
value
[
count
-
i
]);
}
mean
=
mean
/
static_cast
<
double
>
(
qMin
(
averageWindow
,
static_cast
<
unsigned
int
>
(
count
)));
this
->
variance
=
0
;
for
(
unsigned
int
i
=
0
;
(
i
<
averageWindow
)
&&
(((
int
)
count
-
(
int
)
i
)
>=
0
);
++
i
)
{
this
->
variance
+=
(
this
->
value
[
count
-
i
]
-
mean
)
*
(
this
->
value
[
count
-
i
]
-
mean
);
}
this
->
variance
=
this
->
variance
/
static_cast
<
double
>
(
qMin
(
averageWindow
,
static_cast
<
unsigned
int
>
(
count
)));
qSort
(
medianList
);
if
(
medianList
.
count
()
>
2
)
...
...
@@ -901,6 +918,14 @@ double TimeSeriesData::getMedian()
return
median
;
}
/**
* @return the variance
*/
double
TimeSeriesData
::
getVariance
()
{
return
variance
;
}
double
TimeSeriesData
::
getCurrentValue
()
{
return
lastValue
;
...
...
src/ui/linechart/LinechartPlot.h
View file @
cfce88d5
...
...
@@ -132,6 +132,8 @@ public:
double
getMean
();
/** @brief Get the short-term median */
double
getMedian
();
/** @brief Get the short-term variance */
double
getVariance
();
/** @brief Get the current value */
double
getCurrentValue
();
void
setZeroValue
(
double
zeroValue
);
...
...
@@ -166,6 +168,7 @@ private:
QwtArray
<
double
>
value
;
double
mean
;
double
median
;
double
variance
;
unsigned
int
averageWindow
;
QwtArray
<
double
>
outputMs
;
QwtArray
<
double
>
outputValue
;
...
...
@@ -208,6 +211,8 @@ public:
double
getMean
(
QString
id
);
/** @brief Get the short-term median of a curve */
double
getMedian
(
QString
id
);
/** @brief Get the short-term variance of a curve */
double
getVariance
(
QString
id
);
/** @brief Get the last inserted value */
double
getCurrentValue
(
QString
id
);
...
...
src/ui/linechart/LinechartWidget.cc
View file @
cfce88d5
...
...
@@ -63,6 +63,7 @@ listedCurves(new QList<QString>()),
curveLabels
(
new
QMap
<
QString
,
QLabel
*>
()),
curveMeans
(
new
QMap
<
QString
,
QLabel
*>
()),
curveMedians
(
new
QMap
<
QString
,
QLabel
*>
()),
curveVariances
(
new
QMap
<
QString
,
QLabel
*>
()),
curveMenu
(
new
QMenu
(
this
)),
logFile
(
new
QFile
()),
logindex
(
1
),
...
...
@@ -268,6 +269,13 @@ void LinechartWidget::refresh()
// str.sprintf("%+.2f", activePlot->getMedian(k.key()));
// k.value()->setText(str);
// }
QMap
<
QString
,
QLabel
*>::
iterator
l
;
for
(
l
=
curveVariances
->
begin
();
l
!=
curveVariances
->
end
();
++
l
)
{
// Variance
str
.
sprintf
(
"%+.5f"
,
activePlot
->
getVariance
(
l
.
key
()));
l
.
value
()
->
setText
(
str
);
}
}
...
...
@@ -388,6 +396,7 @@ QWidget* LinechartWidget::createCurveItem(QString curve)
QLabel
*
label
;
QLabel
*
value
;
QLabel
*
mean
;
QLabel
*
variance
;
form
->
setAutoFillBackground
(
false
);
horizontalLayout
=
new
QHBoxLayout
(
form
);
horizontalLayout
->
setSpacing
(
5
);
...
...
@@ -437,6 +446,12 @@ QWidget* LinechartWidget::createCurveItem(QString curve)
// curveMedians->insert(curve, median);
// horizontalLayout->addWidget(median);
// Variance
variance
=
new
QLabel
(
form
);
variance
->
setNum
(
0.00
);
curveVariances
->
insert
(
curve
,
variance
);
horizontalLayout
->
addWidget
(
variance
);
/* Color picker
QColor color = QColorDialog::getColor(Qt::green, this);
if (color.isValid()) {
...
...
@@ -453,6 +468,7 @@ QWidget* LinechartWidget::createCurveItem(QString curve)
horizontalLayout
->
setStretchFactor
(
value
,
50
);
horizontalLayout
->
setStretchFactor
(
mean
,
50
);
// horizontalLayout->setStretchFactor(median, 50);
horizontalLayout
->
setStretchFactor
(
variance
,
50
);
// Connect actions
QObject
::
connect
(
checkBox
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
takeButtonClick
(
bool
)));
...
...
src/ui/linechart/LinechartWidget.h
View file @
cfce88d5
...
...
@@ -109,6 +109,7 @@ protected:
QMap
<
QString
,
QLabel
*>*
curveLabels
;
///< References to the curve labels
QMap
<
QString
,
QLabel
*>*
curveMeans
;
///< References to the curve means
QMap
<
QString
,
QLabel
*>*
curveMedians
;
///< References to the curve medians
QMap
<
QString
,
QLabel
*>*
curveVariances
;
///< References to the curve variances
QWidget
*
curvesWidget
;
///< The QWidget containing the curve selection button
QVBoxLayout
*
curvesWidgetLayout
;
///< The layout for the curvesWidget QWidget
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment