Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPaintOpSettings Class Referenceabstract

#include <kis_paintop_settings.h>

+ Inheritance diagram for KisPaintOpSettings:

Classes

struct  OutlineMode
 
struct  UpdateListener
 

Public Types

using UpdateListenerSP = QSharedPointer<UpdateListener>
 
using UpdateListenerWSP = QWeakPointer<UpdateListener>
 

Public Member Functions

virtual void activate ()
 
virtual qreal airbrushInterval () const
 
virtual KisOptimizedBrushOutline brushOutline (const KisPaintInformation &info, const OutlineMode &mode, qreal alignForZoom)
 
KoCanvasResourcesInterfaceSP canvasResourcesInterface () const
 
virtual KisPaintOpSettingsSP clone () const
 
KisPaintOpSettingsSP createMaskingSettings () const
 
QString effectivePaintOpCompositeOp ()
 
bool eraserMode ()
 
bool hasMaskingSettings () const
 
virtual bool hasPatternSettings () const
 
virtual QString indirectPaintingCompositeOp () const
 
virtual bool isAirbrushing () const
 
virtual bool isValid () const
 
 KisPaintOpSettings (const KisPaintOpSettings &rhs)
 
 KisPaintOpSettings (KisResourcesInterfaceSP resourcesInterface)
 
qreal lodSizeThreshold () const
 
virtual bool lodSizeThresholdSupported () const
 
QString maskingBrushCompositeOp () const
 
virtual QString modelName () const
 
virtual bool mousePressEvent (const KisPaintInformation &paintInformation, Qt::KeyboardModifiers modifiers, KisNodeWSP currentNode)
 
virtual bool mouseReleaseEvent ()
 
virtual bool needsAsynchronousUpdates () const
 
KisNodeSP node () const
 
virtual bool paintIncremental ()
 
virtual qreal paintOpAngle () const =0
 
QString paintOpCompositeOp ()
 
qreal paintOpFade ()
 
qreal paintOpFlow ()
 
virtual qreal paintOpOpacity ()
 
virtual qreal paintOpPatternSize ()
 
qreal paintOpScatter ()
 
virtual qreal paintOpSize () const =0
 
 Private ()
 
 Private (const Private &rhs)
 
virtual void regenerateResourceCache (KoResourceCacheInterfaceSP cacheInterface)
 
virtual QList< int > requiredCanvasResources () const
 
virtual void resetSettings (const QStringList &preserveProperties=QStringList())
 
KoResourceCacheInterfaceSP resourceCacheInterface () const
 
KisResourcesInterfaceSP resourcesInterface () const
 
quint64 sanityVersionCookie () const
 
qreal savedBrushOpacity () const
 
qreal savedBrushSize () const
 
qreal savedEraserOpacity () const
 
qreal savedEraserSize () const
 
void setCanvasResourcesInterface (KoCanvasResourcesInterfaceSP canvasResourcesInterface)
 
void setEraserMode (bool value)
 
void setLodSizeThreshold (qreal value)
 
void setModelName (const QString &modelName)
 
virtual void setPaintOpAngle (qreal value)=0
 
void setPaintOpCompositeOp (const QString &value)
 
void setPaintOpFade (qreal value)
 
void setPaintOpFlow (qreal value)
 
virtual void setPaintOpOpacity (qreal value)
 
void setPaintOpScatter (qreal value)
 
virtual void setPaintOpSize (qreal value)=0
 
void setProperty (const QString &name, const QVariant &value) override
 
virtual void setResourceCacheInterface (KoResourceCacheInterfaceSP cacheInterface)
 
void setResourcesInterface (KisResourcesInterfaceSP resourcesInterface)
 
void setSavedBrushOpacity (qreal value)
 
void setSavedBrushSize (qreal value)
 
void setSavedEraserOpacity (qreal value)
 
void setSavedEraserSize (qreal value)
 
void setUpdateListener (UpdateListenerWSP listener)
 
virtual QList< KisUniformPaintOpPropertySPuniformProperties (KisPaintOpSettingsSP settings, QPointer< KisPaintOpPresetUpdateProxy > updateProxy)
 
UpdateListenerWSP updateListener () const
 
virtual bool useSpacingUpdates () const
 
 ~KisPaintOpSettings () override
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisPropertiesConfiguration
void clearProperties ()
 Clear the map of properties.
 
virtual bool compareTo (const KisPropertiesConfiguration *rhs) const
 
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 KisOptimizedBrushOutline ellipseOutline (qreal width, qreal height, qreal scale, qreal rotation)
 
static bool isLodUserAllowed (const KisPropertiesConfigurationSP config)
 
static QPainterPath makeTiltIndicator (KisPaintInformation const &info, QPointF const &start, qreal lengthScale, qreal angle)
 
static void setLodUserAllowed (KisPropertiesConfigurationSP config, bool value)
 
- Static Public Member Functions inherited from KisPropertiesConfiguration
static QString escapeString (const QString &string)
 
static QString extractedPrefixKey ()
 
static QString unescapeString (const QString &string)
 

Public Attributes

KoCanvasResourcesInterfaceSP canvasResourcesInterface
 
QString modelName
 
KoResourceCacheInterfaceSP resourceCacheInterface
 
KisResourcesInterfaceSP resourcesInterface
 
QPointer< KisPaintOpConfigWidgetsettingsWidget
 
QList< KisUniformPaintOpPropertyWSPuniformProperties
 
UpdateListenerWSP updateListener
 
quint64 versionCookie
 
KisRandomSource versionRandomSource
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- Public Attributes inherited from KisPropertiesConfiguration
QSet< QString > notSavedProperties
 
QMap< QString, QVariant > properties
 

Protected Member Functions

virtual void onPropertyChanged ()
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 

Private Attributes

const QScopedPointer< Privated
 

Detailed Description

This class is used to cache the settings for a paintop between two creations. There is one KisPaintOpSettings per input device (mouse, tablet, etc...).

The settings may be stored in a preset. Note that if your paintop's settings subclass has data that is not stored as a property, that data is not saved and restored.

The object also contains a pointer to its parent KisPaintOpPreset object.This is to control the DirtyPreset property of KisPaintOpPreset. Whenever the settings are changed/modified from the original – the preset is set to dirty.

Definition at line 54 of file kis_paintop_settings.cpp.

Member Typedef Documentation

◆ UpdateListenerSP

◆ UpdateListenerWSP

Constructor & Destructor Documentation

◆ KisPaintOpSettings() [1/2]

KisPaintOpSettings::KisPaintOpSettings ( KisResourcesInterfaceSP resourcesInterface)

Definition at line 98 of file kis_paintop_settings.cpp.

99 : d(new Private)
100{
101 d->resourcesInterface = resourcesInterface;
102}
KisResourcesInterfaceSP resourcesInterface
const QScopedPointer< Private > d

References d, and resourcesInterface.

◆ ~KisPaintOpSettings()

KisPaintOpSettings::~KisPaintOpSettings ( )
override

Definition at line 104 of file kis_paintop_settings.cpp.

105{
106}

◆ KisPaintOpSettings() [2/2]

KisPaintOpSettings::KisPaintOpSettings ( const KisPaintOpSettings & rhs)

Member Function Documentation

◆ activate()

void KisPaintOpSettings::activate ( )
virtual

Call this function when the paint op is selected or the tool is activated

Reimplemented in KisDuplicateOpSettings.

Definition at line 293 of file kis_paintop_settings.cpp.

294{
295}

◆ airbrushInterval()

qreal KisPaintOpSettings::airbrushInterval ( ) const
virtual

Indicates the minimum time interval that might be needed between airbrush dabs, in milliseconds. A lower value means painting updates need to happen more frequently. This value should be ignored if isAirbrushing() is false.

The default implementation uses the property AIRBRUSH_RATE, defaulting to an interval of one second if the property is not found. This should be suitable for most paintops.

Reimplemented in KisRoundMarkerOpSettings.

Definition at line 503 of file kis_paintop_settings.cpp.

504{
505 qreal rate = getDouble(AIRBRUSH_RATE, 1.0);
506 if (rate == 0.0) {
507 return LONG_TIME;
508 }
509 else {
510 return 1000.0 / rate;
511 }
512}
const QString AIRBRUSH_RATE
const qreal LONG_TIME
double getDouble(const QString &name, double def=0.0) const

References AIRBRUSH_RATE, KisPropertiesConfiguration::getDouble(), and LONG_TIME.

◆ brushOutline()

KisOptimizedBrushOutline KisPaintOpSettings::brushOutline ( const KisPaintInformation & info,
const OutlineMode & mode,
qreal alignForZoom )
virtual

Returns the brush outline in pixel coordinates. Tool is responsible for conversion into view coordinates. Outline mode has to be passed to the paintop which builds the outline as some paintops have to paint outline always like clone paintop indicating the duplicate position

Reimplemented in KisBrushBasedPaintOpSettings, KisDuplicateOpSettings, KisDuplicateOpSettings, KisDeformPaintOpSettings, KisExperimentPaintOpSettings, KisGridPaintOpSettings, KisHairyPaintOpSettings, KisHairyPaintOpSettings, KisBrushBasedPaintOpSettings, KisMyPaintOpSettings, KisRoundMarkerOpSettings, KisSketchPaintOpSettings, and KisSprayPaintOpSettings.

Definition at line 524 of file kis_paintop_settings.cpp.

525{
527 if (mode.isVisible) {
528 path = ellipseOutline(10, 10, 1.0, 0);
529
530 if (mode.showTiltDecoration) {
531 path.addPath(makeTiltIndicator(info, QPointF(0.0, 0.0), 0.0, 2.0));
532 }
533
534 path.translate(KisAlgebra2D::alignForZoom(info.pos(), alignForZoom));
535 }
536
537 return path;
538}
const QPointF & pos() const
QPointF alignForZoom(const QPointF &pt, qreal zoom)
static QPainterPath makeTiltIndicator(KisPaintInformation const &info, QPointF const &start, qreal lengthScale, qreal angle)
static KisOptimizedBrushOutline ellipseOutline(qreal width, qreal height, qreal scale, qreal rotation)

References KisAlgebra2D::alignForZoom(), ellipseOutline(), KisPaintOpSettings::OutlineMode::isVisible, makeTiltIndicator(), KisPaintInformation::pos(), and KisPaintOpSettings::OutlineMode::showTiltDecoration.

◆ canvasResourcesInterface()

KoCanvasResourcesInterfaceSP KisPaintOpSettings::canvasResourcesInterface ( ) const

◆ clone()

KisPaintOpSettingsSP KisPaintOpSettings::clone ( ) const
virtual

Clone the current settings object. Override this if your settings instance doesn't store everything as properties.

Reimplemented in KisDuplicateOpSettings, and KisBrushBasedPaintOpSettings.

Definition at line 252 of file kis_paintop_settings.cpp.

253{
254 QString paintopID = getString("paintop");
255 if (paintopID.isEmpty())
256 return 0;
257
259 QMapIterator<QString, QVariant> i(getProperties());
260 while (i.hasNext()) {
261 i.next();
262 settings->setProperty(i.key(), QVariant(i.value()));
263 }
264
265 settings->setCanvasResourcesInterface(this->canvasResourcesInterface());
266
267#ifdef SANITY_CHECK_CACHE
268 settings->d->versionCookie = this->d->versionCookie;
269#endif
270
271 return settings;
272}
static KisPaintOpRegistry * instance()
KisPaintOpSettingsSP createSettings(const KoID &id, KisResourcesInterfaceSP resourcesInterface) const
Definition KoID.h:30
KoCanvasResourcesInterfaceSP canvasResourcesInterface
QString getString(const QString &name, const QString &def=QString()) const
virtual QMap< QString, QVariant > getProperties() const

References canvasResourcesInterface, KisPaintOpRegistry::createSettings(), KisSharedPtr< T >::d, d, KisPropertiesConfiguration::getProperties(), KisPropertiesConfiguration::getString(), KisPaintOpRegistry::instance(), and resourcesInterface.

◆ createMaskingSettings()

KisPaintOpSettingsSP KisPaintOpSettings::createMaskingSettings ( ) const
Returns
a newly created settings object representing a preset of the masking brush that should be run alongside the current brush

WARNING: cropping is a workaround for too big brushes due to the proportional scaling using shift+drag gesture.

See this bug: https://bugs.kde.org/show_bug.cgi?id=423572

TODO:

1) Implement a warning notifying the user that his masking brush has been cropped

2) Make sure that the sliders in KisMaskingBrushOption have correct limits (right now they are limited by usual maximumBrushSize)

Definition at line 141 of file kis_paintop_settings.cpp.

142{
144
145 const KoID pixelBrushId(KisPaintOpUtils::MaskingBrushPaintOpId, QString());
146
148 maskingSettings->setCanvasResourcesInterface(canvasResourcesInterface());
149
151
152 const bool useMasterSize = this->getBool(KisPaintOpUtils::MaskingBrushUseMasterSizeTag, true);
153 if (useMasterSize) {
169 const qreal maxMaskingBrushSize = KisImageConfig(true).maxMaskingBrushSize();
170 const qreal masterSizeCoeff = getDouble(KisPaintOpUtils::MaskingBrushMasterSizeCoeffTag, 1.0);
171 maskingSettings->setPaintOpSize(qMin(maxMaskingBrushSize, masterSizeCoeff * paintOpSize()));
172 }
173
174 if (d->resourceCacheInterface) {
175 maskingSettings->setResourceCacheInterface(
178 d->resourceCacheInterface)));
179 }
180
181 return maskingSettings;
182}
int maxMaskingBrushSize() const
QSharedPointer< T > toQShared(T *ptr)
KisPinnedSharedPtr< KisPaintOpSettings > KisPaintOpSettingsSP
Definition kis_types.h:242
const char MaskingBrushUseMasterSizeTag[]
const char MaskingBrushPaintOpId[]
const char MaskingBrushMasterSizeCoeffTag[]
const char MaskingBrushPresetPrefix[]
virtual qreal paintOpSize() const =0
bool getBool(const QString &name, bool def=false) const
void getPrefixedProperties(const QString &prefix, KisPropertiesConfiguration *config) const

References canvasResourcesInterface, KisPaintOpRegistry::createSettings(), d, KisPropertiesConfiguration::getBool(), KisPropertiesConfiguration::getDouble(), KisPropertiesConfiguration::getPrefixedProperties(), hasMaskingSettings(), KisPaintOpRegistry::instance(), KisPaintOpUtils::MaskingBrushMasterSizeCoeffTag, KisPaintOpUtils::MaskingBrushPaintOpId, KisPaintOpUtils::MaskingBrushPresetPrefix, KisPaintOpUtils::MaskingBrushUseMasterSizeTag, KisImageConfig::maxMaskingBrushSize(), paintOpSize(), resourcesInterface, and toQShared().

◆ effectivePaintOpCompositeOp()

QString KisPaintOpSettings::effectivePaintOpCompositeOp ( )

Definition at line 429 of file kis_paintop_settings.cpp.

430{
432}
const QString COMPOSITE_ERASE

References COMPOSITE_ERASE, eraserMode(), and paintOpCompositeOp().

◆ ellipseOutline()

KisOptimizedBrushOutline KisPaintOpSettings::ellipseOutline ( qreal width,
qreal height,
qreal scale,
qreal rotation )
static

Helpers for drawing the brush outline

Definition at line 540 of file kis_paintop_settings.cpp.

541{
542 QPainterPath path;
543 QRectF ellipse(0, 0, width * scale, height * scale);
544 ellipse.translate(-ellipse.center());
545 path.addEllipse(ellipse);
546
547 QTransform m;
548 m.reset();
549 m.rotate(rotation);
550 path = m.map(path);
551 return path;
552}

◆ eraserMode()

bool KisPaintOpSettings::eraserMode ( )

Definition at line 421 of file kis_paintop_settings.cpp.

422{
424 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
425
426 return proxy->getBool("EraserMode", false);
427}
static KisLockedPropertiesServer * instance()

References KisLockedPropertiesServer::instance().

◆ hasMaskingSettings()

bool KisPaintOpSettings::hasMaskingSettings ( ) const
Returns
true if this preset demands a secondary masked brush running alongside it

Definition at line 136 of file kis_paintop_settings.cpp.

137{
139}
const char MaskingBrushEnabledTag[]

References KisPropertiesConfiguration::getBool(), and KisPaintOpUtils::MaskingBrushEnabledTag.

◆ hasPatternSettings()

bool KisPaintOpSettings::hasPatternSettings ( ) const
virtual

Reimplemented in KisFilterOpSettings, KisHairyPaintOpSettings, KisBrushBasedPaintOpSettings, and KisSketchPaintOpSettings.

Definition at line 184 of file kis_paintop_settings.cpp.

185{
186 return false;
187}

◆ indirectPaintingCompositeOp()

QString KisPaintOpSettings::indirectPaintingCompositeOp ( ) const
virtual
Returns
the composite op it to which the indirect painting device should be initialized to. This is used by clone op to reset the composite op to COMPOSITE_COPY

Reimplemented in KisDuplicateOpSettings.

Definition at line 493 of file kis_paintop_settings.cpp.

494{
496}
const QString COMPOSITE_ALPHA_DARKEN

References COMPOSITE_ALPHA_DARKEN.

◆ isAirbrushing()

bool KisPaintOpSettings::isAirbrushing ( ) const
virtual

Whether this paintop wants to deposit paint even when not moving, i.e. the tool needs to activate its timer. If this is true, painting updates need to be generated at regular intervals even in the absence of input device events, e.g. when the cursor is not moving.

The default implementation checks the property AIRBRUSH_ENABLED, defaulting to false if the property is not found. This should be suitable for most paintops.

Reimplemented in KisDeformPaintOpSettings, and KisRoundMarkerOpSettings.

Definition at line 498 of file kis_paintop_settings.cpp.

499{
500 return getBool(AIRBRUSH_ENABLED, false);
501}
const QString AIRBRUSH_ENABLED

References AIRBRUSH_ENABLED, and KisPropertiesConfiguration::getBool().

◆ isLodUserAllowed()

bool KisPaintOpSettings::isLodUserAllowed ( const KisPropertiesConfigurationSP config)
static

Definition at line 604 of file kis_paintop_settings.cpp.

605{
606 return config->getBool("lodUserAllowed", true);
607}

◆ isValid()

bool KisPaintOpSettings::isValid ( ) const
virtual

Check if the settings are valid, setting might be invalid through missing brushes etc Overwrite if the settings of a paintop can be invalid

Returns
state of the settings, default implementation is true

Definition at line 488 of file kis_paintop_settings.cpp.

489{
490 return true;
491}

◆ lodSizeThreshold()

qreal KisPaintOpSettings::lodSizeThreshold ( ) const

Definition at line 619 of file kis_paintop_settings.cpp.

620{
621 return getDouble("lodSizeThreshold", 100.0);
622}

References KisPropertiesConfiguration::getDouble().

◆ lodSizeThresholdSupported()

bool KisPaintOpSettings::lodSizeThresholdSupported ( ) const
virtual

Definition at line 614 of file kis_paintop_settings.cpp.

615{
616 return true;
617}

◆ makeTiltIndicator()

QPainterPath KisPaintOpSettings::makeTiltIndicator ( KisPaintInformation const & info,
QPointF const & start,
qreal lengthScale,
qreal angle )
static

Helper for drawing a triangle representing the tilt of the stylus.

Parameters
startis the offset from the brush's outline's bounding box
lengthScaleis used for deciding the size of the triangle. Brush diameter or width are common choices for this.
angleis the angle between the two sides of the triangle.

Definition at line 554 of file kis_paintop_settings.cpp.

556{
557 if (maxLength == 0.0) maxLength = 50.0;
558 maxLength = qMax(maxLength, 50.0);
559 qreal const length = maxLength * (1 - info.tiltElevation(info, 60.0, 60.0, true));
560 qreal const baseAngle = 360.0 - fmod(KisPaintInformation::tiltDirection(info, true) * 360.0 + 270.0, 360.0);
561
562 QLineF guideLine = QLineF::fromPolar(length, baseAngle + angle);
563 guideLine.translate(start);
564 QPainterPath ret;
565 ret.moveTo(guideLine.p1());
566 ret.lineTo(guideLine.p2());
567 guideLine.setAngle(baseAngle - angle);
568 ret.lineTo(guideLine.p2());
569 ret.lineTo(guideLine.p1());
570 return ret;
571}
qreal length(const QPointF &vec)
Definition Ellipse.cc:82
static qreal tiltDirection(const KisPaintInformation &info, bool normalize=true)

References length(), KisPaintInformation::tiltDirection(), and KisPaintInformation::tiltElevation().

◆ maskingBrushCompositeOp()

QString KisPaintOpSettings::maskingBrushCompositeOp ( ) const
Returns
a composite op id of the masked brush rendering algorithm.

Please take into account that the brush itself always paints in alpha- darken mode, but the final result is combined with this composite op.

Definition at line 237 of file kis_paintop_settings.cpp.

238{
240}
const QString COMPOSITE_MULT
const char MaskingBrushCompositeOpTag[]

References COMPOSITE_MULT, KisPropertiesConfiguration::getString(), and KisPaintOpUtils::MaskingBrushCompositeOpTag.

◆ modelName()

virtual QString KisPaintOpSettings::modelName ( ) const
virtual
Returns
filename of the 3D brush model, empty if no brush is set

Reimplemented in KisMyPaintOpSettings, and KisSprayPaintOpSettings.

◆ mousePressEvent()

bool KisPaintOpSettings::mousePressEvent ( const KisPaintInformation & paintInformation,
Qt::KeyboardModifiers modifiers,
KisNodeWSP currentNode )
virtual

This function is called by a tool when the mouse is pressed. It's useful if the paintop needs mouse interaction for instance in the case of the clone op. If the tool is supposed to ignore the event, the paint op should return true and if the tool is supposed to use the event, return false. See kis_tool_freehand:tryPickByPaintOp()

Reimplemented in KisDuplicateOpSettings, and KisGridPaintOpSettings.

Definition at line 124 of file kis_paintop_settings.cpp.

125{
126 Q_UNUSED(modifiers);
127 Q_UNUSED(currentNode);
128 return true; // ignore the event by default
129}

◆ mouseReleaseEvent()

bool KisPaintOpSettings::mouseReleaseEvent ( )
virtual

This function is called by a tool when the mouse is released. It's useful if the paintop needs mouse interaction for instance in the case of the clone op. If the tool is supposed to ignore the event, the paint op should return true and if the tool is supposed to use the event, return false.

Reimplemented in KisDuplicateOpSettings, and KisGridPaintOpSettings.

Definition at line 131 of file kis_paintop_settings.cpp.

132{
133 return true; // ignore the event by default
134}

◆ needsAsynchronousUpdates()

bool KisPaintOpSettings::needsAsynchronousUpdates ( ) const
virtual

Indicates if the tool should call paintOp->doAsynchronousUpdate() in between paintAt() calls to do the asynchronous rendering

Reimplemented in KisBrushOpSettings.

Definition at line 519 of file kis_paintop_settings.cpp.

520{
521 return false;
522}

◆ node()

KisNodeSP KisPaintOpSettings::node ( ) const
Returns
the node the paintop is working on.

◆ onPropertyChanged()

void KisPaintOpSettings::onPropertyChanged ( )
protectedvirtual

The callback is called every time when a property changes

Reimplemented in KisBrushBasedPaintOpSettings, KisOutlineGenerationPolicy< KisPaintOpSettings >, and KisMyPaintOpSettings.

Definition at line 588 of file kis_paintop_settings.cpp.

589{
590 // clear cached data for the resource
591 d->resourceCacheInterface.clear();
592
593#ifdef SANITY_CHECK_CACHE
594 d->versionCookie = d->versionRandomSource.generate();
595#endif
596
597 UpdateListenerSP updateListener = d->updateListener.toStrongRef();
598
599 if (updateListener) {
600 updateListener->notifySettingsChanged();
601 }
602}
UpdateListenerWSP updateListener
QSharedPointer< UpdateListener > UpdateListenerSP

References d, and updateListener.

◆ paintIncremental()

virtual bool KisPaintOpSettings::paintIncremental ( )
inlinevirtual

XXX: Remove this after 2.0, when the paint operation (incremental/non incremental) will be completely handled in the paintop, not in the tool. This is a filthy hack to move the option to the right place, at least.

Returns
true if we paint incrementally, false if we paint like Photoshop. By default, paintops do not support non-incremental.

Reimplemented in KisCurvePaintOpSettings, KisDuplicateOpSettings, KisDeformPaintOpSettings, KisExperimentPaintOpSettings, KisFilterOpSettings, KisGridPaintOpSettings, KisBrushBasedPaintOpSettings, KisMyPaintOpSettings, KisParticlePaintOpSettings, KisRoundMarkerOpSettings, KisSketchPaintOpSettings, and KisSprayPaintOpSettings.

Definition at line 131 of file kis_paintop_settings.h.

131 {
132 return true;
133 }

◆ paintOpAngle()

virtual qreal KisPaintOpSettings::paintOpAngle ( ) const
pure virtual

◆ paintOpCompositeOp()

QString KisPaintOpSettings::paintOpCompositeOp ( )
Returns
composite mode saved in the properties

Definition at line 405 of file kis_paintop_settings.cpp.

406{
408 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
409
410 return proxy->getString("CompositeOp", COMPOSITE_OVER);
411}
const QString COMPOSITE_OVER

References COMPOSITE_OVER, and KisLockedPropertiesServer::instance().

◆ paintOpFade()

qreal KisPaintOpSettings::paintOpFade ( )
Returns
fade saved in the properties

Definition at line 367 of file kis_paintop_settings.cpp.

368{
370 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
371
372 if (!proxy->hasProperty("brush_definition")) return 1.0;
373
374 QDomDocument doc;
375 doc.setContent(proxy->getString("brush_definition"));
376
377 QDomElement element = doc.documentElement();
378 QDomElement elementChild = element.elementsByTagName("MaskGenerator").item(0).toElement();
379
380 if (elementChild.attributeNode("hfade").value().toDouble() >= elementChild.attributeNode("vfade").value().toDouble()) {
381 return elementChild.attributeNode("hfade").value().toDouble();
382 } else {
383 return elementChild.attributeNode("vfade").value().toDouble();
384 }
385
386}

References KisLockedPropertiesServer::instance().

◆ paintOpFlow()

qreal KisPaintOpSettings::paintOpFlow ( )
Returns
flow saved in the properties

Definition at line 359 of file kis_paintop_settings.cpp.

360{
362 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
363
364 return proxy->getDouble("FlowValue", 1.0);
365}

References KisLockedPropertiesServer::instance().

◆ paintOpOpacity()

qreal KisPaintOpSettings::paintOpOpacity ( )
virtual
Returns
opacity saved in the properties

Reimplemented in KisMyPaintOpSettings.

Definition at line 352 of file kis_paintop_settings.cpp.

353{
355
356 return proxy->getDouble("OpacityValue", 1.0);
357}
KisLockedPropertiesProxySP createLockedPropertiesProxy(KisPropertiesConfiguration *settings)

References KisLockedPropertiesServer::createLockedPropertiesProxy(), and KisLockedPropertiesServer::instance().

◆ paintOpPatternSize()

qreal KisPaintOpSettings::paintOpPatternSize ( )
virtual
Returns
pattern size saved in the properties

Definition at line 397 of file kis_paintop_settings.cpp.

398{
400 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
401
402 return proxy->getDouble("Texture/Pattern/Scale", 0.5);
403}

References KisLockedPropertiesServer::instance().

◆ paintOpScatter()

qreal KisPaintOpSettings::paintOpScatter ( )
Returns
scatter saved in the properties

Definition at line 388 of file kis_paintop_settings.cpp.

389{
391 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
392
393 return proxy->getDouble("ScatterValue", 0.0);
394}

References KisLockedPropertiesServer::instance().

◆ paintOpSize()

virtual qreal KisPaintOpSettings::paintOpSize ( ) const
pure virtual

◆ Private() [1/2]

KisPaintOpSettings::Private ( )
inline

Definition at line 55 of file kis_paintop_settings.cpp.

57#ifdef SANITY_CHECK_CACHE
58 , versionRandomSource(int(reinterpret_cast<std::intptr_t>(this)))
60#endif
61 {}
qint64 generate() const
KisRandomSource versionRandomSource
QPointer< KisPaintOpConfigWidget > settingsWidget

◆ Private() [2/2]

KisPaintOpSettings::Private ( const Private & rhs)
inline

NOTE: we don't copy updateListener intentionally, it is a job of the cloned preset to set the new listener properly

Definition at line 63 of file kis_paintop_settings.cpp.

64 : settingsWidget(0),
65 modelName(rhs.modelName),
66 resourcesInterface(rhs.resourcesInterface),
67 canvasResourcesInterface(rhs.canvasResourcesInterface),
68 resourceCacheInterface(rhs.resourceCacheInterface)
69#ifdef SANITY_CHECK_CACHE
70 , versionRandomSource(int(reinterpret_cast<std::intptr_t>(this)))
71 , versionCookie(rhs.versionCookie)
72#endif
73 {
77 }
KoResourceCacheInterfaceSP resourceCacheInterface

◆ regenerateResourceCache()

void KisPaintOpSettings::regenerateResourceCache ( KoResourceCacheInterfaceSP cacheInterface)
virtual

Reimplemented in KisBrushBasedPaintOpSettings.

Definition at line 214 of file kis_paintop_settings.cpp.

215{
216 if (hasMaskingSettings()) {
218
219 KoResourceCacheInterfaceSP wrappedCacheInterface =
222 cacheInterface));
223
224 maskingSettings->regenerateResourceCache(wrappedCacheInterface);
225 }
226}
KisPaintOpSettingsSP createMaskingSettings() const

References createMaskingSettings(), hasMaskingSettings(), KisPaintOpUtils::MaskingBrushPresetPrefix, and toQShared().

◆ requiredCanvasResources()

QList< int > KisPaintOpSettings::requiredCanvasResources ( ) const
virtual

Reimplemented in KisBrushBasedPaintOpSettings.

Definition at line 189 of file kis_paintop_settings.cpp.

190{
191 return {};
192}

◆ resetSettings()

void KisPaintOpSettings::resetSettings ( const QStringList & preserveProperties = QStringList())
virtual

Removes all the settings from the object while keeping the paintop id, which is loaded to the object by the factory

Reimplemented in KisMyPaintOpSettings.

Definition at line 274 of file kis_paintop_settings.cpp.

275{
276 QStringList allKeys = preserveProperties;
277 allKeys << "paintop";
278
279 QHash<QString, QVariant> preserved;
280 Q_FOREACH (const QString &key, allKeys) {
281 if (hasProperty(key)) {
282 preserved[key] = getProperty(key);
283 }
284 }
285
287
288 for (auto it = preserved.constBegin(); it != preserved.constEnd(); ++it) {
289 setProperty(it.key(), it.value());
290 }
291}
void setProperty(const QString &name, const QVariant &value) override
void clearProperties()
Clear the map of properties.
virtual bool hasProperty(const QString &name) const
virtual bool getProperty(const QString &name, QVariant &value) const

References KisPropertiesConfiguration::clearProperties(), KisPropertiesConfiguration::getProperty(), KisPropertiesConfiguration::hasProperty(), and setProperty().

◆ resourceCacheInterface()

KoResourceCacheInterfaceSP KisPaintOpSettings::resourceCacheInterface ( ) const

◆ resourcesInterface()

KisResourcesInterfaceSP KisPaintOpSettings::resourcesInterface ( ) const
Returns
resource interface that is used for loading linked resources

◆ sanityVersionCookie()

quint64 KisPaintOpSettings::sanityVersionCookie ( ) const

Definition at line 228 of file kis_paintop_settings.cpp.

229{
230#ifdef SANITY_CHECK_CACHE
231 return d->versionCookie;
232#else
233 return 0;
234#endif
235}

References d.

◆ savedBrushOpacity()

qreal KisPaintOpSettings::savedBrushOpacity ( ) const

Definition at line 467 of file kis_paintop_settings.cpp.

468{
469 return getDouble("SavedBrushOpacity", 0.0);
470}

References KisPropertiesConfiguration::getDouble().

◆ savedBrushSize()

qreal KisPaintOpSettings::savedBrushSize ( ) const

Definition at line 445 of file kis_paintop_settings.cpp.

446{
447 return getDouble("SavedBrushSize", 0.0);
448}

References KisPropertiesConfiguration::getDouble().

◆ savedEraserOpacity()

qreal KisPaintOpSettings::savedEraserOpacity ( ) const

Definition at line 456 of file kis_paintop_settings.cpp.

457{
458 return getDouble("SavedEraserOpacity", 0.0);
459}

References KisPropertiesConfiguration::getDouble().

◆ savedEraserSize()

qreal KisPaintOpSettings::savedEraserSize ( ) const

Definition at line 434 of file kis_paintop_settings.cpp.

435{
436 return getDouble("SavedEraserSize", 0.0);
437}

References KisPropertiesConfiguration::getDouble().

◆ setCanvasResourcesInterface()

void KisPaintOpSettings::setCanvasResourcesInterface ( KoCanvasResourcesInterfaceSP canvasResourcesInterface)

Definition at line 199 of file kis_paintop_settings.cpp.

200{
201 d->canvasResourcesInterface = canvasResourcesInterface;
202}

References canvasResourcesInterface, and d.

◆ setEraserMode()

void KisPaintOpSettings::setEraserMode ( bool value)

Definition at line 413 of file kis_paintop_settings.cpp.

414{
416 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
417
418 proxy->setProperty("EraserMode", value);
419}
float value(const T *src, size_t ch)

References KisLockedPropertiesServer::instance(), and value().

◆ setLodSizeThreshold()

void KisPaintOpSettings::setLodSizeThreshold ( qreal value)

Definition at line 624 of file kis_paintop_settings.cpp.

625{
626 setProperty("lodSizeThreshold", value);
627}

References setProperty(), and value().

◆ setLodUserAllowed()

void KisPaintOpSettings::setLodUserAllowed ( KisPropertiesConfigurationSP config,
bool value )
static

Definition at line 609 of file kis_paintop_settings.cpp.

610{
611 config->setProperty("lodUserAllowed", value);
612}

References value().

◆ setModelName()

void KisPaintOpSettings::setModelName ( const QString & modelName)

Set filename of 3D brush model. By default no brush is set

Definition at line 483 of file kis_paintop_settings.cpp.

484{
485 d->modelName = modelName;
486}

References d, and modelName.

◆ setPaintOpAngle()

virtual void KisPaintOpSettings::setPaintOpAngle ( qreal value)
pure virtual

Set paintop angle (in degrees) directly in the properties. Increasing the angle corresponds to a counter-clockwise rotation.

Implemented in KisNoSizePaintOpSettings, KisCurvePaintOpSettings, KisDeformPaintOpSettings, KisGridPaintOpSettings, KisBrushBasedPaintOpSettings, KisMyPaintOpSettings, KisRoundMarkerOpSettings, and KisSprayPaintOpSettings.

◆ setPaintOpCompositeOp()

void KisPaintOpSettings::setPaintOpCompositeOp ( const QString & value)

Set paintop composite mode directly in the properties

Definition at line 344 of file kis_paintop_settings.cpp.

345{
347 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
348
349 proxy->setProperty("CompositeOp", value);
350}

References KisLockedPropertiesServer::instance(), and value().

◆ setPaintOpFade()

void KisPaintOpSettings::setPaintOpFade ( qreal value)

Set paintop fade directly in the properties

Definition at line 313 of file kis_paintop_settings.cpp.

314{
316 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
317
318 if (!proxy->hasProperty("brush_definition")) return;
319
320 // Setting the Fade value is a bit more complex.
321 QDomDocument doc;
322 doc.setContent(proxy->getString("brush_definition"));
323
324 QDomElement element = doc.documentElement();
325 QDomElement elementChild = element.elementsByTagName("MaskGenerator").item(0).toElement();
326
327 elementChild.attributeNode("hfade").setValue(KisDomUtils::toString(value));
328 elementChild.attributeNode("vfade").setValue(KisDomUtils::toString(value));
329
330 proxy->setProperty("brush_definition", doc.toString());
331}
QString toString(const QString &value)

References KisLockedPropertiesServer::instance(), KisDomUtils::toString(), and value().

◆ setPaintOpFlow()

void KisPaintOpSettings::setPaintOpFlow ( qreal value)

Set paintop flow directly in the properties

Definition at line 305 of file kis_paintop_settings.cpp.

306{
308 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
309
310 proxy->setProperty("FlowValue", value);
311}

References KisLockedPropertiesServer::instance(), and value().

◆ setPaintOpOpacity()

void KisPaintOpSettings::setPaintOpOpacity ( qreal value)
virtual

Set paintop opacity directly in the properties

Reimplemented in KisMyPaintOpSettings.

Definition at line 297 of file kis_paintop_settings.cpp.

298{
300 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
301
302 proxy->setProperty("OpacityValue", value);
303}

References KisLockedPropertiesServer::instance(), and value().

◆ setPaintOpScatter()

void KisPaintOpSettings::setPaintOpScatter ( qreal value)

Set paintop scatter directly in the properties

Definition at line 333 of file kis_paintop_settings.cpp.

334{
336 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
337
338 if (!proxy->hasProperty("PressureScatter")) return;
339
340 proxy->setProperty("ScatterValue", value);
341 proxy->setProperty("PressureScatter", !qFuzzyIsNull(value));
342}
static bool qFuzzyIsNull(half h)

References KisLockedPropertiesServer::instance(), qFuzzyIsNull(), and value().

◆ setPaintOpSize()

virtual void KisPaintOpSettings::setPaintOpSize ( qreal value)
pure virtual

◆ setProperty()

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

Overrides the method in KisPropertiesConfiguration to allow onPropertyChanged() callback

Reimplemented from KisPropertiesConfiguration.

Definition at line 573 of file kis_paintop_settings.cpp.

574{
576 UpdateListenerSP updateListener = d->updateListener.toStrongRef();
577
578 if (updateListener) {
579 updateListener->setDirty(true);
580 }
581 }
582
585}
virtual void setProperty(const QString &name, const QVariant &value)

References d, KisPropertiesConfiguration::getProperty(), onPropertyChanged(), KisPropertiesConfiguration::setProperty(), updateListener, and value().

◆ setResourceCacheInterface()

void KisPaintOpSettings::setResourceCacheInterface ( KoResourceCacheInterfaceSP cacheInterface)
virtual

Reimplemented in KisBrushBasedPaintOpSettings.

Definition at line 204 of file kis_paintop_settings.cpp.

205{
206 d->resourceCacheInterface = cacheInterface;
207}

References d.

◆ setResourcesInterface()

void KisPaintOpSettings::setResourcesInterface ( KisResourcesInterfaceSP resourcesInterface)

Set resource interface that will be used for loading linked resources

Definition at line 247 of file kis_paintop_settings.cpp.

248{
249 d->resourcesInterface = resourcesInterface;
250}

References d, and resourcesInterface.

◆ setSavedBrushOpacity()

void KisPaintOpSettings::setSavedBrushOpacity ( qreal value)

Definition at line 472 of file kis_paintop_settings.cpp.

473{
474 setProperty("SavedBrushOpacity", value);
475 setPropertyNotSaved("SavedBrushOpacity");
476}
void setPropertyNotSaved(const QString &name)
Marks a property that should not be saved by toXML.

References setProperty(), KisPropertiesConfiguration::setPropertyNotSaved(), and value().

◆ setSavedBrushSize()

void KisPaintOpSettings::setSavedBrushSize ( qreal value)

Definition at line 450 of file kis_paintop_settings.cpp.

451{
452 setProperty("SavedBrushSize", value);
453 setPropertyNotSaved("SavedBrushSize");
454}

References setProperty(), KisPropertiesConfiguration::setPropertyNotSaved(), and value().

◆ setSavedEraserOpacity()

void KisPaintOpSettings::setSavedEraserOpacity ( qreal value)

Definition at line 461 of file kis_paintop_settings.cpp.

462{
463 setProperty("SavedEraserOpacity", value);
464 setPropertyNotSaved("SavedEraserOpacity");
465}

References setProperty(), KisPropertiesConfiguration::setPropertyNotSaved(), and value().

◆ setSavedEraserSize()

void KisPaintOpSettings::setSavedEraserSize ( qreal value)

Definition at line 439 of file kis_paintop_settings.cpp.

440{
441 setProperty("SavedEraserSize", value);
442 setPropertyNotSaved("SavedEraserSize");
443}

References setProperty(), KisPropertiesConfiguration::setPropertyNotSaved(), and value().

◆ setUpdateListener()

void KisPaintOpSettings::setUpdateListener ( UpdateListenerWSP listener)

Definition at line 114 of file kis_paintop_settings.cpp.

115{
116 d->updateListener = listener;
117}

References d.

◆ uniformProperties()

◆ updateListener()

UpdateListenerWSP KisPaintOpSettings::updateListener ( ) const

◆ useSpacingUpdates()

bool KisPaintOpSettings::useSpacingUpdates ( ) const
virtual

Indicates whether this configuration allows spacing information to be updated between painted dabs during a stroke.

Definition at line 514 of file kis_paintop_settings.cpp.

515{
516 return getBool(SPACING_USE_UPDATES, false);
517}
const QString SPACING_USE_UPDATES

References KisPropertiesConfiguration::getBool(), and SPACING_USE_UPDATES.

Member Data Documentation

◆ canvasResourcesInterface

KoCanvasResourcesInterfaceSP KisPaintOpSettings::canvasResourcesInterface

Definition at line 84 of file kis_paintop_settings.cpp.

◆ d

const QScopedPointer<Private> KisPaintOpSettings::d
private

Definition at line 390 of file kis_paintop_settings.h.

◆ modelName

QString KisPaintOpSettings::modelName

Definition at line 80 of file kis_paintop_settings.cpp.

◆ resourceCacheInterface

KoResourceCacheInterfaceSP KisPaintOpSettings::resourceCacheInterface

Definition at line 85 of file kis_paintop_settings.cpp.

◆ resourcesInterface

KisResourcesInterfaceSP KisPaintOpSettings::resourcesInterface

Definition at line 83 of file kis_paintop_settings.cpp.

◆ settingsWidget

QPointer<KisPaintOpConfigWidget> KisPaintOpSettings::settingsWidget

Definition at line 79 of file kis_paintop_settings.cpp.

◆ uniformProperties

QList< KisUniformPaintOpPropertySP > KisPaintOpSettings::uniformProperties

Definition at line 82 of file kis_paintop_settings.cpp.

◆ updateListener

KisPaintOpSettings::UpdateListenerWSP KisPaintOpSettings::updateListener

Definition at line 81 of file kis_paintop_settings.cpp.

◆ versionCookie

quint64 KisPaintOpSettings::versionCookie

Definition at line 89 of file kis_paintop_settings.cpp.

◆ versionRandomSource

KisRandomSource KisPaintOpSettings::versionRandomSource

Definition at line 88 of file kis_paintop_settings.cpp.


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