1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-19 09:54:15 +01:00

OP-82: PFD: Speed & Altitude indicators fully functional now. Testers needed! Updated the master SVG to make it more readable.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1019 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-07-04 10:29:43 +00:00 committed by edouard
parent 5079b1d348
commit 6492299ef1
4 changed files with 90 additions and 91 deletions

View File

@ -1,4 +1,3 @@
<<<<<<< .mine
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
@ -5343,76 +5342,4 @@ FwbusatRAAAAAElFTkSuQmCC" transform="matrix(0.24 0 0 0.24 128.4102 128.4082)">
id="stop6108" />
</linearGradient>
</g></g></g></svg>>>>>>>> .r967
</g></g></g></svg>

Before

Width:  |  Height:  |  Size: 487 KiB

After

Width:  |  Height:  |  Size: 487 KiB

View File

@ -169,6 +169,13 @@
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective4644"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
</defs>
<sodipodi:namedview
id="base"
@ -178,10 +185,10 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.7"
inkscape:cx="501.01579"
inkscape:cy="324.15029"
inkscape:cx="586.12631"
inkscape:cy="354.15029"
inkscape:document-units="px"
inkscape:current-layer="foreground"
inkscape:current-layer="svg2"
showgrid="false"
inkscape:window-width="1280"
inkscape:window-height="744"
@ -505,7 +512,7 @@
height="450"
width="110.05586"
id="rect6300"
style="fill:#ffffff;fill-opacity:0.36363639;stroke:none;display:inline" />
style="fill:#ffffff;fill-opacity:0.14285714999999999;stroke:#ffffff;display:inline;stroke-opacity:1" />
<path
sodipodi:nodetypes="cccccccc"
id="speed-window"
@ -519,18 +526,12 @@
style="display:inline"
transform="matrix(-1,0,0,1,562.96105,-9.5367432e-7)">
<rect
style="fill:#ffffff;fill-opacity:0.36363639;stroke:none;display:inline"
style="fill:#ffffff;fill-opacity:0.14117647999999999;stroke:#ffffff;display:inline;stroke-opacity:1"
id="rect5640"
width="110.05586"
height="450"
x="-163.69627"
y="131.33096" />
<path
inkscape:label="#rect6927"
style="fill:#000000;fill-opacity:1;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;display:inline"
d="m -162.85715,337.78541 78.912165,0 0,9.3094 10.606602,9.3094 -10.606602,9.3094 0.08512,9.3094 -78.997285,0 0,-37.2376 z"
id="altitude-window"
sodipodi:nodetypes="cccccccc" />
</g>
<rect
style="opacity:0.5;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:2.42740273;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;display:inline"
@ -636,6 +637,12 @@
id="tspan4328"
sodipodi:role="line">GPS</tspan></text>
</g>
<path
inkscape:label="#rect6927"
style="fill:#000000;fill-opacity:1;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;display:inline"
d="m 725.81867,337.78498 -78.91217,0 0,9.3094 -10.6066,9.3094 10.6066,9.3094 -0.0851,9.3094 78.99729,0 0,-37.2376 z"
id="altitude-window"
sodipodi:nodetypes="cccccccc" />
</g>
<g
inkscape:groupmode="layer"

Before

Width:  |  Height:  |  Size: 251 KiB

After

Width:  |  Height:  |  Size: 251 KiB

View File

@ -122,6 +122,8 @@ void PFDGadgetWidget::updateAttitude(UAVObject *object1) {
/*!
\brief Updates the compass reading and speed dial.
This also updates speed & altitude according to GPS data.
Note: the speed dial shows the ground speed at the moment, because
there is no airspeed by default. Should become configurable in a future
gadget release (TODO)
@ -143,7 +145,8 @@ void PFDGadgetWidget::updateHeading(UAVObject *object1) {
if (field) {
// The speed scale represents 30km/h (6 * 5)
// 3.6 : convert m/s to km/h
groundspeedTarget = 3.6*field->getDouble()*speedScaleHeight/(30);
double val = field->getDouble();
groundspeedTarget = 3.6*val*speedScaleHeight/(30);
}
fieldname = QString("Altitude");
field = object1->getField(fieldname);
@ -205,7 +208,7 @@ void PFDGadgetWidget::setDialFile(QString dfn)
- Black speed window: speed-window.
- Altitude rectangle (right site): altitude-bg.
- Altitude scale: altitude-scale.
- Black altitude window: altitude-window.
- Black altitude window: altitude-window.
*/
QGraphicsScene *l_scene = scene();
l_scene->clear(); // Deletes all items contained in the scene as well.
@ -238,7 +241,7 @@ void PFDGadgetWidget::setDialFile(QString dfn)
// Next point bearing:
m_nextpointbearing = new QGraphicsSvgItem();
m_foreground = new QGraphicsSvgItem();
QGraphicsSvgItem *m_foreground = new QGraphicsSvgItem();
m_foreground->setParentItem(m_background);
m_foreground->setSharedRenderer(m_renderer);
m_foreground->setElementId("foreground");
@ -284,6 +287,7 @@ void PFDGadgetWidget::setDialFile(QString dfn)
// Speed
////////////////////
// Speedometer on the left hand:
//
compassMatrix = m_renderer->matrixForElement("speed-bg");
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-bg")).x();
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-bg")).y();
@ -342,6 +346,29 @@ void PFDGadgetWidget::setDialFile(QString dfn)
QRectF rectN = speedscalelines->boundingRect();
m_speedscale->setPos(0,rectB.height()/2-rectN.height()/2-rectN.height()/6);
// Isolate the speed window and put it above the speed scale
compassMatrix = m_renderer->matrixForElement("speed-window");
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-window")).x();
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-window")).y();
qreal speedWindowHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("speed-window")).height();
QGraphicsSvgItem *speedwindow = new QGraphicsSvgItem();
speedwindow->setSharedRenderer(m_renderer);
speedwindow->setElementId("speed-window");
speedwindow->setFlags(QGraphicsItem::ItemClipsChildrenToShape|
QGraphicsItem::ItemClipsToShape);
l_scene->addItem(speedwindow);
matrix.reset();
matrix.translate(startX,startY);
speedwindow->setTransform(matrix,false);
// Last create a Text Item at the location of the speed window
// and save it for future updates:
m_speedtext = new QGraphicsTextItem("0000");
m_speedtext->setDefaultTextColor(QColor("White"));
m_speedtext->setFont(QFont("Arial",(int) speedWindowHeight/2));
matrix.reset();
m_speedtext->setParentItem(speedwindow);
////////////////////
// Altitude
////////////////////
@ -398,6 +425,33 @@ void PFDGadgetWidget::setDialFile(QString dfn)
rectN = altitudescalelines->boundingRect();
m_altitudescale->setPos(0,rectB.height()/2-rectN.height()/2-rectN.height()/6);
// Isolate the Altitude window and put it above the altitude scale
compassMatrix = m_renderer->matrixForElement("altitude-window");
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-window")).x();
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-window")).y();
qreal altitudeWindowHeight = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-window")).height();
QGraphicsSvgItem *altitudewindow = new QGraphicsSvgItem();
altitudewindow->setSharedRenderer(m_renderer);
altitudewindow->setElementId("altitude-window");
altitudewindow->setFlags(QGraphicsItem::ItemClipsChildrenToShape|
QGraphicsItem::ItemClipsToShape);
l_scene->addItem(altitudewindow);
matrix.reset();
matrix.translate(startX,startY);
altitudewindow->setTransform(matrix,false);
// Last create a Text Item at the location of the speed window
// and save it for future updates:
m_altitudetext = new QGraphicsTextItem("0000");
m_altitudetext->setDefaultTextColor(QColor("White"));
m_altitudetext->setFont(QFont("Arial",(int) altitudeWindowHeight/2));
m_altitudetext->setParentItem(altitudewindow);
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("altitude-window")).width()/10;
matrix.reset();
matrix.translate(startX,0);
m_altitudetext->setTransform(matrix,false);
l_scene->setSceneRect(m_background->boundingRect());
// Now Initialize the center for all transforms of the relevant elements to the
@ -548,6 +602,11 @@ void PFDGadgetWidget::moveNeedles()
// fmod does rounding errors!! the formula below works better:
opd = QPointF(x,groundspeedValue-floor(groundspeedValue/speedScaleHeight*6)*speedScaleHeight/6);
m_speedscale->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), false);
double speedText = groundspeedValue/speedScaleHeight*30;
QString s = QString().sprintf("%.0f",speedText);
m_speedtext->setPlainText(s);
// TODO: optimize this by skipping if not necessary...
// Now update the text elements inside the scale:
// (Qt documentation states that the list has the same order
@ -576,6 +635,10 @@ void PFDGadgetWidget::moveNeedles()
// fmod does rounding errors!! the formula below works better:
opd = QPointF(x,altitudeValue-floor(altitudeValue/altitudeScaleHeight*6)*altitudeScaleHeight/6);
m_altitudescale->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), false);
double altitudeText = altitudeValue/altitudeScaleHeight*30;
s = QString().sprintf("%.0f",altitudeText);
m_altitudetext->setPlainText(s);
// TODO: optimize this by skipping if not necessary...
// Now update the text elements inside the scale:
// (Qt documentation states that the list has the same order

View File

@ -78,8 +78,6 @@ private:
// Background: background
QGraphicsSvgItem *m_background;
// Foreground: foreground (contains all fixed elements, including plane)
QGraphicsSvgItem *m_foreground;
// earth/sky : world
QGraphicsSvgItem *m_world;
// Roll scale: rollscale
@ -96,10 +94,14 @@ private:
QGraphicsSvgItem *m_homepointbearing;
// Next point bearing:
QGraphicsSvgItem *m_nextpointbearing;
// Vertical Speed scale:
// Speed scale:
QGraphicsItemGroup *m_speedscale;
// Speed indicator text:
QGraphicsTextItem *m_speedtext;
// Vertical altitude scale:
QGraphicsItemGroup *m_altitudescale;
// Altitude indicator text:
QGraphicsTextItem *m_altitudetext;
double n1MinValue;
double n1MaxValue;