]> git.sesse.net Git - kdenlive/blob - src/vectorscope.h
Display Jpeg exif data in clip properties metadata
[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 "colorplaneexport.h"
18 #include "colortools.h"
19 #include "ui_vectorscope_ui.h"
20
21 class Render;
22 class Monitor;
23 class Vectorscope_UI;
24
25 enum PAINT_MODE { PAINT_GREEN = 0, PAINT_ORIG = 1, PAINT_CHROMA = 2, PAINT_YUV = 3, PAINT_BLACK = 4, PAINT_GREEN2 = 5 };
26 enum BACKGROUND_MODE { BG_NONE = 0, BG_YUV = 1, BG_CHROMA = 2 };
27
28 class Vectorscope : public QWidget, public Ui::Vectorscope_UI {
29     Q_OBJECT
30
31 public:
32     Vectorscope(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent = 0);
33     ~Vectorscope();
34
35 protected:
36     void paintEvent(QPaintEvent *);
37     void resizeEvent(QResizeEvent *event);
38     void mousePressEvent(QMouseEvent *);
39     void mouseMoveEvent(QMouseEvent *event);
40     void raise();
41
42 private:
43     Monitor *m_projMonitor;
44     Monitor *m_clipMonitor;
45     Render *m_activeRender;
46
47     ColorTools *m_colorTools;
48     ColorPlaneExport *m_colorPlaneExport;
49
50     QAction *m_aExportBackground;
51     QAction *m_aAxisEnabled;
52     QAction *m_a75PBox;
53     QAction *m_aRealtime;
54
55     /** How to represent the pixels on the scope (green, original color, ...) */
56     int iPaintMode;
57
58     /** Custom scaling of the vectorscope */
59     float m_scaling;
60
61     /** Number of pixels to skip for getting realtime updates */
62     int m_skipPixels;
63
64     QPoint mapToCanvas(QRect inside, QPointF point);
65     QPoint centerPoint, pR75, pG75, pB75, pCy75, pMg75, pYl75;
66
67     bool circleEnabled;
68     QPoint mousePos;
69
70     /** Updates the dimension. Only necessary when the widget has been resized. */
71     void updateDimensions();
72     bool initialDimensionUpdateDone;
73     QRect m_scopeRect;
74     int cw;
75
76
77     /** The vectorscope color distribution.
78         Class variable as calculated by a thread. */
79     QImage m_scope;
80     QImage m_wheel;
81
82     void calculateScope();
83     QFuture<void> m_scopeCalcThread;
84     QFuture<QImage> m_wheelCalcThread;
85
86     /** This semaphore that guards QFuture m_scopeCalcThread is necessary for avoiding
87         deadlocks. If not present, then an incoming new frame might trigger a new thread
88         at the wrong point in time, causing a deadlock. Nasty ;) */
89     QSemaphore semaphore;
90
91     /** Prods the Scope calculation thread. If it is running, do nothing. If it is not,
92       run a new thread.
93       Returns true if a new thread has been started. */
94     bool prodCalcThread();
95     bool prodWheelThread();
96
97     /** Counts the number of frames that have been rendered in one of the monitors.
98       The frame number will be reset when the vectorscope starts calculating the
99       current frame. */
100     QAtomicInt newFrames;
101     /** Counts the number of other changes that should cause the vectorscope to be
102       recalculated. This is for example a resizeEvent. In this case, no new frames
103       are generated, but the scope has to be updated in any case (also if auto-update
104       is not enabled). */
105     QAtomicInt newChanges;
106     /** Counts the number of changes concerning the background wheel */
107     QAtomicInt newWheelChanges;
108
109 signals:
110     void signalScopeCalculationFinished(const unsigned int &mseconds, const unsigned int &skipPixels);
111
112 private slots:
113     void slotMagnifyChanged();
114     void slotBackgroundChanged();
115     void slotActiveMonitorChanged(bool isClipMonitor);
116     void slotRenderZoneUpdated();
117     void slotScopeCalculationFinished(unsigned int mseconds, unsigned int skipPixels);
118     void slotWheelCalculationFinished();
119     void slotUpdateScope();
120     void slotUpdateWheel();
121     void slotExportBackground();
122 };
123
124 #endif // VECTORSCOPE_H