From 42cb2ed6d6ebece84cf0b88a04af011a465fc192 Mon Sep 17 00:00:00 2001 From: baydam Date: Mon, 31 Oct 2016 17:03:34 +0000 Subject: [PATCH] Test cards pattern improvements --- OutputGLCanvas.cpp | 56 +- OutputGLCanvas.h | 5 +- interface.qrc | 2 + .../images/logo/mapmap-wide-with-border.svg | 133 + .../images/test-signal/ntsc-test-signal.svg | 183 ++ .../images/test-signal/pal-test-signal.svg | 2161 +++++++++-------- 6 files changed, 1443 insertions(+), 1097 deletions(-) create mode 100644 resources/images/logo/mapmap-wide-with-border.svg create mode 100644 resources/images/test-signal/ntsc-test-signal.svg diff --git a/OutputGLCanvas.cpp b/OutputGLCanvas.cpp index 5c61d4f..cac87b5 100644 --- a/OutputGLCanvas.cpp +++ b/OutputGLCanvas.cpp @@ -27,10 +27,7 @@ MM_BEGIN_NAMESPACE OutputGLCanvas::OutputGLCanvas(MainWindow* mainWindow, QWidget* parent, const QGLWidget* shareWidget, QGraphicsScene* scene) : MapperGLCanvas(mainWindow, true, parent, shareWidget, scene), _displayCrosshair(false), - _displayTestSignal(false), - _svg_test_signal(":/test-signal"), - _brush_test_signal(_svg_test_signal), - _palTestCard(":/pal-test-card") + _displayTestSignal(false) { // Disable scrollbars. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -53,10 +50,11 @@ void OutputGLCanvas::drawForeground(QPainter *painter , const QRectF &rect) int testCard = settings.value("signalTestCard", MM::DEFAULT_TEST_CARD).toInt(); glPushMatrix(); painter->translate(rect.x(), rect.y()); + painter->setRenderHint(QPainter::Antialiasing); painter->save(); switch (testCard) { case MM::Classic: - _drawTestSignal(painter); + _drawClassicTestSignal(painter); break; case MM::PAL: _drawPALTestCard(painter); @@ -109,7 +107,7 @@ void OutputGLCanvas::drawForeground(QPainter *painter , const QRectF &rect) } -void OutputGLCanvas::_drawTestSignal(QPainter* painter) +void OutputGLCanvas::_drawClassicTestSignal(QPainter* painter) { const QRect& geo = geometry(); int width = geo.width(); @@ -136,12 +134,12 @@ void OutputGLCanvas::_drawTestSignal(QPainter* painter) } // Create responsive image - QImage image = _svg_test_signal.scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation); - int imageX = (width - image.width()) / 2; - int imageY = (height - image.height()) / 2; + _classicTestCard = QImage(":/test-signal").scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation); + int imageX = (width - _classicTestCard.width()) / 2; + int imageY = (height - _classicTestCard.height()) / 2; // Draw the image. - painter->drawImage(imageX, imageY, image); + painter->drawImage(imageX, imageY, _classicTestCard); } void OutputGLCanvas::_drawPALTestCard(QPainter* painter) @@ -179,17 +177,17 @@ void OutputGLCanvas::_drawPALTestCard(QPainter* painter) } // Create responsive image - QImage image = _palTestCard.scaled(height - (rectSize * 2), height - (rectSize * 2), + _palTestCard = QImage(":/pal-test-card").scaled(height - (rectSize * 2), height - (rectSize * 2), Qt::KeepAspectRatio, Qt::SmoothTransformation); // Draw image - int imageX = (width - image.width()) / 2; - int imageY = (height - image.height()) / 2; - int imageWidth = image.width(); - int imageHeight = image.height(); - painter->drawImage(imageX, imageY, image); + int imageX = (width - _palTestCard.width()) / 2; + int imageY = (height - _palTestCard.height()) / 2; + int imageHeight = _palTestCard.height(); + painter->drawImage(imageX, imageY, _palTestCard); + // Draw text for screen resolution - int fontSize = imageHeight / 20; - QRect textRect((width / 2) - (fontSize * 3), imageY + (imageHeight / 13), fontSize * 6, fontSize); + int fontSize = imageHeight / 18; + QRect textRect((width / 2) - (fontSize * 3), imageY + (imageHeight / 19), fontSize * 6, fontSize); _drawResolutionText(painter, textRect, fontSize); } @@ -198,24 +196,19 @@ void OutputGLCanvas::_drawNTSCTestCard(QPainter* painter) const QRect& geo = geometry(); int width = geo.width(); int height = geo.height(); - QList colors = { - Qt::white, Qt::yellow, Qt::cyan, Qt::green, - Qt::magenta, Qt::red, Qt::blue, Qt::black - }; - const int bandWidth = width / colors.size(); + // Create image + _ntscTestCard = QImage(":/ntsc-test-card").scaled(width, height); - painter->setPen(Qt::NoPen); + // Draw backgroung image + painter->drawImage(geo.x(), geo.y(), _ntscTestCard); + // Draw logo + QImage mapmapLogo = QImage(":/mapmap-logo-with-border").scaled(width, height / 15, Qt::KeepAspectRatio, Qt::SmoothTransformation); + painter->drawImage((width - mapmapLogo.width()) / 2, height / 4, mapmapLogo); - // Draw checkerboard pattern. - for (int x = 0; x < width / bandWidth; x++) - { - painter->setBrush(colors.at(x)); - painter->drawRect(x * bandWidth, 0, bandWidth, height); - } // Draw text for screen resolution - int fontSize = height / 30; + int fontSize = height / 21; QRect textRect((width / 2) - (fontSize * 3), height / 3, fontSize * 6, fontSize); _drawResolutionText(painter, textRect, fontSize); } @@ -229,6 +222,7 @@ void OutputGLCanvas::_drawResolutionText(QPainter *painter, const QRect &rect, i painter->fillRect(rect, Qt::black); QFont font = painter->font(); font.setPixelSize(fontSize); + font.setBold(true); painter->setFont(font); painter->setPen(Qt::white); painter->drawText(rect, Qt::AlignCenter, diff --git a/OutputGLCanvas.h b/OutputGLCanvas.h index 9c54b61..a912ac9 100644 --- a/OutputGLCanvas.h +++ b/OutputGLCanvas.h @@ -50,7 +50,7 @@ public: } private: - void _drawTestSignal(QPainter* painter); + void _drawClassicTestSignal(QPainter* painter); void _drawPALTestCard(QPainter *painter); void _drawNTSCTestCard(QPainter *painter); @@ -58,9 +58,10 @@ private: bool _displayCrosshair; bool _displayTestSignal; - QImage _svg_test_signal; + QImage _classicTestCard; QBrush _brush_test_signal; QImage _palTestCard; + QImage _ntscTestCard; protected: // overriden from QGlWidget: diff --git a/interface.qrc b/interface.qrc index bce1d62..14b0238 100644 --- a/interface.qrc +++ b/interface.qrc @@ -44,5 +44,7 @@ resources/images/test-signal/examples/pal-test-card.png resources/images/test-signal/examples/ntsc-test-card.png resources/images/checkbox/checkbox-unchecked.png + resources/images/test-signal/ntsc-test-signal.svg + resources/images/logo/mapmap-wide-with-border.svg diff --git a/resources/images/logo/mapmap-wide-with-border.svg b/resources/images/logo/mapmap-wide-with-border.svg new file mode 100644 index 0000000..76f9af9 --- /dev/null +++ b/resources/images/logo/mapmap-wide-with-border.svg @@ -0,0 +1,133 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/test-signal/ntsc-test-signal.svg b/resources/images/test-signal/ntsc-test-signal.svg new file mode 100644 index 0000000..a76a1bd --- /dev/null +++ b/resources/images/test-signal/ntsc-test-signal.svg @@ -0,0 +1,183 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/test-signal/pal-test-signal.svg b/resources/images/test-signal/pal-test-signal.svg index 4d2b549..acdfac5 100644 --- a/resources/images/test-signal/pal-test-signal.svg +++ b/resources/images/test-signal/pal-test-signal.svg @@ -23,8 +23,633 @@ sodipodi:docname="pal-test-signal.svg">image/svg+xml \ No newline at end of file + inkscape:current-layer="layer3" /> \ No newline at end of file