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
28534a58
Commit
28534a58
authored
Jul 10, 2011
by
lm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added waypoint connecting lines
parent
69229517
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
21 deletions
+122
-21
opmapwidget.h
src/libs/opmapcontrol/src/mapwidget/opmapwidget.h
+1
-0
waypointlineitem.cpp
src/libs/opmapcontrol/src/mapwidget/waypointlineitem.cpp
+39
-1
waypointlineitem.h
src/libs/opmapcontrol/src/mapwidget/waypointlineitem.h
+22
-2
QGCMapWidget.cc
src/ui/map/QGCMapWidget.cc
+60
-18
No files found.
src/libs/opmapcontrol/src/mapwidget/opmapwidget.h
View file @
28534a58
...
...
@@ -40,6 +40,7 @@
#include "uavitem.h"
#include "gpsitem.h"
#include "homeitem.h"
#include "waypointlineitem.h"
#include "mapripper.h"
namespace
mapcontrol
{
...
...
src/libs/opmapcontrol/src/mapwidget/waypointlineitem.cpp
View file @
28534a58
#include "waypointlineitem.h"
WaypointLineItem
::
WaypointLineItem
()
namespace
mapcontrol
{
WaypointLineItem
::
WaypointLineItem
(
WayPointItem
*
wp1
,
WayPointItem
*
wp2
,
QColor
color
,
mapcontrol
::
MapGraphicItem
*
map
)
:
wp1
(
wp1
),
wp2
(
wp2
),
map
(
map
)
{
core
::
Point
localPoint1
=
map
->
FromLatLngToLocal
(
wp1
->
Coord
());
core
::
Point
localPoint2
=
map
->
FromLatLngToLocal
(
wp2
->
Coord
());
QPen
pen
(
color
);
pen
.
setWidth
(
2
);
setPen
(
pen
);
setLine
(
localPoint1
.
X
(),
localPoint1
.
Y
(),
localPoint2
.
X
(),
localPoint2
.
Y
());
// Update line from both waypoints
connect
(
wp1
,
SIGNAL
(
WPValuesChanged
(
WayPointItem
*
)),
this
,
SLOT
(
updateWPValues
(
WayPointItem
*
)));
connect
(
wp2
,
SIGNAL
(
WPValuesChanged
(
WayPointItem
*
)),
this
,
SLOT
(
updateWPValues
(
WayPointItem
*
)));
// Delete line if one of the waypoints get deleted
connect
(
wp1
,
SIGNAL
(
destroyed
()),
this
,
SLOT
(
deleteLater
()));
connect
(
wp2
,
SIGNAL
(
destroyed
()),
this
,
SLOT
(
deleteLater
()));
}
void
WaypointLineItem
::
updateWPValues
(
WayPointItem
*
waypoint
)
{
Q_UNUSED
(
waypoint
);
if
(
!
wp1
||
!
wp2
)
{
this
->
deleteLater
();
}
else
{
core
::
Point
localPoint1
=
map
->
FromLatLngToLocal
(
wp1
->
Coord
());
core
::
Point
localPoint2
=
map
->
FromLatLngToLocal
(
wp2
->
Coord
());
setLine
(
localPoint1
.
X
(),
localPoint1
.
Y
(),
localPoint2
.
X
(),
localPoint2
.
Y
());
}
}
}
src/libs/opmapcontrol/src/mapwidget/waypointlineitem.h
View file @
28534a58
...
...
@@ -2,11 +2,31 @@
#define WAYPOINTLINEITEM_H
#include <QGraphicsLineItem>
#include "opmapcontrol.h"
class
WaypointLineItem
:
public
QGraphicsLineItem
namespace
mapcontrol
{
class
WaypointLineItem
:
public
QObject
,
public
QGraphicsLineItem
{
Q_OBJECT
Q_INTERFACES
(
QGraphicsItem
)
public:
WaypointLineItem
();
WaypointLineItem
(
WayPointItem
*
wp1
,
WayPointItem
*
wp2
,
QColor
color
=
QColor
(
Qt
::
red
),
MapGraphicItem
*
parent
=
0
);
public
slots
:
/**
* @brief Update waypoint values
*
* @param waypoint The waypoint object that just changed
*/
void
updateWPValues
(
WayPointItem
*
waypoint
);
protected:
internals
::
PointLatLng
point1
;
internals
::
PointLatLng
point2
;
WayPointItem
*
wp1
;
WayPointItem
*
wp2
;
MapGraphicItem
*
map
;
///< The map this item is parent of
};
}
#endif // WAYPOINTLINEITEM_H
src/ui/map/QGCMapWidget.cc
View file @
28534a58
...
...
@@ -156,6 +156,8 @@ void QGCMapWidget::storeSettings()
void
QGCMapWidget
::
mouseDoubleClickEvent
(
QMouseEvent
*
event
)
{
OPMapWidget
::
mouseDoubleClickEvent
(
event
);
// FIXME HACK!
currEditMode
=
EDIT_MODE_WAYPOINTS
;
if
(
currEditMode
==
EDIT_MODE_WAYPOINTS
)
{
// If a waypoint manager is available
...
...
@@ -164,8 +166,13 @@ void QGCMapWidget::mouseDoubleClickEvent(QMouseEvent* event)
// Create new waypoint
internals
::
PointLatLng
pos
=
this
->
currentMousePosition
();
Waypoint
*
wp
=
currWPManager
->
createWaypoint
();
// wp->blockSignals(true);
wp
->
setFrame
(
MAV_FRAME_GLOBAL_RELATIVE_ALT
);
wp
->
setLatitude
(
pos
.
Lat
());
wp
->
setLongitude
(
pos
.
Lng
());
wp
->
setAltitude
(
0
);
// wp->blockSignals(false);
// currWPManager->notifyOfChange(wp);
}
}
}
...
...
@@ -199,13 +206,6 @@ void QGCMapWidget::activeUASSet(UASInterface* uas)
if
(
uas
)
{
currWPManager
=
uas
->
getWaypointManager
();
// QColor color = mav->getColor();
// color.setAlphaF(0.9);
// QPen* pen = new QPen(color);
// pen->setWidth(3.0);
// mavPens.insert(mav->getUASID(), pen);
// // FIXME Remove after refactoring
// waypointPath->setPen(pen);
// Delete all waypoints and add waypoint from new system
updateWaypointList
(
uas
->
getUASID
());
...
...
@@ -461,16 +461,25 @@ void QGCMapWidget::updateWaypoint(int uas, Waypoint* wp)
waypointsToIcons
.
insert
(
wp
,
icon
);
iconsToWaypoints
.
insert
(
icon
,
wp
);
// Add line element
qDebug
()
<<
"ADDING LINE"
;
mapcontrol
::
TrailLineItem
*
line
=
new
mapcontrol
::
TrailLineItem
(
internals
::
PointLatLng
(
0.2
,
0.2
),
icon
->
Coord
(),
QBrush
(
Qt
::
red
),
map
);
// Add line element if this is NOT the first waypoint
if
(
wpindex
>
0
)
{
// Get predecessor of this WP
QVector
<
Waypoint
*
>
wps
=
currWPManager
->
getGlobalFrameAndNavTypeWaypointList
();
Waypoint
*
wp1
=
wps
.
at
(
wpindex
-
1
);
mapcontrol
::
WayPointItem
*
prevIcon
=
waypointsToIcons
.
value
(
wp1
,
NULL
);
// If we got a valid graphics item, continue
if
(
prevIcon
)
{
mapcontrol
::
WaypointLineItem
*
line
=
new
mapcontrol
::
WaypointLineItem
(
prevIcon
,
icon
,
Qt
::
red
,
map
);
QGraphicsItemGroup
*
group
=
waypointLines
.
value
(
uas
,
NULL
);
if
(
group
)
{
group
->
addToGroup
(
line
);
qDebug
()
<<
"ADDED LINE!"
;
}
line
->
setVisible
(
true
);
}
}
}
else
{
// Waypoint exists, block it's signals and update it
mapcontrol
::
WayPointItem
*
icon
=
waypointsToIcons
.
value
(
wp
);
...
...
@@ -523,7 +532,8 @@ void QGCMapWidget::updateWaypointList(int uas)
{
// Currently only accept waypoint updates from the UAS in focus
// this has to be changed to accept read-only updates from other systems as well.
if
(
UASManager
::
instance
()
->
getUASForId
(
uas
)
->
getWaypointManager
()
==
currWPManager
)
{
UASInterface
*
uasInstance
=
UASManager
::
instance
()
->
getUASForId
(
uas
);
if
(
uasInstance
->
getWaypointManager
()
==
currWPManager
)
{
qDebug
()
<<
"UPDATING WP LIST"
;
// Get current WP list
// compare to local WP maps and
...
...
@@ -562,6 +572,38 @@ void QGCMapWidget::updateWaypointList(int uas)
// Update / add only if new
if
(
!
waypointsToIcons
.
contains
(
wp
))
updateWaypoint
(
uas
,
wp
);
}
// Delete connecting waypoint lines
QGraphicsItemGroup
*
group
=
waypointLines
.
value
(
uas
,
NULL
);
if
(
group
)
{
foreach
(
QGraphicsItem
*
item
,
group
->
childItems
())
{
delete
item
;
}
}
// Add line element if this is NOT the first waypoint
mapcontrol
::
WayPointItem
*
prevIcon
=
NULL
;
foreach
(
Waypoint
*
wp
,
wps
)
{
mapcontrol
::
WayPointItem
*
currIcon
=
waypointsToIcons
.
value
(
wp
,
NULL
);
// Do not work on first waypoint, but only increment counter
// do not continue if icon is invalid
if
(
prevIcon
&&
currIcon
)
{
// If we got a valid graphics item, continue
mapcontrol
::
WaypointLineItem
*
line
=
new
mapcontrol
::
WaypointLineItem
(
prevIcon
,
currIcon
,
uasInstance
->
getColor
(),
map
);
QGraphicsItemGroup
*
group
=
waypointLines
.
value
(
uas
,
NULL
);
if
(
group
)
{
group
->
addToGroup
(
line
);
qDebug
()
<<
"ADDED LINE!"
;
}
line
->
setVisible
(
true
);
}
prevIcon
=
currIcon
;
}
}
}
...
...
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