GeoTagPage.qml 7.37 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/

Gus Grubba's avatar
Gus Grubba committed
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

Gus Grubba's avatar
Gus Grubba committed
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 {
Gus Grubba's avatar
Gus Grubba committed
34 35
        id:  pageComponent
        GridLayout {
36
            columns:                2
Gus Grubba's avatar
Gus Grubba committed
37 38 39
            columnSpacing:          _margin
            rowSpacing:             ScreenTools.defaultFontPixelWidth * 2
            width:                  availableWidth
40 41 42 43 44 45
            BusyIndicator {
                running:            geoController.progress > 0 && geoController.progress < 100 && geoController.errorMessage === ""
                width:              progressBar.height
                height:             progressBar.height
                Layout.alignment:   Qt.AlignVCenter | Qt.AlignHCenter
            }
Gus Grubba's avatar
Gus Grubba committed
46 47 48
            //-----------------------------------------------------------------
            ProgressBar {
                id:                 progressBar
Gus Grubba's avatar
Gus Grubba committed
49
                to:                 100
Gus Grubba's avatar
Gus Grubba committed
50
                value:              geoController.progress
51
                opacity:            geoController.progress > 0 ? 1 : 0.25
Gus Grubba's avatar
Gus Grubba committed
52 53 54 55
                Layout.fillWidth:   true
                Layout.alignment:   Qt.AlignVCenter
            }
            //-----------------------------------------------------------------
56
            QGCLabel {
Gus Grubba's avatar
Gus Grubba committed
57 58
                text:               geoController.errorMessage
                color:              "red"
59 60 61 62 63
                font.family:        ScreenTools.demiboldFontFamily
                font.pointSize:     ScreenTools.mediumFontPointSize
                horizontalAlignment:Text.AlignHCenter
                Layout.alignment:   Qt.AlignHCenter
                Layout.columnSpan:  2
64
            }
Gus Grubba's avatar
Gus Grubba committed
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
                }
            }
Gus Grubba's avatar
Gus Grubba committed
87 88 89 90 91
            QGCLabel {
                text:               geoController.logFile
                elide:              Text.ElideLeft
                Layout.fillWidth:   true
                Layout.alignment:   Qt.AlignVCenter
92
            }
Gus Grubba's avatar
Gus Grubba committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
            //-----------------------------------------------------------------
            //-- 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: {
109
                        geoController.imageDirectory = selectImageDir.folder
Gus Grubba's avatar
Gus Grubba committed
110 111
                        close()
                    }
112
                }
Gus Grubba's avatar
Gus Grubba committed
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
            }
            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: {
Gus Grubba's avatar
Gus Grubba committed
136
                        geoController.saveDirectory = selectDestDir.folder
Gus Grubba's avatar
Gus Grubba committed
137 138
                        close()
                    }
Don Gagne's avatar
Don Gagne committed
139 140
                }
            }
Gus Grubba's avatar
Gus Grubba committed
141
            QGCLabel {
142
                text:               geoController.saveDirectory === "" ? (geoController.imageDirectory === "" ? "/TAGGED folder in your image folder" : geoController.imageDirectory + "/TAGGED") : geoController.saveDirectory
Gus Grubba's avatar
Gus Grubba committed
143 144 145
                elide:              Text.ElideLeft
                Layout.fillWidth:   true
                Layout.alignment:   Qt.AlignVCenter
146
            }
Gus Grubba's avatar
Gus Grubba committed
147 148
            //-----------------------------------------------------------------
            //-- Execute
Don Gagne's avatar
Don Gagne committed
149
            QGCButton {
Gus Grubba's avatar
Gus Grubba committed
150 151
                text:               geoController.inProgress ? qsTr("Cancel Tagging") : qsTr("Start Tagging")
                width:              ScreenTools.defaultFontPixelWidth * 30
152
                enabled:            (geoController.imageDirectory !== "" && geoController.logFile !== "") || geoController.inProgress
Gus Grubba's avatar
Gus Grubba committed
153
                Layout.alignment:   Qt.AlignHCenter
154
                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
                    }
                }
            }
Gus Grubba's avatar
Gus Grubba committed
163 164 165
        }
    }
}