diff --git a/images/patterns/lenna.jpg b/images/patterns/lenna.jpg
new file mode 100644
index 0000000..6355eca
Binary files /dev/null and b/images/patterns/lenna.jpg differ
diff --git a/mavground.qrc b/mavground.qrc
index 4a1d721..524119c 100644
--- a/mavground.qrc
+++ b/mavground.qrc
@@ -86,6 +86,7 @@
images/mapproviders/googleearth.svg
images/contrib/slugs.png
images/style-outdoor.css
+ images/patterns/lenna.jpg
images/Vera.ttf
diff --git a/qgcvideo.pro b/qgcvideo.pro
index 8e289ef..01c66cc 100644
--- a/qgcvideo.pro
+++ b/qgcvideo.pro
@@ -7,15 +7,11 @@ TEMPLATE = app
TARGET = qgcvideo
BASEDIR = .
-BUILDDIR = build/qgcvideo
+
LANGUAGE = C++
-CONFIG += release
-CONFIG -= debug
-OBJECTS_DIR = $$BUILDDIR/obj
-MOC_DIR = $$BUILDDIR/moc
-UI_HEADERS_DIR = src/ui/generated
+
macx:DESTDIR = $$BASEDIR/bin/mac
@@ -29,11 +25,18 @@ INCLUDEPATH += . \
# Input
HEADERS += \
+ src/comm/UDPLink.h \
+ src/comm/LinkInterface.h \
+ src/comm/LinkManager.h \
+ src/QGC.h \
src/apps/qgcvideo/QGCVideoMainWindow.h \
src/apps/qgcvideo/QGCVideoApp.h \
src/apps/qgcvideo/QGCVideoWidget.h
SOURCES += \
+ src/comm/UDPLink.cc \
+ src/comm/LinkManager.cc \
+ src/QGC.cc \
src/apps/qgcvideo/main.cc \
src/apps/qgcvideo/QGCVideoMainWindow.cc \
src/apps/qgcvideo/QGCVideoApp.cc \
diff --git a/src/apps/qgcvideo/QGCVideoApp.cc b/src/apps/qgcvideo/QGCVideoApp.cc
index e8c7716..6695e48 100644
--- a/src/apps/qgcvideo/QGCVideoApp.cc
+++ b/src/apps/qgcvideo/QGCVideoApp.cc
@@ -44,6 +44,8 @@
#include
#include "QGCVideoApp.h"
+#include "QGCVideoMainWindow.h"
+#include "UDPLink.h"
/**
@@ -76,7 +78,7 @@ QGCVideoApp::QGCVideoApp(int &argc, char* argv[]) : QApplication(argc, argv)
setFont(fontDatabase.font(fontFamilyName, "Roman", 12));
// Create main window
- QMainWindow* window = new QMainWindow();
+ QMainWindow* window = new QGCVideoMainWindow();
//window->setCentralWidget(new XMLCommProtocolWidget(window));
window->setWindowTitle(applicationName() + " " + applicationVersion());
window->show();
diff --git a/src/apps/qgcvideo/QGCVideoMainWindow.cc b/src/apps/qgcvideo/QGCVideoMainWindow.cc
index 6d25d65..2a1d662 100644
--- a/src/apps/qgcvideo/QGCVideoMainWindow.cc
+++ b/src/apps/qgcvideo/QGCVideoMainWindow.cc
@@ -32,14 +32,67 @@
#include "QGCVideoMainWindow.h"
#include "ui_QGCVideoMainWindow.h"
+#include "UDPLink.h"
+#include
+
QGCVideoMainWindow::QGCVideoMainWindow(QWidget *parent) :
QMainWindow(parent),
+ link(QHostAddress::Any, 5555),
ui(new Ui::QGCVideoMainWindow)
{
ui->setupUi(this);
+
+ // Set widgets in video mode
+ ui->video1Widget->enableVideo(true);
+ ui->video2Widget->enableVideo(true);
+ ui->video3Widget->enableVideo(true);
+ ui->video4Widget->enableVideo(true);
+
+ // Connect link to this widget, receive all bytes
+ connect(&link, SIGNAL(bytesReceived(LinkInterface*,QByteArray)), this, SLOT(receiveBytes(LinkInterface*,QByteArray)));
+
+ // Open port
+ link.connect();
}
QGCVideoMainWindow::~QGCVideoMainWindow()
{
delete ui;
}
+
+void QGCVideoMainWindow::receiveBytes(LinkInterface* link, QByteArray data)
+{
+ // There is no need to differentiate between links
+ // for this use case here
+ Q_UNUSED(link);
+
+ // Image data is stored in QByteArray
+ // Output bytes and load Lenna!
+
+ QString bytes;
+ QString ascii;
+ for (int i=0; i 31 && data.at(i) < 127)
+ {
+ ascii.append(data.at(i));
+ }
+ else
+ {
+ ascii.append(219);
+ }
+ }
+ qDebug() << "Received" << data.size() << "bytes";
+ qDebug() << bytes;
+ qDebug() << "ASCII:" << ascii;
+
+
+ // Load image into window
+ QImage test(":images/patterns/lenna.jpg");
+
+ ui->video1Widget->copyImage(test);
+ ui->video2Widget->copyImage(test);
+ ui->video3Widget->copyImage(test);
+ ui->video4Widget->copyImage(test);
+}
diff --git a/src/apps/qgcvideo/QGCVideoMainWindow.h b/src/apps/qgcvideo/QGCVideoMainWindow.h
index 150bf3f..428da2a 100644
--- a/src/apps/qgcvideo/QGCVideoMainWindow.h
+++ b/src/apps/qgcvideo/QGCVideoMainWindow.h
@@ -33,6 +33,7 @@
#define QGCVIDEOMAINWINDOW_H
#include
+#include "UDPLink.h"
namespace Ui {
class QGCVideoMainWindow;
@@ -46,6 +47,12 @@ public:
explicit QGCVideoMainWindow(QWidget *parent = 0);
~QGCVideoMainWindow();
+public slots:
+ void receiveBytes(LinkInterface* link, QByteArray data);
+
+protected:
+ UDPLink link;
+
private:
Ui::QGCVideoMainWindow *ui;
};
diff --git a/src/apps/qgcvideo/QGCVideoWidget.cc b/src/apps/qgcvideo/QGCVideoWidget.cc
index 1ec9cbc..e7b5f56 100644
--- a/src/apps/qgcvideo/QGCVideoWidget.cc
+++ b/src/apps/qgcvideo/QGCVideoWidget.cc
@@ -160,7 +160,7 @@ QGCVideoWidget::QGCVideoWidget(QWidget* parent)
// Refresh timer
refreshTimer->setInterval(updateInterval);
- connect(refreshTimer, SIGNAL(timeout()), this, SLOT(paintQGCVideoWidget()));
+ connect(refreshTimer, SIGNAL(timeout()), this, SLOT(paintHUD()));
// Resize to correct size and fill with image
//glDrawPixels(glImage.width(), glImage.height(), GL_RGBA, GL_UNSIGNED_BYTE, glImage.bits());
@@ -201,16 +201,12 @@ QSize QGCVideoWidget::sizeHint() const
void QGCVideoWidget::showEvent(QShowEvent* event)
{
- // React only to internal (pre-display)
- // events
Q_UNUSED(event)
refreshTimer->start(updateInterval);
}
void QGCVideoWidget::hideEvent(QHideEvent* event)
{
- // React only to internal (pre-display)
- // events
Q_UNUSED(event);
refreshTimer->stop();
}
@@ -220,20 +216,20 @@ void QGCVideoWidget::contextMenuEvent (QContextMenuEvent* event)
QMenu menu(this);
// Update actions
enableHUDAction->setChecked(hudInstrumentsEnabled);
- enableVideoAction->setChecked(videoEnabled);
+// enableVideoAction->setChecked(videoEnabled);
menu.addAction(enableHUDAction);
//menu.addAction(selectQGCVideoWidgetColorAction);
- menu.addAction(enableVideoAction);
- menu.addAction(selectOfflineDirectoryAction);
+// menu.addAction(enableVideoAction);
+// menu.addAction(selectOfflineDirectoryAction);
//menu.addAction(selectVideoChannelAction);
menu.exec(event->globalPos());
}
void QGCVideoWidget::createActions()
{
- enableHUDAction = new QAction(tr("Enable QGCVideoWidget"), this);
- enableHUDAction->setStatusTip(tr("Show the QGCVideoWidget instruments in this window"));
+ enableHUDAction = new QAction(tr("Enable HUD"), this);
+ enableHUDAction->setStatusTip(tr("Show the HUD instruments in this window"));
enableHUDAction->setCheckable(true);
enableHUDAction->setChecked(hudInstrumentsEnabled);
connect(enableHUDAction, SIGNAL(triggered(bool)), this, SLOT(enableHUDInstruments(bool)));
@@ -242,11 +238,11 @@ void QGCVideoWidget::createActions()
enableVideoAction->setStatusTip(tr("Show the video live feed"));
enableVideoAction->setCheckable(true);
enableVideoAction->setChecked(videoEnabled);
- connect(enableVideoAction, SIGNAL(triggered(bool)), this, SLOT(enableVideo(bool)));
+// connect(enableVideoAction, SIGNAL(triggered(bool)), this, SLOT(enableVideo(bool)));
selectOfflineDirectoryAction = new QAction(tr("Select image log"), this);
selectOfflineDirectoryAction->setStatusTip(tr("Load previously logged images into simulation / replay"));
- connect(selectOfflineDirectoryAction, SIGNAL(triggered()), this, SLOT(selectOfflineDirectory()));
+// connect(selectOfflineDirectoryAction, SIGNAL(triggered()), this, SLOT(selectOfflineDirectory()));
}
/**
diff --git a/src/apps/qgcvideo/QGCVideoWidget.h b/src/apps/qgcvideo/QGCVideoWidget.h
index d88a645..ec27bb5 100644
--- a/src/apps/qgcvideo/QGCVideoWidget.h
+++ b/src/apps/qgcvideo/QGCVideoWidget.h
@@ -30,6 +30,7 @@ public slots:
/** @brief Copy an image from an external buffer */
void copyImage(const QImage& img);
void enableHUDInstruments(bool enabled) { hudInstrumentsEnabled = enabled; }
+ void enableVideo(bool enabled) { videoEnabled = enabled; }
protected slots: