LED framebuffer connected to GUI
This commit is contained in:
parent
488a8ed5dd
commit
980ef0812f
@ -1,12 +1,21 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QGraphicsPixmapItem>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->server = new UdpLedServer ();
|
this->server = new UdpLedServer ();
|
||||||
|
|
||||||
|
this->mOffscreenDiagram = new QImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, QImage::Format_RGB32);
|
||||||
|
this->mOffscreenDiagram->fill(COLOR_BACKGROUND);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -14,3 +23,14 @@ MainWindow::~MainWindow()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::drawImage(QImage *target) {
|
||||||
|
QGraphicsView *graphicsView = new QGraphicsView();
|
||||||
|
graphicsView->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
|
||||||
|
QGraphicsScene* scene=new QGraphicsScene() ;
|
||||||
|
graphicsView->setScene(scene);
|
||||||
|
QGraphicsPixmapItem* item = new QGraphicsPixmapItem(QPixmap::fromImage(*(target)));
|
||||||
|
scene->addItem(item);
|
||||||
|
graphicsView->show();
|
||||||
|
this->ui->ledPanel->addWidget(graphicsView);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,24 @@
|
|||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QImage>
|
||||||
#include "udpserver.h"
|
#include "udpserver.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define MAXIMUM_PANELSIZE 5
|
||||||
|
#define PANEL_WIDTH 32
|
||||||
|
#define PANEL_HEIGHT 40
|
||||||
|
|
||||||
|
#define LED_DIAMETER 5
|
||||||
|
#define LED_DISTANCE (LED_DIAMETER + 2)
|
||||||
|
|
||||||
|
#define DEFAULT_WIDTH (LED_DISTANCE * MAXIMUM_PANELSIZE * PANEL_WIDTH)
|
||||||
|
#define DEFAULT_HEIGHT (LED_DISTANCE * PANEL_HEIGHT)
|
||||||
|
|
||||||
|
|
||||||
|
#define COLOR_BACKGROUND Qt::black
|
||||||
|
#define COLOR_FOREGROUND Qt::orange
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
@ -19,5 +35,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
UdpLedServer *server;
|
UdpLedServer *server;
|
||||||
|
QImage *mOffscreenDiagram;
|
||||||
|
void drawImage(QImage *image);
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -13,8 +13,34 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget"/>
|
<widget class="QWidget" name="centralwidget">
|
||||||
<widget class="QMenuBar" name="menubar"/>
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<widget class="QVBoxLayout" name="ledPanel">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>781</width>
|
||||||
|
<height>441</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenuBar" name="menubar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>800</width>
|
||||||
|
<height>22</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
Loading…
Reference in New Issue
Block a user