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 ***************************************************************************/
17 #include "colorplaneexport.h"
18 #include "colortools.h"
19 #include "ui_vectorscope_ui.h"
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 };
28 class Vectorscope : public QWidget, public Ui::Vectorscope_UI {
32 Vectorscope(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent = 0);
36 void paintEvent(QPaintEvent *);
37 void resizeEvent(QResizeEvent *event);
38 void mousePressEvent(QMouseEvent *);
39 void mouseMoveEvent(QMouseEvent *event);
43 Monitor *m_projMonitor;
44 Monitor *m_clipMonitor;
45 Render *m_activeRender;
47 ColorTools *m_colorTools;
48 ColorPlaneExport *m_colorPlaneExport;
50 QAction *m_aExportBackground;
51 QAction *m_aAxisEnabled;
55 /** How to represent the pixels on the scope (green, original color, ...) */
58 /** Custom scaling of the vectorscope */
61 /** Number of pixels to skip for getting realtime updates */
64 QPoint mapToCanvas(QRect inside, QPointF point);
65 QPoint centerPoint, pR75, pG75, pB75, pCy75, pMg75, pYl75;
70 /** Updates the dimension. Only necessary when the widget has been resized. */
71 void updateDimensions();
72 bool initialDimensionUpdateDone;
77 /** The vectorscope color distribution.
78 Class variable as calculated by a thread. */
82 void calculateScope();
83 QFuture<void> m_scopeCalcThread;
84 QFuture<QImage> m_wheelCalcThread;
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 ;) */
91 /** Prods the Scope calculation thread. If it is running, do nothing. If it is not,
93 Returns true if a new thread has been started. */
94 bool prodCalcThread();
95 bool prodWheelThread();
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
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
105 QAtomicInt newChanges;
106 /** Counts the number of changes concerning the background wheel */
107 QAtomicInt newWheelChanges;
110 void signalScopeCalculationFinished(const unsigned int &mseconds, const unsigned int &skipPixels);
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();
124 #endif // VECTORSCOPE_H