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

#include <kis_paintop_settings.h>

+ Inheritance diagram for KisPaintOpSettings:

Classes

class  DirtyNotificationsLocker
 
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 setRandomOffset (const KisPaintInformation &paintInformation)
 
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
 
bool disableDirtyNotifications
 
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 119 of file kis_paintop_settings.cpp.

120 : d(new Private)
121{
122 d->resourcesInterface = resourcesInterface;
123}
KisResourcesInterfaceSP resourcesInterface
const QScopedPointer< Private > d

References d, and resourcesInterface.

◆ ~KisPaintOpSettings()

KisPaintOpSettings::~KisPaintOpSettings ( )
override

Definition at line 125 of file kis_paintop_settings.cpp.

126{
127}

◆ 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 333 of file kis_paintop_settings.cpp.

334{
335}

◆ 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 543 of file kis_paintop_settings.cpp.

544{
545 qreal rate = getDouble(AIRBRUSH_RATE, 1.0);
546 if (rate == 0.0) {
547 return LONG_TIME;
548 }
549 else {
550 return 1000.0 / rate;
551 }
552}
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 564 of file kis_paintop_settings.cpp.

565{
567 if (mode.isVisible) {
568 path = ellipseOutline(10, 10, 1.0, 0);
569
570 if (mode.showTiltDecoration) {
571 path.addPath(makeTiltIndicator(info, QPointF(0.0, 0.0), 0.0, 2.0));
572 }
573
574 path.translate(KisAlgebra2D::alignForZoom(info.pos(), alignForZoom));
575 }
576
577 return path;
578}
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 292 of file kis_paintop_settings.cpp.

293{
294 QString paintopID = getString("paintop");
295 if (paintopID.isEmpty())
296 return 0;
297
299 QMapIterator<QString, QVariant> i(getProperties());
300 while (i.hasNext()) {
301 i.next();
302 settings->setProperty(i.key(), QVariant(i.value()));
303 }
304
305 settings->setCanvasResourcesInterface(this->canvasResourcesInterface());
306
307#ifdef SANITY_CHECK_CACHE
308 settings->d->versionCookie = this->d->versionCookie;
309#endif
310
311 return settings;
312}
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 181 of file kis_paintop_settings.cpp.

182{
184
185 const KoID pixelBrushId(KisPaintOpUtils::MaskingBrushPaintOpId, QString());
186
188 maskingSettings->setCanvasResourcesInterface(canvasResourcesInterface());
189
191
192 const bool useMasterSize = this->getBool(KisPaintOpUtils::MaskingBrushUseMasterSizeTag, true);
193 if (useMasterSize) {
209 const qreal maxMaskingBrushSize = KisImageConfig(true).maxMaskingBrushSize();
210 const qreal masterSizeCoeff = getDouble(KisPaintOpUtils::MaskingBrushMasterSizeCoeffTag, 1.0);
211 maskingSettings->setPaintOpSize(qMin(maxMaskingBrushSize, masterSizeCoeff * paintOpSize()));
212 }
213
214 if (d->resourceCacheInterface) {
215 maskingSettings->setResourceCacheInterface(
218 d->resourceCacheInterface)));
219 }
220
221 return maskingSettings;
222}
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(), hasMaskingSettings(), KisPaintOpRegistry::instance(), KisPaintOpUtils::MaskingBrushPaintOpId, and resourcesInterface.

◆ effectivePaintOpCompositeOp()

QString KisPaintOpSettings::effectivePaintOpCompositeOp ( )

Definition at line 469 of file kis_paintop_settings.cpp.

470{
472}
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 580 of file kis_paintop_settings.cpp.

581{
582 QPainterPath path;
583 QRectF ellipse(0, 0, width * scale, height * scale);
584 ellipse.translate(-ellipse.center());
585 path.addEllipse(ellipse);
586
587 QTransform m;
588 m.reset();
589 m.rotate(rotation);
590 path = m.map(path);
591 return path;
592}

◆ eraserMode()

bool KisPaintOpSettings::eraserMode ( )

Definition at line 461 of file kis_paintop_settings.cpp.

462{
464 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
465
466 return proxy->getBool("EraserMode", false);
467}
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 176 of file kis_paintop_settings.cpp.

177{
179}
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 224 of file kis_paintop_settings.cpp.

225{
226 return false;
227}

◆ 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 533 of file kis_paintop_settings.cpp.

534{
536}
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 538 of file kis_paintop_settings.cpp.

539{
540 return getBool(AIRBRUSH_ENABLED, false);
541}
const QString AIRBRUSH_ENABLED

References AIRBRUSH_ENABLED, and KisPropertiesConfiguration::getBool().

◆ isLodUserAllowed()

bool KisPaintOpSettings::isLodUserAllowed ( const KisPropertiesConfigurationSP config)
static

Definition at line 644 of file kis_paintop_settings.cpp.

645{
646 return config->getBool("lodUserAllowed", true);
647}

◆ 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 528 of file kis_paintop_settings.cpp.

529{
530 return true;
531}

◆ lodSizeThreshold()

qreal KisPaintOpSettings::lodSizeThreshold ( ) const

Definition at line 659 of file kis_paintop_settings.cpp.

660{
661 return getDouble("lodSizeThreshold", 100.0);
662}

References KisPropertiesConfiguration::getDouble().

◆ lodSizeThresholdSupported()

bool KisPaintOpSettings::lodSizeThresholdSupported ( ) const
virtual

Definition at line 654 of file kis_paintop_settings.cpp.

655{
656 return true;
657}

◆ 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 594 of file kis_paintop_settings.cpp.

596{
597 if (maxLength == 0.0) maxLength = 50.0;
598 maxLength = qMax(maxLength, 50.0);
599 qreal const length = maxLength * (1 - info.tiltElevation(info, 60.0, 60.0, true));
600 qreal const baseAngle = 360.0 - fmod(KisPaintInformation::tiltDirection(info, true) * 360.0 + 270.0, 360.0);
601
602 QLineF guideLine = QLineF::fromPolar(length, baseAngle + angle);
603 guideLine.translate(start);
604 QPainterPath ret;
605 ret.moveTo(guideLine.p1());
606 ret.lineTo(guideLine.p2());
607 guideLine.setAngle(baseAngle - angle);
608 ret.lineTo(guideLine.p2());
609 ret.lineTo(guideLine.p1());
610 return ret;
611}
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 277 of file kis_paintop_settings.cpp.

278{
280}
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 145 of file kis_paintop_settings.cpp.

146{
147 Q_UNUSED(modifiers);
148 Q_UNUSED(currentNode);
149 setRandomOffset(paintInformation);
150 return true; // ignore the event by default
151}
virtual void setRandomOffset(const KisPaintInformation &paintInformation)

References setRandomOffset().

◆ 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 153 of file kis_paintop_settings.cpp.

154{
155 return true; // ignore the event by default
156}

◆ 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 559 of file kis_paintop_settings.cpp.

560{
561 return false;
562}

◆ 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 628 of file kis_paintop_settings.cpp.

629{
630 // clear cached data for the resource
631 d->resourceCacheInterface.clear();
632
633#ifdef SANITY_CHECK_CACHE
634 d->versionCookie = d->versionRandomSource.generate();
635#endif
636
637 UpdateListenerSP updateListener = d->updateListener.toStrongRef();
638
639 if (updateListener) {
640 updateListener->notifySettingsChanged();
641 }
642}
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 445 of file kis_paintop_settings.cpp.

446{
448 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
449
450 return proxy->getString("CompositeOp", COMPOSITE_OVER);
451}
const QString COMPOSITE_OVER

References COMPOSITE_OVER, and KisLockedPropertiesServer::instance().

◆ paintOpFade()

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

Definition at line 407 of file kis_paintop_settings.cpp.

408{
410 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
411
412 if (!proxy->hasProperty("brush_definition")) return 1.0;
413
414 QDomDocument doc;
415 doc.setContent(proxy->getString("brush_definition"));
416
417 QDomElement element = doc.documentElement();
418 QDomElement elementChild = element.elementsByTagName("MaskGenerator").item(0).toElement();
419
420 if (elementChild.attributeNode("hfade").value().toDouble() >= elementChild.attributeNode("vfade").value().toDouble()) {
421 return elementChild.attributeNode("hfade").value().toDouble();
422 } else {
423 return elementChild.attributeNode("vfade").value().toDouble();
424 }
425
426}

References KisLockedPropertiesServer::instance().

◆ paintOpFlow()

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

Definition at line 399 of file kis_paintop_settings.cpp.

400{
402 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
403
404 return proxy->getDouble("FlowValue", 1.0);
405}

References KisLockedPropertiesServer::instance().

◆ paintOpOpacity()

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

Reimplemented in KisMyPaintOpSettings.

Definition at line 392 of file kis_paintop_settings.cpp.

393{
395
396 return proxy->getDouble("OpacityValue", 1.0);
397}
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 437 of file kis_paintop_settings.cpp.

438{
440 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
441
442 return proxy->getDouble("Texture/Pattern/Scale", 0.5);
443}

References KisLockedPropertiesServer::instance().

◆ paintOpScatter()

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

Definition at line 428 of file kis_paintop_settings.cpp.

429{
431 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
432
433 return proxy->getDouble("ScatterValue", 0.0);
434}

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

◆ 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),
70#ifdef SANITY_CHECK_CACHE
71 , versionRandomSource(int(reinterpret_cast<std::intptr_t>(this)))
72 , versionCookie(rhs.versionCookie)
73#endif
74 {
78 }
QPointer< KisPaintOpConfigWidget > settingsWidget
KoResourceCacheInterfaceSP resourceCacheInterface

◆ regenerateResourceCache()

void KisPaintOpSettings::regenerateResourceCache ( KoResourceCacheInterfaceSP cacheInterface)
virtual

Reimplemented in KisBrushBasedPaintOpSettings.

Definition at line 254 of file kis_paintop_settings.cpp.

255{
256 if (hasMaskingSettings()) {
258
259 KoResourceCacheInterfaceSP wrappedCacheInterface =
262 cacheInterface));
263
264 maskingSettings->regenerateResourceCache(wrappedCacheInterface);
265 }
266}
KisPaintOpSettingsSP createMaskingSettings() const

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

◆ requiredCanvasResources()

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

Reimplemented in KisBrushBasedPaintOpSettings.

Definition at line 229 of file kis_paintop_settings.cpp.

230{
231 return {};
232}

◆ 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 314 of file kis_paintop_settings.cpp.

315{
316 QStringList allKeys = preserveProperties;
317 allKeys << "paintop";
318
319 QHash<QString, QVariant> preserved;
320 Q_FOREACH (const QString &key, allKeys) {
321 if (hasProperty(key)) {
322 preserved[key] = getProperty(key);
323 }
324 }
325
327
328 for (auto it = preserved.constBegin(); it != preserved.constEnd(); ++it) {
329 setProperty(it.key(), it.value());
330 }
331}
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 268 of file kis_paintop_settings.cpp.

269{
270#ifdef SANITY_CHECK_CACHE
271 return d->versionCookie;
272#else
273 return 0;
274#endif
275}

References d.

◆ savedBrushOpacity()

qreal KisPaintOpSettings::savedBrushOpacity ( ) const

Definition at line 507 of file kis_paintop_settings.cpp.

508{
509 return getDouble("SavedBrushOpacity", 0.0);
510}

References KisPropertiesConfiguration::getDouble().

◆ savedBrushSize()

qreal KisPaintOpSettings::savedBrushSize ( ) const

Definition at line 485 of file kis_paintop_settings.cpp.

486{
487 return getDouble("SavedBrushSize", 0.0);
488}

References KisPropertiesConfiguration::getDouble().

◆ savedEraserOpacity()

qreal KisPaintOpSettings::savedEraserOpacity ( ) const

Definition at line 496 of file kis_paintop_settings.cpp.

497{
498 return getDouble("SavedEraserOpacity", 0.0);
499}

References KisPropertiesConfiguration::getDouble().

◆ savedEraserSize()

qreal KisPaintOpSettings::savedEraserSize ( ) const

Definition at line 474 of file kis_paintop_settings.cpp.

475{
476 return getDouble("SavedEraserSize", 0.0);
477}

References KisPropertiesConfiguration::getDouble().

◆ setCanvasResourcesInterface()

void KisPaintOpSettings::setCanvasResourcesInterface ( KoCanvasResourcesInterfaceSP canvasResourcesInterface)

Definition at line 239 of file kis_paintop_settings.cpp.

240{
241 d->canvasResourcesInterface = canvasResourcesInterface;
242}

References canvasResourcesInterface, and d.

◆ setEraserMode()

void KisPaintOpSettings::setEraserMode ( bool value)

Definition at line 453 of file kis_paintop_settings.cpp.

454{
456 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
457
458 proxy->setProperty("EraserMode", value);
459}
float value(const T *src, size_t ch)

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

◆ setLodSizeThreshold()

void KisPaintOpSettings::setLodSizeThreshold ( qreal value)

Definition at line 664 of file kis_paintop_settings.cpp.

665{
666 setProperty("lodSizeThreshold", value);
667}

References setProperty(), and value().

◆ setLodUserAllowed()

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

Definition at line 649 of file kis_paintop_settings.cpp.

650{
651 config->setProperty("lodUserAllowed", value);
652}

References value().

◆ setModelName()

void KisPaintOpSettings::setModelName ( const QString & modelName)

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

Definition at line 523 of file kis_paintop_settings.cpp.

524{
525 d->modelName = modelName;
526}

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 384 of file kis_paintop_settings.cpp.

385{
387 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
388
389 proxy->setProperty("CompositeOp", value);
390}

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

◆ setPaintOpFade()

void KisPaintOpSettings::setPaintOpFade ( qreal value)

Set paintop fade directly in the properties

Definition at line 353 of file kis_paintop_settings.cpp.

354{
356 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
357
358 if (!proxy->hasProperty("brush_definition")) return;
359
360 // Setting the Fade value is a bit more complex.
361 QDomDocument doc;
362 doc.setContent(proxy->getString("brush_definition"));
363
364 QDomElement element = doc.documentElement();
365 QDomElement elementChild = element.elementsByTagName("MaskGenerator").item(0).toElement();
366
367 elementChild.attributeNode("hfade").setValue(KisDomUtils::toString(value));
368 elementChild.attributeNode("vfade").setValue(KisDomUtils::toString(value));
369
370 proxy->setProperty("brush_definition", doc.toString());
371}
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 345 of file kis_paintop_settings.cpp.

346{
348 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
349
350 proxy->setProperty("FlowValue", value);
351}

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 337 of file kis_paintop_settings.cpp.

338{
340 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
341
342 proxy->setProperty("OpacityValue", value);
343}

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

◆ setPaintOpScatter()

void KisPaintOpSettings::setPaintOpScatter ( qreal value)

Set paintop scatter directly in the properties

Definition at line 373 of file kis_paintop_settings.cpp.

374{
376 KisLockedPropertiesServer::instance()->createLockedPropertiesProxy(this));
377
378 if (!proxy->hasProperty("PressureScatter")) return;
379
380 proxy->setProperty("ScatterValue", value);
381 proxy->setProperty("PressureScatter", !qFuzzyIsNull(value));
382}
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 613 of file kis_paintop_settings.cpp.

614{
615 if (value != KisPropertiesConfiguration::getProperty(name) && !d->disableDirtyNotifications) {
616 UpdateListenerSP updateListener = d->updateListener.toStrongRef();
617
618 if (updateListener) {
619 updateListener->setDirty(true);
620 }
621 }
622
625}
virtual void setProperty(const QString &name, const QVariant &value)

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

◆ setRandomOffset()

void KisPaintOpSettings::setRandomOffset ( const KisPaintInformation & paintInformation)
virtual

This function is called to set random offsets to the brush whenever the mouse is clicked. It is specific to when the pattern option is set.

Definition at line 158 of file kis_paintop_settings.cpp.

159{
160 bool disableDirtyBefore = d->disableDirtyNotifications;
161 d->disableDirtyNotifications = true;
162 if (getBool("Texture/Pattern/Enabled")) {
163 if (getBool("Texture/Pattern/isRandomOffsetX")) {
164 setProperty("Texture/Pattern/OffsetX",
165 paintInformation.randomSource()->generate(0, KisPropertiesConfiguration::getInt("Texture/Pattern/MaximumOffsetX")));
166 }
167 if (getBool("Texture/Pattern/isRandomOffsetY")) {
168 setProperty("Texture/Pattern/OffsetY",
169 paintInformation.randomSource()->generate(0, KisPropertiesConfiguration::getInt("Texture/Pattern/MaximumOffsetY")));
170
171 }
172 }
173 d->disableDirtyNotifications = disableDirtyBefore;
174}
KisRandomSourceSP randomSource() const
int getInt(const QString &name, int def=0) const

References d, KisRandomSource::generate(), KisPropertiesConfiguration::getBool(), KisPropertiesConfiguration::getInt(), KisPaintInformation::randomSource(), and setProperty().

◆ setResourceCacheInterface()

void KisPaintOpSettings::setResourceCacheInterface ( KoResourceCacheInterfaceSP cacheInterface)
virtual

Reimplemented in KisBrushBasedPaintOpSettings.

Definition at line 244 of file kis_paintop_settings.cpp.

245{
246 d->resourceCacheInterface = cacheInterface;
247}

References d.

◆ setResourcesInterface()

void KisPaintOpSettings::setResourcesInterface ( KisResourcesInterfaceSP resourcesInterface)

Set resource interface that will be used for loading linked resources

Definition at line 287 of file kis_paintop_settings.cpp.

288{
289 d->resourcesInterface = resourcesInterface;
290}

References d, and resourcesInterface.

◆ setSavedBrushOpacity()

void KisPaintOpSettings::setSavedBrushOpacity ( qreal value)

Definition at line 512 of file kis_paintop_settings.cpp.

513{
514 setProperty("SavedBrushOpacity", value);
515 setPropertyNotSaved("SavedBrushOpacity");
516}
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 490 of file kis_paintop_settings.cpp.

491{
492 setProperty("SavedBrushSize", value);
493 setPropertyNotSaved("SavedBrushSize");
494}

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

◆ setSavedEraserOpacity()

void KisPaintOpSettings::setSavedEraserOpacity ( qreal value)

Definition at line 501 of file kis_paintop_settings.cpp.

502{
503 setProperty("SavedEraserOpacity", value);
504 setPropertyNotSaved("SavedEraserOpacity");
505}

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

◆ setSavedEraserSize()

void KisPaintOpSettings::setSavedEraserSize ( qreal value)

Definition at line 479 of file kis_paintop_settings.cpp.

480{
481 setProperty("SavedEraserSize", value);
482 setPropertyNotSaved("SavedEraserSize");
483}

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

◆ setUpdateListener()

void KisPaintOpSettings::setUpdateListener ( UpdateListenerWSP listener)

Definition at line 135 of file kis_paintop_settings.cpp.

136{
137 d->updateListener = listener;
138}

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 554 of file kis_paintop_settings.cpp.

555{
556 return getBool(SPACING_USE_UPDATES, false);
557}
const QString SPACING_USE_UPDATES

References KisPropertiesConfiguration::getBool(), and SPACING_USE_UPDATES.

Member Data Documentation

◆ canvasResourcesInterface

KoCanvasResourcesInterfaceSP KisPaintOpSettings::canvasResourcesInterface

Definition at line 85 of file kis_paintop_settings.cpp.

◆ d

const QScopedPointer<Private> KisPaintOpSettings::d
private

Definition at line 397 of file kis_paintop_settings.h.

◆ disableDirtyNotifications

bool KisPaintOpSettings::disableDirtyNotifications

Definition at line 88 of file kis_paintop_settings.cpp.

◆ modelName

QString KisPaintOpSettings::modelName

Definition at line 81 of file kis_paintop_settings.cpp.

◆ resourceCacheInterface

KoResourceCacheInterfaceSP KisPaintOpSettings::resourceCacheInterface

Definition at line 86 of file kis_paintop_settings.cpp.

◆ resourcesInterface

KisResourcesInterfaceSP KisPaintOpSettings::resourcesInterface

Definition at line 84 of file kis_paintop_settings.cpp.

◆ settingsWidget

QPointer<KisPaintOpConfigWidget> KisPaintOpSettings::settingsWidget

Definition at line 80 of file kis_paintop_settings.cpp.

◆ uniformProperties

QList< KisUniformPaintOpPropertySP > KisPaintOpSettings::uniformProperties

Definition at line 83 of file kis_paintop_settings.cpp.

◆ updateListener

KisPaintOpSettings::UpdateListenerWSP KisPaintOpSettings::updateListener

Definition at line 82 of file kis_paintop_settings.cpp.

◆ versionCookie

quint64 KisPaintOpSettings::versionCookie

Definition at line 92 of file kis_paintop_settings.cpp.

◆ versionRandomSource

KisRandomSource KisPaintOpSettings::versionRandomSource

Definition at line 91 of file kis_paintop_settings.cpp.


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