]> git.sesse.net Git - kdenlive/commitdiff
Color scopes now using the common abstract scope as well. --> Common functions, more...
authorSimon A. Eugster <simon.eu@gmail.com>
Fri, 3 Dec 2010 17:11:41 +0000 (17:11 +0000)
committerSimon A. Eugster <simon.eu@gmail.com>
Fri, 3 Dec 2010 17:11:41 +0000 (17:11 +0000)
svn path=/trunk/kdenlive/; revision=5130

20 files changed:
src/CMakeLists.txt
src/abstractgfxscopewidget.cpp [deleted file]
src/abstractgfxscopewidget.h [deleted file]
src/abstractscopewidget.cpp
src/abstractscopewidget.h
src/audioscopes/abstractaudioscopewidget.cpp
src/audioscopes/abstractaudioscopewidget.h
src/audioscopes/audiospectrum.cpp
src/audioscopes/audiospectrum.h
src/colorscopes/abstractgfxscopewidget.cpp [new file with mode: 0644]
src/colorscopes/abstractgfxscopewidget.h [new file with mode: 0644]
src/colorscopes/histogram.cpp [moved from src/histogram.cpp with 98% similarity]
src/colorscopes/histogram.h [moved from src/histogram.h with 95% similarity]
src/colorscopes/rgbparade.cpp [moved from src/rgbparade.cpp with 98% similarity]
src/colorscopes/rgbparade.h [moved from src/rgbparade.h with 95% similarity]
src/colorscopes/vectorscope.cpp [moved from src/vectorscope.cpp with 99% similarity]
src/colorscopes/vectorscope.h [moved from src/vectorscope.h with 79% similarity]
src/colorscopes/waveform.cpp [moved from src/waveform.cpp with 98% similarity]
src/colorscopes/waveform.h [moved from src/waveform.h with 97% similarity]
src/mainwindow.cpp

index 80fbab923cded2202f7abba4388fe2bd1fb2c8c0..82c7ef1bff30566bd3bd10c58b77c8daa27a60f0 100644 (file)
@@ -220,14 +220,14 @@ set(kdenlive_SRCS
   tracksconfigdialog.cpp
   configtrackscommand.cpp
   abstractscopewidget.cpp
-  abstractgfxscopewidget.cpp
   audioscopes/abstractaudioscopewidget.cpp
   audioscopes/audiospectrum.cpp
   rebuildgroupcommand.cpp
-  histogram.cpp
-  rgbparade.cpp
-  vectorscope.cpp
-  waveform.cpp
+  colorscopes/abstractgfxscopewidget.cpp
+  colorscopes/histogram.cpp
+  colorscopes/rgbparade.cpp
+  colorscopes/vectorscope.cpp
+  colorscopes/waveform.cpp
   colorplaneexport.cpp
   colortools.cpp
   colorcorrection/histogramgenerator.cpp
diff --git a/src/abstractgfxscopewidget.cpp b/src/abstractgfxscopewidget.cpp
deleted file mode 100644 (file)
index 48020ee..0000000
+++ /dev/null
@@ -1,459 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2010 by Simon Andreas Eugster (simon.eu@gmail.com)      *
- *   This file is part of kdenlive. See www.kdenlive.org.                  *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- ***************************************************************************/
-
-#include "qtconcurrentrun.h"
-
-#include "abstractgfxscopewidget.h"
-#include "renderer.h"
-#include "monitor.h"
-
-#include <QFuture>
-#include <QColor>
-#include <QMenu>
-#include <QMouseEvent>
-#include <QPainter>
-
-const int REALTIME_FPS = 30;
-
-const QColor light(250, 238, 226, 255);
-const QColor dark(40,  40,  39, 255);
-const QColor dark2(25,  25,  23, 255);
-
-const QPen AbstractGfxScopeWidget::penThick(QBrush(QColor(250, 250, 250)),     2, Qt::SolidLine);
-const QPen AbstractGfxScopeWidget::penThin(QBrush(QColor(250, 250, 250)),     1, Qt::SolidLine);
-const QPen AbstractGfxScopeWidget::penLight(QBrush(QColor(200, 200, 250, 150)), 1, Qt::SolidLine);
-const QPen AbstractGfxScopeWidget::penLightDots(QBrush(QColor(200, 200, 250, 150)), 1, Qt::DotLine);
-const QPen AbstractGfxScopeWidget::penDark(QBrush(QColor(0, 0, 20, 250)),      1, Qt::SolidLine);
-const QPen AbstractGfxScopeWidget::penDarkDots(QBrush(QColor(0, 0, 20, 250)),      1, Qt::DotLine);
-
-AbstractGfxScopeWidget::AbstractGfxScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, bool trackMouse, QWidget *parent) :
-        QWidget(parent),
-        m_projMonitor(projMonitor),
-        m_clipMonitor(clipMonitor),
-        m_mousePos(0, 0),
-        m_mouseWithinWidget(false),
-        offset(5),
-        m_accelFactorHUD(1),
-        m_accelFactorScope(1),
-        m_accelFactorBackground(1),
-        m_semaphoreHUD(1),
-        m_semaphoreScope(1),
-        m_semaphoreBackground(1),
-        initialDimensionUpdateDone(false),
-        m_requestForcedUpdate(false)
-
-{
-    m_scopePalette = QPalette();
-    m_scopePalette.setBrush(QPalette::Window, QBrush(dark2));
-    m_scopePalette.setBrush(QPalette::Base, QBrush(dark));
-    m_scopePalette.setBrush(QPalette::Button, QBrush(dark));
-    m_scopePalette.setBrush(QPalette::Text, QBrush(light));
-    m_scopePalette.setBrush(QPalette::WindowText, QBrush(light));
-    m_scopePalette.setBrush(QPalette::ButtonText, QBrush(light));
-    this->setPalette(m_scopePalette);
-    this->setAutoFillBackground(true);
-
-    m_aAutoRefresh = new QAction(i18n("Auto Refresh"), this);
-    m_aAutoRefresh->setCheckable(true);
-    m_aRealtime = new QAction(i18n("Realtime (with precision loss)"), this);
-    m_aRealtime->setCheckable(true);
-
-    m_menu = new QMenu(this);
-    m_menu->setPalette(m_scopePalette);
-    m_menu->addAction(m_aAutoRefresh);
-    m_menu->addAction(m_aRealtime);
-
-    this->setContextMenuPolicy(Qt::CustomContextMenu);
-
-    m_activeRender = (m_clipMonitor->isActive()) ? m_clipMonitor->render : m_projMonitor->render;
-
-    bool b = true;
-    b &= connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint)));
-
-    //b &= connect(m_activeRender, SIGNAL(rendererPosition(int)), this, SLOT(slotRenderZoneUpdated()));
-    b &= connect(m_activeRender, SIGNAL(frameUpdated(QImage)), this, SLOT(slotRenderZoneUpdated(QImage)));
-
-    b &= connect(this, SIGNAL(signalHUDRenderingFinished(uint, uint)), this, SLOT(slotHUDRenderingFinished(uint, uint)));
-    b &= connect(this, SIGNAL(signalScopeRenderingFinished(uint, uint)), this, SLOT(slotScopeRenderingFinished(uint, uint)));
-    b &= connect(this, SIGNAL(signalBackgroundRenderingFinished(uint, uint)), this, SLOT(slotBackgroundRenderingFinished(uint, uint)));
-    b &= connect(m_aRealtime, SIGNAL(toggled(bool)), this, SLOT(slotResetRealtimeFactor(bool)));
-    b &= connect(m_aAutoRefresh, SIGNAL(toggled(bool)), this, SLOT(slotAutoRefreshToggled(bool)));
-    Q_ASSERT(b);
-
-    // Enable mouse tracking if desired.
-    // Causes the mouseMoved signal to be emitted when the mouse moves inside the
-    // widget, even when no mouse button is pressed.
-    this->setMouseTracking(trackMouse);
-}
-
-AbstractGfxScopeWidget::~AbstractGfxScopeWidget()
-{
-    writeConfig();
-
-    delete m_menu;
-    delete m_aAutoRefresh;
-    delete m_aRealtime;
-}
-
-void AbstractGfxScopeWidget::init()
-{
-    m_widgetName = widgetName();
-    readConfig();
-}
-
-void AbstractGfxScopeWidget::readConfig()
-{
-    KSharedConfigPtr config = KGlobal::config();
-    KConfigGroup scopeConfig(config, configName());
-    m_aAutoRefresh->setChecked(scopeConfig.readEntry("autoRefresh", true));
-    m_aRealtime->setChecked(scopeConfig.readEntry("realtime", false));
-    scopeConfig.sync();
-}
-
-void AbstractGfxScopeWidget::writeConfig()
-{
-    KSharedConfigPtr config = KGlobal::config();
-    KConfigGroup scopeConfig(config, configName());
-    scopeConfig.writeEntry("autoRefresh", m_aAutoRefresh->isChecked());
-    scopeConfig.writeEntry("realtime", m_aRealtime->isChecked());
-    scopeConfig.sync();
-}
-
-QString AbstractGfxScopeWidget::configName()
-{
-    return "Scope_" + m_widgetName;
-}
-
-void AbstractGfxScopeWidget::prodHUDThread()
-{
-    if (this->visibleRegion().isEmpty()) {
-//        qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating HUD.";
-    } else {
-        if (m_semaphoreHUD.tryAcquire(1)) {
-            Q_ASSERT(!m_threadHUD.isRunning());
-
-            m_newHUDFrames.fetchAndStoreRelaxed(0);
-            m_newHUDUpdates.fetchAndStoreRelaxed(0);
-            m_threadHUD = QtConcurrent::run(this, &AbstractGfxScopeWidget::renderHUD, m_accelFactorHUD);
-//            qDebug() << "HUD thread started in " << m_widgetName;
-
-        } else {
-//            qDebug() << "HUD semaphore locked, not prodding in " << m_widgetName << ". Thread running: " << m_threadHUD.isRunning();
-        }
-    }
-}
-
-void AbstractGfxScopeWidget::prodScopeThread()
-{
-    // Only start a new thread if the scope is actually visible
-    // and not hidden by another widget on the stack and if user want the scope to update.
-    if (this->visibleRegion().isEmpty() || (!m_aAutoRefresh->isChecked() && !m_requestForcedUpdate)) {
-//        qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating scope.";
-    } else {
-        // Try to acquire the semaphore. This must only succeed if m_threadScope is not running
-        // anymore. Therefore the semaphore must NOT be released before m_threadScope ends.
-        // If acquiring the semaphore fails, the thread is still running.
-        if (m_semaphoreScope.tryAcquire(1)) {
-            Q_ASSERT(!m_threadScope.isRunning());
-
-            m_newScopeFrames.fetchAndStoreRelaxed(0);
-            m_newScopeUpdates.fetchAndStoreRelaxed(0);
-
-            Q_ASSERT(m_accelFactorScope > 0);
-
-            // See http://doc.qt.nokia.com/latest/qtconcurrentrun.html#run about
-            // running member functions in a thread
-            m_threadScope = QtConcurrent::run(this, &AbstractGfxScopeWidget::renderScope, m_accelFactorScope, m_scopeImage);
-            m_requestForcedUpdate = false;
-
-//            qDebug() << "Scope thread started in " << m_widgetName;
-
-        } else {
-//            qDebug() << "Scope semaphore locked, not prodding in " << m_widgetName << ". Thread running: " << m_threadScope.isRunning();
-        }
-    }
-}
-void AbstractGfxScopeWidget::prodBackgroundThread()
-{
-    if (this->visibleRegion().isEmpty()) {
-//        qDebug() << "Scope " << m_widgetName << " is not visible. Not calculating background.";
-    } else {
-        if (m_semaphoreBackground.tryAcquire(1)) {
-            Q_ASSERT(!m_threadBackground.isRunning());
-
-            m_newBackgroundFrames.fetchAndStoreRelaxed(0);
-            m_newBackgroundUpdates.fetchAndStoreRelaxed(0);
-            m_threadBackground = QtConcurrent::run(this, &AbstractGfxScopeWidget::renderBackground, m_accelFactorBackground);
-//            qDebug() << "Background thread started in " << m_widgetName;
-
-        } else {
-//            qDebug() << "Background semaphore locked, not prodding in " << m_widgetName << ". Thread running: " << m_threadBackground.isRunning();
-        }
-    }
-}
-
-void AbstractGfxScopeWidget::forceUpdate(bool doUpdate)
-{
-//    qDebug() << "Force update called in " << widgetName() << ". Arg: " << doUpdate;
-    if (!doUpdate) {
-        return;
-    }
-    m_requestForcedUpdate = true;
-    m_newHUDUpdates.fetchAndAddRelaxed(1);
-    m_newScopeUpdates.fetchAndAddRelaxed(1);
-    m_newBackgroundUpdates.fetchAndAddRelaxed(1);
-    prodHUDThread();
-    prodScopeThread();
-    prodBackgroundThread();
-}
-void AbstractGfxScopeWidget::forceUpdateHUD()
-{
-    m_newHUDUpdates.fetchAndAddRelaxed(1);
-    prodHUDThread();
-
-}
-void AbstractGfxScopeWidget::forceUpdateScope()
-{
-    m_newScopeUpdates.fetchAndAddRelaxed(1);
-    m_requestForcedUpdate = true;
-    prodScopeThread();
-
-}
-void AbstractGfxScopeWidget::forceUpdateBackground()
-{
-    m_newBackgroundUpdates.fetchAndAddRelaxed(1);
-    prodBackgroundThread();
-
-}
-
-
-///// Events /////
-
-void AbstractGfxScopeWidget::mouseReleaseEvent(QMouseEvent *event)
-{
-    if (!m_aAutoRefresh->isChecked()) {
-        m_requestForcedUpdate = true;
-        m_activeRender->sendFrameUpdate();
-    }
-    prodHUDThread();
-    prodScopeThread();
-    prodBackgroundThread();
-    QWidget::mouseReleaseEvent(event);
-}
-
-void AbstractGfxScopeWidget::resizeEvent(QResizeEvent *event)
-{
-    // Update the dimension of the available rect for painting
-    m_scopeRect = scopeRect();
-    forceUpdate();
-
-    QWidget::resizeEvent(event);
-}
-
-void AbstractGfxScopeWidget::showEvent(QShowEvent *event)
-{
-    QWidget::showEvent(event);
-    m_scopeRect = scopeRect();
-}
-
-void AbstractGfxScopeWidget::paintEvent(QPaintEvent *)
-{
-    QPainter davinci(this);
-    davinci.drawImage(m_scopeRect.topLeft(), m_imgBackground);
-    davinci.drawImage(m_scopeRect.topLeft(), m_imgScope);
-    davinci.drawImage(m_scopeRect.topLeft(), m_imgHUD);
-}
-
-void AbstractGfxScopeWidget::mouseMoveEvent(QMouseEvent *event)
-{
-    m_mousePos = event->pos();
-    m_mouseWithinWidget = true;
-    emit signalMousePositionChanged();
-}
-void AbstractGfxScopeWidget::leaveEvent(QEvent *)
-{
-    m_mouseWithinWidget = false;
-    emit signalMousePositionChanged();
-}
-
-void AbstractGfxScopeWidget::customContextMenuRequested(const QPoint &pos)
-{
-    m_menu->exec(this->mapToGlobal(pos));
-}
-
-uint AbstractGfxScopeWidget::calculateAccelFactorHUD(uint oldMseconds, uint)
-{
-    return ceil((float)oldMseconds*REALTIME_FPS / 1000);
-}
-uint AbstractGfxScopeWidget::calculateAccelFactorScope(uint oldMseconds, uint)
-{
-    return ceil((float)oldMseconds*REALTIME_FPS / 1000);
-}
-uint AbstractGfxScopeWidget::calculateAccelFactorBackground(uint oldMseconds, uint)
-{
-    return ceil((float)oldMseconds*REALTIME_FPS / 1000);
-}
-
-
-///// Slots /////
-
-void AbstractGfxScopeWidget::slotHUDRenderingFinished(uint mseconds, uint oldFactor)
-{
-//    qDebug() << "HUD rendering has finished, waiting for termination in " << m_widgetName;
-    m_threadHUD.waitForFinished();
-    m_imgHUD = m_threadHUD.result();
-
-    m_semaphoreHUD.release(1);
-    this->update();
-
-    int accel;
-    if (m_aRealtime->isChecked()) {
-        accel = calculateAccelFactorHUD(mseconds, oldFactor);
-        if (m_accelFactorHUD < 1) {
-            accel = 1;
-        }
-        m_accelFactorHUD = accel;
-    }
-
-    if ((m_newHUDFrames > 0 && m_aAutoRefresh->isChecked()) || m_newHUDUpdates > 0) {
-//        qDebug() << "Trying to start a new HUD thread for " << m_widgetName
-//                << ". New frames/updates: " << m_newHUDFrames << "/" << m_newHUDUpdates;
-        prodHUDThread();;
-    }
-}
-
-void AbstractGfxScopeWidget::slotScopeRenderingFinished(uint mseconds, uint oldFactor)
-{
-    // The signal can be received before the thread has really finished. So we
-    // need to wait until it has really finished before starting a new thread.
-//    qDebug() << "Scope rendering has finished, waiting for termination in " << m_widgetName;
-    m_threadScope.waitForFinished();
-    m_imgScope = m_threadScope.result();
-
-    // The scope thread has finished. Now we can release the semaphore, allowing a new thread.
-    // See prodScopeThread where the semaphore is acquired again.
-    m_semaphoreScope.release(1);
-    this->update();
-
-    // Calculate the acceleration factor hint to get «realtime» updates.
-    int accel;
-    if (m_aRealtime->isChecked()) {
-        accel = calculateAccelFactorScope(mseconds, oldFactor);
-        if (accel < 1) {
-            // If mseconds happens to be 0.
-            accel = 1;
-        }
-        // Don't directly calculate with m_accelFactorScope as we are dealing with concurrency.
-        // If m_accelFactorScope is set to 0 at the wrong moment, who knows what might happen
-        // then :) Therefore use a local variable.
-        m_accelFactorScope = accel;
-    }
-
-    if ((m_newScopeFrames > 0 && m_aAutoRefresh->isChecked()) || m_newScopeUpdates > 0) {
-//        qDebug() << "Trying to start a new scope thread for " << m_widgetName
-//                << ". New frames/updates: " << m_newScopeFrames << "/" << m_newScopeUpdates;
-        prodScopeThread();
-    }
-}
-
-void AbstractGfxScopeWidget::slotBackgroundRenderingFinished(uint mseconds, uint oldFactor)
-{
-//    qDebug() << "Background rendering has finished, waiting for termination in " << m_widgetName;
-    m_threadBackground.waitForFinished();
-    m_imgBackground = m_threadBackground.result();
-
-    m_semaphoreBackground.release(1);
-    this->update();
-
-    int accel;
-    if (m_aRealtime->isChecked()) {
-        accel = calculateAccelFactorBackground(mseconds, oldFactor);
-        if (m_accelFactorBackground < 1) {
-            accel = 1;
-        }
-        m_accelFactorBackground = accel;
-    }
-
-    if ((m_newBackgroundFrames > 0 && m_aAutoRefresh->isChecked()) || m_newBackgroundUpdates > 0) {
-//        qDebug() << "Trying to start a new background thread for " << m_widgetName
-//                << ". New frames/updates: " << m_newBackgroundFrames << "/" << m_newBackgroundUpdates;
-        prodBackgroundThread();;
-    }
-}
-
-void AbstractGfxScopeWidget::slotActiveMonitorChanged(bool isClipMonitor)
-{
-//    qDebug() << "Active monitor has changed in " << m_widgetName << ". Is the clip monitor active now? " << isClipMonitor;
-
-    bool b = m_activeRender->disconnect(this);
-    Q_ASSERT(b);
-
-    m_activeRender = (isClipMonitor) ? m_clipMonitor->render : m_projMonitor->render;
-
-    //b &= connect(m_activeRender, SIGNAL(rendererPosition(int)), this, SLOT(slotRenderZoneUpdated()));
-    b &= connect(m_activeRender, SIGNAL(frameUpdated(QImage)), this, SLOT(slotRenderZoneUpdated(QImage)));
-    Q_ASSERT(b);
-
-    // Update the scope for the new monitor.
-    prodHUDThread();
-    prodScopeThread();
-    prodBackgroundThread();
-}
-
-void AbstractGfxScopeWidget::slotRenderZoneUpdated()
-{
-    m_newHUDFrames.fetchAndAddRelaxed(1);
-    m_newScopeFrames.fetchAndAddRelaxed(1);
-    m_newBackgroundFrames.fetchAndAddRelaxed(1);
-
-//    qDebug() << "Monitor incoming. New frames total HUD/Scope/Background: " << m_newHUDFrames
-//            << "/" << m_newScopeFrames << "/" << m_newBackgroundFrames;
-
-    if (this->visibleRegion().isEmpty()) {
-//        qDebug() << "Scope of widget " << m_widgetName << " is not at the top, not rendering.";
-    } else {
-        if (m_aAutoRefresh->isChecked()) {
-            prodHUDThread();
-            prodScopeThread();
-            prodBackgroundThread();
-        }
-    }
-}
-
-void AbstractGfxScopeWidget::slotRenderZoneUpdated(QImage frame)
-{
-    m_scopeImage = frame;
-    slotRenderZoneUpdated();
-}
-
-void AbstractGfxScopeWidget::slotResetRealtimeFactor(bool realtimeChecked)
-{
-    if (!realtimeChecked) {
-        m_accelFactorHUD = 1;
-        m_accelFactorScope = 1;
-        m_accelFactorBackground = 1;
-    }
-}
-
-bool AbstractGfxScopeWidget::autoRefreshEnabled()
-{
-    return m_aAutoRefresh->isChecked();
-}
-
-void AbstractGfxScopeWidget::slotAutoRefreshToggled(bool autoRefresh)
-{
-    if (isVisible()) emit requestAutoRefresh(autoRefresh);
-    // TODO only if depends on input
-    if (autoRefresh) {
-        //forceUpdate();
-        m_requestForcedUpdate = true;
-        m_activeRender->sendFrameUpdate();
-    }
-}
diff --git a/src/abstractgfxscopewidget.h b/src/abstractgfxscopewidget.h
deleted file mode 100644 (file)
index 05219ab..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2010 by Simon Andreas Eugster (simon.eu@gmail.com)      *
- *   This file is part of kdenlive. See www.kdenlive.org.                  *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- ***************************************************************************/
-
-/**
-  This abstract widget is a proof that abstract things sometimes *are* useful.
-
-  The widget expects three layers which
-  * Will be painted on top of each other on each update
-  * Are rendered in a separate thread so that the UI is not blocked
-  * Are rendered only if necessary (e.g., if a layer does not depend
-    on input images, it will not be re-rendered for incoming frames)
-
-  The layer order is as follows:
-     _____________________
-    /                     \
-   /      HUD Layer        \
-  /                         \
-  ---------------------------
-     _____________________
-    /                     \
-   /     Scope Layer       \
-  /                         \
-  ---------------------------
-     _____________________
-    /                     \
-   /   Background Layer    \
-  /                         \
-  ---------------------------
-
-  Colors of Scope Widgets are defined in here (and thus don't need to be
-  re-defined in the implementation of the widget's .ui file).
-
-  The custom context menu already contains entries, like for enabling auto-
-  refresh. It can certainly be extended in the implementation of the widget.
-
-  Note: Widgets deriving from this class should connect slotActiveMonitorChanged
-  to the appropriate signal.
-
-  If you intend to write an own widget inheriting from this one, please read
-  the comments on the unimplemented methods carefully. They are not only here
-  for optical amusement, but also contain important information.
- */
-
-#ifndef ABSTRACTGFXSCOPEWIDGET_H
-#define ABSTRACTGFXSCOPEWIDGET_H
-
-
-#include <QtCore>
-#include <QWidget>
-
-class QMenu;
-
-class Monitor;
-class Render;
-
-class AbstractGfxScopeWidget : public QWidget
-{
-    Q_OBJECT
-
-public:
-    AbstractGfxScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, bool trackMouse = false, QWidget *parent = 0);
-    virtual ~AbstractGfxScopeWidget(); // Must be virtual because of inheritance, to avoid memory leaks
-    QPalette m_scopePalette;
-
-    /** Initializes widget settings (reads configuration).
-      Has to be called in the implementing object. */
-    void init();
-
-    /** Does this scope have auto-refresh enabled */
-    bool autoRefreshEnabled();
-
-    ///// Unimplemented /////
-
-    virtual QString widgetName() const = 0;
-
-    ///// Variables /////
-    static const QPen penThick;
-    static const QPen penThin;
-    static const QPen penLight;
-    static const QPen penLightDots;
-    static const QPen penDark;
-    static const QPen penDarkDots;
-
-protected:
-    ///// Variables /////
-
-    Monitor *m_projMonitor;
-    Monitor *m_clipMonitor;
-    Render *m_activeRender;
-
-
-    /** The context menu. Feel free to add new entries in your implementation. */
-    QMenu *m_menu;
-
-    /** Enables auto refreshing of the scope.
-        This is when a new frame is shown on the active monitor.
-        Resize events always force a recalculation. */
-    QAction *m_aAutoRefresh;
-
-    /** Realtime rendering. Should be disabled if it is not supported.
-        Use the accelerationFactor variable passed to the render functions as a hint of
-        how many times faster the scope should be calculated. */
-    QAction *m_aRealtime;
-
-    /** The mouse position; Updated when the mouse enters the widget
-        AND mouse tracking has been enabled. */
-    QPoint m_mousePos;
-    /** Knows whether the mouse currently lies within the widget or not.
-        Can e.g. be used for drawing a HUD only when the mouse is in the widget. */
-    bool m_mouseWithinWidget;
-
-    /** Offset from the widget's borders */
-    const uchar offset;
-
-    /** The rect on the widget we're painting in.
-        Can be used by the implementing widget, e.g. in the render methods.
-        Is updated when necessary (size changes). */
-    QRect m_scopeRect;
-
-    /** Images storing the calculated layers. Will be used on repaint events. */
-    QImage m_imgHUD;
-    QImage m_imgScope;
-    QImage m_imgBackground;
-
-    /** The acceleration factors can be accessed also by other renderer tasks,
-        e.g. to display the scope's acceleration factor in the HUD renderer. */
-    int m_accelFactorHUD;
-    int m_accelFactorScope;
-    int m_accelFactorBackground;
-
-    /** Reads the widget's configuration.
-        Can be extended in the implementing subclass (make sure to run readConfig as well). */
-    virtual void readConfig();
-    /** Writes the widget configuration.
-        Implementing widgets have to implement an own method and run it in their destructor. */
-    void writeConfig();
-    /** Identifier for the widget's configuration. */
-    QString configName();
-
-
-    ///// Unimplemented Methods /////
-
-    /** Where on the widget we can paint in.
-        May also update other variables that depend on the widget's size.  */
-    virtual QRect scopeRect() = 0;
-
-    /** @brief HUD renderer. Must emit signalHUDRenderingFinished(). @see renderScope */
-    virtual QImage renderHUD(uint accelerationFactor) = 0;
-    /** @brief Scope renderer. Must emit signalScopeRenderingFinished()
-        when calculation has finished, to allow multi-threading.
-        accelerationFactor hints how much faster than usual the calculation should be accomplished, if possible. */
-    virtual QImage renderScope(uint accelerationFactor, const QImage) = 0;
-    /** @brief Background renderer. Must emit signalBackgroundRenderingFinished(). @see renderScope */
-    virtual QImage renderBackground(uint accelerationFactor) = 0;
-
-    /** Must return true if the HUD layer depends on the input monitor.
-        If it does not, then it does not need to be re-calculated when
-        a new frame from the monitor is incoming. */
-    virtual bool isHUDDependingOnInput() const = 0;
-    /** @see isHUDDependingOnInput() */
-    virtual bool isScopeDependingOnInput() const = 0;
-    /** @see isHUDDependingOnInput() */
-    virtual bool isBackgroundDependingOnInput() const = 0;
-
-    ///// Can be reimplemented /////
-    /** Calculates the acceleration factor to be used by the render thread.
-        This method can be refined in the subclass if required. */
-    virtual uint calculateAccelFactorHUD(uint oldMseconds, uint oldFactor);
-    virtual uint calculateAccelFactorScope(uint oldMseconds, uint oldFactor);
-    virtual uint calculateAccelFactorBackground(uint oldMseconds, uint oldFactor);
-
-    ///// Reimplemented /////
-
-    void mouseMoveEvent(QMouseEvent *);
-    void leaveEvent(QEvent *);
-    void mouseReleaseEvent(QMouseEvent *);
-    void paintEvent(QPaintEvent *);
-    void resizeEvent(QResizeEvent *);
-    void showEvent(QShowEvent *); // Called when the widget is activated via the Menu entry
-    //    void raise(); // Called only when  manually calling the event -> useless
-
-
-protected slots:
-    /** Forces an update of all layers. */
-    void forceUpdate(bool doUpdate = true);
-    void forceUpdateHUD();
-    void forceUpdateScope();
-    void forceUpdateBackground();
-    void slotAutoRefreshToggled(bool);
-
-signals:
-    /** mseconds represent the time taken for the calculation,
-        accelerationFactor is the acceleration factor that has been used for this calculation. */
-    void signalHUDRenderingFinished(uint mseconds, uint accelerationFactor);
-    void signalScopeRenderingFinished(uint mseconds, uint accelerationFactor);
-    void signalBackgroundRenderingFinished(uint mseconds, uint accelerationFactor);
-
-    /** For the mouse position itself see m_mousePos.
-        To check whether the mouse has leaved the widget, see m_mouseWithinWidget. */
-    void signalMousePositionChanged();
-
-    /** Do we need the renderer to send its frames to us? */
-    void requestAutoRefresh(bool);
-
-private:
-
-    /** Counts the number of frames that have been rendered in the active monitor.
-      The frame number will be reset when the calculation starts for the current frame. */
-    QAtomicInt m_newHUDFrames;
-    QAtomicInt m_newScopeFrames;
-    QAtomicInt m_newBackgroundFrames;
-
-    /** Counts the number of updates that, unlike new frames, force a recalculation
-      of the scope, like for example a resize event. */
-    QAtomicInt m_newHUDUpdates;
-    QAtomicInt m_newScopeUpdates;
-    QAtomicInt m_newBackgroundUpdates;
-
-    /** The semaphores ensure that the QFutures for the HUD/Scope/Background threads cannot
-      be assigned a new thread while it is still running. (Could cause deadlocks and other
-      nasty things known from parallelism.) */
-    QSemaphore m_semaphoreHUD;
-    QSemaphore m_semaphoreScope;
-    QSemaphore m_semaphoreBackground;
-
-    QFuture<QImage> m_threadHUD;
-    QFuture<QImage> m_threadScope;
-    QFuture<QImage> m_threadBackground;
-
-    bool initialDimensionUpdateDone;
-    bool m_requestForcedUpdate;
-
-    QImage m_scopeImage;
-
-    QString m_widgetName;
-
-    void prodHUDThread();
-    void prodScopeThread();
-    void prodBackgroundThread();
-
-public slots:
-    /** @brief Must be called when the active monitor has shown a new frame.
-      This slot must be connected in the implementing class, it is *not*
-      done in this abstract class. */
-    void slotActiveMonitorChanged(bool isClipMonitor);
-
-private slots:
-    void customContextMenuRequested(const QPoint &pos);
-    /** To be called when a new frame has been received.
-      The scope then decides whether and when it wants to recalculate the scope, depending
-      on whether it is currently visible and whether a calculation thread is already running. */
-    void slotRenderZoneUpdated();
-    void slotRenderZoneUpdated(QImage);
-    /** The following slots are called when rendering of a component has finished. They e.g. update
-      the widget and decide whether to immediately restart the calculation thread. */
-    void slotHUDRenderingFinished(uint mseconds, uint accelerationFactor);
-    void slotScopeRenderingFinished(uint mseconds, uint accelerationFactor);
-    void slotBackgroundRenderingFinished(uint mseconds, uint accelerationFactor);
-
-    /** Resets the acceleration factors to 1 when realtime rendering is disabled. */
-    void slotResetRealtimeFactor(bool realtimeChecked);
-
-};
-
-#endif // ABSTRACTGFXSCOPEWIDGET_H
index c72e584f554eb6a1b81db9b54054f37626b3a113..8b42676fa0f8654c4bb6dab4bc5ea100e0d13066 100644 (file)
@@ -33,10 +33,8 @@ const QPen AbstractScopeWidget::penLightDots(QBrush(QColor(200, 200, 250, 150)),
 const QPen AbstractScopeWidget::penDark(QBrush(QColor(0, 0, 20, 250)),      1, Qt::SolidLine);
 const QPen AbstractScopeWidget::penDarkDots(QBrush(QColor(0, 0, 20, 250)),      1, Qt::DotLine);
 
-AbstractScopeWidget::AbstractScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, bool trackMouse, QWidget *parent) :
+AbstractScopeWidget::AbstractScopeWidget(bool trackMouse, QWidget *parent) :
         QWidget(parent),
-        m_projMonitor(projMonitor),
-        m_clipMonitor(clipMonitor),
         m_mousePos(0, 0),
         m_mouseWithinWidget(false),
         offset(5),
@@ -72,14 +70,9 @@ AbstractScopeWidget::AbstractScopeWidget(Monitor *projMonitor, Monitor *clipMoni
 
     this->setContextMenuPolicy(Qt::CustomContextMenu);
 
-    m_activeRender = (m_clipMonitor->isActive()) ? m_clipMonitor->render : m_projMonitor->render;
-
     bool b = true;
     b &= connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint)));
 
-    //b &= connect(m_activeRender, SIGNAL(rendererPosition(int)), this, SLOT(slotRenderZoneUpdated()));
-    b &= connect(m_activeRender, SIGNAL(frameUpdated(QImage)), this, SLOT(slotRenderZoneUpdated(QImage)));
-
     b &= connect(this, SIGNAL(signalHUDRenderingFinished(uint, uint)), this, SLOT(slotHUDRenderingFinished(uint, uint)));
     b &= connect(this, SIGNAL(signalScopeRenderingFinished(uint, uint)), this, SLOT(slotScopeRenderingFinished(uint, uint)));
     b &= connect(this, SIGNAL(signalBackgroundRenderingFinished(uint, uint)), this, SLOT(slotBackgroundRenderingFinished(uint, uint)));
@@ -240,7 +233,6 @@ void AbstractScopeWidget::mouseReleaseEvent(QMouseEvent *event)
 {
     if (!m_aAutoRefresh->isChecked()) {
         m_requestForcedUpdate = true;
-        m_activeRender->sendFrameUpdate();
     }
     prodHUDThread();
     prodScopeThread();
@@ -388,25 +380,6 @@ void AbstractScopeWidget::slotBackgroundRenderingFinished(uint mseconds, uint ol
     }
 }
 
-void AbstractScopeWidget::slotActiveMonitorChanged(bool isClipMonitor)
-{
-//    qDebug() << "Active monitor has changed in " << m_widgetName << ". Is the clip monitor active now? " << isClipMonitor;
-
-    bool b = m_activeRender->disconnect(this);
-    Q_ASSERT(b);
-
-    m_activeRender = (isClipMonitor) ? m_clipMonitor->render : m_projMonitor->render;
-
-    //b &= connect(m_activeRender, SIGNAL(rendererPosition(int)), this, SLOT(slotRenderZoneUpdated()));
-    b &= connect(m_activeRender, SIGNAL(frameUpdated(QImage)), this, SLOT(slotRenderZoneUpdated(QImage)));
-    Q_ASSERT(b);
-
-    // Update the scope for the new monitor.
-    prodHUDThread();
-    prodScopeThread();
-    prodBackgroundThread();
-}
-
 void AbstractScopeWidget::slotRenderZoneUpdated()
 {
     m_newHUDFrames.fetchAndAddRelaxed(1);
@@ -449,11 +422,12 @@ bool AbstractScopeWidget::autoRefreshEnabled()
 
 void AbstractScopeWidget::slotAutoRefreshToggled(bool autoRefresh)
 {
-    if (isVisible()) emit requestAutoRefresh(autoRefresh);
+    if (isVisible()) {
+        emit requestAutoRefresh(autoRefresh);
+    }
     // TODO only if depends on input
     if (autoRefresh) {
         //forceUpdate();
         m_requestForcedUpdate = true;
-        m_activeRender->sendFrameUpdate();
     }
 }
index 9e28432af11938ffd625f231678ee403b10636dc..bee68863a02725d13f078122e5fe8d163d756393 100644 (file)
@@ -40,9 +40,6 @@
   The custom context menu already contains entries, like for enabling auto-
   refresh. It can certainly be extended in the implementation of the widget.
 
-  Note: Widgets deriving from this class should connect slotActiveMonitorChanged
-  to the appropriate signal.
-
   If you intend to write an own widget inheriting from this one, please read
   the comments on the unimplemented methods carefully. They are not only here
   for optical amusement, but also contain important information.
 
 class QMenu;
 
-class Monitor;
-class Render;
-
 class AbstractScopeWidget : public QWidget
 {
     Q_OBJECT
 
 public:
-    AbstractScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, bool trackMouse = false, QWidget *parent = 0);
+    AbstractScopeWidget(bool trackMouse = false, QWidget *parent = 0);
     virtual ~AbstractScopeWidget(); // Must be virtual because of inheritance, to avoid memory leaks
     QPalette m_scopePalette;
 
     /** Initializes widget settings (reads configuration).
       Has to be called in the implementing object. */
-    void init();
+    virtual void init();
 
     /** Does this scope have auto-refresh enabled */
     bool autoRefreshEnabled();
@@ -90,16 +84,11 @@ public:
 protected:
     ///// Variables /////
 
-    Monitor *m_projMonitor;
-    Monitor *m_clipMonitor;
-    Render *m_activeRender;
-
-
     /** The context menu. Feel free to add new entries in your implementation. */
     QMenu *m_menu;
 
     /** Enables auto refreshing of the scope.
-        This is when a new frame is shown on the active monitor.
+        This is when fresh data is incoming.
         Resize events always force a recalculation. */
     QAction *m_aAutoRefresh;
 
@@ -159,9 +148,9 @@ protected:
     /** @brief Background renderer. Must emit signalBackgroundRenderingFinished(). @see renderScope */
     virtual QImage renderBackground(uint accelerationFactor) = 0;
 
-    /** Must return true if the HUD layer depends on the input monitor.
+    /** Must return true if the HUD layer depends on the input data.
         If it does not, then it does not need to be re-calculated when
-        a new frame from the monitor is incoming. */
+        fresh data is incoming. */
     virtual bool isHUDDependingOnInput() const = 0;
     /** @see isHUDDependingOnInput() */
     virtual bool isScopeDependingOnInput() const = 0;
@@ -192,7 +181,7 @@ protected slots:
     void forceUpdateHUD();
     void forceUpdateScope();
     void forceUpdateBackground();
-    void slotAutoRefreshToggled(bool);
+    virtual void slotAutoRefreshToggled(bool);
 
 signals:
     /** mseconds represent the time taken for the calculation,
@@ -210,8 +199,8 @@ signals:
 
 private:
 
-    /** Counts the number of frames that have been rendered in the active monitor.
-      The frame number will be reset when the calculation starts for the current frame. */
+    /** Counts the number of data frames that have been rendered in the active monitor.
+      The frame number will be reset when the calculation starts for the current data set. */
     QAtomicInt m_newHUDFrames;
     QAtomicInt m_newScopeFrames;
     QAtomicInt m_newBackgroundFrames;
@@ -244,19 +233,13 @@ private:
     void prodScopeThread();
     void prodBackgroundThread();
 
-public slots:
-    /** @brief Must be called when the active monitor has shown a new frame.
-      This slot must be connected in the implementing class, it is *not*
-      done in this abstract class. */
-    void slotActiveMonitorChanged(bool isClipMonitor);
-
 protected slots:
     void customContextMenuRequested(const QPoint &pos);
     /** To be called when a new frame has been received.
       The scope then decides whether and when it wants to recalculate the scope, depending
       on whether it is currently visible and whether a calculation thread is already running. */
     void slotRenderZoneUpdated();
-    void slotRenderZoneUpdated(QImage);
+    void slotRenderZoneUpdated(QImage);//TODO remove
     /** The following slots are called when rendering of a component has finished. They e.g. update
       the widget and decide whether to immediately restart the calculation thread. */
     void slotHUDRenderingFinished(uint mseconds, uint accelerationFactor);
index 52f91b9a1b29ce910f00f9c476ecc080fd1bb657..9b703e305372826aa6f2da8871a51698f34a97cd 100644 (file)
@@ -21,8 +21,8 @@
 #include <QMouseEvent>
 #include <QPainter>
 
-AbstractAudioScopeWidget::AbstractAudioScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, bool trackMouse, QWidget *parent) :
-        AbstractScopeWidget(projMonitor, clipMonitor, trackMouse, parent)
+AbstractAudioScopeWidget::AbstractAudioScopeWidget(bool trackMouse, QWidget *parent) :
+        AbstractScopeWidget(trackMouse, parent)
 {
 }
 
@@ -33,7 +33,6 @@ void AbstractAudioScopeWidget::slotReceiveAudio(const QVector<int16_t>& sampleDa
     m_nChannels = num_channels;
     m_nSamples = num_samples;
     AbstractScopeWidget::slotRenderZoneUpdated();
-    //TODO
 }
 
 AbstractAudioScopeWidget::~AbstractAudioScopeWidget() {}
index e519e2a4398a6c2465bd82e53b3ce8a0229896f7..d8c262dc22ba98c2793d17e05c0f4c54d8dea6fe 100644 (file)
@@ -26,10 +26,11 @@ class AbstractAudioScopeWidget : public AbstractScopeWidget
 {
     Q_OBJECT
 public:
-    AbstractAudioScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, bool trackMouse = false, QWidget *parent = 0);
+    AbstractAudioScopeWidget(bool trackMouse = false, QWidget *parent = 0);
     virtual ~AbstractAudioScopeWidget();
 
 protected:
+    /** @brief This is just a wrapper function, subclasses can use renderAudioScope. */
     virtual QImage renderScope(uint accelerationFactor);
 
     ///// Unimplemented Methods /////
@@ -46,7 +47,7 @@ private:
     int m_nSamples;
 
 private slots:
-    void slotReceiveAudio(const QVector<int16_t>& sampleData, int freq, int num_channels, int num_samples); // NEW, TODO comment
+    void slotReceiveAudio(const QVector<int16_t>& sampleData, int freq, int num_channels, int num_samples);
 
 };
 
index b45bb9c896fe35d94bfc9e60db7c1f00431b74f1..e03497e94a6d82237bf6ad6e6e43020dc6c96b0e 100644 (file)
@@ -20,8 +20,8 @@
 
 bool fileWritten = false;
 
-AudioSpectrum::AudioSpectrum(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent) :
-        AbstractAudioScopeWidget(projMonitor, clipMonitor, true, parent)
+AudioSpectrum::AudioSpectrum(QWidget *parent) :
+        AbstractAudioScopeWidget(true, parent)
 {
     ui = new Ui::AudioSpectrum_UI;
     ui->setupUi(this);
index 205d120257b733780f4cd826d6c7736bf46074ad..9a65a6499bda827d063f02c8d57f557fed62ca57 100644 (file)
@@ -23,7 +23,7 @@ class AudioSpectrum : public AbstractAudioScopeWidget {
     Q_OBJECT
 
 public:
-    AudioSpectrum(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent = 0);
+    AudioSpectrum(QWidget *parent = 0);
     ~AudioSpectrum();
 
     // Implemented virtual methods
diff --git a/src/colorscopes/abstractgfxscopewidget.cpp b/src/colorscopes/abstractgfxscopewidget.cpp
new file mode 100644 (file)
index 0000000..509ea1d
--- /dev/null
@@ -0,0 +1,83 @@
+/***************************************************************************
+ *   Copyright (C) 2010 by Simon Andreas Eugster (simon.eu@gmail.com)      *
+ *   This file is part of kdenlive. See www.kdenlive.org.                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ ***************************************************************************/
+
+#include "qtconcurrentrun.h"
+
+#include "abstractgfxscopewidget.h"
+#include "renderer.h"
+#include "monitor.h"
+
+#include <QFuture>
+#include <QColor>
+#include <QMenu>
+#include <QMouseEvent>
+#include <QPainter>
+
+const int REALTIME_FPS = 30;
+
+AbstractGfxScopeWidget::AbstractGfxScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, bool trackMouse, QWidget *parent) :
+        AbstractScopeWidget(trackMouse, parent),
+        m_clipMonitor(clipMonitor),
+        m_projMonitor(projMonitor)
+
+{
+    m_activeRender = (m_clipMonitor->isActive()) ? m_clipMonitor->render : m_projMonitor->render;
+
+    bool b = true;
+    b &= connect(m_activeRender, SIGNAL(frameUpdated(QImage)), this, SLOT(slotRenderZoneUpdated(QImage)));
+    Q_ASSERT(b);
+}
+AbstractGfxScopeWidget::~AbstractGfxScopeWidget() { }
+
+QImage AbstractGfxScopeWidget::renderScope(uint accelerationFactor)
+{
+    return renderGfxScope(accelerationFactor, m_scopeImage);
+}
+
+void AbstractGfxScopeWidget::mouseReleaseEvent(QMouseEvent *event)
+{
+    if (!m_aAutoRefresh->isChecked()) {
+        m_activeRender->sendFrameUpdate();
+    }
+    AbstractScopeWidget::mouseReleaseEvent(event);
+}
+
+
+///// Slots /////
+
+void AbstractGfxScopeWidget::slotActiveMonitorChanged(bool isClipMonitor)
+{
+//    qDebug() << "Active monitor has changed in " << m_widgetName << ". Is the clip monitor active now? " << isClipMonitor;
+
+    bool b = m_activeRender->disconnect(this);
+    Q_ASSERT(b);
+
+    m_activeRender = (isClipMonitor) ? m_clipMonitor->render : m_projMonitor->render;
+
+    //b &= connect(m_activeRender, SIGNAL(rendererPosition(int)), this, SLOT(slotRenderZoneUpdated()));
+    b &= connect(m_activeRender, SIGNAL(frameUpdated(QImage)), this, SLOT(slotRenderZoneUpdated(QImage)));
+    Q_ASSERT(b);
+
+    // Update the scope for the new monitor.
+    forceUpdate(true);
+}
+
+void AbstractGfxScopeWidget::slotRenderZoneUpdated(QImage frame)
+{
+    m_scopeImage = frame;
+    AbstractScopeWidget::slotRenderZoneUpdated();
+}
+
+void AbstractGfxScopeWidget::slotAutoRefreshToggled(bool autoRefresh)
+{
+    if (autoRefresh) {
+        m_activeRender->sendFrameUpdate();
+    }
+}
diff --git a/src/colorscopes/abstractgfxscopewidget.h b/src/colorscopes/abstractgfxscopewidget.h
new file mode 100644 (file)
index 0000000..49c48d6
--- /dev/null
@@ -0,0 +1,66 @@
+/***************************************************************************
+ *   Copyright (C) 2010 by Simon Andreas Eugster (simon.eu@gmail.com)      *
+ *   This file is part of kdenlive. See www.kdenlive.org.                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ ***************************************************************************/
+
+#ifndef ABSTRACTGFXSCOPEWIDGET_H
+#define ABSTRACTGFXSCOPEWIDGET_H
+
+
+#include <QtCore>
+#include <QWidget>
+
+#include "abstractscopewidget.h"
+
+class QMenu;
+
+class Monitor;
+class Render;
+
+class AbstractGfxScopeWidget : public AbstractScopeWidget
+{
+    Q_OBJECT
+
+public:
+    AbstractGfxScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, bool trackMouse = false, QWidget *parent = 0);
+    virtual ~AbstractGfxScopeWidget(); // Must be virtual because of inheritance, to avoid memory leaks
+
+protected:
+    ///// Variables /////
+
+    Monitor *m_projMonitor;
+    Monitor *m_clipMonitor;
+    Render *m_activeRender;
+
+    /** @brief Scope renderer. Must emit signalScopeRenderingFinished()
+        when calculation has finished, to allow multi-threading.
+        accelerationFactor hints how much faster than usual the calculation should be accomplished, if possible. */
+    virtual QImage renderGfxScope(uint accelerationFactor, const QImage) = 0;
+
+    virtual QImage renderScope(uint accelerationFactor);
+
+    void mouseReleaseEvent(QMouseEvent *);
+
+private:
+    QImage m_scopeImage;
+
+public slots:
+    /** @brief Must be called when the active monitor has shown a new frame.
+      This slot must be connected in the implementing class, it is *not*
+      done in this abstract class. */
+    void slotActiveMonitorChanged(bool isClipMonitor);
+
+protected slots:
+    virtual void slotAutoRefreshToggled(bool autoRefresh);
+
+private slots:
+    void slotRenderZoneUpdated(QImage);
+
+};
+
+#endif // ABSTRACTGFXSCOPEWIDGET_H
similarity index 98%
rename from src/histogram.cpp
rename to src/colorscopes/histogram.cpp
index 4065b163346e9f211182fc6313fc7173c4d12cc5..d0042b6da68df67a9ae8a220bd4455461ca4f800 100644 (file)
@@ -109,7 +109,7 @@ QImage Histogram::renderHUD(uint)
     emit signalHUDRenderingFinished(0, 1);
     return QImage();
 }
-QImage Histogram::renderScope(uint accelFactor, const QImage qimage)
+QImage Histogram::renderGfxScope(uint accelFactor, const QImage qimage)
 {
     QTime start = QTime::currentTime();
     start.start();
similarity index 95%
rename from src/histogram.h
rename to src/colorscopes/histogram.h
index 7796899e49c08c0ac8d772d6761b10f187c28b78..81849a36699492ad348cb2820fded164336edb78 100644 (file)
@@ -40,7 +40,7 @@ private:
     bool isScopeDependingOnInput() const;
     bool isBackgroundDependingOnInput() const;
     QImage renderHUD(uint accelerationFactor);
-    QImage renderScope(uint accelerationFactor, const QImage);
+    QImage renderGfxScope(uint accelerationFactor, const QImage);
     QImage renderBackground(uint accelerationFactor);
     Ui::Histogram_UI *ui;
 
similarity index 98%
rename from src/rgbparade.cpp
rename to src/colorscopes/rgbparade.cpp
index 0ea40eea7cec205385d6608f89793bcf74fad4d8..2586cff8753d36dbfa25b9cb09fabb8f0d38b8db 100644 (file)
@@ -124,7 +124,7 @@ QImage RGBParade::renderHUD(uint)
     return hud;
 }
 
-QImage RGBParade::renderScope(uint accelerationFactor, const QImage qimage)
+QImage RGBParade::renderGfxScope(uint accelerationFactor, const QImage qimage)
 {
     QTime start = QTime::currentTime();
     start.start();
similarity index 95%
rename from src/rgbparade.h
rename to src/colorscopes/rgbparade.h
index 0fd42fe65a2d820181f07924f7f494547a026c70..a51b0453d43f08efa8530d4686e9605150ef29f1 100644 (file)
@@ -44,7 +44,7 @@ private:
     bool isBackgroundDependingOnInput() const;
 
     QImage renderHUD(uint accelerationFactor);
-    QImage renderScope(uint accelerationFactor, const QImage);
+    QImage renderGfxScope(uint accelerationFactor, const QImage);
     QImage renderBackground(uint accelerationFactor);
 };
 
similarity index 99%
rename from src/vectorscope.cpp
rename to src/colorscopes/vectorscope.cpp
index 729643e5abaad6e2f7d946c1ebc2ac5fc230100d..e7ffd0a8d2ea2ce362cda698798b37ada28856c5 100644 (file)
@@ -259,7 +259,7 @@ QImage Vectorscope::renderHUD(uint)
     return hud;
 }
 
-QImage Vectorscope::renderScope(uint accelerationFactor, const QImage qimage)
+QImage Vectorscope::renderGfxScope(uint accelerationFactor, const QImage qimage)
 {
     QTime start = QTime::currentTime();
     QImage scope;
similarity index 79%
rename from src/vectorscope.h
rename to src/colorscopes/vectorscope.h
index 66c660194ca6a322f3481a7f2ee146a5e0452562..38fa5a94698004b80ebd42a6c6582ecaf2c16fbc 100644 (file)
@@ -37,7 +37,7 @@ protected:
     ///// Implemented methods /////
     QRect scopeRect();
     QImage renderHUD(uint accelerationFactor);
-    QImage renderScope(uint accelerationFactor, const QImage);
+    QImage renderGfxScope(uint accelerationFactor, const QImage);
     QImage renderBackground(uint accelerationFactor);
     bool isHUDDependingOnInput() const;
     bool isScopeDependingOnInput() const;
@@ -79,18 +79,6 @@ private:
     void updateDimensions();
     int cw;
 
-    /** Counts the number of frames that have been rendered in one of the monitors.
-      The frame number will be reset when the vectorscope starts calculating the
-      current frame. */
-//    QAtomicInt newFrames;
-    /** Counts the number of other changes that should cause the vectorscope to be
-      recalculated. This is for example a resizeEvent. In this case, no new frames
-      are generated, but the scope has to be updated in any case (also if auto-update
-      is not enabled). */
-//    QAtomicInt newChanges;
-    /** Counts the number of changes concerning the background wheel */
-//    QAtomicInt newWheelChanges;
-
 
 private slots:
     void slotGainChanged(int);
similarity index 98%
rename from src/waveform.cpp
rename to src/colorscopes/waveform.cpp
index 27beee2e543f495f68885b6cee73a9c37326a96d..1dd6304ebe112d7b4c544f1d8477c3ab684e819c 100644 (file)
@@ -169,7 +169,7 @@ QImage Waveform::renderHUD(uint)
     return hud;
 }
 
-QImage Waveform::renderScope(uint accelFactor, const QImage qimage)
+QImage Waveform::renderGfxScope(uint accelFactor, const QImage qimage)
 {
     QTime start = QTime::currentTime();
     start.start();
similarity index 97%
rename from src/waveform.h
rename to src/colorscopes/waveform.h
index 45fde952003bb5c90f16cbd7676e58137545c070..f1d648ab62f9fb3bc420ff9e01b3962a2893e3cb 100644 (file)
@@ -47,7 +47,7 @@ private:
     /// Implemented methods ///
     QRect scopeRect();
     QImage renderHUD(uint);
-    QImage renderScope(uint, const QImage);
+    QImage renderGfxScope(uint, const QImage);
     QImage renderBackground(uint);
     bool isHUDDependingOnInput() const;
     bool isScopeDependingOnInput() const;
index dc40c9b5c8f4a8b478048519dd1553313651ad36..457fc9f626bcadd3d799a6360d7a2ffe20d9b92a 100644 (file)
 #include "kdenlive-config.h"
 #include "cliptranscode.h"
 #include "ui_templateclip_ui.h"
-#include "vectorscope.h"
-#include "waveform.h"
-#include "rgbparade.h"
-#include "histogram.h"
+#include "colorscopes/vectorscope.h"
+#include "colorscopes/waveform.h"
+#include "colorscopes/rgbparade.h"
+#include "colorscopes/histogram.h"
 #include "audiospectrum.h"
 
 #include <KApplication>
@@ -286,7 +286,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
         connect(m_clipMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
     }*/
 
-    m_audioSpectrum = new AudioSpectrum(m_projectMonitor, m_clipMonitor);
+    m_audioSpectrum = new AudioSpectrum();
     m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
     m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
     m_audioSpectrumDock->setWidget(m_audioSpectrum);