From c15368b35e2d6b3a2779d5ed2db6da8cef28b6bc Mon Sep 17 00:00:00 2001 From: Ollo Date: Tue, 15 Aug 2023 12:51:35 +0200 Subject: [PATCH] LEDs are drawn --- simulation/VirtualLedBoard/mainwindow.cpp | 16 ++++++++++++++-- simulation/VirtualLedBoard/mainwindow.h | 8 ++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/simulation/VirtualLedBoard/mainwindow.cpp b/simulation/VirtualLedBoard/mainwindow.cpp index e31bdca..184d8f0 100644 --- a/simulation/VirtualLedBoard/mainwindow.cpp +++ b/simulation/VirtualLedBoard/mainwindow.cpp @@ -13,9 +13,21 @@ MainWindow::MainWindow(QWidget *parent) ui->setupUi(this); this->server = new UdpLedServer (); - this->mOffscreenDiagram = new QImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, QImage::Format_RGB32); - this->mOffscreenDiagram->fill(COLOR_BACKGROUND); + this->mOffscreenPanel = new QImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, QImage::Format_RGB32); + this->mOffscreenPanel->fill(COLOR_BACKGROUND); + /* draw inital screen */ + QPainter painter(this->mOffscreenPanel); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(QPen(COLOR_FOREGROUND, 1)); + painter.setBrush(COLOR_FOREGROUND); + for(int x=0; x < (PANEL_WIDTH * MAXIMUM_PANELSIZE); x++) { + for(int y=0; y < PANEL_HEIGHT; y++) { + painter.drawEllipse(LED_DIAMETER/2 + (x* LED_DISTANCE), LED_DIAMETER/2 + (y * LED_DISTANCE), LED_DIAMETER, LED_DIAMETER); + } + } + + this->drawImage(this->mOffscreenPanel); } MainWindow::~MainWindow() diff --git a/simulation/VirtualLedBoard/mainwindow.h b/simulation/VirtualLedBoard/mainwindow.h index b0ad118..eec930b 100644 --- a/simulation/VirtualLedBoard/mainwindow.h +++ b/simulation/VirtualLedBoard/mainwindow.h @@ -10,15 +10,15 @@ #define PANEL_WIDTH 32 #define PANEL_HEIGHT 40 -#define LED_DIAMETER 5 -#define LED_DISTANCE (LED_DIAMETER + 2) +#define LED_DIAMETER 8 +#define LED_DISTANCE (LED_DIAMETER + 3) #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 +#define COLOR_FOREGROUND QColor(255, 127, 0, 255) QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } @@ -35,7 +35,7 @@ public: private: Ui::MainWindow *ui; UdpLedServer *server; - QImage *mOffscreenDiagram; + QImage *mOffscreenPanel; void drawImage(QImage *image); }; #endif // MAINWINDOW_H