LED framebuffer connected to GUI

This commit is contained in:
Ollo 2023-08-15 00:09:29 +02:00
parent 488a8ed5dd
commit 980ef0812f
3 changed files with 66 additions and 2 deletions

View File

@ -1,12 +1,21 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPainter>
#include <QPixmap>
#include <QGraphicsPixmapItem>
#include <QGraphicsView>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->server = new UdpLedServer ();
this->mOffscreenDiagram = new QImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, QImage::Format_RGB32);
this->mOffscreenDiagram->fill(COLOR_BACKGROUND);
}
MainWindow::~MainWindow()
@ -14,3 +23,14 @@ MainWindow::~MainWindow()
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);
}

View File

@ -2,8 +2,24 @@
#define MAINWINDOW_H
#include <QMainWindow>
#include <QImage>
#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
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
@ -19,5 +35,7 @@ public:
private:
Ui::MainWindow *ui;
UdpLedServer *server;
QImage *mOffscreenDiagram;
void drawImage(QImage *image);
};
#endif // MAINWINDOW_H

View File

@ -13,8 +13,34 @@
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar"/>
<widget class="QWidget" name="centralwidget">
<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>
<resources/>