File indexing completed on 2024-06-16 04:16:41

0001 /*
0002  * This file is part of Krita
0003  *
0004  * SPDX-FileCopyrightText: 2006 Frederic Coiffier <fcoiffie@gmail.com>
0005  * SPDX-FileCopyrightText: 2021 Deif Lou <ginoba@gmail.com>
0006  *
0007  * SPDX-License-Identifier: GPL-2.0-or-later
0008  */
0009 
0010 #ifndef KIS_LEVEL_CONFIG_WIDGET_H
0011 #define KIS_LEVEL_CONFIG_WIDGET_H
0012 
0013 #include <QPair>
0014 #include <QPolygonF>
0015 
0016 #include <kis_config_widget.h>
0017 #include <KisLevelsCurve.h>
0018 
0019 #include "../colorsfilters/virtual_channel_info.h"
0020 
0021 #include "ui_KisLevelsConfigWidget.h"
0022 
0023 class KisHistogram;
0024 class QWidget;
0025 class KisAutoLevelsWidget;
0026 
0027 class KisLevelsConfigWidget : public KisConfigWidget
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032     KisLevelsConfigWidget(QWidget * parent, KisPaintDeviceSP dev, const KoColorSpace* colorSpace);
0033     ~KisLevelsConfigWidget() override;
0034 
0035     KisPropertiesConfigurationSP configuration() const override;
0036     void setConfiguration(const KisPropertiesConfigurationSP config) override;
0037 
0038 private Q_SLOTS:
0039     void resetAll();
0040     void resetInputLevels();
0041     void resetOutputLevels();
0042     void resetAllChannels();
0043     void setActiveChannel(int ch);
0044 
0045     void slot_buttonGroupMode_buttonToggled(QAbstractButton *button, bool checked);
0046     void slot_comboBoxChannel_activated(int index);
0047     void slot_buttonGroupHistogramMode_buttonToggled(QAbstractButton *button, bool checked);
0048     void slot_spinBoxInputBlackPoint_valueChanged(int value);
0049     void slot_spinBoxInputWhitePoint_valueChanged(int value);
0050     void slot_spinBoxInputGamma_valueChanged(qreal value);
0051     void slot_spinBoxOutputBlackPoint_valueChanged(int value);
0052     void slot_spinBoxOutputWhitePoint_valueChanged(int value);
0053     void slot_sliderInputLevels_blackPointChanged(qreal value);
0054     void slot_sliderInputLevels_whitePointChanged(qreal value);
0055     void slot_sliderInputLevels_gammaChanged(qreal value);
0056     void slot_sliderOutputLevels_blackPointChanged(qreal value);
0057     void slot_sliderOutputLevels_whitePointChanged(qreal value);
0058     void slot_buttonAutoLevels_clicked();
0059     void slot_buttonAutoLevelsAllChannels_clicked();
0060     void slot_autoLevelsWidget_parametersChanged();
0061     void slot_autoLevelsWidgetAllChannels_parametersChanged();
0062 
0063     void computeChannelsMinMaxRanges();
0064     void updateWidgets();
0065     void updateHistograms();
0066     void updateHistogramViewChannels();
0067     void setButtonsIcons();
0068 
0069 private:
0070     Ui::LevelsConfigWidget m_page;
0071     KisPaintDeviceSP m_dev;
0072     const KoColorSpace *m_colorSpace;
0073     QVector<VirtualChannelInfo> m_virtualChannels;
0074     QVector<QPair<int, int>> m_virtualChannelsMinMaxRanges;
0075     QPair<int, int> m_lightnessMinMaxRanges;
0076     int m_activeChannel;
0077     int m_activeChannelMin, m_activeChannelMax;
0078     QVector<KisLevelsCurve> m_levelsCurves;
0079     KisLevelsCurve m_lightnessLevelsCurve;
0080     KisLevelsCurve *m_activeLevelsCurve;
0081     QScopedPointer<KisHistogram> m_channelsHistogram;
0082     QScopedPointer<KisHistogram> m_lightnessHistogram;
0083     KisAutoLevelsWidget *m_autoLevelsWidget;
0084 
0085     bool event(QEvent *e) override;
0086 };
0087 
0088 #endif