Commit 8c83e87b authored by pixhawk's avatar pixhawk

Implemented setpoint changes for HSI widget

parent ab28d6a0
...@@ -107,7 +107,7 @@ QSpinBox { ...@@ -107,7 +107,7 @@ QSpinBox {
QPushButton { QPushButton {
font-weight: bold; font-weight: bold;
min-height: 18px; min-height: 18px;
max-height: 32px; max-height: 18px;
border: 2px solid #4A4A4F; border: 2px solid #4A4A4F;
border-radius: 5px; border-radius: 5px;
padding-left: 10px; padding-left: 10px;
...@@ -127,10 +127,10 @@ QToolButton { ...@@ -127,10 +127,10 @@ QToolButton {
font-weight: bold; font-weight: bold;
min-height: 16px; min-height: 16px;
min-width: 24px; min-width: 24px;
max-height: 32px; max-height: 18px;
border: 1px solid #EEEEEE; border: 2px solid #4A4A4F;
border-radius: 5px; border-radius: 5px;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #303030, stop: 1 #202020); background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #232228, stop: 1 #020208);
} }
QToolButton:checked { QToolButton:checked {
......
...@@ -3,23 +3,23 @@ ...@@ -3,23 +3,23 @@
# from http://github.com/pixhawk/qmapcontrol/ # from http://github.com/pixhawk/qmapcontrol/
# over bundled version in lib directory # over bundled version in lib directory
# Version from GIT repository is preferred # Version from GIT repository is preferred
#include ( "../qmapcontrol/QMapControl/QMapControl.pri" ) #{ # include ( "../qmapcontrol/QMapControl/QMapControl.pri" ) #{
# Include bundled version if necessary # Include bundled version if necessary
include(lib/QMapControl/QMapControl.pri) include(lib/QMapControl/QMapControl.pri)
#message("Including bundled QMapControl version as FALLBACK. This is fine on Linux and MacOS, but not the best choice in Windows")
QT += network opengl svg xml phonon
# message("Including bundled QMapControl version as FALLBACK. This is fine on Linux and MacOS, but not the best choice in Windows")
QT += network \
opengl \
svg \
xml \
phonon
TEMPLATE = app TEMPLATE = app
TARGET = qgroundcontrol TARGET = qgroundcontrol
BASEDIR = . BASEDIR = .
BUILDDIR = build BUILDDIR = build
LANGUAGE = C++ LANGUAGE = C++
CONFIG += debug_and_release \
CONFIG += debug_and_release console console
OBJECTS_DIR = $$BUILDDIR/obj OBJECTS_DIR = $$BUILDDIR/obj
MOC_DIR = $$BUILDDIR/moc MOC_DIR = $$BUILDDIR/moc
UI_HEADERS_DIR = src/ui/generated UI_HEADERS_DIR = src/ui/generated
...@@ -142,7 +142,8 @@ HEADERS += src/MG.h \ ...@@ -142,7 +142,8 @@ HEADERS += src/MG.h \
src/ui/watchdog/WatchdogProcessView.h \ src/ui/watchdog/WatchdogProcessView.h \
src/ui/watchdog/WatchdogView.h \ src/ui/watchdog/WatchdogView.h \
src/uas/UASWaypointManager.h \ src/uas/UASWaypointManager.h \
src/ui/HSIDisplay.h src/ui/HSIDisplay.h \
src/QGC.h
SOURCES += src/main.cc \ SOURCES += src/main.cc \
src/Core.cc \ src/Core.cc \
src/uas/UASManager.cc \ src/uas/UASManager.cc \
......
#ifndef QGC_H
#define QGC_H
#include <QColor>
namespace QGC
{
const QColor ColorCyan(55, 154, 195);
}
#endif // QGC_H
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>DebugConsole</class> <class>DebugConsole</class>
<widget class="QWidget" name="DebugConsole"> <widget class="QWidget" name="DebugConsole">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>488</width> <width>435</width>
<height>390</height> <height>185</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing"> <property name="horizontalSpacing">
<number>6</number> <number>6</number>
</property> </property>
<property name="verticalSpacing"> <property name="verticalSpacing">
<number>4</number> <number>4</number>
</property> </property>
<property name="margin"> <property name="margin">
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,10,0,0,0,0"> <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="10,0,0,0,0">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QComboBox" name="linkComboBox">
<property name="text"> <property name="maximumSize">
<string>Link</string> <size>
</property> <width>130</width>
</widget> <height>16777215</height>
</item> </size>
<item> </property>
<widget class="QComboBox" name="linkComboBox"> <property name="toolTip">
<property name="toolTip"> <string>Select the link to monitor</string>
<string>Select the link to monitor</string> </property>
</property> </widget>
</widget> </item>
</item> <item>
<item> <widget class="QLabel" name="speedLabel">
<widget class="QLabel" name="speedLabel"> <property name="text">
<property name="text"> <string>0.0 kB/s</string>
<string>0.0 kB/s</string> </property>
</property> </widget>
</widget> </item>
</item> <item>
<item> <widget class="QCheckBox" name="mavlinkCheckBox">
<widget class="QCheckBox" name="mavlinkCheckBox"> <property name="toolTip">
<property name="toolTip"> <string>Ignore MAVLINK protocol messages in display</string>
<string>Ignore MAVLINK protocol messages in display</string> </property>
</property> <property name="text">
<property name="text"> <string>No MAVLINK</string>
<string>Ignore MAVLINK</string> </property>
</property> </widget>
</widget> </item>
</item> <item>
<item> <widget class="QCheckBox" name="hexCheckBox">
<widget class="QCheckBox" name="hexCheckBox"> <property name="toolTip">
<property name="toolTip"> <string>Display and send bytes in HEX representation</string>
<string>Display and send bytes in HEX representation</string> </property>
</property> <property name="text">
<property name="text"> <string>HEX</string>
<string>HEX</string> </property>
</property> </widget>
</widget> </item>
</item> <item>
<item> <widget class="QCheckBox" name="holdCheckBox">
<widget class="QCheckBox" name="holdCheckBox"> <property name="toolTip">
<property name="toolTip"> <string>Saves CPU ressources, automatically set view to hold if data rate is too high to prevent fast scrolling</string>
<string>Saves CPU ressources, automatically set view to hold if data rate is too high to prevent fast scrolling</string> </property>
</property> <property name="statusTip">
<property name="statusTip"> <string>Saves CPU ressources, automatically set view to hold if data rate is too high to prevent fast scrolling</string>
<string>Saves CPU ressources, automatically set view to hold if data rate is too high to prevent fast scrolling</string> </property>
</property> <property name="whatsThis">
<property name="whatsThis"> <string>Enable auto hold to lower the CPU consumption</string>
<string>Enable auto hold to lower the CPU consumption</string> </property>
</property> <property name="text">
<property name="text"> <string>Auto hold</string>
<string>Auto hold</string> </property>
</property> </widget>
</widget> </item>
</item> </layout>
</layout> </item>
</item> <item row="1" column="0" colspan="2">
<item row="1" column="0" colspan="2"> <widget class="QPlainTextEdit" name="receiveText"/>
<widget class="QPlainTextEdit" name="receiveText"/> </item>
</item> <item row="2" column="0" colspan="2">
<item row="2" column="0" colspan="2"> <widget class="QLineEdit" name="sentText">
<widget class="QLineEdit" name="sentText"> <property name="text">
<property name="text"> <string>Enter data/text below to send</string>
<string>Enter data/text below to send</string> </property>
</property> <property name="readOnly">
<property name="readOnly"> <bool>true</bool>
<bool>true</bool> </property>
</property> </widget>
</widget> </item>
</item> <item row="3" column="0">
<item row="3" column="0"> <widget class="QLineEdit" name="sendText">
<widget class="QLineEdit" name="sendText"> <property name="toolTip">
<property name="toolTip"> <string>Type the bytes to send here, use 0xAA format for HEX (Check HEX checkbox above)</string>
<string>Type the bytes to send here, use 0xAA format for HEX (Check HEX checkbox above)</string> </property>
</property> </widget>
</widget> </item>
</item> <item row="3" column="1">
<item row="3" column="1"> <layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout"> <item>
<item> <widget class="QPushButton" name="transmitButton">
<widget class="QPushButton" name="transmitButton"> <property name="toolTip">
<property name="toolTip"> <string>Send the ASCII text or HEX values over the link</string>
<string>Send the ASCII text or HEX values over the link</string> </property>
</property> <property name="text">
<property name="text"> <string>Send</string>
<string>Send</string> </property>
</property> <property name="icon">
<property name="icon"> <iconset resource="../../mavground.qrc">
<iconset resource="../../mavground.qrc"> <normaloff>:/images/devices/network-wireless.svg</normaloff>:/images/devices/network-wireless.svg</iconset>
<normaloff>:/images/devices/network-wireless.svg</normaloff>:/images/devices/network-wireless.svg</iconset> </property>
</property> </widget>
</widget> </item>
</item> <item>
<item> <widget class="QPushButton" name="holdButton">
<widget class="QPushButton" name="holdButton"> <property name="text">
<property name="text"> <string>Hold</string>
<string>Hold</string> </property>
</property> <property name="checkable">
<property name="checkable"> <bool>true</bool>
<bool>true</bool> </property>
</property> </widget>
</widget> </item>
</item> <item>
<item> <widget class="QPushButton" name="clearButton">
<widget class="QPushButton" name="clearButton"> <property name="text">
<property name="text"> <string>Clear</string>
<string>Clear</string> </property>
</property> </widget>
</widget> </item>
</item> </layout>
</layout> </item>
</item> </layout>
</layout> </widget>
</widget> <resources>
<resources> <include location="../../mavground.qrc"/>
<include location="../../mavground.qrc"/> </resources>
</resources> <connections>
<connections> <connection>
<connection> <sender>clearButton</sender>
<sender>clearButton</sender> <signal>clicked()</signal>
<signal>clicked()</signal> <receiver>receiveText</receiver>
<receiver>receiveText</receiver> <slot>clear()</slot>
<slot>clear()</slot> <hints>
<hints> <hint type="sourcelabel">
<hint type="sourcelabel"> <x>356</x>
<x>356</x> <y>278</y>
<y>278</y> </hint>
</hint> <hint type="destinationlabel">
<hint type="destinationlabel"> <x>199</x>
<x>199</x> <y>146</y>
<y>146</y> </hint>
</hint> </hints>
</hints> </connection>
</connection> </connections>
</connections> </ui>
</ui>
...@@ -581,6 +581,16 @@ float HDDisplay::refToScreenY(float y) ...@@ -581,6 +581,16 @@ float HDDisplay::refToScreenY(float y)
return (scalingFactor * y); return (scalingFactor * y);
} }
float HDDisplay::screenToRefX(float x)
{
return x/scalingFactor;
}
float HDDisplay::screenToRefY(float y)
{
return y/scalingFactor;
}
void HDDisplay::drawLine(float refX1, float refY1, float refX2, float refY2, float width, const QColor& color, QPainter* painter) void HDDisplay::drawLine(float refX1, float refY1, float refX2, float refY2, float width, const QColor& color, QPainter* painter)
{ {
QPen pen(Qt::SolidLine); QPen pen(Qt::SolidLine);
......
...@@ -70,6 +70,8 @@ protected: ...@@ -70,6 +70,8 @@ protected:
float refLineWidthToPen(float line); float refLineWidthToPen(float line);
float refToScreenX(float x); float refToScreenX(float x);
float refToScreenY(float y); float refToScreenY(float y);
float screenToRefX(float x);
float screenToRefY(float y);
void rotatePolygonClockWiseRad(QPolygonF& p, float angle, QPointF origin); void rotatePolygonClockWiseRad(QPolygonF& p, float angle, QPointF origin);
void drawPolygon(QPolygonF refPolygon, QPainter* painter); void drawPolygon(QPolygonF refPolygon, QPainter* painter);
void drawLine(float refX1, float refY1, float refX2, float refY2, float width, const QColor& color, QPainter* painter); void drawLine(float refX1, float refY1, float refX2, float refY2, float width, const QColor& color, QPainter* painter);
......
...@@ -35,6 +35,7 @@ This file is part of the PIXHAWK project ...@@ -35,6 +35,7 @@ This file is part of the PIXHAWK project
#include "UASManager.h" #include "UASManager.h"
#include "HSIDisplay.h" #include "HSIDisplay.h"
#include "MG.h" #include "MG.h"
#include "QGC.h"
#include <QDebug> #include <QDebug>
...@@ -62,11 +63,31 @@ HSIDisplay::HSIDisplay(QWidget *parent) : ...@@ -62,11 +63,31 @@ HSIDisplay::HSIDisplay(QWidget *parent) :
x(0), x(0),
y(0), y(0),
z(0), z(0),
//yaw(0), vx(0),
localAvailable(0) vy(0),
vz(0),
speed(0),
localAvailable(0),
roll(0),
pitch(0),
yaw(0.0f),
bodyXSetCoordinate(0.0f),
bodyYSetCoordinate(0.0f),
bodyZSetCoordinate(0.0f),
bodyYawSet(0.0f),
uiXSetCoordinate(0.0f),
uiYSetCoordinate(0.0f),
uiZSetCoordinate(0.0f),
uiYawSet(0.0f),
metricWidth(2.0f)
{ {
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
refreshTimer->setInterval(80); refreshTimer->setInterval(80);
// FIXME
float bottomMargin = 3.0f;
xCenterPos = vwidth/2.0f;
yCenterPos = vheight/2.0f - bottomMargin;
} }
void HSIDisplay::paintEvent(QPaintEvent * event) void HSIDisplay::paintEvent(QPaintEvent * event)
...@@ -83,21 +104,12 @@ void HSIDisplay::paintDisplay() ...@@ -83,21 +104,12 @@ void HSIDisplay::paintDisplay()
{ {
// Center location of the HSI gauge items // Center location of the HSI gauge items
float xCenterPos = vwidth/2.0f; float bottomMargin = 3.0f;
float yCenterPos = vheight/2.0f;
// Size of the ring instrument // Size of the ring instrument
const float margin = 0.1f; // 10% margin of total width on each side const float margin = 0.1f; // 10% margin of total width on each side
float baseRadius = (vwidth - vwidth * 2.0f * margin) / 2.0f; float baseRadius = (vheight - vheight * 2.0f * margin) / 2.0f - bottomMargin / 2.0f;
// quint64 refreshInterval = 100;
// quint64 currTime = MG::TIME::getGroundTimeNow();
// if (currTime - lastPaintTime < refreshInterval)
// {
// // FIXME Need to find the source of the spurious paint events
// //return;
// }
// lastPaintTime = currTime;
// Draw instruments // Draw instruments
// TESTING THIS SHOULD BE MOVED INTO A QGRAPHICSVIEW // TESTING THIS SHOULD BE MOVED INTO A QGRAPHICSVIEW
// Update scaling factor // Update scaling factor
...@@ -109,75 +121,133 @@ void HSIDisplay::paintDisplay() ...@@ -109,75 +121,133 @@ void HSIDisplay::paintDisplay()
QPainter painter(this); QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true); painter.setRenderHint(QPainter::Antialiasing, true);
painter.setRenderHint(QPainter::HighQualityAntialiasing, true); painter.setRenderHint(QPainter::HighQualityAntialiasing, true);
// Draw background
painter.fillRect(QRect(0, 0, width(), height()), backgroundColor); painter.fillRect(QRect(0, 0, width(), height()), backgroundColor);
const QColor ringColor = QColor(200, 250, 200);
// Draw base instrument // Draw base instrument
// ---------------------- // ----------------------
const QColor ringColor = QColor(200, 250, 200);
const int ringCount = 2; const int ringCount = 2;
for (int i = 0; i < ringCount; i++) for (int i = 0; i < ringCount; i++)
{ {
float radius = (vwidth - vwidth * 2.0f * margin) / (2.0f * i+1) / 2.0f; float radius = (vwidth - vwidth * 2.0f * margin) / (2.0f * i+1) / 2.0f - bottomMargin / 2.0f;
drawCircle(vwidth/2.0f, vheight/2.0f, radius, 0.1f, ringColor, &painter); drawCircle(xCenterPos, yCenterPos, radius, 0.1f, ringColor, &painter);
} }
// Draw center indicator // Draw center indicator
drawCircle(vwidth/2.0f, vheight/2.0f, 1.0f, 0.1f, ringColor, &painter); QPolygonF p(3);
p.replace(0, QPointF(xCenterPos, yCenterPos-2.8484f));
// Draw orientation labels p.replace(1, QPointF(xCenterPos-2.0f, yCenterPos+2.0f));
paintText(tr("N"), ringColor, 3.5f, xCenterPos - 1.0f, yCenterPos - baseRadius - 5.5f, &painter); p.replace(2, QPointF(xCenterPos+2.0f, yCenterPos+2.0f));
paintText(tr("S"), ringColor, 3.5f, xCenterPos - 1.0f, yCenterPos + baseRadius + 1.5f, &painter); drawPolygon(p, &painter);
paintText(tr("E"), ringColor, 3.5f, xCenterPos + baseRadius + 2.0f, yCenterPos - 1.75f, &painter);
paintText(tr("W"), ringColor, 3.5f, xCenterPos - baseRadius - 5.5f, yCenterPos - 1.75f, &painter);
// ---------------------- // ----------------------
// Draw satellites
drawGPS(painter);
// Draw state indicator // Draw state indicator
// Draw position // Draw position
QColor positionColor(20, 20, 200); QColor positionColor(20, 20, 200);
drawPositionSetpoint(xCenterPos, yCenterPos, baseRadius, positionColor, &painter); drawPositionDirection(xCenterPos, yCenterPos, baseRadius, positionColor, &painter);
// Draw attitude // Draw attitude
QColor attitudeColor(200, 20, 20); QColor attitudeColor(200, 20, 20);
drawAttitudeSetpoint(xCenterPos, yCenterPos, baseRadius, attitudeColor, &painter); drawAttitudeDirection(xCenterPos, yCenterPos, baseRadius, attitudeColor, &painter);
// Draw position setpoints in body coordinates
// Draw satellites if (uiXSetCoordinate != 0 || uiYSetCoordinate != 0)
drawGPS(); {
QColor spColor(150, 150, 150);
drawSetpointXY(uiXSetCoordinate, uiYSetCoordinate, uiYawSet, spColor, painter);
}
if (bodyXSetCoordinate != 0 || bodyYSetCoordinate != 0)
{
// Draw setpoint
drawSetpointXY(bodyXSetCoordinate, bodyYSetCoordinate, bodyYawSet, QGC::ColorCyan, painter);
// Draw travel direction line
QPointF m(bodyXSetCoordinate, bodyYSetCoordinate);
QPointF s = metricBodyToRefX(m);
drawLine(s.x(), s.y(), xCenterPos, yCenterPos, 1.5f, QGC::ColorCyan, &painter);
}
// Labels on outer part and bottom
if (localAvailable > 0) //if (localAvailable > 0)
{ {
// Position
QString str; QString str;
str.sprintf("%05.2f %05.2f %05.2f m", x, y, z); str.sprintf("%05.2f %05.2f %05.2f m", x, y, z);
paintText(str, ringColor, 4.5f, xCenterPos + baseRadius - 5.5f, yCenterPos + baseRadius - 20.75f, &painter); paintText(str, ringColor, 3.0f, xCenterPos + baseRadius - 30.75f, vheight - 5.0f, &painter);
// Speed
str.sprintf("%05.2f m/s", speed);
paintText(str, ringColor, 3.0f, xCenterPos, vheight - 5.0f, &painter);
} }
// Draw orientation labels
// Translate and rotate coordinate frame
painter.translate((xCenterPos)*scalingFactor, (yCenterPos)*scalingFactor);
painter.rotate(yaw);
paintText(tr("N"), ringColor, 3.5f, - 1.0f, - baseRadius - 5.5f, &painter);
paintText(tr("S"), ringColor, 3.5f, - 1.0f, + baseRadius + 1.5f, &painter);
paintText(tr("E"), ringColor, 3.5f, + baseRadius + 2.0f, - 1.75f, &painter);
paintText(tr("W"), ringColor, 3.5f, - baseRadius - 5.5f, - 1.75f, &painter);
// FIXME Just for testing
bodyXSetCoordinate = 0.95 * bodyXSetCoordinate + 0.05 * uiXSetCoordinate;
bodyYSetCoordinate = 0.95 * bodyYSetCoordinate + 0.05 * uiYSetCoordinate;
bodyZSetCoordinate = 0.95 * bodyZSetCoordinate + 0.05 * uiZSetCoordinate;
bodyYawSet = 0.95 * bodyYawSet + 0.05 * uiYawSet;
}
//drawSystemIndicator(10.0f-gaugeWidth/2.0f, 20.0f, 10.0f, 40.0f, 15.0f, &painter); QPointF HSIDisplay::screenToMetricBody(QPointF ref)
//drawGauge(15.0f, 15.0f, gaugeWidth/2.0f, 0, 1.0f, "thrust", values.value("thrust", 0.0f), gaugeColor, &painter, qMakePair(0.45f, 0.8f), qMakePair(0.8f, 1.0f), true); {
//drawGauge(15.0f+gaugeWidth*1.7f, 15.0f, gaugeWidth/2.0f, 0, 10.0f, "altitude", values.value("altitude", 0.0f), gaugeColor, &painter, qMakePair(1.0f, 2.5f), qMakePair(0.0f, 0.5f), true); return QPointF(-((screenToRefY(ref.y()) - yCenterPos)/ vwidth) * metricWidth, ((screenToRefX(ref.x()) - xCenterPos) / vwidth) * metricWidth);
}
// Left spacing from border / other gauges, measured from left edge to center
// float leftSpacing = gaugeWidth * spacing; QPointF HSIDisplay::refToMetricBody(QPointF &ref)
// float xCoord = leftSpacing + gaugeWidth/2.0f; {
// return QPointF(-((ref.y() - yCenterPos)/ vwidth) * metricWidth, ((ref.x() - xCenterPos) / vwidth) * metricWidth);
// float topSpacing = leftSpacing; }
// float yCoord = topSpacing + gaugeWidth/2.0f;
// /**
// for (int i = 0; i < acceptList->size(); ++i) * @see refToScreenX()
// { */
// QString value = acceptList->at(i); QPointF HSIDisplay::metricBodyToRefX(QPointF &metric)
// drawGauge(xCoord, yCoord, gaugeWidth/2.0f, minValues.value(value, -1.0f), maxValues.value(value, 1.0f), value, values.value(value, minValues.value(value, 0.0f)), gaugeColor, &painter, goodRanges.value(value, qMakePair(0.0f, 0.5f)), critRanges.value(value, qMakePair(0.7f, 1.0f)), true); {
// xCoord += gaugeWidth + leftSpacing; return QPointF(((metric.y())/ metricWidth) * vwidth + xCenterPos, ((-metric.x()) / metricWidth) * vwidth + yCenterPos);
// // Move one row down if necessary }
// if (xCoord + gaugeWidth > vwidth)
// { void HSIDisplay::mouseDoubleClickEvent(QMouseEvent * event)
// yCoord += topSpacing + gaugeWidth; {
// xCoord = leftSpacing + gaugeWidth/2.0f; static bool dragStarted;
// } static float startX;
// }
if (event->MouseButtonDblClick)
{
//setBodySetpointCoordinateXY(-refToMetric(screenToRefY(event->y()) - yCenterPos), refToMetric(screenToRefX(event->x()) - xCenterPos));
QPointF p = screenToMetricBody(event->posF());
setBodySetpointCoordinateXY(p.x(), p.y());
qDebug() << "Double click at x: " << screenToRefX(event->x()) - xCenterPos << "y:" << screenToRefY(event->y()) - yCenterPos;
}
else if (event->MouseButtonPress)
{
if (event->button() == Qt::RightButton)
{
}
else if (event->button() == Qt::LeftButton)
{
}
}
} }
/** /**
...@@ -186,19 +256,23 @@ void HSIDisplay::paintDisplay() ...@@ -186,19 +256,23 @@ void HSIDisplay::paintDisplay()
*/ */
void HSIDisplay::setActiveUAS(UASInterface* uas) void HSIDisplay::setActiveUAS(UASInterface* uas)
{ {
HDDisplay::setActiveUAS(uas);
//qDebug() << "ATTEMPTING TO SET UAS";
if (this->uas != NULL && this->uas != uas) if (this->uas != NULL && this->uas != uas)
{ {
// Disconnect any previously connected active MAV // Disconnect any previously connected active MAV
//disconnect(uas, SIGNAL(valueChanged(UASInterface*,QString,double,quint64)), this, SLOT(updateValue(UASInterface*,QString,double,quint64))); //disconnect(uas, SIGNAL(valueChanged(UASInterface*,QString,double,quint64)), this, SLOT(updateValue(UASInterface*,QString,double,quint64)));
} }
HDDisplay::setActiveUAS(uas);
//qDebug() << "ATTEMPTING TO SET UAS";
connect(uas, SIGNAL(gpsSatelliteStatusChanged(int,int,float,float,float,bool)), this, SLOT(updateSatellite(int,int,float,float,float,bool))); connect(uas, SIGNAL(gpsSatelliteStatusChanged(int,int,float,float,float,bool)), this, SLOT(updateSatellite(int,int,float,float,float,bool)));
connect(uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateLocalPosition(UASInterface*,double,double,double,quint64))); connect(uas, SIGNAL(localPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateLocalPosition(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateGlobalPosition(UASInterface*,double,double,double,quint64))); connect(uas, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateGlobalPosition(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(attitudeThrustSetPointChanged(UASInterface*,double,double,double,double,quint64)), this, SLOT(updateAttitudeSetpoints(UASInterface*,double,double,double,double,quint64))); connect(uas, SIGNAL(attitudeThrustSetPointChanged(UASInterface*,double,double,double,double,quint64)), this, SLOT(updateAttitudeSetpoints(UASInterface*,double,double,double,double,quint64)));
connect(uas, SIGNAL(positionSetPointsChanged(int,float,float,float,float,quint64)), this, SLOT(updatePositionSetpoints(int,float,float,float,float,quint64))); connect(uas, SIGNAL(positionSetPointsChanged(int,float,float,float,float,quint64)), this, SLOT(updatePositionSetpoints(int,float,float,float,float,quint64)));
connect(uas, SIGNAL(speedChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateSpeed(UASInterface*,double,double,double,quint64)));
// Now connect the new UAS // Now connect the new UAS
...@@ -210,6 +284,36 @@ void HSIDisplay::setActiveUAS(UASInterface* uas) ...@@ -210,6 +284,36 @@ void HSIDisplay::setActiveUAS(UASInterface* uas)
//} //}
} }
void HSIDisplay::updateSpeed(UASInterface* uas, double vx, double vy, double vz, quint64 time)
{
Q_UNUSED(uas);
Q_UNUSED(time);
this->vx = vx;
this->vy = vy;
this->vz = vz;
this->speed = sqrt(pow(vx, 2.0f) + pow(vy, 2.0f) + pow(vz, 2.0f));
}
void HSIDisplay::setBodySetpointCoordinateXY(double x, double y)
{
// Set coordinates and send them out to MAV
qDebug() << "Setting new setpoint at x: " << x << "metric y:" << y;
uiXSetCoordinate = x;
uiYSetCoordinate = y;
}
void HSIDisplay::setBodySetpointCoordinateZ(double z)
{
// Set coordinates and send them out to MAV
uiZSetCoordinate = z;
}
void HSIDisplay::sendBodySetPointCoordinates()
{
// Send the coordinates to the MAV
}
void HSIDisplay::updateAttitudeSetpoints(UASInterface* uas, double rollDesired, double pitchDesired, double yawDesired, double thrustDesired, quint64 usec) void HSIDisplay::updateAttitudeSetpoints(UASInterface* uas, double rollDesired, double pitchDesired, double yawDesired, double thrustDesired, quint64 usec)
{ {
Q_UNUSED(uas); Q_UNUSED(uas);
...@@ -287,14 +391,36 @@ QColor HSIDisplay::getColorForSNR(float snr) ...@@ -287,14 +391,36 @@ QColor HSIDisplay::getColorForSNR(float snr)
return color; return color;
} }
void HSIDisplay::drawGPS() void HSIDisplay::drawSetpointXY(float x, float y, float yaw, const QColor &color, QPainter &painter)
{ {
float xCenter = vwidth/2.0f; float radius = vwidth / 20.0f;
float yCenter = vwidth/2.0f; QPen pen(color);
QPainter painter(this); pen.setWidthF(refLineWidthToPen(0.4f));
painter.setRenderHint(QPainter::Antialiasing, true); pen.setColor(color);
painter.setRenderHint(QPainter::HighQualityAntialiasing, true); painter.setPen(pen);
painter.setBrush(Qt::NoBrush);
QPointF in(x, y);
QPointF p = metricBodyToRefX(in);
drawCircle(p.x(), p.y(), radius, 0.4f, color, &painter);
radius *= 0.8;
drawLine(p.x(), p.y(), p.x()+sin(yaw) * radius, p.y()-cos(yaw) * radius, refLineWidthToPen(0.4f), color, &painter);
painter.setBrush(color);
drawCircle(p.x(), p.y(), radius * 0.1f, 0.1f, color, &painter);
}
void HSIDisplay::drawSafetyArea(const QPointF &topLeft, const QPointF &bottomRight, const QColor &color, QPainter &painter)
{
QPen pen(color);
pen.setWidthF(refLineWidthToPen(0.1f));
pen.setColor(color);
painter.setPen(pen);
painter.drawRect(QRectF(topLeft, bottomRight));
}
void HSIDisplay::drawGPS(QPainter &painter)
{
float xCenter = xCenterPos;
float yCenter = xCenterPos;
// Max satellite circle radius // Max satellite circle radius
const float margin = 0.15f; // 20% margin of total width on each side const float margin = 0.15f; // 20% margin of total width on each side
...@@ -349,18 +475,20 @@ void HSIDisplay::drawGPS() ...@@ -349,18 +475,20 @@ void HSIDisplay::drawGPS()
float xPos = xCenter + (sin(((sat->azimuth/255.0f)*360.0f)/180.0f * M_PI) * cos(sat->elevation/180.0f * M_PI)) * radius; float xPos = xCenter + (sin(((sat->azimuth/255.0f)*360.0f)/180.0f * M_PI) * cos(sat->elevation/180.0f * M_PI)) * radius;
float yPos = yCenter - (cos(((sat->azimuth/255.0f)*360.0f)/180.0f * M_PI) * cos(sat->elevation/180.0f * M_PI)) * radius; float yPos = yCenter - (cos(((sat->azimuth/255.0f)*360.0f)/180.0f * M_PI) * cos(sat->elevation/180.0f * M_PI)) * radius;
// Draw circle for satellite, filled for used satellites
drawCircle(xPos, yPos, vwidth*0.02f, 1.0f, color, &painter); drawCircle(xPos, yPos, vwidth*0.02f, 1.0f, color, &painter);
// Draw satellite PRN
paintText(QString::number(sat->id), QColor(255, 255, 255), 2.9f, xPos+1.7f, yPos+2.0f, &painter); paintText(QString::number(sat->id), QColor(255, 255, 255), 2.9f, xPos+1.7f, yPos+2.0f, &painter);
} }
} }
} }
void HSIDisplay::drawObjects() void HSIDisplay::drawObjects(QPainter &painter)
{ {
Q_UNUSED(painter);
} }
void HSIDisplay::drawPositionSetpoint(float xRef, float yRef, float radius, const QColor& color, QPainter* painter) void HSIDisplay::drawPositionDirection(float xRef, float yRef, float radius, const QColor& color, QPainter* painter)
{ {
// Draw the needle // Draw the needle
const float maxWidth = radius / 10.0f; const float maxWidth = radius / 10.0f;
...@@ -392,10 +520,10 @@ void HSIDisplay::drawPositionSetpoint(float xRef, float yRef, float radius, cons ...@@ -392,10 +520,10 @@ void HSIDisplay::drawPositionSetpoint(float xRef, float yRef, float radius, cons
painter->setBrush(indexBrush); painter->setBrush(indexBrush);
drawPolygon(p, painter); drawPolygon(p, painter);
qDebug() << "DRAWING POS SETPOINT X:" << posXSet << "Y:" << posYSet << angle; //qDebug() << "DRAWING POS SETPOINT X:" << posXSet << "Y:" << posYSet << angle;
} }
void HSIDisplay::drawAttitudeSetpoint(float xRef, float yRef, float radius, const QColor& color, QPainter* painter) void HSIDisplay::drawAttitudeDirection(float xRef, float yRef, float radius, const QColor& color, QPainter* painter)
{ {
// Draw the needle // Draw the needle
const float maxWidth = radius / 10.0f; const float maxWidth = radius / 10.0f;
...@@ -427,7 +555,7 @@ void HSIDisplay::drawAttitudeSetpoint(float xRef, float yRef, float radius, cons ...@@ -427,7 +555,7 @@ void HSIDisplay::drawAttitudeSetpoint(float xRef, float yRef, float radius, cons
// TODO Draw Yaw indicator // TODO Draw Yaw indicator
qDebug() << "DRAWING ATT SETPOINT X:" << attXSet << "Y:" << attYSet << angle; //qDebug() << "DRAWING ATT SETPOINT X:" << attXSet << "Y:" << attYSet << angle;
} }
void HSIDisplay::drawAltitudeSetpoint(float xRef, float yRef, float radius, const QColor& color, QPainter* painter) void HSIDisplay::drawAltitudeSetpoint(float xRef, float yRef, float radius, const QColor& color, QPainter* painter)
...@@ -446,3 +574,13 @@ void HSIDisplay::drawAltitudeSetpoint(float xRef, float yRef, float radius, cons ...@@ -446,3 +574,13 @@ void HSIDisplay::drawAltitudeSetpoint(float xRef, float yRef, float radius, cons
// label.sprintf("%05.1f", value); // label.sprintf("%05.1f", value);
// paintText(label, color, 4.5f, xRef-7.5f, yRef-2.0f, painter); // paintText(label, color, 4.5f, xRef-7.5f, yRef-2.0f, painter);
} }
void HSIDisplay::updateJoystick(double roll, double pitch, double yaw, double thrust, int xHat, int yHat)
{
}
void HSIDisplay::pressKey(int key)
{
}
...@@ -37,6 +37,7 @@ This file is part of the PIXHAWK project ...@@ -37,6 +37,7 @@ This file is part of the PIXHAWK project
#include <QTimer> #include <QTimer>
#include <QMap> #include <QMap>
#include <QPair> #include <QPair>
#include <QMouseEvent>
#include <cmath> #include <cmath>
#include "HDDisplay.h" #include "HDDisplay.h"
...@@ -55,19 +56,38 @@ public slots: ...@@ -55,19 +56,38 @@ public slots:
void updatePositionSetpoints(int uasid, float xDesired, float yDesired, float zDesired, float yawDesired, quint64 usec); void updatePositionSetpoints(int uasid, float xDesired, float yDesired, float zDesired, float yawDesired, quint64 usec);
void updateLocalPosition(UASInterface*, double x, double y, double z, quint64 usec); void updateLocalPosition(UASInterface*, double x, double y, double z, quint64 usec);
void updateGlobalPosition(UASInterface*, double lat, double lon, double alt, quint64 usec); void updateGlobalPosition(UASInterface*, double lat, double lon, double alt, quint64 usec);
void updateSpeed(UASInterface* uas, double vx, double vy, double vz, quint64 time);
void paintEvent(QPaintEvent * event); void paintEvent(QPaintEvent * event);
/** @brief Update state from joystick */
void updateJoystick(double roll, double pitch, double yaw, double thrust, int xHat, int yHat);
void pressKey(int key);
protected slots: protected slots:
void paintDisplay(); void paintDisplay();
void drawGPS(); void drawGPS(QPainter &painter);
void drawObjects(); void drawObjects(QPainter &painter);
void drawPositionSetpoint(float xRef, float yRef, float radius, const QColor& color, QPainter* painter); void drawPositionDirection(float xRef, float yRef, float radius, const QColor& color, QPainter* painter);
void drawAttitudeSetpoint(float xRef, float yRef, float radius, const QColor& color, QPainter* painter); void drawAttitudeDirection(float xRef, float yRef, float radius, const QColor& color, QPainter* painter);
void drawAltitudeSetpoint(float xRef, float yRef, float radius, const QColor& color, QPainter* painter); void drawAltitudeSetpoint(float xRef, float yRef, float radius, const QColor& color, QPainter* painter);
void setBodySetpointCoordinateXY(double x, double y);
void setBodySetpointCoordinateZ(double z);
/** @brief Send the current ui setpoint coordinates as new setpoint to the MAV */
void sendBodySetPointCoordinates();
/** @brief Draw one setpoint */
void drawSetpointXY(float x, float y, float yaw, const QColor &color, QPainter &painter);
/** @brief Draw the limiting safety area */
void drawSafetyArea(const QPointF &topLeft, const QPointF &bottomRight, const QColor &color, QPainter &painter);
void mouseDoubleClickEvent(QMouseEvent* event);
protected: protected:
static QColor getColorForSNR(float snr); static QColor getColorForSNR(float snr);
/** @brief Screen coordinates of widget to metric coordinates in body frame */
QPointF screenToMetricBody(QPointF ref);
/** @brief Reference coordinates to metric coordinates */
QPointF refToMetricBody(QPointF &ref);
/** @brief Metric coordinates to reference coordinates */
QPointF metricBodyToRefX(QPointF &metric);
/** /**
* @brief Private data container class to be used within the HSI widget * @brief Private data container class to be used within the HSI widget
...@@ -132,11 +152,31 @@ protected: ...@@ -132,11 +152,31 @@ protected:
float lat; float lat;
float lon; float lon;
float alt; float alt;
quint64 globalAvailable; ///< Last global position update time quint64 globalAvailable; ///< Last global position update time
float x; float x;
float y; float y;
float z; float z;
quint64 localAvailable; ///< Last local position update time float vx;
float vy;
float vz;
float speed;
quint64 localAvailable; ///< Last local position update time
float roll;
float pitch;
float yaw;
float bodyXSetCoordinate; ///< X Setpoint coordinate active on the MAV
float bodyYSetCoordinate; ///< Y Setpoint coordinate active on the MAV
float bodyZSetCoordinate; ///< Z Setpoint coordinate active on the MAV
float bodyYawSet; ///< Yaw setpoint coordinate active on the MAV
float uiXSetCoordinate; ///< X Setpoint coordinate wanted by the UI
float uiYSetCoordinate; ///< Y Setpoint coordinate wanted by the UI
float uiZSetCoordinate; ///< Z Setpoint coordinate wanted by the UI
float uiYawSet; ///< Yaw Setpoint wanted by the UI
float metricWidth; ///< Width the instrument represents in meters (the width of the ground shown by the widget)
//
float xCenterPos;
float yCenterPos;
private: private:
}; };
......
...@@ -490,10 +490,11 @@ void MainWindow::loadEngineerView() ...@@ -490,10 +490,11 @@ void MainWindow::loadEngineerView()
container3->setWidget(info); container3->setWidget(info);
addDockWidget(Qt::LeftDockWidgetArea, container3); addDockWidget(Qt::LeftDockWidgetArea, container3);
// WAYPOINT LIST // HORIZONTAL SITUATION INDICATOR
QDockWidget* container5 = new QDockWidget(tr("Waypoint List"), this); QDockWidget* container6 = new QDockWidget(tr("Horizontal Situation Indicator"), this);
container5->setWidget(waypoints); container6->setWidget(hsi);
addDockWidget(Qt::BottomDockWidgetArea, container5); hsi->start();
addDockWidget(Qt::BottomDockWidgetArea, container6);
// DEBUG CONSOLE // DEBUG CONSOLE
QDockWidget* container7 = new QDockWidget(tr("Communication Console"), this); QDockWidget* container7 = new QDockWidget(tr("Communication Console"), this);
......
...@@ -6,21 +6,27 @@ ...@@ -6,21 +6,27 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>387</width> <width>380</width>
<height>212</height> <height>190</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,20,0" columnstretch="0,0,0,0,20"> <layout class="QGridLayout" name="gridLayout">
<property name="margin"> <property name="leftMargin">
<number>20</number> <number>6</number>
</property>
<property name="topMargin">
<number>12</number>
</property> </property>
<property name="spacing"> <property name="rightMargin">
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="0" colspan="4"> <property name="bottomMargin">
<number>6</number>
</property>
<item row="0" column="1" colspan="4">
<widget class="QLabel" name="controlStatusLabel"> <widget class="QLabel" name="controlStatusLabel">
<property name="text"> <property name="text">
<string>UNCONNECTED</string> <string>UNCONNECTED</string>
...@@ -30,27 +36,14 @@ ...@@ -30,27 +36,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="4" rowspan="7"> <item row="1" column="1" colspan="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>172</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="4">
<widget class="QPushButton" name="controlButton"> <widget class="QPushButton" name="controlButton">
<property name="text"> <property name="text">
<string>Activate Engine</string> <string>Activate Engine</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="4"> <item row="2" column="1" colspan="4">
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
...@@ -60,13 +53,26 @@ ...@@ -60,13 +53,26 @@
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>218</width> <width>20</width>
<height>6</height> <height>0</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="3" column="0"> <item row="0" column="0" rowspan="6">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>31</width>
<height>159</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="liftoffButton"> <widget class="QPushButton" name="liftoffButton">
<property name="text"> <property name="text">
<string>Liftoff</string> <string>Liftoff</string>
...@@ -77,56 +83,56 @@ ...@@ -77,56 +83,56 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="3"> <item row="3" column="2" colspan="2">
<widget class="QComboBox" name="modeComboBox"/> <widget class="QPushButton" name="landButton">
</item>
<item row="3" column="3">
<widget class="QPushButton" name="shutdownButton">
<property name="text"> <property name="text">
<string>Halt</string> <string>Land</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../mavground.qrc"> <iconset resource="../../mavground.qrc">
<normaloff>:/images/actions/system-log-out.svg</normaloff>:/images/actions/system-log-out.svg</iconset> <normaloff>:/images/control/land.svg</normaloff>:/images/control/land.svg</iconset>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="3"> <item row="3" column="4">
<widget class="QPushButton" name="setModeButton"> <widget class="QPushButton" name="shutdownButton">
<property name="text"> <property name="text">
<string>Set Mode</string> <string>Halt</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../mavground.qrc"> <iconset resource="../../mavground.qrc">
<normaloff>:/images/devices/network-wireless.svg</normaloff>:/images/devices/network-wireless.svg</iconset> <normaloff>:/images/actions/system-log-out.svg</normaloff>:/images/actions/system-log-out.svg</iconset>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="4"> <item row="0" column="5" rowspan="6">
<spacer name="verticalSpacer"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>30</width>
<height>0</height> <height>159</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="3" column="1" colspan="2"> <item row="4" column="1" colspan="2">
<widget class="QPushButton" name="landButton"> <widget class="QComboBox" name="modeComboBox"/>
</item>
<item row="4" column="3" colspan="2">
<widget class="QPushButton" name="setModeButton">
<property name="text"> <property name="text">
<string>Land</string> <string>Set Mode</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../../mavground.qrc"> <iconset resource="../../mavground.qrc">
<normaloff>:/images/control/land.svg</normaloff>:/images/control/land.svg</iconset> <normaloff>:/images/devices/network-wireless.svg</normaloff>:/images/devices/network-wireless.svg</iconset>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="4"> <item row="5" column="1" colspan="4">
<widget class="QLabel" name="lastActionLabel"> <widget class="QLabel" name="lastActionLabel">
<property name="text"> <property name="text">
<string>No actions executed so far</string> <string>No actions executed so far</string>
...@@ -136,6 +142,19 @@ ...@@ -136,6 +142,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="6">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<resources> <resources>
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
<string notr="true"/> <string notr="true"/>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>6</number>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
...@@ -109,19 +112,6 @@ ...@@ -109,19 +112,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="6" rowspan="6">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>108</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
...@@ -398,7 +388,7 @@ ...@@ -398,7 +388,7 @@
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>0</width> <width>0</width>
<height>197</height> <height>0</height>
</size> </size>
</property> </property>
</spacer> </spacer>
......
...@@ -10,6 +10,12 @@ ...@@ -10,6 +10,12 @@
<height>300</height> <height>300</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>500</width>
<height>0</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<string>Form</string> <string>Form</string>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string>QWidget#colorIcon {} <string notr="true">QWidget#colorIcon {}
QWidget { QWidget {
background-color: none; background-color: none;
...@@ -95,19 +95,6 @@ QGroupBox#heartbeatIcon { ...@@ -95,19 +95,6 @@ QGroupBox#heartbeatIcon {
background-color: red; background-color: red;
} }
QToolButton {
font-weight: bold;
font-size: 12px;
border: 1px solid #999999;
border-radius: 5px;
min-width:44px;
max-width: 44px;
min-height: 44px;
max-height: 44px;
padding: 0px;
background-color: none;
}
QToolButton#typeButton { QToolButton#typeButton {
font-weight: bold; font-weight: bold;
font-size: 12px; font-size: 12px;
...@@ -126,7 +113,7 @@ QPushButton { ...@@ -126,7 +113,7 @@ QPushButton {
font-size: 12px; font-size: 12px;
border: 1px solid #999999; border: 1px solid #999999;
border-radius: 10px; border-radius: 10px;
min-width:12px; min-width: 20px;
max-width: 40px; max-width: 40px;
min-height: 16px; min-height: 16px;
max-height: 16px; max-height: 16px;
...@@ -203,14 +190,14 @@ QProgressBar::chunk#thrustBar { ...@@ -203,14 +190,14 @@ QProgressBar::chunk#thrustBar {
<item> <item>
<widget class="QGroupBox" name="uasViewFrame"> <widget class="QGroupBox" name="uasViewFrame">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>350</width> <width>0</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
...@@ -558,7 +545,7 @@ QProgressBar::chunk#thrustBar { ...@@ -558,7 +545,7 @@ QProgressBar::chunk#thrustBar {
<widget class="QPushButton" name="liftoffButton"> <widget class="QPushButton" name="liftoffButton">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>18</width> <width>26</width>
<height>22</height> <height>22</height>
</size> </size>
</property> </property>
...@@ -575,7 +562,7 @@ QProgressBar::chunk#thrustBar { ...@@ -575,7 +562,7 @@ QProgressBar::chunk#thrustBar {
<widget class="QPushButton" name="haltButton"> <widget class="QPushButton" name="haltButton">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>18</width> <width>26</width>
<height>22</height> <height>22</height>
</size> </size>
</property> </property>
...@@ -592,7 +579,7 @@ QProgressBar::chunk#thrustBar { ...@@ -592,7 +579,7 @@ QProgressBar::chunk#thrustBar {
<widget class="QPushButton" name="continueButton"> <widget class="QPushButton" name="continueButton">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>18</width> <width>26</width>
<height>22</height> <height>22</height>
</size> </size>
</property> </property>
...@@ -609,7 +596,7 @@ QProgressBar::chunk#thrustBar { ...@@ -609,7 +596,7 @@ QProgressBar::chunk#thrustBar {
<widget class="QPushButton" name="landButton"> <widget class="QPushButton" name="landButton">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>18</width> <width>26</width>
<height>22</height> <height>22</height>
</size> </size>
</property> </property>
...@@ -637,7 +624,7 @@ QProgressBar::chunk#thrustBar { ...@@ -637,7 +624,7 @@ QProgressBar::chunk#thrustBar {
<widget class="QPushButton" name="abortButton"> <widget class="QPushButton" name="abortButton">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>18</width> <width>26</width>
<height>22</height> <height>22</height>
</size> </size>
</property> </property>
...@@ -654,7 +641,7 @@ QProgressBar::chunk#thrustBar { ...@@ -654,7 +641,7 @@ QProgressBar::chunk#thrustBar {
<widget class="QPushButton" name="killButton"> <widget class="QPushButton" name="killButton">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>18</width> <width>26</width>
<height>22</height> <height>22</height>
</size> </size>
</property> </property>
......
...@@ -47,17 +47,18 @@ void XMLCommProtocolWidget::selectXMLFile() ...@@ -47,17 +47,18 @@ void XMLCommProtocolWidget::selectXMLFile()
{ {
m_ui->fileNameLabel->setText(fileNames.first()); m_ui->fileNameLabel->setText(fileNames.first());
QFile file(fileNames.first()); QFile file(fileNames.first());
// Store filename for next time
settings.setValue(mavlinkXML, fileNames.first());
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
const QString instanceText(QString::fromUtf8(file.readAll())); const QString instanceText(QString::fromUtf8(file.readAll()));
setXML(instanceText); setXML(instanceText);
// Store filename for next time
settings.setValue(mavlinkXML, QFileInfo(file).absoluteFilePath());
} }
else else
{ {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("Could not write XML file. Permission denied"); msgBox.setText("Could not read XML file. Permission denied");
msgBox.exec(); msgBox.exec();
} }
} }
...@@ -114,10 +115,25 @@ void XMLCommProtocolWidget::selectOutputDirectory() ...@@ -114,10 +115,25 @@ void XMLCommProtocolWidget::selectOutputDirectory()
void XMLCommProtocolWidget::generate() void XMLCommProtocolWidget::generate()
{ {
// Check if input file is present
if (!QFileInfo(m_ui->fileNameLabel->text().trimmed()).isFile())
{
QMessageBox::critical(this, tr("Please select an XML input file first"), tr("You have to select an input XML file before generating C files."), QMessageBox::Ok);
return;
}
// Check if output dir is selected
if (!QFileInfo(m_ui->outputDirNameLabel->text().trimmed()).isDir())
{
QMessageBox::critical(this, tr("Please select output directory first"), tr("You have to select an output directory before generating C files."), QMessageBox::Ok);
return;
}
// First save file // First save file
save(); save();
// Clean log // Clean log
m_ui->compileLog->clear(); m_ui->compileLog->clear();
MAVLinkXMLParser* parser = new MAVLinkXMLParser(m_ui->fileNameLabel->text().trimmed(), m_ui->outputDirNameLabel->text().trimmed()); MAVLinkXMLParser* parser = new MAVLinkXMLParser(m_ui->fileNameLabel->text().trimmed(), m_ui->outputDirNameLabel->text().trimmed());
connect(parser, SIGNAL(parseState(QString)), m_ui->compileLog, SLOT(appendHtml(QString))); connect(parser, SIGNAL(parseState(QString)), m_ui->compileLog, SLOT(appendHtml(QString)));
bool result = parser->generate(); bool result = parser->generate();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment