1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

TelemetryMonitorWidget: tx/rx labels, 7 nodes, tx/rx rate text.

This commit is contained in:
Mike LaBranche 2012-08-02 19:33:20 -07:00
parent 63e5fc80ce
commit 9ebf6d916a
3 changed files with 420 additions and 7 deletions

View File

@ -0,0 +1,390 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="990"
height="765"
id="svg2"
version="1.1"
inkscape:version="0.48.2 r9819"
sodipodi:docname="tx-rx.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.58"
inkscape:cx="243.88087"
inkscape:cy="482.05004"
inkscape:document-units="px"
inkscape:current-layer="txrxBackground"
showgrid="false"
showguides="false"
inkscape:guide-bbox="true"
inkscape:window-width="1463"
inkscape:window-height="686"
inkscape:window-x="200"
inkscape:window-y="200"
inkscape:window-maximized="0">
<sodipodi:guide
orientation="1,0"
position="159.7561,421.95122"
id="guide3775" />
<sodipodi:guide
orientation="0,1"
position="339.02439,473.17073"
id="guide3912" />
</sodipodi:namedview>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="bg"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-287.36218)"
style="display:inline">
<g
id="g3963">
<g
id="txrxBackground"
inkscape:label="#g3983">
<rect
style="fill:#333333;fill-rule:evenodd;stroke:#646464;stroke-width:2.57372737;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect2985"
width="617.53455"
height="80.003769"
x="155.99559"
y="503.89172"
ry="12.840112" />
<rect
style="fill:#4d4d4d;stroke:none"
id="rect3755-8"
width="53.658535"
height="25.938581"
x="222.97562"
y="512.58765"
ry="12.969291" />
<rect
style="fill:#4d4d4d;stroke:none"
id="rect3755-1-2"
width="53.658535"
height="25.169617"
x="222.09756"
y="548.42963"
ry="12.584808" />
<rect
style="fill:#4d4d4d;stroke:none"
id="rect3755-7-4"
width="53.658535"
height="25.938581"
x="282.97562"
y="512.58765"
ry="12.969291" />
<rect
style="fill:#4d4d4d;stroke:none"
id="rect3755-1-4-5"
width="53.658535"
height="25.169617"
x="282.09756"
y="548.42963"
ry="12.584808" />
<rect
style="color:#000000;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="rect3755-5"
width="53.658535"
height="25.938581"
x="342.78049"
y="512.58765"
ry="12.969291" />
<rect
style="color:#000000;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="rect3755-1-1"
width="53.658535"
height="25.169617"
x="341.90244"
y="548.42963"
ry="12.584808" />
<rect
style="color:#000000;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="rect3755-7-7"
width="53.658535"
height="25.938581"
x="402.78049"
y="512.58765"
ry="12.969291" />
<rect
style="color:#000000;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="rect3755-1-4-1"
width="53.658535"
height="25.169617"
x="401.90244"
y="548.42963"
ry="12.584808" />
<rect
style="fill:#4d4d4d;stroke:none"
id="rect3755-8-1"
width="53.658535"
height="25.938581"
x="462.78049"
y="512.58765"
ry="12.969291" />
<rect
style="fill:#4d4d4d;stroke:none"
id="rect3755-1-2-5"
width="53.658535"
height="25.169617"
x="461.90244"
y="548.42963"
ry="12.584808" />
<rect
style="fill:#4d4d4d;stroke:none"
id="rect3755-7-4-2"
width="53.658535"
height="25.938581"
x="522.78052"
y="512.58765"
ry="12.969291" />
<rect
style="fill:#4d4d4d;stroke:none"
id="rect3755-1-4-5-7"
width="53.658535"
height="25.169617"
x="521.90247"
y="548.42963"
ry="12.584808" />
<rect
style="color:#000000;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="rect3755-7-7-4"
width="53.658535"
height="25.938581"
x="581.80487"
y="513.30939"
ry="12.969291" />
<rect
style="color:#000000;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="rect3755-1-4-1-2"
width="53.658535"
height="25.169617"
x="580.92682"
y="549.13"
ry="12.584808" />
<text
xml:space="preserve"
style="font-size:40px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#b3b3b3;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
x="164.82353"
y="538.24451"
id="text3093"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3038"
x="164.82353"
y="538.24451">Tx</tspan></text>
<text
sodipodi:linespacing="125%"
id="text3040"
y="538.24451"
x="164.82353"
style="font-size:40px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
xml:space="preserve"><tspan
y="538.24451"
x="164.82353"
id="tspan3042"
sodipodi:role="line">Tx</tspan></text>
<text
xml:space="preserve"
style="font-size:40px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold;font-stretch:normal;font-variant:normal;text-anchor:start;text-align:start;writing-mode:lr"
x="163.79311"
y="572.0863"
id="text3044"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3046"
x="163.79311"
y="572.0863">Rx</tspan></text>
</g>
</g>
</g>
<g
inkscape:groupmode="layer"
id="layer3"
inkscape:label="tx"
style="display:inline">
<rect
style="fill:#00c200;fill-opacity:1;stroke:none;display:inline"
id="tx0"
width="53.658535"
height="26.385658"
x="222.90944"
y="225.09811"
ry="13.192829"
inkscape:label="#rect3755-1-2-9" />
<rect
style="fill:#00c200;fill-opacity:1;stroke:none;display:inline"
id="tx1"
width="53.658535"
height="26.385658"
x="282.90942"
y="225.09811"
ry="13.192829"
inkscape:label="#rect3755-1-4-5-3" />
<rect
style="color:#000000;fill:#00c200;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="tx2"
width="53.658535"
height="26.385658"
x="342.71429"
y="225.09811"
ry="13.192829"
inkscape:label="#rect3755-1-1-19" />
<rect
style="color:#000000;fill:#00c200;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="tx3"
width="53.658535"
height="26.385658"
x="402.71429"
y="225.09811"
ry="13.192829"
inkscape:label="#rect3755-1-4-1-8" />
<rect
style="fill:#ffd800;fill-opacity:1;stroke:none;display:inline"
id="tx4"
width="53.658535"
height="26.385658"
x="462.71429"
y="225.09811"
ry="13.192829"
inkscape:label="#rect3755-1-2-5-6" />
<rect
style="fill:#ffd800;fill-opacity:1;stroke:none;display:inline"
id="tx5"
width="53.658535"
height="26.385658"
x="522.71436"
y="225.09811"
ry="13.192829"
inkscape:label="#rect3755-1-4-5-7-5" />
<rect
style="color:#000000;fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="tx6"
width="53.658535"
height="26.385658"
x="581.73871"
y="225.83234"
ry="13.192829"
inkscape:label="#rect3755-1-4-1-2-2" />
<text
xml:space="preserve"
style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;display:inline;font-family:Sans;-inkscape-font-specification:Sans"
x="647.0033"
y="245.35291"
id="txSpeed"
sodipodi:linespacing="125%"
inkscape:label="#text3167"><tspan
sodipodi:role="line"
id="tspan3169"
x="647.0033"
y="245.35291">0 b/s</tspan></text>
</g>
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="rx"
style="display:inline">
<rect
style="fill:#00c200;fill-opacity:1;stroke:none;display:inline"
id="rx0"
width="53.658535"
height="24.722538"
x="222.35068"
y="261.28473"
ry="12.361269"
inkscape:label="#rect3755-8-12" />
<rect
style="fill:#00c200;fill-opacity:1;stroke:none;display:inline"
id="rx1"
width="53.658535"
height="24.722538"
x="282.35068"
y="261.28473"
ry="12.361269"
inkscape:label="#rect3755-7-4-3" />
<rect
style="color:#000000;fill:#00c200;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="rx2"
width="53.658535"
height="24.722538"
x="342.15555"
y="261.28473"
ry="12.361269"
inkscape:label="#rect3755-5-3" />
<rect
style="color:#000000;fill:#00c200;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="rx3"
width="53.658535"
height="24.722538"
x="402.15555"
y="261.28473"
ry="12.361269"
inkscape:label="#rect3755-7-7-41" />
<rect
style="fill:#ffd800;fill-opacity:1;stroke:none;display:inline"
id="rx4"
width="53.658535"
height="24.722538"
x="462.15555"
y="261.28473"
ry="12.361269"
inkscape:label="#rect3755-8-1-1" />
<rect
style="fill:#ffd800;fill-opacity:1;stroke:none;display:inline"
id="rx5"
width="53.658535"
height="24.722538"
x="522.15552"
y="261.28473"
ry="12.361269"
inkscape:label="#rect3755-7-4-2-3" />
<rect
style="color:#000000;fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
id="rx6"
width="53.658535"
height="24.722538"
x="581.17987"
y="261.97269"
ry="12.361269"
inkscape:label="#rect3755-7-7-4-7" />
<text
xml:space="preserve"
style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
x="646.22638"
y="281.98114"
id="rxSpeed"
sodipodi:linespacing="125%"
inkscape:label="#text3959"><tspan
sodipodi:role="line"
id="tspan3961"
x="646.22638"
y="281.98114">0 b/s</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -2,19 +2,20 @@
#include <QObject>
#include <QtGui>
#include <QtGui/QFont>
#include <QDebug>
TelemetryMonitorWidget::TelemetryMonitorWidget(QWidget *parent) : QGraphicsView(parent)
{
setMinimumSize(160,60);
setMaximumSize(160,60);
setMinimumSize(160,80);
setMaximumSize(160,80);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setFrameStyle(QFrame::NoFrame);
setBackgroundBrush(Qt::transparent);
QGraphicsScene *scene = new QGraphicsScene(0,0,160,60, this);
QGraphicsScene *scene = new QGraphicsScene(0,0,160,80, this);
scene->setBackgroundBrush(Qt::transparent);
QSvgRenderer *renderer = new QSvgRenderer();
@ -47,6 +48,19 @@ TelemetryMonitorWidget::TelemetryMonitorWidget(QWidget *parent) : QGraphicsView(
}
scene->addItem(graph);
txSpeed = new QGraphicsTextItem();
txSpeed->setDefaultTextColor(Qt::white);
txSpeed->setFont(QFont("Helvetica",22,2));
txSpeed->setParentItem(graph);
scene->addItem(txSpeed);
rxSpeed = new QGraphicsTextItem();
rxSpeed->setDefaultTextColor(Qt::white);
rxSpeed->setFont(QFont("Helvetica",22,2));
rxSpeed->setParentItem(graph);
scene->addItem(rxSpeed);
scene->setSceneRect(graph->boundingRect());
setScene(scene);
}
@ -116,15 +130,22 @@ void TelemetryMonitorWidget::showTelemetry()
for (int i=0; i < NODE_NUMELEM; i++) {
txNode = txNodes.at(i);
txNode->setPos((i*(txNode->boundingRect().width() + 8)) + 8, (txNode->boundingRect().height()/2) - 2);
txNode->setPos((i*(txNode->boundingRect().width() + 8)) + 60, (txNode->boundingRect().height()/2) - 2);
txNode->setVisible(connected && i < txIndex);
txNode->update();
rxNode = rxNodes.at(i);
rxNode->setPos((i*(rxNode->boundingRect().width() + 8)) + 8, (rxNode->boundingRect().height()*2) - 2);
rxNode->setPos((i*(rxNode->boundingRect().width() + 8)) + 60, (rxNode->boundingRect().height()*2) - 2);
rxNode->setVisible(connected && i < rxIndex);
rxNode->update();
}
txSpeed->setPos(graph->boundingRect().right() - 100, txNodes.at(0)->pos().y() - 10);
txSpeed->setPlainText(QString("%0").arg(txValue));
rxSpeed->setPos(graph->boundingRect().right() - 100, rxNodes.at(0)->pos().y() - 10);
rxSpeed->setPlainText(QString("%0").arg(rxValue));
update();
}
@ -139,7 +160,7 @@ void TelemetryMonitorWidget::resizeEvent(QResizeEvent* event)
{
Q_UNUSED(event);
graph->setPos(0,-90);
graph->setPos(0,-100);
fitInView(graph, Qt::KeepAspectRatio);
}

View File

@ -21,7 +21,7 @@ public:
double getMax() { return maxValue; }
//number of tx/rx nodes in the graph
static const int NODE_NUMELEM = 12;
static const int NODE_NUMELEM = 7;
signals:
@ -38,6 +38,8 @@ protected:
private:
QGraphicsSvgItem *graph;
QGraphicsTextItem *txSpeed;
QGraphicsTextItem *rxSpeed;
QList<QGraphicsSvgItem*> txNodes;
QList<QGraphicsSvgItem*> rxNodes;