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
3262f6fc
Commit
3262f6fc
authored
Dec 21, 2016
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Charting Tweaks
parent
940a87b5
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
153 additions
and
179 deletions
+153
-179
Linechart.ui
src/ui/Linechart.ui
+15
-6
ChartPlot.cc
src/ui/linechart/ChartPlot.cc
+47
-63
ChartPlot.h
src/ui/linechart/ChartPlot.h
+9
-8
IncrementalPlot.cc
src/ui/linechart/IncrementalPlot.cc
+16
-16
LinechartPlot.cc
src/ui/linechart/LinechartPlot.cc
+16
-16
LinechartWidget.cc
src/ui/linechart/LinechartWidget.cc
+50
-69
LinechartWidget.h
src/ui/linechart/LinechartWidget.h
+0
-1
No files found.
src/ui/Linechart.ui
View file @
3262f6fc
...
...
@@ -29,7 +29,16 @@
<string
notr=
"true"
/>
</property>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
>
<property
name=
"margin"
>
<property
name=
"leftMargin"
>
<number>
6
</number>
</property>
<property
name=
"topMargin"
>
<number>
6
</number>
</property>
<property
name=
"rightMargin"
>
<number>
6
</number>
</property>
<property
name=
"bottomMargin"
>
<number>
6
</number>
</property>
<item>
...
...
@@ -103,8 +112,8 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
8
84
</width>
<height>
4
91
</height>
<width>
8
79
</width>
<height>
4
62
</height>
</rect>
</property>
</widget>
...
...
@@ -113,7 +122,7 @@
<item
row=
"3"
column=
"0"
>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_2"
>
<property
name=
"spacing"
>
<number>
2
</number>
<number>
4
</number>
</property>
<item>
<widget
class=
"QLineEdit"
name=
"plotFilterLineEdit"
>
...
...
@@ -139,7 +148,7 @@
<item>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_3"
>
<property
name=
"spacing"
>
<number>
0
</number>
<number>
6
</number>
</property>
<item>
<widget
class=
"QCheckBox"
name=
"shortNameCheckBox"
>
...
...
@@ -172,7 +181,7 @@
<item>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_4"
>
<property
name=
"spacing"
>
<number>
0
</number>
<number>
6
</number>
</property>
<property
name=
"sizeConstraint"
>
<enum>
QLayout::SetMinimumSize
</enum>
...
...
src/ui/linechart/ChartPlot.cc
View file @
3262f6fc
...
...
@@ -2,80 +2,72 @@
#include "QGCApplication.h"
const
QColor
ChartPlot
::
baseColors
[
numColors
]
=
{
QColor
(
242
,
255
,
128
),
QColor
(
70
,
80
,
242
),
QColor
(
232
,
33
,
47
),
QColor
(
116
,
251
,
110
),
QColor
(
81
,
183
,
244
),
QColor
(
234
,
38
,
107
),
QColor
(
92
,
247
,
217
),
QColor
(
151
,
59
,
239
),
QColor
(
231
,
72
,
28
),
QColor
(
236
,
48
,
221
),
QColor
(
75
,
133
,
243
),
QColor
(
203
,
254
,
121
),
QColor
(
104
,
64
,
240
),
QColor
(
200
,
54
,
238
),
QColor
(
104
,
250
,
138
),
QColor
(
235
,
43
,
165
),
QColor
(
98
,
248
,
176
),
QColor
(
161
,
252
,
116
),
QColor
(
87
,
231
,
246
),
QColor
(
230
,
126
,
23
)
QColor
(
242
,
255
,
128
),
QColor
(
70
,
80
,
242
),
QColor
(
232
,
33
,
47
),
QColor
(
116
,
251
,
110
),
QColor
(
81
,
183
,
244
),
QColor
(
234
,
38
,
107
),
QColor
(
92
,
247
,
217
),
QColor
(
151
,
59
,
239
),
QColor
(
231
,
72
,
28
),
QColor
(
236
,
48
,
221
),
QColor
(
75
,
133
,
243
),
QColor
(
203
,
254
,
121
),
QColor
(
104
,
64
,
240
),
QColor
(
200
,
54
,
238
),
QColor
(
104
,
250
,
138
),
QColor
(
235
,
43
,
165
),
QColor
(
98
,
248
,
176
),
QColor
(
161
,
252
,
116
),
QColor
(
87
,
231
,
246
),
QColor
(
230
,
126
,
23
)
};
ChartPlot
::
ChartPlot
(
QWidget
*
parent
)
:
ChartPlot
::
ChartPlot
(
QWidget
*
parent
)
:
QwtPlot
(
parent
),
nextColorIndex
(
0
),
symbolWidth
(
2.0
f
),
curveWidth
(
2.0
f
),
gridWidth
(
0.8
f
)
_
nextColorIndex
(
0
),
_
symbolWidth
(
2.0
f
),
_
curveWidth
(
2.0
f
),
_
gridWidth
(
0.8
f
)
{
// Initialize the list of curves.
curves
=
QMap
<
QString
,
QwtPlotCurve
*>
();
_curves
=
QMap
<
QString
,
QwtPlotCurve
*>
();
// Set the grid. The colorscheme was already set in generateColorScheme().
grid
=
new
QwtPlotGrid
;
grid
->
enableXMin
(
true
);
grid
->
attach
(
this
);
colors
=
QList
<
QColor
>
();
_grid
=
new
QwtPlotGrid
;
_grid
->
enableXMin
(
true
);
_grid
->
attach
(
this
);
_colors
=
QList
<
QColor
>
();
///> Color map for plots, includes 20 colors
///> Map will start from beginning when the first 20 colors are exceeded
for
(
int
i
=
0
;
i
<
numColors
;
++
i
)
{
colors
.
append
(
baseColors
[
i
]);
for
(
int
i
=
0
;
i
<
numColors
;
++
i
)
{
_colors
.
append
(
baseColors
[
i
]);
}
// Now that all objects have been initialized, color everything.
styleChanged
(
qgcApp
()
->
styleIsDark
());
}
ChartPlot
::~
ChartPlot
()
{
}
QColor
ChartPlot
::
getNextColor
()
{
if
(
nextColorIndex
>=
colors
.
count
())
{
nextColorIndex
=
0
;
if
(
_nextColorIndex
>=
_colors
.
count
())
{
_nextColorIndex
=
0
;
}
return
colors
[
nextColorIndex
++
];
return
_colors
[
_
nextColorIndex
++
];
}
QColor
ChartPlot
::
getColorForCurve
(
const
QString
&
id
)
QColor
ChartPlot
::
getColorForCurve
(
const
QString
&
id
)
{
return
curves
.
value
(
id
)
->
pen
().
color
();
return
_
curves
.
value
(
id
)
->
pen
().
color
();
}
void
ChartPlot
::
shuffleColors
()
{
foreach
(
QwtPlotCurve
*
curve
,
curves
)
{
if
(
curve
->
isVisible
())
{
foreach
(
QwtPlotCurve
*
curve
,
_curves
)
{
if
(
curve
->
isVisible
())
{
QPen
pen
(
curve
->
pen
());
pen
.
setColor
(
getNextColor
());
curve
->
setPen
(
pen
);
...
...
@@ -86,32 +78,24 @@ void ChartPlot::shuffleColors()
void
ChartPlot
::
styleChanged
(
bool
styleIsDark
)
{
// Generate a new color list for curves and recolor them.
for
(
int
i
=
0
;
i
<
numColors
;
++
i
)
{
colors
[
i
]
=
styleIsDark
?
baseColors
[
i
].
lighter
(
150
)
:
baseColors
[
i
].
darker
(
150
);
for
(
int
i
=
0
;
i
<
numColors
;
++
i
)
{
_colors
[
i
]
=
styleIsDark
?
baseColors
[
i
].
lighter
(
150
)
:
baseColors
[
i
].
darker
(
150
);
}
shuffleColors
();
// Configure the rest of the UI colors based on the current theme.
if
(
styleIsDark
)
{
if
(
styleIsDark
)
{
// Set canvas background
setCanvasBackground
(
QColor
(
0
,
0
,
0
));
// Configure the plot grid.
grid
->
setMinorPen
(
QPen
(
QColor
(
0xAA
,
0xAA
,
0xAA
),
gridWidth
,
Qt
::
DotLine
));
grid
->
setMajorPen
(
QPen
(
QColor
(
0xDD
,
0xDD
,
0xDD
),
gridWidth
,
Qt
::
DotLine
));
}
else
{
_grid
->
setMinorPen
(
QPen
(
QColor
(
64
,
64
,
64
),
_gridWidth
,
Qt
::
SolidLine
));
_grid
->
setMajorPen
(
QPen
(
QColor
(
96
,
96
,
96
),
_gridWidth
,
Qt
::
SolidLine
));
}
else
{
// Set canvas background
setCanvasBackground
(
QColor
(
0xFF
,
0xFF
,
0xFF
));
// Configure the plot grid.
grid
->
setMinorPen
(
QPen
(
QColor
(
0x55
,
0x55
,
0x55
),
gridWidth
,
Qt
::
Dot
Line
));
grid
->
setMajorPen
(
QPen
(
QColor
(
0x22
,
0x22
,
0x22
),
gridWidth
,
Qt
::
Dot
Line
));
_grid
->
setMinorPen
(
QPen
(
QColor
(
192
,
192
,
192
),
_gridWidth
,
Qt
::
Solid
Line
));
_grid
->
setMajorPen
(
QPen
(
QColor
(
128
,
128
,
128
),
_gridWidth
,
Qt
::
Solid
Line
));
}
// And finally refresh the widget to make sure all color changes are redrawn.
replot
();
}
src/ui/linechart/ChartPlot.h
View file @
3262f6fc
...
...
@@ -31,14 +31,15 @@ public slots:
protected:
const
static
int
numColors
=
20
;
const
static
QColor
baseColors
[
numColors
];
QList
<
QColor
>
colors
;
///< Colormap for curves
int
nextColorIndex
;
///< Next index in color map
QMap
<
QString
,
QwtPlotCurve
*
>
curves
;
///< Plot curves
QwtPlotGrid
*
grid
;
///< Plot grid
float
symbolWidth
;
///< Width of curve symbols in pixels
float
curveWidth
;
///< Width of curve lines in pixels
float
gridWidth
;
///< Width of gridlines in pixels
QList
<
QColor
>
_colors
;
///< Colormap for curves
int
_nextColorIndex
;
///< Next index in color map
QMap
<
QString
,
QwtPlotCurve
*
>
_curves
;
///< Plot curves
QwtPlotGrid
*
_grid
;
///< Plot grid
float
_symbolWidth
;
///< Width of curve symbols in pixels
float
_curveWidth
;
///< Width of curve lines in pixels
float
_gridWidth
;
///< Width of gridlines in pixels
};
#endif // CHARTPLOT_H
src/ui/linechart/IncrementalPlot.cc
View file @
3262f6fc
...
...
@@ -143,7 +143,7 @@ void IncrementalPlot::showLegend(bool show)
void
IncrementalPlot
::
setStyleText
(
const
QString
&
style
)
{
styleText
=
style
.
toLower
();
foreach
(
QwtPlotCurve
*
curve
,
curves
)
{
foreach
(
QwtPlotCurve
*
curve
,
_
curves
)
{
updateStyle
(
curve
);
}
replot
();
...
...
@@ -161,24 +161,24 @@ void IncrementalPlot::updateStyle(QwtPlotCurve *curve)
// Update the symbol style
QwtSymbol
*
newSymbol
=
NULL
;
if
(
styleText
.
contains
(
"circles"
))
{
newSymbol
=
new
QwtSymbol
(
QwtSymbol
::
Ellipse
,
Qt
::
NoBrush
,
QPen
(
oldColor
,
symbolWidth
),
QSize
(
6
,
6
));
newSymbol
=
new
QwtSymbol
(
QwtSymbol
::
Ellipse
,
Qt
::
NoBrush
,
QPen
(
oldColor
,
_
symbolWidth
),
QSize
(
6
,
6
));
}
else
if
(
styleText
.
contains
(
"crosses"
))
{
newSymbol
=
new
QwtSymbol
(
QwtSymbol
::
XCross
,
Qt
::
NoBrush
,
QPen
(
oldColor
,
symbolWidth
),
QSize
(
5
,
5
));
newSymbol
=
new
QwtSymbol
(
QwtSymbol
::
XCross
,
Qt
::
NoBrush
,
QPen
(
oldColor
,
_
symbolWidth
),
QSize
(
5
,
5
));
}
else
if
(
styleText
.
contains
(
"rect"
))
{
newSymbol
=
new
QwtSymbol
(
QwtSymbol
::
Rect
,
Qt
::
NoBrush
,
QPen
(
oldColor
,
symbolWidth
),
QSize
(
6
,
6
));
newSymbol
=
new
QwtSymbol
(
QwtSymbol
::
Rect
,
Qt
::
NoBrush
,
QPen
(
oldColor
,
_
symbolWidth
),
QSize
(
6
,
6
));
}
// Else-case already handled by NULL value, which indicates no symbol
curve
->
setSymbol
(
newSymbol
);
// Update the line style
if
(
styleText
.
contains
(
"dotted"
))
{
curve
->
setPen
(
QPen
(
oldColor
,
curveWidth
,
Qt
::
DotLine
));
curve
->
setPen
(
QPen
(
oldColor
,
_
curveWidth
,
Qt
::
DotLine
));
}
else
if
(
styleText
.
contains
(
"dashed"
))
{
curve
->
setPen
(
QPen
(
oldColor
,
curveWidth
,
Qt
::
DashLine
));
curve
->
setPen
(
QPen
(
oldColor
,
_
curveWidth
,
Qt
::
DashLine
));
}
else
if
(
styleText
.
contains
(
"line"
)
||
styleText
.
contains
(
"solid"
))
{
curve
->
setPen
(
QPen
(
oldColor
,
curveWidth
,
Qt
::
SolidLine
));
curve
->
setPen
(
QPen
(
oldColor
,
_
curveWidth
,
Qt
::
SolidLine
));
}
else
{
curve
->
setPen
(
QPen
(
oldColor
,
curveWidth
,
Qt
::
NoPen
));
curve
->
setPen
(
QPen
(
oldColor
,
_
curveWidth
,
Qt
::
NoPen
));
}
curve
->
setStyle
(
QwtPlotCurve
::
Lines
);
}
...
...
@@ -260,22 +260,22 @@ void IncrementalPlot::appendData(const QString &key, double *x, double *y, int s
}
// If this is a new curve, create it.
if
(
!
curves
.
contains
(
key
))
{
if
(
!
_
curves
.
contains
(
key
))
{
curve
=
new
QwtPlotCurve
(
key
);
curves
.
insert
(
key
,
curve
);
_
curves
.
insert
(
key
,
curve
);
curve
->
setStyle
(
QwtPlotCurve
::
NoCurve
);
curve
->
setPaintAttribute
(
QwtPlotCurve
::
FilterPoints
);
// Set the color. Only the pen needs to be set
const
QColor
&
c
=
getNextColor
();
curve
->
setPen
(
c
,
symbolWidth
);
curve
->
setPen
(
c
,
_
symbolWidth
);
qDebug
()
<<
"Creating curve"
<<
key
<<
"with color"
<<
c
;
updateStyle
(
curve
);
curve
->
attach
(
this
);
}
else
{
curve
=
curves
.
value
(
key
);
curve
=
_
curves
.
value
(
key
);
}
data
->
append
(
x
,
y
,
size
);
...
...
@@ -359,21 +359,21 @@ int IncrementalPlot::data(const QString &key, double* r_x, double* r_y, int maxS
*/
void
IncrementalPlot
::
showGrid
(
bool
show
)
{
grid
->
setVisible
(
show
);
_
grid
->
setVisible
(
show
);
replot
();
}
bool
IncrementalPlot
::
gridEnabled
()
const
{
return
grid
->
isVisible
();
return
_
grid
->
isVisible
();
}
void
IncrementalPlot
::
removeData
()
{
foreach
(
QwtPlotCurve
*
curve
,
curves
)
{
foreach
(
QwtPlotCurve
*
curve
,
_
curves
)
{
delete
curve
;
}
curves
.
clear
();
_
curves
.
clear
();
foreach
(
CurveData
*
data
,
d_data
)
{
delete
data
;
...
...
src/ui/linechart/LinechartPlot.cc
View file @
3262f6fc
...
...
@@ -190,7 +190,7 @@ void LinechartPlot::removeTimedOutCurves()
{
// Remove this curve
// Delete curves
QwtPlotCurve
*
curve
=
curves
.
take
(
key
);
QwtPlotCurve
*
curve
=
_
curves
.
take
(
key
);
// Delete the object
delete
curve
;
// Set the pointer null
...
...
@@ -276,7 +276,7 @@ void LinechartPlot::appendData(QString dataname, quint64 ms, double value)
valueInterval
=
maxValue
-
minValue
;
// Assign dataset to curve
QwtPlotCurve
*
curve
=
curves
.
value
(
dataname
);
QwtPlotCurve
*
curve
=
_
curves
.
value
(
dataname
);
curve
->
setRawSamples
(
dataset
->
getPlotX
(),
dataset
->
getPlotY
(),
dataset
->
getPlotCount
());
// qDebug() << "mintime" << minTime << "maxtime" << maxTime << "last max time" << "window position" << getWindowPosition();
...
...
@@ -321,7 +321,7 @@ void LinechartPlot::addCurve(QString id)
// Create new curve and set style
QwtPlotCurve
*
curve
=
new
QwtPlotCurve
(
id
);
// Add curve to list
curves
.
insert
(
id
,
curve
);
_
curves
.
insert
(
id
,
curve
);
curve
->
setStyle
(
QwtPlotCurve
::
Lines
);
curve
->
setPaintAttribute
(
QwtPlotCurve
::
FilterPoints
,
true
);
...
...
@@ -414,15 +414,15 @@ void LinechartPlot::setScaling(int scaling)
**/
void
LinechartPlot
::
setVisibleById
(
QString
id
,
bool
visible
)
{
if
(
curves
.
contains
(
id
))
{
curves
.
value
(
id
)
->
setVisible
(
visible
);
if
(
_
curves
.
contains
(
id
))
{
_
curves
.
value
(
id
)
->
setVisible
(
visible
);
if
(
visible
)
{
curves
.
value
(
id
)
->
attach
(
this
);
_
curves
.
value
(
id
)
->
attach
(
this
);
}
else
{
curves
.
value
(
id
)
->
detach
();
_
curves
.
value
(
id
)
->
detach
();
}
}
}
...
...
@@ -467,9 +467,9 @@ void LinechartPlot::showCurve(QString id)
**/
void
LinechartPlot
::
setCurveColor
(
QString
id
,
QColor
color
)
{
QwtPlotCurve
*
curve
=
curves
.
value
(
id
);
QwtPlotCurve
*
curve
=
_
curves
.
value
(
id
);
// Change the color of the curve.
curve
->
setPen
(
QPen
(
QBrush
(
color
),
curveWidth
));
curve
->
setPen
(
QPen
(
QBrush
(
color
),
_
curveWidth
));
//qDebug() << "Setting curve" << id << "to" << color;
...
...
@@ -477,7 +477,7 @@ void LinechartPlot::setCurveColor(QString id, QColor color)
const
QwtSymbol
*
oldSymbol
=
curve
->
symbol
();
QwtSymbol
*
newSymbol
=
NULL
;
if
(
oldSymbol
)
{
newSymbol
=
new
QwtSymbol
(
oldSymbol
->
style
(),
QBrush
(
color
),
QPen
(
color
,
symbolWidth
),
QSize
(
symbolWidth
,
symbolWidth
));
newSymbol
=
new
QwtSymbol
(
oldSymbol
->
style
(),
QBrush
(
color
),
QPen
(
color
,
_symbolWidth
),
QSize
(
_symbolWidth
,
_
symbolWidth
));
}
curve
->
setSymbol
(
newSymbol
);
}
...
...
@@ -490,7 +490,7 @@ void LinechartPlot::setCurveColor(QString id, QColor color)
**/
bool
LinechartPlot
::
isVisible
(
QString
id
)
{
return
curves
.
value
(
id
)
->
isVisible
();
return
_
curves
.
value
(
id
)
->
isVisible
();
}
/**
...
...
@@ -499,9 +499,9 @@ bool LinechartPlot::isVisible(QString id)
bool
LinechartPlot
::
anyCurveVisible
()
{
bool
visible
=
false
;
foreach
(
const
QString
&
key
,
curves
.
keys
())
foreach
(
const
QString
&
key
,
_
curves
.
keys
())
{
if
(
curves
.
value
(
key
)
->
isVisible
())
if
(
_
curves
.
value
(
key
)
->
isVisible
())
{
visible
=
true
;
}
...
...
@@ -530,7 +530,7 @@ void LinechartPlot::setAutoScroll(bool active)
**/
QList
<
QwtPlotCurve
*>
LinechartPlot
::
getCurves
()
{
return
curves
.
values
();
return
_
curves
.
values
();
}
/**
...
...
@@ -702,10 +702,10 @@ void LinechartPlot::removeAllData()
datalock
.
lock
();
// Delete curves
QMap
<
QString
,
QwtPlotCurve
*>::
iterator
i
;
for
(
i
=
curves
.
begin
();
i
!=
curves
.
end
();
++
i
)
for
(
i
=
_curves
.
begin
();
i
!=
_
curves
.
end
();
++
i
)
{
// Remove from curve list
QwtPlotCurve
*
curve
=
curves
.
take
(
i
.
key
());
QwtPlotCurve
*
curve
=
_
curves
.
take
(
i
.
key
());
// Delete the object
delete
curve
;
// Set the pointer null
...
...
src/ui/linechart/LinechartWidget.cc
View file @
3262f6fc
This diff is collapsed.
Click to expand it.
src/ui/linechart/LinechartWidget.h
View file @
3262f6fc
...
...
@@ -138,7 +138,6 @@ protected:
QAction
*
addNewCurve
;
///< Add curve candidate to the active curves
QMenu
*
curveMenu
;
QComboBox
*
timeScaleCmb
;
QToolButton
*
scalingLogButton
;
...
...
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