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
9e061b2d
Commit
9e061b2d
authored
Feb 18, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ComplexMissionItem support for Survey
parent
e513494c
Changes
24
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
636 additions
and
154 deletions
+636
-154
qgcresources.qrc
qgcresources.qrc
+1
-0
qgroundcontrol.pro
qgroundcontrol.pro
+4
-0
MapDrawShape.svg
src/FlightMap/Images/MapDrawShape.svg
+9
-0
MissionEditor.qml
src/MissionEditor/MissionEditor.qml
+43
-8
ComplexMissionItem.cc
src/MissionManager/ComplexMissionItem.cc
+87
-0
ComplexMissionItem.h
src/MissionManager/ComplexMissionItem.h
+73
-0
MissionCommands.cc
src/MissionManager/MissionCommands.cc
+2
-0
MissionController.cc
src/MissionManager/MissionController.cc
+42
-7
MissionController.h
src/MissionManager/MissionController.h
+10
-1
MissionControllerTest.cc
src/MissionManager/MissionControllerTest.cc
+2
-2
MissionItem.cc
src/MissionManager/MissionItem.cc
+0
-18
MissionItem.h
src/MissionManager/MissionItem.h
+17
-6
MissionItemTest.cc
src/MissionManager/MissionItemTest.cc
+2
-2
MissionManager.cc
src/MissionManager/MissionManager.cc
+4
-3
MissionManagerTest.cc
src/MissionManager/MissionManagerTest.cc
+3
-2
SimpleMissionItem.cc
src/MissionManager/SimpleMissionItem.cc
+61
-0
SimpleMissionItem.h
src/MissionManager/SimpleMissionItem.h
+62
-0
QGCLoggingCategory.cc
src/QGCLoggingCategory.cc
+1
-1
QGCLoggingCategory.h
src/QGCLoggingCategory.h
+1
-0
MissionItemEditor.qml
src/QmlControls/MissionItemEditor.qml
+173
-104
QGroundControlQmlGlobal.cc
src/QmlControls/QGroundControlQmlGlobal.cc
+15
-0
QGroundControlQmlGlobal.h
src/QmlControls/QGroundControlQmlGlobal.h
+7
-0
main.cc
src/main.cc
+2
-0
GeneralSettings.qml
src/ui/preferences/GeneralSettings.qml
+15
-0
No files found.
qgcresources.qrc
View file @
9e061b2d
...
@@ -99,6 +99,7 @@
...
@@ -99,6 +99,7 @@
<file alias="MapAddMissionBlack.svg">src/FlightMap/Images/MapAddMissionBlack.svg</file>
<file alias="MapAddMissionBlack.svg">src/FlightMap/Images/MapAddMissionBlack.svg</file>
<file alias="MapCenter.svg">src/FlightMap/Images/MapCenter.svg</file>
<file alias="MapCenter.svg">src/FlightMap/Images/MapCenter.svg</file>
<file alias="MapCenterBlack.svg">src/FlightMap/Images/MapCenterBlack.svg</file>
<file alias="MapCenterBlack.svg">src/FlightMap/Images/MapCenterBlack.svg</file>
<file alias="MapDrawShape.svg">src/FlightMap/Images/MapDrawShape.svg</file>
<file alias="MapHome.svg">src/FlightMap/Images/MapHome.svg</file>
<file alias="MapHome.svg">src/FlightMap/Images/MapHome.svg</file>
<file alias="MapHomeBlack.svg">src/FlightMap/Images/MapHomeBlack.svg</file>
<file alias="MapHomeBlack.svg">src/FlightMap/Images/MapHomeBlack.svg</file>
<file alias="MapSync.svg">src/FlightMap/Images/MapSync.svg</file>
<file alias="MapSync.svg">src/FlightMap/Images/MapSync.svg</file>
...
...
qgroundcontrol.pro
View file @
9e061b2d
...
@@ -261,6 +261,8 @@ HEADERS += \
...
@@ -261,6 +261,8 @@ HEADERS += \
src
/
MissionManager
/
MissionController
.
h
\
src
/
MissionManager
/
MissionController
.
h
\
src
/
MissionManager
/
MissionItem
.
h
\
src
/
MissionManager
/
MissionItem
.
h
\
src
/
MissionManager
/
MissionManager
.
h
\
src
/
MissionManager
/
MissionManager
.
h
\
src
/
MissionManager
/
ComplexMissionItem
.
h
\
src
/
MissionManager
/
SimpleMissionItem
.
h
\
src
/
QGC
.
h
\
src
/
QGC
.
h
\
src
/
QGCApplication
.
h
\
src
/
QGCApplication
.
h
\
src
/
QGCComboBox
.
h
\
src
/
QGCComboBox
.
h
\
...
@@ -388,6 +390,8 @@ SOURCES += \
...
@@ -388,6 +390,8 @@ SOURCES += \
src
/
MissionManager
/
MissionController
.
cc
\
src
/
MissionManager
/
MissionController
.
cc
\
src
/
MissionManager
/
MissionItem
.
cc
\
src
/
MissionManager
/
MissionItem
.
cc
\
src
/
MissionManager
/
MissionManager
.
cc
\
src
/
MissionManager
/
MissionManager
.
cc
\
src
/
MissionManager
/
ComplexMissionItem
.
cc
\
src
/
MissionManager
/
SimpleMissionItem
.
cc
\
src
/
QGC
.
cc
\
src
/
QGC
.
cc
\
src
/
QGCApplication
.
cc
\
src
/
QGCApplication
.
cc
\
src
/
QGCComboBox
.
cc
\
src
/
QGCComboBox
.
cc
\
...
...
src/FlightMap/Images/MapDrawShape.svg
0 → 100644
View file @
9e061b2d
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
version=
"1.1"
id=
"Layer_1"
xmlns=
"http://www.w3.org/2000/svg"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
x=
"0px"
y=
"0px"
viewBox=
"-89 46 72 72"
enable-background=
"new -89 46 72 72"
xml:space=
"preserve"
>
<g
transform=
"matrix(0.96508576,0,0,0.94661676,-1.3508671,3.6129809)"
>
<path
fill=
"none"
stroke=
"#FFFFFF"
stroke-width=
"1.2"
stroke-miterlimit=
"4"
d=
"m -69.288973,77.48289 22.722433,-9.307985 2.098859,4.288973 -23.726235,9.39924 1.186311,4.471483 23.908746,-9.855514 L -41,80.768061 -66.186312,91.079848 -65,95.551331 l 25.460076,-10.403042 -2.372624,7.391635 -13.140684,5.110266"
/>
</g>
<path
fill=
"none"
stroke=
"#FFFFFF"
stroke-width=
"2"
stroke-miterlimit=
"10"
d=
"m -44.193916,62.152091 10.76806,20.623574 -9.21673,19.346005 -24.638783,-3.011404 -6.205323,-25.186312 z"
/>
</svg>
src/MissionEditor/MissionEditor.qml
View file @
9e061b2d
...
@@ -285,6 +285,8 @@ QGCView {
...
@@ -285,6 +285,8 @@ QGCView {
anchors.fill
:
parent
anchors.fill
:
parent
mapName
:
"
MissionEditor
"
mapName
:
"
MissionEditor
"
signal
mapClicked
(
var
coordinate
)
readonly
property
real
animationDuration
:
500
readonly
property
real
animationDuration
:
500
// Initial map position duplicates Fly view position
// Initial map position duplicates Fly view position
...
@@ -301,15 +303,15 @@ QGCView {
...
@@ -301,15 +303,15 @@ QGCView {
anchors.fill
:
parent
anchors.fill
:
parent
onClicked
:
{
onClicked
:
{
var
coordinate
=
editorMap
.
toCoordinate
(
Qt
.
point
(
mouse
.
x
,
mouse
.
y
))
coordinate
.
latitude
=
coordinate
.
latitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
longitude
=
coordinate
.
longitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
altitude
=
coordinate
.
altitude
.
toFixed
(
_decimalPlaces
)
if
(
addMissionItemsButton
.
checked
)
{
if
(
addMissionItemsButton
.
checked
)
{
var
coordinate
=
editorMap
.
toCoordinate
(
Qt
.
point
(
mouse
.
x
,
mouse
.
y
))
var
index
=
controller
.
insertSimpleMissionItem
(
coordinate
,
controller
.
missionItems
.
count
)
coordinate
.
latitude
=
coordinate
.
latitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
longitude
=
coordinate
.
longitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
altitude
=
coordinate
.
altitude
.
toFixed
(
_decimalPlaces
)
var
index
=
controller
.
insertMissionItem
(
coordinate
,
controller
.
missionItems
.
count
)
setCurrentItem
(
index
)
setCurrentItem
(
index
)
}
else
{
}
else
{
editorMap
.
zoomLevel
=
editorMap
.
maxZoomLevel
-
2
editorMap
.
mapClicked
(
coordinate
)
}
}
}
}
}
}
...
@@ -364,7 +366,7 @@ QGCView {
...
@@ -364,7 +366,7 @@ QGCView {
}
}
}
}
// Add the mission items to the map
// Add the
simple
mission items to the map
MapItemView
{
MapItemView
{
model
:
controller
.
missionItems
model
:
controller
.
missionItems
delegate
:
missionItemComponent
delegate
:
missionItemComponent
...
@@ -421,6 +423,22 @@ QGCView {
...
@@ -421,6 +423,22 @@ QGCView {
}
}
}
}
// Add the complex mission items to the map
MapItemView
{
model
:
controller
.
complexMissionItems
delegate
:
polygonItemComponent
}
Component
{
id
:
polygonItemComponent
MapPolygon
{
color
:
'
green
'
path
:
object
.
polygonPath
opacity
:
0.5
}
}
// Add lines between waypoints
// Add lines between waypoints
MissionLineView
{
MissionLineView
{
model
:
controller
.
waypointLines
model
:
controller
.
waypointLines
...
@@ -482,7 +500,7 @@ QGCView {
...
@@ -482,7 +500,7 @@ QGCView {
}
}
onInsert
:
{
onInsert
:
{
controller
.
insertMissionItem
(
editorMap
.
center
,
i
)
controller
.
insert
Simple
MissionItem
(
editorMap
.
center
,
i
)
setCurrentItem
(
i
)
setCurrentItem
(
i
)
}
}
...
@@ -522,6 +540,23 @@ QGCView {
...
@@ -522,6 +540,23 @@ QGCView {
z
:
QGroundControl
.
zOrderWidgets
z
:
QGroundControl
.
zOrderWidgets
}
}
RoundButton
{
id
:
addShapeButton
buttonImage
:
"
/qmlimages/MapDrawShape.svg
"
z
:
QGroundControl
.
zOrderWidgets
visible
:
QGroundControl
.
experimentalSurvey
onClicked
:
{
var
coordinate
=
editorMap
.
center
coordinate
.
latitude
=
coordinate
.
latitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
longitude
=
coordinate
.
longitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
altitude
=
coordinate
.
altitude
.
toFixed
(
_decimalPlaces
)
var
index
=
controller
.
insertComplexMissionItem
(
coordinate
,
controller
.
missionItems
.
count
)
setCurrentItem
(
index
)
checked
=
false
}
}
DropButton
{
DropButton
{
id
:
syncButton
id
:
syncButton
dropDirection
:
dropRight
dropDirection
:
dropRight
...
...
src/MissionManager/ComplexMissionItem.cc
0 → 100644
View file @
9e061b2d
/*===================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#include "ComplexMissionItem.h"
ComplexMissionItem
::
ComplexMissionItem
(
Vehicle
*
vehicle
,
QObject
*
parent
)
:
MissionItem
(
vehicle
,
parent
)
{
}
ComplexMissionItem
::
ComplexMissionItem
(
Vehicle
*
vehicle
,
int
sequenceNumber
,
MAV_CMD
command
,
MAV_FRAME
frame
,
double
param1
,
double
param2
,
double
param3
,
double
param4
,
double
param5
,
double
param6
,
double
param7
,
bool
autoContinue
,
bool
isCurrentItem
,
QObject
*
parent
)
:
MissionItem
(
vehicle
,
sequenceNumber
,
command
,
frame
,
param1
,
param2
,
param3
,
param4
,
param5
,
param6
,
param7
,
autoContinue
,
isCurrentItem
,
parent
)
{
}
ComplexMissionItem
::
ComplexMissionItem
(
const
ComplexMissionItem
&
other
,
QObject
*
parent
)
:
MissionItem
(
other
,
parent
)
{
}
const
ComplexMissionItem
&
ComplexMissionItem
::
operator
=
(
const
ComplexMissionItem
&
other
)
{
static_cast
<
MissionItem
&>
(
*
this
)
=
other
;
return
*
this
;
}
QVariantList
ComplexMissionItem
::
polygonPath
(
void
)
{
return
_polygonPath
;
#if 0
QVariantList list;
list << QVariant::fromValue(QGeoCoordinate(-35.362686830000001, 149.16410282999999))
<< QVariant::fromValue(QGeoCoordinate(-35.362660579999996, 149.16606619999999))
<< QVariant::fromValue(QGeoCoordinate(-35.363832989999999, 149.16505769));
return list;
#endif
}
void
ComplexMissionItem
::
clearPolygon
(
void
)
{
_polygonPath
.
clear
();
emit
polygonPathChanged
();
}
void
ComplexMissionItem
::
addPolygonCoordinate
(
const
QGeoCoordinate
coordinate
)
{
_polygonPath
<<
QVariant
::
fromValue
(
coordinate
);
emit
polygonPathChanged
();
}
src/MissionManager/ComplexMissionItem.h
0 → 100644
View file @
9e061b2d
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef ComplexMissionItem_H
#define ComplexMissionItem_H
#include "MissionItem.h"
class
ComplexMissionItem
:
public
MissionItem
{
Q_OBJECT
public:
ComplexMissionItem
(
Vehicle
*
vehicle
,
QObject
*
parent
=
NULL
);
ComplexMissionItem
(
Vehicle
*
vehicle
,
int
sequenceNumber
,
MAV_CMD
command
,
MAV_FRAME
frame
,
double
param1
,
double
param2
,
double
param3
,
double
param4
,
double
param5
,
double
param6
,
double
param7
,
bool
autoContinue
,
bool
isCurrentItem
,
QObject
*
parent
=
NULL
);
ComplexMissionItem
(
const
ComplexMissionItem
&
other
,
QObject
*
parent
=
NULL
);
const
ComplexMissionItem
&
operator
=
(
const
ComplexMissionItem
&
other
);
Q_PROPERTY
(
QVariantList
polygonPath
READ
polygonPath
NOTIFY
polygonPathChanged
)
Q_INVOKABLE
void
clearPolygon
(
void
);
Q_INVOKABLE
void
addPolygonCoordinate
(
const
QGeoCoordinate
coordinate
);
QVariantList
polygonPath
(
void
);
// Overrides from MissionItem base class
bool
simpleItem
(
void
)
const
final
{
return
false
;
}
QGeoCoordinate
exitCoordinate
(
void
)
const
final
{
return
coordinate
();
}
signals:
void
polygonPathChanged
(
void
);
private:
QVariantList
_polygonPath
;
};
#endif
src/MissionManager/MissionCommands.cc
View file @
9e061b2d
...
@@ -27,6 +27,8 @@ This file is part of the QGROUNDCONTROL project
...
@@ -27,6 +27,8 @@ This file is part of the QGROUNDCONTROL project
#include "QGCApplication.h"
#include "QGCApplication.h"
#include "QGroundControlQmlGlobal.h"
#include "QGroundControlQmlGlobal.h"
#include <QQmlEngine>
MissionCommands
::
MissionCommands
(
QGCApplication
*
app
)
MissionCommands
::
MissionCommands
(
QGCApplication
*
app
)
:
QGCTool
(
app
)
:
QGCTool
(
app
)
,
_commonMissionCommands
(
QStringLiteral
(
":/json/MavCmdInfoCommon.json"
))
,
_commonMissionCommands
(
QStringLiteral
(
":/json/MavCmdInfoCommon.json"
))
...
...
src/MissionManager/MissionController.cc
View file @
9e061b2d
...
@@ -27,6 +27,8 @@ This file is part of the QGROUNDCONTROL project
...
@@ -27,6 +27,8 @@ This file is part of the QGROUNDCONTROL project
#include "CoordinateVector.h"
#include "CoordinateVector.h"
#include "FirmwarePlugin.h"
#include "FirmwarePlugin.h"
#include "QGCApplication.h"
#include "QGCApplication.h"
#include "SimpleMissionItem.h"
#include "ComplexMissionItem.h"
#ifndef __mobile__
#ifndef __mobile__
#include "QGCFileDialog.h"
#include "QGCFileDialog.h"
...
@@ -45,6 +47,7 @@ MissionController::MissionController(QObject *parent)
...
@@ -45,6 +47,7 @@ MissionController::MissionController(QObject *parent)
:
QObject
(
parent
)
:
QObject
(
parent
)
,
_editMode
(
false
)
,
_editMode
(
false
)
,
_missionItems
(
NULL
)
,
_missionItems
(
NULL
)
,
_complexMissionItems
(
NULL
)
,
_activeVehicle
(
NULL
)
,
_activeVehicle
(
NULL
)
,
_autoSync
(
false
)
,
_autoSync
(
false
)
,
_firstItemsFromVehicle
(
false
)
,
_firstItemsFromVehicle
(
false
)
...
@@ -124,9 +127,9 @@ void MissionController::sendMissionItems(void)
...
@@ -124,9 +127,9 @@ void MissionController::sendMissionItems(void)
}
}
}
}
int
MissionController
::
insertMissionItem
(
QGeoCoordinate
coordinate
,
int
i
)
int
MissionController
::
insert
Simple
MissionItem
(
QGeoCoordinate
coordinate
,
int
i
)
{
{
MissionItem
*
newItem
=
new
MissionItem
(
_activeVehicle
,
this
);
MissionItem
*
newItem
=
new
Simple
MissionItem
(
_activeVehicle
,
this
);
newItem
->
setSequenceNumber
(
_missionItems
->
count
());
newItem
->
setSequenceNumber
(
_missionItems
->
count
());
newItem
->
setCoordinate
(
coordinate
);
newItem
->
setCoordinate
(
coordinate
);
newItem
->
setCommand
(
MAV_CMD_NAV_WAYPOINT
);
newItem
->
setCommand
(
MAV_CMD_NAV_WAYPOINT
);
...
@@ -152,6 +155,22 @@ int MissionController::insertMissionItem(QGeoCoordinate coordinate, int i)
...
@@ -152,6 +155,22 @@ int MissionController::insertMissionItem(QGeoCoordinate coordinate, int i)
return
_missionItems
->
count
()
-
1
;
return
_missionItems
->
count
()
-
1
;
}
}
int
MissionController
::
insertComplexMissionItem
(
QGeoCoordinate
coordinate
,
int
i
)
{
ComplexMissionItem
*
newItem
=
new
ComplexMissionItem
(
_activeVehicle
,
this
);
newItem
->
setSequenceNumber
(
_missionItems
->
count
());
newItem
->
setCoordinate
(
coordinate
);
newItem
->
setCommand
(
MAV_CMD_NAV_WAYPOINT
);
_initMissionItem
(
newItem
);
_missionItems
->
insert
(
i
,
newItem
);
_complexMissionItems
->
append
(
newItem
);
_recalcAll
();
return
_missionItems
->
count
()
-
1
;
}
void
MissionController
::
removeMissionItem
(
int
index
)
void
MissionController
::
removeMissionItem
(
int
index
)
{
{
MissionItem
*
item
=
qobject_cast
<
MissionItem
*>
(
_missionItems
->
removeAt
(
index
));
MissionItem
*
item
=
qobject_cast
<
MissionItem
*>
(
_missionItems
->
removeAt
(
index
));
...
@@ -218,7 +237,7 @@ bool MissionController::_loadJsonMissionFile(const QByteArray& bytes, QmlObjectL
...
@@ -218,7 +237,7 @@ bool MissionController::_loadJsonMissionFile(const QByteArray& bytes, QmlObjectL
return
false
;
return
false
;
}
}
MissionItem
*
item
=
new
MissionItem
(
_activeVehicle
,
this
);
MissionItem
*
item
=
new
Simple
MissionItem
(
_activeVehicle
,
this
);
if
(
item
->
load
(
itemValue
.
toObject
(),
errorString
))
{
if
(
item
->
load
(
itemValue
.
toObject
(),
errorString
))
{
missionItems
->
append
(
item
);
missionItems
->
append
(
item
);
}
else
{
}
else
{
...
@@ -228,7 +247,7 @@ bool MissionController::_loadJsonMissionFile(const QByteArray& bytes, QmlObjectL
...
@@ -228,7 +247,7 @@ bool MissionController::_loadJsonMissionFile(const QByteArray& bytes, QmlObjectL
}
}
if
(
json
.
contains
(
_jsonPlannedHomePositionKey
))
{
if
(
json
.
contains
(
_jsonPlannedHomePositionKey
))
{
MissionItem
*
item
=
new
MissionItem
(
_activeVehicle
,
this
);
MissionItem
*
item
=
new
Simple
MissionItem
(
_activeVehicle
,
this
);
if
(
item
->
load
(
json
[
_jsonPlannedHomePositionKey
].
toObject
(),
errorString
))
{
if
(
item
->
load
(
json
[
_jsonPlannedHomePositionKey
].
toObject
(),
errorString
))
{
missionItems
->
insert
(
0
,
item
);
missionItems
->
insert
(
0
,
item
);
...
@@ -263,7 +282,7 @@ bool MissionController::_loadTextMissionFile(QTextStream& stream, QmlObjectListM
...
@@ -263,7 +282,7 @@ bool MissionController::_loadTextMissionFile(QTextStream& stream, QmlObjectListM
if
(
versionOk
)
{
if
(
versionOk
)
{
while
(
!
stream
.
atEnd
())
{
while
(
!
stream
.
atEnd
())
{
MissionItem
*
item
=
new
MissionItem
(
_activeVehicle
,
this
);
MissionItem
*
item
=
new
Simple
MissionItem
(
_activeVehicle
,
this
);
if
(
item
->
load
(
stream
))
{
if
(
item
->
load
(
stream
))
{
missionItems
->
append
(
item
);
missionItems
->
append
(
item
);
...
@@ -612,13 +631,24 @@ void MissionController::_initAllMissionItems(void)
...
@@ -612,13 +631,24 @@ void MissionController::_initAllMissionItems(void)
qDebug
()
<<
"home item"
<<
homeItem
->
coordinate
();
qDebug
()
<<
"home item"
<<
homeItem
->
coordinate
();
QmlObjectListModel
*
newComplexItems
=
new
QmlObjectListModel
(
this
);
for
(
int
i
=
0
;
i
<
_missionItems
->
count
();
i
++
)
{
for
(
int
i
=
0
;
i
<
_missionItems
->
count
();
i
++
)
{
_initMissionItem
(
qobject_cast
<
MissionItem
*>
(
_missionItems
->
get
(
i
)));
MissionItem
*
item
=
qobject_cast
<
MissionItem
*>
(
_missionItems
->
get
(
i
));
if
(
!
item
->
simpleItem
())
{
newComplexItems
->
append
(
item
);
}
_initMissionItem
(
item
);
}
}
delete
_complexMissionItems
;
_complexMissionItems
=
newComplexItems
;
_recalcAll
();
_recalcAll
();
emit
missionItemsChanged
();
emit
missionItemsChanged
();
emit
complexMissionItemsChanged
();
_missionItems
->
setDirty
(
false
);
_missionItems
->
setDirty
(
false
);
...
@@ -773,6 +803,11 @@ QmlObjectListModel* MissionController::missionItems(void)
...
@@ -773,6 +803,11 @@ QmlObjectListModel* MissionController::missionItems(void)
return
_missionItems
;
return
_missionItems
;
}
}
QmlObjectListModel
*
MissionController
::
complexMissionItems
(
void
)
{
return
_complexMissionItems
;
}
bool
MissionController
::
_findLastAltitude
(
double
*
lastAltitude
)
bool
MissionController
::
_findLastAltitude
(
double
*
lastAltitude
)
{
{
bool
found
=
false
;
bool
found
=
false
;
...
@@ -831,7 +866,7 @@ double MissionController::_normalizeLon(double lon)
...
@@ -831,7 +866,7 @@ double MissionController::_normalizeLon(double lon)
/// Add the home position item to the front of the list
/// Add the home position item to the front of the list
void
MissionController
::
_addPlannedHomePosition
(
QmlObjectListModel
*
missionItems
,
bool
addToCenter
)
void
MissionController
::
_addPlannedHomePosition
(
QmlObjectListModel
*
missionItems
,
bool
addToCenter
)
{
{
MissionItem
*
homeItem
=
new
MissionItem
(
_activeVehicle
,
this
);
MissionItem
*
homeItem
=
new
Simple
MissionItem
(
_activeVehicle
,
this
);
missionItems
->
insert
(
0
,
homeItem
);
missionItems
->
insert
(
0
,
homeItem
);
if
(
missionItems
->
count
()
>
1
&&
addToCenter
)
{
if
(
missionItems
->
count
()
>
1
&&
addToCenter
)
{
...
...
src/MissionManager/MissionController.h
View file @
9e061b2d
...
@@ -29,6 +29,8 @@ This file is part of the QGROUNDCONTROL project
...
@@ -29,6 +29,8 @@ This file is part of the QGROUNDCONTROL project
#include "QmlObjectListModel.h"
#include "QmlObjectListModel.h"
#include "Vehicle.h"
#include "Vehicle.h"
#include "QGCLoggingCategory.h"
#include "QGCLoggingCategory.h"
#include "MavlinkQmlSingleton.h"
#include "MissionItem.h"
Q_DECLARE_LOGGING_CATEGORY
(
MissionControllerLog
)
Q_DECLARE_LOGGING_CATEGORY
(
MissionControllerLog
)
...
@@ -41,6 +43,7 @@ public:
...
@@ -41,6 +43,7 @@ public:
~
MissionController
();
~
MissionController
();
Q_PROPERTY
(
QmlObjectListModel
*
missionItems
READ
missionItems
NOTIFY
missionItemsChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
missionItems
READ
missionItems
NOTIFY
missionItemsChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
complexMissionItems
READ
complexMissionItems
NOTIFY
complexMissionItemsChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
waypointLines
READ
waypointLines
NOTIFY
waypointLinesChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
waypointLines
READ
waypointLines
NOTIFY
waypointLinesChanged
)
Q_PROPERTY
(
bool
autoSync
READ
autoSync
WRITE
setAutoSync
NOTIFY
autoSyncChanged
)
Q_PROPERTY
(
bool
autoSync
READ
autoSync
WRITE
setAutoSync
NOTIFY
autoSyncChanged
)
Q_PROPERTY
(
bool
syncInProgress
READ
syncInProgress
NOTIFY
syncInProgressChanged
)
Q_PROPERTY
(
bool
syncInProgress
READ
syncInProgress
NOTIFY
syncInProgressChanged
)
...
@@ -57,11 +60,15 @@ public:
...
@@ -57,11 +60,15 @@ public:
Q_INVOKABLE
QStringList
getMobileMissionFiles
(
void
);
Q_INVOKABLE
QStringList
getMobileMissionFiles
(
void
);
/// @param i: index to insert at
/// @param i: index to insert at
Q_INVOKABLE
int
insertMissionItem
(
QGeoCoordinate
coordinate
,
int
i
);
Q_INVOKABLE
int
insertSimpleMissionItem
(
QGeoCoordinate
coordinate
,
int
i
);
/// @param i: index to insert at
Q_INVOKABLE
int
insertComplexMissionItem
(
QGeoCoordinate
coordinate
,
int
i
);
// Property accessors
// Property accessors
QmlObjectListModel
*
missionItems
(
void
);
QmlObjectListModel
*
missionItems
(
void
);
QmlObjectListModel
*
complexMissionItems
(
void
);
QmlObjectListModel
*
waypointLines
(
void
)
{
return
&
_waypointLines
;
}
QmlObjectListModel
*
waypointLines
(
void
)
{
return
&
_waypointLines
;
}
bool
autoSync
(
void
)
{
return
_autoSync
;
}
bool
autoSync
(
void
)
{
return
_autoSync
;
}
void
setAutoSync
(
bool
autoSync
);
void
setAutoSync
(
bool
autoSync
);
...
@@ -69,6 +76,7 @@ public:
...
@@ -69,6 +76,7 @@ public:
signals:
signals:
void
missionItemsChanged
(
void
);
void
missionItemsChanged
(
void
);
void
complexMissionItemsChanged
(
void
);
void
waypointLinesChanged
(
void
);
void
waypointLinesChanged
(
void
);
void
autoSyncChanged
(
bool
autoSync
);
void
autoSyncChanged
(
bool
autoSync
);
void
newItemsFromVehicle
(
void
);
void
newItemsFromVehicle
(
void
);
...
@@ -111,6 +119,7 @@ private:
...
@@ -111,6 +119,7 @@ private:
private:
private:
bool
_editMode
;
bool
_editMode
;
QmlObjectListModel
*
_missionItems
;
QmlObjectListModel
*
_missionItems
;
QmlObjectListModel
*
_complexMissionItems
;
QmlObjectListModel
_waypointLines
;
QmlObjectListModel
_waypointLines
;
Vehicle
*
_activeVehicle
;
Vehicle
*
_activeVehicle
;
bool
_autoSync
;
bool
_autoSync
;
...
...
src/MissionManager/MissionControllerTest.cc
View file @
9e061b2d
...
@@ -137,7 +137,7 @@ void MissionControllerTest::_testAddWaypointWorker(MAV_AUTOPILOT firmwareType)
...
@@ -137,7 +137,7 @@ void MissionControllerTest::_testAddWaypointWorker(MAV_AUTOPILOT firmwareType)
QGeoCoordinate
coordinate
(
37.803784
,
-
122.462276
);
QGeoCoordinate
coordinate
(
37.803784
,
-
122.462276
);
_missionController
->
insertMissionItem
(
coordinate
,
_missionController
->
missionItems
()
->
count
());
_missionController
->
insert
Simple
MissionItem
(
coordinate
,
_missionController
->
missionItems
()
->
count
());
QCOMPARE
(
_multiSpyMissionController
->
checkOnlySignalsByMask
(
waypointLinesChangedSignalMask
),
true
);
QCOMPARE
(
_multiSpyMissionController
->
checkOnlySignalsByMask
(
waypointLinesChangedSignalMask
),
true
);
...
@@ -182,7 +182,7 @@ void MissionControllerTest::_testOfflineToOnlineWorker(MAV_AUTOPILOT firmwareTyp
...
@@ -182,7 +182,7 @@ void MissionControllerTest::_testOfflineToOnlineWorker(MAV_AUTOPILOT firmwareTyp
_missionController
=
new
MissionController
();
_missionController
=
new
MissionController
();
Q_CHECK_PTR
(
_missionController
);
Q_CHECK_PTR
(
_missionController
);
_missionController
->
start
(
true
/* editMode */
);
_missionController
->
start
(
true
/* editMode */
);
_missionController
->
insertMissionItem
(
QGeoCoordinate
(
37.803784
,
-
122.462276
),
_missionController
->
missionItems
()
->
count
());
_missionController
->
insert
Simple
MissionItem
(
QGeoCoordinate
(
37.803784
,
-
122.462276
),
_missionController
->
missionItems
()
->
count
());
// Go online to empty vehicle
// Go online to empty vehicle
MissionControllerManagerTest
::
_initForFirmwareType
(
firmwareType
);
MissionControllerManagerTest
::
_initForFirmwareType
(
firmwareType
);
...
...
src/MissionManager/MissionItem.cc
View file @
9e061b2d
...
@@ -28,8 +28,6 @@ This file is part of the QGROUNDCONTROL project
...
@@ -28,8 +28,6 @@ This file is part of the QGROUNDCONTROL project
#include "QGCApplication.h"
#include "QGCApplication.h"
#include "JsonHelper.h"
#include "JsonHelper.h"
QGC_LOGGING_CATEGORY
(
MissionItemLog
,
"MissionItemLog"
)
const
double
MissionItem
::
defaultAltitude
=
25.0
;
const
double
MissionItem
::
defaultAltitude
=
25.0
;
FactMetaData
*
MissionItem
::
_altitudeMetaData
=
NULL
;
FactMetaData
*
MissionItem
::
_altitudeMetaData
=
NULL
;
...
@@ -71,22 +69,6 @@ static const struct EnumInfo_s _rgMavFrameInfo[] = {
...
@@ -71,22 +69,6 @@ static const struct EnumInfo_s _rgMavFrameInfo[] = {
{
"MAV_FRAME_GLOBAL_TERRAIN_ALT_INT"
,
MAV_FRAME_GLOBAL_TERRAIN_ALT_INT
},
{
"MAV_FRAME_GLOBAL_TERRAIN_ALT_INT"
,
MAV_FRAME_GLOBAL_TERRAIN_ALT_INT
},
};
};
QDebug
operator
<<
(
QDebug
dbg
,
const
MissionItem
&
missionItem
)
{
QDebugStateSaver
saver
(
dbg
);
dbg
.
nospace
()
<<
"MissionItem("
<<
missionItem
.
coordinate
()
<<
")"
;
return
dbg
;
}
QDebug
operator
<<
(
QDebug
dbg
,
const
MissionItem
*
missionItem
)
{
QDebugStateSaver
saver
(
dbg
);
dbg
.
nospace
()
<<
"MissionItem("
<<
missionItem
->
coordinate
()
<<
")"
;
return
dbg
;
}
MissionItem
::
MissionItem
(
Vehicle
*
vehicle
,
QObject
*
parent
)
MissionItem
::
MissionItem
(
Vehicle
*
vehicle
,
QObject
*
parent
)
:
QObject
(
parent
)
:
QObject
(
parent
)
,
_vehicle
(
vehicle
)
,
_vehicle
(
vehicle
)
...
...
src/MissionManager/MissionItem.h
View file @
9e061b2d
...
@@ -40,8 +40,7 @@
...
@@ -40,8 +40,7 @@
#include "QmlObjectListModel.h"
#include "QmlObjectListModel.h"
#include "MissionCommands.h"
#include "MissionCommands.h"
Q_DECLARE_LOGGING_CATEGORY
(
MissionItemLog
)
// Abstract base class for Simple and Complex MissionItem obejcts.
class
MissionItem
:
public
QObject
class
MissionItem
:
public
QObject
{
{
Q_OBJECT
Q_OBJECT
...
@@ -77,7 +76,6 @@ public:
...
@@ -77,7 +76,6 @@ public:
Q_PROPERTY
(
MavlinkQmlSingleton
::
Qml_MAV_CMD
command
READ
command
WRITE
setCommand
NOTIFY
commandChanged
)
Q_PROPERTY
(
MavlinkQmlSingleton
::
Qml_MAV_CMD
command
READ
command
WRITE
setCommand
NOTIFY
commandChanged
)
Q_PROPERTY
(
QString
commandDescription
READ
commandDescription
NOTIFY
commandChanged
)
Q_PROPERTY
(
QString
commandDescription
READ
commandDescription
NOTIFY
commandChanged
)
Q_PROPERTY
(
QString
commandName
READ
commandName
NOTIFY
commandChanged
)
Q_PROPERTY
(
QString
commandName
READ
commandName
NOTIFY
commandChanged
)
Q_PROPERTY
(
QGeoCoordinate
coordinate
READ
coordinate
WRITE
setCoordinate
NOTIFY
coordinateChanged
)
Q_PROPERTY
(
bool
dirty
READ
dirty
WRITE
setDirty
NOTIFY
dirtyChanged
)
Q_PROPERTY
(
bool
dirty
READ
dirty
WRITE
setDirty
NOTIFY
dirtyChanged
)
Q_PROPERTY
(
double
distance
READ
distance
WRITE
setDistance
NOTIFY
distanceChanged
)
///< Distance to previous waypoint
Q_PROPERTY
(
double
distance
READ
distance
WRITE
setDistance
NOTIFY
distanceChanged
)
///< Distance to previous waypoint
Q_PROPERTY
(
bool
friendlyEditAllowed
READ
friendlyEditAllowed
NOTIFY
friendlyEditAllowedChanged
)
Q_PROPERTY
(
bool
friendlyEditAllowed
READ
friendlyEditAllowed
NOTIFY
friendlyEditAllowedChanged
)
...
@@ -90,6 +88,16 @@ public:
...
@@ -90,6 +88,16 @@ public:
Q_PROPERTY
(
bool
specifiesCoordinate
READ
specifiesCoordinate
NOTIFY
commandChanged
)
Q_PROPERTY
(
bool
specifiesCoordinate
READ
specifiesCoordinate
NOTIFY
commandChanged
)
Q_PROPERTY
(
bool
showHomePosition
READ
showHomePosition
WRITE
setShowHomePosition
NOTIFY
showHomePositionChanged
)
Q_PROPERTY
(
bool
showHomePosition
READ
showHomePosition
WRITE
setShowHomePosition
NOTIFY
showHomePositionChanged
)
// Mission item has two coordinates associated with them:
// coordinate: This is the entry point for a waypoint line into the item. For a simple item it is also the location of the item
// exitCoordinate This is the exit point for a waypoint line coming out of the item. For a SimpleMissionItem this will be the same as
// coordinate. For a ComplexMissionItem it may be different than the entry coordinate.
Q_PROPERTY
(
QGeoCoordinate
coordinate
READ
coordinate
WRITE
setCoordinate
NOTIFY
coordinateChanged
)
Q_PROPERTY
(
QGeoCoordinate
exitCoordinate
READ
exitCoordinate
NOTIFY
exitCoordinateChanged
)
/// @return true: SimpleMissionItem, false: ComplexMissionItem
Q_PROPERTY
(
bool
simpleItem
READ
simpleItem
NOTIFY
simpleItemChanged
)
// These properties are used to display the editing ui
// These properties are used to display the editing ui
Q_PROPERTY
(
QmlObjectListModel
*
checkboxFacts
READ
checkboxFacts
NOTIFY
uiModelChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
checkboxFacts
READ
checkboxFacts
NOTIFY
uiModelChan