GeoTagPage.qml 7.37 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1 2
/****************************************************************************
 *
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
Don Gagne's avatar
Don Gagne committed
4 5 6 7 8 9
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

10 11 12 13
import QtQuick                      2.11
import QtQuick.Controls             2.4
import QtQuick.Dialogs              1.3
import QtQuick.Layouts              1.11
Don Gagne's avatar
Don Gagne committed
14

15
import QGroundControl               1.0
Don Gagne's avatar
Don Gagne committed
16
import QGroundControl.Palette       1.0
17 18
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
Don Gagne's avatar
Don Gagne committed
19 20 21 22 23 24 25
import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controllers   1.0

AnalyzePage {
    id:                 geoTagPage
    pageComponent:      pageComponent
26 27
    pageName:           qsTr("GeoTag Images")
    pageDescription:    qsTr("GeoTag Images is used to tag a set of images from a survey mission with gps coordinates. You must provide the binary log from the flight as well as the directory which contains the images to tag.")
Don Gagne's avatar
Don Gagne committed
28

29 30 31
    readonly property real _margin:     ScreenTools.defaultFontPixelWidth * 2
    readonly property real _minWidth:   ScreenTools.defaultFontPixelWidth * 20
    readonly property real _maxWidth:   ScreenTools.defaultFontPixelWidth * 30
Don Gagne's avatar
Don Gagne committed
32 33

    Component {
34 35 36 37 38 39 40 41 42 43 44
        id:  pageComponent
        GridLayout {
            columns:                2
            columnSpacing:          _margin
            rowSpacing:             ScreenTools.defaultFontPixelWidth * 2
            width:                  availableWidth
            BusyIndicator {
                running:            geoController.progress > 0 && geoController.progress < 100 && geoController.errorMessage === ""
                width:              progressBar.height
                height:             progressBar.height
                Layout.alignment:   Qt.AlignVCenter | Qt.AlignHCenter
45
            }
46 47 48 49 50 51 52 53
            //-----------------------------------------------------------------
            ProgressBar {
                id:                 progressBar
                to:                 100
                value:              geoController.progress
                opacity:            geoController.progress > 0 ? 1 : 0.25
                Layout.fillWidth:   true
                Layout.alignment:   Qt.AlignVCenter
54
            }
55 56 57 58 59 60 61 62 63
            //-----------------------------------------------------------------
            QGCLabel {
                text:               geoController.errorMessage
                color:              "red"
                font.family:        ScreenTools.demiboldFontFamily
                font.pointSize:     ScreenTools.mediumFontPointSize
                horizontalAlignment:Text.AlignHCenter
                Layout.alignment:   Qt.AlignHCenter
                Layout.columnSpan:  2
64
            }
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
            //-----------------------------------------------------------------
            //-- Log File
            QGCButton {
                text:               qsTr("Select log file")
                onClicked:          openLogFile.open()
                Layout.minimumWidth:_minWidth
                Layout.maximumWidth:_maxWidth
                Layout.fillWidth:   true
                Layout.alignment:   Qt.AlignVCenter
                FileDialog {
                    id:             openLogFile
                    title:          qsTr("Select log file")
                    folder:         shortcuts.home
                    nameFilters:    [qsTr("ULog file (*.ulg)"), qsTr("PX4 log file (*.px4log)"), qsTr("All Files (*.*)")]
                    defaultSuffix:  "ulg"
                    selectExisting: true
                    onAccepted: {
                        geoController.logFile = openLogFile.fileUrl
                        close()
                    }
Don Gagne's avatar
Don Gagne committed
85 86
                }
            }
87 88 89 90 91
            QGCLabel {
                text:               geoController.logFile
                elide:              Text.ElideLeft
                Layout.fillWidth:   true
                Layout.alignment:   Qt.AlignVCenter
92
            }
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
            //-----------------------------------------------------------------
            //-- Image Directory
            QGCButton {
                text:               qsTr("Select image directory")
                onClicked:          selectImageDir.open()
                Layout.minimumWidth:_minWidth
                Layout.maximumWidth:_maxWidth
                Layout.fillWidth:   true
                Layout.alignment:   Qt.AlignVCenter
                FileDialog {
                    id:             selectImageDir
                    title:          qsTr("Select image directory")
                    folder:         shortcuts.home
                    selectFolder:   true
                    selectExisting: true
                    onAccepted: {
                        geoController.imageDirectory = selectImageDir.folder
                        close()
                    }
112
                }
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
            }
            QGCLabel {
                text:               geoController.imageDirectory
                elide:              Text.ElideLeft
                Layout.fillWidth:   true
                Layout.alignment:   Qt.AlignVCenter
            }
            //-----------------------------------------------------------------
            //-- Save Directory
            QGCButton {
                text:               qsTr("(Optionally) Select save directory")
                onClicked:          selectDestDir.open()
                Layout.minimumWidth:_minWidth
                Layout.maximumWidth:_maxWidth
                Layout.fillWidth:   true
                Layout.alignment:   Qt.AlignVCenter
                FileDialog {
                    id:             selectDestDir
                    title:          qsTr("Select save directory")
                    folder:         shortcuts.home
                    selectFolder:   true
                    selectExisting: true
                    onAccepted: {
                        geoController.saveDirectory = selectDestDir.folder
                        close()
                    }
Don Gagne's avatar
Don Gagne committed
139 140
                }
            }
141 142 143 144 145
            QGCLabel {
                text:               geoController.saveDirectory === "" ? (geoController.imageDirectory === "" ? "/TAGGED folder in your image folder" : geoController.imageDirectory + "/TAGGED") : geoController.saveDirectory
                elide:              Text.ElideLeft
                Layout.fillWidth:   true
                Layout.alignment:   Qt.AlignVCenter
146
            }
147 148
            //-----------------------------------------------------------------
            //-- Execute
Don Gagne's avatar
Don Gagne committed
149
            QGCButton {
150 151 152 153 154
                text:               geoController.inProgress ? qsTr("Cancel Tagging") : qsTr("Start Tagging")
                width:              ScreenTools.defaultFontPixelWidth * 30
                enabled:            (geoController.imageDirectory !== "" && geoController.logFile !== "") || geoController.inProgress
                Layout.alignment:   Qt.AlignHCenter
                Layout.columnSpan:  2
Don Gagne's avatar
Don Gagne committed
155
                onClicked: {
156 157
                    if (geoController.inProgress) {
                        geoController.cancelTagging()
Don Gagne's avatar
Don Gagne committed
158
                    } else {
159
                        geoController.startTagging()
Don Gagne's avatar
Don Gagne committed
160 161 162
                    }
                }
            }
163 164 165
        }
    }
}