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();
24 ui->cbY->setChecked(true);
25 ui->cbR->setChecked(true);
26 ui->cbG->setChecked(true);
27 ui->cbB->setChecked(true);
30 m_aUnscaled = new QAction(i18n("Unscaled"), this);
31 m_aUnscaled->setCheckable(true);
32 m_menu->addSeparator();
33 m_menu->addAction(m_aUnscaled);
36 b &= connect(ui->cbY, SIGNAL(toggled(bool)), this, SLOT(forceUpdateScope()));
37 b &= connect(ui->cbR, SIGNAL(toggled(bool)), this, SLOT(forceUpdateScope()));
38 b &= connect(ui->cbG, SIGNAL(toggled(bool)), this, SLOT(forceUpdateScope()));
39 b &= connect(ui->cbB, SIGNAL(toggled(bool)), this, SLOT(forceUpdateScope()));
40 b &= connect(m_aUnscaled, SIGNAL(toggled(bool)), this, SLOT(forceUpdateScope()));
45 Histogram::~Histogram()
51 QString Histogram::widgetName() const { return QString("Histogram"); }
53 bool Histogram::isHUDDependingOnInput() const { return false; }
54 bool Histogram::isScopeDependingOnInput() const { return true; }
55 bool Histogram::isBackgroundDependingOnInput() const { return false; }
57 QRect Histogram::scopeRect()
59 qDebug() << "According to the spacer, the top left point is " << ui->verticalSpacer->geometry().x() << "/" << ui->verticalSpacer->geometry().y();
60 QPoint topleft(offset, offset+ ui->verticalSpacer->geometry().y());
61 return QRect(topleft, this->rect().size() - QSize(topleft.x() + offset, topleft.y() + offset));
64 QImage Histogram::renderHUD(uint)
66 emit signalHUDRenderingFinished(0, 1);
69 QImage Histogram::renderScope(uint accelFactor, QImage qimage)
71 QTime start = QTime::currentTime();
74 const int componentFlags = (ui->cbY->isChecked() ? 1 : 0) * HistogramGenerator::ComponentY
75 | (ui->cbR->isChecked() ? 1 : 0) * HistogramGenerator::ComponentR
76 | (ui->cbG->isChecked() ? 1 : 0) * HistogramGenerator::ComponentG
77 | (ui->cbB->isChecked() ? 1 : 0) * HistogramGenerator::ComponentB;
79 QImage histogram = m_histogramGenerator->calculateHistogram(m_scopeRect.size(), qimage,
80 componentFlags, m_aUnscaled->isChecked(), accelFactor);
82 emit signalScopeRenderingFinished(start.elapsed(), accelFactor);
85 QImage Histogram::renderBackground(uint)
87 emit signalBackgroundRenderingFinished(0, 1);