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
588989a0
Commit
588989a0
authored
Jun 17, 2019
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save and load works
parent
6256464b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
150 additions
and
37 deletions
+150
-37
WimaArea.cc
src/Wima/WimaArea.cc
+1
-1
WimaController.cc
src/Wima/WimaController.cc
+110
-3
WimaController.h
src/Wima/WimaController.h
+9
-5
WimaGOperationArea.cc
src/Wima/WimaGOperationArea.cc
+4
-4
WimaView.qml
src/WimaView/WimaView.qml
+26
-24
No files found.
src/Wima/WimaArea.cc
View file @
588989a0
...
...
@@ -499,7 +499,7 @@ bool WimaArea::loadFromJson(const QJsonObject &json, QString& errorString)
_maxAltitude
=
json
[
maxAltitudeName
].
toDouble
();
return
true
;
}
else
{
errorString
.
append
(
"Could not load Maximum Altitude value!
\n
"
);
errorString
.
append
(
tr
(
"Could not load Maximum Altitude value!
\n
"
)
);
return
false
;
}
}
else
{
...
...
src/Wima/WimaController.cc
View file @
588989a0
...
...
@@ -225,7 +225,8 @@ bool WimaController::updateMission()
}
}
saveToFile
(
"TestFile"
);
//saveToFile("TestFile.wima");
//loadFromFile("TestFile.wima");
return
true
;
}
...
...
@@ -262,9 +263,112 @@ void WimaController::saveToFile(const QString& filename)
}
}
void
WimaController
::
loadFromFile
()
bool
WimaController
::
loadFromCurrent
()
{
return
loadFromFile
(
_currentFile
);
}
bool
WimaController
::
loadFromFile
(
const
QString
&
filename
)
{
QString
errorString
;
QString
errorMessage
=
tr
(
"Error loading Plan file (%1). %2"
).
arg
(
filename
).
arg
(
"%1"
);
if
(
filename
.
isEmpty
())
{
return
false
;
}
QFileInfo
fileInfo
(
filename
);
QFile
file
(
filename
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
errorString
=
file
.
errorString
()
+
QStringLiteral
(
" "
)
+
filename
;
qgcApp
()
->
showMessage
(
errorMessage
.
arg
(
errorString
));
return
false
;
}
if
(
fileInfo
.
suffix
()
==
wimaFileExtension
)
{
QJsonDocument
jsonDoc
;
QByteArray
bytes
=
file
.
readAll
();
if
(
!
JsonHelper
::
isJsonFile
(
bytes
,
jsonDoc
,
errorString
))
{
qgcApp
()
->
showMessage
(
errorMessage
.
arg
(
errorString
));
return
false
;
}
QJsonObject
json
=
jsonDoc
.
object
();
QJsonArray
areaArray
=
json
[
"AreaItems"
].
toArray
();
_visualItems
->
clear
();
for
(
int
i
=
0
;
i
<
areaArray
.
size
();
i
++
)
{
QJsonObject
jsonArea
=
areaArray
[
i
].
toObject
();
if
(
jsonArea
.
contains
(
WimaArea
::
areaTypeName
)
&&
jsonArea
[
WimaArea
::
areaTypeName
].
isString
())
{
if
(
jsonArea
[
WimaArea
::
areaTypeName
]
==
WimaArea
::
wimaAreaName
)
{
WimaArea
*
area
=
new
WimaArea
(
this
);
bool
success
=
area
->
loadFromJson
(
jsonArea
,
errorString
);
if
(
!
success
)
{
qgcApp
()
->
showMessage
(
errorMessage
.
arg
(
errorString
));
return
false
;
}
_visualItems
->
append
(
area
);
emit
visualItemsChanged
();
}
else
if
(
jsonArea
[
WimaArea
::
areaTypeName
]
==
WimaGOperationArea
::
wimaGOperationAreaName
)
{
WimaGOperationArea
*
opArea
=
new
WimaGOperationArea
(
this
);
bool
success
=
opArea
->
loadFromJson
(
jsonArea
,
errorString
);
if
(
!
success
)
{
qgcApp
()
->
showMessage
(
errorMessage
.
arg
(
errorString
));
return
false
;
}
_visualItems
->
append
(
opArea
);
emit
visualItemsChanged
();
}
else
if
(
jsonArea
[
WimaArea
::
areaTypeName
]
==
WimaServiceArea
::
wimaServiceAreaName
)
{
WimaServiceArea
*
serArea
=
new
WimaServiceArea
(
this
);
bool
success
=
serArea
->
loadFromJson
(
jsonArea
,
errorString
);
if
(
!
success
)
{
qgcApp
()
->
showMessage
(
errorMessage
.
arg
(
errorString
));
return
false
;
}
_visualItems
->
append
(
serArea
);
emit
visualItemsChanged
();
}
else
if
(
jsonArea
[
WimaArea
::
areaTypeName
]
==
WimaVCorridor
::
wimaVCorridorName
)
{
WimaVCorridor
*
corridor
=
new
WimaVCorridor
(
this
);
bool
success
=
corridor
->
loadFromJson
(
jsonArea
,
errorString
);
if
(
!
success
)
{
qgcApp
()
->
showMessage
(
errorMessage
.
arg
(
errorString
));
return
false
;
}
_visualItems
->
append
(
corridor
);
emit
visualItemsChanged
();
}
else
{
errorString
+=
QString
(
tr
(
"%s not supported.
\n
"
).
arg
(
WimaArea
::
areaTypeName
));
qgcApp
()
->
showMessage
(
errorMessage
.
arg
(
errorString
));
return
false
;
}
}
else
{
errorString
+=
QString
(
tr
(
"Invalid or non existing entry for %s.
\n
"
).
arg
(
WimaArea
::
areaTypeName
));
return
false
;
}
}
_currentFile
.
sprintf
(
"%s/%s.%s"
,
fileInfo
.
path
().
toLocal8Bit
().
data
(),
fileInfo
.
completeBaseName
().
toLocal8Bit
().
data
(),
wimaFileExtension
);
emit
currentFileChanged
();
return
true
;
}
else
{
errorString
+=
QString
(
tr
(
"File extension not supported.
\n
"
));
qgcApp
()
->
showMessage
(
errorMessage
.
arg
(
errorString
));
return
false
;
}
}
void
WimaController
::
recalcVehicleCorridor
()
...
...
@@ -347,8 +451,11 @@ QJsonDocument WimaController::saveToJson()
jsonArray
.
append
(
json
);
}
QJsonObject
json
;
json
[
"AreaItems"
]
=
jsonArray
;
return
QJsonDocument
(
json
Array
);
return
QJsonDocument
(
json
);
}
...
...
src/Wima/WimaController.h
View file @
588989a0
...
...
@@ -15,6 +15,9 @@
#include "SimpleMissionItem.h"
#include "MissionSettingsItem.h"
#include "JsonHelper.h"
#include "QGCApplication.h"
class
WimaController
:
public
QObject
{
...
...
@@ -27,9 +30,9 @@ public:
Q_PROPERTY
(
MissionController
*
missionController
READ
missionController
WRITE
setMissionController
NOTIFY
missionControllerChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
visualItems
READ
visualItems
NOTIFY
visualItemsChanged
)
Q_PROPERTY
(
int
currentPolygonIndex
READ
currentPolygonIndex
WRITE
setCurrentPolygonIndex
NOTIFY
currentPolygonIndexChanged
)
Q_PROPERTY
(
const
QString
currentFile
READ
currentFile
NOTIFY
currentFileChanged
)
Q_PROPERTY
(
QString
currentFile
READ
currentFile
NOTIFY
currentFileChanged
)
Q_PROPERTY
(
QStringList
loadNameFilters
READ
loadNameFilters
CONSTANT
)
Q_PROPERTY
(
QString
fileExtens
tion
READ
fileExtenstion
CONSTANT
)
Q_PROPERTY
(
QString
fileExtens
ion
READ
fileExtension
CONSTANT
)
// Property accessors
...
...
@@ -37,9 +40,9 @@ public:
MissionController
*
missionController
(
void
)
const
{
return
_missionController
;
}
QmlObjectListModel
*
visualItems
(
void
)
const
{
return
_visualItems
;
}
int
currentPolygonIndex
(
void
)
const
{
return
_currentPolygonIndex
;
}
const
QString
currentFile
(
void
)
const
{
return
_currentFile
;
}
QString
currentFile
(
void
)
const
{
return
_currentFile
;
}
QStringList
loadNameFilters
(
void
)
const
;
QString
fileExtens
t
ion
(
void
)
const
{
return
wimaFileExtension
;
}
QString
fileExtension
(
void
)
const
{
return
wimaFileExtension
;
}
...
...
@@ -66,7 +69,8 @@ public:
Q_INVOKABLE
void
saveToCurrent
();
Q_INVOKABLE
void
saveToFile
(
const
QString
&
filename
);
Q_INVOKABLE
void
loadFromFile
();
Q_INVOKABLE
bool
loadFromCurrent
();
Q_INVOKABLE
bool
loadFromFile
(
const
QString
&
filename
);
Q_INVOKABLE
void
resetAllInteractive
(
void
);
Q_INVOKABLE
void
setInteractive
(
void
);
...
...
src/Wima/WimaGOperationArea.cc
View file @
588989a0
...
...
@@ -91,28 +91,28 @@ bool WimaGOperationArea::loadFromJson(const QJsonObject &json, QString& errorStr
if
(
json
.
contains
(
bottomLayerAltitudeName
)
&&
json
[
bottomLayerAltitudeName
].
isDouble
()
)
{
_bottomLayerAltitude
.
setRawValue
(
json
[
bottomLayerAltitudeName
].
toDouble
());
}
else
{
errorString
.
append
(
"Could not load Bottom Layer Altitude!
\n
"
);
errorString
.
append
(
tr
(
"Could not load Bottom Layer Altitude!
\n
"
)
);
retVal
=
false
;
}
if
(
json
.
contains
(
numberOfLayersName
)
&&
json
[
numberOfLayersName
].
isDouble
()
)
{
_numberOfLayers
.
setRawValue
(
json
[
numberOfLayersName
].
toInt
());
}
else
{
errorString
.
append
(
"Could not load Number of Layers!
\n
"
);
errorString
.
append
(
tr
(
"Could not load Number of Layers!
\n
"
)
);
retVal
=
false
;
}
if
(
json
.
contains
(
layerDistanceName
)
&&
json
[
layerDistanceName
].
isDouble
()
)
{
_layerDistance
.
setRawValue
(
json
[
layerDistanceName
].
toDouble
());
}
else
{
errorString
.
append
(
"Could not load Layer Distance!
\n
"
);
errorString
.
append
(
tr
(
"Could not load Layer Distance!
\n
"
)
);
retVal
=
false
;
}
if
(
json
.
contains
(
borderPolygonOffsetName
)
&&
json
[
borderPolygonOffsetName
].
isDouble
()
)
{
_borderPolygonOffset
.
setRawValue
(
json
[
borderPolygonOffsetName
].
toDouble
());
}
else
{
errorString
.
append
(
"Could not load Border Polygon Offset!
\n
"
);
errorString
.
append
(
tr
(
"Could not load Border Polygon Offset!
\n
"
)
);
retVal
=
false
;
}
...
...
src/WimaView/WimaView.qml
View file @
588989a0
...
...
@@ -58,6 +58,7 @@ QGCView {
property
var
_planMasterController
:
masterController
property
var
_missionController
:
_planMasterController
.
missionController
property
var
_visualItems
:
_missionController
.
visualItems
property
var
_wimaVisualItems
:
_wimaController
.
visualItems
property
bool
_lightWidgetBorders
:
editorMap
.
isSatelliteMap
property
bool
_addWaypointOnClick
:
false
property
bool
_addROIOnClick
:
false
...
...
@@ -185,6 +186,14 @@ QGCView {
wimaFileDialog
.
fileExtension
=
wimaController
.
fileExtension
wimaFileDialog
.
openForLoad
()
}
function
saveToSelectedFile
()
{
wimaFileDialog
.
title
=
qsTr
(
"
Save to Wima File
"
)
wimaFileDialog
.
selectExisting
=
false
wimaFileDialog
.
nameFilters
=
wimaController
.
loadNameFilters
wimaFileDialog
.
fileExtension
=
wimaController
.
fileExtension
wimaFileDialog
.
openForSave
()
}
}
PlanMasterController
{
...
...
@@ -1032,12 +1041,13 @@ QGCView {
QGCLabel
{
width
:
sendSaveGrid
.
width
wrapMode
:
Text
.
WordWrap
text
:
masterController
.
dirty
?
text
:
"
unsaved changes not yet implemented
"
/*masterController.dirty ?
(_activeVehicle ?
qsTr("You have unsaved changes. You should upload to your vehicle, or save to a file:") :
qsTr("You have unsaved changes.")
) :
qsTr
(
"
Plan File:
"
)
qsTr("Plan File:")
*/
}
GridLayout
{
...
...
@@ -1048,9 +1058,9 @@ QGCView {
columnSpacing
:
ScreenTools
.
defaultFontPixelWidth
QGCButton
{
text
:
qsTr
(
"
New...
"
)
text
:
qsTr
(
"
New...
ToDo
"
)
Layout.fillWidth
:
true
enabled
:
_
v
isualItems
.
count
>
1
enabled
:
_
wimaV
isualItems
.
count
>
1
onClicked
:
{
dropPanel
.
hide
()
_qgcView
.
showDialog
(
removeAllPromptDialog
,
qsTr
(
"
New Plan
"
),
_qgcView
.
showDialogDefaultWidth
,
StandardButton
.
Yes
|
StandardButton
.
No
)
...
...
@@ -1058,44 +1068,36 @@ QGCView {
}
QGCButton
{
text
:
qsTr
(
"
Open...
"
)
text
:
qsTr
(
"
Open...
Testing
"
)
Layout.fillWidth
:
true
enabled
:
!
masterController
.
syncInProgress
enabled
:
true
//
!masterController.syncInProgress
onClicked
:
{
dropPanel
.
hide
()
if
(
masterController
.
dirty
)
{
_qgcView
.
showDialog
(
syncLoadFromFileOverwrite
,
columnHolder
.
_overwriteText
,
_qgcView
.
showDialogDefaultWidth
,
StandardButton
.
Yes
|
StandardButton
.
Cancel
)
}
else
{
masterController
.
loadFromSelectedFile
()
}
wimaController
.
loadFromSelectedFile
()
}
}
QGCButton
{
text
:
qsTr
(
"
Save
"
)
text
:
qsTr
(
"
Save
Testing
"
)
Layout.fillWidth
:
true
enabled
:
!
masterController
.
syncInProgress
&&
masterController
.
currentPlan
File
!==
""
enabled
:
wimaController
.
current
File
!==
""
onClicked
:
{
dropPanel
.
hide
()
if
(
masterController
.
currentPlanFile
!==
""
)
{
masterController
.
saveToCurrent
()
}
else
{
masterController
.
saveToSelectedFile
()
}
wimaController
.
saveToCurrent
()
}
}
QGCButton
{
text
:
qsTr
(
"
Save As...
"
)
Layout.fillWidth
:
true
enabled
:
!
masterController
.
syncInProgress
&&
_v
isualItems
.
count
>
1
enabled
:
_wimaV
isualItems
.
count
>
1
onClicked
:
{
dropPanel
.
hide
()
masterController
.
saveToSelectedFile
()
}
}
QGCButton
{
/*
QGCButton {
text: qsTr("Save Mission Waypoints As KML...")
Layout.columnSpan: 2
enabled: !masterController.syncInProgress && _visualItems.count > 1
...
...
@@ -1108,7 +1110,7 @@ QGCView {
dropPanel.hide()
masterController.saveKmlToSelectedFile()
}
}
}
*/
Rectangle
{
width
:
parent
.
width
*
0.8
...
...
@@ -1121,7 +1123,7 @@ QGCView {
}
QGCButton
{
text
:
qsTr
(
"
Upload
"
)
text
:
qsTr
(
"
Upload
ToDo
"
)
Layout.fillWidth
:
true
enabled
:
!
masterController
.
offline
&&
!
masterController
.
syncInProgress
&&
_visualItems
.
count
>
1
visible
:
!
QGroundControl
.
corePlugin
.
options
.
disableVehicleConnection
...
...
@@ -1132,7 +1134,7 @@ QGCView {
}
QGCButton
{
text
:
qsTr
(
"
Download
"
)
text
:
qsTr
(
"
Download
ToDo
"
)
Layout.fillWidth
:
true
enabled
:
!
masterController
.
offline
&&
!
masterController
.
syncInProgress
visible
:
!
QGroundControl
.
corePlugin
.
options
.
disableVehicleConnection
...
...
@@ -1147,7 +1149,7 @@ QGCView {
}
QGCButton
{
text
:
qsTr
(
"
Clear Vehicle Mission
"
)
text
:
qsTr
(
"
Clear Vehicle Mission
ToDo
"
)
Layout.fillWidth
:
true
Layout.columnSpan
:
2
enabled
:
!
masterController
.
offline
&&
!
masterController
.
syncInProgress
...
...
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