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
551701e8
Commit
551701e8
authored
Jul 24, 2011
by
lm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Substantially improved map menu, allows now to set update rate and trail distance / time
parent
a2ab9b23
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
154 additions
and
42 deletions
+154
-42
QGCMapToolBar.cc
src/ui/map/QGCMapToolBar.cc
+114
-27
QGCMapToolBar.h
src/ui/map/QGCMapToolBar.h
+8
-3
QGCMapToolBar.ui
src/ui/map/QGCMapToolBar.ui
+11
-11
QGCMapWidget.cc
src/ui/map/QGCMapWidget.cc
+1
-1
QGCMapWidget.h
src/ui/map/QGCMapWidget.h
+20
-0
No files found.
src/ui/map/QGCMapToolBar.cc
View file @
551701e8
...
...
@@ -4,8 +4,13 @@
QGCMapToolBar
::
QGCMapToolBar
(
QWidget
*
parent
)
:
QWidget
(
parent
),
ui
(
new
Ui
::
QGCMapToolBar
),
map
(
NULL
),
ui
(
new
Ui
::
QGCMapToolBar
)
optionsMenu
(
this
),
trailPlotMenu
(
this
),
updateTimesMenu
(
this
),
trailSettingsGroup
(
new
QActionGroup
(
this
)),
updateTimesGroup
(
new
QActionGroup
(
this
))
{
ui
->
setupUi
(
this
);
}
...
...
@@ -30,60 +35,139 @@ void QGCMapToolBar::setMap(QGCMapWidget* map)
// Edit mode handling
ui
->
editButton
->
hide
();
// const int uavTrailTimeList[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // seconds
// const int uavTrailTimeCount = 10;
// const int uavTrailDistanceList[] = {1, 2, 5, 10, 20, 50, 100, 200, 500}; // meters
// const int uavTrailDistanceCount = 9;
// optionsMenu.setParent(this);
// // Build up menu
// //trailPlotMenu(tr("Add trail dot every.."), this);
// for (int i = 0; i < uavTrailTimeCount; ++i)
// {
// trailPlotMenu.addAction(QString("%1 second%2").arg(uavTrailTimeList[i]).arg((uavTrailTimeList[i] > 1) ? "s" : ""), this, SLOT(setUAVTrailTime()));
// }
// for (int i = 0; i < uavTrailDistanceCount; ++i)
// {
// trailPlotMenu.addAction(QString("%1 meter%2").arg(uavTrailDistanceList[i]).arg((uavTrailDistanceList[i] > 1) ? "s" : ""), this, SLOT(setUAVTrailDistance()));
// }
// optionsMenu.addMenu(&trailPlotMenu);
// ui->optionsButton->setMenu(&optionsMenu);
const
int
uavTrailTimeList
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
};
// seconds
const
int
uavTrailTimeCount
=
10
;
const
int
uavTrailDistanceList
[]
=
{
1
,
2
,
5
,
10
,
20
,
50
,
100
,
200
,
500
};
// meters
const
int
uavTrailDistanceCount
=
9
;
// Set exclusive items
trailSettingsGroup
->
setExclusive
(
true
);
updateTimesGroup
->
setExclusive
(
true
);
// Build up menu
trailPlotMenu
.
setTitle
(
tr
(
"&Add trail dot every.."
));
updateTimesMenu
.
setTitle
(
tr
(
"&Limit map view update rate to.."
));
// FIXME MARK CURRENT VALUES IN MENU
for
(
int
i
=
0
;
i
<
uavTrailTimeCount
;
++
i
)
{
QAction
*
action
=
trailPlotMenu
.
addAction
(
tr
(
"%1 second%2"
).
arg
(
uavTrailTimeList
[
i
]).
arg
((
uavTrailTimeList
[
i
]
>
1
)
?
"s"
:
""
),
this
,
SLOT
(
setUAVTrailTime
()));
action
->
setData
(
uavTrailTimeList
[
i
]);
action
->
setCheckable
(
true
);
trailSettingsGroup
->
addAction
(
action
);
}
for
(
int
i
=
0
;
i
<
uavTrailDistanceCount
;
++
i
)
{
QAction
*
action
=
trailPlotMenu
.
addAction
(
tr
(
"%1 meter%2"
).
arg
(
uavTrailDistanceList
[
i
]).
arg
((
uavTrailDistanceList
[
i
]
>
1
)
?
"s"
:
""
),
this
,
SLOT
(
setUAVTrailDistance
()));
action
->
setData
(
uavTrailDistanceList
[
i
]);
action
->
setCheckable
(
true
);
trailSettingsGroup
->
addAction
(
action
);
}
optionsMenu
.
addMenu
(
&
trailPlotMenu
);
// Add update times menu
for
(
int
i
=
100
;
i
<
5000
;
i
+=
400
)
{
float
time
=
i
/
1000.0
f
;
// Convert from ms to seconds
QAction
*
action
=
updateTimesMenu
.
addAction
(
tr
(
"%1 seconds"
).
arg
(
time
),
this
,
SLOT
(
setUpdateInterval
()));
action
->
setData
(
time
);
action
->
setCheckable
(
true
);
if
(
time
==
map
->
getUpdateRateLimit
())
{
action
->
blockSignals
(
true
);
action
->
setChecked
(
true
);
action
->
blockSignals
(
false
);
}
updateTimesGroup
->
addAction
(
action
);
}
// If the current time is not part of the menu defaults
// still add it as new option
if
(
!
updateTimesGroup
->
checkedAction
())
{
float
time
=
map
->
getUpdateRateLimit
();
QAction
*
action
=
updateTimesMenu
.
addAction
(
tr
(
"uptate every %1 seconds"
).
arg
(
time
),
this
,
SLOT
(
setUpdateInterval
()));
action
->
setData
(
time
);
action
->
setCheckable
(
true
);
action
->
setChecked
(
true
);
updateTimesGroup
->
addAction
(
action
);
}
optionsMenu
.
addMenu
(
&
updateTimesMenu
);
ui
->
optionsButton
->
setMenu
(
&
optionsMenu
);
}
}
void
QGCMapToolBar
::
setUAVTrailTime
()
{
QObject
*
sender
=
QObject
::
sender
();
QAction
*
action
=
qobject_cast
<
QAction
*>
(
sender
);
if
(
action
)
{
bool
ok
;
int
trailTime
=
action
->
data
().
toInt
(
&
ok
);
if
(
ok
)
{
(
map
->
setTrailModeTimed
(
trailTime
));
ui
->
posLabel
->
setText
(
tr
(
"Trail mode: Every %1 second%2"
).
arg
(
trailTime
).
arg
((
trailTime
>
1
)
?
"s"
:
""
));
}
}
}
void
QGCMapToolBar
::
setUAVTrailDistance
()
{
QObject
*
sender
=
QObject
::
sender
();
QAction
*
action
=
qobject_cast
<
QAction
*>
(
sender
);
if
(
action
)
{
bool
ok
;
int
trailDistance
=
action
->
data
().
toInt
(
&
ok
);
if
(
ok
)
{
map
->
setTrailModeDistance
(
trailDistance
);
ui
->
posLabel
->
setText
(
tr
(
"Trail mode: Every %1 meter%2"
).
arg
(
trailDistance
).
arg
((
trailDistance
>
1
)
?
"s"
:
""
));
}
}
}
void
QGCMapToolBar
::
setUpdateInterval
()
{
QObject
*
sender
=
QObject
::
sender
();
QAction
*
action
=
qobject_cast
<
QAction
*>
(
sender
);
if
(
action
)
{
bool
ok
;
float
time
=
action
->
data
().
toFloat
(
&
ok
);
if
(
ok
)
map
->
setUpdateRateLimit
(
time
);
}
}
void
QGCMapToolBar
::
tileLoadStart
()
{
ui
->
posLabel
->
setText
(
QString
(
"Starting to load tiles.."
));
ui
->
posLabel
->
setText
(
tr
(
"Starting to load tiles.."
));
}
void
QGCMapToolBar
::
tileLoadEnd
()
{
ui
->
posLabel
->
setText
(
QString
(
"Finished"
));
ui
->
posLabel
->
setText
(
tr
(
"Finished"
));
}
void
QGCMapToolBar
::
tileLoadProgress
(
int
progress
)
{
if
(
progress
==
1
)
{
ui
->
posLabel
->
setText
(
QString
(
"1 tile to load.."
));
ui
->
posLabel
->
setText
(
tr
(
"1 tile to load.."
));
}
else
if
(
progress
>
0
)
{
ui
->
posLabel
->
setText
(
QString
(
"%1 tiles to load.."
).
arg
(
progress
));
ui
->
posLabel
->
setText
(
tr
(
"%1 tiles to load.."
).
arg
(
progress
));
}
else
{
...
...
@@ -94,4 +178,7 @@ void QGCMapToolBar::tileLoadProgress(int progress)
QGCMapToolBar
::~
QGCMapToolBar
()
{
delete
ui
;
delete
trailSettingsGroup
;
delete
updateTimesGroup
;
// FIXME Delete all actions
}
src/ui/map/QGCMapToolBar.h
View file @
551701e8
...
...
@@ -3,6 +3,7 @@
#include <QWidget>
#include <QMenu>
#include <QActionGroup>
class
QGCMapWidget
;
...
...
@@ -26,14 +27,18 @@ public slots:
void
tileLoadProgress
(
int
progress
);
void
setUAVTrailTime
();
void
setUAVTrailDistance
();
void
setUpdateInterval
();
private:
Ui
::
QGCMapToolBar
*
ui
;
protected:
QGCMapWidget
*
map
;
QMenu
optionsMenu
;
QMenu
trailPlotMenu
;
private:
Ui
::
QGCMapToolBar
*
ui
;
QMenu
updateTimesMenu
;
QActionGroup
*
trailSettingsGroup
;
QActionGroup
*
updateTimesGroup
;
};
#endif // QGCMAPTOOLBAR_H
src/ui/map/QGCMapToolBar.ui
View file @
551701e8
...
...
@@ -6,14 +6,14 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
6
69
</width>
<width>
6
93
</width>
<height>
35
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Form
</string>
</property>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
stretch=
"1,1,1,1,1,1,100,20,1"
>
<property
name=
"spacing"
>
<number>
12
</number>
</property>
...
...
@@ -70,25 +70,25 @@
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"optionsButton"
>
<property
name=
"text"
>
<string>
Options
</string>
</property>
</widget>
</item>
<item>
<spacer
name=
"horizontalSpacer"
>
<spacer
name=
"horizontalSpacer_2"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
242
</width>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
<item>
<widget
class=
"QPushButton"
name=
"optionsButton"
>
<property
name=
"text"
>
<string>
Options
</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
...
...
src/ui/map/QGCMapWidget.cc
View file @
551701e8
...
...
@@ -10,7 +10,7 @@ QGCMapWidget::QGCMapWidget(QWidget *parent) :
mapcontrol
::
OPMapWidget
(
parent
),
currWPManager
(
NULL
),
firingWaypointChange
(
NULL
),
maxUpdateInterval
(
2
),
// 2 seconds
maxUpdateInterval
(
2
.1
),
// 2 seconds
followUAVEnabled
(
false
)
{
// Widget is inactive until shown
...
...
src/ui/map/QGCMapWidget.h
View file @
551701e8
...
...
@@ -26,6 +26,8 @@ public:
/** @brief Map centered on current active system */
bool
getFollowUAVEnabled
()
{
return
followUAVEnabled
;
}
/** @brief The maximum map update rate */
float
getUpdateRateLimit
()
{
return
maxUpdateInterval
;
};
signals:
void
homePositionChanged
(
double
latitude
,
double
longitude
,
double
altitude
);
...
...
@@ -60,6 +62,24 @@ public slots:
void
cacheVisibleRegion
();
/** @brief Set follow mode */
void
setFollowUAVEnabled
(
bool
enabled
)
{
followUAVEnabled
=
enabled
;
}
/** @brief Set trail to time mode and set time */
void
setTrailModeTimed
(
int
seconds
)
{
foreach
(
mapcontrol
::
UAVItem
*
uav
,
GetUAVS
())
{
uav
->
SetTrailTime
(
seconds
);
uav
->
SetTrailType
(
mapcontrol
::
UAVTrailType
::
ByTimeElapsed
);
}
}
/** @brief Set trail to distance mode and set time */
void
setTrailModeDistance
(
int
meters
)
{
foreach
(
mapcontrol
::
UAVItem
*
uav
,
GetUAVS
())
{
uav
->
SetTrailDistance
(
meters
);
uav
->
SetTrailType
(
mapcontrol
::
UAVTrailType
::
ByDistance
);
}
}
void
loadSettings
();
void
storeSettings
();
...
...
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