Commit 53a72a04 authored by lm's avatar lm

Fixed initial startup bugs, cleaned up the activation-deactivation of update...

Fixed initial startup bugs, cleaned up the activation-deactivation of update timers. Added initial instructions for new users.
parent 8c910fe8
......@@ -220,16 +220,6 @@ void HDDisplay::renderOverlay()
}
}
void HDDisplay::start()
{
refreshTimer->start();
}
void HDDisplay::stop()
{
refreshTimer->stop();
}
/**
*
* @param uas the UAS/MAV to monitor/display with the HUD
......@@ -669,7 +659,22 @@ void HDDisplay::changeEvent(QEvent *e)
}
void HDDisplay::showEvent(QShowEvent* event)
{
// React only to internal (pre-display)
// events
if (!event->spontaneous())
{
if (event->type() == QEvent::Hide)
{
refreshTimer->stop();
}
else if (event->type() == QEvent::Show)
{
refreshTimer->start(updateInterval);
}
}
}
///**
......
......@@ -64,8 +64,6 @@ public:
public slots:
/** @brief Update a HDD value */
void updateValue(UASInterface* uas, QString name, double value, quint64 msec);
void start();
void stop();
void setActiveUAS(UASInterface* uas);
protected slots:
......@@ -77,6 +75,7 @@ protected slots:
protected:
void changeEvent(QEvent *e);
void paintEvent(QPaintEvent * event);
void showEvent(QShowEvent* event);
float refLineWidthToPen(float line);
float refToScreenX(float x);
float refToScreenY(float y);
......@@ -142,6 +141,7 @@ protected:
int warningBlinkRate; ///< Blink rate of warning messages, will be rounded to the refresh rate
QTimer* refreshTimer; ///< The main timer, controls the update rate
static const int updateInterval = 120; ///< Update interval in milliseconds
QPainter* hudPainter;
QFont font; ///< The HUD font, per default the free Bitstream Vera SANS, which is very close to actual HUD fonts
QFontDatabase fontDatabase;///< Font database, only used to load the TrueType font file (the HUD font is directly loaded from file rather than from the system)
......
......@@ -100,7 +100,7 @@ HSIDisplay::HSIDisplay(QWidget *parent) :
topMargin(3.0f)
{
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
refreshTimer->setInterval(120);
refreshTimer->setInterval(updateInterval);
// this->setScene(new QGraphicsScene(-metricWidth/2.0f, -metricWidth/2.0f, metricWidth, metricWidth, this));
......@@ -925,6 +925,23 @@ void HSIDisplay::wheelEvent(QWheelEvent* event)
emit metricWidthChanged(metricWidth);
}
void HSIDisplay::showEvent(QShowEvent* event)
{
// React only to internal (pre-display)
// events
if (!event->spontaneous())
{
if (event->type() == QEvent::Hide)
{
refreshTimer->stop();
}
else if (event->type() == QEvent::Show)
{
refreshTimer->start(updateInterval);
}
}
}
void HSIDisplay::updateJoystick(double roll, double pitch, double yaw, double thrust, int xHat, int yHat)
{
Q_UNUSED(roll);
......
......@@ -111,6 +111,7 @@ protected slots:
protected:
void showEvent(QShowEvent* event);
/** @brief Get color from GPS signal-to-noise colormap */
static QColor getColorForSNR(float snr);
/** @brief Metric world coordinates to metric body coordinates */
......
......@@ -29,6 +29,8 @@ This file is part of the QGROUNDCONTROL project
*
*/
#include <QShowEvent>
#include <QDebug>
#include <cmath>
#ifndef M_PI
......@@ -129,7 +131,7 @@ HUD::HUD(int width, int height, QWidget* parent)
glImage = QGLWidget::convertToGLFormat(fill);
// Refresh timer
refreshTimer->setInterval(50); // 20 Hz
refreshTimer->setInterval(updateInterval);
//connect(refreshTimer, SIGNAL(timeout()), this, SLOT(update()));
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(paintHUD()));
......@@ -175,27 +177,21 @@ HUD::~HUD()
void HUD::showEvent(QShowEvent* event)
{
Q_UNUSED(event);
if (isVisible())
{
refreshTimer->start();
}
else
// React only to internal (pre-display)
// events
if (!event->spontaneous())
{
refreshTimer->stop();
if (event->type() == QEvent::Hide)
{
refreshTimer->stop();
}
else if (event->type() == QEvent::Show)
{
refreshTimer->start(updateInterval);
}
}
}
void HUD::start()
{
refreshTimer->start();
}
void HUD::stop()
{
refreshTimer->stop();
}
void HUD::updateValue(UASInterface* uas, QString name, double value, quint64 msec)
{
// UAS is not needed
......@@ -561,9 +557,9 @@ void HUD::paintEvent(QPaintEvent *event)
void HUD::paintHUD()
{
// static quint64 interval = 0;
// qDebug() << "INTERVAL:" << MG::TIME::getGroundTimeNow() - interval << __FILE__ << __LINE__;
// interval = MG::TIME::getGroundTimeNow();
// static quint64 interval = 0;
// qDebug() << "INTERVAL:" << MG::TIME::getGroundTimeNow() - interval << __FILE__ << __LINE__;
// interval = MG::TIME::getGroundTimeNow();
// Read out most important values to limit hash table lookups
static float roll = 0.0f;
......
......@@ -60,11 +60,6 @@ public slots:
void initializeGL();
//void paintGL();
/** @brief Start updating the view at 30Hz */
void start();
/** @brief Stop updating the view */
void stop();
/** @brief Set the currently monitored UAS */
void setActiveUAS(UASInterface* uas);
......@@ -124,7 +119,9 @@ protected:
/** @brief Rotate a polygon around a point clockwise */
void rotatePolygonClockWiseRad(QPolygonF& p, float angle, QPointF origin);
/** @brief Override base class show */
virtual void showEvent(QShowEvent* event);
void showEvent(QShowEvent* event);
static const int updateInterval = 50;
QImage* image; ///< Double buffer image
QImage glImage; ///< The background / camera image
......
This diff is collapsed.
......@@ -260,7 +260,7 @@ protected:
* @param tool The ENUM defined in MainWindow.h that is associated to the widget
* @param location The default location for the QDockedWidget in case there is no previous key in the settings
*/
void addToToolsMenu (QWidget* widget, const QString title, const char * slotName, TOOLS_WIDGET_NAMES tool, Qt::DockWidgetArea location);
void addToToolsMenu (QWidget* widget, const QString title, const char * slotName, TOOLS_WIDGET_NAMES tool, Qt::DockWidgetArea location=Qt::RightDockWidgetArea);
/**
* @brief Determines if a QDockWidget needs to be show and if so, shows it
......@@ -353,7 +353,9 @@ protected:
#ifdef QGC_OSGEARTH_ENABLED
QPointer<QWidget> _3DMapWidget;
#endif
#if (defined _MSC_VER) || (defined Q_OS_MAC)
QPointer<QGCGoogleEarthView> gEarthWidget;
#endif
// Dock widgets
QPointer<QDockWidget> controlDockWidget;
QPointer<QDockWidget> infoDockWidget;
......
......@@ -90,7 +90,6 @@ public slots:
void refresh();
protected:
void addCurveToList(QString curve);
void removeCurveFromList(QString curve);
QToolButton* createButton(QWidget* parent);
......
#include <QShowEvent>
#include "Linecharts.h"
#include "UASManager.h"
#include "MainWindow.h"
Linecharts::Linecharts(QWidget *parent) :
QStackedWidget(parent),
plots(),
......@@ -19,24 +23,37 @@ Linecharts::Linecharts(QWidget *parent) :
this, SLOT(addSystem(UASInterface*)));
connect(UASManager::instance(), SIGNAL(activeUASSet(int)),
this, SLOT(selectSystem(int)));
connect(this, SIGNAL(logfileWritten(QString)),
MainWindow::instance(), SLOT(loadDataView(QString)));
}
void Linecharts::setActive(bool active)
void Linecharts::showEvent(QShowEvent* event)
{
this->active = active;
QWidget* prevWidget = currentWidget();
if (prevWidget)
// React only to internal (pre-display)
// events
if (!event->spontaneous())
{
LinechartWidget* chart = dynamic_cast<LinechartWidget*>(prevWidget);
if (chart)
QWidget* prevWidget = currentWidget();
if (prevWidget)
{
chart->setActive(active);
LinechartWidget* chart = dynamic_cast<LinechartWidget*>(prevWidget);
if (chart)
{
if (event->type() == QEvent::Hide)
{
this->active = false;
chart->setActive(false);
}
else if (event->type() == QEvent::Show)
{
this->active = true;
chart->setActive(true);
}
}
}
}
}
void Linecharts::selectSystem(int systemid)
{
QWidget* prevWidget = currentWidget();
......
......@@ -18,8 +18,6 @@ signals:
void logfileWritten(QString fileName);
public slots:
/** @brief Set all plots active/inactive */
void setActive(bool active);
/** @brief Select plot for one system */
void selectSystem(int systemid);
/** @brief Add a new system to the list of plots */
......@@ -28,6 +26,9 @@ public slots:
protected:
QMap<int, LinechartWidget*> plots;
bool active;
void showEvent(QShowEvent* event);
};
#endif // LINECHARTS_H
......@@ -121,6 +121,10 @@ protected slots:
void redraw(void);
protected:
/** @brief Enable / disable widget updating */
void showEvent(QShowEvent* event);
/**
* @brief Get base robot geode.
* @return Smart pointer to the geode.
......
#include <QApplication>
#include <QDir>
#include <QShowEvent>
#include <QDebug>
#include "UASManager.h"
#ifdef _MSC_VER
#include "ui_QGCGoogleEarthView.h"
#else
#ifdef Q_OS_MAC
#include <QWebFrame>
#include <QWebPage>
#include "QGCWebPage.h"
#include "ui_QGCGoogleEarthView.h"
#endif
#include "ui_QGCGoogleEarthView.h"
#include "QGCGoogleEarthView.h"
QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
......@@ -28,7 +29,7 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
webViewWin(new QGCWebAxWidget(this)),
#endif
#if (defined _MSC_VER)
ui(new Ui::QGCGoogleEarthView)
ui(new Ui::QGCGoogleEarthView)
#else
ui(new Ui::QGCGoogleEarthView)
#endif
......@@ -44,7 +45,7 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
#endif
#ifdef _MSC_VER
ui->webViewLayout->addWidget(webViewWin);
ui->webViewLayout->addWidget(webViewWin);
#endif
#if ((defined Q_OS_MAC) | (defined _MSC_VER))
......@@ -64,9 +65,9 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
// Get list of available 3D models
// Load HTML file
#ifdef _MSC_VER
webViewWin->dynamicCall("GoHome()");
webViewWin->dynamicCall("Navigate(const QString&)", QApplication::applicationDirPath() + "/earth.html");
#ifdef _MSC_VER
webViewWin->dynamicCall("GoHome()");
webViewWin->dynamicCall("Navigate(const QString&)", QApplication::applicationDirPath() + "/earth.html");
#endif
// Parse for model links
......@@ -99,43 +100,60 @@ void QGCGoogleEarthView::follow(bool follow)
followCamera = follow;
}
void QGCGoogleEarthView::hide()
void QGCGoogleEarthView::showEvent(QShowEvent* event)
{
updateTimer->stop();
QWidget::hide();
}
void QGCGoogleEarthView::show()
{
if (!webViewInitialized)
// React only to internal (pre-display)
// events
if (!event->spontaneous())
{
if (event->type() == QEvent::Hide)
{
// Disable widget
updateTimer->stop();
}
else if (event->type() == QEvent::Show)
{
// Enable widget, initialize on first run
if (!webViewInitialized)
{
#if (defined Q_OS_MAC)
webViewMac->setPage(new QGCWebPage(webViewMac));
webViewMac->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
webViewMac->load(QUrl("earth.html"));
webViewMac->setPage(new QGCWebPage(webViewMac));
webViewMac->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
webViewMac->load(QUrl("earth.html"));
#endif
#ifdef _MSC_VER
webViewWin->dynamicCall("GoHome()");
webViewWin->dynamicCall("Navigate(const QString&)", "http://pixhawk.ethz.ch");
webViewWin->dynamicCall("GoHome()");
webViewWin->dynamicCall("Navigate(const QString&)", "http://pixhawk.ethz.ch");
#endif
webViewInitialized = true;
webViewInitialized = true;
}
}
updateTimer->start();
}
updateTimer->start();
QWidget::show();
}
void QGCGoogleEarthView::updateState()
{
#ifdef Q_OS_MAC
if (isVisible())
{
#ifdef Q_OS_MAC
if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool())
{
#endif
#ifdef _MSC_VER
// if (webViewMacWin->dynamicCall("Navigate(const QString&)","isInitialized();").toBool())
// {
#endif
static bool initialized = false;
if (!initialized)
{
#ifdef Q_OS_MAC
webViewMac->page()->currentFrame()->evaluateJavaScript("setGCSHome(22.679833,8.549444, 470);");
#endif
#ifdef _MSC_VER
//webViewMac->page()->currentFrame()->evaluateJavaScript("setGCSHome(22.679833,8.549444, 470);");
#endif
initialized = true;
}
int uasId = 0;
......@@ -157,6 +175,7 @@ void QGCGoogleEarthView::updateState()
pitch = mav->getPitch();
yaw = mav->getYaw();
}
#ifdef Q_OS_MAC
webViewMac->page()->currentFrame()->evaluateJavaScript(QString("setAircraftPositionAttitude(%1, %2, %3, %4, %6, %7, %8);")
.arg(uasId)
.arg(lat)
......@@ -165,14 +184,23 @@ void QGCGoogleEarthView::updateState()
.arg(roll)
.arg(pitch)
.arg(yaw));
#endif
#ifdef _MSC_VER
#endif
if (followCamera)
{
#ifdef Q_OS_MAC
webViewMac->page()->currentFrame()->evaluateJavaScript(QString("updateFollowAircraft()"));
#endif
#ifdef _MSC_VER
#endif
}
#if (defined Q_OS_MAC) || (defined _MSC_VER)
}
}
#endif
}
}
......
......@@ -62,10 +62,6 @@ public slots:
void showWaypoints(bool state);
/** @brief Follow the aircraft during flight */
void follow(bool follow);
/** @brief Hide and deactivate */
void hide();
/** @brief Show and activate */
void show();
protected:
void changeEvent(QEvent *e);
......@@ -82,6 +78,9 @@ protected:
QWebView* webViewMac;
#endif
/** @brief Enable / disable widget updating */
void showEvent(QShowEvent* event);
private:
#ifdef _MSC_VER
Ui::QGCGoogleEarthView* ui;
......
#include "QGCUnconnectedInfoWidget.h"
#include "LinkInterface.h"
#include "LinkManager.h"
#include "MAVLinkSimulationLink.h"
#include "MainWindow.h"
#include "ui_QGCUnconnectedInfoWidget.h"
QGCUnconnectedInfoWidget::QGCUnconnectedInfoWidget(QWidget *parent) :
......@@ -7,11 +11,36 @@ QGCUnconnectedInfoWidget::QGCUnconnectedInfoWidget(QWidget *parent) :
{
ui->setupUi(this);
connect(ui->simulationButton, SIGNAL(clicked()), this, SIGNAL(simulation()));
connect(ui->connectButton, SIGNAL(clicked()), this, SIGNAL(addLink()));
connect(ui->simulationButton, SIGNAL(clicked()), this, SLOT(simulate()));
connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(addLink()));
}
QGCUnconnectedInfoWidget::~QGCUnconnectedInfoWidget()
{
delete ui;
}
/**
* @brief Starts the system simulation
*/
void QGCUnconnectedInfoWidget::simulate()
{
// Try to get reference to MAVLinkSimulationlink
QList<LinkInterface*> links = LinkManager::instance()->getLinks();
foreach(LinkInterface* link, links)
{
MAVLinkSimulationLink* sim = dynamic_cast<MAVLinkSimulationLink*>(link);
if (sim)
{
sim->connectLink();
}
}
}
/**
* @return Opens a "Connect new Link" popup
*/
void QGCUnconnectedInfoWidget::addLink()
{
MainWindow::instance()->addLink();
}
......@@ -7,6 +7,16 @@ namespace Ui {
class QGCUnconnectedInfoWidget;
}
/**
* @brief Widget providing initial instructions
*
* This widget provides initial instructions to new users how
* to connect a simulation or a live link to a system to
* QGroundControl. The widget should be automatically be
* unloaded and destroyed once the first MAV/UAS is connected.
*
* @see UASListWidget
*/
class QGCUnconnectedInfoWidget : public QWidget
{
Q_OBJECT
......@@ -17,8 +27,10 @@ public:
Ui::QGCUnconnectedInfoWidget *ui;
signals:
void simulation();
public slots:
/** @brief Start simulation */
void simulate();
/** @brief Add a link */
void addLink();
};
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCUnconnectedInfoWidget</class>
<widget class="QWidget" name="QGCUnconnectedInfoWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="3">
<widget class="QTextEdit" name="textEdit">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="autoFormatting">
<set>QTextEdit::AutoAll</set>
</property>
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;table border=&quot;0&quot; style=&quot;-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;&quot;&gt;
&lt;tr&gt;
&lt;td style=&quot;border: none;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:14pt; font-weight:600;&quot;&gt;Unmanned System List&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:6pt; font-weight:600;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt; font-weight:600;&quot;&gt;No Systems are connected yet.&lt;/span&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt; Please either connect a link or use the simulation function to see QGroundControl in action.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt; font-style:italic;&quot;&gt;Click on the simulation button below to simulate a micro air vehicle or on the connect link button to connect a serial port link. A UDP link is already open for connections.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="simulationButton">
<property name="text">
<string>Simulate MAV</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="connectButton">
<property name="text">
<string>Connect Link</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCUnconnectedInfoWidget</class>
<widget class="QWidget" name="QGCUnconnectedInfoWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="3">
<widget class="QTextEdit" name="textEdit">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="autoFormatting">
<set>QTextEdit::AutoAll</set>
</property>
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;table border=&quot;0&quot; style=&quot;-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;&quot;&gt;
&lt;tr&gt;
&lt;td style=&quot;border: none;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:12pt; font-weight:600;&quot;&gt;Unmanned System List&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:6pt; font-weight:600;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:9pt; font-weight:600;&quot;&gt;No Systems are connected yet.&lt;/span&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:9pt;&quot;&gt; Please either connect a link or use the simulation function to see QGroundControl in action.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:9pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:9pt; font-style:italic;&quot;&gt;Click on the simulation button below to simulate a micro air vehicle or on the connect link button to connect a serial port link. A UDP link is already open for connections on port &lt;/span&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:9pt; font-weight:600; font-style:italic;&quot;&gt;14550&lt;/span&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:9pt; font-style:italic;&quot;&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:9pt; font-style:italic;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:9pt; font-style:italic;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:10pt; font-weight:600;&quot;&gt;Communication Link Help:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:9pt; font-style:italic;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:9pt;&quot;&gt;If you encounter communication problems on your link (e.g. no MAV is shown in the list after connecting the link), please check if you receive data on the link using the communication console. Select &lt;/span&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:9pt; font-weight:600;&quot;&gt;Tools -&amp;gt; Communication Console&lt;/span&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:9pt;&quot;&gt; to enable it. The console should show incoming traffic and some used bandwidth (e.g. 1.43 kB/s on the indicator).&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="simulationButton">
<property name="text">
<string>Simulate MAV</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="connectButton">
<property name="text">
<string>Connect Link</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -57,9 +57,6 @@ UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent), m_ui(new Ui::UA
uWidget = new QGCUnconnectedInfoWidget(this);
listLayout->addWidget(uWidget);
connect(uWidget, SIGNAL(addLink()), this, SLOT(addLink()));
connect(uWidget, SIGNAL(simulation()), this, SLOT(simulate()));
this->setMinimumWidth(250);
uasViews = QMap<UASInterface*, UASView*>();
......@@ -84,25 +81,6 @@ void UASListWidget::changeEvent(QEvent *e)
}
}
void UASListWidget::addLink()
{
MainWindow::instance()->addLink();
}
void UASListWidget::simulate()
{
// Try to get reference to MAVLinkSimulationlink
QList<LinkInterface*> links = LinkManager::instance()->getLinks();
foreach(LinkInterface* link, links)
{
MAVLinkSimulationLink* sim = dynamic_cast<MAVLinkSimulationLink*>(link);
if (sim)
{
sim->connectLink();
}
}
}
void UASListWidget::addUAS(UASInterface* uas)
{
if (uasViews.isEmpty())
......
......@@ -52,10 +52,6 @@ public slots:
void activeUAS(UASInterface* uas);
void removeUAS(UASInterface* uas);
// TODO Kind of hack, works flawless but is bad architecture
void addLink();
void simulate();
protected:
QMap<UASInterface*, UASView*> uasViews;
QVBoxLayout* listLayout;
......
......@@ -173,14 +173,46 @@ void UASView::mouseDoubleClickEvent (QMouseEvent * event)
void UASView::enterEvent(QEvent* event)
{
if (event->MouseMove) emit uasInFocus(uas);
if (event->type() == QEvent::MouseMove)
{
emit uasInFocus(uas);
if (uas != UASManager::instance()->getActiveUAS())
{
grabMouse(QCursor(Qt::PointingHandCursor));
}
}
qDebug() << __FILE__ << __LINE__ << "IN FOCUS";
if (event->type() == QEvent::MouseButtonDblClick)
{
qDebug() << __FILE__ << __LINE__ << "UAS CLICKED!";
}
}
void UASView::leaveEvent(QEvent* event)
{
if (event->MouseMove) emit uasOutFocus(uas);
qDebug() << __FILE__ << __LINE__ << "OUT OF FOCUS";
if (event->type() == QEvent::MouseMove)
{
emit uasOutFocus(uas);
releaseMouse();
}
}
void UASView::showEvent(QShowEvent* event)
{
// React only to internal (pre-display)
// events
if (!event->spontaneous())
{
if (event->type() == QEvent::Hide)
{
refreshTimer->stop();
}
else if (event->type() == QEvent::Show)
{
refreshTimer->start(updateInterval);
}
}
}
void UASView::receiveHeartbeat(UASInterface* uas)
......
......@@ -107,6 +107,8 @@ protected:
void enterEvent(QEvent* event);
/** @brief Mouse leaves the widget */
void leaveEvent(QEvent* event);
/** @brief Enable / disable widget updating */
void showEvent(QShowEvent* event);
private:
Ui::UASView *m_ui;
......
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