const QColor RGBParadeGenerator::colLight(200, 200, 200, 255);
const QColor RGBParadeGenerator::colSoft(150, 150, 150, 255);
+
+const uchar RGBParadeGenerator::distRight(40);
+const uchar RGBParadeGenerator::distBottom(40);
+
RGBParadeGenerator::RGBParadeGenerator()
{
}
const uint byteCount = iw*ih;
const uchar offset = 10;
- const uchar right = 40;
- const uchar bottom = 40;
- const int partW = (ww - 2*offset - right) / 3;
- const int partH = wh - bottom;
+ const int partW = (ww - 2*offset - distRight) / 3;
+ const int partH = wh - distBottom;
// To get constant brightness, independant of acceleration factor and input image size
// Must be a float because the acceleration factor can be high, leading to <1 expected px per px.
- const float avgPxPerPx = ((float)(image.width() * image.height()) / (500*partW*accelFactor));
- const float weaken = (avgPxPerPx == 0) ? 1 : (float)4/avgPxPerPx;
- const int vh = weaken*27;
- const int vm = weaken*18;
- const int vl = weaken*9;
-
- // Divide by 3 because of the 3 components
+ // Divide by 3 because of the 3 components.
const float brightnessAdjustment = accelFactor * ((float) ww*wh/(byteCount>>3)) / 3;
uchar minR = 255, minG = 255, minB = 255, maxR = 0, maxG = 0, maxB = 0, r, g, b;
// << " with an acceleration factor of " << accelFactor;
- QImage unscaled(ww-right, 256, QImage::Format_ARGB32);
+ QImage unscaled(ww-distRight, 256, QImage::Format_ARGB32);
unscaled.fill(qRgba(0, 0, 0, 0));
const float wPrediv = (float)(partW-1)/(iw-1);
paradePoint = QPoint((int)dx, r);
paradeCol = QRgb(unscaled.pixel(paradePoint));
switch(paintMode) {
- case PaintMode_RGB2:
- unscaled.setPixel(paradePoint, qRgba(CHOP255(vh + qRed(paradeCol)), CHOP255(vm + qGreen(paradeCol)),
- CHOP255(vl + qBlue(paradeCol)), 255));
+ case PaintMode_RGB:
+ unscaled.setPixel(paradePoint, qRgba(255,10,10, CHOP255(brightnessAdjustment*16 + qAlpha(paradeCol))));
break;
default:
- unscaled.setPixel(paradePoint, qRgba(255,0,0, CHOP255(brightnessAdjustment*16 + qAlpha(paradeCol))));
+ unscaled.setPixel(paradePoint, qRgba(255,255,255, CHOP255(brightnessAdjustment*16 + qAlpha(paradeCol))));
break;
}
paradePoint = QPoint((int) (dx + partW + offset), g);
paradeCol = QRgb(unscaled.pixel(paradePoint));
switch(paintMode) {
- case PaintMode_RGB2:
- unscaled.setPixel(paradePoint, qRgba(CHOP255(vl + qRed(paradeCol)), CHOP255(vh + qGreen(paradeCol)),
- CHOP255(vm + qBlue(paradeCol)), 255));
+ case PaintMode_RGB:
+ unscaled.setPixel(paradePoint, qRgba(10,255,10, CHOP255(brightnessAdjustment*16 + qAlpha(paradeCol))));
break;
default:
- unscaled.setPixel(paradePoint, qRgba(0,255,0, CHOP255(brightnessAdjustment*16 + qAlpha(paradeCol))));
+ unscaled.setPixel(paradePoint, qRgba(255,255,255, CHOP255(brightnessAdjustment*16 + qAlpha(paradeCol))));
break;
}
paradePoint = QPoint((int) (dx + 2*partW + 2*offset), b);
paradeCol = QRgb(unscaled.pixel(paradePoint));
switch(paintMode) {
- case PaintMode_RGB2:
- unscaled.setPixel(paradePoint, qRgba(CHOP255(vm + qRed(paradeCol)), CHOP255(vl + qGreen(paradeCol)),
- CHOP255(vh + qBlue(paradeCol)), 255));
+ case PaintMode_RGB:
+ unscaled.setPixel(paradePoint, qRgba(10,10,255, CHOP255(brightnessAdjustment*16 + qAlpha(paradeCol))));
break;
default:
- unscaled.setPixel(paradePoint, qRgba(0,0,255, CHOP255(brightnessAdjustment*16 + qAlpha(paradeCol))));
+ unscaled.setPixel(paradePoint, qRgba(255,255,255, CHOP255(brightnessAdjustment*16 + qAlpha(paradeCol))));
break;
}
QRgb opx;
for (uint i = 0; i <= 10; i++) {
dy = (float)i/10 * (partH-1);
- for (uint x = 0; x < ww-right; x++) {
+ for (uint x = 0; x < ww-distRight; x++) {
opx = parade.pixel(x, dy);
parade.setPixel(x,dy, qRgba(CHOP255(150+qRed(opx)), 255,
CHOP255(200+qBlue(opx)), CHOP255(32+qAlpha(opx))));
davinci.drawText(partW + offset + d, wh-20, QString::number(maxG, 'f', 0));
davinci.drawText(2*partW + 2*offset + d, wh-20, QString::number(maxB, 'f', 0));
- davinci.drawText(ww-right+5, 10, "255");
- davinci.drawText(ww-right+5, partH+5, "0");
+ davinci.drawText(ww-distRight+5, 10, "255");
+ davinci.drawText(ww-distRight+5, partH+5, "0");
***************************************************************************/
#include <QMenu>
+#include <QPainter>
#include <QRect>
#include <QTime>
#include "renderer.h"
#include "rgbparadegenerator.h"
RGBParade::RGBParade(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent) :
- AbstractScopeWidget(projMonitor, clipMonitor, parent)
+ AbstractScopeWidget(projMonitor, clipMonitor, true, parent)
{
ui = new Ui::RGBParade_UI();
ui->setupUi(this);
ui->paintMode->addItem(i18n("RGB"), QVariant(RGBParadeGenerator::PaintMode_RGB));
- ui->paintMode->addItem(i18n("RGB 2"), QVariant(RGBParadeGenerator::PaintMode_RGB2));
+ ui->paintMode->addItem(i18n("White"), QVariant(RGBParadeGenerator::PaintMode_White));
bool b = true;
b &= connect(m_aGradRef, SIGNAL(changed()), this, SLOT(forceUpdateScope()));
b &= connect(ui->paintMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceUpdateScope()));
-
+ b &= connect(this, SIGNAL(signalMousePositionChanged()), this, SLOT(forceUpdateHUD()));
Q_ASSERT(b);
m_rgbParadeGenerator = new RGBParadeGenerator();
return QRect(topleft, QPoint(this->size().width() - offset, this->size().height() - offset));
}
-QImage RGBParade::renderHUD(uint) { return QImage(); }
+QImage RGBParade::renderHUD(uint)
+{
+ if (scopeRect().height() > 0 && m_mouseWithinWidget) {
+ QImage hud(m_scopeRect.size(), QImage::Format_ARGB32);
+ hud.fill(qRgba(0,0,0,0));
+
+ QPainter davinci(&hud);
+ davinci.setPen(penLight);
+
+ int x = scopeRect().width()-30;
+ int y = m_mousePos.y() - scopeRect().y();
+
+ // Draw a horizontal line through the current mouse position
+ // and show the value of the waveform there
+ davinci.drawLine(0, y, scopeRect().size().width()-RGBParadeGenerator::distRight, y);
+
+ int val = 255*(1-((float)y/(scopeRect().height()-RGBParadeGenerator::distBottom)));
+ davinci.drawText(x, scopeRect().height()/2, QVariant(val).toString());
+
+ emit signalHUDRenderingFinished(1, 1);
+ return hud;
+ } else {
+ emit signalHUDRenderingFinished(1, 1);
+ return QImage();
+ }
+}
QImage RGBParade::renderScope(uint accelerationFactor, QImage qimage)
{
QTime start = QTime::currentTime();