1 /***************************************************************************
2 * Copyright (C) 2010 by Simon Andreas Eugster (simon.eu@gmail.com) *
3 * This file is part of kdenlive. See www.kdenlive.org. *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 ***************************************************************************/
13 #include "histogramgenerator.h"
14 #include "histogram.h"
17 Histogram::Histogram(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent) :
18 AbstractScopeWidget(projMonitor, clipMonitor, parent)
20 ui = new Ui::Histogram_UI();
23 ui->cbY->setChecked(true);
24 ui->cbR->setChecked(true);
25 ui->cbG->setChecked(true);
26 ui->cbB->setChecked(true);
29 m_aUnscaled = new QAction(i18n("Unscaled"), this);
30 m_aUnscaled->setCheckable(true);
31 m_menu->addSeparator();
32 m_menu->addAction(m_aUnscaled);
35 b &= connect(ui->cbY, SIGNAL(toggled(bool)), this, SLOT(forceUpdateScope()));
36 b &= connect(ui->cbR, SIGNAL(toggled(bool)), this, SLOT(forceUpdateScope()));
37 b &= connect(ui->cbG, SIGNAL(toggled(bool)), this, SLOT(forceUpdateScope()));
38 b &= connect(ui->cbB, SIGNAL(toggled(bool)), this, SLOT(forceUpdateScope()));
39 b &= connect(m_aUnscaled, SIGNAL(toggled(bool)), this, SLOT(forceUpdateScope()));
44 Histogram::~Histogram()
50 QString Histogram::widgetName() const { return QString("Histogram"); }
52 bool Histogram::isHUDDependingOnInput() const { return false; }
53 bool Histogram::isScopeDependingOnInput() const { return true; }
54 bool Histogram::isBackgroundDependingOnInput() const { return false; }
56 QRect Histogram::scopeRect()
58 qDebug() << "According to the spacer, the top left point is " << ui->verticalSpacer->geometry().x() << "/" << ui->verticalSpacer->geometry().y();
59 QPoint topleft(offset, offset+ ui->verticalSpacer->geometry().y());
60 return QRect(topleft, this->rect().size() - QSize(topleft.x() + offset, topleft.y() + offset));
63 QImage Histogram::renderHUD(uint)
65 emit signalHUDRenderingFinished(0, 1);
68 QImage Histogram::renderScope(uint accelFactor)
70 QTime start = QTime::currentTime();
73 const int componentFlags = (ui->cbY->isChecked() ? 1 : 0) * HistogramGenerator::ComponentY
74 | (ui->cbR->isChecked() ? 1 : 0) * HistogramGenerator::ComponentR
75 | (ui->cbG->isChecked() ? 1 : 0) * HistogramGenerator::ComponentG
76 | (ui->cbB->isChecked() ? 1 : 0) * HistogramGenerator::ComponentB;
78 QImage histogram = m_histogramGenerator->calculateHistogram(m_scopeRect.size(), m_activeRender->extractFrame(m_activeRender->seekFramePosition()),
79 componentFlags, m_aUnscaled->isChecked(), accelFactor);
81 emit signalScopeRenderingFinished(start.elapsed(), accelFactor);
84 QImage Histogram::renderBackground(uint)
86 emit signalBackgroundRenderingFinished(0, 1);