From 3bcbbc769782ddb5b5fed3bc13f3b60b7b302ec1 Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Mon, 27 Oct 2014 06:04:12 -0400 Subject: [PATCH] Display test signal --- DestinationGLCanvas.cpp | 28 +++++++++++++++++++++++++++- DestinationGLCanvas.h | 1 + MainWindow.cpp | 23 +++++++++++++++++++++++ MainWindow.h | 1 + MapperGLCanvas.cpp | 6 ++++++ MapperGLCanvas.h | 7 +++++++ 6 files changed, 65 insertions(+), 1 deletion(-) diff --git a/DestinationGLCanvas.cpp b/DestinationGLCanvas.cpp index 1116d5f..a3dc899 100644 --- a/DestinationGLCanvas.cpp +++ b/DestinationGLCanvas.cpp @@ -37,6 +37,14 @@ Shape* DestinationGLCanvas::getShapeFromMappingId(uid mappingId) void DestinationGLCanvas::doDraw(QPainter* painter) { + if (this->displayTestSignal()) + { + glPushMatrix(); + this->_drawTestSignal(painter); + glPopMatrix(); + return; + } + glPushMatrix(); // Draw the mappings. @@ -61,7 +69,9 @@ void DestinationGLCanvas::doDraw(QPainter* painter) mapper->drawControls(painter, &selectedVertices); } else + { mapper->drawControls(painter); + } painter->restore(); } @@ -79,6 +89,22 @@ void DestinationGLCanvas::doDraw(QPainter* painter) painter->drawLine(0, cursorPosition.y(), geo.width(), cursorPosition.y()); } } - +} + +void DestinationGLCanvas::_drawTestSignal(QPainter* painter) +{ + const QRect& geo = geometry(); + painter->setPen(MM::CONTROL_COLOR); + int height = geo.height(); + int width = geo.width(); + + for (int x = 0; x < width; x += 10) + { + painter->drawLine(x, 0, x, height); + } + for (int y = 0; y < height; y += 10) + { + painter->drawLine(0, y, width, y); + } } diff --git a/DestinationGLCanvas.h b/DestinationGLCanvas.h index bbd5d45..2a9ab08 100644 --- a/DestinationGLCanvas.h +++ b/DestinationGLCanvas.h @@ -42,6 +42,7 @@ public: private: virtual void doDraw(QPainter* painter); + void _drawTestSignal(QPainter* painter); bool _displayCrosshair; }; diff --git a/MainWindow.cpp b/MainWindow.cpp index de0d506..a4d73d6 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -1274,6 +1274,19 @@ void MainWindow::createActions() connect(stickyVertices, SIGNAL(toggled(bool)), sourceCanvas, SLOT(enableStickyVertices(bool))); connect(stickyVertices, SIGNAL(toggled(bool)), destinationCanvas, SLOT(enableStickyVertices(bool))); connect(stickyVertices, SIGNAL(toggled(bool)), outputWindow->getCanvas(), SLOT(enableStickyVertices(bool))); + + + displayTestSignal = new QAction(tr("&Display test signal"), this); + // displayTestSignal->setShortcut(tr("Ctrl+T")); + displayTestSignal->setIcon(QIcon(":/control-points")); + displayTestSignal->setStatusTip(tr("Display test signal")); + displayTestSignal->setIconVisibleInMenu(false); + displayTestSignal->setCheckable(true); + displayTestSignal->setChecked(false); + // Manage show/hide of test signal + connect(displayTestSignal, SIGNAL(toggled(bool)), sourceCanvas, SLOT(enableTestSignal(bool))); + connect(displayTestSignal, SIGNAL(toggled(bool)), destinationCanvas, SLOT(enableTestSignal(bool))); + connect(displayTestSignal, SIGNAL(toggled(bool)), outputWindow->getCanvas(), SLOT(enableTestSignal(bool))); } void MainWindow::startFullScreen() @@ -1338,6 +1351,7 @@ void MainWindow::createMenus() viewMenu->addAction(outputWindowFullScreen); viewMenu->addAction(displayCanvasControls); viewMenu->addAction(stickyVertices); + viewMenu->addAction(displayTestSignal); //viewMenu->addAction(outputWindowHasCursor); // Run. @@ -1401,6 +1415,7 @@ void MainWindow::createToolBars() mainToolBar->addAction(outputWindowFullScreen); mainToolBar->addAction(displayCanvasControls); mainToolBar->addAction(stickyVertices); + mainToolBar->addAction(displayTestSignal); runToolBar = addToolBar(tr("&Run")); runToolBar->setIconSize(QSize(MM::TOP_TOOLBAR_ICON_SIZE, MM::TOP_TOOLBAR_ICON_SIZE)); @@ -1448,6 +1463,8 @@ void MainWindow::createStatusBar() void MainWindow::readSettings() { + // FIXME: for each setting that is new since the first release in the major version number branch, + // make sure it exists before reading its value. QSettings settings("MapMap", "MapMap"); restoreGeometry(settings.value("geometry").toByteArray()); @@ -1458,6 +1475,11 @@ void MainWindow::readSettings() outputWindow->restoreGeometry(settings.value("outputWindow").toByteArray()); displayOutputWindow->setChecked(settings.value("displayOutputWindow").toBool()); outputWindowFullScreen->setChecked(settings.value("outputWindowFullScreen").toBool()); + if (settings.contains("displayTestSignal")) + { + displayOutputWindow->setChecked(settings.value("displayTestSignal").toBool()); + } + displayOutputWindow->setChecked(settings.value("displayOutputWindow").toBool()); config_osc_receive_port = 12345; // settings.value("osc_receive_port", 12345).toInt(); updateRecentFileActions(); updateRecentVideoActions(); @@ -1475,6 +1497,7 @@ void MainWindow::writeSettings() settings.setValue("outputWindow", outputWindow->saveGeometry()); settings.setValue("displayOutputWindow", displayOutputWindow->isChecked()); settings.setValue("outputWindowFullScreen", outputWindowFullScreen->isChecked()); + settings.setValue("displayTestSignal", displayTestSignal->isChecked()); settings.setValue("osc_receive_port", config_osc_receive_port); } diff --git a/MainWindow.h b/MainWindow.h index 6acbb52..f4d6cdb 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -278,6 +278,7 @@ private: //QAction *outputWindowHasCursor; QAction *outputWindowFullScreen; QAction *displayCanvasControls; + QAction *displayTestSignal; QAction *stickyVertices; enum { MaxRecentFiles = 10 }; diff --git a/MapperGLCanvas.cpp b/MapperGLCanvas.cpp index e9d7d84..07cc201 100644 --- a/MapperGLCanvas.cpp +++ b/MapperGLCanvas.cpp @@ -343,6 +343,12 @@ void MapperGLCanvas::enableDisplayControls(bool display) updateCanvas(); } +void MapperGLCanvas::enableTestSignal(bool enable) +{ + _displayTestSignal = enable; + updateCanvas(); +} + void MapperGLCanvas::enableStickyVertices(bool value) { _stickyVertices = value; diff --git a/MapperGLCanvas.h b/MapperGLCanvas.h index a1a1704..d13a219 100644 --- a/MapperGLCanvas.h +++ b/MapperGLCanvas.h @@ -67,6 +67,9 @@ public: /// Returns true iff we should display the controls. bool displayControls() const { return _displayControls; } + /// Returns true iff we should display the test signal + bool displayTestSignal() const { return _displayTestSignal; } + /// Returns true iff we want vertices to stick to each other. bool stickyVertices() const { return _stickyVertices; } @@ -129,6 +132,9 @@ private: // True iff we are displaying the controls. bool _displayControls; + // True iff we are displaying the test signal (grid) + bool _displayTestSignal; + // True iff we want vertices to stick to each other. bool _stickyVertices; @@ -140,6 +146,7 @@ public slots: void updateCanvas(); void enableDisplayControls(bool display); void enableStickyVertices(bool display); + void enableTestSignal(bool enable); void deselectVertices(); void deselectAll();