mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
Added OpenGL option to the "Dial" and "LinearDial" plugins.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2613 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
6f2e45d414
commit
3c49944e73
@ -1,6 +1,7 @@
|
||||
TEMPLATE = lib
|
||||
TARGET = DialGadget
|
||||
QT += svg
|
||||
QT += opengl
|
||||
include(../../openpilotgcsplugin.pri)
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
include(dial_dependencies.pri)
|
||||
|
@ -53,6 +53,8 @@ void DialGadget::loadConfiguration(IUAVGadgetConfiguration* config)
|
||||
m->dialNeedle2(),m->dialNeedle3(),m->getN1Move(), m->getN2Move(),
|
||||
m->getN3Move());
|
||||
|
||||
m_widget->enableOpenGL(m->useOpenGL());
|
||||
|
||||
m_widget->setN1Min(m->getN1Min());
|
||||
m_widget->setN1Max(m->getN1Max());
|
||||
m_widget->setN1Factor(m->getN1Factor());
|
||||
|
@ -58,6 +58,8 @@ DialGadgetConfiguration::DialGadgetConfiguration(QString classId, QSettings* qSe
|
||||
if(qSettings != 0) {
|
||||
QString dialFile = qSettings->value("dialFile").toString();
|
||||
|
||||
useOpenGLFlag = qSettings->value("useOpenGLFlag").toBool();
|
||||
|
||||
m_defaultDial=Utils::PathUtils().InsertDataPath(dialFile);
|
||||
dialBackgroundID = qSettings->value("dialBackgroundID").toString();
|
||||
dialForegroundID = qSettings->value("dialForegroundID").toString();
|
||||
@ -93,6 +95,7 @@ DialGadgetConfiguration::DialGadgetConfiguration(QString classId, QSettings* qSe
|
||||
IUAVGadgetConfiguration *DialGadgetConfiguration::clone()
|
||||
{
|
||||
DialGadgetConfiguration *m = new DialGadgetConfiguration(this->classId());
|
||||
m->useOpenGLFlag = useOpenGLFlag;
|
||||
m->m_defaultDial=m_defaultDial;
|
||||
m->setDialBackgroundID(dialBackgroundID);
|
||||
m->setDialForegroundID(dialForegroundID);
|
||||
@ -130,6 +133,8 @@ void DialGadgetConfiguration::saveConfig(QSettings* settings) const {
|
||||
QString dialFile = Utils::PathUtils().RemoveDataPath(m_defaultDial);
|
||||
settings->setValue("dialFile", dialFile);
|
||||
|
||||
settings->setValue("useOpenGLFlag", useOpenGLFlag);
|
||||
|
||||
settings->setValue("dialBackgroundID", dialBackgroundID);
|
||||
settings->setValue("dialForegroundID", dialForegroundID);
|
||||
|
||||
|
@ -69,6 +69,7 @@ public:
|
||||
void setN2Move( QString move) { needle2Move = move; }
|
||||
void setN3Move( QString move) { needle3Move = move; }
|
||||
void setFont(QString text) { font = text; }
|
||||
void setUseOpenGL(bool flag) { useOpenGLFlag = flag; }
|
||||
|
||||
|
||||
//get dial configuration functions
|
||||
@ -97,6 +98,7 @@ public:
|
||||
QString getN2Move() { return needle2Move; }
|
||||
QString getN3Move() { return needle3Move; }
|
||||
QString getFont() { return font;}
|
||||
bool useOpenGL() { return useOpenGLFlag; }
|
||||
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
@ -134,6 +136,8 @@ private:
|
||||
QString needle1Move;
|
||||
QString needle2Move;
|
||||
QString needle3Move;
|
||||
|
||||
bool useOpenGLFlag;
|
||||
};
|
||||
|
||||
#endif // DIALGADGETCONFIGURATION_H
|
||||
|
@ -82,6 +82,8 @@ QWidget *DialGadgetOptionsPage::createPage(QWidget *parent)
|
||||
|
||||
// Restore the contents from the settings:
|
||||
|
||||
options_page->useOpenGL->setChecked(m_config->useOpenGL());
|
||||
|
||||
options_page->svgSourceFile->setExpectedKind(Utils::PathChooser::File);
|
||||
options_page->svgSourceFile->setPromptDialogFilter(tr("SVG image (*.svg)"));
|
||||
options_page->svgSourceFile->setPromptDialogTitle(tr("Choose SVG image"));
|
||||
@ -153,6 +155,7 @@ QWidget *DialGadgetOptionsPage::createPage(QWidget *parent)
|
||||
void DialGadgetOptionsPage::apply()
|
||||
{
|
||||
m_config->setDialFile(options_page->svgSourceFile->path());
|
||||
m_config->setUseOpenGL(options_page->useOpenGL->checkState());
|
||||
m_config->setDialBackgroundID(options_page->backgroundID->text());
|
||||
m_config->setDialForegroundID(options_page->foregroundID->text());
|
||||
m_config->setDialNeedleID1(options_page->needle1ID->text());
|
||||
|
@ -28,7 +28,7 @@
|
||||
<height>311</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
@ -44,6 +44,24 @@
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useOpenGL">
|
||||
<property name="text">
|
||||
<string>Use OpenGL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0">
|
||||
<property name="spacing">
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "dialgadgetwidget.h"
|
||||
#include <utils/stylehelper.h>
|
||||
#include <iostream>
|
||||
#include <QtOpenGL/QGLWidget>
|
||||
#include <QDebug>
|
||||
|
||||
DialGadgetWidget::DialGadgetWidget(QWidget *parent) : QGraphicsView(parent)
|
||||
@ -64,6 +65,17 @@ DialGadgetWidget::~DialGadgetWidget()
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Enables/Disables OpenGL
|
||||
*/
|
||||
void DialGadgetWidget::enableOpenGL(bool flag)
|
||||
{
|
||||
if (flag)
|
||||
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||
else
|
||||
setViewport(new QWidget);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Connects the widget to the relevant UAVObjects
|
||||
*/
|
||||
|
@ -47,6 +47,7 @@ class DialGadgetWidget : public QGraphicsView
|
||||
public:
|
||||
DialGadgetWidget(QWidget *parent = 0);
|
||||
~DialGadgetWidget();
|
||||
void enableOpenGL(bool flag);
|
||||
void setDialFile(QString dfn, QString bg, QString fg, QString n1, QString n2, QString n3,
|
||||
QString n1Move, QString n2Move, QString n3Move);
|
||||
void paint();
|
||||
|
@ -1,6 +1,7 @@
|
||||
TEMPLATE = lib
|
||||
TARGET = LineardialGadget
|
||||
QT += svg
|
||||
QT += opengl
|
||||
include(../../openpilotgcsplugin.pri)
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
include(lineardial_dependencies.pri)
|
||||
|
@ -57,4 +57,5 @@ void LineardialGadget::loadConfiguration(IUAVGadgetConfiguration* config)
|
||||
m_widget->setDialFile(m->getDialFile()); // Triggers widget repaint
|
||||
m_widget->setDialFont(m->getFont());
|
||||
m_widget->connectInput(m->getSourceDataObject(), m->getSourceObjectField());
|
||||
m_widget->enableOpenGL(m->useOpenGL());
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ LineardialGadgetConfiguration::LineardialGadgetConfiguration(QString classId, QS
|
||||
font = qSettings->value("font").toString();
|
||||
decimalPlaces = qSettings->value("decimalPlaces").toInt();
|
||||
factor = qSettings->value("factor").toDouble();
|
||||
useOpenGLFlag = qSettings->value("useOpenGLFlag").toBool();
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,6 +90,7 @@ IUAVGadgetConfiguration *LineardialGadgetConfiguration::clone()
|
||||
m->font = font;
|
||||
m->decimalPlaces = decimalPlaces;
|
||||
m->factor = factor;
|
||||
m->useOpenGLFlag = useOpenGLFlag;
|
||||
|
||||
return m;
|
||||
}
|
||||
@ -113,4 +115,5 @@ void LineardialGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
qSettings->setValue("font", font);
|
||||
qSettings->setValue("decimalPlaces", decimalPlaces);
|
||||
qSettings->setValue("factor", factor);
|
||||
qSettings->setValue("useOpenGLFlag", useOpenGLFlag);
|
||||
}
|
||||
|
@ -56,6 +56,8 @@ public:
|
||||
void setSourceDataObject(QString text) {sourceDataObject = text; }
|
||||
void setSourceObjField(QString text) { sourceObjectField = text; }
|
||||
|
||||
void setUseOpenGL(bool flag) { useOpenGLFlag = flag; }
|
||||
|
||||
//get dial configuration functions
|
||||
QString getDialFile() {return dialFile;}
|
||||
double getMin() { return minValue;}
|
||||
@ -71,6 +73,7 @@ public:
|
||||
QString getFont() { return font;}
|
||||
int getDecimalPlaces() { return decimalPlaces; }
|
||||
double getFactor() { return factor; }
|
||||
bool useOpenGL() { return useOpenGLFlag; }
|
||||
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
@ -96,7 +99,9 @@ private:
|
||||
double yellowMax;
|
||||
double greenMin;
|
||||
double greenMax;
|
||||
|
||||
double factor;
|
||||
bool useOpenGLFlag;
|
||||
|
||||
int decimalPlaces;
|
||||
};
|
||||
|
@ -75,6 +75,7 @@ QWidget *LineardialGadgetOptionsPage::createPage(QWidget *parent)
|
||||
options_page->redMax->setValue(m_config->getRedMax());
|
||||
options_page->factor->setValue(m_config->getFactor());
|
||||
options_page->decPlaces->setValue(m_config->getDecimalPlaces());
|
||||
options_page->useOpenGL->setChecked(m_config->useOpenGL());
|
||||
font.fromString(m_config->getFont());
|
||||
|
||||
// Fills the combo boxes for the UAVObjects
|
||||
@ -163,6 +164,7 @@ void LineardialGadgetOptionsPage::apply()
|
||||
m_config->setFont(font.toString());
|
||||
m_config->setDecimalPlaces(options_page->decPlaces->value());
|
||||
m_config->setFactor(options_page->factor->value());
|
||||
m_config->setUseOpenGL(options_page->useOpenGL->checkState());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@
|
||||
<height>321</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0,0,0,0,0,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0,0,0,0,0,0,0,0">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
@ -44,6 +44,27 @@
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useOpenGL">
|
||||
<property name="text">
|
||||
<string>Use OpenGL</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0">
|
||||
<property name="spacing">
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "lineardialgadgetwidget.h"
|
||||
#include <utils/stylehelper.h>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtOpenGL/QGLWidget>
|
||||
#include <QDebug>
|
||||
|
||||
LineardialGadgetWidget::LineardialGadgetWidget(QWidget *parent) : QGraphicsView(parent)
|
||||
@ -60,6 +61,17 @@ LineardialGadgetWidget::~LineardialGadgetWidget()
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Enables/Disables OpenGL
|
||||
*/
|
||||
void LineardialGadgetWidget::enableOpenGL(bool flag)
|
||||
{
|
||||
if (flag)
|
||||
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||
else
|
||||
setViewport(new QWidget);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Connects the widget to the relevant UAVObjects
|
||||
*/
|
||||
|
@ -46,6 +46,7 @@ class LineardialGadgetWidget : public QGraphicsView
|
||||
public:
|
||||
LineardialGadgetWidget(QWidget *parent = 0);
|
||||
~LineardialGadgetWidget();
|
||||
void enableOpenGL(bool flag);
|
||||
void setDialFile(QString dfn);
|
||||
void paint();
|
||||
void setRange(double min, double max) { minValue=min; maxValue=max;}
|
||||
|
Loading…
x
Reference in New Issue
Block a user