diff --git a/simulation/VirtualLedBoard/mainwindow.cpp b/simulation/VirtualLedBoard/mainwindow.cpp index 184d8f0..bc9a76f 100644 --- a/simulation/VirtualLedBoard/mainwindow.cpp +++ b/simulation/VirtualLedBoard/mainwindow.cpp @@ -13,20 +13,8 @@ MainWindow::MainWindow(QWidget *parent) ui->setupUi(this); this->server = new UdpLedServer (); - 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->mOffscreenPanel = new QImage(DEFAULT_WIDTH + LED_DISTANCE, DEFAULT_HEIGHT + LED_DISTANCE, QImage::Format_RGB32); + this->renderPanel(); this->drawImage(this->mOffscreenPanel); } @@ -46,3 +34,17 @@ void MainWindow::drawImage(QImage *target) { this->ui->ledPanel->addWidget(graphicsView); } +void MainWindow::renderPanel(void) { + 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); + } + } +} diff --git a/simulation/VirtualLedBoard/mainwindow.h b/simulation/VirtualLedBoard/mainwindow.h index eec930b..d96514a 100644 --- a/simulation/VirtualLedBoard/mainwindow.h +++ b/simulation/VirtualLedBoard/mainwindow.h @@ -37,5 +37,6 @@ private: UdpLedServer *server; QImage *mOffscreenPanel; void drawImage(QImage *image); + void renderPanel(void); }; #endif // MAINWINDOW_H