diff --git a/groundStation/gui/MicroCART/MicroCART.pro b/groundStation/gui/MicroCART/MicroCART.pro index d2c2206c6e0deed66c3ef56870ae1faa244c5be3..f5bb8ea5069cd4d1a8c4c451e005f03e383ac737 100644 --- a/groundStation/gui/MicroCART/MicroCART.pro +++ b/groundStation/gui/MicroCART/MicroCART.pro @@ -19,13 +19,15 @@ SOURCES += main.cpp\ trackerworker.cpp \ controlworker.cpp \ quaditem.cpp \ - slotprocess.cpp + slotprocess.cpp \ + qFlightInstruments.cpp HEADERS += mainwindow.h \ trackerworker.h \ controlworker.h \ quaditem.h \ - slotprocess.h + slotprocess.h \ + qFlightInstruments.h FORMS += mainwindow.ui diff --git a/groundStation/gui/MicroCART/main.o b/groundStation/gui/MicroCART/main.o new file mode 100644 index 0000000000000000000000000000000000000000..767107db444ece37a4d56aad6d9d10efca2043cd Binary files /dev/null and b/groundStation/gui/MicroCART/main.o differ diff --git a/groundStation/gui/MicroCART/mainwindow.cpp b/groundStation/gui/MicroCART/mainwindow.cpp index 5abedc40682eb8b1d085dffa33ca954c47f66aad..d5cec6ce48fe0faa1308683dc46888b9497f502f 100644 --- a/groundStation/gui/MicroCART/mainwindow.cpp +++ b/groundStation/gui/MicroCART/mainwindow.cpp @@ -14,6 +14,7 @@ #include "graph_blocks.h" #include "quaditem.h" #include "slotprocess.h" +#include "qFlightInstruments.h" #include <iostream> MainWindow::MainWindow(QWidget *parent) : @@ -25,17 +26,22 @@ MainWindow::MainWindow(QWidget *parent) : sp_y(0.0f), sp_z(0.0f), trackerTimer(new QTimer(this)), + workerStartTimer(new QTimer(this)), backendProcess(new QProcess(this)), - connectedWorkers(0), - workerStartTimer(new QTimer(this)) + connectedWorkers(0) { ui->setupUi(this); - QGraphicsScene *topScene = new QGraphicsScene(this); - ui->topView->setScene(topScene); - QuadItem * quad = new QuadItem(); + QGraphicsScene *posScene = new QGraphicsScene(this); + ui->posView->setScene(posScene); + QuadItem * posIndicator = new QuadItem(); + posScene->addItem(posIndicator); + + QGraphicsScene *attScene = new QGraphicsScene(this); + ui->attView->setScene(attScene); + QADI * attIndicator = new QADI(); + attScene->addWidget(attIndicator); - topScene->addItem(quad); workerStartTimer->setSingleShot(true); @@ -54,7 +60,10 @@ MainWindow::MainWindow(QWidget *parent) : this, SLOT (updateTracker(float, float, float, float, float, float))); connect(trackerWorker, SIGNAL (finished(float, float, float, float, float, float)), - quad, SLOT(updateQuad(float,float,float,float,float,float))); + posIndicator, SLOT(updatePos(float,float,float,float,float,float))); + + connect(trackerWorker, SIGNAL (finished(float, float, float, float, float, float)), + attIndicator, SLOT(updateAttitude(float, float, float, float, float, float))); backendProcess->setProcessChannelMode(QProcess::MergedChannels); diff --git a/groundStation/gui/MicroCART/mainwindow.o b/groundStation/gui/MicroCART/mainwindow.o new file mode 100644 index 0000000000000000000000000000000000000000..985ac913b4e916fffcc7636ae78997bb9533cbb3 Binary files /dev/null and b/groundStation/gui/MicroCART/mainwindow.o differ diff --git a/groundStation/gui/MicroCART/mainwindow.ui b/groundStation/gui/MicroCART/mainwindow.ui index 1fc6dfc6af17e984d7f1a9969c46484d60c16557..a835da062a8fe7f7363120294c375fe0342d933e 100644 --- a/groundStation/gui/MicroCART/mainwindow.ui +++ b/groundStation/gui/MicroCART/mainwindow.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>1004</width> - <height>934</height> + <width>1186</width> + <height>1034</height> </rect> </property> <property name="windowTitle"> @@ -130,8 +130,8 @@ <rect> <x>0</x> <y>0</y> - <width>962</width> - <height>577</height> + <width>1144</width> + <height>677</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_8"> @@ -1069,7 +1069,7 @@ <item> <layout class="QVBoxLayout" name="verticalLayout_9"> <item> - <widget class="QGraphicsView" name="topView"> + <widget class="QGraphicsView" name="posView"> <property name="verticalScrollBarPolicy"> <enum>Qt::ScrollBarAlwaysOff</enum> </property> @@ -1079,7 +1079,7 @@ </widget> </item> <item> - <widget class="QGraphicsView" name="sideView"/> + <widget class="QGraphicsView" name="attView"/> </item> </layout> </item> @@ -1103,7 +1103,7 @@ <rect> <x>0</x> <y>0</y> - <width>1004</width> + <width>1186</width> <height>27</height> </rect> </property> diff --git a/groundStation/gui/MicroCART/qFlightInstruments.cpp b/groundStation/gui/MicroCART/qFlightInstruments.cpp new file mode 100644 index 0000000000000000000000000000000000000000..639ccfa9cad84679962eba13531d454b55efae81 --- /dev/null +++ b/groundStation/gui/MicroCART/qFlightInstruments.cpp @@ -0,0 +1,629 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <QtCore> +#include <QtGui> +#include <QDebug> +#include <QtMath> +#include <QTableWidget> +#include <QHeaderView> + +#include "qFlightInstruments.h" + + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + +QADI::QADI(QWidget *parent) + : QWidget(parent) +{ + connect(this, SIGNAL(canvasReplot(void)), this, SLOT(canvasReplot_slot(void))); + + m_sizeMax = 350; + setMaximumSize(m_sizeMax, m_sizeMax); + setAutoFillBackground(true); + setFocusPolicy(Qt::NoFocus); + + m_roll = 0.0; + m_pitch = 0.0; +} + +QADI::~QADI() +{ + +} + +void QADI::updateAttitude(float longitudinal, float lateral, float height, float pitch, float roll, float yaw) +{ + setData(qRadiansToDegrees(-roll), qRadiansToDegrees(pitch)); +} + +void QADI::canvasReplot_slot(void) +{ + update(); +} + + +void QADI::resizeEvent(QResizeEvent *event) +{ + m_size = qMin(width(),height()) - 2*m_offset; +} + +void QADI::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + + QBrush bgSky(QColor(48,172,220)); + QBrush bgGround(QColor(247,168,21)); + + QPen whitePen(Qt::white); + QPen blackPen(Qt::black); + QPen pitchPen(Qt::white); + QPen pitchZero(Qt::green); + + whitePen.setWidth(2); + blackPen.setWidth(2); + pitchZero.setWidth(3); + + painter.setRenderHint(QPainter::Antialiasing); + + painter.translate(width() / 2, height() / 2); + painter.rotate(m_roll); + + // FIXME: AHRS output left-hand values + double pitch_tem = -m_pitch; + + // draw background + { + int y_min, y_max; + + y_min = m_size/2*-40.0/45.0; + y_max = m_size/2* 40.0/45.0; + + int y = m_size/2*pitch_tem/45.; + if( y < y_min ) y = y_min; + if( y > y_max ) y = y_max; + + int x = sqrt(m_size*m_size/4 - y*y); + qreal gr = atan((double)(y)/x); + gr = gr * 180./3.1415926; + + painter.setPen(blackPen); + painter.setBrush(bgSky); + painter.drawChord(-m_size/2, -m_size/2, m_size, m_size, + gr*16, (180-2*gr)*16); + + painter.setBrush(bgGround); + painter.drawChord(-m_size/2, -m_size/2, m_size, m_size, + gr*16, -(180+2*gr)*16); + } + + // set mask + QRegion maskRegion(-m_size/2, -m_size/2, m_size, m_size, QRegion::Ellipse); + painter.setClipRegion(maskRegion); + + + // draw pitch lines & marker + { + int x, y, x1, y1; + int textWidth; + double p, r; + int ll = m_size/8, l; + + int fontSize = 8; + QString s; + + pitchPen.setWidth(2); + painter.setFont(QFont("", fontSize)); + + + // draw lines + for(int i=-9; i<=9; i++) { + p = i*10; + + s = QString("%1").arg(-p); + + if( i % 3 == 0 ) + l = ll; + else + l = ll/2; + + if( i == 0 ) { + painter.setPen(pitchZero); + l = l * 1.8; + } else { + painter.setPen(pitchPen); + } + + y = m_size/2*p/45.0 - m_size/2*pitch_tem/45.; + x = l; + + r = sqrt(x*x + y*y); + if( r > m_size/2 ) continue; + + painter.drawLine(QPointF(-l, 1.0*y), QPointF(l, 1.0*y)); + + textWidth = 100; + + if( i % 3 == 0 && i != 0 ) { + painter.setPen(QPen(Qt::white)); + + x1 = -x-2-textWidth; + y1 = y - fontSize/2 - 1; + painter.drawText(QRectF(x1, y1, textWidth, fontSize+2), + Qt::AlignRight|Qt::AlignVCenter, s); + } + } + + // draw marker + int markerSize = m_size/20; + float fx1, fy1, fx2, fy2, fx3, fy3; + + painter.setBrush(QBrush(Qt::red)); + painter.setPen(Qt::NoPen); + + fx1 = markerSize; + fy1 = 0; + fx2 = fx1 + markerSize; + fy2 = -markerSize/2; + fx3 = fx1 + markerSize; + fy3 = markerSize/2; + + QPointF points[3] = { + QPointF(fx1, fy1), + QPointF(fx2, fy2), + QPointF(fx3, fy3) + }; + painter.drawPolygon(points, 3); + + QPointF points2[3] = { + QPointF(-fx1, fy1), + QPointF(-fx2, fy2), + QPointF(-fx3, fy3) + }; + painter.drawPolygon(points2, 3); + } + + // draw roll degree lines + { + int nRollLines = 36; + float rotAng = 360.0 / nRollLines; + int rollLineLeng = m_size/25; + double fx1, fy1, fx2, fy2; + int fontSize = 8; + QString s; + + blackPen.setWidth(1); + painter.setPen(blackPen); + painter.setFont(QFont("", fontSize)); + + for(int i=0; i<nRollLines; i++) { + if( i < nRollLines/2 ) + s = QString("%1").arg(-i*rotAng); + else + s = QString("%1").arg(360-i*rotAng); + + fx1 = 0; + fy1 = -m_size/2 + m_offset; + fx2 = 0; + + if( i % 3 == 0 ) { + fy2 = fy1 + rollLineLeng; + painter.drawLine(QPointF(fx1, fy1), QPointF(fx2, fy2)); + + fy2 = fy1 + rollLineLeng+2; + painter.drawText(QRectF(-50, fy2, 100, fontSize+2), + Qt::AlignCenter, s); + } else { + fy2 = fy1 + rollLineLeng/2; + painter.drawLine(QPointF(fx1, fy1), QPointF(fx2, fy2)); + } + + painter.rotate(rotAng); + } + } + + // draw roll marker + { + int rollMarkerSize = m_size/25; + double fx1, fy1, fx2, fy2, fx3, fy3; + + painter.rotate(-m_roll); + painter.setBrush(QBrush(Qt::black)); + + fx1 = 0; + fy1 = -m_size/2 + m_offset; + fx2 = fx1 - rollMarkerSize/2; + fy2 = fy1 + rollMarkerSize; + fx3 = fx1 + rollMarkerSize/2; + fy3 = fy1 + rollMarkerSize; + + QPointF points[3] = { + QPointF(fx1, fy1), + QPointF(fx2, fy2), + QPointF(fx3, fy3) + }; + painter.drawPolygon(points, 3); + } +} + +void QADI::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) { + case Qt::Key_Left: + m_roll -= 1.0; + break; + case Qt::Key_Right: + m_roll += 1.0; + break; + case Qt::Key_Down: + if(m_pitch>-90.) + m_pitch -=1.0; + break; + case Qt::Key_Up: + if(m_pitch<90.) + m_pitch +=1.0; + break; + default: + QWidget::keyPressEvent(event); + break; + } + + update(); +} + + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + + +QCompass::QCompass(QWidget *parent) + : QWidget(parent) +{ + connect(this, SIGNAL(canvasReplot(void)), this, SLOT(canvasReplot_slot(void))); + + m_sizeMin = 200; + m_sizeMax = 600; + m_offset = 2; + m_size = m_sizeMin - 2*m_offset; + + setMinimumSize(m_sizeMin, m_sizeMin); + setMaximumSize(m_sizeMax, m_sizeMax); + resize(m_sizeMin, m_sizeMin); + + setFocusPolicy(Qt::NoFocus); + + m_yaw = 0.0; + m_alt = 0.0; + m_h = 0.0; +} + +QCompass::~QCompass() +{ + +} + + +void QCompass::canvasReplot_slot(void) +{ + update(); +} + +void QCompass::resizeEvent(QResizeEvent *event) +{ + m_size = qMin(width(),height()) - 2*m_offset; +} + +void QCompass::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + + QBrush bgGround(QColor(48,172,220)); + + QPen whitePen(Qt::white); + QPen blackPen(Qt::black); + QPen redPen(Qt::red); + QPen bluePen(Qt::blue); + QPen greenPen(Qt::green); + + whitePen.setWidth(1); + blackPen.setWidth(2); + redPen.setWidth(2); + bluePen.setWidth(2); + greenPen.setWidth(2); + + painter.setRenderHint(QPainter::Antialiasing); + + painter.translate(width() / 2, height() / 2); + + + // draw background + { + painter.setPen(blackPen); + painter.setBrush(bgGround); + + painter.drawEllipse(-m_size/2, -m_size/2, m_size, m_size); + } + + + // draw yaw lines + { + int nyawLines = 36; + float rotAng = 360.0 / nyawLines; + int yawLineLeng = m_size/25; + double fx1, fy1, fx2, fy2; + int fontSize = 8; + QString s; + + blackPen.setWidth(1); + painter.setPen(blackPen); + + for(int i=0; i<nyawLines; i++) { + + if( i == 0 ) { + s = "N"; + painter.setPen(bluePen); + + painter.setFont(QFont("", fontSize*1.3)); + } else if ( i == 9 ) { + s = "W"; + painter.setPen(blackPen); + + painter.setFont(QFont("", fontSize*1.3)); + } else if ( i == 18 ) { + s = "S"; + painter.setPen(redPen); + + painter.setFont(QFont("", fontSize*1.3)); + } else if ( i == 27 ) { + s = "E"; + painter.setPen(blackPen); + + painter.setFont(QFont("", fontSize*1.3)); + } else { + s = QString("%1").arg(i*rotAng); + painter.setPen(blackPen); + + painter.setFont(QFont("", fontSize)); + } + + fx1 = 0; + fy1 = -m_size/2 + m_offset; + fx2 = 0; + + if( i % 3 == 0 ) { + fy2 = fy1 + yawLineLeng; + painter.drawLine(QPointF(fx1, fy1), QPointF(fx2, fy2)); + + fy2 = fy1 + yawLineLeng+4; + painter.drawText(QRectF(-50, fy2, 100, fontSize+2), + Qt::AlignCenter, s); + } else { + fy2 = fy1 + yawLineLeng/2; + painter.drawLine(QPointF(fx1, fy1), QPointF(fx2, fy2)); + } + + painter.rotate(-rotAng); + } + } + + // draw S/N arrow + { + int arrowWidth = m_size/5; + double fx1, fy1, fx2, fy2, fx3, fy3; + + fx1 = 0; + fy1 = -m_size/2 + m_offset + m_size/25 + 15; + fx2 = -arrowWidth/2; + fy2 = 0; + fx3 = arrowWidth/2; + fy3 = 0; + + painter.setPen(Qt::NoPen); + + painter.setBrush(QBrush(Qt::blue)); + QPointF pointsN[3] = { + QPointF(fx1, fy1), + QPointF(fx2, fy2), + QPointF(fx3, fy3) + }; + painter.drawPolygon(pointsN, 3); + + + fx1 = 0; + fy1 = m_size/2 - m_offset - m_size/25 - 15; + fx2 = -arrowWidth/2; + fy2 = 0; + fx3 = arrowWidth/2; + fy3 = 0; + + painter.setBrush(QBrush(Qt::red)); + QPointF pointsS[3] = { + QPointF(fx1, fy1), + QPointF(fx2, fy2), + QPointF(fx3, fy3) + }; + painter.drawPolygon(pointsS, 3); + } + + + // draw yaw marker + { + int yawMarkerSize = m_size/12; + double fx1, fy1, fx2, fy2, fx3, fy3; + + painter.rotate(-m_yaw); + painter.setBrush(QBrush(QColor(0xFF, 0x00, 0x00, 0xE0))); + + fx1 = 0; + fy1 = -m_size/2 + m_offset; + fx2 = fx1 - yawMarkerSize/2; + fy2 = fy1 + yawMarkerSize; + fx3 = fx1 + yawMarkerSize/2; + fy3 = fy1 + yawMarkerSize; + + QPointF points[3] = { + QPointF(fx1, fy1), + QPointF(fx2, fy2), + QPointF(fx3, fy3) + }; + painter.drawPolygon(points, 3); + + painter.rotate(m_yaw); + } + + // draw altitude + { + int altFontSize = 13; + int fx, fy, w, h; + QString s; + char buf[200]; + + w = 130; + h = 2*(altFontSize + 8); + fx = -w/2; + fy = -h/2; + + blackPen.setWidth(2); + painter.setPen(blackPen); + painter.setBrush(QBrush(Qt::white)); + painter.setFont(QFont("", altFontSize)); + + painter.drawRoundedRect(fx, fy, w, h, 6, 6); + + painter.setPen(bluePen); + sprintf(buf, "ALT: %6.1f m", m_alt); + s = buf; + painter.drawText(QRectF(fx, fy+2, w, h/2), Qt::AlignCenter, s); + + sprintf(buf, "H: %6.1f m", m_h); + s = buf; + painter.drawText(QRectF(fx, fy+h/2, w, h/2), Qt::AlignCenter, s); + } +} + +void QCompass::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) { + case Qt::Key_Left: + m_yaw -= 1.0; + break; + case Qt::Key_Right: + m_yaw += 1.0; + break; + case Qt::Key_Down: + m_alt -= 1.0; + break; + case Qt::Key_Up: + m_alt += 1.0; + break; + case Qt::Key_W: + m_h += 1.0; + break; + case Qt::Key_S: + m_h -= 1.0; + break; + + default: + QWidget::keyPressEvent(event); + break; + } + + update(); +} + + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + + +QKeyValueListView::QKeyValueListView(QWidget *parent) : QTableWidget(parent) +{ + connect(this, SIGNAL(listUpdate(void)), this, SLOT(listUpdate_slot(void))); + + m_mutex = new QMutex(); + + // set row & column numbers + setRowCount(0); + setColumnCount(2); + + // set no headers + verticalHeader()->hide(); + horizontalHeader()->hide(); + + // set last section is stretch-able + QHeaderView *HorzHdr = horizontalHeader(); + HorzHdr->setStretchLastSection(true); + HorzHdr->resizeSection(0, 80); // set first column width + + // disable table edit & focus + setEditTriggers(QTableWidget::NoEditTriggers); + setFocusPolicy(Qt::NoFocus); +} + +QKeyValueListView::~QKeyValueListView() +{ + delete m_mutex; +} + +void QKeyValueListView::listUpdate_slot(void) +{ + int i, n; + ListMap::iterator it; + + QColor clCL1, clCL2; + QColor clB1, clB2; + + int fontSize = 8; + int rowHeight = 20; + + clCL1 = QColor(0x00, 0x00, 0xFF); + clCL2 = QColor(0x00, 0x00, 0x00); + clB1 = QColor(0xFF, 0xFF, 0xFF); + clB2 = QColor(0xE0, 0xE0, 0xE0); + + m_mutex->lock(); + + n = m_data.size(); + setRowCount(n); + setColumnCount(2); + + for(i=0, it=m_data.begin(); it!=m_data.end(); i++, it++) { + // set name cell + if( this->item(i, 0) != NULL ) { + this->item(i, 0)->setText(it.key()); + } else { + QTableWidgetItem* item = new QTableWidgetItem(); + item->setText(it.key()); + + item->setTextColor(clCL1); + if( i % 2 == 0 ) item->setBackgroundColor(clB1); + else item->setBackgroundColor(clB2); + + item->setFont(QFont("", fontSize)); + + this->setItem(i, 0, item); + } + + // set value cell + if( this->item(i, 1) != NULL ) { + this->item(i, 1)->setText(it.value()); + } else { + QTableWidgetItem* item = new QTableWidgetItem(); + item->setText(it.value()); + + item->setTextColor(clCL2); + if( i % 2 == 0 ) item->setBackgroundColor(clB1); + else item->setBackgroundColor(clB2); + + item->setFont(QFont("", fontSize)); + + this->setItem(i, 1, item); + } + + setRowHeight(i, rowHeight); + } + + m_mutex->unlock(); +} diff --git a/groundStation/gui/MicroCART/qFlightInstruments.h b/groundStation/gui/MicroCART/qFlightInstruments.h new file mode 100644 index 0000000000000000000000000000000000000000..353efbf08a09349e782504d12e0041d59b39bb9d --- /dev/null +++ b/groundStation/gui/MicroCART/qFlightInstruments.h @@ -0,0 +1,260 @@ +#ifndef __QFLIGHTINSTRUMENTS_H__ +#define __QFLIGHTINSTRUMENTS_H__ + +#include <QtCore> +#include <QtGui> +#include <QWidget> +#include <QMap> +#include <QTableWidget> + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + +/// +/// \brief The Attitude indicator class +/// +class QADI : public QWidget +{ + Q_OBJECT + +public: + QADI(QWidget *parent = 0); + ~QADI(); + + /// + /// \brief Set roll & pitch values (in degree) + /// \param r - roll + /// \param p - pitch + /// + void setData(double r, double p) { + m_roll = r; + m_pitch = p; + if( m_roll < -180 ) m_roll = -180; + if( m_roll > 180 ) m_roll = 180; + if( m_pitch < -90 ) m_pitch = -90; + if( m_pitch > 90 ) m_pitch = 90; + + emit canvasReplot(); + } + + /// + /// \brief Set roll angle (in degree) + /// \param val - roll + /// + void setRoll(double val) { + m_roll = val; + if( m_roll < -180 ) m_roll = -180; + if( m_roll > 180 ) m_roll = 180; + + emit canvasReplot(); + } + + /// + /// \brief Set pitch value (in degree) + /// \param val + /// + void setPitch(double val) { + m_pitch = val; + if( m_pitch < -90 ) m_pitch = -90; + if( m_pitch > 90 ) m_pitch = 90; + + emit canvasReplot(); + } + + /// + /// \brief Get roll angle (in degree) + /// \return roll angle + /// + double getRoll() {return m_roll;} + + /// + /// \brief Get pitch angle (in degree) + /// \return pitch angle + /// + double getPitch(){return m_pitch;} + + +signals: + void canvasReplot(void); + +protected slots: + void updateAttitude(float longitudinal, float lateral, float height, float pitch, float roll, float yaw); + void canvasReplot_slot(void); + +protected: + void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent *event); + void keyPressEvent(QKeyEvent *event); + +protected: + int m_sizeMin, m_sizeMax; ///< widget's min/max size (in pixel) + int m_size, m_offset; ///< current size & offset + + double m_roll; ///< roll angle (in degree) + double m_pitch; ///< pitch angle (in degree) +}; + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + +/// +/// \brief The Compass & altitude display class +/// +class QCompass : public QWidget +{ + Q_OBJECT + +public: + QCompass(QWidget *parent = 0); + ~QCompass(); + + /// + /// \brief Set all data (yaw, alt, height) + /// + /// \param y - yaw ( in degree) + /// \param a - altitude ( in m) + /// \param h - height from ground (in m) + /// + void setData(double y, double a, double h) { + m_yaw = y; + m_alt = a; + m_h = h; + + if( m_yaw < 0 ) m_yaw = 360 + m_yaw; + if( m_yaw > 360 ) m_yaw = m_yaw - 360; + + emit canvasReplot(); + } + + /// + /// \brief Set yaw angle (in degree) + /// \param val - yaw angle (in degree) + /// + void setYaw(double val) { + m_yaw = val; + if( m_yaw < 0 ) m_yaw = 360 + m_yaw; + if( m_yaw > 360 ) m_yaw = m_yaw - 360; + + emit canvasReplot(); + } + + /// + /// \brief Set altitude value + /// \param val - altitude (in m) + /// + void setAlt(double val) { + m_alt = val; + + emit canvasReplot(); + } + + /// + /// \brief Set height from ground + /// \param val - height (in m) + /// + void setH(double val) { + m_h = val; + + emit canvasReplot(); + } + + /// + /// \brief Get yaw angle + /// \return yaw angle (in degree) + /// + double getYaw() {return m_yaw;} + + /// + /// \brief Get altitude value + /// \return altitude (in m) + /// + double getAlt() {return m_alt;} + + /// + /// \brief Get height from ground + /// \return height from ground (in m) + /// + double getH() {return m_h;} + +signals: + void canvasReplot(void); + +protected slots: + void canvasReplot_slot(void); + +protected: + void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent *event); + void keyPressEvent(QKeyEvent *event); + +protected: + int m_sizeMin, m_sizeMax; ///< widget min/max size (in pixel) + int m_size, m_offset; ///< widget size and offset size + + double m_yaw; ///< yaw angle (in degree) + double m_alt; ///< altitude (in m) + double m_h; ///< height from ground (in m) +}; + + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + +typedef QMap<QString, QString> ListMap; + +/// +/// \brief The List view class, it will display key-value pair in lines +/// +class QKeyValueListView : public QTableWidget +{ +public: + Q_OBJECT + +public: + QKeyValueListView(QWidget *parent = 0); + virtual ~QKeyValueListView(); + + /// + /// \brief Set list data + /// \param d - list data + /// + void setData(ListMap &d) { + m_data = d; + emit listUpdate(); + } + + /// + /// \brief Get list data + /// \param d - list data obj + /// + ListMap& getData(void) { + return m_data; + } + + void beginSetData(void) { + m_mutex->lock(); + } + + void endSetData(void) { + m_mutex->unlock(); + } + + /// + /// \brief Reloat data to table widget + /// + void listReload(void) { + emit listUpdate(); + } + +signals: + void listUpdate(void); + +protected slots: + void listUpdate_slot(void); + +protected: + ListMap m_data; + QMutex *m_mutex; +}; + +#endif // end of __QFLIGHTINSTRUMENTS_H__ diff --git a/groundStation/gui/MicroCART/qFlightInstruments.o b/groundStation/gui/MicroCART/qFlightInstruments.o new file mode 100644 index 0000000000000000000000000000000000000000..72a0edc52d0931ab8d33781a4c0b2ba0e84619b9 Binary files /dev/null and b/groundStation/gui/MicroCART/qFlightInstruments.o differ diff --git a/groundStation/gui/MicroCART/quaditem.cpp b/groundStation/gui/MicroCART/quaditem.cpp index 70e74140ad6ebe45a111c3c5602bc4d908a6e046..0f5bb5cd73d3015a3a2c52707b70f6d1fa265ab3 100644 --- a/groundStation/gui/MicroCART/quaditem.cpp +++ b/groundStation/gui/MicroCART/quaditem.cpp @@ -16,10 +16,11 @@ QRectF QuadItem::boundingRect() const void QuadItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { QRectF rec = boundingRect(); + painter->setRenderHint(QPainter::Antialiasing); painter->drawImage(rec,QImage(":/images/quad/quad.png")); } -void QuadItem::updateQuad(float longitudinal, float lateral, float height, float pitch, float roll, float yaw) +void QuadItem::updatePos(float longitudinal, float lateral, float height, float pitch, float roll, float yaw) { QPointF center = boundingRect().center(); this->setTransform(QTransform().translate(center.x(), center.y()).rotate(qRadiansToDegrees(yaw)).translate(-center.x(), -center.y())); diff --git a/groundStation/gui/MicroCART/quaditem.h b/groundStation/gui/MicroCART/quaditem.h index 3f271806b2503a0a98d1284b5cbbc9520436e03e..0e0d13ba60bf33946178bb49f5f51f5314392e23 100644 --- a/groundStation/gui/MicroCART/quaditem.h +++ b/groundStation/gui/MicroCART/quaditem.h @@ -18,7 +18,7 @@ public: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); public slots: - void updateQuad(float longitudinal, float lateral, float height, float pitch, float roll, float yaw); + void updatePos(float longitudinal, float lateral, float height, float pitch, float roll, float yaw); };