/***************************************************************************
* Copyright (C) 2010 by Simon Andreas Eugster (simon.eu@gmail.com) *
+ * This file is part of kdenlive. See www.kdenlive.org. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* (at your option) any later version. *
***************************************************************************/
-/**
-
- Vectorscope.
-
- The basis matrix for converting RGB to YUV is:
-
-mRgb2Yuv = r =
-
- 0.29900 0.58700 0.11400 1.00000
- -0.14741 -0.28939 0.43680 x 0.00000
- 0.61478 -0.51480 -0.09998 0.00000
-
- The resulting YUV value is then drawn on the circle
- using U and V as coordinate values.
-
- The maximum length of such an UV vector is reached
- for the colors Red and Cyan: 0.632.
- To make optimal use of space in the circle, this value
- can be used for scaling.
-
- As we are dealing with RGB values in a range of {0,...,255}
- and the conversion values are made for [0,1], we already
- divide the conversion values by 255 previously, e.g. in
- GNU octave.
- */
+#include <QAction>
#include <QColor>
+#include <QDebug>
#include <QMouseEvent>
+#include <QMenu>
#include <QPainter>
-#include <QDebug>
+#include <QTime>
+
+#include "colorplaneexport.h"
+#include "colortools.h"
+#include "renderer.h"
#include "vectorscope.h"
+#include "vectorscopegenerator.h"
-const float SCALING = 1/.7; // See class docs
const float P75 = .75;
+const unsigned char DEFAULT_Y = 255;
+
const QPointF YUV_R(-.147, .615);
const QPointF YUV_G(-.289, -.515);
const QPointF YUV_B(.437, -.100);
const QPen penThick(QBrush(QColor(250,250,250)), 2, Qt::SolidLine);
const QPen penThin(QBrush(QColor(250,250,250)), 1, Qt::SolidLine);
-const QPen penLight(QBrush(QColor(144,255,100,50)), 1, Qt::SolidLine);
+const QPen penLight(QBrush(QColor(200,200,250,150)), 1, Qt::SolidLine);
+const QPen penDark(QBrush(QColor(0,0,20,250)), 1, Qt::SolidLine);
-Vectorscope::Vectorscope(Render *projRender, Render *clipRender, QWidget *parent) :
- QWidget(parent),
- m_projRender(projRender),
- m_clipRender(clipRender),
- m_activeRender(clipRender),
- iPaintMode(GREEN),
- scaling(1),
- circleOnly(false)
+Vectorscope::Vectorscope(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent) :
+ AbstractScopeWidget(projMonitor, clipMonitor, parent),
+ m_gain(1),
+ m_circleEnabled(false)
{
- setupUi(this);
+ ui = new Ui::Vectorscope_UI();
+ ui->setupUi(this);
+
+ m_colorTools = new ColorTools();
+ m_colorPlaneExport = new ColorPlaneExport(this);
+ m_vectorscopeGenerator = new VectorscopeGenerator();
+
+ ui->paintMode->addItem(i18n("Green 2"), QVariant(VectorscopeGenerator::PaintMode_Green2));
+ ui->paintMode->addItem(i18n("Green"), QVariant(VectorscopeGenerator::PaintMode_Green));
+ ui->paintMode->addItem(i18n("Black"), QVariant(VectorscopeGenerator::PaintMode_Black));
+ ui->paintMode->addItem(i18n("Modified YUV (Chroma)"), QVariant(VectorscopeGenerator::PaintMode_Chroma));
+ ui->paintMode->addItem(i18n("YUV"), QVariant(VectorscopeGenerator::PaintMode_YUV));
+ ui->paintMode->addItem(i18n("Original Color"), QVariant(VectorscopeGenerator::PaintMode_Original));
+
+ ui->backgroundMode->addItem(i18n("None"), QVariant(BG_NONE));
+ ui->backgroundMode->addItem(i18n("YUV"), QVariant(BG_YUV));
+ ui->backgroundMode->addItem(i18n("Modified YUV (Chroma)"), QVariant(BG_CHROMA));
- paintMode->insertItem(GREEN, i18n("Green"));
- paintMode->insertItem(CHROMA, i18n("Chroma"));
- paintMode->insertItem(ORIG, i18n("Original Color"));
- cbAutoRefresh->setEnabled(false);
+ ui->sliderGain->setMinimum(0);
+ ui->sliderGain->setMaximum(40);
+
+ bool b = true;
+ b &= connect(ui->backgroundMode, SIGNAL(currentIndexChanged(int)), this, SLOT(slotBackgroundChanged()));
+ b &= connect(ui->sliderGain, SIGNAL(valueChanged(int)), this, SLOT(slotGainChanged(int)));
+ b &= connect(ui->paintMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceUpdateScope()));
+ ui->sliderGain->setValue(0);
+
+
+ ///// Build context menu /////
+
+ m_menu->addSeparator();
+
+ m_aExportBackground = new QAction(i18n("Export background"), this);
+ m_menu->addAction(m_aExportBackground);
+ b &= connect(m_aExportBackground, SIGNAL(triggered()), this, SLOT(slotExportBackground()));
+
+ m_a75PBox = new QAction(i18n("75% box"), this);
+ m_a75PBox->setCheckable(true);
+ m_menu->addAction(m_a75PBox);
+ b &= connect(m_a75PBox, SIGNAL(changed()), this, SLOT(forceUpdateBackground()));
+
+ m_aAxisEnabled = new QAction(i18n("Draw axis"), this);
+ m_aAxisEnabled->setCheckable(true);
+ m_menu->addAction(m_aAxisEnabled);
+ b &= connect(m_aAxisEnabled, SIGNAL(changed()), this, SLOT(forceUpdateBackground()));
+
+ Q_ASSERT(b);
- connect(paintMode, SIGNAL(currentIndexChanged(int)), this, SLOT(slotPaintModeChanged(int)));
- connect(cbMagnify, SIGNAL(stateChanged(int)), this, SLOT(slotMagnifyChanged()));
this->setMouseTracking(true);
+ slotGainChanged(ui->sliderGain->value());
+
+ init();
}
Vectorscope::~Vectorscope()
{
-}
-
-/**
+ writeConfig();
- Input point is on [-1,1]², 0 being at the center,
- and positive directions are top/right.
-
- Maps to a QRect «inside» which is using the
- 0 point in the top left corner. The coordinates of
- the rect «inside» are relative to «parent». The
- coordinates returned can be used in the parent.
+ delete m_colorTools;
+ delete m_colorPlaneExport;
+ delete m_vectorscopeGenerator;
+ delete m_aExportBackground;
+ delete m_aAxisEnabled;
+ delete m_a75PBox;
+}
- parent v
- +-------------------+
- | inside v |
- | +-----------+ |
- | | + | |
- | | --0++ | | < point
- | | - | |
- | +-----------+ |
- | |
- +-------------------+
+QString Vectorscope::widgetName() const { return QString("Vectorscope"); }
- */
-QPoint Vectorscope::mapToCanvas(QRect inside, QPointF point)
+void Vectorscope::readConfig()
{
- return QPoint(point.x()/2*inside.width() + inside.width()/2 + inside.x(),
- -point.y()/2*inside.height() + inside.height()/2 + inside.y());
+ AbstractScopeWidget::readConfig();
+
+ KSharedConfigPtr config = KGlobal::config();
+ KConfigGroup scopeConfig(config, configName());
+ m_a75PBox->setChecked(scopeConfig.readEntry("75PBox", false));
+ m_aAxisEnabled->setChecked(scopeConfig.readEntry("axis", false));
+ ui->backgroundMode->setCurrentIndex(scopeConfig.readEntry("backgroundmode").toInt());
+ ui->paintMode->setCurrentIndex(scopeConfig.readEntry("paintmode").toInt());
+ ui->sliderGain->setValue(scopeConfig.readEntry("gain", 1));
}
-void Vectorscope::paintEvent(QPaintEvent *)
+void Vectorscope::writeConfig()
{
- // Widget width/height
- int ww = this->size().width();
- int wh = this->size().height();
+ KSharedConfigPtr config = KGlobal::config();
+ KConfigGroup scopeConfig(config, configName());
+ scopeConfig.writeEntry("75PBox", m_a75PBox->isChecked());
+ scopeConfig.writeEntry("axis", m_aAxisEnabled->isChecked());
+ scopeConfig.writeEntry("backgroundmode", ui->backgroundMode->currentIndex());
+ scopeConfig.writeEntry("paintmode", ui->paintMode->currentIndex());
+ scopeConfig.writeEntry("gain", ui->sliderGain->value());
+ scopeConfig.sync();
+}
+QRect Vectorscope::scopeRect()
+{
// Distance from top/left/right
int offset = 6;
- // controlsArea contains the controls at the top;
- // We want to paint below
- QPoint topleft(offset, controlsArea->geometry().height()+offset);
+ // We want to paint below the controls area. The line is the lowest element.
+ QPoint topleft(offset, ui->verticalSpacer->geometry().y()+offset);
+ QPoint bottomright(ui->horizontalSpacer->geometry().right()-offset, this->size().height()-offset);
+
+ QRect scopeRect(topleft, bottomright);
// Circle Width: min of width and height
- int cw = wh - topleft.y();
- if (ww < cw) { cw = ww; }
- cw -= 2*offset;
- QRect scopeRect(topleft, QPoint(cw, cw) + topleft);
+ cw = (scopeRect.height() < scopeRect.width()) ? scopeRect.height() : scopeRect.width();
+ scopeRect.setWidth(cw);
+ scopeRect.setHeight(cw);
+
+
+ m_centerPoint = m_vectorscopeGenerator->mapToCircle(scopeRect.size(), QPointF(0,0));
+ pR75 = m_vectorscopeGenerator->mapToCircle(scopeRect.size(), P75*VectorscopeGenerator::scaling*YUV_R);
+ pG75 = m_vectorscopeGenerator->mapToCircle(scopeRect.size(), P75*VectorscopeGenerator::scaling*YUV_G);
+ pB75 = m_vectorscopeGenerator->mapToCircle(scopeRect.size(), P75*VectorscopeGenerator::scaling*YUV_B);
+ pCy75 = m_vectorscopeGenerator->mapToCircle(scopeRect.size(), P75*VectorscopeGenerator::scaling*YUV_Cy);
+ pMg75 = m_vectorscopeGenerator->mapToCircle(scopeRect.size(), P75*VectorscopeGenerator::scaling*YUV_Mg);
+ pYl75 = m_vectorscopeGenerator->mapToCircle(scopeRect.size(), P75*VectorscopeGenerator::scaling*YUV_Yl);
+
+ return scopeRect;
+}
+
+bool Vectorscope::isHUDDependingOnInput() const { return false; }
+bool Vectorscope::isScopeDependingOnInput() const { return true; }
+bool Vectorscope::isBackgroundDependingOnInput() const { return false; }
+
+QImage Vectorscope::renderHUD(uint)
+{
+
+ QImage hud;
+
+ if (m_circleEnabled) {
+ // Mouse moved: Draw a circle over the scope
+
+ hud = QImage(m_scopeRect.size(), QImage::Format_ARGB32);
+ hud.fill(qRgba(0, 0, 0, 0));
+
+ QPainter davinci(&hud);
+ QPoint widgetCenterPoint = m_scopeRect.topLeft() + m_centerPoint;
+
+ int dx = -widgetCenterPoint.x()+m_mousePos.x();
+ int dy = widgetCenterPoint.y()-m_mousePos.y();
+
+ QPoint reference = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), QPointF(1,0));
+
+ float r = sqrt(dx*dx + dy*dy);
+ float percent = (float) 100*r/VectorscopeGenerator::scaling/m_gain/(reference.x() - widgetCenterPoint.x());
+
+ switch (ui->backgroundMode->itemData(ui->backgroundMode->currentIndex()).toInt()) {
+ case BG_NONE:
+ davinci.setPen(penLight);
+ break;
+ default:
+ if (r > cw/2) {
+ davinci.setPen(penLight);
+ } else {
+ davinci.setPen(penDark);
+ }
+ break;
+ }
+ davinci.drawEllipse(m_centerPoint, (int)r, (int)r);
+ davinci.setPen(penThin);
+ davinci.drawText(QPoint(m_scopeRect.width()-40, m_scopeRect.height()), i18n("%1 \%", QString::number(percent, 'f', 0)));
+
+ float angle = copysign(acos(dx/r)*180/M_PI, dy);
+ davinci.drawText(QPoint(10, m_scopeRect.height()), i18n("%1°", QString::number(angle, 'f', 1)));
+
+ m_circleEnabled = false;
+ } else {
+ hud = QImage(0, 0, QImage::Format_ARGB32);
+ }
+ emit signalHUDRenderingFinished(0, 1);
+ return hud;
+}
+
+QImage Vectorscope::renderScope(uint accelerationFactor, QImage qimage)
+{
+ QTime start = QTime::currentTime();
+ QImage scope;
+
+ if (cw <= 0) {
+ qDebug() << "Scope size not known yet. Aborting.";
+ } else {
+
+ scope = m_vectorscopeGenerator->calculateVectorscope(m_scopeRect.size(),
+ qimage,
+ m_gain, (VectorscopeGenerator::PaintMode) ui->paintMode->itemData(ui->paintMode->currentIndex()).toInt(),
+ m_aAxisEnabled->isChecked(), accelerationFactor);
+
+ }
+
+ unsigned int mseconds = start.msecsTo(QTime::currentTime());
+ emit signalScopeRenderingFinished(mseconds, accelerationFactor);
+ return scope;
+}
+
+QImage Vectorscope::renderBackground(uint)
+{
+ QTime start = QTime::currentTime();
+ start.start();
+
+ QImage bg;
+ switch (ui->backgroundMode->itemData(ui->backgroundMode->currentIndex()).toInt()) {
+ case BG_YUV:
+ qDebug() << "YUV background.";
+ bg = m_colorTools->yuvColorWheel(m_scopeRect.size(), (unsigned char) 128, 1/VectorscopeGenerator::scaling, false, true);
+ break;
+ case BG_CHROMA:
+ bg = m_colorTools->yuvColorWheel(m_scopeRect.size(), (unsigned char) 255, 1/VectorscopeGenerator::scaling, true, true);
+ break;
+ default:
+ qDebug() << "No background.";
+ bg = QImage(cw, cw, QImage::Format_ARGB32);
+ bg.fill(qRgba(0,0,0,0));
+ break;
+ }
// Draw the vectorscope circle
- QPainter davinci(this);
+ QPainter davinci(&bg);
QPoint vinciPoint;
- QPoint centerPoint = mapToCanvas(scopeRect, QPointF(0,0));
+
+
davinci.setRenderHint(QPainter::Antialiasing, true);
- davinci.fillRect(0, 0, ww, wh, QColor(25,25,23));
davinci.setPen(penThick);
- davinci.drawEllipse(scopeRect);
+ davinci.drawEllipse(0, 0, cw, cw);
// Draw RGB/CMY points with 100% chroma
- vinciPoint = mapToCanvas(scopeRect, SCALING*YUV_R);
+ vinciPoint = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), VectorscopeGenerator::scaling*YUV_R);
davinci.drawEllipse(vinciPoint, 4,4);
davinci.drawText(vinciPoint-QPoint(20, -10), "R");
- vinciPoint = mapToCanvas(scopeRect, SCALING*YUV_G);
+ vinciPoint = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), VectorscopeGenerator::scaling*YUV_G);
davinci.drawEllipse(vinciPoint, 4,4);
davinci.drawText(vinciPoint-QPoint(20, 0), "G");
- vinciPoint = mapToCanvas(scopeRect, SCALING*YUV_B);
+ vinciPoint = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), VectorscopeGenerator::scaling*YUV_B);
davinci.drawEllipse(vinciPoint, 4,4);
davinci.drawText(vinciPoint+QPoint(15, 10), "B");
- vinciPoint = mapToCanvas(scopeRect, SCALING*YUV_Cy);
+ vinciPoint = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), VectorscopeGenerator::scaling*YUV_Cy);
davinci.drawEllipse(vinciPoint, 4,4);
davinci.drawText(vinciPoint+QPoint(15, -5), "Cy");
- vinciPoint = mapToCanvas(scopeRect, SCALING*YUV_Mg);
+ vinciPoint = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), VectorscopeGenerator::scaling*YUV_Mg);
davinci.drawEllipse(vinciPoint, 4,4);
davinci.drawText(vinciPoint+QPoint(15, 10), "Mg");
- vinciPoint = mapToCanvas(scopeRect, SCALING*YUV_Yl);
+ vinciPoint = m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), VectorscopeGenerator::scaling*YUV_Yl);
davinci.drawEllipse(vinciPoint, 4,4);
davinci.drawText(vinciPoint-QPoint(25, 0), "Yl");
- // Draw RGB/CMY points with 75% chroma (for NTSC)
- davinci.setPen(penThin);
- davinci.drawEllipse(centerPoint, 4,4);
- davinci.drawEllipse(mapToCanvas(scopeRect, P75*SCALING*YUV_R), 3,3);
- davinci.drawEllipse(mapToCanvas(scopeRect, P75*SCALING*YUV_G), 3,3);
- davinci.drawEllipse(mapToCanvas(scopeRect, P75*SCALING*YUV_B), 3,3);
- davinci.drawEllipse(mapToCanvas(scopeRect, P75*SCALING*YUV_Cy), 3,3);
- davinci.drawEllipse(mapToCanvas(scopeRect, P75*SCALING*YUV_Mg), 3,3);
- davinci.drawEllipse(mapToCanvas(scopeRect, P75*SCALING*YUV_Yl), 3,3);
-
-
- // If no renderer available, there is nothing more to paint now.
- if (m_activeRender == 0) return;
-
-
- // Prepare the vectorscope data
- QImage scope(cw, cw, QImage::Format_ARGB32);
- scope.fill(qRgba(0,0,0,0));
-
- QImage img(m_activeRender->extractFrame(m_activeRender->seekFramePosition()));
- uchar *bits = img.bits();
-
- //davinci.setCompositionMode(QPainter::CompositionMode_Plus);
- davinci.setPen(penLight);
-
- if (!circleOnly) {
- int r,g,b;
- double dy, dr, dg, db, dmax;
- double y,u,v;
- QPoint pt;
- QRgb px;
-
- for (int i = 0; i < img.byteCount(); i+= 4) {
- QRgb *col = (QRgb *) bits;
-
- r = qRed(*col);
- g = qGreen(*col);
- b = qBlue(*col);
-
- y = (double) 0.001173 * r + 0.002302 * g + 0.0004471 * b;
- u = (double) -0.0005781*r -0.001135*g +0.001713*b;
- v = (double) 0.002411*r -0.002019*g -0.0003921*b;
-
- pt = mapToCanvas(QRect(QPoint(0,0), scope.size()), QPointF(SCALING*scaling*u, SCALING*scaling*v));
+ switch (ui->backgroundMode->itemData(ui->backgroundMode->currentIndex()).toInt()) {
+ case BG_NONE:
+ davinci.setPen(penLight);
+ break;
+ default:
+ davinci.setPen(penDark);
+ break;
+ }
- if (!(pt.x() <= scopeRect.width() && pt.x() >= 0
- && pt.y() <= scopeRect.height() && pt.y() >= 0)) {
- // Point lies outside (because of scaling), don't plot it
- continue;
- }
+ // Draw axis
+ if (m_aAxisEnabled->isChecked()) {
+ davinci.drawLine(m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), QPointF(0,-.9)), m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), QPointF(0,.9)));
+ davinci.drawLine(m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), QPointF(-.9,0)), m_vectorscopeGenerator->mapToCircle(m_scopeRect.size(), QPointF(.9,0)));
+ }
- // Draw the pixel using the chosen draw mode
- switch (iPaintMode) {
- case CHROMA:
- dy = 200;
- dr = dy + 290.8*v;
- dg = dy - 100.6*u - 148*v;
- db = dy + 517.2*u;
-
- dmax = dr;
- if (dg > dmax) dmax = dg;
- if (db > dmax) dmax = db;
- dmax = 255/dmax;
-
- dr *= dmax;
- dg *= dmax;
- db *= dmax;
-
- scope.setPixel(pt, qRgba(dr, dg, db, 255));
- break;
- case ORIG:
- scope.setPixel(pt, *col);
- break;
- case GREEN:
- px = scope.pixel(pt);
- scope.setPixel(pt, qRgba(qRed(px)+(255-qRed(px))/40, 255, qBlue(px)+(255-qBlue(px))/40, qAlpha(px)+(255-qAlpha(px))/20));
- break;
- }
+ // Draw center point
+ switch (ui->backgroundMode->itemData(ui->backgroundMode->currentIndex()).toInt()) {
+ case BG_CHROMA:
+ davinci.setPen(penDark);
+ break;
+ default:
+ davinci.setPen(penThin);
+ break;
+ }
+ davinci.drawEllipse(m_centerPoint, 5,5);
- bits += 4;
- }
- davinci.drawImage(scopeRect.topLeft(), scope);
- m_scope = scope;
- } else {
- // Mouse moved: Draw a circle over the (already calculated) scope
- davinci.drawImage(scopeRect.topLeft(), m_scope);
+ // Draw 75% box
+ if (m_a75PBox->isChecked()) {
+ davinci.drawLine(pR75, pYl75);
+ davinci.drawLine(pYl75, pG75);
+ davinci.drawLine(pG75, pCy75);
+ davinci.drawLine(pCy75, pB75);
+ davinci.drawLine(pB75, pMg75);
+ davinci.drawLine(pMg75, pR75);
+ }
- int dx = centerPoint.x()-mousePos.x();
- int dy = centerPoint.y()-mousePos.y();
+ // Draw RGB/CMY points with 75% chroma (for NTSC)
+ davinci.setPen(penThin);
+ davinci.drawEllipse(pR75, 3,3);
+ davinci.drawEllipse(pG75, 3,3);
+ davinci.drawEllipse(pB75, 3,3);
+ davinci.drawEllipse(pCy75, 3,3);
+ davinci.drawEllipse(pMg75, 3,3);
+ davinci.drawEllipse(pYl75, 3,3);
+
+ // Draw realtime factor (number of skipped pixels)
+ if (m_aRealtime->isChecked()) {
+ davinci.setPen(penThin);
+ davinci.drawText(QPoint(m_scopeRect.width()-40, m_scopeRect.height()-15), QVariant(m_accelFactorScope).toString().append("x"));
+ }
- QPoint reference = mapToCanvas(scopeRect, QPointF(1,0));
+ emit signalBackgroundRenderingFinished(start.elapsed(), 1);
+ return bg;
+}
- int r = sqrt(dx*dx + dy*dy);
- float percent = (float) 100*r/SCALING/(reference.x() - centerPoint.x());
- qDebug() << "dx: " << dx << " dy: " << dy << " r: " << r;
- davinci.drawEllipse(centerPoint, r,r);
- davinci.setPen(penThin);
- davinci.drawText(scopeRect.bottomRight()-QPoint(40,0), QVariant((int)percent).toString().append(" %"));
- circleOnly = false;
- }
-}
+///// Slots /////
-void Vectorscope::slotPaintModeChanged(int index)
+void Vectorscope::slotGainChanged(int newval)
{
- iPaintMode = index;
- this->update();
+ m_gain = 1 + (float)newval/10;
+ ui->lblGain->setText(QString::number(m_gain, 'f', 1) + "x");
+ forceUpdateScope();
}
-void Vectorscope::slotMagnifyChanged()
+void Vectorscope::slotExportBackground()
{
- if (cbMagnify->isChecked()) {
- scaling = 1.4;
- } else {
- scaling = 1;
- }
- this->update();
+ qDebug() << "Exporting background";
+ m_colorPlaneExport->show();
+
}
-void Vectorscope::slotActiveMonitorChanged(bool isClipMonitor)
+void Vectorscope::slotBackgroundChanged()
{
- qDebug() << "Active monitor changed. Is clip? " << isClipMonitor;
- if (isClipMonitor) {
- m_activeRender = m_clipRender;
- } else {
- m_activeRender = m_projRender;
+ // Background changed, switch to a suitable color mode now
+ int index;
+ switch (ui->backgroundMode->itemData(ui->backgroundMode->currentIndex()).toInt()) {
+ case BG_YUV:
+ index = ui->paintMode->findData(QVariant(VectorscopeGenerator::PaintMode_Black));
+ if (index >= 0) {
+ ui->paintMode->setCurrentIndex(index);
+ }
+ break;
+
+ case BG_NONE:
+ if (ui->paintMode->itemData(ui->paintMode->currentIndex()).toInt() == VectorscopeGenerator::PaintMode_Black) {
+ index = ui->paintMode->findData(QVariant(VectorscopeGenerator::PaintMode_Green2));
+ ui->paintMode->setCurrentIndex(index);
+ }
+ break;
}
+ forceUpdateBackground();
}
-void Vectorscope::mousePressEvent(QMouseEvent *)
-{
- // Update the scope on mouse press
- this->update();
-}
+
+
+///// Events /////
void Vectorscope::mouseMoveEvent(QMouseEvent *event)
{
// Draw a circle around the center,
// showing percentage number of the radius length
- circleOnly = true;
- mousePos = event->pos();
- qDebug() << "event: " << mousePos.x() << "/" << mousePos.y();
- this->update();
+ m_circleEnabled = true;
+ m_mousePos = event->pos();
+ forceUpdateHUD();
+}
+
+void Vectorscope::leaveEvent(QEvent *event)
+{
+ // Repaint the HUD without the circle
+
+ m_circleEnabled = false;
+ QWidget::leaveEvent(event);
+ forceUpdateHUD();
}