Browse Source

Geo Tag

Converted GeoTagging file dialogs from QtWidgets to QtQuick
Reworked the dialog so it's not all random sizes
QGC4.4
Gus Grubba 6 years ago
parent
commit
54483e9136
  1. 20
      src/AnalyzeView/GeoTagController.cc
  2. 48
      src/AnalyzeView/GeoTagController.h
  3. 155
      src/AnalyzeView/GeoTagPage.qml

20
src/AnalyzeView/GeoTagController.cc

@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
#include "ULogParser.h"
#include "PX4LogParser.h"
GeoTagController::GeoTagController(void)
GeoTagController::GeoTagController()
: _progress(0)
, _inProgress(false)
{
@ -36,34 +36,34 @@ GeoTagController::~GeoTagController() @@ -36,34 +36,34 @@ GeoTagController::~GeoTagController()
}
void GeoTagController::pickLogFile(void)
void GeoTagController::setLogFile(QString filename)
{
QString filename = QString(); //--TODO: QGCQFileDialog::getOpenFileName(MainWindow::instance(), tr("Select log file load"), QString(), tr("ULog file (*.ulg);;PX4 log file (*.px4log);;All Files (*.*)"));
filename.replace("file://","");
if (!filename.isEmpty()) {
_worker.setLogFile(filename);
emit logFileChanged(filename);
}
}
void GeoTagController::pickImageDirectory(void)
void GeoTagController::setImageDirectory(QString dir)
{
QString dir = QString(); //--TODO: QGCQFileDialog::getExistingDirectory(MainWindow::instance(), tr("Select image directory"));
dir.replace("file://","");
if (!dir.isEmpty()) {
_worker.setImageDirectory(dir);
emit imageDirectoryChanged(dir);
}
}
void GeoTagController::pickSaveDirectory(void)
void GeoTagController::setSaveDirectory(QString dir)
{
QString dir = QString(); //--TODO: QGCQFileDialog::getExistingDirectory(MainWindow::instance(), tr("Select save directory"));
dir.replace("file://","");
if (!dir.isEmpty()) {
_worker.setSaveDirectory(dir);
emit saveDirectoryChanged(dir);
}
}
void GeoTagController::startTagging(void)
void GeoTagController::startTagging()
{
_errorMessage.clear();
emit errorMessageChanged(_errorMessage);
@ -151,7 +151,7 @@ void GeoTagController::_setErrorMessage(const QString& error) @@ -151,7 +151,7 @@ void GeoTagController::_setErrorMessage(const QString& error)
emit errorMessageChanged(error);
}
GeoTagWorker::GeoTagWorker(void)
GeoTagWorker::GeoTagWorker()
: _cancel(false)
, _logFile("")
, _imageDirectory("")
@ -160,7 +160,7 @@ GeoTagWorker::GeoTagWorker(void) @@ -160,7 +160,7 @@ GeoTagWorker::GeoTagWorker(void)
}
void GeoTagWorker::run(void)
void GeoTagWorker::run()
{
_cancel = false;
emit progressChanged(1);

48
src/AnalyzeView/GeoTagController.h

@ -26,17 +26,17 @@ class GeoTagWorker : public QThread @@ -26,17 +26,17 @@ class GeoTagWorker : public QThread
Q_OBJECT
public:
GeoTagWorker(void);
GeoTagWorker();
void setLogFile (const QString& logFile) { _logFile = logFile; }
void setImageDirectory (const QString& imageDirectory) { _imageDirectory = imageDirectory; }
void setSaveDirectory (const QString& saveDirectory) { _saveDirectory = saveDirectory; }
QString logFile (void) const { return _logFile; }
QString imageDirectory (void) const { return _imageDirectory; }
QString saveDirectory (void) const { return _saveDirectory; }
QString logFile () const { return _logFile; }
QString imageDirectory () const { return _imageDirectory; }
QString saveDirectory () const { return _saveDirectory; }
void cancelTagging (void) { _cancel = true; }
void cancelTagging () { _cancel = true; }
struct cameraFeedbackPacket {
double timestamp;
@ -51,11 +51,11 @@ public: @@ -51,11 +51,11 @@ public:
};
protected:
void run(void) final;
void run() final;
signals:
void error (QString errorMsg);
void taggingComplete (void);
void taggingComplete ();
void progressChanged (double progress);
private:
@ -77,14 +77,13 @@ private: @@ -77,14 +77,13 @@ private:
class GeoTagController : public QObject
{
Q_OBJECT
public:
GeoTagController(void);
GeoTagController();
~GeoTagController();
Q_PROPERTY(QString logFile READ logFile NOTIFY logFileChanged)
Q_PROPERTY(QString imageDirectory READ imageDirectory NOTIFY imageDirectoryChanged)
Q_PROPERTY(QString saveDirectory READ saveDirectory NOTIFY saveDirectoryChanged)
Q_PROPERTY(QString logFile READ logFile WRITE setLogFile NOTIFY logFileChanged)
Q_PROPERTY(QString imageDirectory READ imageDirectory WRITE setImageDirectory NOTIFY imageDirectoryChanged)
Q_PROPERTY(QString saveDirectory READ saveDirectory WRITE setSaveDirectory NOTIFY saveDirectoryChanged)
/// Set to an error message is geotagging fails
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
@ -95,25 +94,26 @@ public: @@ -95,25 +94,26 @@ public:
/// true: Currently in the process of tagging
Q_PROPERTY(bool inProgress READ inProgress NOTIFY inProgressChanged)
Q_INVOKABLE void pickLogFile(void);
Q_INVOKABLE void pickImageDirectory(void);
Q_INVOKABLE void pickSaveDirectory(void);
Q_INVOKABLE void startTagging(void);
Q_INVOKABLE void cancelTagging(void) { _worker.cancelTagging(); }
Q_INVOKABLE void startTagging();
Q_INVOKABLE void cancelTagging() { _worker.cancelTagging(); }
QString logFile () const { return _worker.logFile(); }
QString imageDirectory () const { return _worker.imageDirectory(); }
QString saveDirectory () const { return _worker.saveDirectory(); }
double progress () const { return _progress; }
bool inProgress () const { return _worker.isRunning(); }
QString errorMessage () const { return _errorMessage; }
QString logFile (void) const { return _worker.logFile(); }
QString imageDirectory (void) const { return _worker.imageDirectory(); }
QString saveDirectory (void) const { return _worker.saveDirectory(); }
double progress (void) const { return _progress; }
bool inProgress (void) const { return _worker.isRunning(); }
QString errorMessage (void) const { return _errorMessage; }
void setLogFile (QString file);
void setImageDirectory (QString dir);
void setSaveDirectory (QString dir);
signals:
void logFileChanged (QString logFile);
void imageDirectoryChanged (QString imageDirectory);
void saveDirectoryChanged (QString saveDirectory);
void progressChanged (double progress);
void inProgressChanged (void);
void inProgressChanged ();
void errorMessageChanged (QString errorMessage);
private slots:

155
src/AnalyzeView/GeoTagPage.qml

@ -9,7 +9,8 @@ @@ -9,7 +9,8 @@
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.12
import QGroundControl 1.0
import QGroundControl.Palette 1.0
@ -25,108 +26,148 @@ AnalyzePage { @@ -25,108 +26,148 @@ AnalyzePage {
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.")
property real _margin: ScreenTools.defaultFontPixelWidth * 2
readonly property real _margin: ScreenTools.defaultFontPixelWidth * 2
readonly property real _minWidth: ScreenTools.defaultFontPixelWidth * 20
readonly property real _maxWidth: ScreenTools.defaultFontPixelWidth * 30
Component {
id: pageComponent
Column {
id: mainColumn
GridLayout {
columns: 3
columnSpacing: _margin
rowSpacing: ScreenTools.defaultFontPixelWidth * 2
width: availableWidth
spacing: _margin
Row {
spacing: ScreenTools.defaultFontPixelWidth * 2
//-----------------------------------------------------------------
ProgressBar {
id: progressBar
width: geoTagPage.width -_margin * 5
maximumValue: 100
value: geoController.progress
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
Layout.columnSpan: 2
}
BusyIndicator {
running: geoController.progress > 0 && geoController.progress < 100 && geoController.errorMessage === ""
width: progressBar.height
height: progressBar.height
Layout.alignment: Qt.AlignVCenter
}
}
//-----------------------------------------------------------------
QGCLabel {
text: geoController.errorMessage
font.bold: true
font.pointSize: ScreenTools.largeFontPointSize
color: "red"
Layout.columnSpan: 3
}
// Horizontal spacer line
//-----------------------------------------------------------------
//-- Horizontal spacer line
Rectangle {
height: 1
width: geoTagPage.width * 1.0
color: qgcPal.windowShadeDark
anchors.horizontalCenter: parent.horizontalCenter
Layout.fillWidth: true
Layout.columnSpan: 3
}
Row {
spacing: _margin
//-----------------------------------------------------------------
//-- Log File
QGCButton {
text: qsTr("Select log file")
width: ScreenTools.defaultFontPixelWidth * 30
onClicked: geoController.pickLogFile()
anchors.verticalCenter: parent.verticalCenter
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()
}
}
}
QGCLabel {
text: geoController.logFile
anchors.verticalCenter: parent.verticalCenter
elide: Text.ElideLeft
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
Layout.columnSpan: 2
}
}
Row {
spacing: _margin
//-----------------------------------------------------------------
//-- Image Directory
QGCButton {
text: qsTr("Select image directory")
width: ScreenTools.defaultFontPixelWidth * 30
onClicked: geoController.pickImageDirectory()
anchors.verticalCenter: parent.verticalCenter
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 = openLogFile.folder
close()
}
}
}
QGCLabel {
text: geoController.imageDirectory
anchors.verticalCenter: parent.verticalCenter
elide: Text.ElideLeft
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
Layout.columnSpan: 2
}
}
Row {
spacing: _margin
//-----------------------------------------------------------------
//-- Save Directory
QGCButton {
text: qsTr("(Optionally) Select save directory")
width: ScreenTools.defaultFontPixelWidth * 30
onClicked: geoController.pickSaveDirectory()
anchors.verticalCenter: parent.verticalCenter
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 = openLogFile.folder
close()
}
}
}
QGCLabel {
text: geoController.saveDirectory !== "" ? geoController.saveDirectory : "/TAGGED folder in your image folder"
anchors.verticalCenter: parent.verticalCenter
}
elide: Text.ElideLeft
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
Layout.columnSpan: 2
}
// Horizontal spacer line
//-----------------------------------------------------------------
//-- Horizontal spacer line
Rectangle {
height: 1
width: geoTagPage.width * 1.0
color: qgcPal.windowShadeDark
anchors.horizontalCenter: parent.horizontalCenter
Layout.fillWidth: true
Layout.columnSpan: 3
}
//-----------------------------------------------------------------
//-- Execute
QGCButton {
text: geoController.inProgress ? qsTr("Cancel Tagging") : qsTr("Start Tagging")
width: ScreenTools.defaultFontPixelWidth * 30
Layout.alignment: Qt.AlignHCenter
Layout.columnSpan: 3
onClicked: {
if (geoController.inProgress) {
geoController.cancelTagging()
@ -135,6 +176,6 @@ AnalyzePage { @@ -135,6 +176,6 @@ AnalyzePage {
}
}
}
} // Column
} // Component
} // AnalyzePage
}
}
}

Loading…
Cancel
Save