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
ce9fead2
Commit
ce9fead2
authored
Jun 04, 2013
by
Bryant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplified color code for ChartPlot
parent
c8f12ee4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
43 deletions
+38
-43
ChartPlot.cc
src/ui/linechart/ChartPlot.cc
+35
-36
ChartPlot.h
src/ui/linechart/ChartPlot.h
+3
-2
LinechartPlot.cc
src/ui/linechart/LinechartPlot.cc
+0
-5
No files found.
src/ui/linechart/ChartPlot.cc
View file @
ce9fead2
#include "ChartPlot.h"
#include "MainWindow.h"
const
int
ChartPlot
::
numBaseColors
=
20
;
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
)
};
ChartPlot
::
ChartPlot
(
QWidget
*
parent
)
:
QwtPlot
(
parent
)
/*,
QwtPlot
(
parent
),
nextColorIndex
(
0
)
/*,
symbolWidth(1.2f),
curveWidth(1.0f),
gridWidth(0.8f),
scaleWidth(1.0f)*/
{
// for (int i = 0; i < numBaseColors; ++i)
// {
// colors[i] = baseColors[i];
// }
// Set up the colorscheme used by this plotter.
// nextColor = 0;
// Set the grid. The colorscheme was already set in generateColorScheme().
grid
=
new
QwtPlotGrid
;
grid
->
enableXMin
(
true
);
grid
->
attach
(
this
);
//
// Enable zooming
// Enable zooming
zoomer
=
new
ScrollZoomer
(
canvas
());
colors
=
QList
<
QColor
>
();
nextColor
=
0
;
///> Color map for plots, includes 20 colors
///> Map will start from beginning when the first 20 colors are exceeded
colors
.
append
(
QColor
(
242
,
255
,
128
));
colors
.
append
(
QColor
(
70
,
80
,
242
));
colors
.
append
(
QColor
(
232
,
33
,
47
));
colors
.
append
(
QColor
(
116
,
251
,
110
));
colors
.
append
(
QColor
(
81
,
183
,
244
));
colors
.
append
(
QColor
(
234
,
38
,
107
));
colors
.
append
(
QColor
(
92
,
247
,
217
));
colors
.
append
(
QColor
(
151
,
59
,
239
));
colors
.
append
(
QColor
(
231
,
72
,
28
));
colors
.
append
(
QColor
(
236
,
48
,
221
));
colors
.
append
(
QColor
(
75
,
133
,
243
));
colors
.
append
(
QColor
(
203
,
254
,
121
));
colors
.
append
(
QColor
(
104
,
64
,
240
));
colors
.
append
(
QColor
(
200
,
54
,
238
));
colors
.
append
(
QColor
(
104
,
250
,
138
));
colors
.
append
(
QColor
(
235
,
43
,
165
));
colors
.
append
(
QColor
(
98
,
248
,
176
));
colors
.
append
(
QColor
(
161
,
252
,
116
));
colors
.
append
(
QColor
(
87
,
231
,
246
));
colors
.
append
(
QColor
(
230
,
126
,
23
));
for
(
int
i
=
0
;
i
<
numColors
;
++
i
)
{
colors
.
append
(
baseColors
[
i
]);
}
// Now that all objects have been initialized, color everything.
applyColorScheme
(((
MainWindow
*
)
parent
)
->
getStyle
());
...
...
@@ -66,10 +64,11 @@ ChartPlot::~ChartPlot()
QColor
ChartPlot
::
getNextColor
()
{
/* Return current color and increment counter for next round */
nextColor
++
;
if
(
nextColor
>=
colors
.
count
())
nextColor
=
0
;
return
colors
[
nextColor
++
];
if
(
nextColorIndex
>=
colors
.
count
())
{
nextColorIndex
=
0
;
}
return
colors
[
nextColorIndex
++
];
}
QColor
ChartPlot
::
getColorForCurve
(
QString
id
)
...
...
@@ -90,7 +89,7 @@ void ChartPlot::shuffleColors()
void
ChartPlot
::
applyColorScheme
(
MainWindow
::
QGC_MAINWINDOW_STYLE
style
)
{
// Generate the color list for curves
for
(
int
i
=
0
;
i
<
num
Base
Colors
;
++
i
)
for
(
int
i
=
0
;
i
<
numColors
;
++
i
)
{
if
(
style
==
MainWindow
::
QGC_MAINWINDOW_STYLE_LIGHT
)
{
// colors[i] = baseColors[i].lighter(150);
...
...
src/ui/linechart/ChartPlot.h
View file @
ce9fead2
...
...
@@ -23,9 +23,10 @@ public:
void
shuffleColors
();
protected:
const
static
int
numBaseColors
;
const
static
int
numColors
=
20
;
const
static
QColor
baseColors
[
numColors
];
QList
<
QColor
>
colors
;
///< Colormap for curves
int
nextColor
;
///< Next index in color map
int
nextColor
Index
;
///< Next index in color map
QMap
<
QString
,
QwtPlotCurve
*
>
curves
;
///< Plot curves
ScrollZoomer
*
zoomer
;
///< Zoomer class for widget
QwtPlotGrid
*
grid
;
///< Plot grid
...
...
src/ui/linechart/LinechartPlot.cc
View file @
ce9fead2
...
...
@@ -609,11 +609,6 @@ quint64 LinechartPlot::getDataInterval()
return
storageInterval
;
}
QList
<
QColor
>
LinechartPlot
::
getColorMap
()
{
return
colors
;
}
/**
* @brief Set logarithmic scaling for the curve
**/
...
...
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