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
e9637d5a
Commit
e9637d5a
authored
Jan 21, 2011
by
Mariano Lizarraga
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'experimental' of github.com:pixhawk/qgroundcontrol into experimental
Conflicts: src/ui/MainWindow.cc
parents
61c6b0af
0d1969c0
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
1173 additions
and
614 deletions
+1173
-614
earth.html
images/earth.html
+25
-28
configuration.h
src/configuration.h
+2
-2
PxQuadMAV.cc
src/uas/PxQuadMAV.cc
+9
-0
UAS.cc
src/uas/UAS.cc
+6
-0
UAS.h
src/uas/UAS.h
+2
-1
UASInterface.h
src/uas/UASInterface.h
+1
-1
UASWaypointManager.cc
src/uas/UASWaypointManager.cc
+35
-11
UASWaypointManager.h
src/uas/UASWaypointManager.h
+16
-11
HDDisplay.cc
src/ui/HDDisplay.cc
+1
-1
HSIDisplay.cc
src/ui/HSIDisplay.cc
+1
-1
HUD.cc
src/ui/HUD.cc
+249
-146
HUD.h
src/ui/HUD.h
+20
-0
MainWindow.cc
src/ui/MainWindow.cc
+329
-146
MainWindow.h
src/ui/MainWindow.h
+14
-2
MainWindow.ui
src/ui/MainWindow.ui
+35
-1
MapWidget.cc
src/ui/MapWidget.cc
+224
-76
MapWidget.h
src/ui/MapWidget.h
+29
-13
QGCMAVLinkLogPlayer.cc
src/ui/QGCMAVLinkLogPlayer.cc
+1
-1
WaypointList.cc
src/ui/WaypointList.cc
+126
-125
WaypointView.ui
src/ui/WaypointView.ui
+2
-2
LinechartWidget.cc
src/ui/linechart/LinechartWidget.cc
+1
-1
MAV2DIcon.cc
src/ui/map/MAV2DIcon.cc
+37
-37
Pixhawk3DWidget.cc
src/ui/map3D/Pixhawk3DWidget.cc
+6
-6
WaypointGroupNode.cc
src/ui/map3D/WaypointGroupNode.cc
+1
-1
UASView.cc
src/ui/uas/UASView.cc
+1
-1
No files found.
images/earth.html
View file @
e9637d5a
...
@@ -192,40 +192,38 @@ function setViewRange(dist)
...
@@ -192,40 +192,38 @@ function setViewRange(dist)
function
addTrailPosition
(
id
,
lat
,
lon
,
alt
)
function
addTrailPosition
(
id
,
lat
,
lon
,
alt
)
{
{
trails
[
id
].
setExtrude
(
false
);
trails
[
id
].
setExtrude
(
false
);
trails
[
id
].
setAltitudeMode
(
ge
.
ALTITUDE_ABSOLUTE
);
trails
[
id
].
setAltitudeMode
(
ge
.
ALTITUDE_ABSOLUTE
);
// Add LineString points
// Add LineString points
trails
[
id
].
getCoordinates
().
pushLatLngAlt
(
lat
,
lon
,
alt
);
trails
[
id
].
getCoordinates
().
pushLatLngAlt
(
lat
,
lon
,
alt
);
// Create a style and set width and color of line
// Create a style and set width and color of line
trailPlacemarks
[
id
].
setStyleSelector
(
ge
.
createStyle
(
''
));
trailPlacemarks
[
id
].
setStyleSelector
(
ge
.
createStyle
(
''
));
lineStyle
=
trailPlacemarks
[
id
].
getStyleSelector
().
getLineStyle
();
lineStyle
=
trailPlacemarks
[
id
].
getStyleSelector
().
getLineStyle
();
lineStyle
.
setWidth
(
5
);
lineStyle
.
setWidth
(
5
);
lineStyle
.
getColor
().
set
(
trailColors
[
id
]);
// aabbggrr format
lineStyle
.
getColor
().
set
(
trailColors
[
id
]);
// aabbggrr format
//lineStyle.getColor().set(color); // aabbggrr format
//lineStyle.getColor().set(color); // aabbggrr format
// Add the feature to Earth
// Add the feature to Earth
if
(
trailsVisible
[
id
]
==
true
)
ge
.
getFeatures
().
replaceChild
(
trailPlacemarks
[
id
],
trailPlacemarks
[
id
]);
if
(
trailsVisible
[
id
]
==
true
)
ge
.
getFeatures
().
replaceChild
(
trailPlacemarks
[
id
],
trailPlacemarks
[
id
]);
}
}
function
initCallback
(
object
)
function
initCallback
(
object
)
{
{
ge
=
object
;
ge
=
object
;
ge
.
getWindow
().
setVisibility
(
true
);
ge
.
getWindow
().
setVisibility
(
true
);
ge
.
getOptions
().
setStatusBarVisibility
(
true
);
ge
.
getOptions
().
setStatusBarVisibility
(
true
);
ge
.
getOptions
().
setScaleLegendVisibility
(
true
);
ge
.
getOptions
().
setScaleLegendVisibility
(
true
);
ge
.
getOptions
().
setFlyToSpeed
(
5.0
);
ge
.
getOptions
().
setFlyToSpeed
(
5.0
);
//ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT);
//ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT);
ge
.
getNavigationControl
().
setVisibility
(
ge
.
VISIBILITY_AUTO
);
ge
.
getNavigationControl
().
setVisibility
(
ge
.
VISIBILITY_AUTO
);
ge
.
getLayerRoot
().
enableLayerById
(
ge
.
LAYER_TERRAIN
,
true
);
ge
.
getLayerRoot
().
enableLayerById
(
ge
.
LAYER_TERRAIN
,
true
);
ge
.
getLayerRoot
().
enableLayerById
(
ge
.
LAYER_BUILDINGS
,
true
);
ge
.
getLayerRoot
().
enableLayerById
(
ge
.
LAYER_BUILDINGS
,
true
);
ge
.
getLayerRoot
().
enableLayerById
(
ge
.
LAYER_BORDERS
,
true
);
ge
.
getLayerRoot
().
enableLayerById
(
ge
.
LAYER_BORDERS
,
true
);
ge
.
getLayerRoot
().
enableLayerById
(
ge
.
LAYER_TREES
,
true
);
ge
.
getLayerRoot
().
enableLayerById
(
ge
.
LAYER_TREES
,
true
);
initialized
=
true
;
initialized
=
true
;
}
}
function
setAircraftPositionAttitude
(
id
,
lat
,
lon
,
alt
,
roll
,
pitch
,
yaw
)
function
setAircraftPositionAttitude
(
id
,
lat
,
lon
,
alt
,
roll
,
pitch
,
yaw
)
...
@@ -247,13 +245,12 @@ function setAircraftPositionAttitude(id, lat, lon, alt, roll, pitch, yaw)
...
@@ -247,13 +245,12 @@ function setAircraftPositionAttitude(id, lat, lon, alt, roll, pitch, yaw)
planeOrient
.
setRoll
(((
roll
/
M_PI
)
+
1.0
)
*
360.0
);
planeOrient
.
setRoll
(((
roll
/
M_PI
)
+
1.0
)
*
360.0
);
planeOrient
.
setTilt
(((
pitch
/
M_PI
)
+
1.0
)
*
360.0
);
planeOrient
.
setTilt
(((
pitch
/
M_PI
)
+
1.0
)
*
360.0
);
planeOrient
.
setHeading
(((
yaw
/
M_PI
)
+
1.0
)
*
360.0
);
planeOrient
.
setHeading
(((
yaw
/
M_PI
)
+
1.0
)
*
360.0
);
}
planeLoc
.
setLatitude
(
lat
);
planeLoc
.
setLatitude
(
lat
);
planeLoc
.
setLongitude
(
lon
);
planeLoc
.
setLongitude
(
lon
);
planeLoc
.
setAltitude
(
alt
);
planeLoc
.
setAltitude
(
alt
);
planeModel
.
setLocation
(
planeLoc
);
}
}
}
function
enableDaylight
(
enabled
)
function
enableDaylight
(
enabled
)
...
...
src/configuration.h
View file @
e9637d5a
...
@@ -17,14 +17,14 @@
...
@@ -17,14 +17,14 @@
#define WITH_TEXT_TO_SPEECH 1
#define WITH_TEXT_TO_SPEECH 1
#define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_VERSION "v. 0.8.
1
(Alpha)"
#define QGC_APPLICATION_VERSION "v. 0.8.
3
(Alpha)"
namespace
QGC
namespace
QGC
{
{
const
QString
APPNAME
=
"QGROUNDCONTROL"
;
const
QString
APPNAME
=
"QGROUNDCONTROL"
;
const
QString
COMPANYNAME
=
"OPENMAV"
;
const
QString
COMPANYNAME
=
"OPENMAV"
;
const
int
APPLICATIONVERSION
=
8
0
;
// 0.8.0
const
int
APPLICATIONVERSION
=
8
3
;
// 0.8.0
}
}
#endif // CONFIGURATION_H
#endif // CONFIGURATION_H
src/uas/PxQuadMAV.cc
View file @
e9637d5a
...
@@ -64,6 +64,15 @@ void PxQuadMAV::receiveMessage(LinkInterface* link, mavlink_message_t message)
...
@@ -64,6 +64,15 @@ void PxQuadMAV::receiveMessage(LinkInterface* link, mavlink_message_t message)
emit
valueChanged
(
uasId
,
"Temperature"
,
"raw"
,
raw
.
temp
,
time
);
emit
valueChanged
(
uasId
,
"Temperature"
,
"raw"
,
raw
.
temp
,
time
);
}
}
break
;
break
;
case
MAVLINK_MSG_ID_IMAGE_TRIGGERED
:
{
// FIXME Kind of a hack to load data from disk
mavlink_image_triggered_t
img
;
mavlink_msg_image_triggered_decode
(
&
message
,
&
img
);
qDebug
()
<<
"IMAGE AVAILABLE:"
<<
img
.
timestamp
;
emit
imageStarted
(
img
.
timestamp
);
}
break
;
case
MAVLINK_MSG_ID_PATTERN_DETECTED
:
case
MAVLINK_MSG_ID_PATTERN_DETECTED
:
{
{
mavlink_pattern_detected_t
detected
;
mavlink_pattern_detected_t
detected
;
...
...
src/uas/UAS.cc
View file @
e9637d5a
...
@@ -464,6 +464,12 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
...
@@ -464,6 +464,12 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
emit
valueChanged
(
uasId
,
"latitude"
,
"deg"
,
pos
.
lat
,
time
);
emit
valueChanged
(
uasId
,
"latitude"
,
"deg"
,
pos
.
lat
,
time
);
emit
valueChanged
(
uasId
,
"longitude"
,
"deg"
,
pos
.
lon
,
time
);
emit
valueChanged
(
uasId
,
"longitude"
,
"deg"
,
pos
.
lon
,
time
);
// FIXME REMOVE
longitude
=
pos
.
lon
;
latitude
=
pos
.
lat
;
altitude
=
pos
.
alt
;
emit
globalPositionChanged
(
this
,
longitude
,
latitude
,
altitude
,
time
);
if
(
pos
.
fix_type
>
0
)
if
(
pos
.
fix_type
>
0
)
{
{
emit
globalPositionChanged
(
this
,
pos
.
lon
,
pos
.
lat
,
pos
.
alt
,
time
);
emit
globalPositionChanged
(
this
,
pos
.
lon
,
pos
.
lat
,
pos
.
alt
,
time
);
...
...
src/uas/UAS.h
View file @
e9637d5a
...
@@ -169,7 +169,7 @@ public:
...
@@ -169,7 +169,7 @@ public:
bool
isAuto
();
bool
isAuto
();
public:
public:
UASWaypointManager
&
getWaypointManager
(
void
)
{
return
waypointManager
;
}
UASWaypointManager
*
getWaypointManager
()
{
return
&
waypointManager
;
}
int
getSystemType
();
int
getSystemType
();
int
getAutopilotType
()
{
return
autopilot
;}
int
getAutopilotType
()
{
return
autopilot
;}
...
@@ -303,6 +303,7 @@ signals:
...
@@ -303,6 +303,7 @@ signals:
void
loadChanged
(
UASInterface
*
uas
,
double
load
);
void
loadChanged
(
UASInterface
*
uas
,
double
load
);
/** @brief Propagate a heartbeat received from the system */
/** @brief Propagate a heartbeat received from the system */
void
heartbeat
(
UASInterface
*
uas
);
void
heartbeat
(
UASInterface
*
uas
);
void
imageStarted
(
quint64
timestamp
);
protected:
protected:
/** @brief Get the UNIX timestamp in microseconds */
/** @brief Get the UNIX timestamp in microseconds */
...
...
src/uas/UASInterface.h
View file @
e9637d5a
...
@@ -79,7 +79,7 @@ public:
...
@@ -79,7 +79,7 @@ public:
virtual
double
getYaw
()
const
=
0
;
virtual
double
getYaw
()
const
=
0
;
/** @brief Get reference to the waypoint manager **/
/** @brief Get reference to the waypoint manager **/
virtual
UASWaypointManager
&
getWaypointManager
(
void
)
=
0
;
virtual
UASWaypointManager
*
getWaypointManager
(
void
)
=
0
;
/* COMMUNICATION FLAGS */
/* COMMUNICATION FLAGS */
...
...
src/uas/UASWaypointManager.cc
View file @
e9637d5a
...
@@ -265,6 +265,13 @@ void UASWaypointManager::handleWaypointCurrent(quint8 systemId, quint8 compId, m
...
@@ -265,6 +265,13 @@ void UASWaypointManager::handleWaypointCurrent(quint8 systemId, quint8 compId, m
}
}
}
}
void
UASWaypointManager
::
notifyOfChange
(
Waypoint
*
wp
)
{
Q_UNUSED
(
wp
);
emit
waypointListChanged
();
emit
waypointListChanged
(
uas
.
getUASID
());
}
int
UASWaypointManager
::
setCurrentWaypoint
(
quint16
seq
)
int
UASWaypointManager
::
setCurrentWaypoint
(
quint16
seq
)
{
{
if
(
seq
<
waypoints
.
size
())
if
(
seq
<
waypoints
.
size
())
...
@@ -313,6 +320,9 @@ void UASWaypointManager::addWaypoint(Waypoint *wp)
...
@@ -313,6 +320,9 @@ void UASWaypointManager::addWaypoint(Waypoint *wp)
waypoints
.
insert
(
waypoints
.
size
(),
wp
);
waypoints
.
insert
(
waypoints
.
size
(),
wp
);
emit
waypointListChanged
();
emit
waypointListChanged
();
emit
waypointListChanged
(
uas
.
getUASID
());
qDebug
()
<<
"ADDED WAYPOINT WITH ID:"
<<
wp
->
getId
();
}
}
}
}
...
@@ -329,6 +339,7 @@ int UASWaypointManager::removeWaypoint(quint16 seq)
...
@@ -329,6 +339,7 @@ int UASWaypointManager::removeWaypoint(quint16 seq)
waypoints
[
i
]
->
setId
(
i
);
waypoints
[
i
]
->
setId
(
i
);
}
}
emit
waypointListChanged
();
emit
waypointListChanged
();
emit
waypointListChanged
(
uas
.
getUASID
());
return
0
;
return
0
;
}
}
return
-
1
;
return
-
1
;
...
@@ -359,6 +370,7 @@ void UASWaypointManager::moveWaypoint(quint16 cur_seq, quint16 new_seq)
...
@@ -359,6 +370,7 @@ void UASWaypointManager::moveWaypoint(quint16 cur_seq, quint16 new_seq)
//waypoints[new_seq]->setId(new_seq);
//waypoints[new_seq]->setId(new_seq);
emit
waypointListChanged
();
emit
waypointListChanged
();
emit
waypointListChanged
(
uas
.
getUASID
());
}
}
}
}
...
@@ -425,21 +437,28 @@ void UASWaypointManager::loadWaypoints(const QString &loadFile)
...
@@ -425,21 +437,28 @@ void UASWaypointManager::loadWaypoints(const QString &loadFile)
emit
loadWPFile
();
emit
loadWPFile
();
emit
waypointListChanged
();
emit
waypointListChanged
();
emit
waypointListChanged
(
uas
.
getUASID
());
}
}
void
UASWaypointManager
::
globalAddWaypoint
(
Waypoint
*
wp
)
//
void UASWaypointManager::globalAddWaypoint(Waypoint *wp)
{
//
{
// FIXME Will be removed
//
// FIXME Will be removed
Q_UNUSED
(
wp
);
//
Q_UNUSED(wp);
}
//
}
int
UASWaypointManager
::
globalRemoveWaypoint
(
quint16
seq
)
//int UASWaypointManager::globalRemoveWaypoint(quint16 seq)
{
//{
// FIXME Will be removed
// // FIXME Will be removed
Q_UNUSED
(
seq
);
// Q_UNUSED(seq);
return
0
;
// return 0;
}
//}
//void UASWaypointManager::waypointUpdated(Waypoint*)
//{
// // FIXME Add rate limiter
// emit waypointListChanged(uas.getUASID());
//}
void
UASWaypointManager
::
clearWaypointList
()
void
UASWaypointManager
::
clearWaypointList
()
{
{
...
@@ -457,6 +476,11 @@ void UASWaypointManager::clearWaypointList()
...
@@ -457,6 +476,11 @@ void UASWaypointManager::clearWaypointList()
}
}
}
}
int
UASWaypointManager
::
getIndexOf
(
Waypoint
*
wp
)
{
return
waypoints
.
indexOf
(
wp
);
}
void
UASWaypointManager
::
readWaypoints
()
void
UASWaypointManager
::
readWaypoints
()
{
{
emit
readGlobalWPFromUAS
(
true
);
emit
readGlobalWPFromUAS
(
true
);
...
...
src/uas/UASWaypointManager.h
View file @
e9637d5a
...
@@ -86,25 +86,27 @@ public:
...
@@ -86,25 +86,27 @@ public:
/** @name Waypoint list operations */
/** @name Waypoint list operations */
/*@{*/
/*@{*/
const
QVector
<
Waypoint
*>
&
getWaypointList
(
void
)
{
return
waypoints
;
}
///< Returns a const reference to the waypoint list.
const
QVector
<
Waypoint
*>
&
getWaypointList
(
void
)
{
return
waypoints
;
}
///< Returns a const reference to the waypoint list.
void
addWaypoint
(
Waypoint
*
wp
);
///< adds a new waypoint to the end of the list and changes its sequence number accordingly
int
removeWaypoint
(
quint16
seq
);
///< locally remove the specified waypoint from the storage
int
removeWaypoint
(
quint16
seq
);
///< locally remove the specified waypoint from the storage
void
moveWaypoint
(
quint16
cur_seq
,
quint16
new_seq
);
///< locally move a waypoint from its current position cur_seq to a new position new_seq
void
moveWaypoint
(
quint16
cur_seq
,
quint16
new_seq
);
///< locally move a waypoint from its current position cur_seq to a new position new_seq
void
saveWaypoints
(
const
QString
&
saveFile
);
///< saves the local waypoint list to saveFile
void
saveWaypoints
(
const
QString
&
saveFile
);
///< saves the local waypoint list to saveFile
void
loadWaypoints
(
const
QString
&
loadFile
);
///< loads a waypoint list from loadFile
void
loadWaypoints
(
const
QString
&
loadFile
);
///< loads a waypoint list from loadFile
void
notifyOfChange
(
Waypoint
*
wp
);
///< Notifies manager to changes to a waypoint
void
localAddWaypoint
(
Waypoint
*
wp
);
///< locally adds a new waypoint to the end of the list and changes its sequence number accordingly
void
localAddWaypoint
(
Waypoint
*
wp
);
///< locally adds a new waypoint to the end of the list and changes its sequence number accordingly
int
localRemoveWaypoint
(
quint16
seq
);
///< locally remove the specified waypoint from the storage
int
localRemoveWaypoint
(
quint16
seq
);
///< locally remove the specified waypoint from the storage
void
localMoveWaypoint
(
quint16
cur_seq
,
quint16
new_seq
);
///< locally move a waypoint from its current position cur_seq to a new position new_seq
void
localMoveWaypoint
(
quint16
cur_seq
,
quint16
new_seq
);
///< locally move a waypoint from its current position cur_seq to a new position new_seq
void
localSaveWaypoints
(
const
QString
&
saveFile
);
///< saves the local waypoint list to saveFile
void
localSaveWaypoints
(
const
QString
&
saveFile
);
///< saves the local waypoint list to saveFile
void
localLoadWaypoints
(
const
QString
&
loadFile
);
///< loads a waypoint list from loadFile
void
localLoadWaypoints
(
const
QString
&
loadFile
);
///< loads a waypoint list from loadFile
int
getIndexOf
(
Waypoint
*
wp
);
///< Get the index of a waypoint in the list
/*@}*/
/*@}*/
/** @name Global waypoint list operations */
UAS
&
getUAS
()
{
return
this
->
uas
;
}
///< Returns the owning UAS
/*@{*/
const
QVector
<
Waypoint
*>
&
getGlobalWaypointList
(
void
)
{
return
waypoints
;
}
///< Returns a const reference to the global waypoint list.
// /** @name Global waypoint list operations */
void
globalAddWaypoint
(
Waypoint
*
wp
);
///< locally adds a new waypoint to the end of the list and changes its sequence number accordingly
// /*@{*/
int
globalRemoveWaypoint
(
quint16
seq
);
///< locally remove the specified waypoint from the storage
// const QVector<Waypoint *> &getGlobalWaypointList(void) { return waypoints; } ///< Returns a const reference to the global waypoint list.
/*@}*/
// void globalAddWaypoint(Waypoint *wp); ///< locally adds a new waypoint to the end of the list and changes its sequence number accordingly
// int globalRemoveWaypoint(quint16 seq); ///< locally remove the specified waypoint from the storage
// /*@}*/
private:
private:
/** @name Message send functions */
/** @name Message send functions */
...
@@ -120,14 +122,17 @@ private:
...
@@ -120,14 +122,17 @@ private:
public
slots
:
public
slots
:
void
timeout
();
///< Called by the timer if a response times out. Handles send retries.
void
timeout
();
///< Called by the timer if a response times out. Handles send retries.
void
addWaypoint
(
Waypoint
*
wp
);
///< adds a new waypoint to the end of the list and changes its sequence number accordingly
signals:
signals:
void
waypointListChanged
(
void
);
///< emits signal that the local waypoint list has been changed
void
waypointListChanged
(
void
);
///< emits signal that the waypoint list has been changed
void
waypointListChanged
(
int
uasid
);
///< Emits signal that list has been changed
void
waypointChanged
(
int
uasid
,
Waypoint
*
wp
);
///< emits signal that waypoint has been changed
void
currentWaypointChanged
(
quint16
);
///< emits the new current waypoint sequence number
void
currentWaypointChanged
(
quint16
);
///< emits the new current waypoint sequence number
void
updateStatusString
(
const
QString
&
);
///< emits the current status string
void
updateStatusString
(
const
QString
&
);
///< emits the current status string
void
loadWPFile
();
///< emits signal that a file wp has been load
void
loadWPFile
();
///< emits signal that a file wp has been load
void
readGlobalWPFromUAS
(
bool
value
);
///< emits signal when finish to read Global WP from UAS
void
readGlobalWPFromUAS
(
bool
value
);
///< emits signal when finish to read Global WP from UAS
private:
private:
UAS
&
uas
;
///< Reference to the corresponding UAS
UAS
&
uas
;
///< Reference to the corresponding UAS
...
...
src/ui/HDDisplay.cc
View file @
e9637d5a
...
@@ -152,7 +152,7 @@ HDDisplay::~HDDisplay()
...
@@ -152,7 +152,7 @@ HDDisplay::~HDDisplay()
QSize
HDDisplay
::
sizeHint
()
const
QSize
HDDisplay
::
sizeHint
()
const
{
{
return
QSize
(
400
,
400.0
f
*
(
vwidth
/
vheight
)
*
1.
1
f
);
return
QSize
(
400
,
400.0
f
*
(
vwidth
/
vheight
)
*
1.
2
f
);
}
}
void
HDDisplay
::
enableGLRendering
(
bool
enable
)
void
HDDisplay
::
enableGLRendering
(
bool
enable
)
...
...
src/ui/HSIDisplay.cc
View file @
e9637d5a
...
@@ -678,7 +678,7 @@ void HSIDisplay::drawWaypoints(QPainter& painter)
...
@@ -678,7 +678,7 @@ void HSIDisplay::drawWaypoints(QPainter& painter)
{
{
if
(
uas
)
if
(
uas
)
{
{
const
QVector
<
Waypoint
*>&
list
=
uas
->
getWaypointManager
().
getWaypointList
();
const
QVector
<
Waypoint
*>&
list
=
uas
->
getWaypointManager
()
->
getWaypointList
();
// for (int i = 0; i < list.size(); i++)
// for (int i = 0; i < list.size(); i++)
// {
// {
// QPointF in(list.at(i)->getX(), list.at(i)->getY());
// QPointF in(list.at(i)->getX(), list.at(i)->getY());
...
...
src/ui/HUD.cc
View file @
e9637d5a
...
@@ -30,6 +30,10 @@ This file is part of the QGROUNDCONTROL project
...
@@ -30,6 +30,10 @@ This file is part of the QGROUNDCONTROL project
*/
*/
#include <QShowEvent>
#include <QShowEvent>
#include <QContextMenuEvent>
#include <QMenu>
#include <QDesktopServices>
#include <QFileDialog>
#include <QDebug>
#include <QDebug>
#include <cmath>
#include <cmath>
...
@@ -39,6 +43,7 @@ This file is part of the QGROUNDCONTROL project
...
@@ -39,6 +43,7 @@ This file is part of the QGROUNDCONTROL project
#include <limits>
#include <limits>
#include "UASManager.h"
#include "UASManager.h"
#include "UAS.h"
#include "HUD.h"
#include "HUD.h"
#include "MG.h"
#include "MG.h"
#include "QGC.h"
#include "QGC.h"
...
@@ -124,7 +129,13 @@ HUD::HUD(int width, int height, QWidget* parent)
...
@@ -124,7 +129,13 @@ HUD::HUD(int width, int height, QWidget* parent)
lat
(
0.0
),
lat
(
0.0
),
lon
(
0.0
),
lon
(
0.0
),
alt
(
0.0
),
alt
(
0.0
),
load
(
0.0
f
)
load
(
0.0
f
),
offlineDirectory
(
""
),
nextOfflineImage
(
""
),
hudInstrumentsEnabled
(
true
),
videoEnabled
(
false
),
xImageFactor
(
1.0
),
yImageFactor
(
1.0
)
{
{
// Set auto fill to false
// Set auto fill to false
setAutoFillBackground
(
false
);
setAutoFillBackground
(
false
);
...
@@ -183,6 +194,10 @@ HUD::HUD(int width, int height, QWidget* parent)
...
@@ -183,6 +194,10 @@ HUD::HUD(int width, int height, QWidget* parent)
// Connect with UAS
// Connect with UAS
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
UASInterface
*
)),
this
,
SLOT
(
setActiveUAS
(
UASInterface
*
)));
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
UASInterface
*
)),
this
,
SLOT
(
setActiveUAS
(
UASInterface
*
)));
createActions
();
if
(
UASManager
::
instance
()
->
getActiveUAS
()
!=
NULL
)
setActiveUAS
(
UASManager
::
instance
()
->
getActiveUAS
());
setVisible
(
false
);
setVisible
(
false
);
}
}
...
@@ -212,6 +227,40 @@ void HUD::hideEvent(QHideEvent* event)
...
@@ -212,6 +227,40 @@ void HUD::hideEvent(QHideEvent* event)
refreshTimer
->
stop
();
refreshTimer
->
stop
();
}
}
void
HUD
::
contextMenuEvent
(
QContextMenuEvent
*
event
)
{
QMenu
menu
(
this
);
// Update actions
enableHUDAction
->
setChecked
(
hudInstrumentsEnabled
);
enableVideoAction
->
setChecked
(
videoEnabled
);
menu
.
addAction
(
enableHUDAction
);
//menu.addAction(selectHUDColorAction);
menu
.
addAction
(
enableVideoAction
);
menu
.
addAction
(
selectOfflineDirectoryAction
);
//menu.addAction(selectVideoChannelAction);
menu
.
exec
(
event
->
globalPos
());
}
void
HUD
::
createActions
()
{
enableHUDAction
=
new
QAction
(
tr
(
"Enable HUD"
),
this
);
enableHUDAction
->
setStatusTip
(
tr
(
"Show the HUD instruments in this window"
));
enableHUDAction
->
setCheckable
(
true
);
enableHUDAction
->
setChecked
(
hudInstrumentsEnabled
);
connect
(
enableHUDAction
,
SIGNAL
(
triggered
(
bool
)),
this
,
SLOT
(
enableHUDInstruments
(
bool
)));
enableVideoAction
=
new
QAction
(
tr
(
"Enable Video Live feed"
),
this
);
enableVideoAction
->
setStatusTip
(
tr
(
"Show the video live feed"
));
enableVideoAction
->
setCheckable
(
true
);
enableVideoAction
->
setChecked
(
videoEnabled
);
connect
(
enableVideoAction
,
SIGNAL
(
triggered
(
bool
)),
this
,
SLOT
(
enableVideo
(
bool
)));
selectOfflineDirectoryAction
=
new
QAction
(
tr
(
"Select image log"
),
this
);
selectOfflineDirectoryAction
->
setStatusTip
(
tr
(
"Load previously logged images into simulation / replay"
));
connect
(
selectOfflineDirectoryAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
selectOfflineDirectory
()));
}
/**
/**
*
*
* @param uas the UAS/MAV to monitor/display with the HUD
* @param uas the UAS/MAV to monitor/display with the HUD
...
@@ -230,22 +279,39 @@ void HUD::setActiveUAS(UASInterface* uas)
...
@@ -230,22 +279,39 @@ void HUD::setActiveUAS(UASInterface* uas)
disconnect
(
uas
,
SIGNAL
(
localPositionChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateLocalPosition
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
disconnect
(
uas
,
SIGNAL
(
localPositionChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateLocalPosition
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
disconnect
(
uas
,
SIGNAL
(
speedChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateSpeed
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
disconnect
(
uas
,
SIGNAL
(
speedChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateSpeed
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
disconnect
(
uas
,
SIGNAL
(
waypointSelected
(
int
,
int
)),
this
,
SLOT
(
selectWaypoint
(
int
,
int
)));
disconnect
(
uas
,
SIGNAL
(
waypointSelected
(
int
,
int
)),
this
,
SLOT
(
selectWaypoint
(
int
,
int
)));
}
// Now connect the new UAS
// Try to disconnect the image link
// Setup communication
UAS
*
u
=
dynamic_cast
<
UAS
*>
(
uas
);
connect
(
uas
,
SIGNAL
(
attitudeChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateAttitude
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
if
(
u
)
connect
(
uas
,
SIGNAL
(
batteryChanged
(
UASInterface
*
,
double
,
double
,
int
)),
this
,
SLOT
(
updateBattery
(
UASInterface
*
,
double
,
double
,
int
)));
{
connect
(
uas
,
SIGNAL
(
statusChanged
(
UASInterface
*
,
QString
,
QString
)),
this
,
SLOT
(
updateState
(
UASInterface
*
,
QString
)));
disconnect
(
u
,
SIGNAL
(
imageStarted
(
quint64
)),
this
,
SLOT
(
startImage
(
quint64
)));
connect
(
uas
,
SIGNAL
(
modeChanged
(
int
,
QString
,
QString
)),
this
,
SLOT
(
updateMode
(
int
,
QString
,
QString
)));
}
connect
(
uas
,
SIGNAL
(
heartbeat
(
UASInterface
*
)),
this
,
SLOT
(
receiveHeartbeat
(
UASInterface
*
)));
}
connect
(
uas
,
SIGNAL
(
localPositionChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateLocalPosition
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
if
(
uas
)
connect
(
uas
,
SIGNAL
(
speedChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateSpeed
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
{
connect
(
uas
,
SIGNAL
(
waypointSelected
(
int
,
int
)),
this
,
SLOT
(
selectWaypoint
(
int
,
int
)));
// Now connect the new UAS
// Setup communication
connect
(
uas
,
SIGNAL
(
attitudeChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateAttitude
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
connect
(
uas
,
SIGNAL
(
batteryChanged
(
UASInterface
*
,
double
,
double
,
int
)),
this
,
SLOT
(
updateBattery
(
UASInterface
*
,
double
,
double
,
int
)));
connect
(
uas
,
SIGNAL
(
statusChanged
(
UASInterface
*
,
QString
,
QString
)),
this
,
SLOT
(
updateState
(
UASInterface
*
,
QString
)));
connect
(
uas
,
SIGNAL
(
modeChanged
(
int
,
QString
,
QString
)),
this
,
SLOT
(
updateMode
(
int
,
QString
,
QString
)));
connect
(
uas
,
SIGNAL
(
heartbeat
(
UASInterface
*
)),
this
,
SLOT
(
receiveHeartbeat
(
UASInterface
*
)));
connect
(
uas
,
SIGNAL
(
localPositionChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateLocalPosition
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
connect
(
uas
,
SIGNAL
(
speedChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateSpeed
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
connect
(
uas
,
SIGNAL
(
waypointSelected
(
int
,
int
)),
this
,
SLOT
(
selectWaypoint
(
int
,
int
)));
// Try to connect the image link
UAS
*
u
=
dynamic_cast
<
UAS
*>
(
uas
);
if
(
u
)
{
connect
(
u
,
SIGNAL
(
imageStarted
(
quint64
)),
this
,
SLOT
(
startImage
(
quint64
)));
}
// Set new UAS
// Set new UAS
this
->
uas
=
uas
;
this
->
uas
=
uas
;
}
}
}
//void HUD::updateAttitudeThrustSetPoint(UASInterface* uas, double rollDesired, double pitchDesired, double yawDesired, double thrustDesired, quint64 msec)
//void HUD::updateAttitudeThrustSetPoint(UASInterface* uas, double rollDesired, double pitchDesired, double yawDesired, double thrustDesired, quint64 msec)
...
@@ -609,174 +675,183 @@ void HUD::paintHUD()
...
@@ -609,174 +675,183 @@ void HUD::paintHUD()
glPushMatrix
();
glPushMatrix
();
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
// Blue / Brown background
if
(
noCamera
)
{
paintCenterBackground
(
roll
,
pitch
,
yawTrans
);
}
// else {
// Fill with black background
// Fill with black background
QString
imagePath
=
"/Users/user/Desktop/frame0000.png"
;
if
(
videoEnabled
)
if
(
QFileInfo
(
imagePath
).
exists
())
{
{
//qDebug() << __FILE__ << __LINE__ << "template image:" << imagePath;
if
(
nextOfflineImage
!=
""
&&
QFileInfo
(
nextOfflineImage
).
exists
())
QImage
fill
=
QImage
(
imagePath
);
{
qDebug
()
<<
__FILE__
<<
__LINE__
<<
"template image:"
<<
nextOfflineImage
;
QImage
fill
=
QImage
(
nextOfflineImage
);
glImage
=
QGLWidget
::
convertToGLFormat
(
fill
);
xImageFactor
=
width
()
/
(
float
)
fill
.
width
();
yImageFactor
=
height
()
/
(
float
)
fill
.
height
();
float
xFactor
;
glImage
=
QGLWidget
::
convertToGLFormat
(
fill
);
float
yFactor
;
xFactor
=
width
()
/
(
float
)
fill
.
width
();
// Reset to save load efforts
yFactor
=
height
()
/
(
float
)
fill
.
height
();
nextOfflineImage
=
""
;
}
glPixelZoom
(
x
Factor
,
y
Factor
);
glPixelZoom
(
x
ImageFactor
,
yImage
Factor
);
// Resize to correct size and fill with image
// Resize to correct size and fill with image
glDrawPixels
(
glImage
.
width
(),
glImage
.
height
(),
GL_RGBA
,
GL_UNSIGNED_BYTE
,
glImage
.
bits
());
glDrawPixels
(
glImage
.
width
(),
glImage
.
height
(),
GL_RGBA
,
GL_UNSIGNED_BYTE
,
glImage
.
bits
());
// FIXME Adjust viewport to scale image into view
}
else
{
// Blue / brown background
paintCenterBackground
(
roll
,
pitch
,
yawTrans
);
}
}
// }
glMatrixMode
(
GL_MODELVIEW
);
glMatrixMode
(
GL_MODELVIEW
);
glPopMatrix
();
glPopMatrix
();
// END OF OPENGL PAINTING
// END OF OPENGL PAINTING
if
(
hudInstrumentsEnabled
)
{
//glEnable(GL_MULTISAMPLE);
// QT PAINTING
//makeCurrent();
QPainter
painter
;
painter
.
begin
(
this
);
painter
.
setRenderHint
(
QPainter
::
Antialiasing
,
true
);
painter
.
setRenderHint
(
QPainter
::
HighQualityAntialiasing
,
true
);
painter
.
translate
((
this
->
vwidth
/
2.0
+
xCenterOffset
)
*
scalingFactor
,
(
this
->
vheight
/
2.0
+
yCenterOffset
)
*
scalingFactor
);
// COORDINATE FRAME IS NOW (0,0) at CENTER OF WIDGET
// Draw all fixed indicators
// MODE
paintText
(
mode
,
infoColor
,
2.0
f
,
(
-
vwidth
/
2.0
)
+
10
,
-
vheight
/
2.0
+
10
,
&
painter
);
// STATE
paintText
(
state
,
infoColor
,
2.0
f
,
(
-
vwidth
/
2.0
)
+
10
,
-
vheight
/
2.0
+
15
,
&
painter
);
// BATTERY
paintText
(
fuelStatus
,
fuelColor
,
2.0
f
,
(
-
vwidth
/
2.0
)
+
10
,
-
vheight
/
2.0
+
20
,
&
painter
);
// Waypoint
paintText
(
waypointName
,
defaultColor
,
2.0
f
,
(
-
vwidth
/
3.0
)
+
10
,
+
vheight
/
3.0
+
15
,
&
painter
);
//glEnable(GL_MULTISAMPLE);
// YAW INDICATOR
//
// QT PAINTING
// .
//makeCurrent();
// . .
QPainter
painter
;
// .......
painter
.
begin
(
this
);
//
painter
.
setRenderHint
(
QPainter
::
Antialiasing
,
true
);
const
float
yawIndicatorWidth
=
4.0
f
;
painter
.
setRenderHint
(
QPainter
::
HighQualityAntialiasing
,
true
);
const
float
yawIndicatorY
=
vheight
/
2.0
f
-
10.0
f
;
painter
.
translate
((
this
->
vwidth
/
2.0
+
xCenterOffset
)
*
scalingFactor
,
(
this
->
vheight
/
2.0
+
yCenterOffset
)
*
scalingFactor
);
QPolygon
yawIndicator
(
4
);
yawIndicator
.
setPoint
(
0
,
QPoint
(
refToScreenX
(
0.0
f
),
refToScreenY
(
yawIndicatorY
)));
yawIndicator
.
setPoint
(
1
,
QPoint
(
refToScreenX
(
yawIndicatorWidth
/
2.0
f
),
refToScreenY
(
yawIndicatorY
+
yawIndicatorWidth
)));
yawIndicator
.
setPoint
(
2
,
QPoint
(
refToScreenX
(
-
yawIndicatorWidth
/
2.0
f
),
refToScreenY
(
yawIndicatorY
+
yawIndicatorWidth
)));
// COORDINATE FRAME IS NOW (0,0) at CENTER OF WIDGET
yawIndicator
.
setPoint
(
3
,
QPoint
(
refToScreenX
(
0.0
f
),
refToScreenY
(
yawIndicatorY
)));
painter
.
setPen
(
defaultColor
);
painter
.
drawPolyline
(
yawIndicator
);
// Draw all fixed indicators
// MODE
paintText
(
mode
,
infoColor
,
2.0
f
,
(
-
vwidth
/
2.0
)
+
10
,
-
vheight
/
2.0
+
10
,
&
painter
);
// STATE
paintText
(
state
,
infoColor
,
2.0
f
,
(
-
vwidth
/
2.0
)
+
10
,
-
vheight
/
2.0
+
15
,
&
painter
);
// BATTERY
paintText
(
fuelStatus
,
fuelColor
,
2.0
f
,
(
-
vwidth
/
2.0
)
+
10
,
-
vheight
/
2.0
+
20
,
&
painter
);
// Waypoint
paintText
(
waypointName
,
defaultColor
,
2.0
f
,
(
-
vwidth
/
3.0
)
+
10
,
+
vheight
/
3.0
+
15
,
&
painter
);
// YAW INDICATOR
//
// .
// . .
// .......
//
const
float
yawIndicatorWidth
=
4.0
f
;
const
float
yawIndicatorY
=
vheight
/
2.0
f
-
10.0
f
;
QPolygon
yawIndicator
(
4
);
yawIndicator
.
setPoint
(
0
,
QPoint
(
refToScreenX
(
0.0
f
),
refToScreenY
(
yawIndicatorY
)));
yawIndicator
.
setPoint
(
1
,
QPoint
(
refToScreenX
(
yawIndicatorWidth
/
2.0
f
),
refToScreenY
(
yawIndicatorY
+
yawIndicatorWidth
)));
yawIndicator
.
setPoint
(
2
,
QPoint
(
refToScreenX
(
-
yawIndicatorWidth
/
2.0
f
),
refToScreenY
(
yawIndicatorY
+
yawIndicatorWidth
)));
yawIndicator
.
setPoint
(
3
,
QPoint
(
refToScreenX
(
0.0
f
),
refToScreenY
(
yawIndicatorY
)));
painter
.
setPen
(
defaultColor
);
painter
.
drawPolyline
(
yawIndicator
);
// CENTER
// CENTER
// HEADING INDICATOR
// HEADING INDICATOR
//
//
// __ __
// __ __
// \/\/
// \/\/
//
//
const
float
hIndicatorWidth
=
7.0
f
;
const
float
hIndicatorWidth
=
7.0
f
;
const
float
hIndicatorY
=
-
25.0
f
;
const
float
hIndicatorY
=
-
25.0
f
;
const
float
hIndicatorYLow
=
hIndicatorY
+
hIndicatorWidth
/
6.0
f
;
const
float
hIndicatorYLow
=
hIndicatorY
+
hIndicatorWidth
/
6.0
f
;
const
float
hIndicatorSegmentWidth
=
hIndicatorWidth
/
7.0
f
;
const
float
hIndicatorSegmentWidth
=
hIndicatorWidth
/
7.0
f
;
QPolygon
hIndicator
(
7
);
QPolygon
hIndicator
(
7
);
hIndicator
.
setPoint
(
0
,
QPoint
(
refToScreenX
(
0.0
f
-
hIndicatorWidth
/
2.0
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
0
,
QPoint
(
refToScreenX
(
0.0
f
-
hIndicatorWidth
/
2.0
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
1
,
QPoint
(
refToScreenX
(
0.0
f
-
hIndicatorWidth
/
2.0
f
+
hIndicatorSegmentWidth
*
1.75
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
1
,
QPoint
(
refToScreenX
(
0.0
f
-
hIndicatorWidth
/
2.0
f
+
hIndicatorSegmentWidth
*
1.75
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
2
,
QPoint
(
refToScreenX
(
0.0
f
-
hIndicatorSegmentWidth
*
1.0
f
),
refToScreenY
(
hIndicatorYLow
)));
hIndicator
.
setPoint
(
2
,
QPoint
(
refToScreenX
(
0.0
f
-
hIndicatorSegmentWidth
*
1.0
f
),
refToScreenY
(
hIndicatorYLow
)));
hIndicator
.
setPoint
(
3
,
QPoint
(
refToScreenX
(
0.0
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
3
,
QPoint
(
refToScreenX
(
0.0
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
4
,
QPoint
(
refToScreenX
(
0.0
f
+
hIndicatorSegmentWidth
*
1.0
f
),
refToScreenY
(
hIndicatorYLow
)));
hIndicator
.
setPoint
(
4
,
QPoint
(
refToScreenX
(
0.0
f
+
hIndicatorSegmentWidth
*
1.0
f
),
refToScreenY
(
hIndicatorYLow
)));
hIndicator
.
setPoint
(
5
,
QPoint
(
refToScreenX
(
0.0
f
+
hIndicatorWidth
/
2.0
f
-
hIndicatorSegmentWidth
*
1.75
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
5
,
QPoint
(
refToScreenX
(
0.0
f
+
hIndicatorWidth
/
2.0
f
-
hIndicatorSegmentWidth
*
1.75
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
6
,
QPoint
(
refToScreenX
(
0.0
f
+
hIndicatorWidth
/
2.0
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
6
,
QPoint
(
refToScreenX
(
0.0
f
+
hIndicatorWidth
/
2.0
f
),
refToScreenY
(
hIndicatorY
)));
painter
.
setPen
(
defaultColor
);
painter
.
setPen
(
defaultColor
);
painter
.
drawPolyline
(
hIndicator
);
painter
.
drawPolyline
(
hIndicator
);
// SETPOINT
// SETPOINT
const
float
centerWidth
=
4.0
f
;
const
float
centerWidth
=
4.0
f
;
painter
.
setPen
(
defaultColor
);
painter
.
setPen
(
defaultColor
);
painter
.
setBrush
(
Qt
::
NoBrush
);
painter
.
setBrush
(
Qt
::
NoBrush
);
// TODO
// TODO
//painter.drawEllipse(QPointF(refToScreenX(qMin(10.0f, values.value("roll desired", 0.0f) * 10.0f)), refToScreenY(qMin(10.0f, values.value("pitch desired", 0.0f) * 10.0f))), refToScreenX(centerWidth/2.0f), refToScreenX(centerWidth/2.0f));
//painter.drawEllipse(QPointF(refToScreenX(qMin(10.0f, values.value("roll desired", 0.0f) * 10.0f)), refToScreenY(qMin(10.0f, values.value("pitch desired", 0.0f) * 10.0f))), refToScreenX(centerWidth/2.0f), refToScreenX(centerWidth/2.0f));
const
float
centerCrossWidth
=
10.0
f
;
const
float
centerCrossWidth
=
10.0
f
;
// left
// left
painter
.
drawLine
(
QPointF
(
refToScreenX
(
-
centerWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)),
QPointF
(
refToScreenX
(
-
centerCrossWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)));
painter
.
drawLine
(
QPointF
(
refToScreenX
(
-
centerWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)),
QPointF
(
refToScreenX
(
-
centerCrossWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)));
// right
// right
painter
.
drawLine
(
QPointF
(
refToScreenX
(
centerWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)),
QPointF
(
refToScreenX
(
centerCrossWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)));
painter
.
drawLine
(
QPointF
(
refToScreenX
(
centerWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)),
QPointF
(
refToScreenX
(
centerCrossWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)));
// top
// top
painter
.
drawLine
(
QPointF
(
refToScreenX
(
0.0
f
),
refToScreenY
(
-
centerWidth
/
2.0
f
)),
QPointF
(
refToScreenX
(
0.0
f
),
refToScreenY
(
-
centerCrossWidth
/
2.0
f
)));
painter
.
drawLine
(
QPointF
(
refToScreenX
(
0.0
f
),
refToScreenY
(
-
centerWidth
/
2.0
f
)),
QPointF
(
refToScreenX
(
0.0
f
),
refToScreenY
(
-
centerCrossWidth
/
2.0
f
)));
// COMPASS
// COMPASS
const
float
compassY
=
-
vheight
/
2.0
f
+
10.0
f
;
const
float
compassY
=
-
vheight
/
2.0
f
+
10.0
f
;
QRectF
compassRect
(
QPointF
(
refToScreenX
(
-
5.0
f
),
refToScreenY
(
compassY
)),
QSizeF
(
refToScreenX
(
10.0
f
),
refToScreenY
(
5.0
f
)));
QRectF
compassRect
(
QPointF
(
refToScreenX
(
-
5.0
f
),
refToScreenY
(
compassY
)),
QSizeF
(
refToScreenX
(
10.0
f
),
refToScreenY
(
5.0
f
)));
painter
.
setBrush
(
Qt
::
NoBrush
);
painter
.
setBrush
(
Qt
::
NoBrush
);
painter
.
setPen
(
Qt
::
SolidLine
);
painter
.
setPen
(
Qt
::
SolidLine
);
painter
.
setPen
(
defaultColor
);
painter
.
setPen
(
defaultColor
);
painter
.
drawRoundedRect
(
compassRect
,
2
,
2
);
painter
.
drawRoundedRect
(
compassRect
,
2
,
2
);
QString
yawAngle
;
QString
yawAngle
;
// const float yawDeg = ((values.value("yaw", 0.0f)/M_PI)*180.0f)+180.f;
// const float yawDeg = ((values.value("yaw", 0.0f)/M_PI)*180.0f)+180.f;
// YAW is in compass-human readable format, so 0 - 360deg. This is normal in aviation, not -180 - +180.
// YAW is in compass-human readable format, so 0 - 360deg. This is normal in aviation, not -180 - +180.
const
float
yawDeg
=
((
yawLP
/
M_PI
)
*
180.0
f
)
+
180.0
f
;
const
float
yawDeg
=
((
yawLP
/
M_PI
)
*
180.0
f
)
+
180.0
f
;
yawAngle
.
sprintf
(
"%03d"
,
(
int
)
yawDeg
);
yawAngle
.
sprintf
(
"%03d"
,
(
int
)
yawDeg
);
paintText
(
yawAngle
,
defaultColor
,
3.5
f
,
-
3.7
f
,
compassY
+
0.9
f
,
&
painter
);
paintText
(
yawAngle
,
defaultColor
,
3.5
f
,
-
3.7
f
,
compassY
+
0.9
f
,
&
painter
);
// CHANGE RATE STRIPS
// CHANGE RATE STRIPS
drawChangeRateStrip
(
-
51.0
f
,
-
50.0
f
,
15.0
f
,
-
1.0
f
,
1.0
f
,
-
zSpeed
,
&
painter
);
drawChangeRateStrip
(
-
51.0
f
,
-
50.0
f
,
15.0
f
,
-
1.0
f
,
1.0
f
,
-
zSpeed
,
&
painter
);
// CHANGE RATE STRIPS
// CHANGE RATE STRIPS
drawChangeRateStrip
(
49.0
f
,
-
50.0
f
,
15.0
f
,
-
1.0
f
,
1.0
f
,
xSpeed
,
&
painter
);
drawChangeRateStrip
(
49.0
f
,
-
50.0
f
,
15.0
f
,
-
1.0
f
,
1.0
f
,
xSpeed
,
&
painter
);
// GAUGES
// GAUGES
// Left altitude gauge
// Left altitude gauge
drawChangeIndicatorGauge
(
-
vGaugeSpacing
,
-
15.0
f
,
10.0
f
,
2.0
f
,
-
zPos
,
defaultColor
,
&
painter
,
false
);
drawChangeIndicatorGauge
(
-
vGaugeSpacing
,
-
15.0
f
,
10.0
f
,
2.0
f
,
-
zPos
,
defaultColor
,
&
painter
,
false
);
// Right speed gauge
// Right speed gauge
drawChangeIndicatorGauge
(
vGaugeSpacing
,
-
15.0
f
,
10.0
f
,
5.0
f
,
xSpeed
,
defaultColor
,
&
painter
,
false
);
drawChangeIndicatorGauge
(
vGaugeSpacing
,
-
15.0
f
,
10.0
f
,
5.0
f
,
xSpeed
,
defaultColor
,
&
painter
,
false
);
// Waypoint name
// Waypoint name
if
(
waypointName
!=
""
)
paintText
(
waypointName
,
defaultColor
,
2.0
f
,
(
-
vwidth
/
3.0
)
+
10
,
+
vheight
/
3.0
+
15
,
&
painter
);
if
(
waypointName
!=
""
)
paintText
(
waypointName
,
defaultColor
,
2.0
f
,
(
-
vwidth
/
3.0
)
+
10
,
+
vheight
/
3.0
+
15
,
&
painter
);
// MOVING PARTS
// MOVING PARTS
painter
.
translate
(
refToScreenX
(
yawTrans
),
0
);
painter
.
translate
(
refToScreenX
(
yawTrans
),
0
);
// Rotate view and draw all roll-dependent indicators
// Rotate view and draw all roll-dependent indicators
painter
.
rotate
((
rollLP
/
M_PI
)
*
-
180.0
f
);
painter
.
rotate
((
rollLP
/
M_PI
)
*
-
180.0
f
);
painter
.
translate
(
0
,
(
-
pitchLP
/
M_PI
)
*
-
180.0
f
*
refToScreenY
(
1.8
));
painter
.
translate
(
0
,
(
-
pitchLP
/
M_PI
)
*
-
180.0
f
*
refToScreenY
(
1.8
));
//qDebug() << "ROLL" << roll << "PITCH" << pitch << "YAW DIFF" << valuesDot.value("roll", 0.0f);
//qDebug() << "ROLL" << roll << "PITCH" << pitch << "YAW DIFF" << valuesDot.value("roll", 0.0f);
// PITCH
// PITCH
paintPitchLines
(
pitchLP
,
&
painter
);
paintPitchLines
(
pitchLP
,
&
painter
);
painter
.
end
();
painter
.
end
();
}
else
{
QPainter
painter
;
painter
.
begin
(
this
);
painter
.
end
();
}
//glDisable(GL_MULTISAMPLE);
//glDisable(GL_MULTISAMPLE);
//glFlush();
//glFlush();
}
}
}
}
...
@@ -1517,6 +1592,34 @@ void HUD::saveImage()
...
@@ -1517,6 +1592,34 @@ void HUD::saveImage()
saveImage
(
fileName
);
saveImage
(
fileName
);
}
}
void
HUD
::
startImage
(
quint64
timestamp
)
{
if
(
videoEnabled
&&
offlineDirectory
!=
""
)
{
// Load and diplay image file
nextOfflineImage
=
QString
(
offlineDirectory
+
"/%1.bmp"
).
arg
(
timestamp
);
}
}
void
HUD
::
selectOfflineDirectory
()
{
QString
fileName
=
QFileDialog
::
getExistingDirectory
(
this
,
tr
(
"Select image directory"
),
QDesktopServices
::
storageLocation
(
QDesktopServices
::
DesktopLocation
));
if
(
fileName
!=
""
)
{
offlineDirectory
=
fileName
;
}
}
void
HUD
::
enableHUDInstruments
(
bool
enabled
)
{
hudInstrumentsEnabled
=
enabled
;
}
void
HUD
::
enableVideo
(
bool
enabled
)
{
videoEnabled
=
enabled
;
}
void
HUD
::
setPixels
(
int
imgid
,
const
unsigned
char
*
imageData
,
int
length
,
int
startIndex
)
void
HUD
::
setPixels
(
int
imgid
,
const
unsigned
char
*
imageData
,
int
length
,
int
startIndex
)
{
{
Q_UNUSED
(
imgid
);
Q_UNUSED
(
imgid
);
...
...
src/ui/HUD.h
View file @
e9637d5a
...
@@ -76,11 +76,19 @@ public slots:
...
@@ -76,11 +76,19 @@ public slots:
void
updateLoad
(
UASInterface
*
,
double
);
void
updateLoad
(
UASInterface
*
,
double
);
void
selectWaypoint
(
int
uasId
,
int
id
);
void
selectWaypoint
(
int
uasId
,
int
id
);
void
startImage
(
quint64
timestamp
);
void
startImage
(
int
imgid
,
int
width
,
int
height
,
int
depth
,
int
channels
);
void
startImage
(
int
imgid
,
int
width
,
int
height
,
int
depth
,
int
channels
);
void
setPixels
(
int
imgid
,
const
unsigned
char
*
imageData
,
int
length
,
int
startIndex
);
void
setPixels
(
int
imgid
,
const
unsigned
char
*
imageData
,
int
length
,
int
startIndex
);
void
finishImage
();
void
finishImage
();
void
saveImage
();
void
saveImage
();
void
saveImage
(
QString
fileName
);
void
saveImage
(
QString
fileName
);
/** @brief Select directory where to load the offline files from */
void
selectOfflineDirectory
();
/** @brief Enable the HUD instruments */
void
enableHUDInstruments
(
bool
enabled
);
/** @brief Enable Video */
void
enableVideo
(
bool
enabled
);
protected
slots
:
protected
slots
:
void
paintCenterBackground
(
float
roll
,
float
pitch
,
float
yaw
);
void
paintCenterBackground
(
float
roll
,
float
pitch
,
float
yaw
);
...
@@ -119,6 +127,8 @@ protected:
...
@@ -119,6 +127,8 @@ protected:
void
showEvent
(
QShowEvent
*
event
);
void
showEvent
(
QShowEvent
*
event
);
/** @brief Stop updating widget */
/** @brief Stop updating widget */
void
hideEvent
(
QHideEvent
*
event
);
void
hideEvent
(
QHideEvent
*
event
);
void
contextMenuEvent
(
QContextMenuEvent
*
event
);
void
createActions
();
static
const
int
updateInterval
=
50
;
static
const
int
updateInterval
=
50
;
...
@@ -192,6 +202,16 @@ protected:
...
@@ -192,6 +202,16 @@ protected:
double
lon
;
double
lon
;
double
alt
;
double
alt
;
float
load
;
float
load
;
QString
offlineDirectory
;
QString
nextOfflineImage
;
bool
hudInstrumentsEnabled
;
bool
videoEnabled
;
float
xImageFactor
;
float
yImageFactor
;
QAction
*
enableHUDAction
;
QAction
*
enableVideoAction
;
QAction
*
selectOfflineDirectoryAction
;
QAction
*
selectVideoChannelAction
;
void
paintEvent
(
QPaintEvent
*
event
);
void
paintEvent
(
QPaintEvent
*
event
);
};
};
...
...
src/ui/MainWindow.cc
View file @
e9637d5a
...
@@ -64,7 +64,7 @@ MainWindow* MainWindow::instance()
...
@@ -64,7 +64,7 @@ MainWindow* MainWindow::instance()
MainWindow
::
MainWindow
(
QWidget
*
parent
)
:
MainWindow
::
MainWindow
(
QWidget
*
parent
)
:
QMainWindow
(
parent
),
QMainWindow
(
parent
),
toolsMenuActions
(),
toolsMenuActions
(),
currentView
(
VIEW_
ENGINEER
),
currentView
(
VIEW_
UNCONNECTED
),
aboutToCloseFlag
(
false
),
aboutToCloseFlag
(
false
),
changingViewsFlag
(
false
)
changingViewsFlag
(
false
)
{
{
...
@@ -82,47 +82,17 @@ MainWindow::MainWindow(QWidget *parent):
...
@@ -82,47 +82,17 @@ MainWindow::MainWindow(QWidget *parent):
}
}
else
else
{
{
if
(
settings
.
value
(
"CURRENT_VIEW"
,
VIEW_PILOT
)
!=
VIEW_PILOT
)
// LOAD THE LAST VIEW
VIEW_SECTIONS
currentViewCandidate
=
(
VIEW_SECTIONS
)
settings
.
value
(
"CURRENT_VIEW"
,
currentView
).
toInt
();
if
(
currentViewCandidate
!=
VIEW_ENGINEER
&&
currentViewCandidate
!=
VIEW_OPERATOR
&&
currentViewCandidate
!=
VIEW_PILOT
)
{
{
currentView
=
(
VIEW_SECTIONS
)
settings
.
value
(
"CURRENT_VIEW"
,
currentView
).
toInt
()
;
currentView
=
currentViewCandidate
;
}
}
}
}
// Check if the settings exist, instantiate defaults if necessary
setDefaultSettingsForAp
();
// OPERATOR VIEW DEFAULT
QString
centralKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
CENTRAL_MAP
,
VIEW_OPERATOR
);
if
(
!
settings
.
contains
(
centralKey
))
{
settings
.
setValue
(
centralKey
,
true
);
}
// ENGINEER VIEW DEFAULT
centralKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
CENTRAL_LINECHART
,
VIEW_ENGINEER
);
if
(
!
settings
.
contains
(
centralKey
))
{
settings
.
setValue
(
centralKey
,
true
);
}
// MAVLINK VIEW DEFAULT
centralKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
CENTRAL_PROTOCOL
,
VIEW_MAVLINK
);
if
(
!
settings
.
contains
(
centralKey
))
{
settings
.
setValue
(
centralKey
,
true
);
}
// PILOT VIEW DEFAULT
centralKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
CENTRAL_HUD
,
VIEW_PILOT
);
if
(
!
settings
.
contains
(
centralKey
))
{
settings
.
setValue
(
centralKey
,
true
);
}
QString
listKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
MENU_UAS_LIST
,
currentView
);
if
(
!
settings
.
contains
(
listKey
))
{
settings
.
setValue
(
listKey
,
true
);
}
settings
.
sync
();
settings
.
sync
();
...
@@ -138,6 +108,7 @@ MainWindow::MainWindow(QWidget *parent):
...
@@ -138,6 +108,7 @@ MainWindow::MainWindow(QWidget *parent):
perspectives
->
addAction
(
ui
.
actionMavlinkView
);
perspectives
->
addAction
(
ui
.
actionMavlinkView
);
perspectives
->
addAction
(
ui
.
actionPilotsView
);
perspectives
->
addAction
(
ui
.
actionPilotsView
);
perspectives
->
addAction
(
ui
.
actionOperatorsView
);
perspectives
->
addAction
(
ui
.
actionOperatorsView
);
perspectives
->
addAction
(
ui
.
actionUnconnectedView
);
perspectives
->
setExclusive
(
true
);
perspectives
->
setExclusive
(
true
);
// Mark the right one as selected
// Mark the right one as selected
...
@@ -145,9 +116,13 @@ MainWindow::MainWindow(QWidget *parent):
...
@@ -145,9 +116,13 @@ MainWindow::MainWindow(QWidget *parent):
if
(
currentView
==
VIEW_MAVLINK
)
ui
.
actionMavlinkView
->
setChecked
(
true
);
if
(
currentView
==
VIEW_MAVLINK
)
ui
.
actionMavlinkView
->
setChecked
(
true
);
if
(
currentView
==
VIEW_PILOT
)
ui
.
actionPilotsView
->
setChecked
(
true
);
if
(
currentView
==
VIEW_PILOT
)
ui
.
actionPilotsView
->
setChecked
(
true
);
if
(
currentView
==
VIEW_OPERATOR
)
ui
.
actionOperatorsView
->
setChecked
(
true
);
if
(
currentView
==
VIEW_OPERATOR
)
ui
.
actionOperatorsView
->
setChecked
(
true
);
if
(
currentView
==
VIEW_UNCONNECTED
)
ui
.
actionUnconnectedView
->
setChecked
(
true
);
// The pilot view is not available on startup
// The pilot, engineer and operator view are not available on startup
// since they only make sense with a system connected.
ui
.
actionPilotsView
->
setEnabled
(
false
);
ui
.
actionPilotsView
->
setEnabled
(
false
);
ui
.
actionOperatorsView
->
setEnabled
(
false
);
ui
.
actionEngineersView
->
setEnabled
(
false
);
buildCommonWidgets
();
buildCommonWidgets
();
...
@@ -217,6 +192,54 @@ MainWindow::~MainWindow()
...
@@ -217,6 +192,54 @@ MainWindow::~MainWindow()
}
}
/**
* Set default settings for this AP type.
*/
void
MainWindow
::
setDefaultSettingsForAp
()
{
// Check if the settings exist, instantiate defaults if necessary
// UNCONNECTED VIEW DEFAULT
QString
centralKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
CENTRAL_MAP
,
VIEW_UNCONNECTED
);
if
(
!
settings
.
contains
(
centralKey
))
{
settings
.
setValue
(
centralKey
,
true
);
}
// OPERATOR VIEW DEFAULT
centralKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
CENTRAL_MAP
,
VIEW_OPERATOR
);
if
(
!
settings
.
contains
(
centralKey
))
{
settings
.
setValue
(
centralKey
,
true
);
// ENABLE UAS LIST
settings
.
setValue
(
buildMenuKey
(
SUB_SECTION_CHECKED
,
MainWindow
::
MENU_UAS_LIST
,
VIEW_OPERATOR
),
true
);
// ENABLE HUD TOOL WIDGET
settings
.
setValue
(
buildMenuKey
(
SUB_SECTION_CHECKED
,
MainWindow
::
MENU_HUD
,
VIEW_OPERATOR
),
true
);
}
// ENGINEER VIEW DEFAULT
centralKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
CENTRAL_LINECHART
,
VIEW_ENGINEER
);
if
(
!
settings
.
contains
(
centralKey
))
{
settings
.
setValue
(
centralKey
,
true
);
}
// MAVLINK VIEW DEFAULT
centralKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
CENTRAL_PROTOCOL
,
VIEW_MAVLINK
);
if
(
!
settings
.
contains
(
centralKey
))
{
settings
.
setValue
(
centralKey
,
true
);
}
// PILOT VIEW DEFAULT
centralKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
CENTRAL_HUD
,
VIEW_PILOT
);
if
(
!
settings
.
contains
(
centralKey
))
{
settings
.
setValue
(
centralKey
,
true
);
}
}
void
MainWindow
::
resizeEvent
(
QResizeEvent
*
event
)
void
MainWindow
::
resizeEvent
(
QResizeEvent
*
event
)
{
{
Q_UNUSED
(
event
);
Q_UNUSED
(
event
);
...
@@ -289,7 +312,7 @@ void MainWindow::buildCommonWidgets()
...
@@ -289,7 +312,7 @@ void MainWindow::buildCommonWidgets()
controlDockWidget
=
new
QDockWidget
(
tr
(
"Control"
),
this
);
controlDockWidget
=
new
QDockWidget
(
tr
(
"Control"
),
this
);
controlDockWidget
->
setObjectName
(
"UNMANNED_SYSTEM_CONTROL_DOCKWIDGET"
);
controlDockWidget
->
setObjectName
(
"UNMANNED_SYSTEM_CONTROL_DOCKWIDGET"
);
controlDockWidget
->
setWidget
(
new
UASControlWidget
(
this
)
);
controlDockWidget
->
setWidget
(
new
UASControlWidget
(
this
)
);
addToToolsMenu
(
controlDockWidget
,
tr
(
"Control"
),
SLOT
(
showToolWidget
()),
MENU_UAS_CONTROL
,
Qt
::
LeftDockWidgetArea
);
addToToolsMenu
(
controlDockWidget
,
tr
(
"Control"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_UAS_CONTROL
,
Qt
::
LeftDockWidgetArea
);
}
}
if
(
!
listDockWidget
)
if
(
!
listDockWidget
)
...
@@ -297,7 +320,7 @@ void MainWindow::buildCommonWidgets()
...
@@ -297,7 +320,7 @@ void MainWindow::buildCommonWidgets()
listDockWidget
=
new
QDockWidget
(
tr
(
"Unmanned Systems"
),
this
);
listDockWidget
=
new
QDockWidget
(
tr
(
"Unmanned Systems"
),
this
);
listDockWidget
->
setWidget
(
new
UASListWidget
(
this
)
);
listDockWidget
->
setWidget
(
new
UASListWidget
(
this
)
);
listDockWidget
->
setObjectName
(
"UNMANNED_SYSTEMS_LIST_DOCKWIDGET"
);
listDockWidget
->
setObjectName
(
"UNMANNED_SYSTEMS_LIST_DOCKWIDGET"
);
addToToolsMenu
(
listDockWidget
,
tr
(
"Unmanned Systems"
),
SLOT
(
showToolWidget
()),
MENU_UAS_LIST
,
Qt
::
RightDockWidgetArea
);
addToToolsMenu
(
listDockWidget
,
tr
(
"Unmanned Systems"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_UAS_LIST
,
Qt
::
RightDockWidgetArea
);
}
}
if
(
!
waypointsDockWidget
)
if
(
!
waypointsDockWidget
)
...
@@ -305,7 +328,7 @@ void MainWindow::buildCommonWidgets()
...
@@ -305,7 +328,7 @@ void MainWindow::buildCommonWidgets()
waypointsDockWidget
=
new
QDockWidget
(
tr
(
"Waypoint List"
),
this
);
waypointsDockWidget
=
new
QDockWidget
(
tr
(
"Waypoint List"
),
this
);
waypointsDockWidget
->
setWidget
(
new
WaypointList
(
this
,
NULL
)
);
waypointsDockWidget
->
setWidget
(
new
WaypointList
(
this
,
NULL
)
);
waypointsDockWidget
->
setObjectName
(
"WAYPOINT_LIST_DOCKWIDGET"
);
waypointsDockWidget
->
setObjectName
(
"WAYPOINT_LIST_DOCKWIDGET"
);
addToToolsMenu
(
waypointsDockWidget
,
tr
(
"Waypoints List"
),
SLOT
(
showToolWidget
()),
MENU_WAYPOINTS
,
Qt
::
BottomDockWidgetArea
);
addToToolsMenu
(
waypointsDockWidget
,
tr
(
"Waypoints List"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_WAYPOINTS
,
Qt
::
BottomDockWidgetArea
);
}
}
if
(
!
infoDockWidget
)
if
(
!
infoDockWidget
)
...
@@ -313,7 +336,7 @@ void MainWindow::buildCommonWidgets()
...
@@ -313,7 +336,7 @@ void MainWindow::buildCommonWidgets()
infoDockWidget
=
new
QDockWidget
(
tr
(
"Status Details"
),
this
);
infoDockWidget
=
new
QDockWidget
(
tr
(
"Status Details"
),
this
);
infoDockWidget
->
setWidget
(
new
UASInfoWidget
(
this
)
);
infoDockWidget
->
setWidget
(
new
UASInfoWidget
(
this
)
);
infoDockWidget
->
setObjectName
(
"UAS_STATUS_DETAILS_DOCKWIDGET"
);
infoDockWidget
->
setObjectName
(
"UAS_STATUS_DETAILS_DOCKWIDGET"
);
addToToolsMenu
(
infoDockWidget
,
tr
(
"Status Details"
),
SLOT
(
showToolWidget
()),
MENU_STATUS
,
Qt
::
RightDockWidgetArea
);
addToToolsMenu
(
infoDockWidget
,
tr
(
"Status Details"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_STATUS
,
Qt
::
RightDockWidgetArea
);
}
}
if
(
!
debugConsoleDockWidget
)
if
(
!
debugConsoleDockWidget
)
...
@@ -321,7 +344,7 @@ void MainWindow::buildCommonWidgets()
...
@@ -321,7 +344,7 @@ void MainWindow::buildCommonWidgets()
debugConsoleDockWidget
=
new
QDockWidget
(
tr
(
"Communication Console"
),
this
);
debugConsoleDockWidget
=
new
QDockWidget
(
tr
(
"Communication Console"
),
this
);
debugConsoleDockWidget
->
setWidget
(
new
DebugConsole
(
this
)
);
debugConsoleDockWidget
->
setWidget
(
new
DebugConsole
(
this
)
);
debugConsoleDockWidget
->
setObjectName
(
"COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET"
);
debugConsoleDockWidget
->
setObjectName
(
"COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET"
);
addToToolsMenu
(
debugConsoleDockWidget
,
tr
(
"Communication Console"
),
SLOT
(
showToolWidget
()),
MENU_DEBUG_CONSOLE
,
Qt
::
BottomDockWidgetArea
);
addToToolsMenu
(
debugConsoleDockWidget
,
tr
(
"Communication Console"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_DEBUG_CONSOLE
,
Qt
::
BottomDockWidgetArea
);
}
}
if
(
!
logPlayerDockWidget
)
if
(
!
logPlayerDockWidget
)
...
@@ -329,13 +352,13 @@ void MainWindow::buildCommonWidgets()
...
@@ -329,13 +352,13 @@ void MainWindow::buildCommonWidgets()
logPlayerDockWidget
=
new
QDockWidget
(
tr
(
"MAVLink Log Player"
),
this
);
logPlayerDockWidget
=
new
QDockWidget
(
tr
(
"MAVLink Log Player"
),
this
);
logPlayerDockWidget
->
setWidget
(
new
QGCMAVLinkLogPlayer
(
mavlink
,
this
)
);
logPlayerDockWidget
->
setWidget
(
new
QGCMAVLinkLogPlayer
(
mavlink
,
this
)
);
logPlayerDockWidget
->
setObjectName
(
"MAVLINK_LOG_PLAYER_DOCKWIDGET"
);
logPlayerDockWidget
->
setObjectName
(
"MAVLINK_LOG_PLAYER_DOCKWIDGET"
);
addToToolsMenu
(
logPlayerDockWidget
,
tr
(
"MAVLink Log Replay"
),
SLOT
(
showToolWidget
()),
MENU_MAVLINK_LOG_PLAYER
,
Qt
::
RightDockWidgetArea
);
addToToolsMenu
(
logPlayerDockWidget
,
tr
(
"MAVLink Log Replay"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_MAVLINK_LOG_PLAYER
,
Qt
::
RightDockWidgetArea
);
}
}
// Center widgets
// Center widgets
if
(
!
mapWidget
)
if
(
!
mapWidget
)
{
{
mapWidget
=
new
MapWidget
(
this
);
mapWidget
=
new
MapWidget
(
this
);
addToCentralWidgetsMenu
(
mapWidget
,
"Maps"
,
SLOT
(
showCentralWidget
()),
CENTRAL_MAP
);
addToCentralWidgetsMenu
(
mapWidget
,
"Maps"
,
SLOT
(
showCentralWidget
()),
CENTRAL_MAP
);
}
}
...
@@ -393,17 +416,17 @@ void MainWindow::buildPxWidgets()
...
@@ -393,17 +416,17 @@ void MainWindow::buildPxWidgets()
#ifdef QGC_OSG_ENABLED
#ifdef QGC_OSG_ENABLED
if
(
!
_3DWidget
)
if
(
!
_3DWidget
)
{
{
//
_3DWidget = Q3DWidgetFactory::get("PIXHAWK");
_3DWidget
=
Q3DWidgetFactory
::
get
(
"PIXHAWK"
);
//
addToCentralWidgetsMenu(_3DWidget, "Local 3D", SLOT(showCentralWidget()), CENTRAL_3D_LOCAL);
addToCentralWidgetsMenu
(
_3DWidget
,
"Local 3D"
,
SLOT
(
showCentralWidget
()),
CENTRAL_3D_LOCAL
);
}
}
#endif
#endif
#ifdef QGC_OSGEARTH_ENABLED
#ifdef QGC_OSGEARTH_ENABLED
//
if (!_3DMapWidget)
if
(
!
_3DMapWidget
)
//
{
{
//
_3DMapWidget = Q3DWidgetFactory::get("MAP3D");
_3DMapWidget
=
Q3DWidgetFactory
::
get
(
"MAP3D"
);
//
addToCentralWidgetsMenu(_3DMapWidget, "OSG Earth 3D", SLOT(showCentralWidget()), CENTRAL_OSGEARTH);
addToCentralWidgetsMenu
(
_3DMapWidget
,
"OSG Earth 3D"
,
SLOT
(
showCentralWidget
()),
CENTRAL_OSGEARTH
);
//
}
}
#endif
#endif
#if (defined _MSC_VER) | (defined Q_OS_MAC)
#if (defined _MSC_VER) | (defined Q_OS_MAC)
...
@@ -422,7 +445,7 @@ void MainWindow::buildPxWidgets()
...
@@ -422,7 +445,7 @@ void MainWindow::buildPxWidgets()
detectionDockWidget
=
new
QDockWidget
(
tr
(
"Object Recognition"
),
this
);
detectionDockWidget
=
new
QDockWidget
(
tr
(
"Object Recognition"
),
this
);
detectionDockWidget
->
setWidget
(
new
ObjectDetectionView
(
"images/patterns"
,
this
)
);
detectionDockWidget
->
setWidget
(
new
ObjectDetectionView
(
"images/patterns"
,
this
)
);
detectionDockWidget
->
setObjectName
(
"OBJECT_DETECTION_DOCK_WIDGET"
);
detectionDockWidget
->
setObjectName
(
"OBJECT_DETECTION_DOCK_WIDGET"
);
addToToolsMenu
(
detectionDockWidget
,
tr
(
"Object Recognition"
),
SLOT
(
showToolWidget
()),
MENU_DETECTION
,
Qt
::
RightDockWidgetArea
);
addToToolsMenu
(
detectionDockWidget
,
tr
(
"Object Recognition"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_DETECTION
,
Qt
::
RightDockWidgetArea
);
}
}
if
(
!
parametersDockWidget
)
if
(
!
parametersDockWidget
)
...
@@ -430,7 +453,7 @@ void MainWindow::buildPxWidgets()
...
@@ -430,7 +453,7 @@ void MainWindow::buildPxWidgets()
parametersDockWidget
=
new
QDockWidget
(
tr
(
"Calibration and Onboard Parameters"
),
this
);
parametersDockWidget
=
new
QDockWidget
(
tr
(
"Calibration and Onboard Parameters"
),
this
);
parametersDockWidget
->
setWidget
(
new
ParameterInterface
(
this
)
);
parametersDockWidget
->
setWidget
(
new
ParameterInterface
(
this
)
);
parametersDockWidget
->
setObjectName
(
"PARAMETER_INTERFACE_DOCKWIDGET"
);
parametersDockWidget
->
setObjectName
(
"PARAMETER_INTERFACE_DOCKWIDGET"
);
addToToolsMenu
(
parametersDockWidget
,
tr
(
"Calibration and Parameters"
),
SLOT
(
showToolWidget
()),
MENU_PARAMETERS
,
Qt
::
RightDockWidgetArea
);
addToToolsMenu
(
parametersDockWidget
,
tr
(
"Calibration and Parameters"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_PARAMETERS
,
Qt
::
RightDockWidgetArea
);
}
}
if
(
!
watchdogControlDockWidget
)
if
(
!
watchdogControlDockWidget
)
...
@@ -438,7 +461,7 @@ void MainWindow::buildPxWidgets()
...
@@ -438,7 +461,7 @@ void MainWindow::buildPxWidgets()
watchdogControlDockWidget
=
new
QDockWidget
(
tr
(
"Process Control"
),
this
);
watchdogControlDockWidget
=
new
QDockWidget
(
tr
(
"Process Control"
),
this
);
watchdogControlDockWidget
->
setWidget
(
new
WatchdogControl
(
this
)
);
watchdogControlDockWidget
->
setWidget
(
new
WatchdogControl
(
this
)
);
watchdogControlDockWidget
->
setObjectName
(
"WATCHDOG_CONTROL_DOCKWIDGET"
);
watchdogControlDockWidget
->
setObjectName
(
"WATCHDOG_CONTROL_DOCKWIDGET"
);
addToToolsMenu
(
watchdogControlDockWidget
,
tr
(
"Process Control"
),
SLOT
(
showToolWidget
()),
MENU_WATCHDOG
,
Qt
::
BottomDockWidgetArea
);
addToToolsMenu
(
watchdogControlDockWidget
,
tr
(
"Process Control"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_WATCHDOG
,
Qt
::
BottomDockWidgetArea
);
}
}
if
(
!
hsiDockWidget
)
if
(
!
hsiDockWidget
)
...
@@ -446,7 +469,7 @@ void MainWindow::buildPxWidgets()
...
@@ -446,7 +469,7 @@ void MainWindow::buildPxWidgets()
hsiDockWidget
=
new
QDockWidget
(
tr
(
"Horizontal Situation Indicator"
),
this
);
hsiDockWidget
=
new
QDockWidget
(
tr
(
"Horizontal Situation Indicator"
),
this
);
hsiDockWidget
->
setWidget
(
new
HSIDisplay
(
this
)
);
hsiDockWidget
->
setWidget
(
new
HSIDisplay
(
this
)
);
hsiDockWidget
->
setObjectName
(
"HORIZONTAL_SITUATION_INDICATOR_DOCK_WIDGET"
);
hsiDockWidget
->
setObjectName
(
"HORIZONTAL_SITUATION_INDICATOR_DOCK_WIDGET"
);
addToToolsMenu
(
hsiDockWidget
,
tr
(
"HSI"
),
SLOT
(
showToolWidget
()),
MENU_HSI
,
Qt
::
BottomDockWidgetArea
);
addToToolsMenu
(
hsiDockWidget
,
tr
(
"HSI"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_HSI
,
Qt
::
BottomDockWidgetArea
);
}
}
if
(
!
headDown1DockWidget
)
if
(
!
headDown1DockWidget
)
...
@@ -454,7 +477,7 @@ void MainWindow::buildPxWidgets()
...
@@ -454,7 +477,7 @@ void MainWindow::buildPxWidgets()
headDown1DockWidget
=
new
QDockWidget
(
tr
(
"Flight Display"
),
this
);
headDown1DockWidget
=
new
QDockWidget
(
tr
(
"Flight Display"
),
this
);
headDown1DockWidget
->
setWidget
(
new
HDDisplay
(
acceptList
,
"Flight Display"
,
this
)
);
headDown1DockWidget
->
setWidget
(
new
HDDisplay
(
acceptList
,
"Flight Display"
,
this
)
);
headDown1DockWidget
->
setObjectName
(
"HEAD_DOWN_DISPLAY_1_DOCK_WIDGET"
);
headDown1DockWidget
->
setObjectName
(
"HEAD_DOWN_DISPLAY_1_DOCK_WIDGET"
);
addToToolsMenu
(
headDown1DockWidget
,
tr
(
"Flight Display"
),
SLOT
(
showToolWidget
()),
MENU_HDD_1
,
Qt
::
RightDockWidgetArea
);
addToToolsMenu
(
headDown1DockWidget
,
tr
(
"Flight Display"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_HDD_1
,
Qt
::
RightDockWidgetArea
);
}
}
if
(
!
headDown2DockWidget
)
if
(
!
headDown2DockWidget
)
...
@@ -462,7 +485,7 @@ void MainWindow::buildPxWidgets()
...
@@ -462,7 +485,7 @@ void MainWindow::buildPxWidgets()
headDown2DockWidget
=
new
QDockWidget
(
tr
(
"Payload Status"
),
this
);
headDown2DockWidget
=
new
QDockWidget
(
tr
(
"Payload Status"
),
this
);
headDown2DockWidget
->
setWidget
(
new
HDDisplay
(
acceptList2
,
"Payload Status"
,
this
)
);
headDown2DockWidget
->
setWidget
(
new
HDDisplay
(
acceptList2
,
"Payload Status"
,
this
)
);
headDown2DockWidget
->
setObjectName
(
"HEAD_DOWN_DISPLAY_2_DOCK_WIDGET"
);
headDown2DockWidget
->
setObjectName
(
"HEAD_DOWN_DISPLAY_2_DOCK_WIDGET"
);
addToToolsMenu
(
headDown2DockWidget
,
tr
(
"Payload Status"
),
SLOT
(
showToolWidget
()),
MENU_HDD_2
,
Qt
::
RightDockWidgetArea
);
addToToolsMenu
(
headDown2DockWidget
,
tr
(
"Payload Status"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_HDD_2
,
Qt
::
RightDockWidgetArea
);
}
}
if
(
!
rcViewDockWidget
)
if
(
!
rcViewDockWidget
)
...
@@ -470,7 +493,7 @@ void MainWindow::buildPxWidgets()
...
@@ -470,7 +493,7 @@ void MainWindow::buildPxWidgets()
rcViewDockWidget
=
new
QDockWidget
(
tr
(
"Radio Control"
),
this
);
rcViewDockWidget
=
new
QDockWidget
(
tr
(
"Radio Control"
),
this
);
rcViewDockWidget
->
setWidget
(
new
QGCRemoteControlView
(
this
)
);
rcViewDockWidget
->
setWidget
(
new
QGCRemoteControlView
(
this
)
);
rcViewDockWidget
->
setObjectName
(
"RADIO_CONTROL_CHANNELS_DOCK_WIDGET"
);
rcViewDockWidget
->
setObjectName
(
"RADIO_CONTROL_CHANNELS_DOCK_WIDGET"
);
addToToolsMenu
(
rcViewDockWidget
,
tr
(
"Radio Control"
),
SLOT
(
showToolWidget
()),
MENU_RC_VIEW
,
Qt
::
BottomDockWidgetArea
);
addToToolsMenu
(
rcViewDockWidget
,
tr
(
"Radio Control"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_RC_VIEW
,
Qt
::
BottomDockWidgetArea
);
}
}
if
(
!
headUpDockWidget
)
if
(
!
headUpDockWidget
)
...
@@ -478,7 +501,31 @@ void MainWindow::buildPxWidgets()
...
@@ -478,7 +501,31 @@ void MainWindow::buildPxWidgets()
headUpDockWidget
=
new
QDockWidget
(
tr
(
"HUD"
),
this
);
headUpDockWidget
=
new
QDockWidget
(
tr
(
"HUD"
),
this
);
headUpDockWidget
->
setWidget
(
new
HUD
(
320
,
240
,
this
));
headUpDockWidget
->
setWidget
(
new
HUD
(
320
,
240
,
this
));
headUpDockWidget
->
setObjectName
(
"HEAD_UP_DISPLAY_DOCK_WIDGET"
);
headUpDockWidget
->
setObjectName
(
"HEAD_UP_DISPLAY_DOCK_WIDGET"
);
addToToolsMenu
(
headUpDockWidget
,
tr
(
"Control Indicator"
),
SLOT
(
showToolWidget
()),
MENU_HUD
,
Qt
::
LeftDockWidgetArea
);
addToToolsMenu
(
headUpDockWidget
,
tr
(
"Head Up Display"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_HUD
,
Qt
::
RightDockWidgetArea
);
}
if
(
!
video1DockWidget
)
{
video1DockWidget
=
new
QDockWidget
(
tr
(
"Video Stream 1"
),
this
);
HUD
*
video1
=
new
HUD
(
160
,
120
,
this
);
video1
->
enableHUDInstruments
(
false
);
video1
->
enableVideo
(
true
);
// FIXME select video stream as well
video1DockWidget
->
setWidget
(
video1
);
video1DockWidget
->
setObjectName
(
"VIDEO_STREAM_1_DOCK_WIDGET"
);
addToToolsMenu
(
video1DockWidget
,
tr
(
"Video Stream 1"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_VIDEO_STREAM_1
,
Qt
::
LeftDockWidgetArea
);
}
if
(
!
video2DockWidget
)
{
video2DockWidget
=
new
QDockWidget
(
tr
(
"Video Stream 2"
),
this
);
HUD
*
video2
=
new
HUD
(
160
,
120
,
this
);
video2
->
enableHUDInstruments
(
false
);
video2
->
enableVideo
(
true
);
// FIXME select video stream as well
video2DockWidget
->
setWidget
(
video2
);
video2DockWidget
->
setObjectName
(
"VIDEO_STREAM_2_DOCK_WIDGET"
);
addToToolsMenu
(
video2DockWidget
,
tr
(
"Video Stream 2"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_VIDEO_STREAM_2
,
Qt
::
LeftDockWidgetArea
);
}
}
// Dialogue widgets
// Dialogue widgets
...
@@ -499,7 +546,7 @@ void MainWindow::buildSlugsWidgets()
...
@@ -499,7 +546,7 @@ void MainWindow::buildSlugsWidgets()
headUpDockWidget
=
new
QDockWidget
(
tr
(
"Control Indicator"
),
this
);
headUpDockWidget
=
new
QDockWidget
(
tr
(
"Control Indicator"
),
this
);
headUpDockWidget
->
setWidget
(
new
HUD
(
320
,
240
,
this
));
headUpDockWidget
->
setWidget
(
new
HUD
(
320
,
240
,
this
));
headUpDockWidget
->
setObjectName
(
"HEAD_UP_DISPLAY_DOCK_WIDGET"
);
headUpDockWidget
->
setObjectName
(
"HEAD_UP_DISPLAY_DOCK_WIDGET"
);
addToToolsMenu
(
headUpDockWidget
,
tr
(
"HUD"
),
SLOT
(
showToolWidget
()),
MENU_HUD
,
Qt
::
LeftDockWidgetArea
);
addToToolsMenu
(
headUpDockWidget
,
tr
(
"HUD"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_HUD
,
Qt
::
LeftDockWidgetArea
);
}
}
if
(
!
rcViewDockWidget
)
if
(
!
rcViewDockWidget
)
...
@@ -507,7 +554,7 @@ void MainWindow::buildSlugsWidgets()
...
@@ -507,7 +554,7 @@ void MainWindow::buildSlugsWidgets()
rcViewDockWidget
=
new
QDockWidget
(
tr
(
"Radio Control"
),
this
);
rcViewDockWidget
=
new
QDockWidget
(
tr
(
"Radio Control"
),
this
);
rcViewDockWidget
->
setWidget
(
new
QGCRemoteControlView
(
this
)
);
rcViewDockWidget
->
setWidget
(
new
QGCRemoteControlView
(
this
)
);
rcViewDockWidget
->
setObjectName
(
"RADIO_CONTROL_CHANNELS_DOCK_WIDGET"
);
rcViewDockWidget
->
setObjectName
(
"RADIO_CONTROL_CHANNELS_DOCK_WIDGET"
);
addToToolsMenu
(
rcViewDockWidget
,
tr
(
"Radio Control"
),
SLOT
(
showToolWidget
()),
MENU_RC_VIEW
,
Qt
::
BottomDockWidgetArea
);
addToToolsMenu
(
rcViewDockWidget
,
tr
(
"Radio Control"
),
SLOT
(
showToolWidget
(
bool
)),
MENU_RC_VIEW
,
Qt
::
BottomDockWidgetArea
);
}
}
// if (!slugsDataWidget)
// if (!slugsDataWidget)
...
@@ -553,15 +600,17 @@ void MainWindow::addToCentralWidgetsMenu ( QWidget* widget,
...
@@ -553,15 +600,17 @@ void MainWindow::addToCentralWidgetsMenu ( QWidget* widget,
QAction
*
tempAction
;
QAction
*
tempAction
;
// Add the separator that will separate tools from central Widgets
// Not needed any more - separate menu now available
if
(
!
toolsMenuActions
[
CENTRAL_SEPARATOR
])
{
// // Add the separator that will separate tools from central Widgets
tempAction
=
ui
.
menuTools
->
addSeparator
();
// if (!toolsMenuActions[CENTRAL_SEPARATOR])
toolsMenuActions
[
CENTRAL_SEPARATOR
]
=
tempAction
;
// {
tempAction
->
setData
(
CENTRAL_SEPARATOR
);
// tempAction = ui.menuTools->addSeparator();
}
// toolsMenuActions[CENTRAL_SEPARATOR] = tempAction;
// tempAction->setData(CENTRAL_SEPARATOR);
// }
tempAction
=
ui
.
menu
Tools
->
addAction
(
title
);
tempAction
=
ui
.
menu
Main
->
addAction
(
title
);
tempAction
->
setCheckable
(
true
);
tempAction
->
setCheckable
(
true
);
tempAction
->
setData
(
centralWidget
);
tempAction
->
setData
(
centralWidget
);
...
@@ -583,13 +632,17 @@ void MainWindow::addToCentralWidgetsMenu ( QWidget* widget,
...
@@ -583,13 +632,17 @@ void MainWindow::addToCentralWidgetsMenu ( QWidget* widget,
}
}
// connect the action
// connect the action
connect
(
tempAction
,
SIGNAL
(
triggered
()),
this
,
slotName
);
connect
(
tempAction
,
SIGNAL
(
triggered
(
bool
)),
this
,
slotName
);
}
}
void
MainWindow
::
showCentralWidget
()
void
MainWindow
::
showCentralWidget
()
{
{
QAction
*
senderAction
=
qobject_cast
<
QAction
*>
(
sender
());
QAction
*
senderAction
=
qobject_cast
<
QAction
*>
(
sender
());
// Block sender action while manipulating state
senderAction
->
blockSignals
(
true
);
int
tool
=
senderAction
->
data
().
toInt
();
int
tool
=
senderAction
->
data
().
toInt
();
QString
chKey
;
QString
chKey
;
...
@@ -597,7 +650,6 @@ void MainWindow::showCentralWidget()
...
@@ -597,7 +650,6 @@ void MainWindow::showCentralWidget()
if
(
senderAction
&&
dockWidgets
[
tool
])
if
(
senderAction
&&
dockWidgets
[
tool
])
{
{
// uncheck all central widget actions
// uncheck all central widget actions
QHashIterator
<
int
,
QAction
*>
i
(
toolsMenuActions
);
QHashIterator
<
int
,
QAction
*>
i
(
toolsMenuActions
);
while
(
i
.
hasNext
())
while
(
i
.
hasNext
())
...
@@ -606,7 +658,11 @@ void MainWindow::showCentralWidget()
...
@@ -606,7 +658,11 @@ void MainWindow::showCentralWidget()
//qDebug() << "shCW" << i.key() << "read";
//qDebug() << "shCW" << i.key() << "read";
if
(
i
.
value
()
&&
i
.
value
()
->
data
().
toInt
()
>
255
)
if
(
i
.
value
()
&&
i
.
value
()
->
data
().
toInt
()
>
255
)
{
{
// Block signals and uncheck action
// firing would be unneccesary
i
.
value
()
->
blockSignals
(
true
);
i
.
value
()
->
setChecked
(
false
);
i
.
value
()
->
setChecked
(
false
);
i
.
value
()
->
blockSignals
(
false
);
// update the settings
// update the settings
chKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
static_cast
<
TOOLS_WIDGET_NAMES
>
(
i
.
value
()
->
data
().
toInt
()),
currentView
);
chKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
static_cast
<
TOOLS_WIDGET_NAMES
>
(
i
.
value
()
->
data
().
toInt
()),
currentView
);
...
@@ -625,6 +681,9 @@ void MainWindow::showCentralWidget()
...
@@ -625,6 +681,9 @@ void MainWindow::showCentralWidget()
chKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
static_cast
<
TOOLS_WIDGET_NAMES
>
(
tool
),
currentView
);
chKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
static_cast
<
TOOLS_WIDGET_NAMES
>
(
tool
),
currentView
);
settings
.
setValue
(
chKey
,
true
);
settings
.
setValue
(
chKey
,
true
);
// Unblock sender action
senderAction
->
blockSignals
(
false
);
presentView
();
presentView
();
}
}
}
}
...
@@ -684,39 +743,97 @@ void MainWindow::addToToolsMenu ( QWidget* widget,
...
@@ -684,39 +743,97 @@ void MainWindow::addToToolsMenu ( QWidget* widget,
}
}
else
else
{
{
tempAction
->
setChecked
(
settings
.
value
(
chKey
).
toBool
());
tempAction
->
setChecked
(
settings
.
value
(
chKey
,
false
).
toBool
());
widget
->
setVisible
(
settings
.
value
(
chKey
,
false
).
toBool
());
widget
->
setVisible
(
settings
.
value
(
chKey
,
false
).
toBool
());
}
}
// connect the action
// connect the action
connect
(
tempAction
,
SIGNAL
(
triggered
()),
this
,
slotName
);
connect
(
tempAction
,
SIGNAL
(
toggled
(
bool
)),
this
,
slotName
);
connect
(
qobject_cast
<
QDockWidget
*>
(
dockWidgets
[
tool
]),
SIGNAL
(
visibilityChanged
(
bool
)),
this
,
SLOT
(
showToolWidget
(
bool
)));
// connect(qobject_cast <QDockWidget *>(dockWidgets[tool]),
// connect(qobject_cast <QDockWidget *>(dockWidgets[tool]),
// SIGNAL(visibilityChanged(bool)), this, SLOT(updateVisibilitySettings(bool)));
// SIGNAL(visibilityChanged(bool)), this, SLOT(updateVisibilitySettings(bool)));
connect
(
qobject_cast
<
QDockWidget
*>
(
dockWidgets
[
tool
]),
connect
(
qobject_cast
<
QDockWidget
*>
(
dockWidgets
[
tool
]),
SIGNAL
(
dockLocationChanged
(
Qt
::
DockWidgetArea
)),
this
,
SLOT
(
updateLocationSettings
(
Qt
::
DockWidgetArea
)));
SIGNAL
(
dockLocationChanged
(
Qt
::
DockWidgetArea
)),
this
,
SLOT
(
updateLocationSettings
(
Qt
::
DockWidgetArea
)));
}
}
void
MainWindow
::
showToolWidget
()
void
MainWindow
::
showToolWidget
(
bool
visible
)
{
{
QAction
*
temp
=
qobject_cast
<
QAction
*>
(
sender
());
if
(
!
aboutToCloseFlag
&&
!
changingViewsFlag
)
int
tool
=
temp
->
data
().
toInt
();
if
(
temp
&&
dockWidgets
[
tool
])
{
{
if
(
temp
->
isChecked
())
QAction
*
action
=
qobject_cast
<
QAction
*>
(
sender
());
// Prevent this to fire if undocked
if
(
action
)
{
{
addDockWidget
(
dockWidgetLocations
[
tool
],
qobject_cast
<
QDockWidget
*>
(
dockWidgets
[
tool
]));
int
tool
=
action
->
data
().
toInt
();
qobject_cast
<
QDockWidget
*>
(
dockWidgets
[
tool
])
->
show
();
QDockWidget
*
dockWidget
=
qobject_cast
<
QDockWidget
*>
(
dockWidgets
[
tool
]);
qDebug
()
<<
"DATA:"
<<
tool
<<
"FLOATING"
<<
dockWidget
->
isFloating
()
<<
"checked"
<<
action
->
isChecked
()
<<
"visible"
<<
dockWidget
->
isVisible
()
<<
"action vis:"
<<
action
->
isVisible
();
if
(
dockWidget
&&
dockWidget
->
isVisible
()
!=
visible
)
{
if
(
visible
)
{
qDebug
()
<<
"DOCK WIDGET ADDED"
;
addDockWidget
(
dockWidgetLocations
[
tool
],
dockWidget
);
dockWidget
->
show
();
}
else
{
qDebug
()
<<
"DOCK WIDGET REMOVED"
;
removeDockWidget
(
dockWidget
);
//dockWidget->hide();
}
QHashIterator
<
int
,
QWidget
*>
i
(
dockWidgets
);
while
(
i
.
hasNext
())
{
i
.
next
();
if
((
static_cast
<
QDockWidget
*>
(
dockWidgets
[
i
.
key
()]))
==
dockWidget
)
{
QString
chKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
static_cast
<
TOOLS_WIDGET_NAMES
>
(
i
.
key
()),
currentView
);
settings
.
setValue
(
chKey
,
visible
);
qDebug
()
<<
"showToolWidget(): Set key"
<<
chKey
<<
"to"
<<
visible
;
break
;
}
}
}
}
}
else
QDockWidget
*
dockWidget
=
qobject_cast
<
QDockWidget
*>
(
QObject
::
sender
());
qDebug
()
<<
"Trying to cast dockwidget"
<<
dockWidget
<<
"isvisible"
<<
visible
;
if
(
dockWidget
)
{
{
removeDockWidget
(
qobject_cast
<
QDockWidget
*>
(
dockWidgets
[
tool
]));
// Get action
int
tool
=
dockWidgets
.
key
(
dockWidget
);
qDebug
()
<<
"Updating widget setting"
<<
tool
<<
"to"
<<
visible
;
QAction
*
action
=
toolsMenuActions
[
tool
];
action
->
blockSignals
(
true
);
action
->
setChecked
(
visible
);
action
->
blockSignals
(
false
);
QHashIterator
<
int
,
QWidget
*>
i
(
dockWidgets
);
while
(
i
.
hasNext
())
{
i
.
next
();
if
((
static_cast
<
QDockWidget
*>
(
dockWidgets
[
i
.
key
()]))
==
dockWidget
)
{
QString
chKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
static_cast
<
TOOLS_WIDGET_NAMES
>
(
i
.
key
()),
currentView
);
settings
.
setValue
(
chKey
,
visible
);
qDebug
()
<<
"showToolWidget(): Set key"
<<
chKey
<<
"to"
<<
visible
;
break
;
}
}
}
}
}
}
}
}
...
@@ -728,6 +845,8 @@ void MainWindow::showTheWidget (TOOLS_WIDGET_NAMES widget, VIEW_SECTIONS view)
...
@@ -728,6 +845,8 @@ void MainWindow::showTheWidget (TOOLS_WIDGET_NAMES widget, VIEW_SECTIONS view)
tempVisible
=
settings
.
value
(
buildMenuKey
(
SUB_SECTION_CHECKED
,
widget
,
view
),
false
).
toBool
();
tempVisible
=
settings
.
value
(
buildMenuKey
(
SUB_SECTION_CHECKED
,
widget
,
view
),
false
).
toBool
();
qDebug
()
<<
"showTheWidget(): Set key"
<<
buildMenuKey
(
SUB_SECTION_CHECKED
,
widget
,
view
)
<<
"to"
<<
tempVisible
;
if
(
tempWidget
)
if
(
tempWidget
)
{
{
toolsMenuActions
[
widget
]
->
setChecked
(
tempVisible
);
toolsMenuActions
[
widget
]
->
setChecked
(
tempVisible
);
...
@@ -746,12 +865,14 @@ void MainWindow::showTheWidget (TOOLS_WIDGET_NAMES widget, VIEW_SECTIONS view)
...
@@ -746,12 +865,14 @@ void MainWindow::showTheWidget (TOOLS_WIDGET_NAMES widget, VIEW_SECTIONS view)
// }
// }
// }
// }
if
(
(
tempWidget
!=
NULL
)
&&
tempVisible
)
if
(
tempWidget
!=
NULL
)
{
{
addDockWidget
(
tempLocation
,
tempWidget
);
if
(
tempVisible
)
tempWidget
->
show
();
{
addDockWidget
(
tempLocation
,
tempWidget
);
tempWidget
->
show
();
}
}
}
}
}
QString
MainWindow
::
buildMenuKey
(
SETTINGS_SECTIONS
section
,
TOOLS_WIDGET_NAMES
tool
,
VIEW_SECTIONS
view
)
QString
MainWindow
::
buildMenuKey
(
SETTINGS_SECTIONS
section
,
TOOLS_WIDGET_NAMES
tool
,
VIEW_SECTIONS
view
)
...
@@ -763,11 +884,11 @@ QString MainWindow::buildMenuKey(SETTINGS_SECTIONS section, TOOLS_WIDGET_NAMES t
...
@@ -763,11 +884,11 @@ QString MainWindow::buildMenuKey(SETTINGS_SECTIONS section, TOOLS_WIDGET_NAMES t
UASManager
::
instance
()
->
getActiveUAS
()
->
getAutopilotType
()
:
UASManager
::
instance
()
->
getActiveUAS
()
->
getAutopilotType
()
:
-
1
;
-
1
;
return
(
QString
::
number
(
apType
)
+
"
/
"
+
return
(
QString
::
number
(
apType
)
+
"
_
"
+
QString
::
number
(
SECTION_MENU
)
+
"
/
"
+
QString
::
number
(
SECTION_MENU
)
+
"
_
"
+
QString
::
number
(
view
)
+
"
/
"
+
QString
::
number
(
view
)
+
"
_
"
+
QString
::
number
(
tool
)
+
"
/
"
+
QString
::
number
(
tool
)
+
"
_
"
+
QString
::
number
(
section
)
+
"
/
"
);
QString
::
number
(
section
)
+
"
_
"
);
}
}
void
MainWindow
::
closeEvent
(
QCloseEvent
*
event
)
void
MainWindow
::
closeEvent
(
QCloseEvent
*
event
)
...
@@ -785,6 +906,29 @@ void MainWindow::closeEvent(QCloseEvent *event)
...
@@ -785,6 +906,29 @@ void MainWindow::closeEvent(QCloseEvent *event)
QMainWindow
::
closeEvent
(
event
);
QMainWindow
::
closeEvent
(
event
);
}
}
void
MainWindow
::
showDockWidget
(
bool
vis
)
{
if
(
!
aboutToCloseFlag
&&
!
changingViewsFlag
)
{
QDockWidget
*
temp
=
qobject_cast
<
QDockWidget
*>
(
sender
());
if
(
temp
)
{
QHashIterator
<
int
,
QWidget
*>
i
(
dockWidgets
);
while
(
i
.
hasNext
())
{
i
.
next
();
if
((
static_cast
<
QDockWidget
*>
(
dockWidgets
[
i
.
key
()]))
==
temp
)
{
QString
chKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
static_cast
<
TOOLS_WIDGET_NAMES
>
(
i
.
key
()),
currentView
);
settings
.
setValue
(
chKey
,
vis
);
toolsMenuActions
[
i
.
key
()]
->
setChecked
(
vis
);
break
;
}
}
}
}
}
void
MainWindow
::
updateVisibilitySettings
(
bool
vis
)
void
MainWindow
::
updateVisibilitySettings
(
bool
vis
)
{
{
...
@@ -795,9 +939,11 @@ void MainWindow::updateVisibilitySettings (bool vis)
...
@@ -795,9 +939,11 @@ void MainWindow::updateVisibilitySettings (bool vis)
if
(
temp
)
if
(
temp
)
{
{
QHashIterator
<
int
,
QWidget
*>
i
(
dockWidgets
);
QHashIterator
<
int
,
QWidget
*>
i
(
dockWidgets
);
while
(
i
.
hasNext
())
{
while
(
i
.
hasNext
())
{
i
.
next
();
i
.
next
();
if
((
static_cast
<
QDockWidget
*>
(
dockWidgets
[
i
.
key
()]))
==
temp
)
{
if
((
static_cast
<
QDockWidget
*>
(
dockWidgets
[
i
.
key
()]))
==
temp
)
{
QString
chKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
static_cast
<
TOOLS_WIDGET_NAMES
>
(
i
.
key
()),
currentView
);
QString
chKey
=
buildMenuKey
(
SUB_SECTION_CHECKED
,
static_cast
<
TOOLS_WIDGET_NAMES
>
(
i
.
key
()),
currentView
);
settings
.
setValue
(
chKey
,
vis
);
settings
.
setValue
(
chKey
,
vis
);
toolsMenuActions
[
i
.
key
()]
->
setChecked
(
vis
);
toolsMenuActions
[
i
.
key
()]
->
setChecked
(
vis
);
...
@@ -838,13 +984,7 @@ void MainWindow::connectCommonWidgets()
...
@@ -838,13 +984,7 @@ void MainWindow::connectCommonWidgets()
if
(
mapWidget
&&
waypointsDockWidget
->
widget
())
if
(
mapWidget
&&
waypointsDockWidget
->
widget
())
{
{
// clear path create on the map
connect
(
waypointsDockWidget
->
widget
(),
SIGNAL
(
clearPathclicked
()),
mapWidget
,
SLOT
(
clearWaypoints
()));
// add Waypoint widget in the WaypointList widget when mouse clicked
connect
(
mapWidget
,
SIGNAL
(
captureMapCoordinateClick
(
QPointF
)),
waypointsDockWidget
->
widget
(),
SLOT
(
addWaypointMouse
(
QPointF
)));
// it notifies that a waypoint global goes to do create and a map graphic too
connect
(
waypointsDockWidget
->
widget
(),
SIGNAL
(
createWaypointAtMap
(
QPointF
)),
mapWidget
,
SLOT
(
createWaypointGraphAtMap
(
QPointF
)));
}
}
//TODO temporaly debug
//TODO temporaly debug
...
@@ -1130,6 +1270,7 @@ void MainWindow::connectCommonActions()
...
@@ -1130,6 +1270,7 @@ void MainWindow::connectCommonActions()
connect
(
ui
.
actionPilotsView
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadPilotView
()));
connect
(
ui
.
actionPilotsView
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadPilotView
()));
connect
(
ui
.
actionEngineersView
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadEngineerView
()));
connect
(
ui
.
actionEngineersView
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadEngineerView
()));
connect
(
ui
.
actionOperatorsView
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadOperatorView
()));
connect
(
ui
.
actionOperatorsView
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadOperatorView
()));
connect
(
ui
.
actionUnconnectedView
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadUnconnectedView
()));
connect
(
ui
.
actionMavlinkView
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadMAVLinkView
()));
connect
(
ui
.
actionMavlinkView
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadMAVLinkView
()));
connect
(
ui
.
actionReloadStyle
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
reloadStylesheet
()));
connect
(
ui
.
actionReloadStyle
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
reloadStylesheet
()));
...
@@ -1276,8 +1417,13 @@ void MainWindow::UASCreated(UASInterface* uas)
...
@@ -1276,8 +1417,13 @@ void MainWindow::UASCreated(UASInterface* uas)
if
(
uas
!=
NULL
)
if
(
uas
!=
NULL
)
{
{
// The pilot view was not available on startup, enable it now
// Set default settings
setDefaultSettingsForAp
();
// The pilot, operator and engineer views were not available on startup, enable them now
ui
.
actionPilotsView
->
setEnabled
(
true
);
ui
.
actionPilotsView
->
setEnabled
(
true
);
ui
.
actionOperatorsView
->
setEnabled
(
true
);
ui
.
actionEngineersView
->
setEnabled
(
true
);
QIcon
icon
;
QIcon
icon
;
// Set matching icon
// Set matching icon
...
@@ -1371,6 +1517,7 @@ void MainWindow::UASCreated(UASInterface* uas)
...
@@ -1371,6 +1517,7 @@ void MainWindow::UASCreated(UASInterface* uas)
// }
// }
// }
// }
// }
// }
}
}
break
;
break
;
default:
default:
...
@@ -1391,8 +1538,6 @@ void MainWindow::UASCreated(UASInterface* uas)
...
@@ -1391,8 +1538,6 @@ void MainWindow::UASCreated(UASInterface* uas)
connectPxActions
();
connectPxActions
();
}
}
break
;
break
;
loadOperatorView
();
}
}
// Change the view only if this is the first UAS
// Change the view only if this is the first UAS
...
@@ -1406,19 +1551,31 @@ void MainWindow::UASCreated(UASInterface* uas)
...
@@ -1406,19 +1551,31 @@ void MainWindow::UASCreated(UASInterface* uas)
// Load last view if setting is present
// Load last view if setting is present
if
(
settings
.
contains
(
"CURRENT_VIEW_WITH_UAS_CONNECTED"
))
if
(
settings
.
contains
(
"CURRENT_VIEW_WITH_UAS_CONNECTED"
))
{
{
clearView
();
int
view
=
settings
.
value
(
"CURRENT_VIEW_WITH_UAS_CONNECTED"
).
toInt
();
int
view
=
settings
.
value
(
"CURRENT_VIEW_WITH_UAS_CONNECTED"
).
toInt
();
currentView
=
(
VIEW_SECTIONS
)
view
;
switch
(
view
)
presentView
();
// Restore the widget positions and size
if
(
settings
.
contains
(
getWindowStateKey
()))
{
{
restoreState
(
settings
.
value
(
getWindowStateKey
()).
toByteArray
(),
QGC
::
applicationVersion
());
case
VIEW_ENGINEER
:
loadEngineerView
();
break
;
case
VIEW_MAVLINK
:
loadMAVLinkView
();
break
;
case
VIEW_PILOT
:
loadPilotView
();
break
;
case
VIEW_UNCONNECTED
:
loadUnconnectedView
();
break
;
case
VIEW_OPERATOR
:
default:
loadOperatorView
();
break
;
}
}
}
}
else
else
{
{
load
Enginee
rView
();
load
Operato
rView
();
}
}
}
}
...
@@ -1436,7 +1593,7 @@ void MainWindow::UASCreated(UASInterface* uas)
...
@@ -1436,7 +1593,7 @@ void MainWindow::UASCreated(UASInterface* uas)
void
MainWindow
::
clearView
()
void
MainWindow
::
clearView
()
{
{
// Save current state
// Save current state
if
(
UASManager
::
instance
()
->
get
ActiveUAS
()
)
settings
.
setValue
(
getWindowStateKey
(),
saveState
(
QGC
::
applicationVersion
()));
if
(
UASManager
::
instance
()
->
get
UASList
().
count
()
>
0
)
settings
.
setValue
(
getWindowStateKey
(),
saveState
(
QGC
::
applicationVersion
()));
settings
.
setValue
(
getWindowGeometryKey
(),
saveGeometry
());
settings
.
setValue
(
getWindowGeometryKey
(),
saveGeometry
());
QAction
*
temp
;
QAction
*
temp
;
...
@@ -1449,12 +1606,12 @@ void MainWindow::clearView()
...
@@ -1449,12 +1606,12 @@ void MainWindow::clearView()
if
(
temp
)
if
(
temp
)
{
{
//
qDebug() << "TOOL:" << chKey << "IS:" << temp->isChecked();
qDebug
()
<<
"TOOL:"
<<
chKey
<<
"IS:"
<<
temp
->
isChecked
();
settings
.
setValue
(
chKey
,
temp
->
isChecked
());
settings
.
setValue
(
chKey
,
temp
->
isChecked
());
}
}
else
else
{
{
//
qDebug() << "TOOL:" << chKey << "IS DEFAULT AND UNCHECKED";
qDebug
()
<<
"TOOL:"
<<
chKey
<<
"IS DEFAULT AND UNCHECKED"
;
settings
.
setValue
(
chKey
,
false
);
settings
.
setValue
(
chKey
,
false
);
}
}
}
}
...
@@ -1471,11 +1628,8 @@ void MainWindow::clearView()
...
@@ -1471,11 +1628,8 @@ void MainWindow::clearView()
if
(
dockWidget
)
if
(
dockWidget
)
{
{
// Remove dock widget from main window
// Remove dock widget from main window
//this->removeDockWidget(dockWidget);
removeDockWidget
(
dockWidget
);
dockWidget
->
setVisible
(
false
);
//dockWidget->setVisible(false);
// Deletion of dockWidget would also delete all child
// widgets of dockWidget
// Is there a way to unset a widget from QDockWidget?
}
}
}
}
changingViewsFlag
=
false
;
changingViewsFlag
=
false
;
...
@@ -1485,11 +1639,10 @@ void MainWindow::loadEngineerView()
...
@@ -1485,11 +1639,10 @@ void MainWindow::loadEngineerView()
{
{
if
(
currentView
!=
VIEW_ENGINEER
)
if
(
currentView
!=
VIEW_ENGINEER
)
{
{
clearView
();
clearView
();
currentView
=
VIEW_ENGINEER
;
currentView
=
VIEW_ENGINEER
;
ui
.
actionEngineersView
->
setChecked
(
true
);
presentView
();
presentView
();
}
}
}
}
...
@@ -1497,11 +1650,21 @@ void MainWindow::loadOperatorView()
...
@@ -1497,11 +1650,21 @@ void MainWindow::loadOperatorView()
{
{
if
(
currentView
!=
VIEW_OPERATOR
)
if
(
currentView
!=
VIEW_OPERATOR
)
{
{
clearView
();
clearView
();
currentView
=
VIEW_OPERATOR
;
currentView
=
VIEW_OPERATOR
;
ui
.
actionOperatorsView
->
setChecked
(
true
);
presentView
();
}
}
presentView
();
void
MainWindow
::
loadUnconnectedView
()
{
if
(
currentView
!=
VIEW_UNCONNECTED
)
{
clearView
();
currentView
=
VIEW_UNCONNECTED
;
ui
.
actionUnconnectedView
->
setChecked
(
true
);
presentView
();
}
}
}
}
...
@@ -1509,11 +1672,10 @@ void MainWindow::loadPilotView()
...
@@ -1509,11 +1672,10 @@ void MainWindow::loadPilotView()
{
{
if
(
currentView
!=
VIEW_PILOT
)
if
(
currentView
!=
VIEW_PILOT
)
{
{
clearView
();
clearView
();
currentView
=
VIEW_PILOT
;
currentView
=
VIEW_PILOT
;
ui
.
actionPilotsView
->
setChecked
(
true
);
presentView
();
presentView
();
}
}
}
}
...
@@ -1521,11 +1683,10 @@ void MainWindow::loadMAVLinkView()
...
@@ -1521,11 +1683,10 @@ void MainWindow::loadMAVLinkView()
{
{
if
(
currentView
!=
VIEW_MAVLINK
)
if
(
currentView
!=
VIEW_MAVLINK
)
{
{
clearView
();
clearView
();
currentView
=
VIEW_MAVLINK
;
currentView
=
VIEW_MAVLINK
;
ui
.
actionMavlinkView
->
setChecked
(
true
);
presentView
();
presentView
();
}
}
}
}
...
@@ -1556,7 +1717,6 @@ void MainWindow::presentView()
...
@@ -1556,7 +1717,6 @@ void MainWindow::presentView()
showTheCentralWidget
(
CENTRAL_DATA_PLOT
,
currentView
);
showTheCentralWidget
(
CENTRAL_DATA_PLOT
,
currentView
);
// Show docked widgets based on current view and autopilot type
// Show docked widgets based on current view and autopilot type
// UAS CONTROL
// UAS CONTROL
...
@@ -1631,8 +1791,29 @@ void MainWindow::presentView()
...
@@ -1631,8 +1791,29 @@ void MainWindow::presentView()
// MAVLINK LOG PLAYER
// MAVLINK LOG PLAYER
showTheWidget
(
MENU_MAVLINK_LOG_PLAYER
,
currentView
);
showTheWidget
(
MENU_MAVLINK_LOG_PLAYER
,
currentView
);
// VIDEO 1
showTheWidget
(
MENU_VIDEO_STREAM_1
,
currentView
);
// VIDEO 2
showTheWidget
(
MENU_VIDEO_STREAM_2
,
currentView
);
this
->
show
();
this
->
show
();
// Restore window state
if
(
UASManager
::
instance
()
->
getUASList
().
count
()
>
0
)
{
// Restore the mainwindow size
if
(
settings
.
contains
(
getWindowGeometryKey
()))
{
restoreGeometry
(
settings
.
value
(
getWindowGeometryKey
()).
toByteArray
());
}
// Restore the widget positions and size
if
(
settings
.
contains
(
getWindowStateKey
()))
{
restoreState
(
settings
.
value
(
getWindowStateKey
()).
toByteArray
(),
QGC
::
applicationVersion
());
}
}
}
}
void
MainWindow
::
showTheCentralWidget
(
TOOLS_WIDGET_NAMES
centralWidget
,
VIEW_SECTIONS
view
)
void
MainWindow
::
showTheCentralWidget
(
TOOLS_WIDGET_NAMES
centralWidget
,
VIEW_SECTIONS
view
)
...
@@ -1640,15 +1821,17 @@ void MainWindow::showTheCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SE
...
@@ -1640,15 +1821,17 @@ void MainWindow::showTheCentralWidget (TOOLS_WIDGET_NAMES centralWidget, VIEW_SE
bool
tempVisible
;
bool
tempVisible
;
QWidget
*
tempWidget
=
dockWidgets
[
centralWidget
];
QWidget
*
tempWidget
=
dockWidgets
[
centralWidget
];
tempVisible
=
settings
.
value
(
buildMenuKey
(
SUB_SECTION_CHECKED
,
centralWidget
,
view
),
false
).
toBool
();
tempVisible
=
settings
.
value
(
buildMenuKey
(
SUB_SECTION_CHECKED
,
centralWidget
,
view
),
false
).
toBool
();
//
qDebug() << buildMenuKey (SUB_SECTION_CHECKED,centralWidget,view) << tempVisible;
qDebug
()
<<
buildMenuKey
(
SUB_SECTION_CHECKED
,
centralWidget
,
view
)
<<
tempVisible
;
if
(
toolsMenuActions
[
centralWidget
])
if
(
toolsMenuActions
[
centralWidget
])
{
{
qDebug
()
<<
"SETTING TO:"
<<
tempVisible
;
toolsMenuActions
[
centralWidget
]
->
setChecked
(
tempVisible
);
toolsMenuActions
[
centralWidget
]
->
setChecked
(
tempVisible
);
}
}
if
(
centerStack
&&
tempWidget
&&
tempVisible
)
if
(
centerStack
&&
tempWidget
&&
tempVisible
)
{
{
qDebug
()
<<
"ACTIVATING MAIN WIDGET"
;
centerStack
->
setCurrentWidget
(
tempWidget
);
centerStack
->
setCurrentWidget
(
tempWidget
);
}
}
}
}
...
...
src/ui/MainWindow.h
View file @
e9637d5a
...
@@ -112,6 +112,8 @@ public slots:
...
@@ -112,6 +112,8 @@ public slots:
void
stopVideoCapture
();
void
stopVideoCapture
();
void
saveScreen
();
void
saveScreen
();
/** @brief Load default view when no MAV is connected */
void
loadUnconnectedView
();
/** @brief Load view for pilot */
/** @brief Load view for pilot */
void
loadPilotView
();
void
loadPilotView
();
/** @brief Load view for engineer */
/** @brief Load view for engineer */
...
@@ -166,7 +168,7 @@ public slots:
...
@@ -166,7 +168,7 @@ public slots:
* It shows the QDockedWidget based on the action sender
* It shows the QDockedWidget based on the action sender
*
*
*/
*/
void
showToolWidget
();
void
showToolWidget
(
bool
visible
);
/**
/**
* @brief Shows a Widget from the center stack based on the action sender
* @brief Shows a Widget from the center stack based on the action sender
...
@@ -177,8 +179,10 @@ public slots:
...
@@ -177,8 +179,10 @@ public slots:
*/
*/
void
showCentralWidget
();
void
showCentralWidget
();
/** @brief Change actively a QDockWidgets visibility by an action */
void
showDockWidget
(
bool
vis
);
/** @brief Updates a QDockWidget's checked status based on its visibility */
/** @brief Updates a QDockWidget's checked status based on its visibility */
void
updateVisibilitySettings
(
bool
vis
);
void
updateVisibilitySettings
(
bool
vis
);
/** @brief Updates a QDockWidget's location */
/** @brief Updates a QDockWidget's location */
void
updateLocationSettings
(
Qt
::
DockWidgetArea
location
);
void
updateLocationSettings
(
Qt
::
DockWidgetArea
location
);
...
@@ -187,6 +191,9 @@ protected:
...
@@ -187,6 +191,9 @@ protected:
MainWindow
(
QWidget
*
parent
=
0
);
MainWindow
(
QWidget
*
parent
=
0
);
/** @brief Set default window settings for the current autopilot type */
void
setDefaultSettingsForAp
();
// These defines are used to save the settings when selecting with
// These defines are used to save the settings when selecting with
// which widgets populate the views
// which widgets populate the views
// FIXME: DO NOT PUT CUSTOM VALUES IN THIS ENUM since it is iterated over
// FIXME: DO NOT PUT CUSTOM VALUES IN THIS ENUM since it is iterated over
...
@@ -212,6 +219,8 @@ protected:
...
@@ -212,6 +219,8 @@ protected:
MENU_SLUGS_HIL
,
MENU_SLUGS_HIL
,
MENU_SLUGS_CAMERA
,
MENU_SLUGS_CAMERA
,
MENU_MAVLINK_LOG_PLAYER
,
MENU_MAVLINK_LOG_PLAYER
,
MENU_VIDEO_STREAM_1
,
MENU_VIDEO_STREAM_2
,
CENTRAL_SEPARATOR
=
255
,
// do not change
CENTRAL_SEPARATOR
=
255
,
// do not change
CENTRAL_LINECHART
,
CENTRAL_LINECHART
,
CENTRAL_PROTOCOL
,
CENTRAL_PROTOCOL
,
...
@@ -238,6 +247,7 @@ protected:
...
@@ -238,6 +247,7 @@ protected:
VIEW_OPERATOR
,
VIEW_OPERATOR
,
VIEW_PILOT
,
VIEW_PILOT
,
VIEW_MAVLINK
,
VIEW_MAVLINK
,
VIEW_UNCONNECTED
,
///< View in unconnected mode, when no UAS is available
}
VIEW_SECTIONS
;
}
VIEW_SECTIONS
;
...
@@ -368,6 +378,8 @@ protected:
...
@@ -368,6 +378,8 @@ protected:
QPointer
<
QDockWidget
>
watchdogControlDockWidget
;
QPointer
<
QDockWidget
>
watchdogControlDockWidget
;
QPointer
<
QDockWidget
>
headUpDockWidget
;
QPointer
<
QDockWidget
>
headUpDockWidget
;
QPointer
<
QDockWidget
>
video1DockWidget
;
QPointer
<
QDockWidget
>
video2DockWidget
;
QPointer
<
QDockWidget
>
logPlayerDockWidget
;
QPointer
<
QDockWidget
>
logPlayerDockWidget
;
QPointer
<
QDockWidget
>
hsiDockWidget
;
QPointer
<
QDockWidget
>
hsiDockWidget
;
...
...
src/ui/MainWindow.ui
View file @
e9637d5a
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
</widget>
</widget>
<widget
class=
"QMenu"
name=
"menuTools"
>
<widget
class=
"QMenu"
name=
"menuTools"
>
<property
name=
"title"
>
<property
name=
"title"
>
<string>
Tool
s
</string>
<string>
Widget
s
</string>
</property>
</property>
<addaction
name=
"actionNewCustomWidget"
/>
<addaction
name=
"actionNewCustomWidget"
/>
</widget>
</widget>
...
@@ -121,11 +121,18 @@
...
@@ -121,11 +121,18 @@
<addaction
name=
"actionPilotsView"
/>
<addaction
name=
"actionPilotsView"
/>
<addaction
name=
"separator"
/>
<addaction
name=
"separator"
/>
<addaction
name=
"actionMavlinkView"
/>
<addaction
name=
"actionMavlinkView"
/>
<addaction
name=
"actionUnconnectedView"
/>
</widget>
<widget
class=
"QMenu"
name=
"menuMain"
>
<property
name=
"title"
>
<string>
Main
</string>
</property>
</widget>
</widget>
<addaction
name=
"menuMGround"
/>
<addaction
name=
"menuMGround"
/>
<addaction
name=
"menuNetwork"
/>
<addaction
name=
"menuNetwork"
/>
<addaction
name=
"menuConnected_Systems"
/>
<addaction
name=
"menuConnected_Systems"
/>
<addaction
name=
"menuUnmanned_System"
/>
<addaction
name=
"menuUnmanned_System"
/>
<addaction
name=
"menuMain"
/>
<addaction
name=
"menuTools"
/>
<addaction
name=
"menuTools"
/>
<addaction
name=
"menuPerspectives"
/>
<addaction
name=
"menuPerspectives"
/>
<addaction
name=
"menuHelp"
/>
<addaction
name=
"menuHelp"
/>
...
@@ -296,6 +303,9 @@
...
@@ -296,6 +303,9 @@
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Operator
</string>
<string>
Operator
</string>
</property>
</property>
<property
name=
"shortcut"
>
<string>
Meta+O
</string>
</property>
</action>
</action>
<action
name=
"actionEngineersView"
>
<action
name=
"actionEngineersView"
>
<property
name=
"checkable"
>
<property
name=
"checkable"
>
...
@@ -308,6 +318,9 @@
...
@@ -308,6 +318,9 @@
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Engineer
</string>
<string>
Engineer
</string>
</property>
</property>
<property
name=
"shortcut"
>
<string>
Meta+E
</string>
</property>
</action>
</action>
<action
name=
"actionMavlinkView"
>
<action
name=
"actionMavlinkView"
>
<property
name=
"checkable"
>
<property
name=
"checkable"
>
...
@@ -320,6 +333,9 @@
...
@@ -320,6 +333,9 @@
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Mavlink
</string>
<string>
Mavlink
</string>
</property>
</property>
<property
name=
"shortcut"
>
<string>
Meta+M
</string>
</property>
</action>
</action>
<action
name=
"actionReloadStyle"
>
<action
name=
"actionReloadStyle"
>
<property
name=
"icon"
>
<property
name=
"icon"
>
...
@@ -341,6 +357,9 @@
...
@@ -341,6 +357,9 @@
<property
name=
"text"
>
<property
name=
"text"
>
<string>
Pilot
</string>
<string>
Pilot
</string>
</property>
</property>
<property
name=
"shortcut"
>
<string>
Meta+P
</string>
</property>
</action>
</action>
<action
name=
"actionNewCustomWidget"
>
<action
name=
"actionNewCustomWidget"
>
<property
name=
"icon"
>
<property
name=
"icon"
>
...
@@ -379,6 +398,21 @@
...
@@ -379,6 +398,21 @@
<string>
QGroundControl global settings
</string>
<string>
QGroundControl global settings
</string>
</property>
</property>
</action>
</action>
<action
name=
"actionUnconnectedView"
>
<property
name=
"checkable"
>
<bool>
true
</bool>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../../mavground.qrc"
>
<normaloff>
:/images/devices/network-wireless.svg
</normaloff>
:/images/devices/network-wireless.svg
</iconset>
</property>
<property
name=
"text"
>
<string>
Unconnected
</string>
</property>
<property
name=
"shortcut"
>
<string>
Meta+U
</string>
</property>
</action>
</widget>
</widget>
<layoutdefault
spacing=
"6"
margin=
"11"
/>
<layoutdefault
spacing=
"6"
margin=
"11"
/>
<resources>
<resources>
...
...
src/ui/MapWidget.cc
View file @
e9637d5a
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "UASManager.h"
#include "UASManager.h"
#include "MAV2DIcon.h"
#include "MAV2DIcon.h"
#include "Waypoint2DIcon.h"
#include "Waypoint2DIcon.h"
#include "UASWaypointManager.h"
#include "MG.h"
#include "MG.h"
...
@@ -38,7 +39,7 @@ MapWidget::MapWidget(QWidget *parent) :
...
@@ -38,7 +39,7 @@ MapWidget::MapWidget(QWidget *parent) :
mc
=
new
qmapcontrol
::
MapControl
(
QSize
(
320
,
240
));
mc
=
new
qmapcontrol
::
MapControl
(
QSize
(
320
,
240
));
// VISUAL MAP STYLE
// VISUAL MAP STYLE
QString
buttonStyle
(
"QAbstractButton { background-color: rgba(20, 20, 20, 45%); border-color: rgba(10, 10, 10, 50%)}"
);
QString
buttonStyle
(
"QAbstractButton { background-color: rgba(20, 20, 20, 45%); border-color: rgba(10, 10, 10, 50%)}
QAbstractButton:checked { border: 2px solid #379AC3; }
"
);
mc
->
setPen
(
QGC
::
colorCyan
.
darker
(
400
));
mc
->
setPen
(
QGC
::
colorCyan
.
darker
(
400
));
...
@@ -93,7 +94,7 @@ MapWidget::MapWidget(QWidget *parent) :
...
@@ -93,7 +94,7 @@ MapWidget::MapWidget(QWidget *parent) :
// SET INITIAL POSITION AND ZOOM
// SET INITIAL POSITION AND ZOOM
// Set default zoom level
// Set default zoom level
mc
->
setZoom
(
1
6
);
mc
->
setZoom
(
1
7
);
// Zurich, ETH
// Zurich, ETH
mc
->
setView
(
QPointF
(
8.548056
,
47.376389
));
mc
->
setView
(
QPointF
(
8.548056
,
47.376389
));
...
@@ -371,7 +372,7 @@ void MapWidget::createPathButtonClicked(bool checked)
...
@@ -371,7 +372,7 @@ void MapWidget::createPathButtonClicked(bool checked)
// emit signal start to create a Waypoint global
// emit signal start to create a Waypoint global
emit
createGlobalWP
(
true
,
mc
->
currentCoordinate
());
//
emit createGlobalWP(true, mc->currentCoordinate());
// // Clear the previous WP track
// // Clear the previous WP track
// // TODO: Move this to an actual clear track button and add a warning dialog
// // TODO: Move this to an actual clear track button and add a warning dialog
...
@@ -400,50 +401,104 @@ void MapWidget::createPathButtonClicked(bool checked)
...
@@ -400,50 +401,104 @@ void MapWidget::createPathButtonClicked(bool checked)
void
MapWidget
::
captureMapClick
(
const
QMouseEvent
*
event
,
const
QPointF
coordinate
)
void
MapWidget
::
captureMapClick
(
const
QMouseEvent
*
event
,
const
QPointF
coordinate
)
{
{
//qDebug() << mc->mouseMode();
if
(
QEvent
::
MouseButtonRelease
==
event
->
type
()
&&
createPath
->
isChecked
())
if
(
QEvent
::
MouseButtonRelease
==
event
->
type
()
&&
createPath
->
isChecked
())
{
{
// Create waypoint name
// Create waypoint name
QString
str
;
QString
str
;
str
=
QString
(
"%1"
).
arg
(
waypointPath
->
numberOfPoints
());
// create the WP and set everything in the LineString to display the path
// create the WP and set everything in the LineString to display the path
Waypoint2DIcon
*
tempCirclePoint
;
Waypoint2DIcon
*
tempCirclePoint
;
if
(
mav
)
if
(
mav
)
{
{
tempCirclePoint
=
new
Waypoint2DIcon
(
coordinate
.
x
(),
coordinate
.
y
(),
20
,
str
,
qmapcontrol
::
Point
::
Middle
,
new
QPen
(
mav
->
getColor
()));
mav
->
getWaypointManager
()
->
addWaypoint
(
new
Waypoint
(
mav
->
getWaypointManager
()
->
getWaypointList
().
count
(),
coordinate
.
x
(),
coordinate
.
y
()));
}
}
else
else
{
{
str
=
QString
(
"%1"
).
arg
(
waypointPath
->
numberOfPoints
());
tempCirclePoint
=
new
Waypoint2DIcon
(
coordinate
.
x
(),
coordinate
.
y
(),
20
,
str
,
qmapcontrol
::
Point
::
Middle
);
tempCirclePoint
=
new
Waypoint2DIcon
(
coordinate
.
x
(),
coordinate
.
y
(),
20
,
str
,
qmapcontrol
::
Point
::
Middle
);
}
mc
->
layer
(
"Waypoints"
)
->
addGeometry
(
tempCirclePoint
);
qmapcontrol
::
Point
*
tempPoint
=
new
qmapcontrol
::
Point
(
coordinate
.
x
(),
coordinate
.
y
(),
str
);
mc
->
layer
(
"Waypoints"
)
->
addGeometry
(
tempCirclePoint
);
wps
.
append
(
tempPoint
);
waypointPath
->
addPoint
(
tempPoint
);
wpIndex
.
insert
(
str
,
tempPoint
);
qmapcontrol
::
Point
*
tempPoint
=
new
qmapcontrol
::
Point
(
coordinate
.
x
(),
coordinate
.
y
(),
str
);
wps
.
append
(
tempPoint
);
waypointPath
->
addPoint
(
tempPoint
);
// Refresh the screen
// Refresh the screen
mc
->
updateRequest
(
tempPoint
->
boundingBox
().
toRect
());
mc
->
updateRequest
(
tempPoint
->
boundingBox
().
toRect
());
}
// emit signal mouse was clicked
// emit signal mouse was clicked
emit
captureMapCoordinateClick
(
coordinate
);
//
emit captureMapCoordinateClick(coordinate);
}
}
}
}
void
MapWidget
::
createWaypointGraphAtMap
(
const
QPointF
coordinate
)
void
MapWidget
::
updateWaypoint
(
int
uas
,
Waypoint
*
wp
)
{
{
if
(
!
wpExists
(
coordinate
))
//qDebug() << "UPDATING WP" << wp->getId() << __FILE__ << __LINE__;
if
(
uas
==
this
->
mav
->
getUASID
())
{
{
int
wpindex
=
UASManager
::
instance
()
->
getUASForId
(
uas
)
->
getWaypointManager
()
->
getIndexOf
(
wp
);
// Create waypoint name
// Create waypoint name
QString
str
;
QString
str
=
QString
(
"%1"
).
arg
(
wpindex
);
// Check if wp exists yet
if
(
!
(
wps
.
count
()
>
wpindex
))
{
QPointF
coordinate
;
coordinate
.
setX
(
wp
->
getX
());
coordinate
.
setY
(
wp
->
getY
());
createWaypointGraphAtMap
(
wpindex
,
coordinate
);
qDebug
()
<<
"Waypoint Index did not contain"
<<
str
;
}
else
{
// Waypoint exists, update it
if
(
!
waypointIsDrag
)
{
qDebug
()
<<
"indice WP= "
<<
wpindex
<<
"
\n
"
;
QPointF
coordinate
;
coordinate
.
setX
(
wp
->
getX
());
coordinate
.
setY
(
wp
->
getY
());
Point
*
waypoint
;
waypoint
=
wps
.
at
(
wpindex
);
//wpIndex[str];
if
(
waypoint
)
{
// First set waypoint coordinate
waypoint
->
setCoordinate
(
coordinate
);
// Now update icon position
//mc->layer("Waypoints")->removeGeometry(wpIcons.at(wpindex));
wpIcons
.
at
(
wpindex
)
->
setCoordinate
(
coordinate
);
//mc->layer("Waypoints")->addGeometry(wpIcons.at(wpindex));
// Then waypoint line coordinate
Point
*
linesegment
=
NULL
;
if
(
waypointPath
->
points
().
size
()
>
wpindex
)
{
linesegment
=
waypointPath
->
points
().
at
(
wpindex
);
}
if
(
linesegment
)
{
linesegment
->
setCoordinate
(
coordinate
);
}
//point2Find = dynamic_cast <Point*> (mc->layer("Waypoints")->get_Geometry(wpindex));
//point2Find->setCoordinate(coordinate);
mc
->
updateRequest
(
waypoint
->
boundingBox
().
toRect
());
}
}
}
}
}
str
=
QString
(
"%1"
).
arg
(
waypointPath
->
numberOfPoints
());
void
MapWidget
::
createWaypointGraphAtMap
(
int
id
,
const
QPointF
coordinate
)
{
if
(
!
wpExists
(
coordinate
))
{
// Create waypoint name
QString
str
;
// create the WP and set everything in the LineString to display the path
// create the WP and set everything in the LineString to display the path
//CirclePoint* tempCirclePoint = new CirclePoint(coordinate.x(), coordinate.y(), 10, str);
//CirclePoint* tempCirclePoint = new CirclePoint(coordinate.x(), coordinate.y(), 10, str);
...
@@ -451,35 +506,42 @@ void MapWidget::createWaypointGraphAtMap(const QPointF coordinate)
...
@@ -451,35 +506,42 @@ void MapWidget::createWaypointGraphAtMap(const QPointF coordinate)
if
(
mav
)
if
(
mav
)
{
{
tempCirclePoint
=
new
Waypoint2DIcon
(
coordinate
.
x
(),
coordinate
.
y
(),
20
,
str
,
qmapcontrol
::
Point
::
Middle
,
new
QPen
(
mav
->
getColor
()));
int
uas
=
mav
->
getUASID
();
str
=
QString
(
"%1"
).
arg
(
id
);
qDebug
()
<<
"Waypoint list count:"
<<
str
;
tempCirclePoint
=
new
Waypoint2DIcon
(
coordinate
.
x
(),
coordinate
.
y
(),
20
,
str
,
qmapcontrol
::
Point
::
Middle
,
mavPens
.
value
(
uas
));
}
}
else
else
{
{
str
=
QString
(
"%1"
).
arg
(
id
);
tempCirclePoint
=
new
Waypoint2DIcon
(
coordinate
.
x
(),
coordinate
.
y
(),
20
,
str
,
qmapcontrol
::
Point
::
Middle
);
tempCirclePoint
=
new
Waypoint2DIcon
(
coordinate
.
x
(),
coordinate
.
y
(),
20
,
str
,
qmapcontrol
::
Point
::
Middle
);
}
}
mc
->
layer
(
"Waypoints"
)
->
addGeometry
(
tempCirclePoint
);
mc
->
layer
(
"Waypoints"
)
->
addGeometry
(
tempCirclePoint
);
wpIcons
.
append
(
tempCirclePoint
);
Point
*
tempPoint
=
new
Point
(
coordinate
.
x
(),
coordinate
.
y
(),
str
);
Point
*
tempPoint
=
new
Point
(
coordinate
.
x
(),
coordinate
.
y
(),
str
);
wps
.
append
(
tempPoint
);
wps
.
append
(
tempPoint
);
waypointPath
->
addPoint
(
tempPoint
);
waypointPath
->
addPoint
(
tempPoint
);
wpIndex
.
insert
(
str
,
tempPoint
);
//
wpIndex.insert(str,tempPoint);
qDebug
()
<<
"Funcion createWaypointGraphAtMap WP= "
<<
str
<<
" -> x= "
<<
tempPoint
->
latitude
()
<<
" y= "
<<
tempPoint
->
longitude
();
qDebug
()
<<
"Funcion createWaypointGraphAtMap WP= "
<<
str
<<
" -> x= "
<<
tempPoint
->
latitude
()
<<
" y= "
<<
tempPoint
->
longitude
();
// Refresh the screen
// Refresh the screen
mc
->
updateRequest
New
();
//
(tempPoint->boundingBox().toRect());
mc
->
updateRequest
(
tempPoint
->
boundingBox
().
toRect
());
}
}
//// // emit signal mouse was clicked
//// // emit signal mouse was clicked
// emit captureMapCoordinateClick(coordinate);
// emit captureMapCoordinateClick(coordinate);
}
}
int
MapWidget
::
wpExists
(
const
QPointF
coordinate
){
int
MapWidget
::
wpExists
(
const
QPointF
coordinate
)
{
for
(
int
i
=
0
;
i
<
wps
.
size
();
i
++
){
for
(
int
i
=
0
;
i
<
wps
.
size
();
i
++
){
if
(
wps
.
at
(
i
)
->
latitude
()
==
coordinate
.
y
()
&&
if
(
wps
.
at
(
i
)
->
latitude
()
==
coordinate
.
y
()
&&
wps
.
at
(
i
)
->
longitude
()
==
coordinate
.
x
()){
wps
.
at
(
i
)
->
longitude
()
==
coordinate
.
x
())
{
return
1
;
return
1
;
}
}
}
}
...
@@ -493,21 +555,23 @@ void MapWidget::captureGeometryClick(Geometry* geom, QPoint point)
...
@@ -493,21 +555,23 @@ void MapWidget::captureGeometryClick(Geometry* geom, QPoint point)
Q_UNUSED
(
point
);
Q_UNUSED
(
point
);
mc
->
setMouseMode
(
qmapcontrol
::
MapControl
::
None
);
mc
->
setMouseMode
(
qmapcontrol
::
MapControl
::
None
);
}
}
void
MapWidget
::
captureGeometryDrag
(
Geometry
*
geom
,
QPointF
coordinate
)
void
MapWidget
::
captureGeometryDrag
(
Geometry
*
geom
,
QPointF
coordinate
)
{
{
waypointIsDrag
=
true
;
waypointIsDrag
=
true
;
// Refresh the screen
// Refresh the screen
mc
->
updateRequest
(
geom
->
boundingBox
().
toRect
());
mc
->
updateRequest
(
geom
->
boundingBox
().
toRect
());
int
temp
=
0
;
int
temp
=
0
;
// Get waypoint index in list
bool
wpIndexOk
;
int
index
=
geom
->
name
().
toInt
(
&
wpIndexOk
);
qmapcontrol
::
Point
*
point2Find
;
qmapcontrol
::
Point
*
point2Find
;
point2Find
=
wp
Index
[
geom
->
name
()]
;
point2Find
=
wp
s
.
at
(
geom
->
name
().
toInt
())
;
if
(
point2Find
)
if
(
point2Find
)
{
{
...
@@ -518,6 +582,21 @@ void MapWidget::captureGeometryDrag(Geometry* geom, QPointF coordinate)
...
@@ -518,6 +582,21 @@ void MapWidget::captureGeometryDrag(Geometry* geom, QPointF coordinate)
{
{
point2Find
->
setCoordinate
(
coordinate
);
point2Find
->
setCoordinate
(
coordinate
);
if
(
wpIndexOk
)
{
mc
->
updateRequest
(
point2Find
->
boundingBox
().
toRect
());
if
(
mav
)
{
QVector
<
Waypoint
*>
wps
=
mav
->
getWaypointManager
()
->
getWaypointList
();
if
(
wps
.
size
()
>
index
)
{
wps
.
at
(
index
)
->
setX
(
coordinate
.
x
());
wps
.
at
(
index
)
->
setY
(
coordinate
.
y
());
mav
->
getWaypointManager
()
->
notifyOfChange
(
wps
.
at
(
index
));
}
}
}
// qDebug() << geom->name();
// qDebug() << geom->name();
temp
=
geom
->
get_myIndex
();
temp
=
geom
->
get_myIndex
();
//qDebug() << temp;
//qDebug() << temp;
...
@@ -553,18 +632,102 @@ MapWidget::~MapWidget()
...
@@ -553,18 +632,102 @@ MapWidget::~MapWidget()
void
MapWidget
::
addUAS
(
UASInterface
*
uas
)
void
MapWidget
::
addUAS
(
UASInterface
*
uas
)
{
{
connect
(
uas
,
SIGNAL
(
globalPositionChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateGlobalPosition
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
connect
(
uas
,
SIGNAL
(
globalPositionChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateGlobalPosition
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
//connect(uas->getWaypointManager(), SIGNAL(waypointListChanged()), this, SLOT(redoWaypoints()));
}
void
MapWidget
::
updateWaypointList
(
int
uas
)
{
// Get already existing waypoints
UASInterface
*
uasInstance
=
UASManager
::
instance
()
->
getUASForId
(
uas
);
if
(
uasInstance
)
{
QVector
<
Waypoint
*>
wpList
=
uasInstance
->
getWaypointManager
()
->
getWaypointList
();
// Clear if necessary
if
(
wpList
.
count
()
==
0
)
{
clearWaypoints
(
uas
);
return
;
}
// Load all existing waypoints into map view
foreach
(
Waypoint
*
wp
,
wpList
)
{
updateWaypoint
(
mav
->
getUASID
(),
wp
);
}
// Delete now unused wps
if
(
wps
.
count
()
>
wpList
.
count
())
{
mc
->
layer
(
"Waypoints"
)
->
removeGeometry
(
waypointPath
);
for
(
int
i
=
wpList
.
count
();
i
<
wps
.
count
();
++
i
)
{
QRect
updateRect
=
wps
.
at
(
i
)
->
boundingBox
().
toRect
();
wps
.
removeAt
(
i
);
mc
->
layer
(
"Waypoints"
)
->
removeGeometry
(
wpIcons
.
at
(
i
));
waypointPath
->
points
().
removeAt
(
i
);
//Point* linesegment = waypointPath->points().at(mav->getWaypointManager()->getWaypointList().indexOf(wp));
mc
->
updateRequest
(
updateRect
);
}
mc
->
layer
(
"Waypoints"
)
->
addGeometry
(
waypointPath
);
}
// Clear and rebuild linestring
}
}
void
MapWidget
::
redoWaypoints
(
int
uas
)
{
// QObject* sender = QObject::sender();
// UASWaypointManager* manager = dynamic_cast<UASWaypointManager*>(sender);
// if (sender)
// {
// Get waypoint list for this MAV
// Clear all waypoints
clearWaypoints
();
// Re-add the updated waypoints
// }
updateWaypointList
(
uas
);
}
}
void
MapWidget
::
activeUASSet
(
UASInterface
*
uas
)
void
MapWidget
::
activeUASSet
(
UASInterface
*
uas
)
{
{
// Disconnect old MAV
if
(
mav
)
{
// clear path create on the map
disconnect
(
mav
->
getWaypointManager
(),
SIGNAL
(
waypointListChanged
(
int
)),
this
,
SLOT
(
updateWaypointList
(
int
)));
// add Waypoint widget in the WaypointList widget when mouse clicked
disconnect
(
this
,
SIGNAL
(
waypointCreated
(
Waypoint
*
)),
mav
->
getWaypointManager
(),
SLOT
(
addWaypoint
(
Waypoint
*
)));
// it notifies that a waypoint global goes to do create and a map graphic too
//connect(waypointsDockWidget->widget(), SIGNAL(createWaypointAtMap(QPointF)), mapWidget, SLOT(createWaypointGraphAtMap(QPointF)));
}
if
(
uas
)
if
(
uas
)
{
{
mav
=
uas
;
mav
=
uas
;
QColor
color
=
mav
->
getColor
();
QColor
color
=
mav
->
getColor
()
.
lighter
(
100
)
;
color
.
setAlphaF
(
0.6
);
color
.
setAlphaF
(
0.6
);
QPen
*
pen
=
new
QPen
(
color
);
QPen
*
pen
=
new
QPen
(
color
);
pen
->
setWidth
(
3.0
);
pen
->
setWidth
(
2.0
);
// FIXME Load waypoints of this system
mavPens
.
insert
(
mav
->
getUASID
(),
pen
);
// FIXME Remove after refactoring
waypointPath
->
setPen
(
pen
);
// Delete all waypoints and start fresh
redoWaypoints
();
// clear path create on the map
connect
(
mav
->
getWaypointManager
(),
SIGNAL
(
waypointListChanged
(
int
)),
this
,
SLOT
(
updateWaypointList
(
int
)));
// add Waypoint widget in the WaypointList widget when mouse clicked
connect
(
this
,
SIGNAL
(
waypointCreated
(
Waypoint
*
)),
mav
->
getWaypointManager
(),
SLOT
(
addWaypoint
(
Waypoint
*
)));
}
}
}
}
...
@@ -589,7 +752,10 @@ void MapWidget::updateGlobalPosition(UASInterface* uas, double lat, double lon,
...
@@ -589,7 +752,10 @@ void MapWidget::updateGlobalPosition(UASInterface* uas, double lat, double lon,
//pointpen->setWidth(3);
//pointpen->setWidth(3);
//points.append(new CirclePoint(lat, lon, 10, uas->getUASName(), Point::Middle, pointpen));
//points.append(new CirclePoint(lat, lon, 10, uas->getUASName(), Point::Middle, pointpen));
MAV2DIcon
*
p
;
qmapcontrol
::
Point
*
p
;
QPointF
coordinate
;
coordinate
.
setX
(
lat
);
coordinate
.
setY
(
lon
);
if
(
!
uasIcons
.
contains
(
uas
->
getUASID
()))
if
(
!
uasIcons
.
contains
(
uas
->
getUASID
()))
{
{
...
@@ -597,40 +763,42 @@ void MapWidget::updateGlobalPosition(UASInterface* uas, double lat, double lon,
...
@@ -597,40 +763,42 @@ void MapWidget::updateGlobalPosition(UASInterface* uas, double lat, double lon,
QColor
uasColor
=
uas
->
getColor
();
QColor
uasColor
=
uas
->
getColor
();
// Icon
// Icon
QPen
*
pointpen
=
new
QPen
(
uasColor
);
//QPen* pointpen = new QPen(uasColor);
qDebug
()
<<
uas
->
getUASName
();
qDebug
()
<<
"2D MAP: ADDING"
<<
uas
->
getUASName
()
<<
__FILE__
<<
__LINE__
;
p
=
new
MAV2DIcon
(
lat
,
lon
,
20
,
uas
->
getUASName
(),
qmapcontrol
::
Point
::
Middle
,
pointpen
);
//p = new MAV2DIcon(lat, lon, 20, uas->getUASName(), qmapcontrol::Point::Middle, mavPens.value(uas->getUASID()));
p
=
new
Waypoint2DIcon
(
lat
,
lon
,
20
,
QString
(
"%1"
).
arg
(
uas
->
getUASID
()),
qmapcontrol
::
Point
::
Middle
);
uasIcons
.
insert
(
uas
->
getUASID
(),
p
);
uasIcons
.
insert
(
uas
->
getUASID
(),
p
);
tracks
->
addGeometry
(
p
);
mc
->
layer
(
"Waypoints"
)
->
addGeometry
(
p
);
// Line
// Line
// A QPen also can use transparency
// A QPen also can use transparency
QList
<
qmapcontrol
::
Point
*>
points
;
QList
<
qmapcontrol
::
Point
*>
points
;
points
.
append
(
new
qmapcontrol
::
Point
(
lat
,
lon
,
""
));
points
.
append
(
new
qmapcontrol
::
Point
(
coordinate
.
x
(),
coordinate
.
y
()
));
QPen
*
linepen
=
new
QPen
(
uasColor
.
darker
());
QPen
*
linepen
=
new
QPen
(
uasColor
.
darker
());
linepen
->
setWidth
(
2
);
linepen
->
setWidth
(
2
);
// Create tracking line string
// Create tracking line string
qmapcontrol
::
LineString
*
ls
=
new
qmapcontrol
::
LineString
(
points
,
uas
->
getUASName
(
),
linepen
);
qmapcontrol
::
LineString
*
ls
=
new
qmapcontrol
::
LineString
(
points
,
QString
(
"%1"
).
arg
(
uas
->
getUASID
()
),
linepen
);
uasTrails
.
insert
(
uas
->
getUASID
(),
ls
);
uasTrails
.
insert
(
uas
->
getUASID
(),
ls
);
// Add the LineString to the layer
// Add the LineString to the layer
mc
->
layer
(
"
Tracking
"
)
->
addGeometry
(
ls
);
mc
->
layer
(
"
Waypoints
"
)
->
addGeometry
(
ls
);
}
}
else
else
{
{
p
=
dynamic_cast
<
MAV2DIcon
*>
(
uasIcons
.
value
(
uas
->
getUASID
()));
// p = dynamic_cast<MAV2DIcon*>(uasIcons.value(uas->getUASID()));
if
(
p
)
// if (p)
{
// {
p
=
uasIcons
.
value
(
uas
->
getUASID
());
p
->
setCoordinate
(
QPointF
(
lat
,
lon
));
p
->
setCoordinate
(
QPointF
(
lat
,
lon
));
p
->
setYaw
(
uas
->
getYaw
());
//
p->setYaw(uas->getYaw());
}
//
}
// Extend trail
// Extend trail
uasTrails
.
value
(
uas
->
getUASID
())
->
addPoint
(
new
qmapcontrol
::
Point
(
lat
,
lon
,
""
));
uasTrails
.
value
(
uas
->
getUASID
())
->
addPoint
(
new
qmapcontrol
::
Point
(
coordinate
.
x
(),
coordinate
.
y
()
));
}
}
mc
->
updateRequest
(
p
->
boundingBox
().
toRect
());
mc
->
updateRequest
(
p
->
boundingBox
().
toRect
());
//mc->updateRequestNew();//(uasTrails.value(uas->getUASID())->boundingBox().toRect());
//mc->updateRequestNew();//(uasTrails.value(uas->getUASID())->boundingBox().toRect());
...
@@ -738,24 +906,28 @@ void MapWidget::changeEvent(QEvent *e)
...
@@ -738,24 +906,28 @@ void MapWidget::changeEvent(QEvent *e)
}
}
}
}
void
MapWidget
::
clearWaypoints
()
void
MapWidget
::
clearWaypoints
(
int
uas
)
{
{
// Clear the previous WP track
// Clear the previous WP track
mc
->
layer
(
"Waypoints"
)
->
clearGeometries
();
//
mc->layer("Waypoints")->clearGeometries();
wps
.
clear
();
wps
.
clear
();
waypointPath
->
setPoints
(
wps
);
waypointPath
->
points
().
clear
();
//delete waypointPath;
//waypointPath = new
mc
->
layer
(
"Waypoints"
)
->
addGeometry
(
waypointPath
);
mc
->
layer
(
"Waypoints"
)
->
addGeometry
(
waypointPath
);
wpIndex
.
clear
();
//
wpIndex.clear();
mc
->
updateRequestNew
();
//(waypointPath->boundingBox().toRect());
mc
->
updateRequestNew
();
//(waypointPath->boundingBox().toRect());
if
(
createPath
->
isChecked
())
if
(
createPath
->
isChecked
())
{
{
createPath
->
click
();
createPath
->
click
();
}
}
qDebug
()
<<
"CLEARING WAYPOINTS"
;
}
}
void
MapWidget
::
clearPath
()
void
MapWidget
::
clearPath
(
int
uas
)
{
{
mc
->
layer
(
"Tracking"
)
->
clearGeometries
();
mc
->
layer
(
"Tracking"
)
->
clearGeometries
();
foreach
(
qmapcontrol
::
LineString
*
ls
,
uasTrails
)
foreach
(
qmapcontrol
::
LineString
*
ls
,
uasTrails
)
...
@@ -769,30 +941,6 @@ void MapWidget::clearPath()
...
@@ -769,30 +941,6 @@ void MapWidget::clearPath()
mc
->
updateRequestNew
();
//(QRect(0, 0, width(), height()));
mc
->
updateRequestNew
();
//(QRect(0, 0, width(), height()));
}
}
void
MapWidget
::
changeGlobalWaypointPositionBySpinBox
(
int
index
,
float
lat
,
float
lon
)
{
if
(
!
waypointIsDrag
)
{
qDebug
()
<<
"indice WP= "
<<
index
<<
"
\n
"
;
QPointF
coordinate
;
coordinate
.
setX
(
lon
);
coordinate
.
setY
(
lat
);
Point
*
point2Find
;
point2Find
=
wpIndex
[
QString
::
number
(
index
)];
point2Find
->
setCoordinate
(
coordinate
);
point2Find
=
dynamic_cast
<
Point
*>
(
mc
->
layer
(
"Waypoints"
)
->
get_Geometry
(
index
));
point2Find
->
setCoordinate
(
coordinate
);
// Refresh the screen
mc
->
updateRequestNew
();
//(point2Find->boundingBox().toRect());
}
}
void
MapWidget
::
updateCameraPosition
(
double
radio
,
double
bearing
,
QString
dir
)
void
MapWidget
::
updateCameraPosition
(
double
radio
,
double
bearing
,
QString
dir
)
{
{
// FIXME Mariano
// FIXME Mariano
...
...
src/ui/MapWidget.h
View file @
e9637d5a
...
@@ -44,6 +44,8 @@ This file is part of the QGROUNDCONTROL project
...
@@ -44,6 +44,8 @@ This file is part of the QGROUNDCONTROL project
class
QMenu
;
class
QMenu
;
class
Waypoint
;
class
Waypoint2DIcon
;
namespace
Ui
{
namespace
Ui
{
class
MapWidget
;
class
MapWidget
;
...
@@ -72,10 +74,18 @@ public slots:
...
@@ -72,10 +74,18 @@ public slots:
QPointF
getPointxBearing_Range
(
double
lat1
,
double
lon1
,
double
bearing
,
double
distance
);
QPointF
getPointxBearing_Range
(
double
lat1
,
double
lon1
,
double
bearing
,
double
distance
);
/** @brief Clear the waypoints overlay layer */
/** @brief Clear the waypoints overlay layer */
void
clearWaypoints
();
void
clearWaypoints
(
int
uas
=
0
);
/** @brief Clear the UAV tracks on the map */
/** @brief Clear the UAV tracks on the map */
void
clearPath
();
void
clearPath
(
int
uas
=
0
);
void
changeGlobalWaypointPositionBySpinBox
(
int
index
,
float
lat
,
float
lon
);
/** @brief Update waypoint list */
void
updateWaypointList
(
int
uas
);
/** @brief Clear all waypoints and re-add them from updated list */
void
redoWaypoints
(
int
uas
=
0
);
/** @brief Update waypoint */
void
updateWaypoint
(
int
uas
,
Waypoint
*
wp
);
void
drawBorderCamAtMap
(
bool
status
);
void
drawBorderCamAtMap
(
bool
status
);
/** @brief Bring up dialog to go to a specific location */
/** @brief Bring up dialog to go to a specific location */
void
goTo
();
void
goTo
();
...
@@ -105,12 +115,12 @@ protected:
...
@@ -105,12 +115,12 @@ protected:
QMenu
*
mapMenu
;
QMenu
*
mapMenu
;
QPushButton
*
mapButton
;
QPushButton
*
mapButton
;
qmapcontrol
::
MapControl
*
mc
;
///< QMapControl widget
qmapcontrol
::
MapControl
*
mc
;
///< QMapControl widget
qmapcontrol
::
MapAdapter
*
mapadapter
;
///< Adapter to load the map data
qmapcontrol
::
MapAdapter
*
mapadapter
;
///< Adapter to load the map data
qmapcontrol
::
Layer
*
l
;
///< Current map layer (background)
qmapcontrol
::
Layer
*
l
;
///< Current map layer (background)
qmapcontrol
::
Layer
*
overlay
;
///< Street overlay (foreground)
qmapcontrol
::
Layer
*
overlay
;
///< Street overlay (foreground)
qmapcontrol
::
Layer
*
tracks
;
///< Layer for UAV tracks
qmapcontrol
::
Layer
*
tracks
;
///< Layer for UAV tracks
qmapcontrol
::
GeometryLayer
*
geomLayer
;
///< Layer for waypoints
qmapcontrol
::
GeometryLayer
*
geomLayer
;
///< Layer for waypoints
//only for experiment
//only for experiment
qmapcontrol
::
GeometryLayer
*
camLayer
;
///< Layer for camera indicator
qmapcontrol
::
GeometryLayer
*
camLayer
;
///< Layer for camera indicator
...
@@ -124,6 +134,9 @@ protected:
...
@@ -124,6 +134,9 @@ protected:
QMap
<
int
,
qmapcontrol
::
Point
*>
uasIcons
;
QMap
<
int
,
qmapcontrol
::
Point
*>
uasIcons
;
QMap
<
int
,
qmapcontrol
::
LineString
*>
uasTrails
;
QMap
<
int
,
qmapcontrol
::
LineString
*>
uasTrails
;
QMap
<
int
,
QPen
*>
mavPens
;
//QMap<int, QList<qmapcontrol::Point*> > mavWps;
//QMap<int, qmapcontrol::LineString*> waypointPaths;
UASInterface
*
mav
;
UASInterface
*
mav
;
quint64
lastUpdate
;
quint64
lastUpdate
;
...
@@ -135,21 +148,24 @@ protected:
...
@@ -135,21 +148,24 @@ protected:
void
createPathButtonClicked
(
bool
checked
);
void
createPathButtonClicked
(
bool
checked
);
void
createWaypointGraphAtMap
(
const
QPointF
coordinate
);
/** @brief Create the graphic representation of the waypoint */
void
createWaypointGraphAtMap
(
int
id
,
const
QPointF
coordinate
);
void
mapproviderSelected
(
QAction
*
action
);
void
mapproviderSelected
(
QAction
*
action
);
signals:
signals:
//void movePoint(QPointF newCoord);
//void movePoint(QPointF newCoord);
void
captureMapCoordinateClick
(
const
QPointF
coordinate
);
//ROCA
//void captureMapCoordinateClick(const QPointF coordinate); //ROCA
void
createGlobalWP
(
bool
value
,
QPointF
centerCoordinate
);
//void createGlobalWP(bool value, QPointF centerCoordinate);
void
waypointCreated
(
Waypoint
*
wp
);
void
sendGeometryEndDrag
(
const
QPointF
coordinate
,
const
int
index
);
void
sendGeometryEndDrag
(
const
QPointF
coordinate
,
const
int
index
);
private:
private:
Ui
::
MapWidget
*
m_ui
;
Ui
::
MapWidget
*
m_ui
;
QList
<
qmapcontrol
::
Point
*>
wps
;
QList
<
qmapcontrol
::
Point
*>
wps
;
QList
<
Waypoint2DIcon
*>
wpIcons
;
qmapcontrol
::
LineString
*
waypointPath
;
qmapcontrol
::
LineString
*
waypointPath
;
QHash
<
QString
,
qmapcontrol
::
Point
*>
wpIndex
;
//
QHash <QString, qmapcontrol::Point*> wpIndex;
QPen
*
pointPen
;
QPen
*
pointPen
;
int
wpExists
(
const
QPointF
coordinate
);
int
wpExists
(
const
QPointF
coordinate
);
bool
waypointIsDrag
;
bool
waypointIsDrag
;
...
...
src/ui/QGCMAVLinkLogPlayer.cc
View file @
e9637d5a
...
@@ -319,7 +319,7 @@ void QGCMAVLinkLogPlayer::logLoop()
...
@@ -319,7 +319,7 @@ void QGCMAVLinkLogPlayer::logLoop()
//qDebug() << "nextExecutionTime:" << nextExecutionTime << "QGC START TIME:" << currentStartTime << "LOG START TIME:" << startTime;
//qDebug() << "nextExecutionTime:" << nextExecutionTime << "QGC START TIME:" << currentStartTime << "LOG START TIME:" << startTime;
if
(
nextExecutionTime
<
5
)
if
(
nextExecutionTime
<
2
)
{
{
logLoop
();
logLoop
();
}
}
...
...
src/ui/WaypointList.cc
View file @
e9637d5a
...
@@ -127,11 +127,11 @@ void WaypointList::setUAS(UASInterface* uas)
...
@@ -127,11 +127,11 @@ void WaypointList::setUAS(UASInterface* uas)
connect
(
uas
,
SIGNAL
(
localPositionChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updatePosition
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
connect
(
uas
,
SIGNAL
(
localPositionChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updatePosition
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
connect
(
uas
,
SIGNAL
(
attitudeChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateAttitude
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
connect
(
uas
,
SIGNAL
(
attitudeChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateAttitude
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
connect
(
&
uas
->
getWaypointManager
(),
SIGNAL
(
updateStatusString
(
const
QString
&
)),
this
,
SLOT
(
updateStatusLabel
(
const
QString
&
)));
connect
(
uas
->
getWaypointManager
(),
SIGNAL
(
updateStatusString
(
const
QString
&
)),
this
,
SLOT
(
updateStatusLabel
(
const
QString
&
)));
connect
(
&
uas
->
getWaypointManager
(),
SIGNAL
(
waypointListChanged
(
void
)),
this
,
SLOT
(
waypointListChanged
(
void
)));
connect
(
uas
->
getWaypointManager
(),
SIGNAL
(
waypointListChanged
(
void
)),
this
,
SLOT
(
waypointListChanged
(
void
)));
connect
(
&
uas
->
getWaypointManager
(),
SIGNAL
(
currentWaypointChanged
(
quint16
)),
this
,
SLOT
(
currentWaypointChanged
(
quint16
)));
connect
(
uas
->
getWaypointManager
(),
SIGNAL
(
currentWaypointChanged
(
quint16
)),
this
,
SLOT
(
currentWaypointChanged
(
quint16
)));
connect
(
&
uas
->
getWaypointManager
(),
SIGNAL
(
loadWPFile
()),
this
,
SLOT
(
setIsLoadFileWP
()));
connect
(
uas
->
getWaypointManager
(),
SIGNAL
(
loadWPFile
()),
this
,
SLOT
(
setIsLoadFileWP
()));
connect
(
&
uas
->
getWaypointManager
(),
SIGNAL
(
readGlobalWPFromUAS
(
bool
)),
this
,
SLOT
(
setIsReadGlobalWP
(
bool
)));
connect
(
uas
->
getWaypointManager
(),
SIGNAL
(
readGlobalWPFromUAS
(
bool
)),
this
,
SLOT
(
setIsReadGlobalWP
(
bool
)));
}
}
}
}
...
@@ -141,7 +141,7 @@ void WaypointList::saveWaypoints()
...
@@ -141,7 +141,7 @@ void WaypointList::saveWaypoints()
if
(
uas
)
if
(
uas
)
{
{
QString
fileName
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"Save File"
),
"./waypoints.txt"
,
tr
(
"Waypoint File (*.txt)"
));
QString
fileName
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"Save File"
),
"./waypoints.txt"
,
tr
(
"Waypoint File (*.txt)"
));
uas
->
getWaypointManager
()
.
saveWaypoints
(
fileName
);
uas
->
getWaypointManager
()
->
saveWaypoints
(
fileName
);
}
}
}
}
...
@@ -152,7 +152,7 @@ void WaypointList::loadWaypoints()
...
@@ -152,7 +152,7 @@ void WaypointList::loadWaypoints()
QString
fileName
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Load File"
),
"."
,
tr
(
"Waypoint File (*.txt)"
));
QString
fileName
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Load File"
),
"."
,
tr
(
"Waypoint File (*.txt)"
));
uas
->
getWaypointManager
()
.
loadWaypoints
(
fileName
);
uas
->
getWaypointManager
()
->
loadWaypoints
(
fileName
);
}
}
}
}
...
@@ -160,7 +160,7 @@ void WaypointList::transmit()
...
@@ -160,7 +160,7 @@ void WaypointList::transmit()
{
{
if
(
uas
)
if
(
uas
)
{
{
uas
->
getWaypointManager
()
.
writeWaypoints
();
uas
->
getWaypointManager
()
->
writeWaypoints
();
}
}
}
}
...
@@ -168,7 +168,7 @@ void WaypointList::read()
...
@@ -168,7 +168,7 @@ void WaypointList::read()
{
{
if
(
uas
)
if
(
uas
)
{
{
uas
->
getWaypointManager
()
.
readWaypoints
();
uas
->
getWaypointManager
()
->
readWaypoints
();
}
}
}
}
...
@@ -178,17 +178,17 @@ void WaypointList::add()
...
@@ -178,17 +178,17 @@ void WaypointList::add()
{
{
// if(isGlobalWP)
// if(isGlobalWP)
// {
// {
// const QVector<Waypoint *> &waypoints = uas->getWaypointManager()
.
getWaypointList();
// const QVector<Waypoint *> &waypoints = uas->getWaypointManager()
->
getWaypointList();
// if (waypoints.size() > 0)
// if (waypoints.size() > 0)
// {
// {
// Waypoint *last = waypoints.at(waypoints.size()-1);
// Waypoint *last = waypoints.at(waypoints.size()-1);
// Waypoint *wp = new Waypoint(0, centerMapCoordinate.x(), centerMapCoordinate.y(), last->getZ(), last->getYaw(), last->getAutoContinue(), false, last->getOrbit(), last->getHoldTime());
// Waypoint *wp = new Waypoint(0, centerMapCoordinate.x(), centerMapCoordinate.y(), last->getZ(), last->getYaw(), last->getAutoContinue(), false, last->getOrbit(), last->getHoldTime());
// uas->getWaypointManager()
.
addWaypoint(wp);
// uas->getWaypointManager()
->
addWaypoint(wp);
// }
// }
// else
// else
// {
// {
// Waypoint *wp = new Waypoint(0, centerMapCoordinate.x(), centerMapCoordinate.y(), -0.8, 0.0, true, true, 0.15, 2000);
// Waypoint *wp = new Waypoint(0, centerMapCoordinate.x(), centerMapCoordinate.y(), -0.8, 0.0, true, true, 0.15, 2000);
// uas->getWaypointManager()
.
addWaypoint(wp);
// uas->getWaypointManager()
->
addWaypoint(wp);
// }
// }
//
//
// emit createWaypointAtMap(centerMapCoordinate);
// emit createWaypointAtMap(centerMapCoordinate);
...
@@ -196,7 +196,7 @@ void WaypointList::add()
...
@@ -196,7 +196,7 @@ void WaypointList::add()
// else
// else
{
{
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
.
getWaypointList
();
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
->
getWaypointList
();
Waypoint
*
wp
;
Waypoint
*
wp
;
...
@@ -206,13 +206,13 @@ void WaypointList::add()
...
@@ -206,13 +206,13 @@ void WaypointList::add()
Waypoint
*
last
=
waypoints
.
at
(
waypoints
.
size
()
-
1
);
Waypoint
*
last
=
waypoints
.
at
(
waypoints
.
size
()
-
1
);
wp
=
new
Waypoint
(
0
,
last
->
getX
(),
last
->
getY
(),
last
->
getZ
(),
last
->
getYaw
(),
last
->
getAutoContinue
(),
false
,
last
->
getOrbit
(),
wp
=
new
Waypoint
(
0
,
last
->
getX
(),
last
->
getY
(),
last
->
getZ
(),
last
->
getYaw
(),
last
->
getAutoContinue
(),
false
,
last
->
getOrbit
(),
last
->
getHoldTime
(),
last
->
getFrame
(),
last
->
getAction
());
last
->
getHoldTime
(),
last
->
getFrame
(),
last
->
getAction
());
uas
->
getWaypointManager
()
.
addWaypoint
(
wp
);
uas
->
getWaypointManager
()
->
addWaypoint
(
wp
);
}
}
else
else
{
{
// Create global frame waypoint per default
// Create global frame waypoint per default
wp
=
new
Waypoint
(
0
,
uas
->
getLongitude
(),
uas
->
getLatitude
(),
uas
->
getAltitude
(),
0.0
,
true
,
true
,
0.15
,
0
,
MAV_FRAME_GLOBAL
,
MAV_ACTION_NAVIGATE
);
wp
=
new
Waypoint
(
0
,
uas
->
getLongitude
(),
uas
->
getLatitude
(),
uas
->
getAltitude
(),
0.0
,
true
,
true
,
0.15
,
0
,
MAV_FRAME_GLOBAL
,
MAV_ACTION_NAVIGATE
);
uas
->
getWaypointManager
()
.
addWaypoint
(
wp
);
uas
->
getWaypointManager
()
->
addWaypoint
(
wp
);
}
}
if
(
wp
->
getFrame
()
==
MAV_FRAME_GLOBAL
)
if
(
wp
->
getFrame
()
==
MAV_FRAME_GLOBAL
)
{
{
...
@@ -234,17 +234,17 @@ void WaypointList::addCurrentPositonWaypoint()
...
@@ -234,17 +234,17 @@ void WaypointList::addCurrentPositonWaypoint()
//}
//}
//else
//else
{
{
const QVector<Waypoint *> &waypoints = uas->getWaypointManager()
.
getWaypointList();
const QVector<Waypoint *> &waypoints = uas->getWaypointManager()
->
getWaypointList();
if (waypoints.size() > 0)
if (waypoints.size() > 0)
{
{
Waypoint *last = waypoints.at(waypoints.size()-1);
Waypoint *last = waypoints.at(waypoints.size()-1);
Waypoint *wp = new Waypoint(0, (qRound(mavX*100))/100., (qRound(mavY*100))/100., (qRound(mavZ*100))/100., (qRound(mavYaw*100))/100., last->getAutoContinue(), false, last->getOrbit(), last->getHoldTime());
Waypoint *wp = new Waypoint(0, (qRound(mavX*100))/100., (qRound(mavY*100))/100., (qRound(mavZ*100))/100., (qRound(mavYaw*100))/100., last->getAutoContinue(), false, last->getOrbit(), last->getHoldTime());
uas->getWaypointManager()
.
addWaypoint(wp);
uas->getWaypointManager()
->
addWaypoint(wp);
}
}
else
else
{
{
Waypoint *wp = new Waypoint(0, (qRound(mavX*100))/100., (qRound(mavY*100))/100., (qRound(mavZ*100))/100., (qRound(mavYaw*100))/100., true, true, 0.15, 2000);
Waypoint *wp = new Waypoint(0, (qRound(mavX*100))/100., (qRound(mavY*100))/100., (qRound(mavZ*100))/100., (qRound(mavYaw*100))/100., true, true, 0.15, 2000);
uas->getWaypointManager()
.
addWaypoint(wp);
uas->getWaypointManager()
->
addWaypoint(wp);
}
}
//isLocalWP = true;
//isLocalWP = true;
...
@@ -264,7 +264,7 @@ void WaypointList::changeCurrentWaypoint(quint16 seq)
...
@@ -264,7 +264,7 @@ void WaypointList::changeCurrentWaypoint(quint16 seq)
{
{
if
(
uas
)
if
(
uas
)
{
{
uas
->
getWaypointManager
()
.
setCurrentWaypoint
(
seq
);
uas
->
getWaypointManager
()
->
setCurrentWaypoint
(
seq
);
}
}
}
}
...
@@ -272,7 +272,7 @@ void WaypointList::currentWaypointChanged(quint16 seq)
...
@@ -272,7 +272,7 @@ void WaypointList::currentWaypointChanged(quint16 seq)
{
{
if
(
uas
)
if
(
uas
)
{
{
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
.
getWaypointList
();
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
->
getWaypointList
();
if
(
seq
<
waypoints
.
size
())
if
(
seq
<
waypoints
.
size
())
{
{
...
@@ -297,124 +297,125 @@ void WaypointList::waypointListChanged()
...
@@ -297,124 +297,125 @@ void WaypointList::waypointListChanged()
{
{
if
(
uas
)
if
(
uas
)
{
{
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
().
getWaypointList
();
// Prevent updates to prevent visual flicker
this
->
setUpdatesEnabled
(
false
);
// For Global Waypoints
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
->
getWaypointList
();
//if(isGlobalWP)
//{
// For Global Waypoints
//isLocalWP = false;
//if(isGlobalWP)
//// first remove all views of non existing waypoints
//{
//if (!wpGlobalViews.empty())
//isLocalWP = false;
//{
//// first remove all views of non existing waypoints
//QMapIterator<Waypoint*,WaypointGlobalView*> viewIt(wpGlobalViews);
//if (!wpGlobalViews.empty())
//viewIt.toFront();
//{
//while(viewIt.hasNext())
//QMapIterator<Waypoint*,WaypointGlobalView*> viewIt(wpGlobalViews);
//{
//viewIt.toFront();
//viewIt.next();
//while(viewIt.hasNext())
//Waypoint *cur = viewIt.key();
//{
//int i;
//viewIt.next();
//for (i = 0; i < waypoints.size(); i++)
//Waypoint *cur = viewIt.key();
//{
//int i;
//if (waypoints[i] == cur)
//for (i = 0; i < waypoints.size(); i++)
//{
//{
//break;
//if (waypoints[i] == cur)
//}
//{
//}
//break;
//if (i == waypoints.size())
//}
//{
//}
//WaypointGlobalView* widget = wpGlobalViews.find(cur).value();
//if (i == waypoints.size())
//widget->hide();
//{
//listLayout->removeWidget(widget);
//WaypointGlobalView* widget = wpGlobalViews.find(cur).value();
//wpGlobalViews.remove(cur);
//widget->hide();
//}
//listLayout->removeWidget(widget);
//}
//wpGlobalViews.remove(cur);
//}
//}
//}
//// then add/update the views for each waypoint in the list
//}
//for(int i = 0; i < waypoints.size(); i++)
//{
//// then add/update the views for each waypoint in the list
//Waypoint *wp = waypoints[i];
//for(int i = 0; i < waypoints.size(); i++)
//if (!wpGlobalViews.contains(wp))
//{
//{
//Waypoint *wp = waypoints[i];
//WaypointGlobalView* wpview = new WaypointGlobalView(wp, this);
//if (!wpGlobalViews.contains(wp))
//wpGlobalViews.insert(wp, wpview);
//{
//connect(wpview, SIGNAL(removeWaypoint(Waypoint*)), this, SLOT(removeWaypoint(Waypoint*)));
//WaypointGlobalView* wpview = new WaypointGlobalView(wp, this);
//connect(wpview, SIGNAL(changePositionWP(Waypoint*)), this, SLOT(changeWPPositionBySpinBox(Waypoint*)));
//wpGlobalViews.insert(wp, wpview);
//// connect(wpview, SIGNAL(moveDownWaypoint(Waypoint*)), this, SLOT(moveDown(Waypoint*)));
//connect(wpview, SIGNAL(removeWaypoint(Waypoint*)), this, SLOT(removeWaypoint(Waypoint*)));
//// connect(wpview, SIGNAL(moveUpWaypoint(Waypoint*)), this, SLOT(moveUp(Waypoint*)));
//connect(wpview, SIGNAL(changePositionWP(Waypoint*)), this, SLOT(changeWPPositionBySpinBox(Waypoint*)));
//// connect(wpview, SIGNAL(changePositionWP(Waypoint*)), this, SLOT(waypointGlobalPositionChanged(Waypoint*)));
//// connect(wpview, SIGNAL(moveDownWaypoint(Waypoint*)), this, SLOT(moveDown(Waypoint*)));
//// connect(wpview, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointChanged(quint16)));
//// connect(wpview, SIGNAL(moveUpWaypoint(Waypoint*)), this, SLOT(moveUp(Waypoint*)));
//// connect(wpview, SIGNAL(changeCurrentWaypoint(quint16)), this, SLOT(changeCurrentWaypoint(quint16)));
//// connect(wpview, SIGNAL(changePositionWP(Waypoint*)), this, SLOT(waypointGlobalPositionChanged(Waypoint*)));
//}
//// connect(wpview, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointChanged(quint16)));
//WaypointGlobalView *wpgv = wpGlobalViews.value(wp);
//// connect(wpview, SIGNAL(changeCurrentWaypoint(quint16)), this, SLOT(changeCurrentWaypoint(quint16)));
//wpgv->updateValues();
//}
//listLayout->addWidget(wpgv);
//WaypointGlobalView *wpgv = wpGlobalViews.value(wp);
//}
//wpgv->updateValues();
//listLayout->addWidget(wpgv);
//}
//}
//else
//}
//else
//{
// for local Waypoints
// first remove all views of non existing waypoints
if
(
!
wpViews
.
empty
())
{
{
// for local Waypoints
QMapIterator
<
Waypoint
*
,
WaypointView
*>
viewIt
(
wpViews
);
// first remove all views of non existing waypoints
viewIt
.
toFront
();
if
(
!
wpViews
.
empty
())
while
(
viewIt
.
hasNext
())
{
{
QMapIterator
<
Waypoint
*
,
WaypointView
*>
viewIt
(
wpViews
);
viewIt
.
next
();
viewIt
.
toFront
();
Waypoint
*
cur
=
viewIt
.
key
();
while
(
viewIt
.
hasNext
())
int
i
;
for
(
i
=
0
;
i
<
waypoints
.
size
();
i
++
)
{
{
viewIt
.
next
();
if
(
waypoints
[
i
]
==
cur
)
Waypoint
*
cur
=
viewIt
.
key
();
int
i
;
for
(
i
=
0
;
i
<
waypoints
.
size
();
i
++
)
{
{
if
(
waypoints
[
i
]
==
cur
)
break
;
{
break
;
}
}
if
(
i
==
waypoints
.
size
())
{
WaypointView
*
widget
=
wpViews
.
find
(
cur
).
value
();
widget
->
hide
();
listLayout
->
removeWidget
(
widget
);
wpViews
.
remove
(
cur
);
}
}
}
}
if
(
i
==
waypoints
.
size
())
{
WaypointView
*
widget
=
wpViews
.
find
(
cur
).
value
();
widget
->
hide
();
listLayout
->
removeWidget
(
widget
);
wpViews
.
remove
(
cur
);
}
}
}
}
// then add/update the views for each waypoint in the list
// then add/update the views for each waypoint in the list
for
(
int
i
=
0
;
i
<
waypoints
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
waypoints
.
size
();
i
++
)
{
Waypoint
*
wp
=
waypoints
[
i
];
if
(
!
wpViews
.
contains
(
wp
))
{
{
Waypoint
*
wp
=
waypoints
[
i
];
WaypointView
*
wpview
=
new
WaypointView
(
wp
,
this
);
if
(
!
wpViews
.
contains
(
wp
))
wpViews
.
insert
(
wp
,
wpview
);
{
connect
(
wpview
,
SIGNAL
(
moveDownWaypoint
(
Waypoint
*
)),
this
,
SLOT
(
moveDown
(
Waypoint
*
)));
WaypointView
*
wpview
=
new
WaypointView
(
wp
,
this
);
connect
(
wpview
,
SIGNAL
(
moveUpWaypoint
(
Waypoint
*
)),
this
,
SLOT
(
moveUp
(
Waypoint
*
)));
wpViews
.
insert
(
wp
,
wpview
);
connect
(
wpview
,
SIGNAL
(
removeWaypoint
(
Waypoint
*
)),
this
,
SLOT
(
removeWaypoint
(
Waypoint
*
)));
connect
(
wpview
,
SIGNAL
(
moveDownWaypoint
(
Waypoint
*
)),
this
,
SLOT
(
moveDown
(
Waypoint
*
)));
connect
(
wpview
,
SIGNAL
(
currentWaypointChanged
(
quint16
)),
this
,
SLOT
(
currentWaypointChanged
(
quint16
)));
connect
(
wpview
,
SIGNAL
(
moveUpWaypoint
(
Waypoint
*
)),
this
,
SLOT
(
moveUp
(
Waypoint
*
)));
connect
(
wpview
,
SIGNAL
(
changeCurrentWaypoint
(
quint16
)),
this
,
SLOT
(
changeCurrentWaypoint
(
quint16
)));
connect
(
wpview
,
SIGNAL
(
removeWaypoint
(
Waypoint
*
)),
this
,
SLOT
(
removeWaypoint
(
Waypoint
*
)));
}
connect
(
wpview
,
SIGNAL
(
currentWaypointChanged
(
quint16
)),
this
,
SLOT
(
currentWaypointChanged
(
quint16
)));
connect
(
wpview
,
SIGNAL
(
changeCurrentWaypoint
(
quint16
)),
this
,
SLOT
(
changeCurrentWaypoint
(
quint16
)));
}
WaypointView
*
wpv
=
wpViews
.
value
(
wp
);
WaypointView
*
wpv
=
wpViews
.
value
(
wp
);
wpv
->
updateValues
();
// update the values of the ui elements in the view
wpv
->
updateValues
();
// update the values of the ui elements in the view
listLayout
->
addWidget
(
wpv
);
listLayout
->
addWidget
(
wpv
);
}
}
}
this
->
setUpdatesEnabled
(
true
);
loadFileGlobalWP
=
false
;
}
}
loadFileGlobalWP
=
false
;
//}
}
}
void
WaypointList
::
moveUp
(
Waypoint
*
wp
)
void
WaypointList
::
moveUp
(
Waypoint
*
wp
)
{
{
if
(
uas
)
if
(
uas
)
{
{
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
.
getWaypointList
();
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
->
getWaypointList
();
//get the current position of wp in the local storage
//get the current position of wp in the local storage
int
i
;
int
i
;
...
@@ -427,7 +428,7 @@ void WaypointList::moveUp(Waypoint* wp)
...
@@ -427,7 +428,7 @@ void WaypointList::moveUp(Waypoint* wp)
// if wp was found and its not the first entry, move it
// if wp was found and its not the first entry, move it
if
(
i
<
waypoints
.
size
()
&&
i
>
0
)
if
(
i
<
waypoints
.
size
()
&&
i
>
0
)
{
{
uas
->
getWaypointManager
()
.
moveWaypoint
(
i
,
i
-
1
);
uas
->
getWaypointManager
()
->
moveWaypoint
(
i
,
i
-
1
);
}
}
}
}
}
}
...
@@ -436,7 +437,7 @@ void WaypointList::moveDown(Waypoint* wp)
...
@@ -436,7 +437,7 @@ void WaypointList::moveDown(Waypoint* wp)
{
{
if
(
uas
)
if
(
uas
)
{
{
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
.
getWaypointList
();
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
->
getWaypointList
();
//get the current position of wp in the local storage
//get the current position of wp in the local storage
int
i
;
int
i
;
...
@@ -449,7 +450,7 @@ void WaypointList::moveDown(Waypoint* wp)
...
@@ -449,7 +450,7 @@ void WaypointList::moveDown(Waypoint* wp)
// if wp was found and its not the last entry, move it
// if wp was found and its not the last entry, move it
if
(
i
<
waypoints
.
size
()
-
1
)
if
(
i
<
waypoints
.
size
()
-
1
)
{
{
uas
->
getWaypointManager
()
.
moveWaypoint
(
i
,
i
+
1
);
uas
->
getWaypointManager
()
->
moveWaypoint
(
i
,
i
+
1
);
}
}
}
}
}
}
...
@@ -458,7 +459,7 @@ void WaypointList::removeWaypoint(Waypoint* wp)
...
@@ -458,7 +459,7 @@ void WaypointList::removeWaypoint(Waypoint* wp)
{
{
if
(
uas
)
if
(
uas
)
{
{
uas
->
getWaypointManager
()
.
removeWaypoint
(
wp
->
getId
());
uas
->
getWaypointManager
()
->
removeWaypoint
(
wp
->
getId
());
}
}
}
}
...
@@ -482,7 +483,7 @@ void WaypointList::on_clearWPListButton_clicked()
...
@@ -482,7 +483,7 @@ void WaypointList::on_clearWPListButton_clicked()
if
(
uas
)
if
(
uas
)
{
{
emit
clearPathclicked
();
emit
clearPathclicked
();
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
.
getWaypointList
();
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
->
getWaypointList
();
while
(
!
waypoints
.
isEmpty
())
//for(int i = 0; i <= waypoints.size(); i++)
while
(
!
waypoints
.
isEmpty
())
//for(int i = 0; i <= waypoints.size(); i++)
{
{
WaypointView
*
widget
=
wpViews
.
find
(
waypoints
[
0
]).
value
();
WaypointView
*
widget
=
wpViews
.
find
(
waypoints
[
0
]).
value
();
...
@@ -503,17 +504,17 @@ void WaypointList::addWaypointMouse(QPointF coordinate)
...
@@ -503,17 +504,17 @@ void WaypointList::addWaypointMouse(QPointF coordinate)
{
{
if
(
uas
)
if
(
uas
)
{
{
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
.
getWaypointList
();
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
->
getWaypointList
();
if
(
waypoints
.
size
()
>
0
)
if
(
waypoints
.
size
()
>
0
)
{
{
Waypoint
*
last
=
waypoints
.
at
(
waypoints
.
size
()
-
1
);
Waypoint
*
last
=
waypoints
.
at
(
waypoints
.
size
()
-
1
);
Waypoint
*
wp
=
new
Waypoint
(
0
,
coordinate
.
x
(),
coordinate
.
y
(),
last
->
getZ
(),
last
->
getYaw
(),
last
->
getAutoContinue
(),
false
,
last
->
getOrbit
(),
last
->
getHoldTime
());
Waypoint
*
wp
=
new
Waypoint
(
0
,
coordinate
.
x
(),
coordinate
.
y
(),
last
->
getZ
(),
last
->
getYaw
(),
last
->
getAutoContinue
(),
false
,
last
->
getOrbit
(),
last
->
getHoldTime
());
uas
->
getWaypointManager
()
.
addWaypoint
(
wp
);
uas
->
getWaypointManager
()
->
addWaypoint
(
wp
);
}
}
else
else
{
{
Waypoint
*
wp
=
new
Waypoint
(
0
,
coordinate
.
x
(),
coordinate
.
y
(),
-
0.8
,
0.0
,
true
,
true
,
0.15
,
2000
);
Waypoint
*
wp
=
new
Waypoint
(
0
,
coordinate
.
x
(),
coordinate
.
y
(),
-
0.8
,
0.0
,
true
,
true
,
0.15
,
2000
);
uas
->
getWaypointManager
()
.
addWaypoint
(
wp
);
uas
->
getWaypointManager
()
->
addWaypoint
(
wp
);
}
}
...
@@ -527,7 +528,7 @@ void WaypointList::waypointGlobalChanged(QPointF coordinate, int indexWP)
...
@@ -527,7 +528,7 @@ void WaypointList::waypointGlobalChanged(QPointF coordinate, int indexWP)
{
{
if
(
uas
)
if
(
uas
)
{
{
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
.
getWaypointList
();
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
->
getWaypointList
();
if
(
waypoints
.
size
()
>
0
)
if
(
waypoints
.
size
()
>
0
)
{
{
Waypoint
*
temp
=
waypoints
.
at
(
indexWP
);
Waypoint
*
temp
=
waypoints
.
at
(
indexWP
);
...
@@ -560,7 +561,7 @@ void WaypointList::clearWPWidget()
...
@@ -560,7 +561,7 @@ void WaypointList::clearWPWidget()
{
{
if
(
uas
)
if
(
uas
)
{
{
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
.
getWaypointList
();
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
()
->
getWaypointList
();
while
(
!
waypoints
.
isEmpty
())
//for(int i = 0; i <= waypoints.size(); i++)
while
(
!
waypoints
.
isEmpty
())
//for(int i = 0; i <= waypoints.size(); i++)
{
{
WaypointView
*
widget
=
wpViews
.
find
(
waypoints
[
0
]).
value
();
WaypointView
*
widget
=
wpViews
.
find
(
waypoints
[
0
]).
value
();
...
...
src/ui/WaypointView.ui
View file @
e9637d5a
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
<x>
0
</x>
<x>
0
</x>
<y>
0
</y>
<y>
0
</y>
<width>
1389
</width>
<width>
1389
</width>
<height>
3
3
</height>
<height>
3
9
</height>
</rect>
</rect>
</property>
</property>
<property
name=
"sizePolicy"
>
<property
name=
"sizePolicy"
>
...
@@ -375,7 +375,7 @@ QProgressBar::chunk#thrustBar {
...
@@ -375,7 +375,7 @@ QProgressBar::chunk#thrustBar {
<string>
m
</string>
<string>
m
</string>
</property>
</property>
<property
name=
"decimals"
>
<property
name=
"decimals"
>
<number>
7
</number>
<number>
2
</number>
</property>
</property>
<property
name=
"minimum"
>
<property
name=
"minimum"
>
<double>
-100000.000000000000000
</double>
<double>
-100000.000000000000000
</double>
...
...
src/ui/linechart/LinechartWidget.cc
View file @
e9637d5a
...
@@ -483,7 +483,7 @@ void LinechartWidget::startLogging()
...
@@ -483,7 +483,7 @@ void LinechartWidget::startLogging()
fileName
.
append
(
".csv"
);
fileName
.
append
(
".csv"
);
}
}
while
(
!
(
fileName
.
endsWith
(
".txt"
)
||
fileName
.
endsWith
(
".csv"
))
&&
!
abort
)
while
(
!
(
fileName
.
endsWith
(
".txt"
)
||
fileName
.
endsWith
(
".csv"
))
&&
!
abort
&&
fileName
!=
""
)
{
{
QMessageBox
msgBox
;
QMessageBox
msgBox
;
msgBox
.
setIcon
(
QMessageBox
::
Critical
);
msgBox
.
setIcon
(
QMessageBox
::
Critical
);
...
...
src/ui/map/MAV2DIcon.cc
View file @
e9637d5a
...
@@ -46,50 +46,50 @@ void MAV2DIcon::setYaw(float yaw)
...
@@ -46,50 +46,50 @@ void MAV2DIcon::setYaw(float yaw)
void
MAV2DIcon
::
drawIcon
(
QPen
*
pen
)
void
MAV2DIcon
::
drawIcon
(
QPen
*
pen
)
{
{
//
mypixmap = new QPixmap(radius+1, radius+1);
mypixmap
=
new
QPixmap
(
radius
+
1
,
radius
+
1
);
//
mypixmap->fill(Qt::transparent);
mypixmap
->
fill
(
Qt
::
transparent
);
//
QPainter painter(mypixmap);
QPainter
painter
(
mypixmap
);
//
// DRAW WAYPOINT
// DRAW WAYPOINT
//
QPointF p(radius/2, radius/2);
QPointF
p
(
radius
/
2
,
radius
/
2
);
//
float waypointSize = radius;
float
waypointSize
=
radius
;
//
QPolygonF poly(4);
QPolygonF
poly
(
4
);
//
// Top point
// Top point
//
poly.replace(0, QPointF(p.x(), p.y()-waypointSize/2.0f));
poly
.
replace
(
0
,
QPointF
(
p
.
x
(),
p
.
y
()
-
waypointSize
/
2.0
f
));
//
// Right point
// Right point
//
poly.replace(1, QPointF(p.x()+waypointSize/2.0f, p.y()));
poly
.
replace
(
1
,
QPointF
(
p
.
x
()
+
waypointSize
/
2.0
f
,
p
.
y
()));
//
// Bottom point
// Bottom point
//
poly.replace(2, QPointF(p.x(), p.y() + waypointSize/2.0f));
poly
.
replace
(
2
,
QPointF
(
p
.
x
(),
p
.
y
()
+
waypointSize
/
2.0
f
));
//
poly.replace(3, QPointF(p.x() - waypointSize/2.0f, p.y()));
poly
.
replace
(
3
,
QPointF
(
p
.
x
()
-
waypointSize
/
2.0
f
,
p
.
y
()));
//// // Select color based on if this is the current waypoint
// // Select color based on if this is the current waypoint
//// if (list.at(i)->getCurrent())
// if (list.at(i)->getCurrent())
//// {
//// color = QGC::colorCyan;//uas->getColor();
//// pen.setWidthF(refLineWidthToPen(0.8f));
//// }
//// else
//// {
//// color = uas->getColor();
//// pen.setWidthF(refLineWidthToPen(0.4f));
//// }
// //pen.setColor(color);
// if (pen)
// {
// {
//
pen->setWidthF(2
);
//
color = QGC::colorCyan;//uas->getColor(
);
// p
ainter.setPen(*pen
);
// p
en.setWidthF(refLineWidthToPen(0.8f)
);
// }
// }
// else
// else
// {
// {
// QPen pen2(Qt::red);
// color = uas->getColor();
// pen2.setWidth(2);
// pen.setWidthF(refLineWidthToPen(0.4f));
// painter.setPen(pen2);
// }
// }
// painter.setBrush(Qt::NoBrush);
// float rad = (waypointSize/2.0f) * 0.8 * (1/sqrt(2.0f));
//pen.setColor(color);
// painter.drawLine(p.x(), p.y(), p.x()+sin(yaw) * radius, p.y()-cos(yaw) * rad);
if
(
pen
)
// painter.drawPolygon(poly);
{
pen
->
setWidthF
(
2
);
painter
.
setPen
(
*
pen
);
}
else
{
QPen
pen2
(
Qt
::
red
);
pen2
.
setWidth
(
2
);
painter
.
setPen
(
pen2
);
}
painter
.
setBrush
(
Qt
::
NoBrush
);
float
rad
=
(
waypointSize
/
2.0
f
)
*
0.8
*
(
1
/
sqrt
(
2.0
f
));
painter
.
drawLine
(
p
.
x
(),
p
.
y
(),
p
.
x
()
+
sin
(
yaw
)
*
radius
,
p
.
y
()
-
cos
(
yaw
)
*
rad
);
painter
.
drawPolygon
(
poly
);
}
}
src/ui/map3D/Pixhawk3DWidget.cc
View file @
e9637d5a
...
@@ -308,7 +308,7 @@ Pixhawk3DWidget::insertWaypoint(void)
...
@@ -308,7 +308,7 @@ Pixhawk3DWidget::insertWaypoint(void)
if
(
wp
)
if
(
wp
)
{
{
wp
->
setFrame
(
frame
);
wp
->
setFrame
(
frame
);
uas
->
getWaypointManager
()
.
addWaypoint
(
wp
);
uas
->
getWaypointManager
()
->
addWaypoint
(
wp
);
}
}
}
}
}
}
...
@@ -325,7 +325,7 @@ Pixhawk3DWidget::setWaypoint(void)
...
@@ -325,7 +325,7 @@ Pixhawk3DWidget::setWaypoint(void)
if
(
uas
)
if
(
uas
)
{
{
const
QVector
<
Waypoint
*>
waypoints
=
const
QVector
<
Waypoint
*>
waypoints
=
uas
->
getWaypointManager
()
.
getWaypointList
();
uas
->
getWaypointManager
()
->
getWaypointList
();
Waypoint
*
waypoint
=
waypoints
.
at
(
selectedWpIndex
);
Waypoint
*
waypoint
=
waypoints
.
at
(
selectedWpIndex
);
if
(
frame
==
MAV_FRAME_GLOBAL
)
if
(
frame
==
MAV_FRAME_GLOBAL
)
...
@@ -366,7 +366,7 @@ Pixhawk3DWidget::deleteWaypoint(void)
...
@@ -366,7 +366,7 @@ Pixhawk3DWidget::deleteWaypoint(void)
{
{
if
(
uas
)
if
(
uas
)
{
{
uas
->
getWaypointManager
()
.
removeWaypoint
(
selectedWpIndex
);
uas
->
getWaypointManager
()
->
removeWaypoint
(
selectedWpIndex
);
}
}
}
}
...
@@ -377,7 +377,7 @@ Pixhawk3DWidget::setWaypointAltitude(void)
...
@@ -377,7 +377,7 @@ Pixhawk3DWidget::setWaypointAltitude(void)
{
{
bool
ok
;
bool
ok
;
const
QVector
<
Waypoint
*>
waypoints
=
const
QVector
<
Waypoint
*>
waypoints
=
uas
->
getWaypointManager
()
.
getWaypointList
();
uas
->
getWaypointManager
()
->
getWaypointList
();
Waypoint
*
waypoint
=
waypoints
.
at
(
selectedWpIndex
);
Waypoint
*
waypoint
=
waypoints
.
at
(
selectedWpIndex
);
double
altitude
=
waypoint
->
getZ
();
double
altitude
=
waypoint
->
getZ
();
...
@@ -409,10 +409,10 @@ Pixhawk3DWidget::clearAllWaypoints(void)
...
@@ -409,10 +409,10 @@ Pixhawk3DWidget::clearAllWaypoints(void)
if
(
uas
)
if
(
uas
)
{
{
const
QVector
<
Waypoint
*>
waypoints
=
const
QVector
<
Waypoint
*>
waypoints
=
uas
->
getWaypointManager
()
.
getWaypointList
();
uas
->
getWaypointManager
()
->
getWaypointList
();
for
(
int
i
=
waypoints
.
size
()
-
1
;
i
>=
0
;
--
i
)
for
(
int
i
=
waypoints
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
{
uas
->
getWaypointManager
()
.
removeWaypoint
(
i
);
uas
->
getWaypointManager
()
->
removeWaypoint
(
i
);
}
}
}
}
}
}
...
...
src/ui/map3D/WaypointGroupNode.cc
View file @
e9637d5a
...
@@ -78,7 +78,7 @@ WaypointGroupNode::update(MAV_FRAME frame, UASInterface *uas)
...
@@ -78,7 +78,7 @@ WaypointGroupNode::update(MAV_FRAME frame, UASInterface *uas)
removeChild
(
0
,
getNumChildren
());
removeChild
(
0
,
getNumChildren
());
}
}
const
QVector
<
Waypoint
*>&
list
=
uas
->
getWaypointManager
()
.
getWaypointList
();
const
QVector
<
Waypoint
*>&
list
=
uas
->
getWaypointManager
()
->
getWaypointList
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++
)
{
{
...
...
src/ui/uas/UASView.cc
View file @
e9637d5a
...
@@ -83,7 +83,7 @@ UASView::UASView(UASInterface* uas, QWidget *parent) :
...
@@ -83,7 +83,7 @@ UASView::UASView(UASInterface* uas, QWidget *parent) :
connect
(
uas
,
SIGNAL
(
loadChanged
(
UASInterface
*
,
double
)),
this
,
SLOT
(
updateLoad
(
UASInterface
*
,
double
)));
connect
(
uas
,
SIGNAL
(
loadChanged
(
UASInterface
*
,
double
)),
this
,
SLOT
(
updateLoad
(
UASInterface
*
,
double
)));
connect
(
uas
,
SIGNAL
(
heartbeatTimeout
()),
this
,
SLOT
(
heartbeatTimeout
()));
connect
(
uas
,
SIGNAL
(
heartbeatTimeout
()),
this
,
SLOT
(
heartbeatTimeout
()));
connect
(
uas
,
SIGNAL
(
waypointSelected
(
int
,
int
)),
this
,
SLOT
(
selectWaypoint
(
int
,
int
)));
connect
(
uas
,
SIGNAL
(
waypointSelected
(
int
,
int
)),
this
,
SLOT
(
selectWaypoint
(
int
,
int
)));
connect
(
&
(
uas
->
getWaypointManager
()
),
SIGNAL
(
currentWaypointChanged
(
quint16
)),
this
,
SLOT
(
currentWaypointUpdated
(
quint16
)));
connect
(
uas
->
getWaypointManager
(
),
SIGNAL
(
currentWaypointChanged
(
quint16
)),
this
,
SLOT
(
currentWaypointUpdated
(
quint16
)));
connect
(
uas
,
SIGNAL
(
systemTypeSet
(
UASInterface
*
,
uint
)),
this
,
SLOT
(
setSystemType
(
UASInterface
*
,
uint
)));
connect
(
uas
,
SIGNAL
(
systemTypeSet
(
UASInterface
*
,
uint
)),
this
,
SLOT
(
setSystemType
(
UASInterface
*
,
uint
)));
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASStatusChanged
(
UASInterface
*
,
bool
)),
this
,
SLOT
(
updateActiveUAS
(
UASInterface
*
,
bool
)));
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASStatusChanged
(
UASInterface
*
,
bool
)),
this
,
SLOT
(
updateActiveUAS
(
UASInterface
*
,
bool
)));
...
...
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