Commit 223a7484 authored by Michael Carpenter's avatar Michael Carpenter

CompassConfig implementation

parent 36060bd1
......@@ -3,9 +3,106 @@
CompassConfig::CompassConfig(QWidget *parent) : QWidget(parent)
{
m_uas=0;
ui.setupUi(this);
}
ui.autoDecCheckBox->setEnabled(false);
ui.enableCheckBox->setEnabled(false);
ui.orientationComboBox->setEnabled(false);
ui.declinationLineEdit->setEnabled(false);
connect(ui.enableCheckBox,SIGNAL(clicked(bool)),this,SLOT(enableClicked(bool)));
connect(ui.autoDecCheckBox,SIGNAL(clicked(bool)),this,SLOT(autoDecClicked(bool)));
connect(ui.orientationComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(orientationComboChanged(int)));
connect(UASManager::instance(),SIGNAL(activeUASSet(UASInterface*)),this,SLOT(activeUASSet(UASInterface*)));
activeUASSet(UASManager::instance()->getActiveUAS());
}
CompassConfig::~CompassConfig()
{
}
void CompassConfig::activeUASSet(UASInterface *uas)
{
if (!uas) return;
if (!m_uas)
{
disconnect(m_uas,SIGNAL(parameterChanged(int,int,QString,QVariant)),this,SLOT(parameterChanged(int,int,QString,QVariant)));
}
m_uas = uas;
connect(m_uas,SIGNAL(parameterChanged(int,int,QString,QVariant)),this,SLOT(parameterChanged(int,int,QString,QVariant)));
}
void CompassConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value)
{
if (parameterName == "MAG_ENABLE")
{
if (value.toInt() == 0)
{
ui.enableCheckBox->setChecked(false);
ui.autoDecCheckBox->setEnabled(false);
ui.declinationLineEdit->setEnabled(false);
}
else
{
ui.enableCheckBox->setChecked(true);
ui.autoDecCheckBox->setEnabled(true);
ui.declinationLineEdit->setEnabled(true);
}
ui.enableCheckBox->setEnabled(true);
}
else if (parameterName == "COMPASS_AUTODEC")
{
if (value.toInt() == 0)
{
ui.autoDecCheckBox->setChecked(false);
}
else
{
ui.autoDecCheckBox->setChecked(true);
}
}
else if (parameterName == "COMPASS_DEC")
{
ui.declinationLineEdit->setText(QString::number(value.toDouble()));
}
}
void CompassConfig::enableClicked(bool enabled)
{
if (m_uas)
{
if (enabled)
{
m_uas->setParameter(0,"MAG_ENABLE",QVariant(1));
ui.autoDecCheckBox->setEnabled(true);
if (!ui.autoDecCheckBox->isChecked())
{
ui.declinationLineEdit->setEnabled(true);
}
}
else
{
m_uas->setParameter(0,"MAG_ENABLE",QVariant(0));
ui.autoDecCheckBox->setEnabled(false);
ui.declinationLineEdit->setEnabled(false);
}
}
}
void CompassConfig::autoDecClicked(bool enabled)
{
if (m_uas)
{
if (enabled)
{
m_uas->setParameter(0,"COMPASS_AUTODEC",QVariant(1));
}
else
{
m_uas->setParameter(0,"COMPASS_AUTODEC",QVariant(0));
}
}
}
void CompassConfig::orientationComboChanged(int index)
{
}
......@@ -3,7 +3,8 @@
#include <QWidget>
#include "ui_CompassConfig.h"
#include "UASManager.h"
#include "UASInterface.h"
class CompassConfig : public QWidget
{
Q_OBJECT
......@@ -11,9 +12,15 @@ class CompassConfig : public QWidget
public:
explicit CompassConfig(QWidget *parent = 0);
~CompassConfig();
private slots:
void activeUASSet(UASInterface *uas);
void parameterChanged(int uas, int component, QString parameterName, QVariant value);
void enableClicked(bool enabled);
void autoDecClicked(bool enabled);
void orientationComboChanged(int index);
private:
Ui::CompassConfig ui;
UASInterface *m_uas;
};
#endif // COMPASSCONFIG_H
......@@ -42,7 +42,7 @@
<string>&lt;a href=&quot;http://magnetic-declination.com/&quot;&gt;Declination Website&lt;/a&gt;</string>
</property>
</widget>
<widget class="QComboBox" name="comboBox">
<widget class="QComboBox" name="orientationComboBox">
<property name="geometry">
<rect>
<x>280</x>
......@@ -102,7 +102,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="lineEdit"/>
<widget class="QLineEdit" name="declinationLineEdit"/>
</item>
<item>
<widget class="QLabel" name="label_3">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment