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
0e6411c7
Commit
0e6411c7
authored
Oct 19, 2013
by
John Tapsell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix setStyleText() to apply to future curves
parent
beb0ecfb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
30 deletions
+39
-30
IncrementalPlot.cc
src/ui/linechart/IncrementalPlot.cc
+35
-28
IncrementalPlot.h
src/ui/linechart/IncrementalPlot.h
+4
-2
No files found.
src/ui/linechart/IncrementalPlot.cc
View file @
0e6411c7
...
...
@@ -157,36 +157,43 @@ void IncrementalPlot::showLegend(bool show)
*/
void
IncrementalPlot
::
setStyleText
(
const
QString
&
style
)
{
styleText
=
style
.
toLower
();
foreach
(
QwtPlotCurve
*
curve
,
curves
)
{
// Style of datapoints
if
(
style
.
toLower
().
contains
(
"circles"
))
{
curve
->
setSymbol
(
QwtSymbol
(
QwtSymbol
::
Ellipse
,
Qt
::
NoBrush
,
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
symbolWidth
),
QSize
(
6
,
6
))
);
}
else
if
(
style
.
toLower
().
contains
(
"crosses"
))
{
curve
->
setSymbol
(
QwtSymbol
(
QwtSymbol
::
XCross
,
Qt
::
NoBrush
,
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
symbolWidth
),
QSize
(
5
,
5
))
);
}
else
if
(
style
.
toLower
().
contains
(
"rect"
))
{
curve
->
setSymbol
(
QwtSymbol
(
QwtSymbol
::
Rect
,
Qt
::
NoBrush
,
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
symbolWidth
),
QSize
(
6
,
6
))
);
}
else
if
(
style
.
toLower
().
contains
(
"line"
))
{
// Show no symbol
curve
->
setSymbol
(
QwtSymbol
(
QwtSymbol
::
NoSymbol
,
Qt
::
NoBrush
,
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
symbolWidth
),
QSize
(
6
,
6
))
);
}
updateStyle
(
curve
);
}
replot
();
}
// Style of lines
if
(
style
.
toLower
().
contains
(
"dotted"
))
{
curve
->
setPen
(
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
curveWidth
,
Qt
::
DotLine
));
}
else
if
(
style
.
toLower
().
contains
(
"dashed"
))
{
curve
->
setPen
(
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
curveWidth
,
Qt
::
DashLine
));
}
else
if
(
style
.
toLower
().
contains
(
"line"
)
||
style
.
toLower
().
contains
(
"solid"
))
{
curve
->
setPen
(
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
curveWidth
,
Qt
::
SolidLine
));
}
else
{
curve
->
setPen
(
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
curveWidth
,
Qt
::
NoPen
));
}
curve
->
setStyle
(
QwtPlotCurve
::
Lines
);
void
IncrementalPlot
::
updateStyle
(
QwtPlotCurve
*
curve
)
{
if
(
styleText
.
isNull
())
return
;
// Style of datapoints
if
(
styleText
.
contains
(
"circles"
))
{
curve
->
setSymbol
(
QwtSymbol
(
QwtSymbol
::
Ellipse
,
Qt
::
NoBrush
,
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
symbolWidth
),
QSize
(
6
,
6
))
);
}
else
if
(
styleText
.
contains
(
"crosses"
))
{
curve
->
setSymbol
(
QwtSymbol
(
QwtSymbol
::
XCross
,
Qt
::
NoBrush
,
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
symbolWidth
),
QSize
(
5
,
5
))
);
}
else
if
(
styleText
.
contains
(
"rect"
))
{
curve
->
setSymbol
(
QwtSymbol
(
QwtSymbol
::
Rect
,
Qt
::
NoBrush
,
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
symbolWidth
),
QSize
(
6
,
6
))
);
}
else
if
(
styleText
.
contains
(
"line"
))
{
// Show no symbol
curve
->
setSymbol
(
QwtSymbol
(
QwtSymbol
::
NoSymbol
,
Qt
::
NoBrush
,
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
symbolWidth
),
QSize
(
6
,
6
))
);
}
// Style of lines
if
(
styleText
.
contains
(
"dotted"
))
{
curve
->
setPen
(
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
curveWidth
,
Qt
::
DotLine
));
}
else
if
(
styleText
.
contains
(
"dashed"
))
{
curve
->
setPen
(
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
curveWidth
,
Qt
::
DashLine
));
}
else
if
(
styleText
.
contains
(
"line"
)
||
styleText
.
contains
(
"solid"
))
{
curve
->
setPen
(
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
curveWidth
,
Qt
::
SolidLine
));
}
else
{
curve
->
setPen
(
QPen
(
QBrush
(
curve
->
symbol
().
pen
().
color
()),
curveWidth
,
Qt
::
NoPen
));
}
replot
(
);
curve
->
setStyle
(
QwtPlotCurve
::
Lines
);
}
void
IncrementalPlot
::
resetScaling
()
...
...
@@ -275,7 +282,7 @@ void IncrementalPlot::appendData(const QString &key, double *x, double *y, int s
const
QColor
&
c
=
getNextColor
();
curve
->
setSymbol
(
QwtSymbol
(
QwtSymbol
::
XCross
,
QBrush
(
c
),
QPen
(
c
,
symbolWidth
),
QSize
(
5
,
5
))
);
updateStyle
(
curve
);
//Apply any user-set style
curve
->
attach
(
this
);
}
else
{
curve
=
curves
.
value
(
key
);
...
...
@@ -374,7 +381,7 @@ void IncrementalPlot::showGrid(bool show)
replot
();
}
bool
IncrementalPlot
::
gridEnabled
()
bool
IncrementalPlot
::
gridEnabled
()
const
{
return
grid
->
isVisible
();
}
...
...
src/ui/linechart/IncrementalPlot.h
View file @
0e6411c7
...
...
@@ -81,7 +81,7 @@ public:
virtual
~
IncrementalPlot
();
/** @brief Get the state of the grid */
bool
gridEnabled
();
bool
gridEnabled
()
const
;
/** @brief Read out data from a curve */
int
data
(
const
QString
&
key
,
double
*
r_x
,
double
*
r_y
,
int
maxSize
);
...
...
@@ -125,10 +125,12 @@ protected:
double
xmax
;
///< Maximum x value seen
double
ymin
;
///< Minimum y value seen
double
ymax
;
///< Maximum y value seen
QString
styleText
;
///< Curve style set by setStyleText
private:
QMap
<
QString
,
CurveData
*
>
d_data
;
///< Data points
/** Helper function to apply styleText style to the given curve */
void
updateStyle
(
QwtPlotCurve
*
curve
);
};
#endif
/* INCREMENTALPLOT_H */
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