Changeset View
Changeset View
Standalone View
Standalone View
plugins/dockers/histogram/histogramdockerwidget.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (c) 2016 Eugene Ingerman <geneing at gmail dot com> | ||||
3 | * | ||||
4 | * This library is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU Lesser General Public License as published by | ||||
6 | * the Free Software Foundation; version 2.1 of the License. | ||||
7 | * | ||||
8 | * This library is distributed in the hope that it will be useful, | ||||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
11 | * GNU Lesser General Public License for more details. | ||||
12 | * | ||||
13 | * You should have received a copy of the GNU Lesser General Public License | ||||
14 | * along with this program; if not, write to the Free Software | ||||
15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
16 | */ | ||||
17 | | ||||
18 | | ||||
19 | #ifndef HISTOGRAMDOCKERWIDGET_H | ||||
20 | #define HISTOGRAMDOCKERWIDGET_H | ||||
21 | | ||||
22 | #include <QObject> | ||||
23 | #include <QWidget> | ||||
24 | #include <QLabel> | ||||
25 | #include <QThread> | ||||
26 | #include "kis_types.h" | ||||
27 | #include <vector> | ||||
28 | | ||||
29 | class KisCanvas2; | ||||
30 | | ||||
31 | typedef std::vector<std::vector<quint32> > HistVector; //Don't use QVector here - it's too slow for this purpose | ||||
32 | | ||||
33 | | ||||
34 | class HistogramComputationThread : public QThread | ||||
35 | { | ||||
36 | Q_OBJECT | ||||
37 | public: | ||||
38 | HistogramComputationThread(KisPaintDeviceSP _dev, const QRect& _bounds) : m_dev(_dev), m_bounds(_bounds) | ||||
39 | {} | ||||
40 | | ||||
41 | void run() Q_DECL_OVERRIDE; | ||||
42 | | ||||
43 | Q_SIGNALS: | ||||
44 | void resultReady(HistVector*); | ||||
45 | | ||||
46 | private: | ||||
47 | KisPaintDeviceSP m_dev; | ||||
48 | QRect m_bounds; | ||||
49 | HistVector bins; | ||||
50 | }; | ||||
51 | | ||||
52 | | ||||
53 | class HistogramDockerWidget : public QLabel | ||||
54 | { | ||||
55 | Q_OBJECT | ||||
56 | | ||||
57 | public: | ||||
58 | HistogramDockerWidget(QWidget *parent = 0, const char *name = 0, Qt::WindowFlags f = 0); | ||||
59 | ~HistogramDockerWidget(); | ||||
60 | void setPaintDevice(KisCanvas2* canvas); | ||||
61 | void paintEvent(QPaintEvent *event); | ||||
62 | | ||||
63 | public Q_SLOTS: | ||||
64 | void updateHistogram(); | ||||
65 | void receiveNewHistogram(HistVector*); | ||||
66 | | ||||
67 | private: | ||||
68 | KisPaintDeviceSP m_paintDevice; | ||||
69 | HistVector m_histogramData; | ||||
70 | QRect m_bounds; | ||||
71 | bool m_smoothHistogram; | ||||
72 | }; | ||||
73 | | ||||
74 | #endif // HISTOGRAMDOCKERWIDGET_H |