mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Less agressive smoothing on the dials, add a factor option to dials for quick unit conversion, and allow negative max value for range settings.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@689 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
0fc8240b12
commit
3ea3bf4018
@ -53,8 +53,10 @@ void AirspeedGadget::loadConfiguration(IUAVGadgetConfiguration* config)
|
||||
|
||||
m_widget->setN1Min(m->getN1Min());
|
||||
m_widget->setN1Max(m->getN1Max());
|
||||
m_widget->setN1Factor(m->getN1Factor());
|
||||
m_widget->setN2Min(m->getN2Min());
|
||||
m_widget->setN2Max(m->getN2Max());
|
||||
m_widget->setN2Factor(m->getN2Factor());
|
||||
m_widget->connectNeedles(m->getN1DataObject(),m->getN1ObjField(),
|
||||
m->getN2DataObject(),m->getN2ObjField());
|
||||
}
|
||||
|
@ -39,10 +39,12 @@ AirspeedGadgetConfiguration::AirspeedGadgetConfiguration(QString classId, const
|
||||
dialForegroundID("foreground"),
|
||||
dialNeedleID1("needle"),
|
||||
dialNeedleID2("needle-2"),
|
||||
needle1MinValue(0.001),
|
||||
needle1MinValue(0),
|
||||
needle1MaxValue(100),
|
||||
needle2MinValue(0.001),
|
||||
needle2MaxValue(100)
|
||||
needle2MinValue(0),
|
||||
needle2MaxValue(100),
|
||||
needle1Factor(1),
|
||||
needle2Factor(1)
|
||||
{
|
||||
//if a saved configuration exists load it
|
||||
if (state.count() > 0) {
|
||||
@ -62,6 +64,8 @@ AirspeedGadgetConfiguration::AirspeedGadgetConfiguration(QString classId, const
|
||||
stream >> needle1ObjectField;
|
||||
stream >> needle2DataObject;
|
||||
stream >> needle2ObjectField;
|
||||
stream >> needle1Factor;
|
||||
stream >> needle2Factor;
|
||||
|
||||
}
|
||||
}
|
||||
@ -96,6 +100,8 @@ QByteArray AirspeedGadgetConfiguration::saveState() const
|
||||
stream << needle1ObjectField;
|
||||
stream << needle2DataObject;
|
||||
stream << needle2ObjectField;
|
||||
stream << needle1Factor;
|
||||
stream << needle2Factor;
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ public:
|
||||
void setN2Min(double val) { needle2MinValue = val;}
|
||||
void setN1Max(double val) { needle1MaxValue = val;}
|
||||
void setN2Max(double val) { needle2MaxValue = val;}
|
||||
void setN1Factor(double val) { needle1Factor = val;}
|
||||
void setN2Factor(double val) { needle2Factor = val;}
|
||||
void setN1DataObject(QString text) {needle1DataObject = text; }
|
||||
void setN2DataObject(QString text){ needle2DataObject = text; }
|
||||
void setN1ObjField(QString text) { needle1ObjectField = text; }
|
||||
@ -66,6 +68,8 @@ public:
|
||||
double getN2Min() { return needle2MinValue;}
|
||||
double getN1Max() { return needle1MaxValue;}
|
||||
double getN2Max() { return needle2MaxValue;}
|
||||
double getN1Factor() { return needle1Factor;}
|
||||
double getN2Factor() { return needle2Factor;}
|
||||
QString getN1DataObject() { return needle1DataObject; }
|
||||
QString getN2DataObject() { return needle2DataObject; }
|
||||
QString getN1ObjField() { return needle1ObjectField; }
|
||||
@ -88,6 +92,8 @@ private:
|
||||
double needle1MaxValue; // Value corresponding to a 360 degree angle;
|
||||
double needle2MinValue;
|
||||
double needle2MaxValue;
|
||||
double needle1Factor;
|
||||
double needle2Factor;
|
||||
|
||||
QString needle1DataObject;
|
||||
QString needle1ObjectField;
|
||||
|
@ -74,6 +74,8 @@ QWidget *AirspeedGadgetOptionsPage::createPage(QWidget *parent)
|
||||
options_page->needle1Max->setValue(m_config->getN1Max());
|
||||
options_page->needle2Min->setValue(m_config->getN2Min());
|
||||
options_page->needle2Max->setValue(m_config->getN2Max());
|
||||
options_page->factor1->setValue(m_config->getN1Factor());
|
||||
options_page->factor2->setValue(m_config->getN2Factor());
|
||||
|
||||
//select saved UAV Object field values
|
||||
if(options_page->uavObject1->findText(m_config->getN1DataObject())!=-1){
|
||||
@ -122,8 +124,10 @@ void AirspeedGadgetOptionsPage::apply()
|
||||
m_config->setDialNeedleID2(options_page->needle2ID->text());
|
||||
m_config->setN1Min(options_page->needle1Min->value());
|
||||
m_config->setN1Max(options_page->needle1Max->value());
|
||||
m_config->setN1Factor(options_page->factor1->value());
|
||||
m_config->setN2Min(options_page->needle2Min->value());
|
||||
m_config->setN2Max(options_page->needle2Max->value());
|
||||
m_config->setN2Factor(options_page->factor2->value());
|
||||
m_config->setN1DataObject(options_page->uavObject1->currentText());
|
||||
m_config->setN2DataObject(options_page->uavObject2->currentText());
|
||||
m_config->setN1ObjField(options_page->objectField1->currentText());
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>486</width>
|
||||
<height>300</height>
|
||||
<width>487</width>
|
||||
<height>326</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -25,7 +25,7 @@
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
<width>481</width>
|
||||
<height>339</height>
|
||||
<height>354</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0,0">
|
||||
@ -114,6 +114,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -121,38 +124,67 @@
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Indicator 1</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Indicator 1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="needle1ID">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="needle1ID">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Min</string>
|
||||
<string>Min:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -178,7 +210,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Max</string>
|
||||
<string>Max:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -194,7 +226,30 @@
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.001000000000000</double>
|
||||
<double>-100000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Factor:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="factor1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-100000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100000.000000000000000</double>
|
||||
@ -262,21 +317,31 @@
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string>Indicator 2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string>Indicator 2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>ID</string>
|
||||
<string>ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -290,10 +355,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>Min</string>
|
||||
<string>Min:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -319,7 +391,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="text">
|
||||
<string>Max</string>
|
||||
<string>Max:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -335,7 +407,30 @@
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.001000000000000</double>
|
||||
<double>-100000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Factor:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="factor2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-100000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100000.000000000000000</double>
|
||||
|
@ -52,7 +52,7 @@ AirspeedGadgetWidget::AirspeedGadgetWidget(QWidget *parent) : QGraphicsView(pare
|
||||
|
||||
// This timer mechanism makes needles rotate smoothly
|
||||
connect(&dialTimer, SIGNAL(timeout()), this, SLOT(rotateNeedles()));
|
||||
dialTimer.start(30);
|
||||
dialTimer.start(20);
|
||||
|
||||
// Test code for timer to rotate the needle
|
||||
#if 0
|
||||
@ -212,11 +212,11 @@ void AirspeedGadgetWidget::resizeEvent(QResizeEvent *event)
|
||||
// Converts the value into an angle:
|
||||
// this enables smooth rotation in rotateNeedles below
|
||||
void AirspeedGadgetWidget::setNeedle1(double value) {
|
||||
needle1Target = 360*value/(n1MaxValue-n1MinValue);
|
||||
needle1Target = 360*value*n1Factor/(n1MaxValue-n1MinValue);
|
||||
}
|
||||
|
||||
void AirspeedGadgetWidget::setNeedle2(double value) {
|
||||
needle2Target = 360*value/(n2MaxValue-n2MinValue);
|
||||
needle2Target = 360*value*n2Factor/(n2MaxValue-n2MinValue);
|
||||
}
|
||||
|
||||
|
||||
@ -227,7 +227,7 @@ void AirspeedGadgetWidget::setNeedle2(double value) {
|
||||
void AirspeedGadgetWidget::rotateNeedles()
|
||||
{
|
||||
if ((abs((needle2Value-needle2Target)*10) > 5) && n2enabled) {
|
||||
needle2Value+=(needle2Target - needle2Value)/10;
|
||||
needle2Value+=(needle2Target - needle2Value)/5;
|
||||
m_needle2->resetTransform();
|
||||
QRectF rect = m_needle2->boundingRect();
|
||||
m_needle2->translate(rect.width()/2,rect.height()/2);
|
||||
@ -236,7 +236,7 @@ void AirspeedGadgetWidget::rotateNeedles()
|
||||
}
|
||||
|
||||
if ((abs((needle1Value-needle1Target)*10) > 5)) {
|
||||
needle1Value += (needle1Target - needle1Value)/10;
|
||||
needle1Value += (needle1Target - needle1Value)/5;
|
||||
m_needle1->resetTransform();
|
||||
QRectF rect = m_needle1->boundingRect();
|
||||
m_needle1->translate(rect.width()/2,rect.height()/2);
|
||||
|
@ -54,8 +54,10 @@ public:
|
||||
void setNeedle2(double value);
|
||||
void setN1Min(double value) {n1MinValue = value;}
|
||||
void setN1Max(double value) {n1MaxValue = value;}
|
||||
void setN1Factor(double value) {n1Factor = value;}
|
||||
void setN2Min(double value) {n2MinValue = value;}
|
||||
void setN2Max(double value) {n2MaxValue = value;}
|
||||
void setN2Factor(double value) {n2Factor = value;}
|
||||
// Sets up needle/UAVObject connections:
|
||||
void connectNeedles(QString object1, QString field1,
|
||||
QString object2, QString field2);
|
||||
@ -86,8 +88,10 @@ private:
|
||||
|
||||
double n1MinValue;
|
||||
double n1MaxValue;
|
||||
double n1Factor;
|
||||
double n2MinValue;
|
||||
double n2MaxValue;
|
||||
double n2Factor;
|
||||
|
||||
// The Value and target variables
|
||||
// are expressed in degrees
|
||||
|
Loading…
x
Reference in New Issue
Block a user