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
dfc6bdd4
Commit
dfc6bdd4
authored
Aug 21, 2018
by
Gus Grubba
Committed by
Gus Grubba
Aug 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CP - Allow plugin to add its own keys to plan files.
Expose root plan keys
parent
b74609fe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
25 deletions
+56
-25
PlanMasterController.cc
src/MissionManager/PlanMasterController.cc
+34
-19
PlanMasterController.h
src/MissionManager/PlanMasterController.h
+6
-5
QGCCorePlugin.h
src/api/QGCCorePlugin.h
+16
-1
No files found.
src/MissionManager/PlanMasterController.cc
View file @
dfc6bdd4
...
...
@@ -9,6 +9,7 @@
#include "PlanMasterController.h"
#include "QGCApplication.h"
#include "QGCCorePlugin.h"
#include "MultiVehicleManager.h"
#include "SettingsManager.h"
#include "AppSettings.h"
...
...
@@ -22,16 +23,19 @@
QGC_LOGGING_CATEGORY
(
PlanMasterControllerLog
,
"PlanMasterControllerLog"
)
const
int
PlanMasterController
::
_p
lanFileVersion
=
1
;
const
char
*
PlanMasterController
::
_p
lanFileType
=
"Plan"
;
const
char
*
PlanMasterController
::
_j
sonMissionObjectKey
=
"mission"
;
const
char
*
PlanMasterController
::
_j
sonGeoFenceObjectKey
=
"geoFence"
;
const
char
*
PlanMasterController
::
_j
sonRallyPointsObjectKey
=
"rallyPoints"
;
const
int
PlanMasterController
::
kP
lanFileVersion
=
1
;
const
char
*
PlanMasterController
::
kP
lanFileType
=
"Plan"
;
const
char
*
PlanMasterController
::
kJ
sonMissionObjectKey
=
"mission"
;
const
char
*
PlanMasterController
::
kJ
sonGeoFenceObjectKey
=
"geoFence"
;
const
char
*
PlanMasterController
::
kJ
sonRallyPointsObjectKey
=
"rallyPoints"
;
PlanMasterController
::
PlanMasterController
(
QObject
*
parent
)
:
QObject
(
parent
)
,
_multiVehicleMgr
(
qgcApp
()
->
toolbox
()
->
multiVehicleManager
())
,
_controllerVehicle
(
new
Vehicle
((
MAV_AUTOPILOT
)
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
offlineEditingFirmwareType
()
->
rawValue
().
toInt
(),
(
MAV_TYPE
)
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
offlineEditingVehicleType
()
->
rawValue
().
toInt
(),
qgcApp
()
->
toolbox
()
->
firmwarePluginManager
()))
,
_controllerVehicle
(
new
Vehicle
(
static_cast
<
MAV_AUTOPILOT
>
(
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
offlineEditingFirmwareType
()
->
rawValue
().
toInt
()),
static_cast
<
MAV_TYPE
>
(
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
offlineEditingVehicleType
()
->
rawValue
().
toInt
()),
qgcApp
()
->
toolbox
()
->
firmwarePluginManager
()))
,
_managerVehicle
(
_controllerVehicle
)
,
_flyView
(
true
)
,
_offline
(
true
)
...
...
@@ -101,7 +105,7 @@ void PlanMasterController::_activeVehicleChanged(Vehicle* activeVehicle)
}
bool
newOffline
=
false
;
if
(
activeVehicle
==
NULL
)
{
if
(
activeVehicle
==
nullptr
)
{
// Since there is no longer an active vehicle we use the offline controller vehicle as the manager vehicle
_managerVehicle
=
_controllerVehicle
;
newOffline
=
true
;
...
...
@@ -299,28 +303,33 @@ void PlanMasterController::loadFromFile(const QString& filename)
return
;
}
int
version
;
QJsonObject
json
=
jsonDoc
.
object
();
if
(
!
JsonHelper
::
validateQGCJsonFile
(
json
,
_planFileType
,
_planFileVersion
,
_planFileVersion
,
version
,
errorString
))
{
//-- Allow plugins to pre process the load
qgcApp
()
->
toolbox
()
->
corePlugin
()
->
preLoadFromJson
(
this
,
json
);
int
version
;
if
(
!
JsonHelper
::
validateQGCJsonFile
(
json
,
kPlanFileType
,
kPlanFileVersion
,
kPlanFileVersion
,
version
,
errorString
))
{
qgcApp
()
->
showMessage
(
errorMessage
.
arg
(
errorString
));
return
;
}
QList
<
JsonHelper
::
KeyValidateInfo
>
rgKeyInfo
=
{
{
_j
sonMissionObjectKey
,
QJsonValue
::
Object
,
true
},
{
_j
sonGeoFenceObjectKey
,
QJsonValue
::
Object
,
true
},
{
_j
sonRallyPointsObjectKey
,
QJsonValue
::
Object
,
true
},
{
kJ
sonMissionObjectKey
,
QJsonValue
::
Object
,
true
},
{
kJ
sonGeoFenceObjectKey
,
QJsonValue
::
Object
,
true
},
{
kJ
sonRallyPointsObjectKey
,
QJsonValue
::
Object
,
true
},
};
if
(
!
JsonHelper
::
validateKeys
(
json
,
rgKeyInfo
,
errorString
))
{
qgcApp
()
->
showMessage
(
errorMessage
.
arg
(
errorString
));
return
;
}
if
(
!
_missionController
.
load
(
json
[
_j
sonMissionObjectKey
].
toObject
(),
errorString
)
||
!
_geoFenceController
.
load
(
json
[
_j
sonGeoFenceObjectKey
].
toObject
(),
errorString
)
||
!
_rallyPointController
.
load
(
json
[
_j
sonRallyPointsObjectKey
].
toObject
(),
errorString
))
{
if
(
!
_missionController
.
load
(
json
[
kJ
sonMissionObjectKey
].
toObject
(),
errorString
)
||
!
_geoFenceController
.
load
(
json
[
kJ
sonGeoFenceObjectKey
].
toObject
(),
errorString
)
||
!
_rallyPointController
.
load
(
json
[
kJ
sonRallyPointsObjectKey
].
toObject
(),
errorString
))
{
qgcApp
()
->
showMessage
(
errorMessage
.
arg
(
errorString
));
}
else
{
//-- Allow plugins to post process the load
qgcApp
()
->
toolbox
()
->
corePlugin
()
->
postLoadFromJson
(
this
,
json
);
success
=
true
;
}
}
else
if
(
fileInfo
.
suffix
()
==
AppSettings
::
missionFileExtension
)
{
...
...
@@ -354,16 +363,22 @@ void PlanMasterController::loadFromFile(const QString& filename)
QJsonDocument
PlanMasterController
::
saveToJson
()
{
QJsonObject
planJson
;
qgcApp
()
->
toolbox
()
->
corePlugin
()
->
preSaveToJson
(
this
,
planJson
);
QJsonObject
missionJson
;
QJsonObject
fenceJson
;
QJsonObject
rallyJson
;
JsonHelper
::
saveQGCJsonFileHeader
(
planJson
,
_planFileType
,
_planFileVersion
);
JsonHelper
::
saveQGCJsonFileHeader
(
planJson
,
kPlanFileType
,
kPlanFileVersion
);
//-- Allow plugin to preemptly add its own keys to mission
qgcApp
()
->
toolbox
()
->
corePlugin
()
->
preSaveToMissionJson
(
this
,
missionJson
);
_missionController
.
save
(
missionJson
);
//-- Allow plugin to add its own keys to mission
qgcApp
()
->
toolbox
()
->
corePlugin
()
->
postSaveToMissionJson
(
this
,
missionJson
);
_geoFenceController
.
save
(
fenceJson
);
_rallyPointController
.
save
(
rallyJson
);
planJson
[
_jsonMissionObjectKey
]
=
missionJson
;
planJson
[
_jsonGeoFenceObjectKey
]
=
fenceJson
;
planJson
[
_jsonRallyPointsObjectKey
]
=
rallyJson
;
planJson
[
kJsonMissionObjectKey
]
=
missionJson
;
planJson
[
kJsonGeoFenceObjectKey
]
=
fenceJson
;
planJson
[
kJsonRallyPointsObjectKey
]
=
rallyJson
;
qgcApp
()
->
toolbox
()
->
corePlugin
()
->
postSaveToJson
(
this
,
planJson
);
return
QJsonDocument
(
planJson
);
}
...
...
src/MissionManager/PlanMasterController.h
View file @
dfc6bdd4
...
...
@@ -91,6 +91,12 @@ public:
Vehicle
*
controllerVehicle
(
void
)
{
return
_controllerVehicle
;
}
Vehicle
*
managerVehicle
(
void
)
{
return
_managerVehicle
;
}
static
const
int
kPlanFileVersion
;
static
const
char
*
kPlanFileType
;
static
const
char
*
kJsonMissionObjectKey
;
static
const
char
*
kJsonGeoFenceObjectKey
;
static
const
char
*
kJsonRallyPointsObjectKey
;
signals:
void
containsItemsChanged
(
bool
containsItems
);
void
syncInProgressChanged
(
void
);
...
...
@@ -124,9 +130,4 @@ private:
bool
_sendRallyPoints
;
QString
_currentPlanFile
;
static
const
int
_planFileVersion
;
static
const
char
*
_planFileType
;
static
const
char
*
_jsonMissionObjectKey
;
static
const
char
*
_jsonGeoFenceObjectKey
;
static
const
char
*
_jsonRallyPointsObjectKey
;
};
src/api/QGCCorePlugin.h
View file @
dfc6bdd4
...
...
@@ -32,6 +32,7 @@ class Vehicle;
class
LinkInterface
;
class
QmlObjectListModel
;
class
VideoReceiver
;
class
PlanMasterController
;
class
QGCCorePlugin
:
public
QGCTool
{
...
...
@@ -88,7 +89,7 @@ public:
virtual
QString
showAdvancedUIMessage
(
void
)
const
;
/// @return An instance of an alternate position source (or NULL if not available)
virtual
QGeoPositionInfoSource
*
createPositionSource
(
QObject
*
parent
)
{
Q_UNUSED
(
parent
);
return
NULL
;
}
virtual
QGeoPositionInfoSource
*
createPositionSource
(
QObject
*
parent
)
{
Q_UNUSED
(
parent
);
return
nullptr
;
}
/// Allows a plugin to override the specified color name from the palette
virtual
void
paletteOverride
(
QString
colorName
,
QGCPalette
::
PaletteColorInfo_t
&
colorInfo
);
...
...
@@ -110,6 +111,20 @@ public:
/// should derive from QmlComponentInfo and set the url property.
virtual
QmlObjectListModel
*
customMapItems
(
void
);
/// Allows custom builds to add custom items to the plan file. Either before the document is
/// created or after.
virtual
void
preSaveToJson
(
PlanMasterController
*
pController
,
QJsonObject
&
json
)
{
Q_UNUSED
(
pController
);
Q_UNUSED
(
json
);
}
virtual
void
postSaveToJson
(
PlanMasterController
*
pController
,
QJsonObject
&
json
)
{
Q_UNUSED
(
pController
);
Q_UNUSED
(
json
);
}
/// Same for the specific "mission" portion
virtual
void
preSaveToMissionJson
(
PlanMasterController
*
pController
,
QJsonObject
&
missionJson
)
{
Q_UNUSED
(
pController
);
Q_UNUSED
(
missionJson
);
}
virtual
void
postSaveToMissionJson
(
PlanMasterController
*
pController
,
QJsonObject
&
missionJson
)
{
Q_UNUSED
(
pController
);
Q_UNUSED
(
missionJson
);
}
/// Allows custom builds to load custom items from the plan file. Either before the document is
/// parsed or after.
virtual
void
preLoadFromJson
(
PlanMasterController
*
pController
,
QJsonObject
&
json
)
{
Q_UNUSED
(
pController
);
Q_UNUSED
(
json
);
}
virtual
void
postLoadFromJson
(
PlanMasterController
*
pController
,
QJsonObject
&
json
)
{
Q_UNUSED
(
pController
);
Q_UNUSED
(
json
);
}
bool
showTouchAreas
(
void
)
const
{
return
_showTouchAreas
;
}
bool
showAdvancedUI
(
void
)
const
{
return
_showAdvancedUI
;
}
void
setShowTouchAreas
(
bool
show
);
...
...
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