1 /*
2  * This file is part of Krita
3  *
4  * Copyright (c) 2006 Frederic Coiffier <fcoiffie@gmail.com>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef _KIS_LEVEL_FILTER_H_
22 #define _KIS_LEVEL_FILTER_H_
23 
24 #include "filter/kis_color_transformation_filter.h"
25 #include "kis_config_widget.h"
26 #include "ui_wdg_level.h"
27 
28 class WdgLevel;
29 class QWidget;
30 class KisHistogram;
31 
32 
33 /**
34  * This class affect Intensity Y of the image
35  */
36 class KisLevelFilter : public KisColorTransformationFilter
37 {
38 
39 public:
40 
41     KisLevelFilter();
42     ~KisLevelFilter() override;
43 
44 public:
45 
46 //     virtual KisFilterConfigurationSP factoryConfiguration() const;
47     KisConfigWidget * createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev, bool useForMasks) const override;
48 
49     KoColorTransformation* createTransformation(const KoColorSpace* cs, const KisFilterConfigurationSP config) const override;
50 
id()51     static inline KoID id() {
52         return KoID("levels", i18n("Levels"));
53     }
54 
55 };
56 
57 
58 class KisLevelConfigWidget : public KisConfigWidget
59 {
60     Q_OBJECT
61 public:
62     KisLevelConfigWidget(QWidget * parent, KisPaintDeviceSP dev);
63     ~KisLevelConfigWidget() override;
64 
65     KisPropertiesConfigurationSP configuration() const override;
66     void setConfiguration(const KisPropertiesConfigurationSP config) override;
67     Ui::WdgLevel m_page;
68 
69 protected Q_SLOTS:
70     void slotDrawHistogram(bool isLogarithmic);
71 
72     void slotModifyInBlackLimit(int);
73     void slotModifyInWhiteLimit(int);
74     void slotModifyOutBlackLimit(int);
75     void slotModifyOutWhiteLimit(int);
76 
77     void slotAutoLevel(void);
78     void slotInvert(void);
79 
80     void resetOutSpinLimit();
81 
82 protected:
83     QScopedPointer<KisHistogram> m_histogram;
84     bool m_isLogarithmic;
85     bool m_inverted;
86 };
87 
88 #endif
89