Krita Source Code Documentation
Loading...
Searching...
No Matches
KisLevelsFilterConfiguration Class Reference

#include <KisLevelsFilterConfiguration.h>

+ Inheritance diagram for KisLevelsFilterConfiguration:

Public Member Functions

KisFilterConfigurationSP clone () const override
 
virtual void fromLegacyXML (const QDomElement &)
 
void fromLegacyXML (const QDomElement &root) override
 
void fromXML (const QDomElement &) override
 
void fromXML (const QDomElement &) override
 
void fromXML (const QDomElement &e) override
 
bool fromXML (const QString &xml, bool clear=true) override
 
bool isCompatible (const KisPaintDeviceSP) const override
 
 KisLevelsFilterConfiguration (const KisLevelsFilterConfiguration &rhs)
 
 KisLevelsFilterConfiguration (int channelCount, KisResourcesInterfaceSP resourcesInterface)
 
 KisLevelsFilterConfiguration (int channelCount, qint32 version, KisResourcesInterfaceSP resourcesInterface)
 
const QVector< KisLevelsCurvelevelsCurves () const
 
const KisLevelsCurve lightnessLevelsCurve () const
 
const QVector< quint16 > & lightnessTransfer () const
 
void setDefaults ()
 
void setLevelsCurves (const QVector< KisLevelsCurve > &newLevelsCurves)
 
void setLightnessLevelsCurve (const KisLevelsCurve &newLightnessLevelsCurve)
 
void setProperty (const QString &name, const QVariant &value) override
 
void setShowLogarithmicHistogram (bool newShowLogarithmicHistogram)
 
void setUseLightnessMode (bool newUseLightnessMode)
 
bool showLogarithmicHistogram () const
 
QString toXML () const override
 
void toXML (QDomDocument &, QDomElement &) const override
 
void toXML (QDomDocument &, QDomElement &) const override
 
void toXML (QDomDocument &doc, QDomElement &root) const override
 
const QVector< QVector< quint16 > > & transfers () const
 
bool useLightnessMode () const
 
- Public Member Functions inherited from KisColorTransformationConfiguration
KoColorTransformationcolorTransformation (const KoColorSpace *cs, const KisColorTransformationFilter *filter) const
 
void destroyCache ()
 
void invalidateColorTransformationCache ()
 Manually invalidate the cache. By default setProperty invalidates the cache but this method can be used in subclasses when setProperty is not used to set options. This forces the regeneration of the color transforms.
 
 KisColorTransformationConfiguration (const KisColorTransformationConfiguration &rhs)
 
 KisColorTransformationConfiguration (const QString &name, qint32 version, KisResourcesInterfaceSP resourcesInterface)
 
 Private ()
 
 ~KisColorTransformationConfiguration () override
 
 ~Private ()
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisFilterConfiguration
QBitArray channelFlags () const
 
KisFilterConfigurationSP cloneWithResourcesSnapshot (KisResourcesInterfaceSP globalResourcesInterface=nullptr) const
 
virtual bool compareTo (const KisPropertiesConfiguration *rhs) const override
 
void createLocalResourcesSnapshot (KisResourcesInterfaceSP globalResourcesInterface=nullptr)
 
virtual QList< KoResourceLoadResultembeddedResources (KisResourcesInterfaceSP globalResourcesInterface) const
 
bool hasLocalResourcesSnapshot () const
 
 KisFilterConfiguration (const QString &name, qint32 version, KisResourcesInterfaceSP resourcesInterface)
 
virtual QList< KoResourceLoadResultlinkedResources (KisResourcesInterfaceSP globalResourcesInterface) const
 
const QString & name () const
 
 Private (const Private &rhs)
 
 Private (const QString &_name, qint32 _version, KisResourcesInterfaceSP _resourcesInterface)
 
QList< KoResourceLoadResultrequiredResources (KisResourcesInterfaceSP globalResourcesInterface) const
 
KisResourcesInterfaceSP resourcesInterface () const
 
void setChannelFlags (QBitArray channelFlags)
 
virtual void setResourcesInterface (KisResourcesInterfaceSP resourcesInterface)
 
qint32 version () const
 
 ~KisFilterConfiguration () override
 
- Public Member Functions inherited from KisPropertiesConfiguration
void clearProperties ()
 Clear the map of properties.
 
virtual void dump () const
 
void fromXML (const QDomElement &) override
 
bool fromXML (const QString &xml, bool clear=true) override
 
bool getBool (const QString &name, bool def=false) const
 
KoColor getColor (const QString &name, const KoColor &color=KoColor()) const
 getColor fetch the given property as a KoColor.
 
KisCubicCurve getCubicCurve (const QString &name, const KisCubicCurve &curve=KisCubicCurve()) const
 
double getDouble (const QString &name, double def=0.0) const
 
float getFloat (const QString &name, float def=0.0) const
 
int getInt (const QString &name, int def=0) const
 
void getPrefixedProperties (const QString &prefix, KisPropertiesConfiguration *config) const
 
void getPrefixedProperties (const QString &prefix, KisPropertiesConfigurationSP config) const
 
virtual QMap< QString, QVariant > getProperties () const
 
virtual QList< QString > getPropertiesKeys () const
 
virtual QVariant getProperty (const QString &name) const
 
virtual bool getProperty (const QString &name, QVariant &value) const
 
QString getPropertyLazy (const QString &name, const char *defaultValue) const
 
QStringList getPropertyLazy (const QString &name, const QStringList &defaultValue) const
 
template<typename T >
getPropertyLazy (const QString &name, const T &defaultValue) const
 
QString getString (const QString &name, const QString &def=QString()) const
 
QStringList getStringList (const QString &name, const QStringList &defaultValue=QStringList()) const
 
virtual bool hasProperty (const QString &name) const
 
 KisPropertiesConfiguration ()
 
 KisPropertiesConfiguration (const KisPropertiesConfiguration &rhs)
 
KisPropertiesConfigurationoperator= (const KisPropertiesConfiguration &rhs)
 
void removeProperty (const QString &name)
 
void setPrefixedProperties (const QString &prefix, const KisPropertiesConfiguration *config)
 
void setPrefixedProperties (const QString &prefix, const KisPropertiesConfigurationSP config)
 
void setProperty (const QString &name, const QStringList &value)
 
void setPropertyNotSaved (const QString &name)
 Marks a property that should not be saved by toXML.
 
QString toXML () const override
 
void toXML (QDomDocument &, QDomElement &) const override
 
 ~KisPropertiesConfiguration () override
 
- Public Member Functions inherited from KisSerializableConfiguration
 KisSerializableConfiguration ()
 
 KisSerializableConfiguration (const KisSerializableConfiguration &rhs)
 
virtual ~KisSerializableConfiguration ()
 
- Public Member Functions inherited from KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 

Static Public Member Functions

static KisLevelsCurve defaultLevelsCurve ()
 
static QString defaultName ()
 
static constexpr bool defaultShowLogarithmicHistogram ()
 
static constexpr bool defaultUseLightnessMode ()
 
static constexpr qint32 defaultVersion ()
 
- Static Public Member Functions inherited from KisPropertiesConfiguration
static QString escapeString (const QString &string)
 
static QString extractedPrefixKey ()
 
static QString unescapeString (const QString &string)
 

Private Member Functions

int channelCount () const
 
void setChannelCount (int newChannelCount)
 
void setLegacyValuesFromLightnessLevelsCurve ()
 
void setLightessLevelsCurveFromLegacyValues ()
 
void updateLightnessTransfer ()
 
void updateTransfers ()
 

Private Attributes

QVector< quint16 > m_lightnessTransfer
 
QVector< QVector< quint16 > > m_transfers
 

Additional Inherited Members

- Public Attributes inherited from KisColorTransformationConfiguration
QMap< QThread *, KoColorTransformation * > colorTransformation
 
QMutex mutex
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- Public Attributes inherited from KisFilterConfiguration
QBitArray channelFlags
 
QString name
 
KisResourcesInterfaceSP resourcesInterface = 0
 
qint32 version
 
- Public Attributes inherited from KisPropertiesConfiguration
QSet< QString > notSavedProperties
 
QMap< QString, QVariant > properties
 
- Protected Member Functions inherited from KisFilterConfiguration
 KisFilterConfiguration (const KisFilterConfiguration &rhs)
 
void setVersion (qint32 version)
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 

Detailed Description

Definition at line 16 of file KisLevelsFilterConfiguration.h.

Constructor & Destructor Documentation

◆ KisLevelsFilterConfiguration() [1/3]

KisLevelsFilterConfiguration::KisLevelsFilterConfiguration ( int channelCount,
qint32 version,
KisResourcesInterfaceSP resourcesInterface )

◆ KisLevelsFilterConfiguration() [2/3]

KisLevelsFilterConfiguration::KisLevelsFilterConfiguration ( int channelCount,
KisResourcesInterfaceSP resourcesInterface )

Definition at line 23 of file KisLevelsFilterConfiguration.cpp.

25{}
KisLevelsFilterConfiguration(int channelCount, qint32 version, KisResourcesInterfaceSP resourcesInterface)

◆ KisLevelsFilterConfiguration() [3/3]

KisLevelsFilterConfiguration::KisLevelsFilterConfiguration ( const KisLevelsFilterConfiguration & rhs)

Member Function Documentation

◆ channelCount()

int KisLevelsFilterConfiguration::channelCount ( ) const
private

Definition at line 198 of file KisLevelsFilterConfiguration.cpp.

199{
200 return getInt("number_of_channels", 0);
201}
int getInt(const QString &name, int def=0) const

References KisPropertiesConfiguration::getInt().

◆ clone()

KisFilterConfigurationSP KisLevelsFilterConfiguration::clone ( ) const
overridevirtual
Returns
an exact copy of the filter configuration. Resources interface is becomes shared between two configuration objects.

Reimplemented from KisColorTransformationConfiguration.

Definition at line 33 of file KisLevelsFilterConfiguration.cpp.

34{
35 return new KisLevelsFilterConfiguration(*this);
36}

References KisLevelsFilterConfiguration().

◆ defaultLevelsCurve()

static KisLevelsCurve KisLevelsFilterConfiguration::defaultLevelsCurve ( )
inlinestatic

Definition at line 27 of file KisLevelsFilterConfiguration.h.

27{ return KisLevelsCurve(); }
This class holds the parameters for a levels adjustment. It is modeled after KisCubicCurve and has si...

◆ defaultName()

static QString KisLevelsFilterConfiguration::defaultName ( )
inlinestatic

Definition at line 25 of file KisLevelsFilterConfiguration.h.

25{ return "levels"; }

◆ defaultShowLogarithmicHistogram()

static constexpr bool KisLevelsFilterConfiguration::defaultShowLogarithmicHistogram ( )
inlinestaticconstexpr

Definition at line 29 of file KisLevelsFilterConfiguration.h.

29{ return false; }

◆ defaultUseLightnessMode()

static constexpr bool KisLevelsFilterConfiguration::defaultUseLightnessMode ( )
inlinestaticconstexpr

Definition at line 28 of file KisLevelsFilterConfiguration.h.

28{ return true; }

◆ defaultVersion()

static constexpr qint32 KisLevelsFilterConfiguration::defaultVersion ( )
inlinestaticconstexpr

Definition at line 26 of file KisLevelsFilterConfiguration.h.

26{ return 2; }

◆ fromLegacyXML() [1/2]

void KisFilterConfiguration::fromLegacyXML ( const QDomElement & root)
virtual

This function is use to convert from legacy XML as used in .kra file.

Reimplemented from KisFilterConfiguration.

Definition at line 72 of file kis_filter_configuration.cc.

73{
75 d->name = root.attribute("name");
76 d->version = root.attribute("version").toInt();
77
78 QDomElement e;
79 for (e = root.firstChildElement("property"); !e.isNull(); e = e.nextSiblingElement()) {
80 QString name = e.attribute("name");
81 QString type = e.attribute("type");
82 QString value = e.text();
83
84 // XXX: Convert the variant pro-actively to the right type?
85 setProperty(name, QVariant(value));
86 }
87}
float value(const T *src, size_t ch)
void setProperty(const QString &name, const QVariant &value) override
void clearProperties()
Clear the map of properties.

◆ fromLegacyXML() [2/2]

void KisLevelsFilterConfiguration::fromLegacyXML ( const QDomElement & root)
overridevirtual

This function is use to convert from legacy XML as used in .kra file.

Reimplemented from KisFilterConfiguration.

Definition at line 208 of file KisLevelsFilterConfiguration.cpp.

209{
210 fromXML(root);
211}
void fromXML(const QDomElement &e) override

References fromXML().

◆ fromXML() [1/4]

void KisPropertiesConfiguration::fromXML ( const QDomElement & root)
overridevirtual

Fill the properties configuration object from the XML encoded representation in s. This function use the "Legacy" style XML of the 1.x .kra file format.

Note: the existing properties will not be cleared

Reimplemented from KisFilterConfiguration.

Definition at line 74 of file kis_properties_configuration.cc.

71{
72 QDomElement e;
73 for (e = root.firstChildElement("param"); !e.isNull(); e = e.nextSiblingElement("param")) {
74 QString name = e.attribute("name");
75 QString value = e.text();
76
77 // Older versions didn't have a "type" parameter,
78 // so fall back to the old behavior if it's missing.
79 if (!e.hasAttribute("type")) {
80 d->properties[name] = QVariant(value);
81 } else if (e.attribute("type") == "bytearray") {
82 d->properties[name] = QVariant(QByteArray::fromBase64(value.toLatin1()));
83 } else {
84 d->properties[name] = value;
85 }
86 }
87}

◆ fromXML() [2/4]

void KisFilterConfiguration::fromXML ( const QDomElement & )
overridevirtual

Fill the object from the XML encoded representation in s.

Reimplemented from KisFilterConfiguration.

Definition at line 77 of file kis_filter_configuration.cc.

90{
91 d->version = elt.attribute("version").toInt();
93}
bool fromXML(const QString &xml, bool clear=true) override

◆ fromXML() [3/4]

void KisLevelsFilterConfiguration::fromXML ( const QDomElement & )
overridevirtual

Fill the object from the XML encoded representation in s.

Reimplemented from KisFilterConfiguration.

Definition at line 213 of file KisLevelsFilterConfiguration.cpp.

214{
215 int version;
216 version = root.attribute("version").toInt();
217
218 QDomElement e = root.firstChild().toElement();
219 QString attributeName;
222 bool lightnessMode = defaultUseLightnessMode();
223 bool logarithmicHistogram = defaultShowLogarithmicHistogram();
224
225 if (version == 1) {
226 while (!e.isNull()) {
227 attributeName = e.attribute("name");
228 if (attributeName == "gammavalue") {
229 const double value = KisDomUtils::toDouble(e.text());
231 } else {
232 const double value = KisDomUtils::toDouble(e.text()) / 255.0;
233 if (attributeName == "blackvalue") {
235 } else if (attributeName == "whitevalue") {
237 } else if (attributeName == "outblackvalue") {
239 } else if (attributeName == "outwhitevalue") {
241 }
242 }
243 e = e.nextSiblingElement();
244 }
245 } else if (version == 2) {
246 int numChannels = 0;
247 QHash<int, KisLevelsCurve> unsortedLevelsCurves;
248 KisLevelsCurve levelsCurve;
249
250 while (!e.isNull()) {
251 attributeName = e.attribute("name");
252 if (attributeName == "mode") {
253 lightnessMode = e.text() != "channels";
254 } else if (attributeName == "histogram_mode") {
255 logarithmicHistogram = e.text() == "logarithmic";
256 } else if (attributeName == "lightness") {
258 } else if (attributeName == "number_of_channels") {
259 numChannels = e.text().toInt();
260 } else {
261 const QRegularExpression rx("channel_(\\d+)");
262 const QRegularExpressionMatch match = rx.match(attributeName);
263 if (match.hasMatch()) {
264 const int index = match.captured(1).toInt();
265 if (!e.text().isEmpty()) {
266 levelsCurve.fromString(e.text());
267 unsortedLevelsCurves[index] = levelsCurve;
268 }
269 }
270 }
271 e = e.nextSiblingElement();
272 }
273
274 for (int i = 0; i < numChannels; ++i) {
275 if (unsortedLevelsCurves.contains(i)) {
276 levelsCurves.append(unsortedLevelsCurves[i]);
277 } else {
279 }
280 }
281 }
282
286 setUseLightnessMode(lightnessMode);
287 setShowLogarithmicHistogram(logarithmicHistogram);
288}
void setOutputBlackPoint(qreal newOutputBlackPoint)
Set the output black point.
void setOutputWhitePoint(qreal newOutputWhitePoint)
Set the output white point.
void setInputGamma(qreal newInputGamma)
Set the gamma value.
void setInputWhitePoint(qreal newInputWhitePoint)
Set the input white point.
void fromString(const QString &text, bool *ok=nullptr)
Parses the parameters from a given text.
void setInputBlackPoint(qreal newInputBlackPoint)
Set the input black point.
void setLevelsCurves(const QVector< KisLevelsCurve > &newLevelsCurves)
const KisLevelsCurve lightnessLevelsCurve() const
static constexpr bool defaultShowLogarithmicHistogram()
void setShowLogarithmicHistogram(bool newShowLogarithmicHistogram)
static constexpr bool defaultUseLightnessMode()
const QVector< KisLevelsCurve > levelsCurves() const
void setUseLightnessMode(bool newUseLightnessMode)
void setLightnessLevelsCurve(const KisLevelsCurve &newLightnessLevelsCurve)
double toDouble(const QString &str, bool *ok=nullptr)

References defaultLevelsCurve(), defaultShowLogarithmicHistogram(), defaultUseLightnessMode(), defaultVersion(), KisLevelsCurve::fromString(), levelsCurves(), lightnessLevelsCurve(), KisLevelsCurve::setInputBlackPoint(), KisLevelsCurve::setInputGamma(), KisLevelsCurve::setInputWhitePoint(), setLevelsCurves(), setLightnessLevelsCurve(), KisLevelsCurve::setOutputBlackPoint(), KisLevelsCurve::setOutputWhitePoint(), setShowLogarithmicHistogram(), setUseLightnessMode(), KisFilterConfiguration::setVersion(), KisDomUtils::toDouble(), value(), and KisFilterConfiguration::version.

◆ fromXML() [4/4]

bool KisPropertiesConfiguration::fromXML ( const QString & xml,
bool clear = true )
overridevirtual

Fill the properties configuration object from the XML encoded representation in s. This function use the "Legacy" style XML of the 1.x .kra file format.

Parameters
xmlthe string that will be parsed as xml
clearif true, the properties map will be emptied.
Returns
true is the xml document could be parsed

Reimplemented from KisFilterConfiguration.

Definition at line 74 of file kis_properties_configuration.cc.

56{
57 if (clear) {
59 }
60
61 QDomDocument doc;
62 bool retval = bool(doc.setContent(xml));
63 if (retval) {
64 QDomElement e = doc.documentElement();
65 fromXML(e);
66 }
67 return retval;
68}

◆ isCompatible()

bool KisLevelsFilterConfiguration::isCompatible ( const KisPaintDeviceSP ) const
overridevirtual

Check if that configuration is compatible with this paint device. The default implementation always return true.

Reimplemented from KisFilterConfiguration.

Definition at line 38 of file KisLevelsFilterConfiguration.cpp.

39{
40 return useLightnessMode() || (int)dev->compositionSourceColorSpace()->channelCount() == channelCount();
41}

References channelCount(), KoColorSpace::channelCount(), KisPaintDevice::compositionSourceColorSpace(), and useLightnessMode().

◆ levelsCurves()

const QVector< KisLevelsCurve > KisLevelsFilterConfiguration::levelsCurves ( ) const

Definition at line 43 of file KisLevelsFilterConfiguration.cpp.

44{
45 QVector<KisLevelsCurve> levelsCurves_;
46 for (qint32 i = 0; i < channelCount(); ++i) {
47 const QString levelsCurveStr = getString(QString("channel_") + KisDomUtils::toString(i), "");
48 levelsCurves_.append(levelsCurveStr.isEmpty() ? KisLevelsCurve() : KisLevelsCurve(levelsCurveStr));
49 }
50 return levelsCurves_;
51}
QString toString(const QString &value)
QString getString(const QString &name, const QString &def=QString()) const

References channelCount(), KisPropertiesConfiguration::getString(), and KisDomUtils::toString().

◆ lightnessLevelsCurve()

const KisLevelsCurve KisLevelsFilterConfiguration::lightnessLevelsCurve ( ) const

Definition at line 53 of file KisLevelsFilterConfiguration.cpp.

54{
55 const QString levelsCurveStr = getString("lightness", "");
56 return levelsCurveStr.isEmpty() ? KisLevelsCurve() : KisLevelsCurve(levelsCurveStr);
57}

References KisPropertiesConfiguration::getString().

◆ lightnessTransfer()

const QVector< quint16 > & KisLevelsFilterConfiguration::lightnessTransfer ( ) const

Definition at line 94 of file KisLevelsFilterConfiguration.cpp.

95{
97}

References m_lightnessTransfer.

◆ setChannelCount()

void KisLevelsFilterConfiguration::setChannelCount ( int newChannelCount)
private

Definition at line 203 of file KisLevelsFilterConfiguration.cpp.

204{
205 setProperty("number_of_channels", newChannelCount);
206}

References setProperty().

◆ setDefaults()

◆ setLegacyValuesFromLightnessLevelsCurve()

void KisLevelsFilterConfiguration::setLegacyValuesFromLightnessLevelsCurve ( )
private

The purpose of this function is to copy the values of the new and compact "lightness" option, that correspond to the lightness levels adjustment, to the legacy options that where used before version 2 of the filter. Storing the legacy options as well as the new ones improves backwards compatibility of documents. Note that the "blackvalue", "whitevalue", "outblackvalue" and "outwhitevalue" legacy properties span the range [0, 255] while the values in the "lightness" property span the range [0, 1]

Definition at line 163 of file KisLevelsFilterConfiguration.cpp.

164{
165 KisLevelsCurve lightnessLevelsCurve_ = lightnessLevelsCurve();
166 KisColorTransformationConfiguration::setProperty("blackvalue", static_cast<int>(qRound(lightnessLevelsCurve_.inputBlackPoint() * 255.0)));
167 KisColorTransformationConfiguration::setProperty("whitevalue", static_cast<int>(qRound(lightnessLevelsCurve_.inputWhitePoint() * 255.0)));
168 KisColorTransformationConfiguration::setProperty("gammavalue", lightnessLevelsCurve_.inputGamma());
169 KisColorTransformationConfiguration::setProperty("outblackvalue", static_cast<int>(qRound(lightnessLevelsCurve_.outputBlackPoint() * 255.0)));
170 KisColorTransformationConfiguration::setProperty("outwhitevalue", static_cast<int>(qRound(lightnessLevelsCurve_.outputWhitePoint() * 255.0)));
171}
qreal outputBlackPoint() const
Get the output black point.
qreal inputBlackPoint() const
Get the input black point.
qreal inputGamma() const
Get the gamma value.
qreal inputWhitePoint() const
Get the input white point.
qreal outputWhitePoint() const
Get the output white point.
void setProperty(const QString &name, const QVariant &value) override

References KisLevelsCurve::inputBlackPoint(), KisLevelsCurve::inputGamma(), KisLevelsCurve::inputWhitePoint(), lightnessLevelsCurve(), KisLevelsCurve::outputBlackPoint(), KisLevelsCurve::outputWhitePoint(), and KisColorTransformationConfiguration::setProperty().

◆ setLevelsCurves()

void KisLevelsFilterConfiguration::setLevelsCurves ( const QVector< KisLevelsCurve > & newLevelsCurves)

Definition at line 59 of file KisLevelsFilterConfiguration.cpp.

60{
61 for (int i = 0; i < newLevelsCurves.size(); ++i) {
62 setProperty(QString("channel_") + KisDomUtils::toString(i), newLevelsCurves[i].toString());
63 }
64 setChannelCount(newLevelsCurves.size());
66}

References setChannelCount(), setProperty(), KisDomUtils::toString(), and updateTransfers().

◆ setLightessLevelsCurveFromLegacyValues()

void KisLevelsFilterConfiguration::setLightessLevelsCurveFromLegacyValues ( )
private

The purpose of this function is to copy the values of the legacy options (levels filter version < 2), that correspond to the lightness levels adjustment, to the new and compact "lightness" option which is used now. Note that the "blackvalue", "whitevalue", "outblackvalue" and "outwhitevalue" legacy properties span the range [0, 255] while the values in the "lightness" property span the range [0, 1]

Definition at line 140 of file KisLevelsFilterConfiguration.cpp.

141{
142 const double inputBlackPoint = static_cast<double>(getInt("blackvalue", 0)) / 255.0;
143 const double inputWhitePoint = static_cast<double>(getInt("whitevalue", 255)) / 255.0;
144 const double inputGamma = getDouble("gammavalue", 1.0);
145 const double outputBlackPoint = static_cast<double>(getInt("outblackvalue", 0)) / 255.0;
146 const double outputWhitePoint = static_cast<double>(getInt("outwhitevalue", 255)) / 255.0;
148 "lightness",
149 KisLevelsCurve(inputBlackPoint, inputWhitePoint, inputGamma, outputBlackPoint, outputWhitePoint).toString()
150 );
151}
double getDouble(const QString &name, double def=0.0) const

References KisPropertiesConfiguration::getDouble(), KisPropertiesConfiguration::getInt(), and KisColorTransformationConfiguration::setProperty().

◆ setLightnessLevelsCurve()

void KisLevelsFilterConfiguration::setLightnessLevelsCurve ( const KisLevelsCurve & newLightnessLevelsCurve)

Definition at line 68 of file KisLevelsFilterConfiguration.cpp.

69{
70 setProperty("lightness", newLightnessLevelsCurve.toString());
71}
QString toString() const
Get a text representation of the parameters. The format is: "input_black_point;input_white_point;inpu...

References setProperty(), and KisLevelsCurve::toString().

◆ setProperty()

void KisLevelsFilterConfiguration::setProperty ( const QString & name,
const QVariant & value )
overridevirtual

The options may be changed directly using the "setProperty" method of the "KisPropertiesConfiguration". In this case we must intercept the action to update the transfer function luts after setting the property. if some legacy property is set (lightness levels properties prior to version 2) then the legacy properties are copied to the new and compact "lightness" property. Conversely, if the "lightness" property is set, its values are copied to the legacy properties.

Reimplemented from KisColorTransformationConfiguration.

Definition at line 182 of file KisLevelsFilterConfiguration.cpp.

183{
185
186 if (name == "lightness") {
189 } else if (name == "blackvalue" || name == "whitevalue" || name == "gammavalue" ||
190 name == "outblackvalue" || name == "outwhitevalue") {
193 } else if (QRegularExpression("channel_\\d+").match(name).hasMatch()) {
195 }
196}

References KisFilterConfiguration::name, setLegacyValuesFromLightnessLevelsCurve(), setLightessLevelsCurveFromLegacyValues(), KisColorTransformationConfiguration::setProperty(), updateLightnessTransfer(), updateTransfers(), and value().

◆ setShowLogarithmicHistogram()

void KisLevelsFilterConfiguration::setShowLogarithmicHistogram ( bool newShowLogarithmicHistogram)

Definition at line 126 of file KisLevelsFilterConfiguration.cpp.

127{
128 setProperty("histogram_mode", newShowLogarithmicHistogram ? "logarithmic" : "linear");
129}

References setProperty().

◆ setUseLightnessMode()

void KisLevelsFilterConfiguration::setUseLightnessMode ( bool newUseLightnessMode)

Definition at line 121 of file KisLevelsFilterConfiguration.cpp.

122{
123 setProperty("mode", newUseLightnessMode ? "lightness" : "channels");
124}

References setProperty().

◆ showLogarithmicHistogram()

bool KisLevelsFilterConfiguration::showLogarithmicHistogram ( ) const

Definition at line 110 of file KisLevelsFilterConfiguration.cpp.

111{
112 const QString mode = getString("histogram_mode", "");
113 if (mode == "logarithmic") {
114 return true;
115 } else if (mode == "linear") {
116 return false;
117 }
119}

References defaultShowLogarithmicHistogram(), and KisPropertiesConfiguration::getString().

◆ toXML() [1/4]

QString KisPropertiesConfiguration::toXML ( ) const
overridevirtual

Create a serialized version of this properties config This function use the "Legacy" style XML of the 1.x .kra file format.

Reimplemented from KisFilterConfiguration.

Definition at line 75 of file kis_properties_configuration.cc.

128{
129 QDomDocument doc = QDomDocument("params");
130 QDomElement root = doc.createElement("params");
131 doc.appendChild(root);
132 toXML(doc, root);
133 return doc.toString();
134}

◆ toXML() [2/4]

void KisFilterConfiguration::toXML ( QDomDocument & ,
QDomElement &  ) const
overridevirtual

Create a serialized version of this object

Reimplemented from KisFilterConfiguration.

Definition at line 78 of file kis_filter_configuration.cc.

96{
97 elt.setAttribute("version", d->version);
99}

◆ toXML() [3/4]

void KisPropertiesConfiguration::toXML ( QDomDocument & doc,
QDomElement & root ) const
overridevirtual

Create a serialized version of this properties config This function use the "Legacy" style XML of the 1.x .kra file format.

Reimplemented from KisFilterConfiguration.

Definition at line 75 of file kis_properties_configuration.cc.

90{
91 QMap<QString, QVariant>::ConstIterator it;
92 for (it = d->properties.constBegin(); it != d->properties.constEnd(); ++it) {
93 if (d->notSavedProperties.contains(it.key())) {
94 continue;
95 }
96
97 QDomElement e = doc.createElement("param");
98 e.setAttribute("name", QString(it.key().toLatin1()));
99 QString type = "string";
100 QVariant v = it.value();
101 QDomText text;
102 if (v.type() == QVariant::UserType && v.userType() == qMetaTypeId<KisCubicCurve>()) {
103 text = doc.createCDATASection(v.value<KisCubicCurve>().toString());
104 } else if (v.type() == QVariant::UserType && v.userType() == qMetaTypeId<KoColor>()) {
105 QDomDocument cdataDoc = QDomDocument("color");
106 QDomElement cdataRoot = cdataDoc.createElement("color");
107 cdataDoc.appendChild(cdataRoot);
108 v.value<KoColor>().toXML(cdataDoc, cdataRoot);
109 text = cdataDoc.createCDATASection(cdataDoc.toString());
110 type = "color";
111 } else if(v.type() == QVariant::String ) {
112 text = doc.createCDATASection(v.toString()); // XXX: Unittest this!
113 type = "string";
114 } else if(v.type() == QVariant::ByteArray ) {
115 text = doc.createTextNode(QString::fromLatin1(v.toByteArray().toBase64())); // Arbitrary Data
116 type = "bytearray";
117 } else {
118 text = doc.createTextNode(v.toString());
119 type = "internal";
120 }
121 e.setAttribute("type", type);
122 e.appendChild(text);
123 root.appendChild(e);
124 }
125}
qreal v
QString toString() const

◆ toXML() [4/4]

void KisLevelsFilterConfiguration::toXML ( QDomDocument & ,
QDomElement &  ) const
overridevirtual

Create a serialized version of this object

levels curve param follows this format: "input_black_point;input_white_point;input_gamma;output_black_point;output_white_point"

For backwards compatibility, the "blackvalue" etc. values are also saved. Those contain the values of the lightness mode levels.

<params version=2>
<param name="mode">lightness</param>
<param name="histogram_mode">logarithmic</param>
<param name="lightness">0;1;0.4;0;1</param>
<param name="number_of_channels">3</param>
<param name="channel_0">0;1;1;0;1</param>
<param name="channel_1">0.2;0.8;1.2;0.25;0.75</param>
<param name="channel_2">0;1;0.6;0;1</param>
<param type="internal" name="blackvalue">0</param>
<param type="internal" name="whitevalue">255</param>
<param type="internal" name="gammavalue">1</param>
<param type="internal" name="outblackvalue">0</param>
<param type="internal" name="outwhitevalue">255</param>
</params>

Reimplemented from KisFilterConfiguration.

Definition at line 306 of file KisLevelsFilterConfiguration.cpp.

307{
334 root.setAttribute("version", version());
335
336 QDomText text;
337 QDomElement t;
338
339 addParamNode(doc, root, "mode", useLightnessMode() ? "lightness" : "channels");
340 addParamNode(doc, root, "histogram_mode", showLogarithmicHistogram() ? "logarithmic" : "linear");
341 addParamNode(doc, root, "lightness", lightnessLevelsCurve().toString());
342 addParamNode(doc, root, "number_of_channels", KisDomUtils::toString(channelCount()));
343
344 const QVector<KisLevelsCurve> levelsCurves_ = levelsCurves();
345 for (int i = 0; i < levelsCurves_.size(); ++i) {
346 const QString name = QString("channel_") + KisDomUtils::toString(i);
347 const QString value = levelsCurves_[i].toString();
348 addParamNode(doc, root, name, value);
349 }
350 const KisLevelsCurve lightnessCurve_ = lightnessLevelsCurve();
351 addParamNode(doc, root, "blackvalue", KisDomUtils::toString(static_cast<int>(qRound(lightnessCurve_.inputBlackPoint() * 255.0))), true);
352 addParamNode(doc, root, "whitevalue", KisDomUtils::toString(static_cast<int>(qRound(lightnessCurve_.inputWhitePoint() * 255.0))), true);
353 addParamNode(doc, root, "gammavalue", KisDomUtils::toString(lightnessCurve_.inputGamma()), true);
354 addParamNode(doc, root, "outblackvalue", KisDomUtils::toString(static_cast<int>(qRound(lightnessCurve_.outputBlackPoint() * 255.0))), true);
355 addParamNode(doc, root, "outwhitevalue", KisDomUtils::toString(static_cast<int>(qRound(lightnessCurve_.outputWhitePoint() * 255.0))), true);
356}
void addParamNode(QDomDocument &doc, QDomElement &root, const QString &name, const QString &value)

References addParamNode(), channelCount(), KisLevelsCurve::inputBlackPoint(), KisLevelsCurve::inputGamma(), KisLevelsCurve::inputWhitePoint(), levelsCurves(), lightnessLevelsCurve(), KisFilterConfiguration::name, KisLevelsCurve::outputBlackPoint(), KisLevelsCurve::outputWhitePoint(), showLogarithmicHistogram(), KisDomUtils::toString(), useLightnessMode(), value(), and KisFilterConfiguration::version.

◆ transfers()

const QVector< QVector< quint16 > > & KisLevelsFilterConfiguration::transfers ( ) const

Definition at line 89 of file KisLevelsFilterConfiguration.cpp.

90{
91 return m_transfers;
92}

References m_transfers.

◆ updateLightnessTransfer()

void KisLevelsFilterConfiguration::updateLightnessTransfer ( )
private

Definition at line 82 of file KisLevelsFilterConfiguration.cpp.

83{
84 const KisLevelsCurve lightnessLevelsCurve_ = lightnessLevelsCurve();
85
86 m_lightnessTransfer = lightnessLevelsCurve_.uint16Transfer();
87}
const QVector< quint16 > & uint16Transfer(int size=256) const
Returns a vector of size.

References lightnessLevelsCurve(), m_lightnessTransfer, and KisLevelsCurve::uint16Transfer().

◆ updateTransfers()

void KisLevelsFilterConfiguration::updateTransfers ( )
private

Definition at line 73 of file KisLevelsFilterConfiguration.cpp.

74{
76 m_transfers.resize(lc.size());
77 for (int i = 0; i < lc.size(); i++) {
78 m_transfers[i] = lc[i].uint16Transfer();
79 }
80}

References levelsCurves(), and m_transfers.

◆ useLightnessMode()

bool KisLevelsFilterConfiguration::useLightnessMode ( ) const

Definition at line 99 of file KisLevelsFilterConfiguration.cpp.

100{
101 const QString mode = getString("mode", "");
102 if (mode == "lightness") {
103 return true;
104 } else if (mode == "channels") {
105 return false;
106 }
108}

References defaultUseLightnessMode(), and KisPropertiesConfiguration::getString().

Member Data Documentation

◆ m_lightnessTransfer

QVector<quint16> KisLevelsFilterConfiguration::m_lightnessTransfer
private

Definition at line 59 of file KisLevelsFilterConfiguration.h.

◆ m_transfers

QVector<QVector<quint16> > KisLevelsFilterConfiguration::m_transfers
private

Definition at line 58 of file KisLevelsFilterConfiguration.h.


The documentation for this class was generated from the following files: