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
14c97a7e
Commit
14c97a7e
authored
Jul 21, 2011
by
LM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed very bad plot bugs preventing correct plotting, made QGC suspectible to plot crashes
parent
24aea41f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
20 deletions
+66
-20
QGCDataPlot2D.cc
src/ui/QGCDataPlot2D.cc
+64
-18
IncrementalPlot.cc
src/ui/linechart/IncrementalPlot.cc
+2
-2
No files found.
src/ui/QGCDataPlot2D.cc
View file @
14c97a7e
...
@@ -375,10 +375,25 @@ void QGCDataPlot2D::loadCsvLog(QString file, QString xAxisName, QString yAxisFil
...
@@ -375,10 +375,25 @@ void QGCDataPlot2D::loadCsvLog(QString file, QString xAxisName, QString yAxisFil
// Clear plot
// Clear plot
plot
->
removeData
();
plot
->
removeData
();
Q
Vector
<
double
>
xValues
;
Q
Map
<
QString
,
QVector
<
double
>*
>
xValues
;
QMap
<
QString
,
QVector
<
double
>*
>
yValues
;
QMap
<
QString
,
QVector
<
double
>*
>
yValues
;
curveNames
.
append
(
header
.
split
(
separator
,
QString
::
SkipEmptyParts
));
curveNames
.
append
(
header
.
split
(
separator
,
QString
::
SkipEmptyParts
));
// Eliminate any non-string curve names
for
(
int
i
=
0
;
i
<
curveNames
.
count
();
++
i
)
{
if
(
curveNames
.
at
(
i
).
length
()
==
0
||
curveNames
.
at
(
i
)
==
" "
||
curveNames
.
at
(
i
)
==
"
\n
"
||
curveNames
.
at
(
i
)
==
"
\t
"
||
curveNames
.
at
(
i
)
==
"
\r
"
)
{
// Remove bogus curve name
curveNames
.
removeAt
(
i
);
}
}
QString
curveName
;
QString
curveName
;
// Clear UI elements
// Clear UI elements
...
@@ -408,6 +423,7 @@ void QGCDataPlot2D::loadCsvLog(QString file, QString xAxisName, QString yAxisFil
...
@@ -408,6 +423,7 @@ void QGCDataPlot2D::loadCsvLog(QString file, QString xAxisName, QString yAxisFil
if
(
curveName
!=
xAxisFilter
)
{
if
(
curveName
!=
xAxisFilter
)
{
if
((
yAxisFilter
==
""
)
||
yAxisFilter
.
contains
(
curveName
))
{
if
((
yAxisFilter
==
""
)
||
yAxisFilter
.
contains
(
curveName
))
{
yValues
.
insert
(
curveName
,
new
QVector
<
double
>
());
yValues
.
insert
(
curveName
,
new
QVector
<
double
>
());
xValues
.
insert
(
curveName
,
new
QVector
<
double
>
());
// Add separator starting with second item
// Add separator starting with second item
if
(
curveNameIndex
>
0
&&
curveNameIndex
<
curveNames
.
count
())
{
if
(
curveNameIndex
>
0
&&
curveNameIndex
<
curveNames
.
count
())
{
ui
->
yAxis
->
setText
(
ui
->
yAxis
->
text
()
+
"|"
);
ui
->
yAxis
->
setText
(
ui
->
yAxis
->
text
()
+
"|"
);
...
@@ -425,29 +441,58 @@ void QGCDataPlot2D::loadCsvLog(QString file, QString xAxisName, QString yAxisFil
...
@@ -425,29 +441,58 @@ void QGCDataPlot2D::loadCsvLog(QString file, QString xAxisName, QString yAxisFil
double
x
,
y
;
double
x
,
y
;
while
(
!
in
.
atEnd
())
{
while
(
!
in
.
atEnd
())
{
QString
line
=
in
.
readLine
();
QString
line
=
in
.
readLine
();
QStringList
values
=
line
.
split
(
separator
,
QString
::
SkipEmptyParts
);
// Keep empty parts here - we still have to act on them
QStringList
values
=
line
.
split
(
separator
,
QString
::
KeepEmptyParts
);
foreach
(
curveName
,
curveNames
)
{
bool
headerfound
=
false
;
bool
okx
;
if
(
curveName
==
xAxisFilter
)
{
// First get header - ORDER MATTERS HERE!
foreach
(
curveName
,
curveNames
)
{
if
(
curveName
==
xAxisFilter
)
{
// X AXIS HANDLING
// X AXIS HANDLING
// Take this value as x if it is selected
// Take this value as x if it is selected
x
=
values
.
at
(
curveNames
.
indexOf
(
curveName
)).
toDouble
(
&
okx
);
QString
text
=
values
.
at
(
curveNames
.
indexOf
(
curveName
));
xValues
.
append
(
x
);
// - 1270125570000ULL);
text
=
text
.
trimmed
();
}
else
{
if
(
text
.
length
()
>
0
&&
text
!=
" "
&&
text
!=
"
\n
"
&&
text
!=
"
\r
"
&&
text
!=
"
\t
"
)
// Y AXIS HANDLING
{
bool
okx
=
true
;
x
=
text
.
toDouble
(
&
okx
);
if
(
okx
&&
!
isnan
(
x
)
&&
!
isinf
(
x
))
{
headerfound
=
true
;
}
}
}
}
if
(
yAxisFilter
==
""
||
yAxisFilter
.
contains
(
curveName
))
{
if
(
headerfound
)
// Only append y values where a valid x value is present
{
if
(
yValues
.
value
(
curveName
)
->
count
()
==
xValues
.
count
()
-
1
)
{
// Search again from start for values - ORDER MATTERS HERE!
foreach
(
curveName
,
curveNames
)
{
// Y AXIS HANDLING
if
(
curveName
!=
xAxisFilter
&&
(
yAxisFilter
==
""
||
yAxisFilter
.
contains
(
curveName
)))
{
bool
oky
;
bool
oky
;
int
curveNameIndex
=
curveNames
.
indexOf
(
curveName
);
int
curveNameIndex
=
curveNames
.
indexOf
(
curveName
);
if
(
values
.
count
()
>
curveNameIndex
)
{
if
(
values
.
count
()
>
curveNameIndex
)
y
=
values
.
at
(
curveNameIndex
).
toDouble
(
&
oky
);
{
QString
text
(
values
.
at
(
curveNameIndex
));
text
=
text
.
trimmed
();
y
=
text
.
toDouble
(
&
oky
);
// Only INF is really an issue for the plot
// NaN is fine
if
(
oky
&&
!
isnan
(
y
)
&&
!
isinf
(
y
)
&&
text
.
length
()
>
0
&&
text
!=
" "
&&
text
!=
"
\n
"
&&
text
!=
"
\r
"
&&
text
!=
"
\t
"
)
{
// Only append definitely valid values
xValues
.
value
(
curveName
)
->
append
(
x
);
yValues
.
value
(
curveName
)
->
append
(
y
);
yValues
.
value
(
curveName
)
->
append
(
y
);
}
}
}
}
...
@@ -459,8 +504,9 @@ void QGCDataPlot2D::loadCsvLog(QString file, QString xAxisName, QString yAxisFil
...
@@ -459,8 +504,9 @@ void QGCDataPlot2D::loadCsvLog(QString file, QString xAxisName, QString yAxisFil
// Add data array of each curve to the plot at once (fast)
// Add data array of each curve to the plot at once (fast)
// Iterates through all x-y curve combinations
// Iterates through all x-y curve combinations
for
(
int
i
=
0
;
i
<
yValues
.
count
();
i
++
)
{
for
(
int
i
=
0
;
i
<
yValues
.
count
();
i
++
)
{
plot
->
appendData
(
yValues
.
keys
().
at
(
i
),
xValues
.
data
(),
yValues
.
values
().
at
(
i
)
->
data
(),
xValues
.
count
());
plot
->
appendData
(
yValues
.
keys
().
at
(
i
),
xValues
.
values
().
at
(
i
)
->
data
(),
yValues
.
values
().
at
(
i
)
->
data
(),
xValues
.
values
().
at
(
i
)
->
count
());
}
}
plot
->
updateScale
();
plot
->
setStyleText
(
ui
->
style
->
currentText
());
plot
->
setStyleText
(
ui
->
style
->
currentText
());
}
}
...
...
src/ui/linechart/IncrementalPlot.cc
View file @
14c97a7e
...
@@ -259,9 +259,9 @@ void IncrementalPlot::resetScaling()
...
@@ -259,9 +259,9 @@ void IncrementalPlot::resetScaling()
void
IncrementalPlot
::
updateScale
()
void
IncrementalPlot
::
updateScale
()
{
{
const
double
margin
=
0.05
;
const
double
margin
=
0.05
;
double
xMinRange
=
xmin
+
(
xmin
*
margin
);
double
xMinRange
=
xmin
-
(
xmin
*
margin
);
double
xMaxRange
=
xmax
+
(
xmax
*
margin
);
double
xMaxRange
=
xmax
+
(
xmax
*
margin
);
double
yMinRange
=
ymin
+
(
ymin
*
margin
);
double
yMinRange
=
ymin
-
(
ymin
*
margin
);
double
yMaxRange
=
ymax
+
(
ymax
*
margin
);
double
yMaxRange
=
ymax
+
(
ymax
*
margin
);
if
(
symmetric
)
{
if
(
symmetric
)
{
double
xRange
=
xMaxRange
-
xMinRange
;
double
xRange
=
xMaxRange
-
xMinRange
;
...
...
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