From 6ab6f3e84a493fcc5bc6ef220eea2a0ef1586293 Mon Sep 17 00:00:00 2001 From: edouard Date: Fri, 26 Nov 2010 22:49:50 +0000 Subject: [PATCH] OP-35 Now display a picture of the board layout for each device that is detected. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2163 ebee16cc-31ac-478f-84a7-5cbb03baadba --- artwork/Misc/ahrs-1.svg | 2948 ++++++++++++++ artwork/Misc/mainboard-v0.9.svg | 3577 +---------------- ground/src/plugins/uploader/devicewidget.cpp | 48 +- ground/src/plugins/uploader/devicewidget.h | 7 + .../plugins/uploader/images/deviceID-1.svg | 2466 ++++++++++++ .../plugins/uploader/images/deviceID-69.svg | 2948 ++++++++++++++ ground/src/plugins/uploader/uploader.pro | 3 + ground/src/plugins/uploader/uploader.qrc | 6 + 8 files changed, 8445 insertions(+), 3558 deletions(-) create mode 100644 artwork/Misc/ahrs-1.svg create mode 100644 ground/src/plugins/uploader/images/deviceID-1.svg create mode 100644 ground/src/plugins/uploader/images/deviceID-69.svg create mode 100644 ground/src/plugins/uploader/uploader.qrc diff --git a/artwork/Misc/ahrs-1.svg b/artwork/Misc/ahrs-1.svg new file mode 100644 index 000000000..3b6a15ebb --- /dev/null +++ b/artwork/Misc/ahrs-1.svg @@ -0,0 +1,2948 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/artwork/Misc/mainboard-v0.9.svg b/artwork/Misc/mainboard-v0.9.svg index 8a947de37..74cef1199 100644 --- a/artwork/Misc/mainboard-v0.9.svg +++ b/artwork/Misc/mainboard-v0.9.svg @@ -10,8 +10,8 @@ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="744.09448819" - height="1052.3622047" + width="400" + height="253" id="svg2" version="1.1" inkscape:version="0.48.0 r9654" @@ -26,16 +26,20 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1.4" - inkscape:cx="399.17715" - inkscape:cy="629.09545" + inkscape:cx="232.29172" + inkscape:cy="100.73288" inkscape:document-units="px" inkscape:current-layer="layer3" showgrid="false" - inkscape:window-width="1280" - inkscape:window-height="998" - inkscape:window-x="-4" - inkscape:window-y="-4" - inkscape:window-maximized="1" /> + inkscape:window-width="1366" + inkscape:window-height="691" + inkscape:window-x="0" + inkscape:window-y="24" + inkscape:window-maximized="1" + fit-margin-top="0" + fit-margin-left="0" + fit-margin-right="0" + fit-margin-bottom="0" /> @@ -44,7 +48,7 @@ image/svg+xml - + @@ -52,3555 +56,13 @@ inkscape:label="Background" inkscape:groupmode="layer" id="layer1" - sodipodi:insensitive="true" - style="display:inline"> + style="display:inline" + transform="translate(-188.57143,-331.57648)"> @@ -3609,7 +71,7 @@ eAoAAAAASUVORK5CYII= id="layer3" inkscape:label="Mb pcb" style="display:inline" - sodipodi:insensitive="true"> + transform="translate(-188.57143,-331.57648)"> + style="display:inline" + transform="translate(-188.57143,-331.57648)"> setupUi(this); + devicePic = NULL; // Initialize pointer to null + + // Initialization of the Device icon display + myDevice->devicePicture->setScene(new QGraphicsScene(this)); connect(myDevice->verifyButton, SIGNAL(clicked()), this, SLOT(verifyFirmware())); connect(myDevice->retrieveButton, SIGNAL(clicked()), this, SLOT(downloadFirmware())); connect(myDevice->updateButton, SIGNAL(clicked()), this, SLOT(uploadFirmware())); } + +void deviceWidget::showEvent(QShowEvent *event) +{ + Q_UNUSED(event) + // Thit fitInView method should only be called now, once the + // widget is shown, otherwise it cannot compute its values and + // the result is usually a ahrsbargraph that is way too small. + if (devicePic) + myDevice->devicePicture->fitInView(devicePic,Qt::KeepAspectRatio); +} + +void deviceWidget::resizeEvent(QResizeEvent* event) +{ + Q_UNUSED(event); + if (devicePic) + myDevice->devicePicture->fitInView(devicePic, Qt::KeepAspectRatio); +} + + void deviceWidget::setDeviceID(int devID){ deviceID = devID; } @@ -53,6 +76,29 @@ void deviceWidget::populate() { int id = m_dfu->devices[deviceID].ID; myDevice->deviceID->setText(QString("Device ID: ") + QString::number(id)); + // DeviceID tells us what sort of HW we have detected: + // display a nice icon: + myDevice->devicePicture->scene()->clear(); + if (devicePic) + delete devicePic; + devicePic = new QGraphicsSvgItem(); + devicePic->setSharedRenderer(new QSvgRenderer()); + + switch (id) { + case 1: + devicePic->renderer()->load(QString(":/uploader/images/deviceID-1.svg")); + break; + case 69: + devicePic->renderer()->load(QString(":/uploader/images/deviceID-69.svg")); + break; + default: + break; + } + devicePic->setElementId("device"); + myDevice->devicePicture->scene()->addItem(devicePic); + myDevice->devicePicture->setSceneRect(devicePic->boundingRect()); + myDevice->devicePicture->fitInView(devicePic,Qt::KeepAspectRatio); + bool r = m_dfu->devices[deviceID].Readable; bool w = m_dfu->devices[deviceID].Writable; myDevice->deviceACL->setText(QString("Access: ") + QString(r ? "R" : "-") + QString(w ? "W" : "-")); @@ -104,7 +150,7 @@ void deviceWidget::verifyFirmware() void deviceWidget::uploadFirmware() { if (!m_dfu->devices[deviceID].Writable) { - myDevice->statusLabel->setText(QString("Device not writable!")); + status("Device not writable!"); return; } diff --git a/ground/src/plugins/uploader/devicewidget.h b/ground/src/plugins/uploader/devicewidget.h index 2bd723093..44ec0ffbe 100644 --- a/ground/src/plugins/uploader/devicewidget.h +++ b/ground/src/plugins/uploader/devicewidget.h @@ -32,6 +32,8 @@ #include "op_dfu.h" #include #include +#include +#include using namespace OP_DFU; @@ -52,6 +54,7 @@ private: DFUObject *m_dfu; QByteArray downloadedFirmware; QString filename; + QGraphicsSvgItem *devicePic; signals: @@ -64,6 +67,10 @@ public slots: void uploadFinished(OP_DFU::Status); void status(QString str); +protected: + void showEvent(QShowEvent *event); + void resizeEvent(QResizeEvent *event); + }; #endif // DEVICEWIDGET_H diff --git a/ground/src/plugins/uploader/images/deviceID-1.svg b/ground/src/plugins/uploader/images/deviceID-1.svg new file mode 100644 index 000000000..adc9a3d05 --- /dev/null +++ b/ground/src/plugins/uploader/images/deviceID-1.svg @@ -0,0 +1,2466 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ground/src/plugins/uploader/images/deviceID-69.svg b/ground/src/plugins/uploader/images/deviceID-69.svg new file mode 100644 index 000000000..3b6a15ebb --- /dev/null +++ b/ground/src/plugins/uploader/images/deviceID-69.svg @@ -0,0 +1,2948 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ground/src/plugins/uploader/uploader.pro b/ground/src/plugins/uploader/uploader.pro index 5bc1cf0d9..3f9d5c172 100755 --- a/ground/src/plugins/uploader/uploader.pro +++ b/ground/src/plugins/uploader/uploader.pro @@ -27,3 +27,6 @@ OTHER_FILES += Uploader.pluginspec FORMS += \ uploader.ui \ devicewidget.ui + +RESOURCES += \ + uploader.qrc diff --git a/ground/src/plugins/uploader/uploader.qrc b/ground/src/plugins/uploader/uploader.qrc new file mode 100644 index 000000000..f004d4f6e --- /dev/null +++ b/ground/src/plugins/uploader/uploader.qrc @@ -0,0 +1,6 @@ + + + images/deviceID-1.svg + images/deviceID-69.svg + +