1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-60 : more performance and precision improvements for the analog dials plugin. Config dialog size corrected as well.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@889 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-06-25 14:48:24 +00:00 committed by edouard
parent 9f0d8795c8
commit 06d9919981
2 changed files with 83 additions and 76 deletions

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>487</width>
<height>346</height>
<width>513</width>
<height>341</height>
</rect>
</property>
<property name="sizePolicy">
@ -24,7 +24,7 @@
<rect>
<x>-1</x>
<y>-1</y>
<width>504</width>
<width>481</width>
<height>331</height>
</rect>
</property>
@ -107,20 +107,26 @@
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Indicator 1</string>
</attribute>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<x>10</x>
<y>10</y>
<width>471</width>
<height>110</height>
<width>441</width>
<height>121</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -333,13 +339,13 @@
<attribute name="title">
<string>Indicator 2</string>
</attribute>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<x>10</x>
<y>10</y>
<width>471</width>
<height>116</height>
<width>441</width>
<height>121</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
@ -540,10 +546,10 @@
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<x>10</x>
<y>10</y>
<width>471</width>
<height>116</height>
<width>441</width>
<height>121</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">

View File

@ -45,10 +45,12 @@ AirspeedGadgetWidget::AirspeedGadgetWidget(QWidget *parent) : QGraphicsView(pare
obj2 = NULL;
obj3 = NULL;
needle1Target = 0;
needle2Target = 0;
needle3Target = 0;
// This timer mechanism makes needles rotate smoothly
connect(&dialTimer, SIGNAL(timeout()), this, SLOT(rotateNeedles()));
dialTimer.start(20);
}
AirspeedGadgetWidget::~AirspeedGadgetWidget()
@ -367,89 +369,88 @@ void AirspeedGadgetWidget::rotateNeedles()
{
int dialRun = 3;
if (n2enabled) {
double needle2Diff;
if (abs((needle2Value-needle2Target)*10) > 5) {
double needle2Diff;
needle2Diff =(needle2Target - needle2Value)/5;
if (rotateN2) {
m_needle2->setRotation(m_needle2->rotation()+needle2Diff);
} else {
QPointF opd = QPointF(0,0);
if (horizN2) {
opd = QPointF(needle2Diff,0);
}
if (vertN2) {
opd = QPointF(0,needle2Diff);
}
m_needle2->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), true);
// Since we have moved the needle, we need to move
// the transform origin point the opposite way
// so that it keeps rotating from the same point.
// (this is only useful if needle1 and needle2 are the
// same object, for combined movement such as attitude indicator).
QPointF oop = m_needle2->transformOriginPoint();
m_needle2->setTransformOriginPoint(oop.x()-opd.x(),oop.y()-opd.y());
}
needle2Value += needle2Diff;
} else {
needle2Value = needle2Target;
needle2Diff = needle2Target - needle2Value;
dialRun--;
}
if (rotateN2) {
m_needle2->setRotation(m_needle2->rotation()+needle2Diff);
} else {
QPointF opd = QPointF(0,0);
if (horizN2) {
opd = QPointF(needle2Diff,0);
}
if (vertN2) {
opd = QPointF(0,needle2Diff);
}
m_needle2->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), true);
// Since we have moved the needle, we need to move
// the transform origin point the opposite way
// so that it keeps rotating from the same point.
// (this is only useful if needle1 and needle2 are the
// same object, for combined movement such as attitude indicator).
QPointF oop = m_needle2->transformOriginPoint();
m_needle2->setTransformOriginPoint(oop.x()-opd.x(),oop.y()-opd.y());
}
needle2Value += needle2Diff;
} else {
dialRun--;
}
// We assume that needle1 always exists!
double needle1Diff;
if ((abs((needle1Value-needle1Target)*10) > 5)) {
double needle1Diff;
needle1Diff = (needle1Target - needle1Value)/5;
if (rotateN1) {
m_needle1->setRotation(m_needle1->rotation()+needle1Diff);
} else {
QPointF opd = QPointF(0,0);
if (horizN1) {
opd = QPointF(needle1Diff,0);
}
if (vertN1) {
opd = QPointF(0,needle1Diff);
}
m_needle1->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), true);
QPointF oop = m_needle1->transformOriginPoint();
m_needle1->setTransformOriginPoint((oop.x()-opd.x()),(oop.y()-opd.y()));
}
needle1Value += needle1Diff;
} else { // value is close enough to target, value to exact target
// to cancel out any potential drift
needle1Value = needle1Target;
} else {
needle1Diff = needle1Target - needle1Value;
dialRun--;
}
if (rotateN1) {
m_needle1->setRotation(m_needle1->rotation()+needle1Diff);
} else {
QPointF opd = QPointF(0,0);
if (horizN1) {
opd = QPointF(needle1Diff,0);
}
if (vertN1) {
opd = QPointF(0,needle1Diff);
}
m_needle1->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), true);
QPointF oop = m_needle1->transformOriginPoint();
m_needle1->setTransformOriginPoint((oop.x()-opd.x()),(oop.y()-opd.y()));
}
needle1Value += needle1Diff;
if (n3enabled) {
double needle3Diff;
if ((abs((needle3Value-needle3Target)*10) > 5)) {
double needle3Diff;
needle3Diff = (needle3Target - needle3Value)/5;
if (rotateN3) {
m_needle3->setRotation(m_needle3->rotation()+needle3Diff);
} else {
QPointF opd = QPointF(0,0);
if (horizN3) {
opd = QPointF(needle3Diff,0);
}
if (vertN3) {
opd = QPointF(0,needle3Diff);
}
m_needle3->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), true);
QPointF oop = m_needle3->transformOriginPoint();
m_needle3->setTransformOriginPoint((oop.x()-opd.x()),(oop.y()-opd.y()));
}
needle3Value += needle3Diff;
} else {
needle3Value = needle3Target;
needle3Diff = needle3Target - needle3Value;
dialRun--;
}
if (rotateN3) {
m_needle3->setRotation(m_needle3->rotation()+needle3Diff);
} else {
QPointF opd = QPointF(0,0);
if (horizN3) {
opd = QPointF(needle3Diff,0);
}
if (vertN3) {
opd = QPointF(0,needle3Diff);
}
m_needle3->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), true);
QPointF oop = m_needle3->transformOriginPoint();
m_needle3->setTransformOriginPoint((oop.x()-opd.x()),(oop.y()-opd.y()));
}
needle3Value += needle3Diff;
} else {
dialRun--;
}
update();
//update();
// Now check: if dialRun is now zero, we should
// just stop the timer since all needles have finished moving
if (!dialRun) dialTimer.stop();