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
118a8e16
Commit
118a8e16
authored
Oct 16, 2020
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
service area depot issue solved.
parent
de75bd19
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
205 additions
and
163 deletions
+205
-163
QGCMapPolygon.h
src/MissionManager/QGCMapPolygon.h
+124
-118
WimaServiceArea.cc
src/Wima/Geometry/WimaServiceArea.cc
+28
-2
WimaServiceArea.h
src/Wima/Geometry/WimaServiceArea.h
+4
-2
EmptyManager.cpp
src/Wima/WaypointManager/EmptyManager.cpp
+4
-4
DragCoordinate.qml
src/WimaView/DragCoordinate.qml
+12
-13
WimaServiceAreaMapVisual.qml
src/WimaView/WimaServiceAreaMapVisual.qml
+33
-24
No files found.
src/MissionManager/QGCMapPolygon.h
View file @
118a8e16
...
@@ -10,139 +10,145 @@
...
@@ -10,139 +10,145 @@
#ifndef QGCMapPolygon_H
#ifndef QGCMapPolygon_H
#define QGCMapPolygon_H
#define QGCMapPolygon_H
#include <QObject>
#include <QGeoCoordinate>
#include <QGeoCoordinate>
#include <Q
VariantLis
t>
#include <Q
Objec
t>
#include <QPolygon>
#include <QPolygon>
#include <QVariantList>
#include "QmlObjectListModel.h"
#include "QmlObjectListModel.h"
/// The QGCMapPolygon class provides a polygon which can be displayed on a map
using a map visuals control.
/// The QGCMapPolygon class provides a polygon which can be displayed on a map
///
It maintains a representation of the polygon on QVariantList and QmlObjectListModel format.
///
using a map visuals control. It maintains a representation of the polygon on
class
QGCMapPolygon
:
public
QObject
/// QVariantList and QmlObjectListModel format.
{
class
QGCMapPolygon
:
public
QObject
{
Q_OBJECT
Q_OBJECT
public:
public:
QGCMapPolygon
(
QObject
*
parent
=
nullptr
);
QGCMapPolygon
(
QObject
*
parent
=
nullptr
);
QGCMapPolygon
(
const
QGCMapPolygon
&
other
,
QObject
*
parent
=
nullptr
);
QGCMapPolygon
(
const
QGCMapPolygon
&
other
,
QObject
*
parent
=
nullptr
);
const
QGCMapPolygon
&
operator
=
(
const
QGCMapPolygon
&
other
);
const
QGCMapPolygon
&
operator
=
(
const
QGCMapPolygon
&
other
);
Q_PROPERTY
(
int
count
READ
count
NOTIFY
countChanged
)
Q_PROPERTY
(
int
count
READ
count
NOTIFY
countChanged
)
Q_PROPERTY
(
QVariantList
path
READ
path
NOTIFY
pathChanged
)
Q_PROPERTY
(
QVariantList
path
READ
path
NOTIFY
pathChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
pathModel
READ
qmlPathModel
CONSTANT
)
Q_PROPERTY
(
QmlObjectListModel
*
pathModel
READ
qmlPathModel
CONSTANT
)
Q_PROPERTY
(
bool
dirty
READ
dirty
WRITE
setDirty
NOTIFY
dirtyChanged
)
Q_PROPERTY
(
bool
dirty
READ
dirty
WRITE
setDirty
NOTIFY
dirtyChanged
)
Q_PROPERTY
(
QGeoCoordinate
center
READ
center
WRITE
setCenter
NOTIFY
centerChanged
)
Q_PROPERTY
(
Q_PROPERTY
(
bool
centerDrag
READ
centerDrag
WRITE
setCenterDrag
NOTIFY
centerDragChanged
)
QGeoCoordinate
center
READ
center
WRITE
setCenter
NOTIFY
centerChanged
)
Q_PROPERTY
(
bool
interactive
READ
interactive
WRITE
setInteractive
NOTIFY
interactiveChanged
)
Q_PROPERTY
(
bool
centerDrag
READ
centerDrag
WRITE
setCenterDrag
NOTIFY
Q_PROPERTY
(
double
area
READ
area
NOTIFY
areaChanged
)
centerDragChanged
)
Q_PROPERTY
(
bool
interactive
READ
interactive
WRITE
setInteractive
NOTIFY
Q_INVOKABLE
void
clear
(
void
);
interactiveChanged
)
Q_INVOKABLE
void
appendVertex
(
const
QGeoCoordinate
&
coordinate
);
Q_PROPERTY
(
double
area
READ
area
NOTIFY
areaChanged
)
Q_INVOKABLE
void
removeVertex
(
int
vertexIndex
);
Q_INVOKABLE
void
appendVertices
(
const
QList
<
QGeoCoordinate
>&
coordinates
);
Q_INVOKABLE
void
clear
(
void
);
Q_INVOKABLE
void
appendVertex
(
const
QGeoCoordinate
&
coordinate
);
/// Adjust the value for the specified coordinate
Q_INVOKABLE
void
removeVertex
(
int
vertexIndex
);
/// @param vertexIndex Polygon point index to modify (0-based)
Q_INVOKABLE
void
appendVertices
(
const
QList
<
QGeoCoordinate
>
&
coordinates
);
/// @param coordinate New coordinate for point
Q_INVOKABLE
void
adjustVertex
(
int
vertexIndex
,
const
QGeoCoordinate
coordinate
);
/// Adjust the value for the specified coordinate
/// @param vertexIndex Polygon point index to modify (0-based)
/// Splits the segment comprised of vertextIndex -> vertexIndex + 1
/// @param coordinate New coordinate for point
Q_INVOKABLE
void
splitPolygonSegment
(
int
vertexIndex
);
Q_INVOKABLE
void
adjustVertex
(
int
vertexIndex
,
const
QGeoCoordinate
coordinate
);
/// Returns true if the specified coordinate is within the polygon
Q_INVOKABLE
bool
containsCoordinate
(
const
QGeoCoordinate
&
coordinate
)
const
;
/// Splits the segment comprised of vertextIndex -> vertexIndex + 1
Q_INVOKABLE
void
splitPolygonSegment
(
int
vertexIndex
);
/// Offsets the current polygon edges by the specified distance in meters
Q_INVOKABLE
void
offset
(
double
distance
);
/// Returns true if the specified coordinate is within the polygon
Q_INVOKABLE
bool
containsCoordinate
(
const
QGeoCoordinate
&
coordinate
)
const
;
/// Loads a polygon from a KML/SH{ file
/// @return true: success
/// Offsets the current polygon edges by the specified distance in meters
Q_INVOKABLE
bool
loadKMLOrSHPFile
(
const
QString
&
file
);
Q_INVOKABLE
void
offset
(
double
distance
);
/// Returns the path in a list of QGeoCoordinate's format
/// Loads a polygon from a KML/SH{ file
QList
<
QGeoCoordinate
>
coordinateList
(
void
)
const
;
/// @return true: success
Q_INVOKABLE
bool
loadKMLOrSHPFile
(
const
QString
&
file
);
/// Returns the QGeoCoordinate for the vertex specified
Q_INVOKABLE
QGeoCoordinate
vertexCoordinate
(
int
vertex
)
const
;
/// Returns the path in a list of QGeoCoordinate's format
QList
<
QGeoCoordinate
>
coordinateList
(
void
)
const
;
/// Adjust polygon winding order to be clockwise (if needed)
Q_INVOKABLE
void
verifyClockwiseWinding
(
void
);
/// Returns the QGeoCoordinate for the vertex specified
Q_INVOKABLE
QGeoCoordinate
vertexCoordinate
(
int
vertex
)
const
;
/// Saves the polygon to the json object.
/// @param json Json object to save to
/// Adjust polygon winding order to be clockwise (if needed)
void
saveToJson
(
QJsonObject
&
json
);
Q_INVOKABLE
void
verifyClockwiseWinding
(
void
);
/// Load a polygon from json
/// Saves the polygon to the json object.
/// @param json Json object to load from
/// @param json Json object to save to
/// @param required true: no polygon in object will generate error
void
saveToJson
(
QJsonObject
&
json
);
/// @param errorString Error string if return is false
/// @return true: success, false: failure (errorString set)
/// Load a polygon from json
bool
loadFromJson
(
const
QJsonObject
&
json
,
bool
required
,
QString
&
errorString
);
/// @param json Json object to load from
/// @param required true: no polygon in object will generate error
/// Convert polygon to NED and return (D is ignored)
/// @param errorString Error string if return is false
QList
<
QPointF
>
nedPolygon
(
void
)
const
;
/// @return true: success, false: failure (errorString set)
bool
loadFromJson
(
const
QJsonObject
&
json
,
bool
required
,
/// Returns the area of the polygon in meters squared
QString
&
errorString
);
double
area
(
void
)
const
;
/// Convert polygon to NED and return (D is ignored)
// Property methods
QList
<
QPointF
>
nedPolygon
(
void
)
const
;
int
count
(
void
)
const
{
return
_polygonPath
.
count
();
}
/// Returns the area of the polygon in meters squared
bool
dirty
(
void
)
const
{
return
_dirty
;
}
double
area
(
void
)
const
;
void
setDirty
(
bool
dirty
);
QGeoCoordinate
center
(
void
)
const
{
return
_center
;
}
// Property methods
bool
centerDrag
(
void
)
const
{
return
_centerDrag
;
}
bool
interactive
(
void
)
const
{
return
_interactive
;
}
int
count
(
void
)
const
{
return
_polygonPath
.
count
();
}
bool
dirty
(
void
)
const
{
return
_dirty
;
}
QVariantList
path
(
void
)
const
{
return
_polygonPath
;
}
void
setDirty
(
bool
dirty
);
QmlObjectListModel
*
qmlPathModel
(
void
)
{
return
&
_polygonModel
;
}
QGeoCoordinate
center
(
void
)
const
{
return
_center
;
}
QmlObjectListModel
&
pathModel
(
void
)
{
return
_polygonModel
;
}
bool
centerDrag
(
void
)
const
{
return
_centerDrag
;
}
bool
interactive
(
void
)
const
{
return
_interactive
;
}
// Friends
friend
void
print
(
const
QGCMapPolygon
&
poly
,
QString
&
outputString
);
QVariantList
path
(
void
)
const
{
return
_polygonPath
;
}
friend
void
print
(
const
QGCMapPolygon
&
poly
);
const
QVariantList
&
pathReference
(
void
)
const
{
return
_polygonPath
;
}
QmlObjectListModel
*
qmlPathModel
(
void
)
{
return
&
_polygonModel
;
}
// static Variables
QmlObjectListModel
&
pathModel
(
void
)
{
return
_polygonModel
;
}
static
const
char
*
jsonPolygonKey
;
// Friends
friend
void
print
(
const
QGCMapPolygon
&
poly
,
QString
&
outputString
);
friend
void
print
(
const
QGCMapPolygon
&
poly
);
// static Variables
static
const
char
*
jsonPolygonKey
;
signals:
signals:
void
countChanged
(
int
count
);
void
countChanged
(
int
count
);
void
pathChanged
(
void
);
void
pathChanged
(
void
);
void
dirtyChanged
(
bool
dirty
);
void
dirtyChanged
(
bool
dirty
);
void
cleared
(
void
);
void
cleared
(
void
);
void
centerChanged
(
QGeoCoordinate
center
);
void
centerChanged
(
QGeoCoordinate
center
);
void
centerDragChanged
(
bool
centerDrag
);
void
centerDragChanged
(
bool
centerDrag
);
void
interactiveChanged
(
bool
interactive
);
void
interactiveChanged
(
bool
interactive
);
void
areaChanged
(
void
);
void
areaChanged
(
void
);
public
slots
:
public
slots
:
void
setPath
(
const
QList
<
QGeoCoordinate
>&
path
);
void
setPath
(
const
QList
<
QGeoCoordinate
>
&
path
);
void
setPath
(
const
QVector
<
QGeoCoordinate
>&
path
);
void
setPath
(
const
QVector
<
QGeoCoordinate
>
&
path
);
void
setPath
(
const
QVariantList
&
path
);
void
setPath
(
const
QVariantList
&
path
);
void
setCenter
(
QGeoCoordinate
newCenter
);
void
setCenter
(
QGeoCoordinate
newCenter
);
void
setCenterDrag
(
bool
centerDrag
);
void
setCenterDrag
(
bool
centerDrag
);
void
setInteractive
(
bool
interactive
);
void
setInteractive
(
bool
interactive
);
private
slots
:
private
slots
:
void
_polygonModelCountChanged
(
int
count
);
void
_polygonModelCountChanged
(
int
count
);
void
_polygonModelDirtyChanged
(
bool
dirty
);
void
_polygonModelDirtyChanged
(
bool
dirty
);
void
_updateCenter
(
void
);
void
_updateCenter
(
void
);
private:
private:
void
_init
(
void
);
void
_init
(
void
);
QPolygonF
_toPolygonF
(
void
)
const
;
QPolygonF
_toPolygonF
(
void
)
const
;
QGeoCoordinate
_coordFromPointF
(
const
QPointF
&
point
)
const
;
QGeoCoordinate
_coordFromPointF
(
const
QPointF
&
point
)
const
;
QPointF
_pointFFromCoord
(
const
QGeoCoordinate
&
coordinate
)
const
;
QPointF
_pointFFromCoord
(
const
QGeoCoordinate
&
coordinate
)
const
;
QVariantList
_polygonPath
;
QVariantList
_polygonPath
;
QmlObjectListModel
_polygonModel
;
QmlObjectListModel
_polygonModel
;
bool
_dirty
;
bool
_dirty
;
QGeoCoordinate
_center
;
QGeoCoordinate
_center
;
bool
_centerDrag
;
bool
_centerDrag
;
bool
_ignoreCenterUpdates
;
bool
_ignoreCenterUpdates
;
bool
_interactive
;
bool
_interactive
;
};
};
#endif
#endif
src/Wima/Geometry/WimaServiceArea.cc
View file @
118a8e16
...
@@ -23,10 +23,16 @@ WimaServiceArea &WimaServiceArea::operator=(const WimaServiceArea &other) {
...
@@ -23,10 +23,16 @@ WimaServiceArea &WimaServiceArea::operator=(const WimaServiceArea &other) {
return
*
this
;
return
*
this
;
}
}
const
QGeoCoordinate
&
WimaServiceArea
::
depot
()
const
{
return
_depot
;
}
QGeoCoordinate
WimaServiceArea
::
depotQml
()
const
{
return
_depot
;
}
bool
WimaServiceArea
::
setDepot
(
const
QGeoCoordinate
&
coordinate
)
{
bool
WimaServiceArea
::
setDepot
(
const
QGeoCoordinate
&
coordinate
)
{
if
(
_depot
!=
coordinate
)
{
if
(
_depot
.
latitude
()
!=
coordinate
.
latitude
()
||
_depot
.
longitude
()
!=
coordinate
.
longitude
())
{
if
(
this
->
containsCoordinate
(
coordinate
))
{
if
(
this
->
containsCoordinate
(
coordinate
))
{
_depot
=
coordinate
;
_depot
=
coordinate
;
_depot
.
setAltitude
(
0
);
emit
depotChanged
();
emit
depotChanged
();
return
true
;
return
true
;
}
}
...
@@ -90,7 +96,27 @@ void WimaServiceArea::init() {
...
@@ -90,7 +96,27 @@ void WimaServiceArea::init() {
this
->
setObjectName
(
wimaServiceAreaName
);
this
->
setObjectName
(
wimaServiceAreaName
);
connect
(
this
,
&
WimaArea
::
pathChanged
,
[
this
]
{
connect
(
this
,
&
WimaArea
::
pathChanged
,
[
this
]
{
if
(
!
this
->
_depot
.
isValid
()
||
!
this
->
containsCoordinate
(
this
->
_depot
))
{
if
(
!
this
->
_depot
.
isValid
()
||
!
this
->
containsCoordinate
(
this
->
_depot
))
{
this
->
setDepot
(
this
->
center
());
if
(
this
->
containsCoordinate
(
this
->
center
()))
{
// Use center.
this
->
setDepot
(
this
->
center
());
}
else
if
(
this
->
_depot
.
isValid
())
{
// Use nearest coordinate.
auto
minDist
=
std
::
numeric_limits
<
double
>::
infinity
();
auto
minIt
=
this
->
pathReference
().
begin
();
for
(
auto
it
=
this
->
pathReference
().
begin
();
it
<
this
->
pathReference
().
end
();
++
it
)
{
const
auto
vertex
=
it
->
value
<
QGeoCoordinate
>
();
auto
d
=
vertex
.
distanceTo
(
this
->
_depot
);
if
(
d
<
minDist
)
{
minDist
=
d
;
minIt
=
it
;
}
}
this
->
setDepot
(
minIt
->
value
<
QGeoCoordinate
>
());
}
else
if
(
this
->
pathReference
().
size
()
>
0
)
{
// Use first coordinate.
this
->
setDepot
(
this
->
pathReference
().
value
(
0
).
value
<
QGeoCoordinate
>
());
}
}
}
});
});
}
}
src/Wima/Geometry/WimaServiceArea.h
View file @
118a8e16
...
@@ -11,14 +11,16 @@ public:
...
@@ -11,14 +11,16 @@ public:
WimaServiceArea
(
const
WimaServiceArea
&
other
,
QObject
*
parent
);
WimaServiceArea
(
const
WimaServiceArea
&
other
,
QObject
*
parent
);
WimaServiceArea
&
operator
=
(
const
WimaServiceArea
&
other
);
WimaServiceArea
&
operator
=
(
const
WimaServiceArea
&
other
);
Q_PROPERTY
(
QGeoCoordinate
depot
READ
depot
WRITE
setDepot
NOTIFY
depotChanged
)
Q_PROPERTY
(
QGeoCoordinate
depot
READ
depotQml
WRITE
setDepot
NOTIFY
depotChanged
)
// Overrides from WimaPolygon
// Overrides from WimaPolygon
QString
mapVisualQML
(
void
)
const
{
return
"WimaServiceAreaMapVisual.qml"
;
}
QString
mapVisualQML
(
void
)
const
{
return
"WimaServiceAreaMapVisual.qml"
;
}
QString
editorQML
(
void
)
const
{
return
"WimaServiceAreaEditor.qml"
;
}
QString
editorQML
(
void
)
const
{
return
"WimaServiceAreaEditor.qml"
;
}
// Property acessors
// Property acessors
const
QGeoCoordinate
&
depot
(
void
)
const
{
return
_depot
;
}
const
QGeoCoordinate
&
depot
(
void
)
const
;
QGeoCoordinate
depotQml
(
void
)
const
;
// Member Methodes
// Member Methodes
void
saveToJson
(
QJsonObject
&
json
);
void
saveToJson
(
QJsonObject
&
json
);
...
...
src/Wima/WaypointManager/EmptyManager.cpp
View file @
118a8e16
...
@@ -7,12 +7,12 @@ WaypointManager::EmptyManager::EmptyManager(Settings &settings, AreaInterface &)
...
@@ -7,12 +7,12 @@ WaypointManager::EmptyManager::EmptyManager(Settings &settings, AreaInterface &)
void
WaypointManager
::
EmptyManager
::
clear
()
{}
void
WaypointManager
::
EmptyManager
::
clear
()
{}
bool
WaypointManager
::
EmptyManager
::
update
()
{}
bool
WaypointManager
::
EmptyManager
::
update
()
{
return
true
;
}
bool
WaypointManager
::
EmptyManager
::
next
()
{}
bool
WaypointManager
::
EmptyManager
::
next
()
{
return
true
;
}
bool
WaypointManager
::
EmptyManager
::
previous
()
{}
bool
WaypointManager
::
EmptyManager
::
previous
()
{
return
true
;
}
bool
WaypointManager
::
EmptyManager
::
reset
()
{}
bool
WaypointManager
::
EmptyManager
::
reset
()
{
return
true
;
}
}
// namespace WaypointManager
}
// namespace WaypointManager
src/WimaView/DragCoordinate.qml
View file @
118a8e16
...
@@ -29,10 +29,8 @@ Item {
...
@@ -29,10 +29,8 @@ Item {
property
bool
checked
property
bool
checked
property
string
label
:
"
Reference
"
property
string
label
:
"
Reference
"
property
var
_itemVisual
property
var
_itemVisual
:
undefined
property
bool
_itemVisualShowing
:
false
property
var
_dragArea
:
undefined
property
var
_dragArea
property
bool
_dragAreaShowing
:
false
signal
clicked
()
signal
clicked
()
signal
released
()
signal
released
()
...
@@ -45,31 +43,30 @@ Item {
...
@@ -45,31 +43,30 @@ Item {
signal
dragReleased
()
signal
dragReleased
()
function
hideItemVisuals
()
{
function
hideItemVisuals
()
{
if
(
_itemVisualShowing
)
{
if
(
_itemVisual
)
{
map
.
removeMapItem
(
_itemVisual
)
_itemVisual
.
destroy
()
_itemVisual
.
destroy
()
_itemVisual
Showing
=
false
_itemVisual
=
undefined
}
}
}
}
function
showItemVisuals
()
{
function
showItemVisuals
()
{
if
(
!
_itemVisual
Showing
)
{
if
(
!
_itemVisual
)
{
_itemVisual
=
indicatorComponent
.
createObject
(
map
)
_itemVisual
=
indicatorComponent
.
createObject
(
map
)
map
.
addMapItem
(
_itemVisual
)
map
.
addMapItem
(
_itemVisual
)
_itemVisualShowing
=
true
}
}
}
}
function
hideDragArea
()
{
function
hideDragArea
()
{
if
(
_dragArea
Showing
)
{
if
(
_dragArea
)
{
_dragArea
.
destroy
()
_dragArea
.
destroy
()
_dragArea
Showing
=
false
_dragArea
=
undefined
}
}
}
}
function
showDragArea
()
{
function
showDragArea
()
{
if
(
!
_dragArea
Showing
)
{
if
(
!
_dragArea
)
{
_dragArea
=
dragAreaComponent
.
createObject
(
map
)
_dragArea
=
dragAreaComponent
.
createObject
(
map
)
_dragAreaShowing
=
true
}
}
}
}
...
@@ -102,7 +99,9 @@ Item {
...
@@ -102,7 +99,9 @@ Item {
itemIndicator
:
_itemVisual
itemIndicator
:
_itemVisual
Component.onCompleted
:
itemCoordinate
=
_root
.
coordinate
Component.onCompleted
:
itemCoordinate
=
_root
.
coordinate
onItemCoordinateChanged
:
_root
.
coordinate
=
itemCoordinate
onItemCoordinateChanged
:
{
_root
.
coordinate
=
itemCoordinate
}
onDragStart
:
_root
.
dragStart
()
onDragStart
:
_root
.
dragStart
()
onDragStop
:
_root
.
dragStop
()
onDragStop
:
_root
.
dragStop
()
...
...
src/WimaView/WimaServiceAreaMapVisual.qml
View file @
118a8e16
...
@@ -26,35 +26,32 @@ Item {
...
@@ -26,35 +26,32 @@ Item {
property
var
areaItem
:
object
property
var
areaItem
:
object
property
var
_polygon
:
areaItem
property
var
_polygon
:
areaItem
property
var
_depot
property
var
_depot
:
undefined
property
bool
showDepot
:
areaItem
.
interactive
||
areaItem
.
borderPolygon
.
interactive
property
bool
_showDepot
:
areaItem
.
interactive
||
areaItem
.
borderPolygon
.
interactive
property
bool
_depotVisible
:
false
on_ShowDepotChanged
:
{
onShowDepotChanged
:
{
if
(
_showDepot
){
if
(
showDepot
){
_addDepot
()
if
(
!
_depotVisible
){
_addDepot
()
}
}
else
{
}
else
{
if
(
_depotVisible
){
_destroyDepot
()
_destroyDepot
()
}
}
}
}
}
signal
clicked
(
int
sequenceNumber
)
signal
clicked
(
int
sequenceNumber
)
function
_addDepot
()
{
function
_addDepot
()
{
_depot
=
depotPointComponent
.
createObject
(
map
)
if
(
!
_depot
){
map
.
addMapItem
(
_depot
)
_depot
=
depotPointComponent
.
createObject
(
_root
)
_depotVisible
=
true
map
.
addMapItem
(
_depot
)
}
}
}
function
_destroyDepot
()
{
function
_destroyDepot
()
{
if
(
_depot
){
if
(
_depot
){
map
.
removeMapItem
(
_depot
)
_depot
.
destroy
()
_depot
.
destroy
()
_depot
=
undefined
}
}
_depotVisible
=
false
}
}
/// Add an initial 4 sided polygon if there is none
/// Add an initial 4 sided polygon if there is none
...
@@ -104,7 +101,7 @@ Item {
...
@@ -104,7 +101,7 @@ Item {
Component.onCompleted
:
{
Component.onCompleted
:
{
_addInitialPolygon
()
_addInitialPolygon
()
if
(
showDepot
){
if
(
_
showDepot
){
_addDepot
()
_addDepot
()
}
}
}
}
...
@@ -137,21 +134,33 @@ Item {
...
@@ -137,21 +134,33 @@ Item {
Component
{
Component
{
id
:
depotPointComponent
id
:
depotPointComponent
DragCoordinate
{
DragCoordinate
{
property
var
depot
:
areaItem
.
depot
property
var
depot
:
_root
.
areaItem
.
depot
map
:
_root
.
map
map
:
_root
.
map
qgcView
:
_root
.
qgcView
qgcView
:
_root
.
qgcView
z
:
QGroundControl
.
zOrderMapItems
z
:
QGroundControl
.
zOrderMapItems
checked
:
showDepot
checked
:
_root
.
_
showDepot
coordinate
:
depot
coordinate
:
_root
.
areaItem
.
depot
label
:
"
Depot
"
label
:
"
Depot
"
onDragReleased
:
{
function
syncAndBind
(){
if
(
areaItem
.
containsCoordinate
(
coordinate
)){
if
(
coordinate
.
latitude
!==
depot
.
latitude
||
areaItem
.
depot
=
coordinate
coordinate
.
longitude
!==
depot
.
longitude
){
if
(
_root
.
areaItem
.
containsCoordinate
(
coordinate
)){
_root
.
areaItem
.
depot
=
coordinate
}
}
}
coordinate
=
Qt
.
binding
(
function
()
{
return
areaItem
.
depot
;
})
coordinate
=
Qt
.
binding
(
function
()
{
return
_root
.
areaItem
.
depot
})
}
}
onDragReleased
:
{
syncAndBind
()
}
Component.onCompleted
:
{
syncAndBind
()
}
}
}
}
}
...
...
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