]> git.sesse.net Git - kdenlive/blob - src/colorscopes/abstractgfxscopewidget.cpp
Color scopes now using the common abstract scope as well. --> Common functions, more...
[kdenlive] / src / colorscopes / abstractgfxscopewidget.cpp
1 /***************************************************************************
2  *   Copyright (C) 2010 by Simon Andreas Eugster (simon.eu@gmail.com)      *
3  *   This file is part of kdenlive. See www.kdenlive.org.                  *
4  *                                                                         *
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  ***************************************************************************/
10
11 #include "qtconcurrentrun.h"
12
13 #include "abstractgfxscopewidget.h"
14 #include "renderer.h"
15 #include "monitor.h"
16
17 #include <QFuture>
18 #include <QColor>
19 #include <QMenu>
20 #include <QMouseEvent>
21 #include <QPainter>
22
23 const int REALTIME_FPS = 30;
24
25 AbstractGfxScopeWidget::AbstractGfxScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, bool trackMouse, QWidget *parent) :
26         AbstractScopeWidget(trackMouse, parent),
27         m_clipMonitor(clipMonitor),
28         m_projMonitor(projMonitor)
29
30 {
31     m_activeRender = (m_clipMonitor->isActive()) ? m_clipMonitor->render : m_projMonitor->render;
32
33     bool b = true;
34     b &= connect(m_activeRender, SIGNAL(frameUpdated(QImage)), this, SLOT(slotRenderZoneUpdated(QImage)));
35     Q_ASSERT(b);
36 }
37 AbstractGfxScopeWidget::~AbstractGfxScopeWidget() { }
38
39 QImage AbstractGfxScopeWidget::renderScope(uint accelerationFactor)
40 {
41     return renderGfxScope(accelerationFactor, m_scopeImage);
42 }
43
44 void AbstractGfxScopeWidget::mouseReleaseEvent(QMouseEvent *event)
45 {
46     if (!m_aAutoRefresh->isChecked()) {
47         m_activeRender->sendFrameUpdate();
48     }
49     AbstractScopeWidget::mouseReleaseEvent(event);
50 }
51
52
53 ///// Slots /////
54
55 void AbstractGfxScopeWidget::slotActiveMonitorChanged(bool isClipMonitor)
56 {
57 //    qDebug() << "Active monitor has changed in " << m_widgetName << ". Is the clip monitor active now? " << isClipMonitor;
58
59     bool b = m_activeRender->disconnect(this);
60     Q_ASSERT(b);
61
62     m_activeRender = (isClipMonitor) ? m_clipMonitor->render : m_projMonitor->render;
63
64     //b &= connect(m_activeRender, SIGNAL(rendererPosition(int)), this, SLOT(slotRenderZoneUpdated()));
65     b &= connect(m_activeRender, SIGNAL(frameUpdated(QImage)), this, SLOT(slotRenderZoneUpdated(QImage)));
66     Q_ASSERT(b);
67
68     // Update the scope for the new monitor.
69     forceUpdate(true);
70 }
71
72 void AbstractGfxScopeWidget::slotRenderZoneUpdated(QImage frame)
73 {
74     m_scopeImage = frame;
75     AbstractScopeWidget::slotRenderZoneUpdated();
76 }
77
78 void AbstractGfxScopeWidget::slotAutoRefreshToggled(bool autoRefresh)
79 {
80     if (autoRefresh) {
81         m_activeRender->sendFrameUpdate();
82     }
83 }