QGCMapPolygonControls.qml 2.45 KB
Newer Older
1 2
import QtQuick          2.3
import QtQuick.Controls 1.2
3 4 5 6 7 8 9 10 11 12 13 14 15 16

import QGroundControl.ScreenTools   1.0
import QGroundControl.Controls      1.0
import QGroundControl.Palette       1.0

/// Controls for drawing/editing map polygon
Column {
    id:     root
    spacing: _margin

    property var sectionLabel: qsTr("Polygon:") ///< Section label
    property var flightMap                      ///< Must be set to FlightMap control
    property var polygon                        ///< Must be set to MapPolygon

17 18
    signal polygonEditCompleted ///< Signalled when either a capture or adjust has completed

19 20 21 22 23 24 25 26
    property real _margin: ScreenTools.defaultFontPixelWidth / 2

    function polygonCaptureStarted() {
        polygon.clear()
    }

    function polygonCaptureFinished(coordinates) {
        polygon.path = coordinates
27
        polygonEditCompleted()
28 29 30 31 32 33 34
    }

    function polygonAdjustVertex(vertexIndex, vertexCoordinate) {
        polygon.adjustCoordinate(vertexIndex, vertexCoordinate)
    }

    function polygonAdjustStarted() { }
35 36 37 38

    function polygonAdjustFinished() {
        polygonEditCompleted()
    }
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

    QGCLabel { text: sectionLabel }

    Rectangle {
        anchors.left:   parent.left
        anchors.right:  parent.right
        height:         1
        color:          qgcPal.text
    }

    Row {
        spacing: ScreenTools.defaultFontPixelWidth

        QGCButton {
            text:       flightMap.polygonDraw.drawingPolygon ? qsTr("Finish Draw") : qsTr("Draw")
            visible:    !flightMap.polygonDraw.adjustingPolygon
            enabled:    ((flightMap.polygonDraw.drawingPolygon && flightMap.polygonDraw.polygonReady) || !flightMap.polygonDraw.drawingPolygon)

            onClicked: {
                if (flightMap.polygonDraw.drawingPolygon) {
                    flightMap.polygonDraw.finishCapturePolygon()
                } else {
                    flightMap.polygonDraw.startCapturePolygon(root)
                }
            }
        }

        QGCButton {
            text:       flightMap.polygonDraw.adjustingPolygon ? qsTr("Finish Adjust") : qsTr("Adjust")
            visible:    polygon.path.length > 0 && !flightMap.polygonDraw.drawingPolygon

            onClicked: {
                if (flightMap.polygonDraw.adjustingPolygon) {
                    flightMap.polygonDraw.finishAdjustPolygon()
                } else {
                    flightMap.polygonDraw.startAdjustPolygon(root, polygon.path)
                }
            }
        }
    }
}