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);
42 Monitor *m_projMonitor;
43 Monitor *m_clipMonitor;
44 Render *m_activeRender;
46 ColorTools *m_colorTools;
47 ColorPlaneExport *m_colorPlaneExport;
49 QAction *m_aExportBackground;
50 QAction *m_aAxisEnabled;
54 /** How to represent the pixels on the scope (green, original color, ...) */
57 /** Custom scaling of the vectorscope */
60 /** Number of pixels to skip for getting realtime updates */
63 QPoint mapToCanvas(QRect inside, QPointF point);
64 QPoint centerPoint, pR75, pG75, pB75, pCy75, pMg75, pYl75;
69 /** Updates the dimension. Only necessary when the widget has been resized. */
70 void updateDimensions();
71 bool initialDimensionUpdateDone;
76 /** The vectorscope color distribution.
77 Class variable as calculated by a thread. */
81 void calculateScope();
82 QFuture<void> m_scopeCalcThread;
83 QFuture<QImage> m_wheelCalcThread;
85 /** This semaphore that guards QFuture m_scopeCalcThread is necessary for avoiding
86 deadlocks. If not present, then an incoming new frame might trigger a new thread
87 at the wrong point in time, causing a deadlock. Nasty ;) */
90 /** Prods the Scope calculation thread. If it is running, do nothing. If it is not,
92 Returns true if a new thread has been started. */
93 bool prodCalcThread();
94 bool prodWheelThread();
96 /** Counts the number of frames that have been rendered in one of the monitors.
97 The frame number will be reset when the vectorscope starts calculating the
100 /** Counts the number of other changes that should cause the vectorscope to be
101 recalculated. This is for example a resizeEvent. In this case, no new frames
102 are generated, but the scope has to be updated in any case (also if auto-update
104 QAtomicInt newChanges;
105 /** Counts the number of changes concerning the background wheel */
106 QAtomicInt newWheelChanges;
109 void signalScopeCalculationFinished(const unsigned int &mseconds, const unsigned int &skipPixels);
112 void slotMagnifyChanged();
113 void slotBackgroundChanged();
114 void slotActiveMonitorChanged(bool isClipMonitor);
115 void slotRenderZoneUpdated();
116 void slotScopeCalculationFinished(unsigned int mseconds, unsigned int skipPixels);
117 void slotWheelCalculationFinished();
118 void slotUpdateScope();
119 void slotUpdateWheel();
120 void slotExportBackground();
123 #endif // VECTORSCOPE_H