diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/Developer.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/Developer.xml
index d04c74168..126696f0d 100644
--- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/Developer.xml
+++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/Developer.xml
@@ -1781,32 +1781,6 @@
-
-
-
- false
- 0.0.0
-
-
- false
- %%DATAPATH%%pfd/default/pfd.svg
- false
- false
-
-
-
-
- false
- 0.0.0
-
-
- true
- %%DATAPATH%%pfd/default/pfd.svg
- false
- false
-
-
-
@@ -1816,12 +1790,14 @@
false
2000
+ 1
false
%%DATAPATH%%pfd/default/readymap.earth
46.6715
10.1589
true
%%DATAPATH%%pfd/default/Pfd.qml
+ 1
false
diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml
index bee98b3e0..4f4666e0c 100644
--- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml
+++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml
@@ -1819,33 +1819,7 @@
true
-
-
-
-
- false
- 0.0.0
-
-
- false
- %%DATAPATH%%pfd/default/pfd.svg
- false
- false
-
-
-
-
- false
- 0.0.0
-
-
- true
- %%DATAPATH%%pfd/default/pfd.svg
- false
- false
-
-
-
+
@@ -1855,12 +1829,14 @@
false
2000
+ 1
false
%%DATAPATH%%pfd/default/readymap.earth
46.6715
10.1589
true
%%DATAPATH%%pfd/default/Pfd.qml
+ 1
false
diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml
index bd99b9685..eaabdd8e5 100644
--- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml
+++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml
@@ -1797,33 +1797,7 @@
true
-
-
-
-
- false
- 0.0.0
-
-
- false
- %%DATAPATH%%pfd/default/pfd.svg
- false
- false
-
-
-
-
- false
- 0.0.0
-
-
- true
- %%DATAPATH%%pfd/default/pfd.svg
- false
- false
-
-
-
+
@@ -1833,12 +1807,14 @@
false
2000
+ 1
false
%%DATAPATH%%pfd/default/readymap.earth
46.6715
10.1589
true
%%DATAPATH%%pfd/default/Pfd.qml
+ 1
false
diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml
index a8f4d66b2..4d0ef2c89 100644
--- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml
+++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml
@@ -24,10 +24,10 @@ Item {
anchors.verticalCenter: parent.verticalCenter
// The altitude scale represents 30 meters,
// move it in 0..5m range
- anchors.verticalCenterOffset: -height/30 * (PositionActual.Down-Math.floor(PositionActual.Down/5)*5)
+ anchors.verticalCenterOffset: -height/30 * (PositionActual.Down-Math.floor(PositionActual.Down/5*qmlWidget.altitudeFactor)*5)
anchors.left: parent.left
- property int topNumber: 15-Math.floor(PositionActual.Down/5)*5
+ property int topNumber: 15-Math.floor(PositionActual.Down/5*qmlWidget.altitudeFactor)*5
// Altitude numbers
Column {
@@ -52,7 +52,6 @@ Item {
}
}
-
SvgElementImage {
id: altitude_window
clip: true
@@ -69,7 +68,7 @@ Item {
Text {
id: altitude_text
- text: Math.floor(-PositionActual.Down).toFixed()
+ text: Math.floor(-PositionActual.Down * qmlWidget.altitudeFactor).toFixed()
color: "white"
font {
family: "Arial"
@@ -78,4 +77,26 @@ Item {
anchors.centerIn: parent
}
}
+
+ SvgElementImage {
+ id: altitude_unit
+ elementName: "altitude-unit"
+ sceneSize: sceneItem.sceneSize
+ clip: true
+
+ x: Math.floor(scaledBounds.x * sceneItem.width)
+ y: Math.floor(scaledBounds.y * sceneItem.height)
+
+ Text {
+ id: altitude_unit_text
+ text: qmlWidget.altitudeUnit
+ color: "white"
+ font {
+ family: "Arial"
+ pixelSize: parent.height
+ }
+ anchors.right: parent.right
+ }
+ }
+
}
diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml
index 8d821e7c3..fd6f175d4 100644
--- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml
+++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml
@@ -31,7 +31,7 @@ Item {
Text {
id: gps_text
- text: "GPS: " + GPSPosition.Satellites + "\nPDP: " + GPSPosition.PDOP
+ text: "GPS: " + GPSPosition.Satellites + "\nPDP: " + Math.round(GPSPosition.PDOP*10)/10
color: "white"
font.family: "Arial"
font.pixelSize: telemetry_status.height * 0.75
diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml
index 1340b9cdb..6d8643e66 100644
--- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml
+++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml
@@ -3,7 +3,7 @@ import Qt 4.7
Item {
id: sceneItem
property variant sceneSize
- property real groundSpeed : 3.6 * Math.sqrt(Math.pow(VelocityActual.North,2)+
+ property real groundSpeed : qmlWidget.speedFactor * Math.sqrt(Math.pow(VelocityActual.North,2)+
Math.pow(VelocityActual.East,2))
SvgElementImage {
@@ -58,7 +58,6 @@ Item {
}
}
-
SvgElementImage {
id: speed_window
clip: true
@@ -82,4 +81,25 @@ Item {
anchors.centerIn: parent
}
}
+
+ SvgElementImage {
+ id: speed_unit
+ elementName: "speed-unit"
+ sceneSize: sceneItem.sceneSize
+ clip: true
+
+ x: Math.floor(scaledBounds.x * sceneItem.width)
+ y: Math.floor(scaledBounds.y * sceneItem.height)
+
+ Text {
+ id: speed_unit_text
+ text: qmlWidget.speedUnit
+ color: "white"
+ font {
+ family: "Arial"
+ pixelSize: parent.height
+ }
+ anchors.right: parent.right
+ }
+ }
}
diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg b/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg
index abdc4f8c5..2b7ff19bd 100644
--- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg
+++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg
@@ -14,8 +14,8 @@
height="707.56323"
id="svg2"
version="1.1"
- inkscape:version="0.48.3.1 r9886"
- sodipodi:docname="pfd-11.svg"
+ inkscape:version="0.48.4 r9939"
+ sodipodi:docname="pfd.svg"
style="display:inline"
inkscape:export-filename="C:\Users\Nuno\Desktop\OpenPilot\PFD\PFD-4.png"
inkscape:export-xdpi="71.993568"
@@ -1616,15 +1616,15 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.1617336"
- inkscape:cx="415.72223"
- inkscape:cy="353.78162"
+ inkscape:cx="613.40088"
+ inkscape:cy="388.21292"
inkscape:document-units="px"
- inkscape:current-layer="svg2"
+ inkscape:current-layer="foreground"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1017"
- inkscape:window-x="-4"
- inkscape:window-y="-4"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
inkscape:window-maximized="1"
showguides="false"
inkscape:guide-bbox="true"
@@ -1953,8 +1953,7 @@
id="layer3"
inkscape:label="foreground"
style="display:inline"
- transform="translate(230.4171,-2.5493479)"
- sodipodi:insensitive="true">
+ transform="translate(230.4171,-2.5493479)">
@@ -1980,7 +1979,7 @@
+ transform="translate(19.192898,0)">
+ transform="translate(184.16754,0)">
+
+
+
-
ALT
- m/s
- m
+ inkscape:label="rect2816"
+ style="display:inline">
- The OpenPilot Project
- (C) 2010 Edouard Lafargue
- The GNU Public License (GPL) Version 3
- The Primary Flight Display gadget
- http://www.openpilot.org
-
-
-
-
-
diff --git a/ground/openpilotgcs/src/plugins/pfd/images/pfd-default.svg b/ground/openpilotgcs/src/plugins/pfd/images/pfd-default.svg
deleted file mode 100644
index 0fdc3669b..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/images/pfd-default.svg
+++ /dev/null
@@ -1,394 +0,0 @@
-
-
-
-
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfd.pro b/ground/openpilotgcs/src/plugins/pfd/pfd.pro
deleted file mode 100644
index 961d89c19..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfd.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-TEMPLATE = lib
-TARGET = PFDGadget
-QT += svg
-QT += opengl
-include(../../openpilotgcsplugin.pri)
-include(../../plugins/coreplugin/coreplugin.pri)
-include(pfd_dependencies.pri)
-HEADERS += pfdplugin.h
-HEADERS += pfdgadget.h
-HEADERS += pfdgadgetwidget.h
-HEADERS += pfdgadgetfactory.h
-HEADERS += pfdgadgetconfiguration.h
-HEADERS += pfdgadgetoptionspage.h
-SOURCES += pfdplugin.cpp
-SOURCES += pfdgadget.cpp
-SOURCES += pfdgadgetfactory.cpp
-SOURCES += pfdgadgetwidget.cpp
-SOURCES += pfdgadgetconfiguration.cpp
-SOURCES += pfdgadgetoptionspage.cpp
-OTHER_FILES += PFDGadget.pluginspec
-FORMS += pfdgadgetoptionspage.ui
-RESOURCES += pfd.qrc
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfd.qrc b/ground/openpilotgcs/src/plugins/pfd/pfd.qrc
deleted file mode 100644
index 278dd281e..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfd.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- images/pfd-default.svg
-
-
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfd_dependencies.pri b/ground/openpilotgcs/src/plugins/pfd/pfd_dependencies.pri
deleted file mode 100644
index 9aae5fbc0..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfd_dependencies.pri
+++ /dev/null
@@ -1 +0,0 @@
-include(../../plugins/uavobjects/uavobjects.pri)
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfdgadget.cpp b/ground/openpilotgcs/src/plugins/pfd/pfdgadget.cpp
deleted file mode 100644
index 6d91e3c88..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfdgadget.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- ******************************************************************************
- *
- * @file pfdgadget.cpp
- * @author Edouard Lafargue Copyright (C) 2010.
- * @addtogroup GCSPlugins GCS Plugins
- * @{
- * @addtogroup OPMapPlugin Primary Flight Display Plugin
- * @{
- * @brief The Primary Flight Display Gadget
- *****************************************************************************/
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "pfdgadget.h"
-#include "pfdgadgetwidget.h"
-#include "pfdgadgetconfiguration.h"
-
-PFDGadget::PFDGadget(QString classId, PFDGadgetWidget *widget, QWidget *parent) :
- IUAVGadget(classId, parent),
- m_widget(widget)
-{}
-
-PFDGadget::~PFDGadget()
-{
- delete m_widget;
-}
-
-/*
- This is called when a configuration is loaded, and updates the plugin's settings.
- Careful: the plugin is already drawn before the loadConfiguration method is called the
- first time, so you have to be careful not to assume all the plugin values are initialized
- the first time you use them
- */
-void PFDGadget::loadConfiguration(IUAVGadgetConfiguration *config)
-{
- PFDGadgetConfiguration *m = qobject_cast(config);
-
- m_widget->setHqFonts(m->getHqFonts());
- m_widget->setDialFile(m->dialFile());
- m_widget->enableOpenGL(m->useOpenGL());
- m_widget->enableSmoothUpdates(m->getBeSmooth());
- m_widget->connectNeedles();
-}
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfdgadget.h b/ground/openpilotgcs/src/plugins/pfd/pfdgadget.h
deleted file mode 100644
index c161aa97f..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfdgadget.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- ******************************************************************************
- *
- * @file pfdgadget.h
- * @author Edouard Lafargue Copyright (C) 2010.
- * @addtogroup GCSPlugins GCS Plugins
- * @{
- * @addtogroup OPMapPlugin Primary Flight Display Plugin
- * @{
- * @brief The Primary Flight Display Gadget
- *****************************************************************************/
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PFDGADGET_H_
-#define PFDGADGET_H_
-
-#include
-#include "pfdgadgetwidget.h"
-
-class IUAVGadget;
-class QWidget;
-class QString;
-class PFDGadgetWidget;
-
-using namespace Core;
-
-class PFDGadget : public Core::IUAVGadget {
- Q_OBJECT
-public:
- PFDGadget(QString classId, PFDGadgetWidget *widget, QWidget *parent = 0);
- ~PFDGadget();
-
- QWidget *widget()
- {
- return m_widget;
- }
- void loadConfiguration(IUAVGadgetConfiguration *config);
-
-private:
- PFDGadgetWidget *m_widget;
-};
-
-
-#endif // PFDGADGET_H_
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetconfiguration.cpp b/ground/openpilotgcs/src/plugins/pfd/pfdgadgetconfiguration.cpp
deleted file mode 100644
index f05235409..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetconfiguration.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- ******************************************************************************
- *
- * @file pfdgadgetconfiguration.cpp
- * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
- * @addtogroup GCSPlugins GCS Plugins
- * @{
- * @addtogroup OPMapPlugin Primary Flight Display Plugin
- * @{
- * @brief The Primary Flight Display Gadget
- *****************************************************************************/
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "pfdgadgetconfiguration.h"
-#include "utils/pathutils.h"
-
-/**
- * Loads a saved configuration or defaults if non exist.
- *
- */
-PFDGadgetConfiguration::PFDGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
- IUAVGadgetConfiguration(classId, parent),
- m_defaultDial("Unknown"),
- beSmooth(true)
-{
- // if a saved configuration exists load it
- if (qSettings != 0) {
- QString dialFile = qSettings->value("dialFile").toString();
- useOpenGLFlag = qSettings->value("useOpenGLFlag").toBool();
- hqFonts = qSettings->value("hqFonts").toBool();
- beSmooth = qSettings->value("beSmooth").toBool();
- m_defaultDial = Utils::PathUtils().InsertDataPath(dialFile);
- }
-}
-
-/**
- * Clones a configuration.
- *
- */
-IUAVGadgetConfiguration *PFDGadgetConfiguration::clone()
-{
- PFDGadgetConfiguration *m = new PFDGadgetConfiguration(this->classId());
-
- m->m_defaultDial = m_defaultDial;
- m->useOpenGLFlag = useOpenGLFlag;
- m->hqFonts = hqFonts;
- m->beSmooth = beSmooth;
- return m;
-}
-
-/**
- * Saves a configuration.
- *
- */
-void PFDGadgetConfiguration::saveConfig(QSettings *qSettings) const
-{
- QString dialFile = Utils::PathUtils().RemoveDataPath(m_defaultDial);
-
- qSettings->setValue("dialFile", dialFile);
- qSettings->setValue("useOpenGLFlag", useOpenGLFlag);
- qSettings->setValue("hqFonts", hqFonts);
- qSettings->setValue("beSmooth", beSmooth);
-}
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetconfiguration.h b/ground/openpilotgcs/src/plugins/pfd/pfdgadgetconfiguration.h
deleted file mode 100644
index 9f3152c63..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetconfiguration.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- ******************************************************************************
- *
- * @file pfdgadgetconfiguration.h
- * @author Edouard Lafargue Copyright (C) 2010.
- * @addtogroup GCSPlugins GCS Plugins
- * @{
- * @addtogroup OPMapPlugin Primary Flight Display Plugin
- * @{
- * @brief The Primary Flight Display Gadget
- *****************************************************************************/
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PFDGADGETCONFIGURATION_H
-#define PFDGADGETCONFIGURATION_H
-
-#include
-
-using namespace Core;
-
-class PFDGadgetConfiguration : public IUAVGadgetConfiguration {
- Q_OBJECT
-public:
- explicit PFDGadgetConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
-
- // set dial configuration functions
- void setDialFile(QString dialFile)
- {
- m_defaultDial = dialFile;
- }
- void setUseOpenGL(bool flag)
- {
- useOpenGLFlag = flag;
- }
- void setHqFonts(bool flag)
- {
- hqFonts = flag;
- }
- void setBeSmooth(bool flag)
- {
- beSmooth = flag;
- }
-
- // get dial configuration functions
- QString dialFile()
- {
- return m_defaultDial;
- }
- bool useOpenGL()
- {
- return useOpenGLFlag;
- }
- bool getHqFonts()
- {
- return hqFonts;
- }
- bool getBeSmooth()
- {
- return beSmooth;
- }
-
- void saveConfig(QSettings *settings) const;
- IUAVGadgetConfiguration *clone();
-
-private:
- QString m_defaultDial; // The name of the dial's SVG source file
- bool useOpenGLFlag;
- bool hqFonts;
- bool beSmooth;
-};
-
-#endif // PFDGADGETCONFIGURATION_H
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetfactory.cpp b/ground/openpilotgcs/src/plugins/pfd/pfdgadgetfactory.cpp
deleted file mode 100644
index 1e3725189..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetfactory.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- ******************************************************************************
- *
- * @file pfdgadgetfactory.cpp
- * @author Edouard Lafargue Copyright (C) 2010.
- * @addtogroup GCSPlugins GCS Plugins
- * @{
- * @addtogroup OPMapPlugin Primary Flight Display Plugin
- * @{
- * @brief The Primary Flight Display Gadget
- *****************************************************************************/
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#include "pfdgadgetfactory.h"
-#include "pfdgadgetwidget.h"
-#include "pfdgadget.h"
-#include "pfdgadgetconfiguration.h"
-#include "pfdgadgetoptionspage.h"
-#include
-
-PFDGadgetFactory::PFDGadgetFactory(QObject *parent) :
- IUAVGadgetFactory(QString("PFDGadget"),
- tr("Primary Flight Display"),
- parent)
-{}
-
-PFDGadgetFactory::~PFDGadgetFactory()
-{}
-
-Core::IUAVGadget *PFDGadgetFactory::createGadget(QWidget *parent)
-{
- PFDGadgetWidget *gadgetWidget = new PFDGadgetWidget(parent);
-
- return new PFDGadget(QString("PFDGadget"), gadgetWidget, parent);
-}
-
-IUAVGadgetConfiguration *PFDGadgetFactory::createConfiguration(QSettings *qSettings)
-{
- return new PFDGadgetConfiguration(QString("PFDGadget"), qSettings);
-}
-
-IOptionsPage *PFDGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
-{
- return new PFDGadgetOptionsPage(qobject_cast(config));
-}
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetfactory.h b/ground/openpilotgcs/src/plugins/pfd/pfdgadgetfactory.h
deleted file mode 100644
index be7867494..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetfactory.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- ******************************************************************************
- *
- * @file pfdgadgetfactory.h
- * @author Edouard Lafargue Copyright (C) 2010.
- * @addtogroup GCSPlugins GCS Plugins
- * @{
- * @addtogroup OPMapPlugin Primary Flight Display Plugin
- * @{
- * @brief The Primary Flight Display Gadget
- *****************************************************************************/
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PFDGADGETFACTORY_H_
-#define PFDGADGETFACTORY_H_
-
-#include
-
-namespace Core {
-class IUAVGadget;
-class IUAVGadgetFactory;
-}
-
-using namespace Core;
-
-class PFDGadgetFactory : public IUAVGadgetFactory {
- Q_OBJECT
-public:
- PFDGadgetFactory(QObject *parent = 0);
- ~PFDGadgetFactory();
-
- Core::IUAVGadget *createGadget(QWidget *parent);
- IUAVGadgetConfiguration *createConfiguration(QSettings *qSettings);
- IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
-};
-
-#endif // PFDGADGETFACTORY_H_
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/pfd/pfdgadgetoptionspage.cpp
deleted file mode 100644
index 3af712dd4..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetoptionspage.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- ******************************************************************************
- *
- * @file pfdgadgetoptionspage.cpp
- * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
- * @addtogroup GCSPlugins GCS Plugins
- * @{
- * @addtogroup OPMapPlugin Primary Flight Display Plugin
- * @{
- * @brief The Primary Flight Display Gadget
- *****************************************************************************/
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "pfdgadgetoptionspage.h"
-#include "pfdgadgetconfiguration.h"
-#include "ui_pfdgadgetoptionspage.h"
-#include "extensionsystem/pluginmanager.h"
-#include "uavobjectmanager.h"
-#include "uavdataobject.h"
-
-
-#include
-#include
-#include
-
-PFDGadgetOptionsPage::PFDGadgetOptionsPage(PFDGadgetConfiguration *config, QObject *parent) :
- IOptionsPage(parent),
- m_config(config)
-{}
-
-// creates options page widget (uses the UI file)
-QWidget *PFDGadgetOptionsPage::createPage(QWidget *parent)
-{
- Q_UNUSED(parent);
-
- options_page = new Ui::PFDGadgetOptionsPage();
- // main widget
- QWidget *optionsPageWidget = new QWidget;
- // main layout
- options_page->setupUi(optionsPageWidget);
-
-
- // Restore the contents from the settings:
- options_page->svgSourceFile->setExpectedKind(Utils::PathChooser::File);
- options_page->svgSourceFile->setPromptDialogFilter(tr("SVG image (*.svg)"));
- options_page->svgSourceFile->setPromptDialogTitle(tr("Choose SVG image"));
- options_page->svgSourceFile->setPath(m_config->dialFile());
- options_page->useOpenGL->setChecked(m_config->useOpenGL());
- options_page->hqText->setChecked(m_config->getHqFonts());
- options_page->smoothUpdates->setChecked(m_config->getBeSmooth());
-
- return optionsPageWidget;
-}
-
-/**
- * Called when the user presses apply or OK.
- *
- * Saves the current values
- *
- */
-void PFDGadgetOptionsPage::apply()
-{
- m_config->setDialFile(options_page->svgSourceFile->path());
- m_config->setUseOpenGL(options_page->useOpenGL->checkState());
- m_config->setHqFonts(options_page->hqText->checkState());
- m_config->setBeSmooth(options_page->smoothUpdates->checkState());
-}
-
-
-void PFDGadgetOptionsPage::finish()
-{}
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetoptionspage.h b/ground/openpilotgcs/src/plugins/pfd/pfdgadgetoptionspage.h
deleted file mode 100644
index 83ea51ded..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetoptionspage.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- ******************************************************************************
- *
- * @file pfdgadgetoptionspage.h
- * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
- * @addtogroup GCSPlugins GCS Plugins
- * @{
- * @addtogroup OPMapPlugin Primary Flight Display Plugin
- * @{
- * @brief The Primary Flight Display Gadget
- *****************************************************************************/
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PFDGADGETOPTIONSPAGE_H
-#define PFDGADGETOPTIONSPAGE_H
-
-#include "coreplugin/dialogs/ioptionspage.h"
-#include "QString"
-#include
-#include
-
-namespace Core {
-class IUAVGadgetConfiguration;
-}
-
-class PFDGadgetConfiguration;
-
-namespace Ui {
-class PFDGadgetOptionsPage;
-}
-
-using namespace Core;
-
-class PFDGadgetOptionsPage : public IOptionsPage {
- Q_OBJECT
-public:
- explicit PFDGadgetOptionsPage(PFDGadgetConfiguration *config, QObject *parent = 0);
-
- QWidget *createPage(QWidget *parent);
- void apply();
- void finish();
-
-private:
- Ui::PFDGadgetOptionsPage *options_page;
- PFDGadgetConfiguration *m_config;
-
-private slots:
-};
-
-#endif // PFDGADGETOPTIONSPAGE_H
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetoptionspage.ui b/ground/openpilotgcs/src/plugins/pfd/pfdgadgetoptionspage.ui
deleted file mode 100644
index 1373d2d3c..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetoptionspage.ui
+++ /dev/null
@@ -1,150 +0,0 @@
-
-
- PFDGadgetOptionsPage
-
-
-
- 0
- 0
- 430
- 306
-
-
-
-
- 0
- 0
-
-
-
- Form
-
-
-
- 0
-
- -
-
-
- QFrame::NoFrame
-
-
- QFrame::Plain
-
-
- true
-
-
-
-
- 0
- 0
- 430
- 306
-
-
-
-
- 0
-
-
-
-
-
- 10
-
-
- QLayout::SetMaximumSize
-
-
- 10
-
-
-
-
-
- PFD SVG:
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
-
-
- -
-
-
-
-
-
- true
-
-
- Use OpenGL for rendering
-
-
- true
-
-
-
- -
-
-
- High Quality text (OpenGL)
-
-
-
-
-
- -
-
-
-
-
-
- Smooth updates
-
-
- true
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::MinimumExpanding
-
-
-
- 20
- 40
-
-
-
-
-
-
-
-
-
-
-
-
- Utils::PathChooser
- QWidget
-
- 1
-
-
-
-
-
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/pfd/pfdgadgetwidget.cpp
deleted file mode 100644
index bbd034193..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetwidget.cpp
+++ /dev/null
@@ -1,1133 +0,0 @@
-/**
- ******************************************************************************
- *
- * @file pfdgadgetwidget.cpp
- * @author Edouard Lafargue Copyright (C) 2010.
- * @addtogroup GCSPlugins GCS Plugins
- * @{
- * @addtogroup OPMapPlugin Primary Flight Display Plugin
- * @{
- * @brief The Primary Flight Display Gadget
- *****************************************************************************/
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "pfdgadgetwidget.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-PFDGadgetWidget::PFDGadgetWidget(QWidget *parent) : QGraphicsView(parent)
-{
- setMinimumSize(64, 64);
- setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
- setScene(new QGraphicsScene(this));
-// setRenderHint(QPainter::SmoothPixmapTransform);
-
- setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
- // setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
- // setRenderHints(QPainter::TextAntialiasing);
- // setRenderHints(QPainter::HighQualityAntialiasing);
-
- m_renderer = new QSvgRenderer();
-
- attitudeObj = NULL;
- headingObj = NULL;
- gcsBatteryObj = NULL;
- gpsObj = NULL;
- compassBandWidth = 0;
- pfdError = true;
- hqFonts = false;
- rollTarget = 0;
- rollValue = 0;
- pitchTarget = 0;
- pitchValue = 0;
- headingTarget = 0;
- headingValue = 0;
- groundspeedTarget = 0;
- groundspeedValue = 0;
- altitudeTarget = 0;
- altitudeValue = 0;
-
- // This timer mechanism makes needles rotate smoothly
- connect(&dialTimer, SIGNAL(timeout()), this, SLOT(moveNeedles()));
- dialTimer.start(30);
-
- connect(&skyDialTimer, SIGNAL(timeout()), this, SLOT(moveSky()));
- skyDialTimer.start(30);
-}
-
-PFDGadgetWidget::~PFDGadgetWidget()
-{
- skyDialTimer.stop();
- dialTimer.stop();
-}
-
-void PFDGadgetWidget::setToolTipPrivate()
-{
- static qint32 updateRate = 0;
- UAVObject::Metadata mdata = attitudeObj->getMetadata();
-
- if (mdata.flightTelemetryUpdatePeriod != updateRate) {
- this->setToolTip("Current refresh rate:" + QString::number(mdata.flightTelemetryUpdatePeriod) + " miliseconds" + "\nIf you want to change it please edit the AttitudeActual metadata on the object browser.");
- }
-}
-
-/*!
- \brief Enables/Disables OpenGL
- */
-void PFDGadgetWidget::enableOpenGL(bool flag)
-{
- if (flag) {
- setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
- } else {
- setViewport(new QWidget);
- }
-}
-
-/*!
- \brief Connects the widget to the relevant UAVObjects
-
- Should only be called after the PFD artwork is loaded.
- We want: AttitudeActual, FlightBattery, Location.
-
- */
-void PFDGadgetWidget::connectNeedles()
-{
- if (attitudeObj != NULL) {
- disconnect(attitudeObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateAttitude(UAVObject *)));
- }
-
- if (headingObj != NULL) {
- disconnect(headingObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateHeading(UAVObject *)));
- }
-
- if (gcsBatteryObj != NULL) {
- disconnect(gcsBatteryObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateBattery(UAVObject *)));
- }
-
- if (gpsObj != NULL) {
- disconnect(gpsObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateGPS(UAVObject *)));
- }
-
- // Safeguard: if artwork did not load properly, don't go further
- if (pfdError) {
- return;
- }
- ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
- UAVObjectManager *objManager = pm->getObject();
-
- airspeedObj = dynamic_cast(objManager->getObject("AirspeedActual"));
- if (airspeedObj != NULL) {
- connect(airspeedObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateAirspeed(UAVObject *)));
- } else {
- qDebug() << "Error: Object is unknown (AirspeedActual).";
- }
-
- groundspeedObj = dynamic_cast(objManager->getObject("VelocityActual"));
- if (groundspeedObj != NULL) {
- connect(groundspeedObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateGroundspeed(UAVObject *)));
- } else {
- qDebug() << "Error: Object is unknown (VelocityActual).";
- }
-
- altitudeObj = dynamic_cast(objManager->getObject("PositionActual"));
- if (altitudeObj != NULL) {
- connect(altitudeObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateAltitude(UAVObject *)));
- } else {
- qDebug() << "Error: Object is unknown (PositionActual).";
- }
-
- attitudeObj = dynamic_cast(objManager->getObject("AttitudeActual"));
- if (attitudeObj != NULL) {
- connect(attitudeObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateAttitude(UAVObject *)));
- } else {
- qDebug() << "Error: Object is unknown (AttitudeActual).";
- }
-
- headingObj = dynamic_cast(objManager->getObject("PositionActual"));
- if (headingObj != NULL) {
- connect(headingObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateHeading(UAVObject *)));
- } else {
- qDebug() << "Error: Object is unknown (PositionActual).";
- }
-
- if (gcsGPSStats) {
- gpsObj = dynamic_cast(objManager->getObject("GPSPosition"));
- if (gpsObj != NULL) {
- connect(gpsObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateGPS(UAVObject *)));
- } else {
- qDebug() << "Error: Object is unknown (GPSPosition).";
- }
- }
-
- if (gcsTelemetryArrow || gcsTelemetryStats) {
- // Only register if the PFD wants link stats/status
- gcsTelemetryObj = dynamic_cast(objManager->getObject("GCSTelemetryStats"));
- if (gcsTelemetryObj != NULL) {
- connect(gcsTelemetryObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateLinkStatus(UAVObject *)));
- } else {
- qDebug() << "Error: Object is unknown (GCSTelemetryStats).";
- }
- }
-
- if (gcsBatteryStats) { // Only register if the PFD wants battery display
- gcsBatteryObj = dynamic_cast(objManager->getObject("FlightBatteryState"));
- if (gcsBatteryObj != NULL) {
- connect(gcsBatteryObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateBattery(UAVObject *)));
- } else {
- qDebug() << "Error: Object is unknown (FlightBatteryState).";
- }
- }
-}
-
-
-/*!
- \brief Updates the GPS stats
- */
-void PFDGadgetWidget::updateGPS(UAVObject *object1)
-{
- UAVObjectField *field = object1->getField(QString("Satellites"));
- UAVObjectField *field1 = object1->getField(QString("PDOP"));
-
- if (field && field1) {
- QString s = QString("GPS: ") + field->getValue().toString() + "\nPDP: "
- + field1->getValue().toString();
- if (s != satString) {
- gcsGPSStats->setPlainText(s);
- satString = s;
- }
- }
-}
-
-/*!
- \brief Updates the link stats
- */
-void PFDGadgetWidget::updateLinkStatus(UAVObject *object1)
-{
- // TODO: find a way to avoid updating the graphics if the value
- // has not changed since the last update
- // Double check that the field exists:
- QString st = QString("Status");
- QString tdr = QString("TxDataRate");
- QString rdr = QString("RxDataRate");
- UAVObjectField *field = object1->getField(st);
- UAVObjectField *field2 = object1->getField(tdr);
- UAVObjectField *field3 = object1->getField(rdr);
-
- if (field && field2 && field3) {
- QString s = field->getValue().toString();
- if (m_renderer->elementExists("gcstelemetry-" + s) && gcsTelemetryArrow) {
- gcsTelemetryArrow->setElementId("gcstelemetry-" + s);
- } else { // Safeguard
- gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected");
- }
- double v1 = field2->getDouble();
- double v2 = field3->getDouble();
- s.sprintf("%.0f/%.0f", v1, v2);
- if (gcsTelemetryStats) {
- gcsTelemetryStats->setPlainText(s);
- }
- } else {
- qDebug() << "UpdateLinkStatus: Wrong field, maybe an issue with object disconnection ?";
- }
-}
-
-/*!
- \brief Reads the updated attitude and computes the new display position
-
- Resolution is 1 degree roll & 1/7.5 degree pitch.
- */
-void PFDGadgetWidget::updateAttitude(UAVObject *object1)
-{
- setToolTipPrivate();
- UAVObjectField *rollField = object1->getField(QString("Roll"));
- UAVObjectField *yawField = object1->getField(QString("Yaw"));
- UAVObjectField *pitchField = object1->getField(QString("Pitch"));
- if (rollField && yawField && pitchField) {
- // These factors assume some things about the PFD SVG, namely:
- // - Roll, Pitch and Heading value in degrees
- // - Pitch lines are 300px high for a +20/-20 range, which means
- // 7.5 pixels per pitch degree.
- // TODO: loosen this constraint and only require a +/- 20 deg range,
- // and compute the height from the SVG element.
- // Also: keep the integer value only, to avoid unnecessary redraws
- rollTarget = -floor(rollField->getDouble() * 10) / 10;
- if ((rollTarget - rollValue) > 180) {
- rollValue += 360;
- } else if (((rollTarget - rollValue) < -180)) {
- rollValue -= 360;
- }
- pitchTarget = floor(pitchField->getDouble() * 7.5);
-
- // These factors assume some things about the PFD SVG, namely:
- // - Heading value in degrees
- // - "Scale" element is 540 degrees wide
-
- // Corvus Corax: "If you want a smooth transition between two angles, It is usually solved that by substracting
- // one from another, and if the result is >180 or <-180 I substract (respectively add) 360 degrees
- // to it. That way you always get the "shorter difference" to turn in."
- double fac = compassBandWidth / 540;
- headingTarget = yawField->getDouble() * (-fac);
- if (headingTarget != headingTarget) {
- headingTarget = headingValue; // NaN checking.
- }
- if ((headingValue - headingTarget) / fac > 180) {
- headingTarget += 360 * fac;
- } else if (((headingValue - headingTarget) / fac < -180)) {
- headingTarget -= 360 * fac;
- }
- headingTarget = floor(headingTarget * 10) / 10; // Avoid stupid redraws
-
- if (!dialTimer.isActive()) {
- dialTimer.start(); // Rearm the dial Timer which might be stopped.
- }
- } else {
- qDebug() << "Unable to get one of the fields for attitude update";
- }
-}
-
-/*!
- \brief Updates the compass reading and speed dial.
-
- This also updates speed & altitude according to PositionActual data.
-
- Note: the speed dial shows the ground speed at the moment, because
- there is no airspeed by default. Should become configurable in a future
- gadget release (TODO)
- */
-void PFDGadgetWidget::updateHeading(UAVObject *object)
-{
- Q_UNUSED(object);
-}
-
-/*!
- \brief Called by updates to @PositionActual to compute groundspeed from velocity
- */
-void PFDGadgetWidget::updateGroundspeed(UAVObject *object)
-{
- UAVObjectField *northField = object->getField("North");
- UAVObjectField *eastField = object->getField("East");
-
- if (northField && eastField) {
- double val = floor(sqrt(pow(northField->getDouble(), 2) + pow(eastField->getDouble(), 2)) * 10) / 10;
- groundspeedTarget = 3.6 * val * speedScaleHeight / 30;
-
- if (!dialTimer.isActive()) {
- dialTimer.start(); // Rearm the dial Timer which might be stopped.
- }
- } else {
- qDebug() << "UpdateHeading: Wrong field, maybe an issue with object disconnection ?";
- }
-}
-
-
-/*!
- \brief Called by updates to @AirspeedActual
- */
-void PFDGadgetWidget::updateAirspeed(UAVObject *object)
-{
- UAVObjectField *airspeedField = object->getField("CalibratedAirspeed");
-
- if (airspeedField) {
- airspeedTarget = airspeedField->getDouble();
-
- if (!dialTimer.isActive()) {
- dialTimer.start(); // Rearm the dial Timer which might be stopped.
- }
- } else {
- qDebug() << "UpdateHeading: Wrong field, maybe an issue with object disconnection ?";
- }
-}
-
-/*!
- \brief Called by the @ref PositionActual updates to show altitude
- */
-void PFDGadgetWidget::updateAltitude(UAVObject *object)
-{
- UAVObjectField *downField = object->getField("Down");
-
- if (downField) {
- altitudeTarget = -downField->getDouble();
-
- if (!dialTimer.isActive()) {
- dialTimer.start(); // Rearm the dial Timer which might be stopped.
- }
- } else {
- qDebug() << "Unable to get field for altitude update. Obj: " << object->getName();
- }
-}
-
-
-/*!
- \brief Called by the UAVObject which got updated
- */
-void PFDGadgetWidget::updateBattery(UAVObject *object1)
-{
- // Double check that the field exists:
- QString voltage = QString("Voltage");
- QString current = QString("Current");
- QString energy = QString("ConsumedEnergy");
- UAVObjectField *field = object1->getField(voltage);
- UAVObjectField *field2 = object1->getField(current);
- UAVObjectField *field3 = object1->getField(energy);
-
- if (field && field2 && field3) {
- QString s = QString();
- double v0 = field->getDouble();
- double v1 = field2->getDouble();
- double v2 = field3->getDouble();
- s.sprintf("%.2fV\n%.2fA\n%.0fmAh", v0, v1, v2);
- if (s != batString) {
- gcsBatteryStats->setPlainText(s);
- batString = s;
- }
- } else {
- qDebug() << "UpdateBattery: Wrong field, maybe an issue with object disconnection ?";
- }
-}
-
-
-/*!
- \brief Sets up the PFD from the SVG master file.
-
- Initializes the display, and does all the one-time calculations.
- */
-void PFDGadgetWidget::setDialFile(QString dfn)
-{
- QGraphicsScene *l_scene = scene();
-
- setBackgroundBrush(QBrush(Utils::StyleHelper::baseColor()));
- if (QFile::exists(dfn) && m_renderer->load(dfn) && m_renderer->isValid()) {
-/* The PFD element IDs are fixed, not like with the analog dial.
- - Background: background
- - Foreground: foreground (contains all fixed elements, including plane)
- - earth/sky : world
- - Roll scale: rollscale
- - compass frame: compass (part of the foreground)
- - compass band : compass-band
- - Home point: homewaypoint
- - Next point: nextwaypoint
- - Home point bearing: homewaypoint-bearing
- - Next point bearing: nextwaypoint-bearing
- - Speed rectangle (left side): speed-bg
- - Speed scale: speed-scale.
- - Black speed window: speed-window.
- - Altitude rectangle (right site): altitude-bg.
- - Altitude scale: altitude-scale.
- - Black altitude window: altitude-window.
- - GCS Telemetry status arrow: gcstelemetry-XXXX
- - Telemetry link rate: linkrate
- - GPS status text: gps-txt
- - Battery stats: battery-txt
- */
- l_scene->clear(); // Deletes all items contained in the scene as well.
- m_background = new CachedSvgItem();
- // All other items will be clipped to the shape of the background
- m_background->setFlags(QGraphicsItem::ItemClipsChildrenToShape |
- QGraphicsItem::ItemClipsToShape);
- m_background->setSharedRenderer(m_renderer);
- m_background->setElementId("background");
- l_scene->addItem(m_background);
-
- m_world = new CachedSvgItem();
- m_world->setParentItem(m_background);
- m_world->setSharedRenderer(m_renderer);
- m_world->setElementId("world");
- l_scene->addItem(m_world);
-
- // red Roll scale: rollscale
- m_rollscale = new CachedSvgItem();
- m_rollscale->setSharedRenderer(m_renderer);
- m_rollscale->setElementId("rollscale");
- l_scene->addItem(m_rollscale);
-
- // Home point:
- m_homewaypoint = new CachedSvgItem();
- // Next point:
- m_nextwaypoint = new CachedSvgItem();
- // Home point bearing:
- m_homepointbearing = new CachedSvgItem();
- // Next point bearing:
- m_nextpointbearing = new CachedSvgItem();
-
- QGraphicsSvgItem *m_foreground = new CachedSvgItem();
- m_foreground->setParentItem(m_background);
- m_foreground->setSharedRenderer(m_renderer);
- m_foreground->setElementId("foreground");
- l_scene->addItem(m_foreground);
-
- ////////////////////
- // Compass
- ////////////////////
- // Get the default location of the Compass:
- QMatrix compassMatrix = m_renderer->matrixForElement("compass");
- qreal startX = compassMatrix.mapRect(m_renderer->boundsOnElement("compass")).x();
- qreal startY = compassMatrix.mapRect(m_renderer->boundsOnElement("compass")).y();
- // Then once we have the initial location, we can put it
- // into a QGraphicsSvgItem which we will display at the same
- // place: we do this so that the heading scale can be clipped to
- // the compass dial region.
- m_compass = new CachedSvgItem();
- m_compass->setSharedRenderer(m_renderer);
- m_compass->setElementId("compass");
- m_compass->setFlags(QGraphicsItem::ItemClipsChildrenToShape |
- QGraphicsItem::ItemClipsToShape);
- l_scene->addItem(m_compass);
- QTransform matrix;
- matrix.translate(startX, startY);
- m_compass->setTransform(matrix, false);
-
- // Now place the compass scale inside:
- m_compassband = new CachedSvgItem();
- m_compassband->setSharedRenderer(m_renderer);
- m_compassband->setElementId("compass-band");
- m_compassband->setParentItem(m_compass);
- l_scene->addItem(m_compassband);
- matrix.reset();
- // Note: the compass band has to be a path, which means all text elements have to be
- // converted, ortherwise boundsOnElement does not compute the height correctly
- // if the highest element is a text element. This is a Qt Bug as far as I can tell.
-
- // compass-scale is the while bottom line inside the band: using the band's width
- // includes half the width of the letters, which causes errors:
- compassBandWidth = m_renderer->boundsOnElement("compass-scale").width();
-
- ////////////////////
- // Speed
- ////////////////////
- // Speedometer on the left hand:
- //
- compassMatrix = m_renderer->matrixForElement("speed-bg");
- startX = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-bg")).x();
- startY = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-bg")).y();
- QGraphicsSvgItem *verticalbg = new CachedSvgItem();
- verticalbg->setSharedRenderer(m_renderer);
- verticalbg->setElementId("speed-bg");
- verticalbg->setFlags(QGraphicsItem::ItemClipsChildrenToShape |
- QGraphicsItem::ItemClipsToShape);
- l_scene->addItem(verticalbg);
- matrix.reset();
- matrix.translate(startX, startY);
- verticalbg->setTransform(matrix, false);
-
- // Note: speed-scale should contain exactly 6 major ticks
- // for 30km/h
- m_speedscale = new QGraphicsItemGroup();
- m_speedscale->setParentItem(verticalbg);
-
- QGraphicsSvgItem *speedscalelines = new CachedSvgItem();
- speedscalelines->setSharedRenderer(m_renderer);
- speedscalelines->setElementId("speed-scale");
- speedScaleHeight = m_renderer->matrixForElement("speed-scale").mapRect(
- m_renderer->boundsOnElement("speed-scale")).height();
- startX = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-bg")).width();
- startX -= m_renderer->matrixForElement("speed-scale").mapRect(
- m_renderer->boundsOnElement("speed-scale")).width();
- matrix.reset();
- matrix.translate(startX, 0);
- speedscalelines->setTransform(matrix, false);
- // Quick way to reposition the item before putting it in the group:
- speedscalelines->setParentItem(verticalbg);
- m_speedscale->addToGroup(speedscalelines); // (reparents the item)
-
- // Add the scale text elements:
- QGraphicsTextItem *speed0 = new QGraphicsTextItem("0");
- speed0->setDefaultTextColor(QColor("White"));
- speed0->setFont(QFont("Arial", (int)speedScaleHeight / 30));
- if (hqFonts) {
- speed0->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- }
- matrix.reset();
- matrix.translate(compassMatrix.mapRect(m_renderer->boundsOnElement("speed-bg")).width() / 10, -speedScaleHeight / 30);
- speed0->setTransform(matrix, false);
- speed0->setParentItem(verticalbg);
- m_speedscale->addToGroup(speed0);
- for (int i = 0; i < 6; i++) {
- speed0 = new QGraphicsTextItem("");
- speed0->setDefaultTextColor(QColor("White"));
- speed0->setFont(QFont("Arial", (int)speedScaleHeight / 30));
- speed0->setPlainText(QString().setNum(i * 5 + 1));
- if (hqFonts) {
- speed0->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- }
- matrix.translate(0, speedScaleHeight / 6);
- speed0->setTransform(matrix, false);
- speed0->setParentItem(verticalbg);
- m_speedscale->addToGroup(speed0);
- }
- // Now vertically center the speed scale on the speed background
- QRectF rectB = verticalbg->boundingRect();
- QRectF rectN = speedscalelines->boundingRect();
- m_speedscale->setPos(0, rectB.height() / 2 - rectN.height() / 2 - rectN.height() / 6);
-
- // Isolate the speed window and put it above the speed scale
- compassMatrix = m_renderer->matrixForElement("speed-window");
- startX = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-window")).x();
- startY = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-window")).y();
- qreal speedWindowHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-window")).height();
- QGraphicsSvgItem *speedwindow = new CachedSvgItem();
- speedwindow->setSharedRenderer(m_renderer);
- speedwindow->setElementId("speed-window");
- speedwindow->setFlags(QGraphicsItem::ItemClipsChildrenToShape |
- QGraphicsItem::ItemClipsToShape);
- l_scene->addItem(speedwindow);
- matrix.reset();
- matrix.translate(startX, startY);
- speedwindow->setTransform(matrix, false);
-
- // Last create a Text Item at the location of the speed window
- // and save it for future updates:
- m_speedtext = new QGraphicsTextItem("0000");
- m_speedtext->setDefaultTextColor(QColor("White"));
- m_speedtext->setFont(QFont("Arial", (int)speedWindowHeight / 2));
- if (hqFonts) {
- m_speedtext->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- }
- m_speedtext->setParentItem(speedwindow);
-
- ////////////////////
- // Altitude
- ////////////////////
- // Right hand, very similar to speed
- compassMatrix = m_renderer->matrixForElement("altitude-bg");
- startX = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-bg")).x();
- startY = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-bg")).y();
- verticalbg = new CachedSvgItem();
- verticalbg->setSharedRenderer(m_renderer);
- verticalbg->setElementId("altitude-bg");
- verticalbg->setFlags(QGraphicsItem::ItemClipsChildrenToShape |
- QGraphicsItem::ItemClipsToShape);
- l_scene->addItem(verticalbg);
- matrix.reset();
- matrix.translate(startX, startY);
- verticalbg->setTransform(matrix, false);
-
- // Note: altitude-scale should contain exactly 6 major ticks
- // for 30 meters
- m_altitudescale = new QGraphicsItemGroup();
- m_altitudescale->setParentItem(verticalbg);
-
- QGraphicsSvgItem *altitudescalelines = new CachedSvgItem();
- altitudescalelines->setSharedRenderer(m_renderer);
- altitudescalelines->setElementId("altitude-scale");
- altitudeScaleHeight = m_renderer->matrixForElement("altitude-scale").mapRect(
- m_renderer->boundsOnElement("altitude-scale")).height();
- // Quick way to reposition the item before putting it in the group:
- altitudescalelines->setParentItem(verticalbg);
- m_altitudescale->addToGroup(altitudescalelines); // (reparents the item)
-
- // Add the scale text elements:
- speed0 = new QGraphicsTextItem("XXXX");
- speed0->setDefaultTextColor(QColor("White"));
- speed0->setFont(QFont("Arial", (int)altitudeScaleHeight / 30));
- if (hqFonts) {
- speed0->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- }
- matrix.reset();
- matrix.translate(m_renderer->matrixForElement("altitude-scale").mapRect(m_renderer->boundsOnElement("altitude-scale")).width()
- + m_renderer->matrixForElement("altitude-bg").mapRect(m_renderer->boundsOnElement("altitude-bg")).width() / 10, -altitudeScaleHeight / 30);
- speed0->setTransform(matrix, false);
- speed0->setParentItem(verticalbg);
- m_altitudescale->addToGroup(speed0);
- for (int i = 0; i < 6; i++) {
- speed0 = new QGraphicsTextItem("XXXX");
- speed0->setDefaultTextColor(QColor("White"));
- speed0->setFont(QFont("Arial", (int)altitudeScaleHeight / 30));
- speed0->setPlainText(QString().setNum(i * 5 + 1));
- if (hqFonts) {
- speed0->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- }
- matrix.translate(0, altitudeScaleHeight / 6);
- speed0->setTransform(matrix, false);
- speed0->setParentItem(verticalbg);
- m_altitudescale->addToGroup(speed0);
- }
- // Now vertically center the speed scale on the speed background
- rectB = verticalbg->boundingRect();
- rectN = altitudescalelines->boundingRect();
- m_altitudescale->setPos(0, rectB.height() / 2 - rectN.height() / 2 - rectN.height() / 6);
-
- // Isolate the Altitude window and put it above the altitude scale
- compassMatrix = m_renderer->matrixForElement("altitude-window");
- startX = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-window")).x();
- startY = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-window")).y();
- qreal altitudeWindowHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-window")).height();
- QGraphicsSvgItem *altitudewindow = new CachedSvgItem();
- altitudewindow->setSharedRenderer(m_renderer);
- altitudewindow->setElementId("altitude-window");
- altitudewindow->setFlags(QGraphicsItem::ItemClipsChildrenToShape |
- QGraphicsItem::ItemClipsToShape);
- l_scene->addItem(altitudewindow);
- matrix.reset();
- matrix.translate(startX, startY);
- altitudewindow->setTransform(matrix, false);
-
- // Last create a Text Item at the location of the speed window
- // and save it for future updates:
- m_altitudetext = new QGraphicsTextItem("0000");
- m_altitudetext->setDefaultTextColor(QColor("White"));
- m_altitudetext->setFont(QFont("Arial", (int)altitudeWindowHeight / 2));
- if (hqFonts) {
- m_altitudetext->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- }
- m_altitudetext->setParentItem(altitudewindow);
- startX = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-window")).width() / 10;
- matrix.reset();
- matrix.translate(startX, 0);
- m_altitudetext->setTransform(matrix, false);
-
- ////////////////
- // GCS Telemetry Indicator
- ////////////////
- if (m_renderer->elementExists("gcstelemetry-Disconnected")) {
- compassMatrix = m_renderer->matrixForElement("gcstelemetry-Disconnected");
- startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).x();
- startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).y();
- gcsTelemetryArrow = new CachedSvgItem();
- gcsTelemetryArrow->setSharedRenderer(m_renderer);
- gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected");
- l_scene->addItem(gcsTelemetryArrow);
- matrix.reset();
- matrix.translate(startX, startY);
- gcsTelemetryArrow->setTransform(matrix, false);
- } else {
- gcsTelemetryArrow = NULL;
- }
-
- if (m_renderer->elementExists("linkrate")) {
- compassMatrix = m_renderer->matrixForElement("linkrate");
- startX = compassMatrix.mapRect(m_renderer->boundsOnElement("linkrate")).x();
- startY = compassMatrix.mapRect(m_renderer->boundsOnElement("linkrate")).y();
- qreal linkRateHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("linkrate")).height();
- gcsTelemetryStats = new QGraphicsTextItem();
- gcsTelemetryStats->setDefaultTextColor(QColor("White"));
- gcsTelemetryStats->setFont(QFont("Arial", (int)linkRateHeight));
- if (hqFonts) {
- gcsTelemetryStats->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- }
- l_scene->addItem(gcsTelemetryStats);
- matrix.reset();
- matrix.translate(startX, startY - linkRateHeight / 2);
- gcsTelemetryStats->setTransform(matrix, false);
- } else {
- gcsTelemetryStats = NULL;
- }
-
-
- ////////////////
- // GCS Battery Indicator
- ////////////////
- /* (to be used the day I add a green/yellow/red indicator)
- compassMatrix = m_renderer->matrixForElement("gcstelemetry-Disconnected");
- startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).x();
- startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).y();
- gcsTelemetryArrow = new CachedSvgItem();
- gcsTelemetryArrow->setSharedRenderer(m_renderer);
- gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected");
- l_scene->addItem(gcsTelemetryArrow);
- matrix.reset();
- matrix.translate(startX,startY);
- gcsTelemetryArrow->setTransform(matrix,false);
- */
-
- if (m_renderer->elementExists("battery-txt")) {
- compassMatrix = m_renderer->matrixForElement("battery-txt");
- startX = compassMatrix.mapRect(m_renderer->boundsOnElement("battery-txt")).x();
- startY = compassMatrix.mapRect(m_renderer->boundsOnElement("battery-txt")).y();
- qreal batStatHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("battery-txt")).height();
- gcsBatteryStats = new QGraphicsTextItem("Battery");
- gcsBatteryStats->setDefaultTextColor(QColor("White"));
- gcsBatteryStats->setFont(QFont("Arial", (int)batStatHeight));
- if (hqFonts) {
- gcsBatteryStats->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- }
- l_scene->addItem(gcsBatteryStats);
- matrix.reset();
- matrix.translate(startX, startY - batStatHeight / 2);
- gcsBatteryStats->setTransform(matrix, false);
- } else {
- gcsBatteryStats = NULL;
- }
-
- ////////////////
- // GCS GPS Indicator
- ////////////////
- /* (to be used the day I add a green/yellow/red indicator)
- compassMatrix = m_renderer->matrixForElement("gcstelemetry-Disconnected");
- startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).x();
- startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).y();
- gcsTelemetryArrow = new CachedSvgItem();
- gcsTelemetryArrow->setSharedRenderer(m_renderer);
- gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected");
- l_scene->addItem(gcsTelemetryArrow);
- matrix.reset();
- matrix.translate(startX,startY);
- gcsTelemetryArrow->setTransform(matrix,false);
- */
-
- if (m_renderer->elementExists("gps-txt")) {
- compassMatrix = m_renderer->matrixForElement("gps-txt");
- startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gps-txt")).x();
- startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gps-txt")).y();
- qreal gpsStatHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("gps-txt")).height();
- gcsGPSStats = new QGraphicsTextItem("GPS");
- gcsGPSStats->setDefaultTextColor(QColor("White"));
- gcsGPSStats->setFont(QFont("Arial", (int)gpsStatHeight));
- if (hqFonts) {
- gcsGPSStats->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- }
- l_scene->addItem(gcsGPSStats);
- matrix.reset();
- matrix.translate(startX, startY - gpsStatHeight / 2);
- gcsGPSStats->setTransform(matrix, false);
- } else {
- gcsGPSStats = NULL;
- }
-
- l_scene->setSceneRect(m_background->boundingRect());
-
- /////////////////
- // Item placement
- /////////////////
-
- // Now Initialize the center for all transforms of the relevant elements to the
- // center of the background:
-
- // 1) Move the center of the needle to the center of the background.
- rectB = m_background->boundingRect();
- rectN = m_world->boundingRect();
- m_world->setPos(rectB.width() / 2 - rectN.width() / 2, rectB.height() / 2 - rectN.height() / 2);
- // 2) Put the transform origin point of the needle at its center.
- m_world->setTransformOriginPoint(rectN.width() / 2, rectN.height() / 2);
-
- rectN = m_rollscale->boundingRect();
- m_rollscale->setPos(rectB.width() / 2 - rectN.width() / 2, rectB.height() / 2 - rectN.height() / 2);
- m_rollscale->setTransformOriginPoint(rectN.width() / 2, rectN.height() / 2);
-
- // Also to the same init for the compass:
- rectB = m_compass->boundingRect();
- rectN = m_compassband->boundingRect();
- m_compassband->setPos(rectB.width() / 2 - rectN.width() / 2, rectB.height() / 2 - rectN.height() / 2);
- m_compassband->setTransformOriginPoint(rectN.width() / 2, rectN.height() / 2);
-
- // Last: we just loaded the dial file which is by default valid for a "zero" value
- // of the needles, so we have to reset the needles too upon dial file loading, otherwise
- // we would end up with an offset when we change a dial file and the needle value
- // is not zero at that time.
- rollValue = 0;
- pitchValue = 0;
- headingValue = 0;
- groundspeedValue = 0;
- altitudeValue = 0;
- pfdError = false;
- if (!dialTimer.isActive()) {
- dialTimer.start(); // Rearm the dial Timer which might be stopped.
- }
- } else { qDebug() << "Error on PFD artwork file.";
- m_renderer->load(QString(":/pfd/images/pfd-default.svg"));
- l_scene->clear(); // This also deletes all items contained in the scene.
- m_background = new CachedSvgItem();
- m_background->setSharedRenderer(m_renderer);
- l_scene->addItem(m_background);
- pfdError = true; }
-}
-
-void PFDGadgetWidget::paint()
-{
- // update();
-}
-
-void PFDGadgetWidget::paintEvent(QPaintEvent *event)
-{
- // Skip painting until the dial file is loaded
- if (!m_renderer->isValid()) {
- qDebug() << "Dial file not loaded, not rendering";
- return;
- }
- QGraphicsView::paintEvent(event);
-}
-
-// This event enables the dial to be dynamically resized
-// whenever the gadget is resized, taking advantage of the vector
-// nature of SVG dials.
-void PFDGadgetWidget::resizeEvent(QResizeEvent *event)
-{
- Q_UNUSED(event);
- fitInView(m_background, Qt::KeepAspectRatio);
-}
-
-
-/*!
- \brief Update method for the vertical scales
- */
-void PFDGadgetWidget::moveVerticalScales() {}
-
-void PFDGadgetWidget::moveSky()
-{
- int dialCount = 2; // Gets decreased by one for each element
-
- // which has finished moving
-// qDebug() << "MoveSky";
- /// TODO: optimize!!!
- if (pfdError) {
- // skyDialTimer.stop();
- return;
- }
-
- // In some instances, it can happen that the rollValue & target are
- // invalid inside the UAVObjects, and become a "nan" value, which freezes
- // the PFD and the whole GCS: for this reason, we check this here.
- // The strange check below works, it is a workaround because "isnan(double)"
- // is not supported on every compiler.
- if (rollTarget != rollTarget || pitchTarget != pitchTarget) {
- return;
- }
- //////
- // Roll
- //////
- if (rollValue != rollTarget) {
- double rollDiff;
- if ((abs((rollValue - rollTarget) * 10) > 5) && beSmooth) {
- rollDiff = (rollTarget - rollValue) / 2;
- } else {
- rollDiff = rollTarget - rollValue;
- dialCount--;
- }
- m_world->setRotation(m_world->rotation() + rollDiff);
- m_rollscale->setRotation(m_rollscale->rotation() + rollDiff);
- rollValue += rollDiff;
- } else {
- dialCount--;
- }
-
- //////
- // Pitch
- //////
- if (pitchValue != pitchTarget) {
- double pitchDiff;
- if ((abs((pitchValue - pitchTarget) * 10) > 5) && beSmooth) {
- // if (0) {
- pitchDiff = (pitchTarget - pitchValue) / 2;
- } else {
- pitchDiff = pitchTarget - pitchValue;
- dialCount--;
- }
- QPointF opd = QPointF(0, pitchDiff);
- m_world->setTransform(QTransform::fromTranslate(opd.x(), opd.y()), true);
- QPointF oop = m_world->transformOriginPoint();
- m_world->setTransformOriginPoint((oop.x() - opd.x()), (oop.y() - opd.y()));
- pitchValue += pitchDiff;
- } else {
- dialCount--;
- }
-
- if (dialCount) {
- scene()->update(sceneRect());
- }
- // if (!dialCount)
- // skyDialTimer.stop();
-}
-
-
-// Take an input value and move the elements accordingly.
-// Movement is smooth, starts fast and slows down when
-// approaching the target.
-//
-void PFDGadgetWidget::moveNeedles()
-{
- int dialCount = 3; // Gets decreased by one for each element
-
- // which has finished moving
-
-// qDebug() << "MoveNeedles";
- /// TODO: optimize!!!
-
- if (pfdError) {
- dialTimer.stop();
- return;
- }
-
- //////
- // Heading
- //
- // If you want a smooth transition between two angles, It is usually solved that by substracting
- // one from another, and if the result is >180 or <-180 I substract (respectively add) 360 degrees
- // to it. That way you always get the "shorter difference" to turn in.
- //////
- if (headingValue != headingTarget) {
- double headingDiff;
- if ((abs((headingValue - headingTarget) * 10) > 5) && beSmooth) {
- headingDiff = (headingTarget - headingValue) / 5;
- } else {
- headingDiff = headingTarget - headingValue;
- dialCount--;
- }
- double threshold = 180 * compassBandWidth / 540;
- // Note: rendering can jump oh so very slightly when crossing the 180 degree
- // boundary, should not impact actual useability of the display.
- if ((headingValue + headingDiff) >= threshold) {
- // We went over 180°: activate a -360 degree offset
- headingDiff -= 2 * threshold;
- headingTarget -= 2 * threshold;
- } else if ((headingValue + headingDiff) < -threshold) {
- // We went under -180°: remove the -360 degree offset
- headingDiff += 2 * threshold;
- headingTarget += 2 * threshold;
- }
- QPointF opd = QPointF(headingDiff, 0);
- m_compassband->setTransform(QTransform::fromTranslate(opd.x(), opd.y()), true);
- headingValue += headingDiff;
- } else {
- dialCount--;
- }
-
- //////
- // Airspeed
- //////
- if (airspeedValue != airspeedTarget) {
- if ((abs(airspeedValue - airspeedTarget) > speedScaleHeight / 100) && beSmooth) {
- airspeedValue += (airspeedTarget - airspeedValue) / 2;
- } else {
- airspeedValue = airspeedTarget;
- dialCount--;
- }
-
- float airspeed_kph = airspeedValue * 3.6;
- float airspeed_kph_scale = airspeed_kph * speedScaleHeight / 30;
-
- qreal x = m_speedscale->transform().dx();
- // opd = QPointF(x,fmod(airspeed_kph,speedScaleHeight/6));
- // fmod does rounding errors!! the formula below works better:
- QPointF opd = QPointF(x, airspeed_kph_scale - floor(airspeed_kph_scale / speedScaleHeight * 6) * speedScaleHeight / 6);
- m_speedscale->setTransform(QTransform::fromTranslate(opd.x(), opd.y()), false);
-
- double speedText = airspeed_kph;
- QString s = QString().sprintf("%.0f", speedText);
- m_speedtext->setPlainText(s);
-
- // Now update the text elements inside the scale:
- // (Qt documentation states that the list has the same order
- // as the item add order in the QGraphicsItemGroup)
- QList textList = m_speedscale->childItems();
- qreal val = 5 * floor(airspeed_kph_scale / speedScaleHeight * 6) + 20;
- foreach(QGraphicsItem * item, textList) {
- if (QGraphicsTextItem * text = qgraphicsitem_cast(item)) {
- QString s = (val < 0) ? QString() : QString().sprintf("%.0f", val);
- if (text->toPlainText() == s) {
- break; // This should happen at element one if is has not changed, indicating
- }
- // that it's not necessary to do the rest of the list
- text->setPlainText(s);
- val -= 5;
- }
- }
- } else {
- dialCount--;
- }
-
- //////
- // Groundspeed
- //////
- if (groundspeedValue != groundspeedTarget) {
- groundspeedValue = groundspeedTarget;
- qreal x = m_speedscale->transform().dx();
- // opd = QPointF(x,fmod(groundspeedValue,speedScaleHeight/6));
- // fmod does rounding errors!! the formula below works better:
- QPointF opd = QPointF(x, groundspeedValue - floor(groundspeedValue / speedScaleHeight * 6) * speedScaleHeight / 6);
- m_speedscale->setTransform(QTransform::fromTranslate(opd.x(), opd.y()), false);
-
- double speedText = groundspeedValue / speedScaleHeight * 30;
- QString s = QString().sprintf("%.0f", speedText);
- m_speedtext->setPlainText(s);
-
- // Now update the text elements inside the scale:
- // (Qt documentation states that the list has the same order
- // as the item add order in the QGraphicsItemGroup)
- QList textList = m_speedscale->childItems();
- qreal val = 5 * floor(groundspeedValue / speedScaleHeight * 6) + 20;
- foreach(QGraphicsItem * item, textList) {
- if (QGraphicsTextItem * text = qgraphicsitem_cast(item)) {
- QString s = (val < 0) ? QString() : QString().sprintf("%.0f", val);
- if (text->toPlainText() == s) {
- break; // This should happen at element one if is has not changed, indicating
- }
- // that it's not necessary to do the rest of the list
- text->setPlainText(s);
- val -= 5;
- }
- }
- }
-
- //////
- // Altitude
- //////
- if (altitudeValue != altitudeTarget) {
- if ((abs(altitudeValue - altitudeTarget) > altitudeScaleHeight / 100) && beSmooth) {
- altitudeValue += (altitudeTarget - altitudeValue) / 2;
- } else {
- altitudeValue = altitudeTarget;
- dialCount--;
- }
-
- // The altitude scale represents 30 meters
- float altitudeValue_scale = floor(altitudeValue * 10) / 10 * altitudeScaleHeight / 30;
-
- qreal x = m_altitudescale->transform().dx();
- // opd = QPointF(x,fmod(altitudeValue,altitudeScaleHeight/6));
- // fmod does rounding errors!! the formula below works better:
- QPointF opd = QPointF(x, altitudeValue_scale - floor(altitudeValue_scale / altitudeScaleHeight * 6) * altitudeScaleHeight / 6);
- m_altitudescale->setTransform(QTransform::fromTranslate(opd.x(), opd.y()), false);
-
- double altitudeText = altitudeValue;
- QString s = QString().sprintf("%.0f", altitudeText);
- m_altitudetext->setPlainText(s);
-
- // Now update the text elements inside the scale:
- // (Qt documentation states that the list has the same order
- // as the item add order in the QGraphicsItemGroup)
- QList textList = m_altitudescale->childItems();
- qreal val = 5 * floor(altitudeValue_scale / altitudeScaleHeight * 6) + 20;
- foreach(QGraphicsItem * item, textList) {
- if (QGraphicsTextItem * text = qgraphicsitem_cast(item)) {
- QString s = (val < 0) ? QString() : QString().sprintf("%.0f", val);
- if (text->toPlainText() == s) {
- break; // This should happen at element one if is has not changed, indicating
- }
- // that it's not necessary to do the rest of the list
- text->setPlainText(s);
- val -= 5;
- }
- }
- } else {
- dialCount--;
- }
-
- if (!dialCount) {
- dialTimer.stop();
- } else {
- scene()->update(sceneRect());
- }
-}
-
-/**
- @}
- @}
- */
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetwidget.h b/ground/openpilotgcs/src/plugins/pfd/pfdgadgetwidget.h
deleted file mode 100644
index d80b73432..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfdgadgetwidget.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- ******************************************************************************
- *
- * @file pfdgadgetwidget.h
- * @author Edouard Lafargue Copyright (C) 2010.
- * @addtogroup GCSPlugins GCS Plugins
- * @{
- * @addtogroup OPMapPlugin Primary Flight Display Plugin
- * @{
- * @brief The Primary Flight Display Gadget
- *****************************************************************************/
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PFDGADGETWIDGET_H_
-#define PFDGADGETWIDGET_H_
-
-#include "pfdgadgetconfiguration.h"
-#include "extensionsystem/pluginmanager.h"
-#include "uavobjectmanager.h"
-#include "uavobject.h"
-#include
-#include
-#include
-
-#include
-#include
-
-class PFDGadgetWidget : public QGraphicsView {
- Q_OBJECT
-
-public:
- PFDGadgetWidget(QWidget *parent = 0);
- ~PFDGadgetWidget();
- void setDialFile(QString dfn);
- void paint();
- // Sets up needle/UAVObject connections:
- void connectNeedles();
- void enableOpenGL(bool flag);
- void setHqFonts(bool flag)
- {
- hqFonts = flag;
- }
- void enableSmoothUpdates(bool flag)
- {
- beSmooth = flag;
- }
-
-
-public slots:
- void updateAttitude(UAVObject *object1);
- void updateHeading(UAVObject *object1);
- void updateGPS(UAVObject *object1);
- void updateGroundspeed(UAVObject *object1);
- void updateAirspeed(UAVObject *object1);
- void updateAltitude(UAVObject *object1);
- void updateBattery(UAVObject *object1);
- void updateLinkStatus(UAVObject *object1);
-
-protected:
- void paintEvent(QPaintEvent *event);
- void resizeEvent(QResizeEvent *event);
-
-
-private slots:
- void moveNeedles();
- void moveVerticalScales();
- void moveSky();
- void setToolTipPrivate();
-private:
- QSvgRenderer *m_renderer;
-
- // Background: background
- QGraphicsSvgItem *m_background;
- // earth/sky : world
- QGraphicsSvgItem *m_world;
- // Roll scale: rollscale
- QGraphicsSvgItem *m_rollscale;
- // Compass dial:
- QGraphicsSvgItem *m_compass;
- // Compass band:
- QGraphicsSvgItem *m_compassband;
- // Home point:
- QGraphicsSvgItem *m_homewaypoint;
- // Next point:
- QGraphicsSvgItem *m_nextwaypoint;
- // Home point bearing:
- QGraphicsSvgItem *m_homepointbearing;
- // Next point bearing:
- QGraphicsSvgItem *m_nextpointbearing;
- // Speed scale:
- QGraphicsItemGroup *m_speedscale;
- // Speed indicator text:
- QGraphicsTextItem *m_speedtext;
- // Vertical altitude scale:
- QGraphicsItemGroup *m_altitudescale;
- // Altitude indicator text:
- QGraphicsTextItem *m_altitudetext;
- // GCS link status Arrow
- QGraphicsSvgItem *gcsTelemetryArrow;
- QGraphicsTextItem *gcsTelemetryStats;
- QGraphicsTextItem *gcsBatteryStats;
- QGraphicsTextItem *gcsGPSStats;
-
- // The Value and target variables
- // are expressed in degrees
- double rollTarget;
- double rollValue;
- double pitchTarget;
- double pitchValue;
- double headingTarget;
- double headingValue;
- double groundspeedTarget;
- double groundspeedValue;
- double airspeedTarget;
- double airspeedValue;
- double altitudeTarget;
- double altitudeValue;
-
- qreal compassBandWidth;
- qreal speedScaleHeight;
- qreal altitudeScaleHeight;
-
- // Name of the fields to read when an update is received:
- UAVDataObject *airspeedObj;
- UAVDataObject *altitudeObj;
- UAVDataObject *attitudeObj;
- UAVDataObject *groundspeedObj;
- UAVDataObject *headingObj;
- UAVDataObject *gpsObj;
- UAVDataObject *gcsTelemetryObj;
- UAVDataObject *gcsBatteryObj;
-
- // Rotation timer
- QTimer dialTimer;
- QTimer skyDialTimer;
-
- QString satString;
- QString batString;
-
- // Flag to check for pfd Error
- bool pfdError;
- // Flag to enable better rendering of fonts in OpenGL
- bool hqFonts;
- bool beSmooth;
-};
-#endif /* PFDGADGETWIDGET_H_ */
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfdplugin.cpp b/ground/openpilotgcs/src/plugins/pfd/pfdplugin.cpp
deleted file mode 100644
index fce87ea88..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfdplugin.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- ******************************************************************************
- *
- * @file pfdplugin.h
- * @author Edouard Lafargue Copyright (C) 2010.
- * @addtogroup GCSPlugins GCS Plugins
- * @{
- * @addtogroup OPMapPlugin Primary Flight Display Plugin
- * @{
- * @brief The Primary Flight Display Gadget
- *****************************************************************************/
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "pfdplugin.h"
-#include "pfdgadgetfactory.h"
-#include
-#include
-#include
-#include
-
-
-PFDPlugin::PFDPlugin()
-{
- // Do nothing
-}
-
-PFDPlugin::~PFDPlugin()
-{
- // Do nothing
-}
-
-bool PFDPlugin::initialize(const QStringList & args, QString *errMsg)
-{
- Q_UNUSED(args);
- Q_UNUSED(errMsg);
- mf = new PFDGadgetFactory(this);
- addAutoReleasedObject(mf);
-
- return true;
-}
-
-void PFDPlugin::extensionsInitialized()
-{
- // Do nothing
-}
-
-void PFDPlugin::shutdown()
-{
- // Do nothing
-}
-Q_EXPORT_PLUGIN(PFDPlugin)
diff --git a/ground/openpilotgcs/src/plugins/pfd/pfdplugin.h b/ground/openpilotgcs/src/plugins/pfd/pfdplugin.h
deleted file mode 100644
index 067384793..000000000
--- a/ground/openpilotgcs/src/plugins/pfd/pfdplugin.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- ******************************************************************************
- *
- * @file pfdplugin.h
- * @author Edouard Lafargue Copyright (C) 2010.
- * @addtogroup GCSPlugins GCS Plugins
- * @{
- * @addtogroup OPMapPlugin Primary Flight Display Plugin
- * @{
- * @brief The Primary Flight Display Gadget
- *****************************************************************************/
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PFDPLUGIN_H_
-#define PFDPLUGIN_H_
-
-#include
-
-class PFDGadgetFactory;
-
-class PFDPlugin : public ExtensionSystem::IPlugin {
-public:
- PFDPlugin();
- ~PFDPlugin();
-
- void extensionsInitialized();
- bool initialize(const QStringList & arguments, QString *errorString);
- void shutdown();
-private:
- PFDGadgetFactory *mf;
-};
-#endif /* PFDPLUGIN_H_ */
diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp
index 265a96497..365a323b7 100644
--- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp
+++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp
@@ -46,6 +46,10 @@ void PfdQmlGadget::loadConfiguration(IUAVGadgetConfiguration *config)
m_widget->setLatitude(m->latitude());
m_widget->setLongitude(m->longitude());
m_widget->setAltitude(m->altitude());
+ m_widget->setSpeedFactor(m->speedFactor());
+ m_widget->setSpeedUnit(m->speedUnit());
+ m_widget->setAltitudeFactor(m->altitudeFactor());
+ m_widget->setAltitudeUnit(m->altitudeUnit());
// setting OSGEARTH_CACHE_ONLY seems to work the most reliably
// between osgEarth versions I tried
diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.cpp
index e00e52a1d..d3efb6a42 100644
--- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.cpp
+++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.cpp
@@ -31,8 +31,19 @@ PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(QString classId, QSettings
m_latitude(0),
m_longitude(0),
m_altitude(0),
- m_cacheOnly(false)
+ m_cacheOnly(false),
+ m_speedFactor(1.0),
+ m_altitudeFactor(1.0)
{
+
+ m_speedMap[1.0] = "m/s";
+ m_speedMap[3.6] = "km/h";
+ m_speedMap[2.2369] = "mph";
+ m_speedMap[1.9438] = "knots";
+
+ m_altitudeMap[1.0] = "m";
+ m_altitudeMap[3.2808] = "ft";
+
// if a saved configuration exists load it
if (qSettings != 0) {
m_qmlFile = qSettings->value("qmlFile").toString();
@@ -48,6 +59,8 @@ PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(QString classId, QSettings
m_longitude = qSettings->value("longitude").toDouble();
m_altitude = qSettings->value("altitude").toDouble();
m_cacheOnly = qSettings->value("cacheOnly").toBool();
+ m_speedFactor = qSettings->value("speedFactor").toDouble();
+ m_altitudeFactor = qSettings->value("altitudeFactor").toDouble();
}
}
@@ -68,6 +81,8 @@ IUAVGadgetConfiguration *PfdQmlGadgetConfiguration::clone()
m->m_longitude = m_longitude;
m->m_altitude = m_altitude;
m->m_cacheOnly = m_cacheOnly;
+ m->m_speedFactor = m_speedFactor;
+ m->m_altitudeFactor = m_altitudeFactor;
return m;
}
@@ -91,4 +106,6 @@ void PfdQmlGadgetConfiguration::saveConfig(QSettings *qSettings) const
qSettings->setValue("longitude", m_longitude);
qSettings->setValue("altitude", m_altitude);
qSettings->setValue("cacheOnly", m_cacheOnly);
+ qSettings->setValue("speedFactor", m_speedFactor);
+ qSettings->setValue("altitudeFactor", m_altitudeFactor);
}
diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.h b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.h
index f09e4a0ad..7171c3bd9 100644
--- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.h
+++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.h
@@ -18,6 +18,7 @@
#define PFDQMLGADGETCONFIGURATION_H
#include
+#include
using namespace Core;
@@ -62,6 +63,14 @@ public:
{
m_cacheOnly = flag;
}
+ void setSpeedFactor(double factor)
+ {
+ m_speedFactor = factor;
+ }
+ void setAltitudeFactor(double factor)
+ {
+ m_altitudeFactor = factor;
+ }
QString qmlFile() const
{
@@ -99,6 +108,34 @@ public:
{
return m_cacheOnly;
}
+ double speedFactor() const
+ {
+ return m_speedFactor;
+ }
+ double altitudeFactor() const
+ {
+ return m_altitudeFactor;
+ }
+
+ QString speedUnit() const
+ {
+ return m_speedMap[m_speedFactor];
+ }
+
+ QString altitudeUnit() const
+ {
+ return m_altitudeMap[m_altitudeFactor];
+ }
+
+ QMapIterator speedMapIterator()
+ {
+ return QMapIterator(m_speedMap);
+ }
+
+ QMapIterator altitudeMapIterator()
+ {
+ return QMapIterator(m_altitudeMap);
+ }
void saveConfig(QSettings *settings) const;
IUAVGadgetConfiguration *clone();
@@ -113,6 +150,10 @@ private:
double m_longitude;
double m_altitude;
bool m_cacheOnly;
+ double m_speedFactor;
+ double m_altitudeFactor;
+ QMap m_speedMap;
+ QMap m_altitudeMap;
};
#endif // PfdQmlGADGETCONFIGURATION_H
diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetfactory.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetfactory.cpp
index 0fa0503aa..f7d6b1f66 100644
--- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetfactory.cpp
+++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetfactory.cpp
@@ -22,7 +22,7 @@
PfdQmlGadgetFactory::PfdQmlGadgetFactory(QObject *parent) :
IUAVGadgetFactory(QString("PfdQmlGadget"),
- tr("PFD (qml)"),
+ tr("PFD"),
parent)
{}
diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.cpp
index 0b20b8480..99fb40501 100644
--- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.cpp
+++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.cpp
@@ -62,6 +62,23 @@ QWidget *PfdQmlGadgetOptionsPage::createPage(QWidget *parent)
options_page->altitude->setText(QString::number(m_config->altitude()));
options_page->useOnlyCache->setChecked(m_config->cacheOnly());
+ //Setup units combos
+ QMapIterator iter = m_config->speedMapIterator();
+ while(iter.hasNext())
+ {
+ iter.next();
+ options_page->speedUnitCombo->addItem(iter.value(), iter.key());
+ }
+ options_page->speedUnitCombo->setCurrentIndex(options_page->speedUnitCombo->findData(m_config->speedFactor()));
+
+ iter = m_config->altitudeMapIterator();
+ while(iter.hasNext())
+ {
+ iter.next();
+ options_page->altUnitCombo->addItem(iter.value(), iter.key());
+ }
+ options_page->altUnitCombo->setCurrentIndex(options_page->altUnitCombo->findData(m_config->altitudeFactor()));
+
#ifndef USE_OSG
options_page->showTerrain->setChecked(false);
options_page->showTerrain->setVisible(false);
@@ -93,6 +110,9 @@ void PfdQmlGadgetOptionsPage::apply()
m_config->setLongitude(options_page->longitude->text().toDouble());
m_config->setAltitude(options_page->altitude->text().toDouble());
m_config->setCacheOnly(options_page->useOnlyCache->isChecked());
+
+ m_config->setSpeedFactor(options_page->speedUnitCombo->itemData(options_page->speedUnitCombo->currentIndex()).toDouble());
+ m_config->setAltitudeFactor(options_page->altUnitCombo->itemData(options_page->altUnitCombo->currentIndex()).toDouble());
}
void PfdQmlGadgetOptionsPage::finish()
diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.ui b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.ui
index 20d617e9b..bb136c6e1 100644
--- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.ui
+++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.ui
@@ -6,8 +6,8 @@
0
0
- 457
- 436
+ 636
+ 558
@@ -19,11 +19,11 @@
Form
-
+
0
- -
+
-
QFrame::NoFrame
@@ -39,15 +39,15 @@
0
0
- 457
- 436
+ 636
+ 558
-
+
0
-
-
+
-
10
@@ -77,7 +77,7 @@
- -
+
-
Use OpenGL
@@ -87,7 +87,45 @@
- -
+
-
+
+
-
+
+
+ Speed Unit:
+
+
+
+ -
+
+
+ Altitude Unit:
+
+
+
+ -
+
+
+
+ 150
+ 16777215
+
+
+
+
+ -
+
+
+
+ 150
+ 16777215
+
+
+
+
+
+
+ -
Show Terrain:
@@ -223,7 +261,7 @@
- -
+
-
Qt::Vertical
diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp
index 60fe0539c..b28e1e418 100644
--- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp
+++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp
@@ -39,7 +39,11 @@ PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWidget *parent) :
m_actualPositionUsed(false),
m_latitude(46.671478),
m_longitude(10.158932),
- m_altitude(2000)
+ m_altitude(2000),
+ m_speedUnit("m/s"),
+ m_speedFactor(1.0),
+ m_altitudeUnit("m"),
+ m_altitudeFactor(1.0)
{
setMinimumSize(64, 64);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
@@ -121,6 +125,38 @@ void PfdQmlGadgetWidget::setTerrainEnabled(bool arg)
}
}
+void PfdQmlGadgetWidget::setSpeedUnit(QString unit)
+{
+ if (m_speedUnit != unit) {
+ m_speedUnit = unit;
+ emit speedUnitChanged(unit);
+ }
+}
+
+void PfdQmlGadgetWidget::setSpeedFactor(double factor)
+{
+ if (m_speedFactor != factor) {
+ m_speedFactor = factor;
+ emit speedFactorChanged(factor);
+ }
+}
+
+void PfdQmlGadgetWidget::setAltitudeUnit(QString unit)
+{
+ if (m_altitudeUnit != unit) {
+ m_altitudeUnit = unit;
+ emit altitudeUnitChanged(unit);
+ }
+}
+
+void PfdQmlGadgetWidget::setAltitudeFactor(double factor)
+{
+ if (m_altitudeFactor != factor) {
+ m_altitudeFactor = factor;
+ emit altitudeFactorChanged(factor);
+ }
+}
+
void PfdQmlGadgetWidget::setOpenGLEnabled(bool arg)
{
if (m_openGLEnabled != arg) {
diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h
index 77ab49f9d..46d540345 100644
--- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h
+++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h
@@ -26,6 +26,11 @@ class PfdQmlGadgetWidget : public QDeclarativeView {
Q_PROPERTY(bool actualPositionUsed READ actualPositionUsed WRITE setActualPositionUsed NOTIFY actualPositionUsedChanged)
+ Q_PROPERTY(QString speedUnit READ speedUnit WRITE setSpeedUnit NOTIFY speedUnitChanged)
+ Q_PROPERTY(double speedFactor READ speedFactor WRITE setSpeedFactor NOTIFY speedFactorChanged)
+ Q_PROPERTY(QString altitudeUnit READ altitudeUnit WRITE setAltitudeUnit NOTIFY altitudeUnitChanged)
+ Q_PROPERTY(double altitudeFactor READ altitudeFactor WRITE setAltitudeFactor NOTIFY altitudeFactorChanged)
+
// pre-defined fallback position
Q_PROPERTY(double latitude READ latitude WRITE setLatitude NOTIFY latitudeChanged)
Q_PROPERTY(double longitude READ longitude WRITE setLongitude NOTIFY longitudeChanged)
@@ -45,6 +50,23 @@ public:
return m_terrainEnabled && m_openGLEnabled;
}
+ QString speedUnit() const
+ {
+ return m_speedUnit;
+ }
+ double speedFactor() const
+ {
+ return m_speedFactor;
+ }
+ QString altitudeUnit() const
+ {
+ return m_altitudeUnit;
+ }
+ double altitudeFactor() const
+ {
+ return m_altitudeFactor;
+ }
+
bool actualPositionUsed() const
{
return m_actualPositionUsed;
@@ -65,6 +87,12 @@ public:
public slots:
void setEarthFile(QString arg);
void setTerrainEnabled(bool arg);
+
+ void setSpeedUnit(QString unit);
+ void setSpeedFactor(double factor);
+ void setAltitudeUnit(QString unit);
+ void setAltitudeFactor(double factor);
+
void setOpenGLEnabled(bool arg);
void setLatitude(double arg);
@@ -82,6 +110,11 @@ signals:
void longitudeChanged(double arg);
void altitudeChanged(double arg);
+ void speedUnitChanged(QString arg);
+ void speedFactorChanged(double arg);
+ void altitudeUnitChanged(QString arg);
+ void altitudeFactorChanged(double arg);
+
private:
QString m_qmlFileName;
QString m_earthFile;
@@ -92,6 +125,11 @@ private:
double m_latitude;
double m_longitude;
double m_altitude;
+
+ QString m_speedUnit;
+ double m_speedFactor;
+ QString m_altitudeUnit;
+ double m_altitudeFactor;
};
#endif /* PFDQMLGADGETWIDGET_H_ */
diff --git a/ground/openpilotgcs/src/plugins/plugins.pro b/ground/openpilotgcs/src/plugins/plugins.pro
index 3f371b722..73bea8c59 100644
--- a/ground/openpilotgcs/src/plugins/plugins.pro
+++ b/ground/openpilotgcs/src/plugins/plugins.pro
@@ -132,12 +132,6 @@ plugin_gpsdisplay.depends = plugin_coreplugin
plugin_gpsdisplay.depends += plugin_uavobjects
SUBDIRS += plugin_gpsdisplay
-# Primary Flight Display (PFD) gadget
-plugin_pfd.subdir = pfd
-plugin_pfd.depends = plugin_coreplugin
-plugin_pfd.depends += plugin_uavobjects
-SUBDIRS += plugin_pfd
-
# QML viewer gadget
plugin_qmlview.subdir = qmlview
plugin_qmlview.depends = plugin_coreplugin
@@ -150,7 +144,7 @@ plugin_pathactioneditor.depends = plugin_coreplugin
plugin_pathactioneditor.depends += plugin_uavobjects
SUBDIRS += plugin_pathactioneditor
-# Primary Flight Display (PFD) gadget, QML version
+# Primary Flight Display (PFD) gadget
plugin_pfdqml.subdir = pfdqml
plugin_pfdqml.depends = plugin_coreplugin
plugin_pfdqml.depends += plugin_uavobjects