11#include <QDomDocument>
13#include <QPainterPath>
48#define SANITY_CHECK_CACHE
50#ifdef SANITY_CHECK_CACHE
58 , versionRandomSource(int(reinterpret_cast<
std::intptr_t>(this)))
59 , versionCookie(versionRandomSource.generate())
65 modelName(rhs.modelName),
66 resourcesInterface(rhs.resourcesInterface),
67 canvasResourcesInterface(rhs.canvasResourcesInterface),
68 resourceCacheInterface(rhs.resourceCacheInterface)
70 , versionRandomSource(int(reinterpret_cast<
std::intptr_t>(this)))
71 , versionCookie(rhs.versionCookie)
87#ifdef SANITY_CHECK_CACHE
116 d->updateListener = listener;
121 return d->updateListener;
127 Q_UNUSED(currentNode);
171 maskingSettings->setPaintOpSize(qMin(maxMaskingBrushSize, masterSizeCoeff *
paintOpSize()));
174 if (
d->resourceCacheInterface) {
175 maskingSettings->setResourceCacheInterface(
178 d->resourceCacheInterface)));
181 return maskingSettings;
196 return d->canvasResourcesInterface;
206 d->resourceCacheInterface = cacheInterface;
211 return d->resourceCacheInterface;
224 maskingSettings->regenerateResourceCache(wrappedCacheInterface);
230#ifdef SANITY_CHECK_CACHE
231 return d->versionCookie;
244 return d->resourcesInterface;
254 QString paintopID =
getString(
"paintop");
255 if (paintopID.isEmpty())
260 while (i.hasNext()) {
262 settings->setProperty(i.key(), QVariant(i.value()));
267#ifdef SANITY_CHECK_CACHE
268 settings->
d->versionCookie = this->
d->versionCookie;
277 allKeys <<
"paintop";
279 QHash<QString, QVariant> preserved;
280 Q_FOREACH (
const QString &key, allKeys) {
288 for (
auto it = preserved.constBegin(); it != preserved.constEnd(); ++it) {
302 proxy->setProperty(
"OpacityValue",
value);
310 proxy->setProperty(
"FlowValue",
value);
318 if (!proxy->hasProperty(
"brush_definition"))
return;
322 doc.setContent(proxy->getString(
"brush_definition"));
324 QDomElement element = doc.documentElement();
325 QDomElement elementChild = element.elementsByTagName(
"MaskGenerator").item(0).toElement();
330 proxy->setProperty(
"brush_definition", doc.toString());
338 if (!proxy->hasProperty(
"PressureScatter"))
return;
340 proxy->setProperty(
"ScatterValue",
value);
349 proxy->setProperty(
"CompositeOp",
value);
356 return proxy->getDouble(
"OpacityValue", 1.0);
364 return proxy->getDouble(
"FlowValue", 1.0);
372 if (!proxy->hasProperty(
"brush_definition"))
return 1.0;
375 doc.setContent(proxy->getString(
"brush_definition"));
377 QDomElement element = doc.documentElement();
378 QDomElement elementChild = element.elementsByTagName(
"MaskGenerator").item(0).toElement();
380 if (elementChild.attributeNode(
"hfade").value().toDouble() >= elementChild.attributeNode(
"vfade").value().toDouble()) {
381 return elementChild.attributeNode(
"hfade").value().toDouble();
383 return elementChild.attributeNode(
"vfade").value().toDouble();
393 return proxy->getDouble(
"ScatterValue", 0.0);
402 return proxy->getDouble(
"Texture/Pattern/Scale", 0.5);
418 proxy->setProperty(
"EraserMode",
value);
426 return proxy->getBool(
"EraserMode",
false);
436 return getDouble(
"SavedEraserSize", 0.0);
458 return getDouble(
"SavedEraserOpacity", 0.0);
469 return getDouble(
"SavedBrushOpacity", 0.0);
510 return 1000.0 / rate;
543 QRectF ellipse(0, 0, width * scale, height * scale);
544 ellipse.translate(-ellipse.center());
545 path.addEllipse(ellipse);
555 QPointF
const& start, qreal maxLength, qreal angle)
557 if (maxLength == 0.0) maxLength = 50.0;
558 maxLength = qMax(maxLength, 50.0);
562 QLineF guideLine = QLineF::fromPolar(
length, baseAngle + angle);
563 guideLine.translate(start);
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());
591 d->resourceCacheInterface.clear();
593#ifdef SANITY_CHECK_CACHE
594 d->versionCookie =
d->versionRandomSource.generate();
606 return config->getBool(
"lodUserAllowed",
true);
611 config->setProperty(
"lodUserAllowed",
value);
621 return getDouble(
"lodSizeThreshold", 100.0);
637 if (props.isEmpty()) {
640 props.append(createProperty(opacity, settings, updateProxy));
641 props.append(createProperty(size, settings, updateProxy));
642 props.append(createProperty(flow, settings, updateProxy));
qreal length(const QPointF &vec)
float value(const T *src, size_t ch)
const QString COMPOSITE_OVER
const QString COMPOSITE_MULT
const QString COMPOSITE_ERASE
const QString COMPOSITE_ALPHA_DARKEN
int maxMaskingBrushSize() const
static KisLockedPropertiesServer * instance()
KisLockedPropertiesProxySP createLockedPropertiesProxy(KisPropertiesConfiguration *settings)
static KisPaintOpRegistry * instance()
KisPaintOpSettingsSP createSettings(const KoID &id, KisResourcesInterfaceSP resourcesInterface) const
static bool qFuzzyIsNull(half h)
#define SANITY_CHECK_CACHE
const QString AIRBRUSH_ENABLED
const QString AIRBRUSH_RATE
const QString SPACING_USE_UPDATES
QSharedPointer< T > toQShared(T *ptr)
Container< QSharedPointer< T > > listWeakToStrong(const Container< QWeakPointer< T > > &container, bool allOrNothing=true)
Container< QWeakPointer< T > > listStrongToWeak(const Container< QSharedPointer< T > > &container)
KisPinnedSharedPtr< KisPaintOpSettings > KisPaintOpSettingsSP
QPointF alignForZoom(const QPointF &pt, qreal zoom)
QString toString(const QString &value)
const char MaskingBrushEnabledTag[]
const char MaskingBrushUseMasterSizeTag[]
const char MaskingBrushPaintOpId[]
const char MaskingBrushMasterSizeCoeffTag[]
const char MaskingBrushPresetPrefix[]
const char MaskingBrushCompositeOpTag[]
virtual ~UpdateListener()
virtual void onPropertyChanged()
virtual void regenerateResourceCache(KoResourceCacheInterfaceSP cacheInterface)
void setSavedEraserSize(qreal value)
static QPainterPath makeTiltIndicator(KisPaintInformation const &info, QPointF const &start, qreal lengthScale, qreal angle)
virtual bool isValid() const
virtual QString indirectPaintingCompositeOp() const
qreal savedEraserOpacity() const
QString paintOpCompositeOp()
quint64 sanityVersionCookie() const
static void setLodUserAllowed(KisPropertiesConfigurationSP config, bool value)
KisRandomSource versionRandomSource
static bool isLodUserAllowed(const KisPropertiesConfigurationSP config)
virtual qreal paintOpOpacity()
virtual bool needsAsynchronousUpdates() const
void setSavedBrushSize(qreal value)
virtual bool hasPatternSettings() const
qreal savedEraserSize() const
KisResourcesInterfaceSP resourcesInterface
~KisPaintOpSettings() override
static KisOptimizedBrushOutline ellipseOutline(qreal width, qreal height, qreal scale, qreal rotation)
void setCanvasResourcesInterface(KoCanvasResourcesInterfaceSP canvasResourcesInterface)
QString effectivePaintOpCompositeOp()
KisPaintOpSettings(KisResourcesInterfaceSP resourcesInterface)
virtual bool mouseReleaseEvent()
virtual qreal paintOpSize() const =0
void setPaintOpCompositeOp(const QString &value)
bool hasMaskingSettings() const
QPointer< KisPaintOpConfigWidget > settingsWidget
void setPaintOpFlow(qreal value)
virtual KisOptimizedBrushOutline brushOutline(const KisPaintInformation &info, const OutlineMode &mode, qreal alignForZoom)
virtual KisPaintOpSettingsSP clone() const
virtual qreal airbrushInterval() const
virtual bool lodSizeThresholdSupported() const
void setModelName(const QString &modelName)
qreal savedBrushSize() const
qreal savedBrushOpacity() const
virtual void resetSettings(const QStringList &preserveProperties=QStringList())
void setProperty(const QString &name, const QVariant &value) override
virtual void setPaintOpOpacity(qreal value)
virtual qreal paintOpPatternSize()
void setEraserMode(bool value)
void setPaintOpFade(qreal value)
qreal lodSizeThreshold() const
void setResourcesInterface(KisResourcesInterfaceSP resourcesInterface)
virtual void setResourceCacheInterface(KoResourceCacheInterfaceSP cacheInterface)
virtual bool isAirbrushing() const
void setSavedBrushOpacity(qreal value)
void setSavedEraserOpacity(qreal value)
const QScopedPointer< Private > d
virtual bool mousePressEvent(const KisPaintInformation &paintInformation, Qt::KeyboardModifiers modifiers, KisNodeWSP currentNode)
KisPaintOpSettingsSP createMaskingSettings() const
KoCanvasResourcesInterfaceSP canvasResourcesInterface
QList< KisUniformPaintOpPropertyWSP > uniformProperties
void setLodSizeThreshold(qreal value)
UpdateListenerWSP updateListener
void setPaintOpScatter(qreal value)
QString maskingBrushCompositeOp() const
void setUpdateListener(UpdateListenerWSP listener)
virtual bool useSpacingUpdates() const
KoResourceCacheInterfaceSP resourceCacheInterface
virtual QList< int > requiredCanvasResources() const
Private(const Private &rhs)
void setPropertyNotSaved(const QString &name)
Marks a property that should not be saved by toXML.
QString getString(const QString &name, const QString &def=QString()) const
void clearProperties()
Clear the map of properties.
virtual bool hasProperty(const QString &name) const
virtual void setProperty(const QString &name, const QVariant &value)
bool getBool(const QString &name, bool def=false) const
double getDouble(const QString &name, double def=0.0) const
void getPrefixedProperties(const QString &prefix, KisPropertiesConfiguration *config) const
virtual bool getProperty(const QString &name, QVariant &value) const
virtual QMap< QString, QVariant > getProperties() const