Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_perchannel_filter.cpp
Go to the documentation of this file.
1/*
2 * This file is part of Krita
3 *
4 * SPDX-FileCopyrightText: 2005 C. Boemann <cbo@boemann.dk>
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
10
11#include <Qt>
12#include <QLayout>
13#include <QPixmap>
14#include <QPainter>
15#include <QDomDocument>
16#include <QHBoxLayout>
17
18#include "KoChannelInfo.h"
21#include "KoColorSpace.h"
24#include "KoCompositeOp.h"
25#include "KoID.h"
26
27#include "kis_signals_blocker.h"
28
30#include "kis_config_widget.h"
32#include <kis_selection.h>
33#include <kis_paint_device.h>
35
36#include "kis_histogram.h"
37#include "kis_painter.h"
40
42
44 : KisMultiChannelConfigWidget(parent, dev, f)
45{
46 init();
47
48 // These are not used by this filter,
49 // but the dialog is shared with KisCrossChannelFilter
50 m_page->lblDriverChannel->hide();
51 m_page->cmbDriverChannel->hide();
52}
53
56
57#define BITS_PER_BYTE 8
58#define pwr2(p) (1<<p)
60{
61 // Getting range accepted by channel
63
64 KoChannelInfo::enumChannelValueType valueType = currentVChannel.valueType();
65
66 int order = BITS_PER_BYTE * currentVChannel.channelSize();
67 int maxValue = pwr2(order);
68 int min;
69 int max;
70
72
73 switch (valueType) {
77 min = 0;
78 max = maxValue - 1;
79 break;
82 min = -maxValue / 2;
83 max = maxValue / 2 - 1;
84 break;
88 default:
89 //Hack Alert: should be changed to float
92 const QList<KoChannelInfo*> channels = m_dev->colorSpace()->channels();
93 min = channels[m_activeVChannel]->getUIMin();
94 max = channels[m_activeVChannel]->getUIMax();
95 } else {
96 // it must be "Hue", "Saturation" or other "channel" that isn't actually accessible in the color space
97 min = 0;
98 // specific number apparently doesn't matter,
99 // if there is 255, it will work just fine, too
100 max = 100;
101 }
102 } else {
103 min = 0;
104 max = 100;
105 }
106 break;
107 }
108
110 m_page->intIn, m_page->intOut, min, max, min, max));
111}
112
113
115{
116 const int numChannels = m_virtualChannels.size();
117
120
121 KIS_ASSERT_RECOVER(m_activeVChannel < m_curves.size()) { return cfg; }
122
123 cfg->setCurves(m_curves);
124 cfg->setActiveCurve(m_activeVChannel);
125
126 return cfg;
127}
128
133
135 : KisMultiChannelFilterConfiguration(channelCount, "perchannel", 1, resourcesInterface)
136{
137 init();
138}
139
144
148
153
158
159// KisPerChannelFilter
160
161KisPerChannelFilter::KisPerChannelFilter() : KisMultiChannelFilter(id(), i18n("&Color Adjustment curves..."))
162{
163 setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
164}
165
167{
168 return new KisPerChannelConfigWidget(parent, dev);
169}
170
175
177{
178 const KisPerChannelFilterConfiguration* configBC =
179 dynamic_cast<const KisPerChannelFilterConfiguration*>(config.data()); // Somehow, this shouldn't happen
180 Q_ASSERT(configBC);
181
182 QList<bool> isIdentityList;
183 for (const KisCubicCurve &curve : configBC->curves()) {
184 isIdentityList.append(curve.isIdentity());
185 }
186
188}
KisCurveWidgetControlsManager< QSpinBox > KisCurveWidgetControlsManagerInt
const KoID CMYKAColorModelID("CMYKA", ki18n("CMYK/Alpha"))
const KoID LABAColorModelID("LABA", ki18n("L*a*b*/Alpha"))
static KisResourcesInterfaceSP instance()
QVector< VirtualChannelInfo > m_virtualChannels
const QVector< QVector< quint16 > > & transfers() const
const QList< KisCubicCurve > & curves() const
const KoColorSpace * colorSpace() const
QScopedPointer< KisCurveWidgetControlsManagerInt > m_curveControlsManager
KisPropertiesConfigurationSP configuration() const override
virtual KisPropertiesConfigurationSP getDefaultConfiguration() override
KisPerChannelConfigWidget(QWidget *parent, KisPaintDeviceSP dev, Qt::WindowFlags f=Qt::WindowFlags())
KisPerChannelFilterConfiguration(int channelCount, KisResourcesInterfaceSP resourcesInterface)
KisFilterConfigurationSP clone() const override
KisFilterConfigurationSP factoryConfiguration(KisResourcesInterfaceSP resourcesInterface) const override
KisConfigWidget * createConfigurationWidget(QWidget *parent, const KisPaintDeviceSP dev, bool useForMasks) const override
KoColorTransformation * createTransformation(const KoColorSpace *cs, const KisFilterConfigurationSP config) const override
enumChannelValueType
enum to define the value of the channel
@ UINT8
use this for an unsigned integer 8bits channel
@ UINT16
use this for an integer 16bits channel
@ INT16
use this for an integer 16bits channel
@ INT8
use this for an integer 8bits channel
@ FLOAT32
use this for a float 32bits channel
@ FLOAT16
use this for a float 16bits channel
@ UINT32
use this for an unsigned integer 21bits channel
@ FLOAT64
use this for a float 64bits channel
QList< KoChannelInfo * > channels
virtual KoID colorModelId() const =0
virtual quint32 channelCount() const =0
KoChannelInfo::enumChannelValueType valueType() const
#define KIS_ASSERT_RECOVER(cond)
Definition kis_assert.h:55
#define BITS_PER_BYTE
#define pwr2(p)
KoColorTransformation * createPerChannelTransformationFromTransfers(const KoColorSpace *cs, const QVector< QVector< quint16 > > &transfers, const QList< bool > &transferIsIdentity)
Create a composed per channel transformation object from the set of given transfers.
void setShortcut(const QKeySequence &shortcut)