mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
Fixed the small display bug in the linear dial. Display code is now OK, what is missing is: writing numeric value, connecting to input (either uavobject or other abstraction level)
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@591 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
19b6c70588
commit
2b6ffc8bb0
@ -105,17 +105,23 @@ void LineardialGadgetWidget::setDialFile(QString dfn)
|
||||
QMatrix barMatrix = m_renderer->matrixForElement("bargraph");
|
||||
startX = barMatrix.mapRect(m_renderer->boundsOnElement("bargraph")).x();
|
||||
startY = barMatrix.mapRect(m_renderer->boundsOnElement("bargraph")).y();
|
||||
std::cout << "StartX: " << startX << std::endl;
|
||||
std::cout << "StartY: " << startY << std::endl;
|
||||
bargraphWidth = barMatrix.mapRect(m_renderer->boundsOnElement("bargraph")).width();
|
||||
indexHeight = m_renderer->matrixForElement("needle").mapRect(m_renderer->boundsOnElement("needle")).height();
|
||||
indexWidth = m_renderer->matrixForElement("needle").mapRect(m_renderer->boundsOnElement("needle")).width();
|
||||
std::cout << "Index height: " << indexHeight << std::endl;
|
||||
|
||||
QTransform matrix;
|
||||
matrix.translate(startX-indexWidth/2,startY-indexHeight/2);
|
||||
index->setTransform(matrix,false);
|
||||
// Now adjust the red/yellow/green zones:
|
||||
double range = maxValue-minValue;
|
||||
|
||||
green->resetTransform();
|
||||
double greenScale = (greenMax-greenMin)/range;
|
||||
double greenStart = (greenMin-minValue)/range*green->boundingRect().width();
|
||||
QTransform matrix;
|
||||
matrix.reset();
|
||||
matrix.scale(greenScale,1);
|
||||
matrix.translate((greenStart+startX)/greenScale,startY);
|
||||
green->setTransform(matrix,false);
|
||||
@ -194,8 +200,12 @@ void LineardialGadgetWidget::moveIndex()
|
||||
if ((abs((indexValue-indexTarget)*10) > 3)) {
|
||||
indexValue += (indexTarget - indexValue)/10;
|
||||
index->resetTransform();
|
||||
// TODO: do not do so many calculations during the update
|
||||
// code, precompute everything;
|
||||
qreal factor = bargraphWidth/100;
|
||||
index->translate(indexValue*factor+startX,startY-indexHeight/2);
|
||||
QTransform matrix;
|
||||
matrix.translate(indexValue*factor+startX-indexWidth/2,startY-indexHeight/2);
|
||||
index->setTransform(matrix,false);
|
||||
update();
|
||||
}
|
||||
}
|
||||
@ -204,7 +214,7 @@ void LineardialGadgetWidget::moveIndex()
|
||||
// Test function for timer to rotate needles
|
||||
void LineardialGadgetWidget::testRotate()
|
||||
{
|
||||
testVal+=15;
|
||||
testVal=0;
|
||||
if (testVal > maxValue) testVal=minValue;
|
||||
setIndex((double)testVal);
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ private:
|
||||
qreal startY; // green/yellow/red zones.
|
||||
qreal bargraphWidth;
|
||||
qreal indexHeight;
|
||||
qreal indexWidth;
|
||||
|
||||
double testVal;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user