mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +01:00
Added "use OpenGL" option to qml based PFD
This commit is contained in:
parent
02c00fabb2
commit
a8e6f4991b
@ -38,6 +38,7 @@ PfdQmlGadget::~PfdQmlGadget()
|
||||
void PfdQmlGadget::loadConfiguration(IUAVGadgetConfiguration* config)
|
||||
{
|
||||
PfdQmlGadgetConfiguration *m = qobject_cast<PfdQmlGadgetConfiguration*>(config);
|
||||
m_widget->setOpenGLEnabled(m->openGLEnabled());
|
||||
m_widget->setQmlFile(m->qmlFile());
|
||||
m_widget->setEarthFile(m->earthFile());
|
||||
m_widget->setTerrainEnabled(m->terrainEnabled());
|
||||
|
@ -25,7 +25,8 @@ PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(QString classId, QSettings
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_qmlFile("Unknown"),
|
||||
m_earthFile("Unknown"),
|
||||
m_terrainEnabled(true),
|
||||
m_openGLEnabled(true),
|
||||
m_terrainEnabled(false),
|
||||
m_actualPositionUsed(false),
|
||||
m_latitude(0),
|
||||
m_longitude(0),
|
||||
@ -40,6 +41,7 @@ PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(QString classId, QSettings
|
||||
m_earthFile = qSettings->value("earthFile").toString();
|
||||
m_earthFile=Utils::PathUtils().InsertDataPath(m_earthFile);
|
||||
|
||||
m_openGLEnabled = qSettings->value("openGLEnabled", true).toBool();
|
||||
m_terrainEnabled = qSettings->value("terrainEnabled").toBool();
|
||||
m_actualPositionUsed = qSettings->value("actualPositionUsed").toBool();
|
||||
m_latitude = qSettings->value("latitude").toDouble();
|
||||
@ -57,6 +59,7 @@ IUAVGadgetConfiguration *PfdQmlGadgetConfiguration::clone()
|
||||
{
|
||||
PfdQmlGadgetConfiguration *m = new PfdQmlGadgetConfiguration(this->classId());
|
||||
m->m_qmlFile = m_qmlFile;
|
||||
m->m_openGLEnabled = m_openGLEnabled;
|
||||
m->m_earthFile = m_earthFile;
|
||||
m->m_terrainEnabled = m_terrainEnabled;
|
||||
m->m_actualPositionUsed = m_actualPositionUsed;
|
||||
@ -78,6 +81,7 @@ void PfdQmlGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
QString earthFile = Utils::PathUtils().RemoveDataPath(m_earthFile);
|
||||
qSettings->setValue("earthFile", earthFile);
|
||||
|
||||
qSettings->setValue("openGLEnabled", m_openGLEnabled);
|
||||
qSettings->setValue("terrainEnabled", m_terrainEnabled);
|
||||
qSettings->setValue("actualPositionUsed", m_actualPositionUsed);
|
||||
qSettings->setValue("latitude", m_latitude);
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
|
||||
void setQmlFile(const QString &fileName) { m_qmlFile=fileName; }
|
||||
void setEarthFile(const QString &fileName) { m_earthFile=fileName; }
|
||||
void setOpenGLEnabled(bool flag) { m_openGLEnabled = flag; }
|
||||
void setTerrainEnabled(bool flag) { m_terrainEnabled = flag; }
|
||||
void setActualPositionUsed(bool flag) { m_actualPositionUsed = flag; }
|
||||
void setLatitude(double value) { m_latitude = value; }
|
||||
@ -38,6 +39,7 @@ public:
|
||||
|
||||
QString qmlFile() const { return m_qmlFile; }
|
||||
QString earthFile() const { return m_earthFile; }
|
||||
bool openGLEnabled() const { return m_openGLEnabled; }
|
||||
bool terrainEnabled() const { return m_terrainEnabled; }
|
||||
bool actualPositionUsed() const { return m_actualPositionUsed; }
|
||||
double latitude() const { return m_latitude; }
|
||||
@ -51,6 +53,7 @@ public:
|
||||
private:
|
||||
QString m_qmlFile; // The name of the dial's SVG source file
|
||||
QString m_earthFile; // The name of osgearth terrain file
|
||||
bool m_openGLEnabled;
|
||||
bool m_terrainEnabled;
|
||||
bool m_actualPositionUsed;
|
||||
double m_latitude;
|
||||
|
@ -53,6 +53,7 @@ QWidget *PfdQmlGadgetOptionsPage::createPage(QWidget *parent)
|
||||
options_page->earthFile->setPromptDialogTitle(tr("Choose OsgEarth terrain file"));
|
||||
options_page->earthFile->setPath(m_config->earthFile());
|
||||
|
||||
options_page->useOpenGL->setChecked(m_config->openGLEnabled());
|
||||
options_page->showTerrain->setChecked(m_config->terrainEnabled());
|
||||
|
||||
options_page->useActualLocation->setChecked(m_config->actualPositionUsed());
|
||||
@ -80,7 +81,13 @@ void PfdQmlGadgetOptionsPage::apply()
|
||||
{
|
||||
m_config->setQmlFile(options_page->qmlSourceFile->path());
|
||||
m_config->setEarthFile(options_page->earthFile->path());
|
||||
m_config->setOpenGLEnabled(options_page->useOpenGL->isChecked());
|
||||
|
||||
#ifdef USE_OSG
|
||||
m_config->setTerrainEnabled(options_page->showTerrain->isChecked());
|
||||
#else
|
||||
m_config->setTerrainEnabled(false);
|
||||
#endif
|
||||
|
||||
m_config->setActualPositionUsed(options_page->useActualLocation->isChecked());
|
||||
m_config->setLatitude(options_page->latitude->text().toDouble());
|
||||
|
@ -20,12 +20,6 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="frameShape">
|
||||
@ -42,8 +36,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>457</width>
|
||||
<height>436</height>
|
||||
<width>439</width>
|
||||
<height>418</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
@ -78,6 +72,16 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="useOpenGL">
|
||||
<property name="text">
|
||||
<string>Use OpenGL</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="showTerrain">
|
||||
<property name="title">
|
||||
<string>Show Terrain:</string>
|
||||
@ -213,7 +217,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -249,12 +253,12 @@
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>150</x>
|
||||
<y>138</y>
|
||||
<x>167</x>
|
||||
<y>188</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>142</x>
|
||||
<y>172</y>
|
||||
<x>260</x>
|
||||
<y>222</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
@ -265,12 +269,12 @@
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>164</x>
|
||||
<y>141</y>
|
||||
<x>181</x>
|
||||
<y>188</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>164</x>
|
||||
<y>202</y>
|
||||
<x>282</x>
|
||||
<y>255</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
@ -281,12 +285,28 @@
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>190</x>
|
||||
<y>141</y>
|
||||
<x>207</x>
|
||||
<y>188</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>190</x>
|
||||
<y>237</y>
|
||||
<x>308</x>
|
||||
<y>288</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>useOpenGL</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>showTerrain</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>99</x>
|
||||
<y>57</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>99</x>
|
||||
<y>89</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWidget *parent) :
|
||||
QDeclarativeView(parent),
|
||||
m_openGLEnabled(false),
|
||||
m_terrainEnabled(false),
|
||||
m_actualPositionUsed(false),
|
||||
m_latitude(46.671478),
|
||||
@ -44,12 +45,15 @@ PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWidget *parent) :
|
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
setResizeMode(SizeRootObjectToView);
|
||||
|
||||
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||
//setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||
|
||||
QStringList objectsToExport;
|
||||
objectsToExport << "VelocityActual" <<
|
||||
"PositionActual" <<
|
||||
"AttitudeActual" <<
|
||||
"VelocityDesired" <<
|
||||
"PositionDesired" <<
|
||||
"AttitudeHoldDesired" <<
|
||||
"GPSPosition" <<
|
||||
"GCSTelemetryStats" <<
|
||||
"FlightBatteryState";
|
||||
@ -106,9 +110,26 @@ void PfdQmlGadgetWidget::setEarthFile(QString arg)
|
||||
|
||||
void PfdQmlGadgetWidget::setTerrainEnabled(bool arg)
|
||||
{
|
||||
if (m_terrainEnabled != arg) {
|
||||
m_terrainEnabled = arg;
|
||||
emit terrainEnabledChanged(arg);
|
||||
bool wasEnabled = terrainEnabled();
|
||||
m_terrainEnabled = arg;
|
||||
|
||||
if (wasEnabled != terrainEnabled())
|
||||
emit terrainEnabledChanged(terrainEnabled());
|
||||
}
|
||||
|
||||
void PfdQmlGadgetWidget::setOpenGLEnabled(bool arg)
|
||||
{
|
||||
if (m_openGLEnabled != arg) {
|
||||
m_openGLEnabled = arg;
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Set OPENGL" << m_openGLEnabled;
|
||||
if (m_openGLEnabled)
|
||||
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||
else
|
||||
setViewport(new QWidget);
|
||||
|
||||
//update terrainEnabled status with opengl status chaged
|
||||
setTerrainEnabled(m_terrainEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
void setQmlFile(QString fn);
|
||||
|
||||
QString earthFile() const { return m_earthFile; }
|
||||
bool terrainEnabled() const { return m_terrainEnabled; }
|
||||
bool terrainEnabled() const { return m_terrainEnabled && m_openGLEnabled; }
|
||||
|
||||
bool actualPositionUsed() const { return m_actualPositionUsed; }
|
||||
double latitude() const { return m_latitude; }
|
||||
@ -49,6 +49,7 @@ public:
|
||||
public slots:
|
||||
void setEarthFile(QString arg);
|
||||
void setTerrainEnabled(bool arg);
|
||||
void setOpenGLEnabled(bool arg);
|
||||
|
||||
void setLatitude(double arg);
|
||||
void setLongitude(double arg);
|
||||
@ -68,6 +69,7 @@ signals:
|
||||
private:
|
||||
QString m_qmlFileName;
|
||||
QString m_earthFile;
|
||||
bool m_openGLEnabled;
|
||||
bool m_terrainEnabled;
|
||||
|
||||
bool m_actualPositionUsed;
|
||||
|
Loading…
x
Reference in New Issue
Block a user