const float P75 = .75;
const unsigned char DEFAULT_Y = 255;
-//const unsigned int REALTIME_FPS = 15; // in fps.
const QPointF YUV_R(-.147, .615);
const QPointF YUV_G(-.289, -.515);
ui = new Ui::Vectorscope_UI();
ui->setupUi(this);
- //TODO don't draw circle when mouseLeaved
-
m_colorTools = new ColorTools();
m_colorPlaneExport = new ColorPlaneExport(this);
m_vectorscopeGenerator = new VectorscopeGenerator();
m_a75PBox = new QAction(i18n("75% box"), this);
m_a75PBox->setCheckable(true);
- m_a75PBox->setChecked(false);
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_aAxisEnabled->setChecked(false);
m_menu->addAction(m_aAxisEnabled);
b &= connect(m_aAxisEnabled, SIGNAL(changed()), this, SLOT(forceUpdateBackground()));
this->setMouseTracking(true);
slotGainChanged(ui->sliderGain->value());
+
+ init();
}
Vectorscope::~Vectorscope()
{
+ writeConfig();
+
delete m_colorTools;
delete m_colorPlaneExport;
delete m_vectorscopeGenerator;
delete m_a75PBox;
}
-QString Vectorscope::widgetName() const {
- return QString("Vectorscope");
+QString Vectorscope::widgetName() const { return QString("Vectorscope"); }
+
+void Vectorscope::readConfig()
+{
+ 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));
}
-QRect Vectorscope::scopeRect()
+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;
// We want to paint below the controls area. The line is the lowest element.
- QPoint topleft(offset, ui->line->y()+offset);
+ 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
- cw = wh - topleft.y();
- if (ww < cw) { cw = ww; }
- cw -= 2*offset;
+ cw = (scopeRect.height() < scopeRect.width()) ? scopeRect.height() : scopeRect.width();
+ scopeRect.setWidth(cw);
+ scopeRect.setHeight(cw);
- QRect scopeRect(topleft, QPoint(cw, cw) + topleft);
m_centerPoint = m_vectorscopeGenerator->mapToCircle(scopeRect.size(), QPointF(0,0));
pR75 = m_vectorscopeGenerator->mapToCircle(scopeRect.size(), P75*VectorscopeGenerator::scaling*YUV_R);
davinci.setPen(penLight);
break;
default:
- davinci.setPen(penDark);
+ if (r > cw/2) {
+ davinci.setPen(penLight);
+ } else {
+ davinci.setPen(penDark);
+ }
break;
}
davinci.drawEllipse(m_centerPoint, (int)r, (int)r);
return hud;
}
-QImage Vectorscope::renderScope(uint accelerationFactor)
+QImage Vectorscope::renderScope(uint accelerationFactor, QImage qimage)
{
QTime start = QTime::currentTime();
QImage scope;
} else {
scope = m_vectorscopeGenerator->calculateVectorscope(m_scopeRect.size(),
- m_activeRender->extractFrame(m_activeRender->seekFramePosition()),
+ qimage,
m_gain, (VectorscopeGenerator::PaintMode) ui->paintMode->itemData(ui->paintMode->currentIndex()).toInt(),
m_aAxisEnabled->isChecked(), accelerationFactor);
}
unsigned int mseconds = start.msecsTo(QTime::currentTime());
-// qDebug() << "Scope rendered in " << mseconds << " ms. Sending finished signal.";
-// emit signalScopeCalculationFinished(mseconds, skipPixels);
emit signalScopeRenderingFinished(mseconds, accelerationFactor);
-// qDebug() << "xxScope: Signal finished sent.";
return scope;
}
m_mousePos = event->pos();
forceUpdateHUD();
}
+
+void Vectorscope::leaveEvent(QEvent *event)
+{
+ // Repaint the HUD without the circle
+
+ m_circleEnabled = false;
+ QWidget::leaveEvent(event);
+ forceUpdateHUD();
+}