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
20b7fce7
Commit
20b7fce7
authored
Jul 23, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for adjusting existing survey polygon
parent
8ba8c2c1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
154 additions
and
19 deletions
+154
-19
FlightMap.qml
src/FlightMap/FlightMap.qml
+123
-13
SurveyItemEditor.qml
src/MissionEditor/SurveyItemEditor.qml
+22
-6
ComplexMissionItem.cc
src/MissionManager/ComplexMissionItem.cc
+8
-0
ComplexMissionItem.h
src/MissionManager/ComplexMissionItem.h
+1
-0
No files found.
src/FlightMap/FlightMap.qml
View file @
20b7fce7
...
...
@@ -137,11 +137,11 @@ Map {
// Connections {
// target: map.polygonDraw
//
// onPolygonStarted: {
// onPolygon
Capture
Started: {
// // Polygon creation has started
// }
//
// onPolygonFinished: {
// onPolygon
Capture
Finished: {
// // Polygon capture complete, coordinates signal variable contains the polygon points
// }
// }
...
...
@@ -161,6 +161,30 @@ Map {
horizontalAlignment
:
Text
.
AlignHCenter
text
:
qsTr
(
"
Click to add point %1
"
).
arg
(
ScreenTools
.
isMobile
||
!
polygonDrawer
.
polygonReady
?
""
:
qsTr
(
"
- Right Click to end polygon
"
))
visible
:
polygonDrawer
.
drawingPolygon
Connections
{
target
:
polygonDrawer
onDrawingPolygonChanged
:
{
if
(
polygonDrawer
.
drawingPolygon
)
{
polygonHelp
.
text
=
qsTr
(
"
Click to add point
"
)
}
polygonHelp
.
visible
=
polygonDrawer
.
drawingPolygon
}
onPolygonReadyChanged
:
{
if
(
polygonDrawer
.
polygonReady
&&
!
ScreenTools
.
isMobile
)
{
polygonHelp
.
text
=
qsTr
(
"
Click to add point - Right Click to end polygon
"
)
}
}
onAdjustingPolygonChanged
:
{
if
(
polygonDrawer
.
adjustingPolygon
)
{
polygonHelp
.
text
=
qsTr
(
"
Adjust polygon by dragging corners
"
)
}
polygonHelp
.
visible
=
polygonDrawer
.
adjustingPolygon
}
}
}
MouseArea
{
...
...
@@ -171,27 +195,39 @@ Map {
z
:
1000
// Hack to fix MouseArea layering for now
property
alias
drawingPolygon
:
polygonDrawer
.
hoverEnabled
property
bool
adjustingPolygon
:
false
property
bool
polygonReady
:
polygonDrawerPolygon
.
path
.
length
>
3
///< true: enough points have been captured to create a closed polygon
/// New polygon capture has started
signal
polygonStarted
signal
polygon
Capture
Started
/// Polygon capture is complete
/// @param coordinates Map coordinates for the polygon points
signal
polygonFinished
(
var
coordinates
)
signal
polygonCaptureFinished
(
var
coordinates
)
/// Polygon adjustment has begun
signal
polygonAdjustStarted
/// Polygon Vertex coordinate has been adjusted
signal
polygonAdjustVertex
(
int
vertexIndex
,
var
vertexCoordinate
)
/// Polygon adjustment finished
signal
polygonAdjustFinished
property
var
_vertexDragList
:
[]
/// Begin capturing a new polygon
/// polygonStarted will be signalled
function
startPolygon
()
{
/// polygon
Capture
Started will be signalled
function
start
Capture
Polygon
()
{
polygonDrawer
.
drawingPolygon
=
true
polygonDrawer
.
_clearPolygon
()
polygonDrawer
.
polygonStarted
()
polygonDrawer
.
polygon
Capture
Started
()
}
/// Finish capturing the polygon
/// polygonFinished will be signalled
/// polygon
Capture
Finished will be signalled
/// @return true: polygon completed, false: not enough points to complete polygon
function
finishPolygon
()
{
function
finish
Capture
Polygon
()
{
if
(
!
polygonDrawer
.
polygonReady
)
{
return
false
}
...
...
@@ -200,10 +236,82 @@ Map {
polygonPath
.
pop
()
// get rid of drag coordinate
polygonDrawer
.
_clearPolygon
()
polygonDrawer
.
drawingPolygon
=
false
polygonDrawer
.
polygonFinished
(
polygonPath
)
polygonDrawer
.
polygon
Capture
Finished
(
polygonPath
)
return
true
}
function
startAdjustPolygon
(
vertexCoordinates
)
{
polygonDrawer
.
adjustingPolygon
=
true
for
(
var
i
=
0
;
i
<
vertexCoordinates
.
length
;
i
++
)
{
var
mapItem
=
Qt
.
createQmlObject
(
"
import QtQuick 2.5;
"
+
"
import QtLocation 5.3;
"
+
"
import QGroundControl.ScreenTools 1.0;
"
+
"
Rectangle {
"
+
"
id: vertexDrag;
"
+
"
width: _sideLength;
"
+
"
height: _sideLength;
"
+
"
color: 'red';
"
+
""
+
"
property var coordinate;
"
+
"
property int index;
"
+
""
+
"
readonly property real _sideLength: ScreenTools.defaultFontPixelWidth * 2;
"
+
"
readonly property real _halfSideLength: _sideLength / 2;
"
+
""
+
"
Drag.active: dragMouseArea.drag.active;
"
+
"
Drag.hotSpot.x: _halfSideLength;
"
+
"
Drag.hotSpot.y: _halfSideLength;
"
+
""
+
"
onXChanged: updateCoordinate();
"
+
"
onYChanged: updateCoordinate();
"
+
""
+
"
function updateCoordinate() {
"
+
"
vertexDrag.coordinate = _map.toCoordinate(Qt.point(vertexDrag.x + _halfSideLength, vertexDrag.y + _halfSideLength), false);
"
+
"
polygonDrawer.polygonAdjustVertex(vertexDrag.index, vertexDrag.coordinate);
"
+
"
}
"
+
""
+
"
function updatePosition() {
"
+
"
var vertexPoint = _map.fromCoordinate(coordinate, false);
"
+
"
vertexDrag.x = vertexPoint.x - _halfSideLength;
"
+
"
vertexDrag.y = vertexPoint.y - _halfSideLength;
"
+
"
}
"
+
""
+
"
Connections {
"
+
"
target: _map;
"
+
"
onCenterChanged: updatePosition();
"
+
"
onZoomLevelChanged: updatePosition();
"
+
"
}
"
+
""
+
"
MouseArea {
"
+
"
id: dragMouseArea;
"
+
"
anchors.fill: parent;
"
+
"
drag.target: parent;
"
+
"
drag.minimumX: 0;
"
+
"
drag.minimumY: 0;
"
+
"
drag.maximumX: _map.width - parent.width;
"
+
"
drag.maximumY: _map.height - parent.height;
"
+
"
}
"
+
"
}
"
,
_map
)
mapItem
.
z
=
QGroundControl
.
zOrderMapItems
+
1
mapItem
.
coordinate
=
vertexCoordinates
[
i
]
mapItem
.
index
=
i
mapItem
.
updatePosition
()
polygonDrawer
.
_vertexDragList
.
push
(
mapItem
)
polygonDrawer
.
polygonAdjustStarted
()
}
}
function
finishAdjustPolygon
()
{
polygonDrawer
.
adjustingPolygon
=
false
for
(
var
i
=
0
;
i
<
polygonDrawer
.
_vertexDragList
.
length
;
i
++
)
{
polygonDrawer
.
_vertexDragList
[
i
].
destroy
()
}
polygonDrawer
.
_vertexDragList
=
[]
polygonDrawer
.
polygonAdjustFinished
()
}
function
_clearPolygon
()
{
// Simpler methods to clear the path simply don't work due to bugs. This craziness does.
var
bogusCoord
=
_map
.
toCoordinate
(
Qt
.
point
(
height
/
2
,
width
/
2
))
...
...
@@ -242,7 +350,7 @@ Map {
polygonPath
.
push
(
clickCoordinate
)
polygonDrawerPolygon
.
path
=
polygonPath
}
else
if
(
polygonDrawer
.
polygonReady
)
{
finishPolygon
()
finish
Capture
Polygon
()
}
}
...
...
@@ -261,6 +369,7 @@ Map {
}
}
/// Polygon being drawn
MapPolygon
{
id
:
polygonDrawerPolygon
color
:
"
blue
"
...
...
@@ -268,6 +377,7 @@ Map {
visible
:
polygonDrawer
.
drawingPolygon
}
/// Next line for polygon
MapPolyline
{
id
:
polygonDrawerNextPoint
line.color
:
"
green
"
...
...
src/MissionEditor/SurveyItemEditor.qml
View file @
20b7fce7
...
...
@@ -101,26 +101,42 @@ Rectangle {
Connections
{
target
:
editorMap
.
polygonDraw
onPolygonStarted
:
{
onPolygon
Capture
Started
:
{
missionItem
.
clearPolygon
()
}
onPolygonFinished
:
{
onPolygon
Capture
Finished
:
{
for
(
var
i
=
0
;
i
<
coordinates
.
length
;
i
++
)
{
missionItem
.
addPolygonCoordinate
(
coordinates
[
i
])
}
}
onPolygonAdjustVertex
:
missionItem
.
adjustPolygonCoordinate
(
vertexIndex
,
vertexCoordinate
)
}
QGCButton
{
text
:
editorMap
.
polygonDraw
.
drawingPolygon
?
qsTr
(
"
Finish Polygon
"
)
:
qsTr
(
"
Draw Polygon
"
)
enabled
:
(
editorMap
.
polygonDraw
.
drawingPolygon
&&
editorMap
.
polygonDraw
.
polygonReady
)
||
!
editorMap
.
polygonDraw
.
drawingPolygon
text
:
editorMap
.
polygonDraw
.
drawingPolygon
?
qsTr
(
"
Finish Draw
"
)
:
qsTr
(
"
Draw Polygon
"
)
enabled
:
((
editorMap
.
polygonDraw
.
drawingPolygon
&&
editorMap
.
polygonDraw
.
polygonReady
)
||
!
editorMap
.
polygonDraw
.
drawingPolygon
)
&&
!
editorMap
.
polygonDraw
.
adjustingPolygon
onClicked
:
{
if
(
editorMap
.
polygonDraw
.
drawingPolygon
)
{
editorMap
.
polygonDraw
.
finishPolygon
()
editorMap
.
polygonDraw
.
finishCapturePolygon
()
}
else
{
editorMap
.
polygonDraw
.
startCapturePolygon
()
}
}
}
QGCButton
{
text
:
editorMap
.
polygonDraw
.
adjustingPolygon
?
qsTr
(
"
Finish Adjust
"
)
:
qsTr
(
"
Adjust Polygon
"
)
enabled
:
!
editorMap
.
polygonDraw
.
drawingPolygon
onClicked
:
{
if
(
editorMap
.
polygonDraw
.
adjustingPolygon
)
{
editorMap
.
polygonDraw
.
finishAdjustPolygon
()
}
else
{
editorMap
.
polygonDraw
.
start
Polygon
(
)
editorMap
.
polygonDraw
.
start
AdjustPolygon
(
missionItem
.
polygonPath
)
}
}
}
...
...
src/MissionManager/ComplexMissionItem.cc
View file @
20b7fce7
...
...
@@ -87,6 +87,14 @@ void ComplexMissionItem::addPolygonCoordinate(const QGeoCoordinate coordinate)
setDirty
(
true
);
}
void
ComplexMissionItem
::
adjustPolygonCoordinate
(
int
vertexIndex
,
const
QGeoCoordinate
coordinate
)
{
_polygonPath
[
vertexIndex
]
=
QVariant
::
fromValue
(
coordinate
);
emit
polygonPathChanged
();
_generateGrid
();
setDirty
(
true
);
}
int
ComplexMissionItem
::
lastSequenceNumber
(
void
)
const
{
int
lastSeq
=
_sequenceNumber
;
...
...
src/MissionManager/ComplexMissionItem.h
View file @
20b7fce7
...
...
@@ -37,6 +37,7 @@ public:
Q_INVOKABLE
void
clearPolygon
(
void
);
Q_INVOKABLE
void
addPolygonCoordinate
(
const
QGeoCoordinate
coordinate
);
Q_INVOKABLE
void
adjustPolygonCoordinate
(
int
vertexIndex
,
const
QGeoCoordinate
coordinate
);
QVariantList
polygonPath
(
void
)
{
return
_polygonPath
;
}
QVariantList
gridPoints
(
void
)
{
return
_gridPoints
;
}
...
...
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