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
1b9ab2a4
Commit
1b9ab2a4
authored
Nov 12, 2011
by
Lorenz Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-enabled automatic gauges, now again user-configurable
parent
2711ddf5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
11 deletions
+76
-11
HDDisplay.cc
src/ui/HDDisplay.cc
+61
-8
HDDisplay.h
src/ui/HDDisplay.h
+8
-0
MainWindow.cc
src/ui/MainWindow.cc
+7
-3
No files found.
src/ui/HDDisplay.cc
View file @
1b9ab2a4
...
...
@@ -271,16 +271,23 @@ void HDDisplay::addGauge()
QStringList
items
;
for
(
int
i
=
0
;
i
<
values
.
count
();
++
i
)
{
QString
key
=
values
.
keys
().
at
(
i
);
QString
label
=
key
;
QStringList
keySplit
=
key
.
split
(
"."
);
if
(
keySplit
.
size
()
>
1
)
{
keySplit
.
removeFirst
();
label
=
keySplit
.
join
(
"."
);
}
QString
unit
=
units
.
value
(
key
);
if
(
unit
.
contains
(
"deg"
)
||
unit
.
contains
(
"rad"
))
{
items
.
append
(
QString
(
"%1,%2,%3,%4,
s"
).
arg
(
"-180"
).
arg
(
key
).
arg
(
unit
).
arg
(
"+180"
));
items
.
append
(
QString
(
"%1,%2,%3,%4,
%5,s"
).
arg
(
"-180"
).
arg
(
key
).
arg
(
unit
).
arg
(
"+180"
).
arg
(
label
));
}
else
{
items
.
append
(
QString
(
"%1,%2,%3,%4
"
).
arg
(
"0"
).
arg
(
key
).
arg
(
unit
).
arg
(
"+100"
));
items
.
append
(
QString
(
"%1,%2,%3,%4
,%5"
).
arg
(
"0"
).
arg
(
key
).
arg
(
unit
).
arg
(
"+100"
).
arg
(
label
));
}
}
bool
ok
;
QString
item
=
QInputDialog
::
getItem
(
this
,
tr
(
"Add Gauge Instrument"
),
tr
(
"Format: min,
curve name, unit, max
[,s]"
),
items
,
0
,
true
,
&
ok
);
tr
(
"Format: min,
data name, unit, max, label
[,s]"
),
items
,
0
,
true
,
&
ok
);
if
(
ok
&&
!
item
.
isEmpty
())
{
addGauge
(
item
);
}
...
...
@@ -307,9 +314,19 @@ void HDDisplay::addGauge(const QString& gauge)
val
=
parts
.
at
(
3
).
toDouble
(
&
ok
);
success
&=
ok
;
if
(
ok
)
maxValues
.
insert
(
key
,
val
);
// Convert name
if
(
parts
.
length
()
>=
5
)
{
if
(
parts
.
at
(
4
).
length
()
>
0
)
{
customNames
.
insert
(
key
,
parts
.
at
(
4
));
}
}
// Convert symmetric flag
if
(
parts
.
length
()
>=
5
)
{
if
(
parts
.
at
(
4
).
contains
(
"s"
))
{
if
(
parts
.
length
()
>=
6
)
{
if
(
parts
.
at
(
5
).
contains
(
"s"
))
{
symmetric
.
insert
(
key
,
true
);
}
}
...
...
@@ -425,12 +442,15 @@ void HDDisplay::renderOverlay()
float
topSpacing
=
leftSpacing
;
float
yCoord
=
topSpacing
+
gaugeWidth
/
2.0
f
;
for
(
int
i
=
0
;
i
<
acceptList
->
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
acceptList
->
size
();
++
i
)
{
QString
value
=
acceptList
->
at
(
i
);
drawGauge
(
xCoord
,
yCoord
,
gaugeWidth
/
2.0
f
,
minValues
.
value
(
value
,
-
1.0
f
),
maxValues
.
value
(
value
,
1.0
f
),
value
,
values
.
value
(
value
,
minValues
.
value
(
value
,
0.0
f
)),
gaugeColor
,
&
painter
,
symmetric
.
value
(
value
,
false
),
goodRanges
.
value
(
value
,
qMakePair
(
0.0
f
,
0.5
f
)),
critRanges
.
value
(
value
,
qMakePair
(
0.7
f
,
1.0
f
)),
true
);
QString
label
=
customNames
.
value
(
value
);
drawGauge
(
xCoord
,
yCoord
,
gaugeWidth
/
2.0
f
,
minValues
.
value
(
value
,
-
1.0
f
),
maxValues
.
value
(
value
,
1.0
f
),
label
,
values
.
value
(
value
,
minValues
.
value
(
value
,
0.0
f
)),
gaugeColor
,
&
painter
,
symmetric
.
value
(
value
,
false
),
goodRanges
.
value
(
value
,
qMakePair
(
0.0
f
,
0.5
f
)),
critRanges
.
value
(
value
,
qMakePair
(
0.7
f
,
1.0
f
)),
true
);
xCoord
+=
gaugeWidth
+
leftSpacing
;
// Move one row down if necessary
if
(
xCoord
+
gaugeWidth
*
0.9
f
>
vwidth
)
{
if
(
xCoord
+
gaugeWidth
*
0.9
f
>
vwidth
)
{
yCoord
+=
topSpacing
+
gaugeWidth
;
xCoord
=
leftSpacing
+
gaugeWidth
/
2.0
f
;
}
...
...
@@ -807,12 +827,45 @@ float HDDisplay::refLineWidthToPen(float line)
return
line
*
2.50
f
;
}
void
HDDisplay
::
addSource
(
QObject
*
obj
)
{
//genericSources.append(obj);
// FIXME XXX HACK
// if (plots.size() > 0)
// {
// Connect generic source
connect
(
obj
,
SIGNAL
(
valueChanged
(
int
,
QString
,
QString
,
int
,
quint64
)),
this
,
SLOT
(
updateValue
(
int
,
QString
,
QString
,
int
,
quint64
)));
connect
(
obj
,
SIGNAL
(
valueChanged
(
int
,
QString
,
QString
,
unsigned
int
,
quint64
)),
this
,
SLOT
(
updateValue
(
int
,
QString
,
QString
,
unsigned
int
,
quint64
)));
connect
(
obj
,
SIGNAL
(
valueChanged
(
int
,
QString
,
QString
,
quint64
,
quint64
)),
this
,
SLOT
(
updateValue
(
int
,
QString
,
QString
,
quint64
,
quint64
)));
connect
(
obj
,
SIGNAL
(
valueChanged
(
int
,
QString
,
QString
,
qint64
,
quint64
)),
this
,
SLOT
(
updateValue
(
int
,
QString
,
QString
,
qint64
,
quint64
)));
connect
(
obj
,
SIGNAL
(
valueChanged
(
int
,
QString
,
QString
,
double
,
quint64
)),
this
,
SLOT
(
updateValue
(
int
,
QString
,
QString
,
double
,
quint64
)));
// }
}
void
HDDisplay
::
updateValue
(
const
int
uasId
,
const
QString
&
name
,
const
QString
&
unit
,
const
int
value
,
const
quint64
msec
)
{
if
(
!
intValues
.
contains
(
name
))
intValues
.
insert
(
name
,
true
);
updateValue
(
uasId
,
name
,
unit
,
(
double
)
value
,
msec
);
}
void
HDDisplay
::
updateValue
(
const
int
uasId
,
const
QString
&
name
,
const
QString
&
unit
,
const
unsigned
int
value
,
const
quint64
msec
)
{
if
(
!
intValues
.
contains
(
name
))
intValues
.
insert
(
name
,
true
);
updateValue
(
uasId
,
name
,
unit
,
(
double
)
value
,
msec
);
}
void
HDDisplay
::
updateValue
(
const
int
uasId
,
const
QString
&
name
,
const
QString
&
unit
,
const
qint64
value
,
const
quint64
msec
)
{
if
(
!
intValues
.
contains
(
name
))
intValues
.
insert
(
name
,
true
);
updateValue
(
uasId
,
name
,
unit
,
(
double
)
value
,
msec
);
}
void
HDDisplay
::
updateValue
(
const
int
uasId
,
const
QString
&
name
,
const
QString
&
unit
,
const
quint64
value
,
const
quint64
msec
)
{
if
(
!
intValues
.
contains
(
name
))
intValues
.
insert
(
name
,
true
);
updateValue
(
uasId
,
name
,
unit
,
(
double
)
value
,
msec
);
}
void
HDDisplay
::
updateValue
(
const
int
uasId
,
const
QString
&
name
,
const
QString
&
unit
,
const
double
value
,
const
quint64
msec
)
{
Q_UNUSED
(
uasId
);
...
...
src/ui/HDDisplay.h
View file @
1b9ab2a4
...
...
@@ -68,7 +68,14 @@ public slots:
void
updateValue
(
const
int
uasId
,
const
QString
&
name
,
const
QString
&
unit
,
const
double
value
,
const
quint64
msec
);
/** @brief Update a HDD integer value */
void
updateValue
(
const
int
uasId
,
const
QString
&
name
,
const
QString
&
unit
,
const
int
value
,
const
quint64
msec
);
/** @brief Update a HDD integer value */
void
updateValue
(
const
int
uasId
,
const
QString
&
name
,
const
QString
&
unit
,
const
unsigned
int
value
,
const
quint64
msec
);
/** @brief Update a HDD integer value */
void
updateValue
(
const
int
uasId
,
const
QString
&
name
,
const
QString
&
unit
,
const
qint64
value
,
const
quint64
msec
);
/** @brief Update a HDD integer value */
void
updateValue
(
const
int
uasId
,
const
QString
&
name
,
const
QString
&
unit
,
const
quint64
value
,
const
quint64
msec
);
virtual
void
setActiveUAS
(
UASInterface
*
uas
);
void
addSource
(
QObject
*
obj
);
/** @brief Removes a plot item by the action data */
void
removeItemByAction
();
...
...
@@ -149,6 +156,7 @@ protected:
QMap
<
QString
,
float
>
maxValues
;
///< The maximum value this variable is assumed to have
QMap
<
QString
,
bool
>
symmetric
;
///< Draw the gauge / dial symmetric bool = yes
QMap
<
QString
,
bool
>
intValues
;
///< Is the gauge value an integer?
QMap
<
QString
,
QString
>
customNames
;
///< Custom names for the data names
QMap
<
QString
,
QPair
<
float
,
float
>
>
goodRanges
;
///< The range of good values
QMap
<
QString
,
QPair
<
float
,
float
>
>
critRanges
;
///< The range of critical values
double
scalingFactor
;
///< Factor used to scale all absolute values to screen coordinates
...
...
src/ui/MainWindow.cc
View file @
1b9ab2a4
...
...
@@ -91,8 +91,8 @@ MainWindow::MainWindow(QWidget *parent):
currentStyle
(
QGC_MAINWINDOW_STYLE_INDOOR
),
aboutToCloseFlag
(
false
),
changingViewsFlag
(
false
),
styleFileName
(
QCoreApplication
::
applicationDirPath
()
+
"/style-indoor.css"
),
centerStackActionGroup
(
this
),
styleFileName
(
QCoreApplication
::
applicationDirPath
()
+
"/style-indoor.css"
),
autoReconnect
(
false
),
lowPowerMode
(
false
)
{
...
...
@@ -427,14 +427,18 @@ void MainWindow::buildCommonWidgets()
if
(
!
headDown1DockWidget
)
{
headDown1DockWidget
=
new
QDockWidget
(
tr
(
"Flight Display"
),
this
);
headDown1DockWidget
->
setWidget
(
new
HDDisplay
(
acceptList
,
"Flight Display"
,
this
)
);
HDDisplay
*
hdDisplay
=
new
HDDisplay
(
acceptList
,
"Flight Display"
,
this
);
hdDisplay
->
addSource
(
mavlinkDecoder
);
headDown1DockWidget
->
setWidget
(
hdDisplay
);
headDown1DockWidget
->
setObjectName
(
"HEAD_DOWN_DISPLAY_1_DOCK_WIDGET"
);
addTool
(
headDown1DockWidget
,
tr
(
"Flight Display"
),
Qt
::
RightDockWidgetArea
);
}
if
(
!
headDown2DockWidget
)
{
headDown2DockWidget
=
new
QDockWidget
(
tr
(
"Actuator Status"
),
this
);
headDown2DockWidget
->
setWidget
(
new
HDDisplay
(
acceptList2
,
"Actuator Status"
,
this
)
);
HDDisplay
*
hdDisplay
=
new
HDDisplay
(
acceptList2
,
"Actuator Status"
,
this
);
hdDisplay
->
addSource
(
mavlinkDecoder
);
headDown2DockWidget
->
setWidget
(
hdDisplay
);
headDown2DockWidget
->
setObjectName
(
"HEAD_DOWN_DISPLAY_2_DOCK_WIDGET"
);
addTool
(
headDown2DockWidget
,
tr
(
"Actuator Status"
),
Qt
::
RightDockWidgetArea
);
}
...
...
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