WimaPlanMapItems.qml 2.72 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

import QtQuick          2.3
import QtLocation       5.3
import QtPositioning    5.3

import QGroundControl           1.0
import QGroundControl.Controls  1.0
import QGroundControl.FlightMap 1.0

// Adds visual items generated by wima planer to the map.
Item {
    id: _root

22 23
    property var        map                 ///< Map control to show items on
    property bool       largeMapView        ///< true: map takes up entire view, false: map is in small window
24 25 26 27 28
    property string     color: "green"      // Mission Items Color
    property var        missionItems
    property var        path
    property var        zOrderWP
    property var        zOrderLines
29

30
    property var    _map: map
31 32
    property var    _missionLineViewComponent

Valentin Platzgummer's avatar
Valentin Platzgummer committed
33
    property var zoom: map.zoomLevel
34
    property bool showItems:        true
35

Valentin Platzgummer's avatar
Valentin Platzgummer committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
//    onZoomChanged: {
//        console.log('zoomLevel')
//        console.log(zoom)
//    }

    function hideNumber() {
        if (zoom > 19.5) {
            return 1
        } else if (zoom > 19) {
            return 2
        } else if (zoom > 17) {
            return 4
        } else if (zoom > 14) {
            return 8
        } else {
            return -1
        }

    }

56 57
    Component {
        id: missionLineViewComponent
58

59 60 61 62 63
        MapPolyline {
            line.width: 3
            line.color: showItems ? _root.color : "transparent"
            path:       _root.path
            z:          _root.zOrderLines
64 65 66
        }
    }

67

68
    Repeater {
69
        model: largeMapView ? ( showItems ? missionItems : 0) : 0
70 71 72

        delegate: WimaMissionItemMapVisual {
            map:        _map
73 74
            color:     _root.color
            zOrder:    _root.zOrderWP
Valentin Platzgummer's avatar
Valentin Platzgummer committed
75 76 77 78 79 80 81 82 83 84 85
            visible:   isVisible(index) && _root.visible


            function isVisible(index) {
                var num = hideNumber()
                if (num > 0) {
                    return ((index+num) % num) == 0 ? true : false
                } else {
                    return false
                }
            }
86 87 88
        }
    }

89

90

91 92 93 94 95 96 97 98 99 100
    Component.onCompleted: {
        _missionLineViewComponent = missionLineViewComponent.createObject(map)
        if (_missionLineViewComponent.status === Component.Error)
            console.log(_missionLineViewComponent.errorString())
        map.addMapItem(_missionLineViewComponent)
    }

    Component.onDestruction: {
        _missionLineViewComponent.destroy()
    }
101 102


103
}