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
0ea78c2f
Commit
0ea78c2f
authored
Apr 30, 2014
by
Lorenz Meier
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #630 from treymarc/widget_xyplot_timeserie_patch
add option "time serie" option to the XYPlot widget
parents
6de98807
78283634
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
13 deletions
+35
-13
QGCXYPlot.cc
src/ui/designer/QGCXYPlot.cc
+32
-12
QGCXYPlot.h
src/ui/designer/QGCXYPlot.h
+3
-1
No files found.
src/ui/designer/QGCXYPlot.cc
View file @
0ea78c2f
...
...
@@ -33,23 +33,28 @@ public:
/** Append data, returning the number of removed items */
int
appendData
(
const
QPointF
&
data
)
{
if
(
!
minMaxSet
)
{
m_data
.
append
(
data
);
int
removed
=
0
;
while
(
m_data
.
size
()
>
m_maxShowPoints
)
{
++
removed
;
m_data
.
removeFirst
();
}
if
(
!
minMaxSet
)
{
xmin
=
xmax
=
data
.
x
();
ymin
=
ymax
=
data
.
y
();
minMaxSet
=
true
;
}
else
if
(
m_autoScale
)
{
xmin
=
qMin
(
qreal
(
xmin
),
data
.
x
());
previousTime
=
xmin
;
}
else
if
(
m_autoScale
)
{
if
(
m_autoScaleTime
)
{
xmin
+=
removed
*
(
data
.
x
()
-
previousTime
);
previousTime
=
data
.
x
();
}
else
{
xmin
=
qMin
(
qreal
(
xmin
),
data
.
x
());
}
xmax
=
qMax
(
qreal
(
xmax
),
data
.
x
());
ymin
=
qMin
(
qreal
(
ymin
),
data
.
y
());
ymax
=
qMax
(
qreal
(
ymax
),
data
.
y
());
}
m_data
.
append
(
data
);
int
removed
=
0
;
while
(
m_data
.
size
()
>
m_maxStorePoints
)
{
++
removed
;
m_data
.
removeFirst
();
}
itemChanged
();
return
removed
;
}
...
...
@@ -61,6 +66,10 @@ public:
void
setColor
(
const
QColor
&
color
)
{
m_color
=
color
;
}
void
setTimeSerie
(
bool
state
)
{
clear
();
m_autoScaleTime
=
state
;
}
void
unsetMinMax
()
{
if
(
m_autoScale
)
return
;
...
...
@@ -70,7 +79,7 @@ public:
minMaxSet
=
false
;
else
{
minMaxSet
=
true
;
xmax
=
xmin
=
m_data
.
at
(
0
).
x
();
previousTime
=
xmax
=
xmin
=
m_data
.
at
(
0
).
x
();
ymax
=
ymin
=
m_data
.
at
(
0
).
y
();
for
(
int
i
=
1
;
i
<
m_data
.
size
();
i
++
)
{
xmin
=
qMin
(
qreal
(
xmin
),
m_data
.
at
(
i
).
x
());
...
...
@@ -164,12 +173,14 @@ private:
int
m_smoothPoints
;
/** Number of points to average across */
mutable
QColor
m_color
;
double
previousTime
;
double
xmin
;
double
xmax
;
double
ymin
;
double
ymax
;
bool
minMaxSet
;
bool
m_autoScale
;
bool
m_autoScaleTime
;
int
m_startIndex
;
};
...
...
@@ -220,6 +231,7 @@ QGCXYPlot::QGCXYPlot(QWidget *parent) :
connect
(
ui
->
minY
,
SIGNAL
(
valueChanged
(
double
)),
this
,
SLOT
(
updateMinMaxSettings
()));
connect
(
ui
->
maxY
,
SIGNAL
(
valueChanged
(
double
)),
this
,
SLOT
(
updateMinMaxSettings
()));
connect
(
ui
->
automaticAxisRange
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
updateMinMaxSettings
()));
connect
(
ui
->
timeAxisRange
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
setTimeAxis
()));
connect
(
ui
->
maxDataShowSpinBox
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
updateMinMaxSettings
()));
connect
(
ui
->
maxDataStoreSpinBox
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
updateMinMaxSettings
()));
connect
(
ui
->
smoothSpinBox
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
updateMinMaxSettings
()));
...
...
@@ -261,6 +273,7 @@ void QGCXYPlot::setEditMode(bool editMode)
ui
->
maxDataShowSpinBox
->
setVisible
(
editMode
);
ui
->
maxDataStoreSpinBox
->
setVisible
(
editMode
);
ui
->
automaticAxisRange
->
setVisible
(
editMode
);
ui
->
timeAxisRange
->
setVisible
(
editMode
);
ui
->
lblSmooth
->
setVisible
(
editMode
);
ui
->
smoothSpinBox
->
setVisible
(
editMode
);
...
...
@@ -286,7 +299,7 @@ void QGCXYPlot::writeSettings(QSettings& settings)
settings
.
setValue
(
"QGC_XYPLOT_MAXDATA_SHOW"
,
ui
->
maxDataShowSpinBox
->
value
());
settings
.
setValue
(
"QGC_XYPLOT_AUTO"
,
ui
->
automaticAxisRange
->
isChecked
());
settings
.
setValue
(
"QGC_XYPLOT_SMOOTH"
,
ui
->
smoothSpinBox
->
value
());
settings
.
setValue
(
"QGC_XYPLOT_TIME"
,
ui
->
timeAxisRange
->
isChecked
());
settings
.
sync
();
}
void
QGCXYPlot
::
readSettings
(
const
QString
&
pre
,
const
QVariantMap
&
settings
)
...
...
@@ -301,6 +314,7 @@ void QGCXYPlot::readSettings(const QString& pre,const QVariantMap& settings)
ui
->
maxDataStoreSpinBox
->
setValue
(
settings
.
value
(
pre
+
"QGC_XYPLOT_MAXDATA_STORE"
,
10000
).
toInt
());
ui
->
maxDataShowSpinBox
->
setValue
(
settings
.
value
(
pre
+
"QGC_XYPLOT_MAXDATA_SHOW"
,
15
).
toInt
());
ui
->
smoothSpinBox
->
setValue
(
settings
.
value
(
pre
+
"QGC_XYPLOT_SMOOTH"
,
1
).
toInt
());
ui
->
timeAxisRange
->
setChecked
(
settings
.
value
(
pre
+
"QGC_XYPLOT_TIME"
,
true
).
toBool
());
plot
->
setAxisTitle
(
QwtPlot
::
xBottom
,
ui
->
editXParam
->
currentText
());
plot
->
setAxisTitle
(
QwtPlot
::
yLeft
,
ui
->
editYParam
->
currentText
());
updateMinMaxSettings
();
...
...
@@ -318,6 +332,7 @@ void QGCXYPlot::readSettings(const QSettings& settings)
ui
->
maxDataStoreSpinBox
->
setValue
(
settings
.
value
(
"QGC_XYPLOT_MAXDATA_STORE"
,
10000
).
toInt
());
ui
->
maxDataShowSpinBox
->
setValue
(
settings
.
value
(
"QGC_XYPLOT_MAXDATA_SHOW"
,
15
).
toInt
());
ui
->
smoothSpinBox
->
setValue
(
settings
.
value
(
"QGC_XYPLOT_SMOOTH"
,
1
).
toInt
());
ui
->
timeAxisRange
->
setChecked
(
settings
.
value
(
"QGC_XYPLOT_TIME"
,
true
).
toBool
());
plot
->
setAxisTitle
(
QwtPlot
::
xBottom
,
ui
->
editXParam
->
currentText
());
plot
->
setAxisTitle
(
QwtPlot
::
yLeft
,
ui
->
editYParam
->
currentText
());
updateMinMaxSettings
();
...
...
@@ -412,6 +427,11 @@ void QGCXYPlot::updateMinMaxSettings()
xycurve
->
setSmoothPoints
(
ui
->
smoothSpinBox
->
value
());
}
void
QGCXYPlot
::
setTimeAxis
()
{
xycurve
->
setTimeSerie
(
ui
->
timeAxisRange
->
isChecked
());
}
void
QGCXYPlot
::
on_maxDataShowSpinBox_valueChanged
(
int
value
)
{
ui
->
maxDataStoreSpinBox
->
setMinimum
(
value
);
...
...
src/ui/designer/QGCXYPlot.h
View file @
0ea78c2f
...
...
@@ -31,10 +31,11 @@ public slots:
void
styleChanged
(
MainWindow
::
QGC_MAINWINDOW_STYLE
style
);
void
updateMinMaxSettings
();
private
slots
:
void
on_maxDataShowSpinBox_valueChanged
(
int
value
);
void
on_stopStartButton_toggled
(
bool
checked
);
void
setTimeAxis
();
void
on_timeScrollBar_valueChanged
(
int
value
);
private:
...
...
@@ -42,6 +43,7 @@ private:
QwtPlot
*
plot
;
XYPlotCurve
*
xycurve
;
bool
autoScaleTime
;
double
x
;
/**< Last unused value for the x-coordinate */
quint64
x_timestamp_us
;
/**< Timestamp that we last recieved a value for x */
bool
x_valid
;
/**< Whether we have recieved an x value but so far no corresponding y value */
...
...
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