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
a167021b
Commit
a167021b
authored
Aug 20, 2014
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disabled state only draws border
Plus a few API tweaks
parent
cd907cde
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
64 deletions
+70
-64
QGCRadioChannelDisplay.cpp
src/ui/designer/QGCRadioChannelDisplay.cpp
+68
-63
QGCRadioChannelDisplay.h
src/ui/designer/QGCRadioChannelDisplay.h
+2
-1
No files found.
src/ui/designer/QGCRadioChannelDisplay.cpp
View file @
a167021b
...
...
@@ -70,43 +70,46 @@ void QGCRadioChannelDisplay::paintEvent(QPaintEvent *event)
painter
.
setBrush
(
Qt
::
SolidPattern
);
//draw the text value of the widget, and its label
QString
valStr
=
QString
::
number
(
m_value
);
painter
.
setPen
(
QColor
::
fromRgb
(
255
,
255
,
255
));
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
(
gradientBrush
);
if
(
!
m_showMinMax
)
{
//draw just the value
int
newval
=
(
height
()
-
2
-
twiceFontHeight
)
*
((
float
)(
curVal
-
m_min
)
/
((
m_max
-
m_min
)
+
1
));
int
yVal
=
(
height
()
-
2
-
twiceFontHeight
)
-
newval
;
painter
.
drawRect
(
1
,
yVal
,
width
()
-
3
,((
height
()
-
2
)
-
yVal
-
twiceFontHeight
));
}
else
{
//draw the value
int
newval
=
(
height
()
-
2
-
twiceFontHeight
)
*
((
float
)(
curVal
/
3001.0
));
int
yVal
=
(
height
()
-
2
-
twiceFontHeight
)
-
newval
;
painter
.
drawRect
(
1
,
yVal
,
width
()
-
3
,((
height
()
-
2
)
-
yVal
-
twiceFontHeight
));
//draw min max indicator bars
painter
.
setPen
(
QColor
::
fromRgb
(
255
,
0
,
0
));
painter
.
setBrush
(
Qt
::
NoBrush
);
int
yMax
=
(
height
()
-
3
-
twiceFontHeight
)
-
(((
height
()
-
3
-
twiceFontHeight
)
*
((
float
)
m_max
/
3000.0
)));
int
yMin
=
(
height
()
-
3
-
twiceFontHeight
)
-
(((
height
()
-
3
-
twiceFontHeight
)
*
((
float
)
m_min
/
3000.0
)));
painter
.
drawRect
(
2
,
yMax
,
width
()
-
3
,
yMin
-
yMax
);
//draw min and max labels
QString
minstr
=
QString
::
number
(
m_min
);
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
"min"
)
/
2.0
),
yMin
,
"min"
);
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
minstr
)
/
2.0
),
yMin
+
fontHeight
,
minstr
);
QString
maxstr
=
QString
::
number
(
m_max
);
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
"max"
)
/
2.0
),
yMax
,
"max"
);
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
maxstr
)
/
2.0
),
yMax
+
fontHeight
,
maxstr
);
if
(
isEnabled
())
{
QString
valStr
=
QString
::
number
(
m_value
);
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
(
gradientBrush
);
if
(
!
m_showMinMax
)
{
//draw just the value
int
newval
=
(
height
()
-
2
-
twiceFontHeight
)
*
((
float
)(
curVal
-
m_min
)
/
((
m_max
-
m_min
)
+
1
));
int
yVal
=
(
height
()
-
2
-
twiceFontHeight
)
-
newval
;
painter
.
drawRect
(
1
,
yVal
,
width
()
-
3
,((
height
()
-
2
)
-
yVal
-
twiceFontHeight
));
}
else
{
//draw the value
int
newval
=
(
height
()
-
2
-
twiceFontHeight
)
*
((
float
)(
curVal
/
3001.0
));
int
yVal
=
(
height
()
-
2
-
twiceFontHeight
)
-
newval
;
painter
.
drawRect
(
1
,
yVal
,
width
()
-
3
,((
height
()
-
2
)
-
yVal
-
twiceFontHeight
));
//draw min max indicator bars
painter
.
setPen
(
QColor
::
fromRgb
(
255
,
0
,
0
));
painter
.
setBrush
(
Qt
::
NoBrush
);
int
yMax
=
(
height
()
-
3
-
twiceFontHeight
)
-
(((
height
()
-
3
-
twiceFontHeight
)
*
((
float
)
m_max
/
3000.0
)));
int
yMin
=
(
height
()
-
3
-
twiceFontHeight
)
-
(((
height
()
-
3
-
twiceFontHeight
)
*
((
float
)
m_min
/
3000.0
)));
painter
.
drawRect
(
2
,
yMax
,
width
()
-
3
,
yMin
-
yMax
);
//draw min and max labels
QString
minstr
=
QString
::
number
(
m_min
);
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
"min"
)
/
2.0
),
yMin
,
"min"
);
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
minstr
)
/
2.0
),
yMin
+
fontHeight
,
minstr
);
QString
maxstr
=
QString
::
number
(
m_max
);
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
"max"
)
/
2.0
),
yMax
,
"max"
);
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
maxstr
)
/
2.0
),
yMax
+
fontHeight
,
maxstr
);
}
}
}
else
//horizontal orientation
...
...
@@ -123,35 +126,37 @@ void QGCRadioChannelDisplay::paintEvent(QPaintEvent *event)
//draw the value string
painter
.
setPen
(
QColor
::
fromRgb
(
255
,
255
,
255
));
QString
valstr
=
QString
::
number
(
m_value
);
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
(
0
,
128
,
0
));
painter
.
setBrush
(
hGradientBrush
);
if
(
!
m_showMinMax
)
{
//draw just the value
painter
.
drawRect
(
1
,
1
,(
width
()
-
3
)
*
((
float
)(
curVal
-
m_min
)
/
(
m_max
-
m_min
)),(
height
()
-
3
)
-
twiceFontHeight
);
}
else
{
//draw the value
painter
.
drawRect
(
1
,
1
,(
width
()
-
3
)
*
((
float
)
curVal
/
3000.0
),(
height
()
-
3
)
-
twiceFontHeight
);
//draw the min and max bars
painter
.
setBrush
(
Qt
::
NoBrush
);
painter
.
setPen
(
QColor
::
fromRgb
(
255
,
0
,
0
));
painter
.
drawRect
(
width
()
*
((
float
)
m_min
/
3000.0
),
2
,((
width
()
-
1
)
*
((
float
)
m_max
/
3000.0
))
-
(
width
()
*
((
float
)
m_min
/
3000.0
)),(
height
()
-
5
)
-
twiceFontHeight
);
//draw the min and max strings
QString
minstr
=
QString
::
number
(
m_min
);
painter
.
drawText
((
width
()
*
((
float
)
m_min
/
3000.0
))
-
(
painter
.
fontMetrics
().
width
(
"min"
)
/
2.0
),((
height
()
-
3
)
-
(
painter
.
fontMetrics
().
height
()
*
1
)),
"min"
);
painter
.
drawText
((
width
()
*
((
float
)
m_min
/
3000.0
))
-
(
painter
.
fontMetrics
().
width
(
minstr
)
/
2.0
),((
height
()
-
3
)
-
(
painter
.
fontMetrics
().
height
()
*
0
)),
minstr
);
QString
maxstr
=
QString
::
number
(
m_max
);
painter
.
drawText
((
width
()
*
((
float
)
m_max
/
3000.0
))
-
(
painter
.
fontMetrics
().
width
(
"max"
)
/
2.0
),((
height
()
-
3
)
-
(
painter
.
fontMetrics
().
height
()
*
1
)),
"max"
);
painter
.
drawText
((
width
()
*
((
float
)
m_max
/
3000.0
))
-
(
painter
.
fontMetrics
().
width
(
maxstr
)
/
2.0
),((
height
()
-
3
)
-
(
painter
.
fontMetrics
().
height
()
*
0
)),
maxstr
);
if
(
isEnabled
())
{
QString
valstr
=
QString
::
number
(
m_value
);
painter
.
drawText
((
width
()
/
2.0
)
-
(
painter
.
fontMetrics
().
width
(
valstr
)
/
2.0
),((
height
()
-
3
)
-
(
fontHeight
*
0
)),
valstr
);
painter
.
setPen
(
QColor
::
fromRgb
(
0
,
128
,
0
));
painter
.
setBrush
(
hGradientBrush
);
if
(
!
m_showMinMax
)
{
//draw just the value
painter
.
drawRect
(
1
,
1
,(
width
()
-
3
)
*
((
float
)(
curVal
-
m_min
)
/
(
m_max
-
m_min
)),(
height
()
-
3
)
-
twiceFontHeight
);
}
else
{
//draw the value
painter
.
drawRect
(
1
,
1
,(
width
()
-
3
)
*
((
float
)
curVal
/
3000.0
),(
height
()
-
3
)
-
twiceFontHeight
);
//draw the min and max bars
painter
.
setBrush
(
Qt
::
NoBrush
);
painter
.
setPen
(
QColor
::
fromRgb
(
255
,
0
,
0
));
painter
.
drawRect
(
width
()
*
((
float
)
m_min
/
3000.0
),
2
,((
width
()
-
1
)
*
((
float
)
m_max
/
3000.0
))
-
(
width
()
*
((
float
)
m_min
/
3000.0
)),(
height
()
-
5
)
-
twiceFontHeight
);
//draw the min and max strings
QString
minstr
=
QString
::
number
(
m_min
);
painter
.
drawText
((
width
()
*
((
float
)
m_min
/
3000.0
))
-
(
painter
.
fontMetrics
().
width
(
"min"
)
/
2.0
),((
height
()
-
3
)
-
(
painter
.
fontMetrics
().
height
()
*
1
)),
"min"
);
painter
.
drawText
((
width
()
*
((
float
)
m_min
/
3000.0
))
-
(
painter
.
fontMetrics
().
width
(
minstr
)
/
2.0
),((
height
()
-
3
)
-
(
painter
.
fontMetrics
().
height
()
*
0
)),
minstr
);
QString
maxstr
=
QString
::
number
(
m_max
);
painter
.
drawText
((
width
()
*
((
float
)
m_max
/
3000.0
))
-
(
painter
.
fontMetrics
().
width
(
"max"
)
/
2.0
),((
height
()
-
3
)
-
(
painter
.
fontMetrics
().
height
()
*
1
)),
"max"
);
painter
.
drawText
((
width
()
*
((
float
)
m_max
/
3000.0
))
-
(
painter
.
fontMetrics
().
width
(
maxstr
)
/
2.0
),((
height
()
-
3
)
-
(
painter
.
fontMetrics
().
height
()
*
0
)),
maxstr
);
}
}
}
}
...
...
@@ -173,9 +178,9 @@ void QGCRadioChannelDisplay::setValue(int value)
update
();
}
void
QGCRadioChannelDisplay
::
showMinMax
()
void
QGCRadioChannelDisplay
::
showMinMax
(
bool
show
)
{
m_showMinMax
=
true
;
m_showMinMax
=
show
;
update
();
}
...
...
src/ui/designer/QGCRadioChannelDisplay.h
View file @
a167021b
...
...
@@ -10,8 +10,9 @@ public:
explicit
QGCRadioChannelDisplay
(
QWidget
*
parent
=
0
);
void
setOrientation
(
Qt
::
Orientation
orient
);
void
setValue
(
int
value
);
void
showMinMax
();
void
showMinMax
(
bool
show
=
true
);
void
hideMinMax
();
bool
isMinMaxShown
()
{
return
m_showMinMax
;
}
void
setValueAndRange
(
int
val
,
int
min
,
int
max
);
void
setMinMax
(
int
min
,
int
max
);
void
setMin
(
int
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