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 ***************************************************************************/
15 #include "rgbparade.h"
16 #include "rgbparadegenerator.h"
18 RGBParade::RGBParade(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent) :
19 AbstractScopeWidget(projMonitor, clipMonitor, parent)
21 ui = new Ui::RGBParade_UI();
24 ui->paintMode->addItem(i18n("RGB"), QVariant(RGBParadeGenerator::PaintMode_RGB));
25 ui->paintMode->addItem(i18n("RGB 2"), QVariant(RGBParadeGenerator::PaintMode_RGB2));
29 m_menu->addSeparator();
30 m_aAxis = new QAction(i18n("Draw axis"), this);
31 m_aAxis->setCheckable(true);
32 m_menu->addAction(m_aAxis);
33 b &= connect(m_aAxis, SIGNAL(changed()), this, SLOT(forceUpdateScope()));
35 m_aGradRef = new QAction(i18n("Gradient reference line"), this);
36 m_aGradRef->setCheckable(true);
37 m_menu->addAction(m_aGradRef);
38 b &= connect(m_aGradRef, SIGNAL(changed()), this, SLOT(forceUpdateScope()));
40 b &= connect(ui->paintMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceUpdateScope()));
44 m_rgbParadeGenerator = new RGBParadeGenerator();
48 RGBParade::~RGBParade()
53 delete m_rgbParadeGenerator;
58 void RGBParade::readConfig()
60 AbstractScopeWidget::readConfig();
62 KSharedConfigPtr config = KGlobal::config();
63 KConfigGroup scopeConfig(config, configName());
64 ui->paintMode->setCurrentIndex(scopeConfig.readEntry("paintmode", 0));
65 m_aAxis->setChecked(scopeConfig.readEntry("axis", true));
66 m_aGradRef->setChecked(scopeConfig.readEntry("gradref", false));
69 void RGBParade::writeConfig()
71 KSharedConfigPtr config = KGlobal::config();
72 KConfigGroup scopeConfig(config, configName());
73 scopeConfig.writeEntry("paintmode", ui->paintMode->currentIndex());
74 scopeConfig.writeEntry("axis", m_aAxis->isChecked());
75 scopeConfig.writeEntry("gradref", m_aGradRef->isChecked());
80 QString RGBParade::widgetName() const { return "RGB Parade"; }
82 QRect RGBParade::scopeRect()
84 QPoint topleft(offset, ui->verticalSpacer->geometry().y() + 2*offset);
85 return QRect(topleft, QPoint(this->size().width() - offset, this->size().height() - offset));
88 QImage RGBParade::renderHUD(uint) { return QImage(); }
89 QImage RGBParade::renderScope(uint accelerationFactor, QImage qimage)
91 QTime start = QTime::currentTime();
94 int paintmode = ui->paintMode->itemData(ui->paintMode->currentIndex()).toInt();
95 QImage parade = m_rgbParadeGenerator->calculateRGBParade(m_scopeRect.size(), qimage, (RGBParadeGenerator::PaintMode) paintmode,
96 m_aAxis->isChecked(), m_aGradRef->isChecked(), accelerationFactor);
97 emit signalScopeRenderingFinished(start.elapsed(), accelerationFactor);
100 QImage RGBParade::renderBackground(uint) { return QImage(); }
102 bool RGBParade::isHUDDependingOnInput() const { return false; }
103 bool RGBParade::isScopeDependingOnInput() const { return true; }
104 bool RGBParade::isBackgroundDependingOnInput() const { return false; }