]> git.sesse.net Git - kdenlive/blob - src/vectorscope.h
e57bf36b8d62904de51c9e0091687e99b5313bee
[kdenlive] / src / vectorscope.h
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 #ifndef VECTORSCOPE_H
12 #define VECTORSCOPE_H
13
14 #include <QtCore>
15 #include "renderer.h"
16 #include "monitor.h"
17 #include "ui_vectorscope_ui.h"
18
19 class Render;
20 class Monitor;
21 class Vectorscope_UI;
22
23 enum PAINT_MODE { GREEN = 0, ORIG = 1, CHROMA = 2 };
24
25 class Vectorscope : public QWidget, public Ui::Vectorscope_UI {
26     Q_OBJECT
27
28 public:
29     Vectorscope(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent = 0);
30     ~Vectorscope();
31
32 protected:
33     void paintEvent(QPaintEvent *);
34     void resizeEvent(QResizeEvent *event);
35     void mousePressEvent(QMouseEvent *);
36     void mouseMoveEvent(QMouseEvent *event);
37
38 private:
39     Monitor *m_projMonitor;
40     Monitor *m_clipMonitor;
41     Render *m_activeRender;
42
43     /** How to represent the pixels on the scope (green, original color, ...) */
44     int iPaintMode;
45
46     float scaling;
47
48
49     QPoint mapToCanvas(QRect inside, QPointF point);
50
51     bool circleEnabled;
52     QPoint mousePos;
53
54     /** Updates the dimension. Only necessary when the widget has been resized. */
55     void updateDimensions();
56     bool initialDimensionUpdateDone;
57     QRect m_scopeRect;
58     int cw;
59
60
61     /** The vectorscope color distribution.
62         Class variable as calculated by a thread. */
63     QImage m_scope;
64
65     void calculateScope();
66     QFuture<void> m_scopeCalcThread;
67
68     /** Prods the Scope calculation thread. If it is running, do nothing. If it is not,
69       run a new thread.
70       Returns true if a new thread has been started. */
71     bool prodCalcThread();
72
73     /** Counts the number of frames that have been rendered in one of the monitors.
74       The frame number will be reset when the vectorscope starts calculating the
75       current frame. */
76     QAtomicInt newFrames;
77     /** Counts the number of other changes that should cause the vectorscope to be
78       recalculated. This is for example a resizeEvent. In this case, no new frames
79       are generated, but the scope has to be updated in any case (also if auto-update
80       is not enabled). */
81     QAtomicInt newChanges;
82
83 signals:
84     void signalScopeCalculationFinished();
85
86 private slots:
87     void slotMagnifyChanged();
88     void slotActiveMonitorChanged(bool isClipMonitor);
89     void slotRenderZoneUpdated();
90     void slotScopeCalculationFinished();
91     void slotUpdateScope();
92
93 };
94
95 #endif // VECTORSCOPE_H