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
e5198b1e
Commit
e5198b1e
authored
Jul 30, 2013
by
tstellanova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gradients for RC indicators
parent
174d686d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
5 deletions
+19
-5
QGCRadioChannelDisplay.cpp
src/ui/designer/QGCRadioChannelDisplay.cpp
+19
-5
No files found.
src/ui/designer/QGCRadioChannelDisplay.cpp
View file @
e5198b1e
#include "QGCRadioChannelDisplay.h"
#include <QPainter>
QGCRadioChannelDisplay
::
QGCRadioChannelDisplay
(
QWidget
*
parent
)
:
QWidget
(
parent
)
{
m_showMinMax
=
false
;
m_min
=
0
;
...
...
@@ -13,6 +12,8 @@ QGCRadioChannelDisplay::QGCRadioChannelDisplay(QWidget *parent) : QWidget(parent
m_fillBrush
=
QBrush
(
Qt
::
green
,
Qt
::
SolidPattern
);
}
void
QGCRadioChannelDisplay
::
setName
(
QString
name
)
{
...
...
@@ -25,12 +26,16 @@ void QGCRadioChannelDisplay::setOrientation(Qt::Orientation orient)
m_orientation
=
orient
;
update
();
}
void
QGCRadioChannelDisplay
::
paintEvent
(
QPaintEvent
*
event
)
{
//Values range from 0-3000.
//1500 is the middle, static servo value.
QPainter
painter
(
this
);
int
fontHeight
=
painter
.
fontMetrics
().
height
();
int
twiceFontHeight
=
fontHeight
*
2
;
...
...
@@ -47,6 +52,11 @@ void QGCRadioChannelDisplay::paintEvent(QPaintEvent *event)
if
(
m_orientation
==
Qt
::
Vertical
)
{
QLinearGradient
gradientBrush
(
0
,
0
,
this
->
width
(),
this
->
height
());
gradientBrush
.
setColorAt
(
1.0
,
QColor
::
fromRgb
(
0
,
128
,
0
));
gradientBrush
.
setColorAt
(
0.5
,
QColor
::
fromRgb
(
0
,
200
,
0
));
gradientBrush
.
setColorAt
(
0.0
,
QColor
::
fromRgb
(
64
,
255
,
0
));
//draw border
painter
.
drawRect
(
0
,
0
,
width
()
-
1
,(
height
()
-
1
)
-
twiceFontHeight
);
painter
.
setPen
(
QColor
::
fromRgb
(
50
,
255
,
50
));
...
...
@@ -58,9 +68,8 @@ void QGCRadioChannelDisplay::paintEvent(QPaintEvent *event)
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
m_name
)
/
2.0
),((
height
()
-
3
)
-
(
fontHeight
*
1
)),
m_name
);
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
valStr
)
/
2.0
),((
height
()
-
3
)
-
(
fontHeight
*
0
)),
valStr
);
painter
.
setPen
(
QColor
::
fromRgb
(
128
,
128
,
64
));
painter
.
setBrush
(
m_fill
Brush
);
painter
.
setBrush
(
gradient
Brush
);
if
(
!
m_showMinMax
)
{
//draw just the value
...
...
@@ -95,10 +104,15 @@ void QGCRadioChannelDisplay::paintEvent(QPaintEvent *event)
}
else
//horizontal orientation
{
QLinearGradient
hGradientBrush
(
0
,
0
,
this
->
width
(),
this
->
height
());
hGradientBrush
.
setColorAt
(
0.0
,
QColor
::
fromRgb
(
0
,
128
,
0
));
hGradientBrush
.
setColorAt
(
0.5
,
QColor
::
fromRgb
(
0
,
200
,
0
));
hGradientBrush
.
setColorAt
(
1.0
,
QColor
::
fromRgb
(
64
,
255
,
0
));
//draw the value
painter
.
drawRect
(
0
,
0
,
width
()
-
1
,(
height
()
-
1
)
-
twiceFontHeight
);
painter
.
setPen
(
QColor
::
fromRgb
(
50
,
255
,
50
));
painter
.
setBrush
(
m_fill
Brush
);
painter
.
setBrush
(
hGradient
Brush
);
//draw the value string
painter
.
setPen
(
QColor
::
fromRgb
(
255
,
255
,
255
));
...
...
@@ -108,7 +122,7 @@ void QGCRadioChannelDisplay::paintEvent(QPaintEvent *event)
painter
.
setPen
(
QColor
::
fromRgb
(
0
,
128
,
0
));
painter
.
setBrush
(
m_fill
Brush
);
painter
.
setBrush
(
hGradient
Brush
);
if
(
!
m_showMinMax
)
{
//draw just the 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