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

#include <kis_grid_paintop_settings.h>

+ Inheritance diagram for KisGridPaintOpSettings:

Classes

struct  Private
 

Public Member Functions

KisOptimizedBrushOutline brushOutline (const KisPaintInformation &info, const OutlineMode &mode, qreal alignForZoom) override
 
 KisGridPaintOpSettings (KisResourcesInterfaceSP resourcesInterface)
 
bool mousePressEvent (const KisPaintInformation &pos, Qt::KeyboardModifiers modifiers, KisNodeWSP currentNode) override
 
bool mouseReleaseEvent () override
 
bool paintIncremental () override
 
qreal paintOpAngle () const override
 
qreal paintOpSize () const override
 
void setPaintOpAngle (qreal value) override
 
void setPaintOpSize (qreal value) override
 
QList< KisUniformPaintOpPropertySPuniformProperties (KisPaintOpSettingsSP settings, QPointer< KisPaintOpPresetUpdateProxy > updateProxy) override
 
 ~KisGridPaintOpSettings () override
 
- Public Member Functions inherited from KisOutlineGenerationPolicy< KisPaintOpSettings >
 KisOutlineGenerationPolicy (KisCurrentOutlineFetcher::Options options, KisResourcesInterfaceSP resourcesInterface)
 
void onPropertyChanged () override
 
const KisCurrentOutlineFetcheroutlineFetcher () const
 
 ~KisOutlineGenerationPolicy () override
 
- Public Member Functions inherited from KisPaintOpSettings
virtual void activate ()
 
virtual qreal airbrushInterval () const
 
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 needsAsynchronousUpdates () const
 
KisNodeSP node () const
 
QString paintOpCompositeOp ()
 
qreal paintOpFade ()
 
qreal paintOpFlow ()
 
virtual qreal paintOpOpacity ()
 
virtual qreal paintOpPatternSize ()
 
qreal paintOpScatter ()
 
 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)
 
void setPaintOpCompositeOp (const QString &value)
 
void setPaintOpFade (qreal value)
 
void setPaintOpFlow (qreal value)
 
virtual void setPaintOpOpacity (qreal value)
 
void setPaintOpScatter (qreal value)
 
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)
 
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 ()
 

Public Attributes

bool m_modifyOffsetWithShortcut
 
- Public Attributes inherited from KisPaintOpSettings
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
 

Private Attributes

const QScopedPointer< Privatem_d
 

Additional Inherited Members

- Public Types inherited from KisPaintOpSettings
using UpdateListenerSP = QSharedPointer<UpdateListener>
 
using UpdateListenerWSP = QWeakPointer<UpdateListener>
 
- Static Public Member Functions inherited from KisPaintOpSettings
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)
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 

Detailed Description

Definition at line 20 of file kis_grid_paintop_settings.h.

Constructor & Destructor Documentation

◆ KisGridPaintOpSettings()

◆ ~KisGridPaintOpSettings()

KisGridPaintOpSettings::~KisGridPaintOpSettings ( )
override

Definition at line 56 of file kis_grid_paintop_settings.cpp.

57{
58}

Member Function Documentation

◆ brushOutline()

KisOptimizedBrushOutline KisGridPaintOpSettings::brushOutline ( const KisPaintInformation & info,
const OutlineMode & mode,
qreal alignForZoom )
overridevirtual

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 from KisPaintOpSettings.

Definition at line 103 of file kis_grid_paintop_settings.cpp.

104{
106 KisGridOpOptionData option;
107 option.read(this);
108 KisGridShapeOptionData shapeOption;
109 shapeOption.read(this);
110 if (mode.isVisible) {
111 qreal sizex = option.diameter * option.grid_scale;
112 qreal sizey = option.diameter * option.grid_scale;
113 QRectF rc(0, 0, sizex, sizey);
114 rc.translate(-rc.center());
115 path.addRect(rc);
116
117 path = outlineFetcher()->fetchOutline(info, this, path, mode, alignForZoom);
118
119 if (mode.showTiltDecoration) {
120 QPainterPath tiltLine = makeTiltIndicator(info, QPointF(0.0, 0.0), sizex * 0.5, 3.0);
121 path.addPath(outlineFetcher()->fetchOutline(info, this, tiltLine, mode, alignForZoom, 1.0, 0.0, true, 0, 0));
122 }
123 }
125 qreal gridWidth = option.diameter * option.grid_scale ;
126 qreal gridHeight = option.diameter * option.grid_scale ;
127
128 qreal cellWidth = option.grid_width * option.grid_scale ;
129 qreal cellHeight = option.grid_height * option.grid_scale;
130
131 qreal horizontalOffset = option.horizontal_offset;
132 qreal verticalOffset = option.vertical_offset;
133
134 int divide;
135 if (option.grid_pressure_division) {
136 divide = option.grid_division_level * info.pressure();
137 }
138 else {
139 divide = option.grid_division_level;
140 }
141
142 divide = qRound(option.grid_scale * divide);
143
144 //Adjust the start position of the drawn grid to the top left of the brush instead of in the center
145 qreal posX = info.pos().x() - (gridWidth/2) + (cellWidth/2) - horizontalOffset;
146 qreal posY = info.pos().y() - (gridHeight/2) + (cellHeight/2) - verticalOffset;
147
148 //Lock the grid alignment
149 posX = posX - std::fmod(posX, cellWidth) + horizontalOffset;
150 posY = posY - std::fmod(posY, cellHeight) + verticalOffset;
151 const QRectF dabRect(posX , posY , cellWidth, cellHeight);
152
153 divide = qMax(1, divide);
154 const qreal yStep = cellHeight / (qreal)divide;
155 const qreal xStep = cellWidth / (qreal)divide;
156
157 QRectF tile;
158 QPainterPath cellPath;
159 for (int y = 0; y < (gridHeight)/yStep; y++) {
160 for (int x = 0; x < (gridWidth)/xStep; x++) {
161 tile = QRectF(dabRect.x() + x * xStep, dabRect.y() + y * yStep, xStep, yStep);
162 switch (shapeOption.shape) {
163 case 0: {
164 cellPath.addEllipse(tile);
165 break;
166 }
167 case 1: {
168 cellPath.addRect(tile);
169 break;
170 }
171 case 2: {
172 cellPath.moveTo(tile.topRight());
173 cellPath.lineTo(tile.bottomLeft());
174 break;
175 }
176 case 3: {
177 cellPath.moveTo(tile.topRight());
178 cellPath.lineTo(tile.bottomLeft());
179 break;
180 }
181 case 4: {
182 cellPath.moveTo(tile.topRight());
183 cellPath.lineTo(tile.bottomLeft());
184 break;
185 }
186 default: {
187 break;
188 }
189 }
190 }
191 }
192 KisOptimizedBrushOutline cellPath2 = outlineFetcher()->fetchOutline(info, this, cellPath, mode, alignForZoom);
193 path.addPath(cellPath2);
194 }
195 return path;
196}
KisOptimizedBrushOutline fetchOutline(const KisPaintInformation &info, const KisPaintOpSettingsSP settings, const KisOptimizedBrushOutline &originalOutline, const KisPaintOpSettings::OutlineMode &mode, qreal alignForZoom, qreal additionalScale=1.0, qreal additionalRotation=0.0, bool tilt=false, qreal tiltcenterx=1.0, qreal tiltcentery=1.0) const
void addPath(const QPainterPath &path)
const KisCurrentOutlineFetcher * outlineFetcher() const
const QPointF & pos() const
qreal pressure() const
The pressure of the value (from 0.0 to 1.0)
bool read(const KisPropertiesConfiguration *setting)
bool read(const KisPropertiesConfiguration *setting)
int shape
Ellipse, rectangle, line, pixel, anti-aliased pixel.
static QPainterPath makeTiltIndicator(KisPaintInformation const &info, QPointF const &start, qreal lengthScale, qreal angle)

References KisOptimizedBrushOutline::addPath(), KisGridOpOptionData::diameter, KisCurrentOutlineFetcher::fetchOutline(), KisGridOpOptionData::grid_division_level, KisGridOpOptionData::grid_height, KisGridOpOptionData::grid_pressure_division, KisGridOpOptionData::grid_scale, KisGridOpOptionData::grid_width, KisGridOpOptionData::horizontal_offset, KisPaintOpSettings::OutlineMode::isVisible, m_modifyOffsetWithShortcut, KisPaintOpSettings::makeTiltIndicator(), KisOutlineGenerationPolicy< KisPaintOpSettings >::outlineFetcher(), KisPaintInformation::pos(), KisPaintInformation::pressure(), KisGridOpOptionData::read(), KisGridShapeOptionData::read(), KisGridShapeOptionData::shape, KisPaintOpSettings::OutlineMode::showTiltDecoration, and KisGridOpOptionData::vertical_offset.

◆ mousePressEvent()

bool KisGridPaintOpSettings::mousePressEvent ( const KisPaintInformation & paintInformation,
Qt::KeyboardModifiers modifiers,
KisNodeWSP currentNode )
overridevirtual

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 from KisPaintOpSettings.

Definition at line 67 of file kis_grid_paintop_settings.cpp.

68{
69 Q_UNUSED(currentNode);
70
72 option.read(this);
73 bool eventIgnored = true;
74 qreal newHorizontalOffset = std::fmod(info.pos().x() + option.grid_width/2.0, (float)option.grid_width);
75 qreal newVerticalOffset = std::fmod(info.pos().y() + option.grid_height/2.0, (float)option.grid_height);
76
77 // If pressing ctrl+alt change the offset according to mouse position
78 if (modifiers == (Qt::ControlModifier | Qt::AltModifier) || m_modifyOffsetWithShortcut) {
80 newHorizontalOffset = (newHorizontalOffset / (float)option.grid_width);
81 newVerticalOffset = (newVerticalOffset / (float)option.grid_height);
82
83 if (newHorizontalOffset > 0.5) {
84 newHorizontalOffset = newHorizontalOffset - 1;
85 }
86 if (newVerticalOffset > 0.5) {
87 newVerticalOffset = newVerticalOffset -1;
88 }
89 option.horizontal_offset = newHorizontalOffset * option.grid_width;
90 option.vertical_offset = newVerticalOffset * option.grid_height;
91 option.write(this);
92 eventIgnored = false;
93 }
94 return eventIgnored;
95}
void write(KisPropertiesConfiguration *setting) const

References KisGridOpOptionData::grid_height, KisGridOpOptionData::grid_width, KisGridOpOptionData::horizontal_offset, m_modifyOffsetWithShortcut, KisPaintInformation::pos(), KisGridOpOptionData::read(), KisGridOpOptionData::vertical_offset, and KisGridOpOptionData::write().

◆ mouseReleaseEvent()

bool KisGridPaintOpSettings::mouseReleaseEvent ( )
overridevirtual

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 from KisPaintOpSettings.

Definition at line 97 of file kis_grid_paintop_settings.cpp.

98{
100 bool ignoreEvent = true;
101 return ignoreEvent;
102}

References m_modifyOffsetWithShortcut.

◆ paintIncremental()

bool KisGridPaintOpSettings::paintIncremental ( )
overridevirtual

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 from KisPaintOpSettings.

Definition at line 60 of file kis_grid_paintop_settings.cpp.

References BUILDUP, KisPaintingModeOptionData::paintingMode, and KisPaintingModeOptionData::read().

◆ paintOpAngle()

qreal KisGridPaintOpSettings::paintOpAngle ( ) const
overridevirtual
Returns
paintop angle (in degrees) saved in the properties

Implements KisPaintOpSettings.

Definition at line 51 of file kis_grid_paintop_settings.cpp.

52{
53 return 0.0;
54}

◆ paintOpSize()

qreal KisGridPaintOpSettings::paintOpSize ( ) const
overridevirtual
Returns
size saved in the properties

Implements KisPaintOpSettings.

Definition at line 39 of file kis_grid_paintop_settings.cpp.

40{
42 option.read(this);
43 return option.diameter;
44}

References KisGridOpOptionData::diameter, and KisGridOpOptionData::read().

◆ setPaintOpAngle()

void KisGridPaintOpSettings::setPaintOpAngle ( qreal value)
overridevirtual

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

Implements KisPaintOpSettings.

Definition at line 46 of file kis_grid_paintop_settings.cpp.

47{
48 Q_UNUSED(value);
49}
float value(const T *src, size_t ch)

References value().

◆ setPaintOpSize()

void KisGridPaintOpSettings::setPaintOpSize ( qreal value)
overridevirtual

Set paintop size directly in the properties

Implements KisPaintOpSettings.

Definition at line 31 of file kis_grid_paintop_settings.cpp.

32{
34 option.read(this);
35 option.diameter = value;
36 option.write(this);
37}

References KisGridOpOptionData::diameter, KisGridOpOptionData::read(), value(), and KisGridOpOptionData::write().

◆ uniformProperties()

QList< KisUniformPaintOpPropertySP > KisGridPaintOpSettings::uniformProperties ( KisPaintOpSettingsSP settings,
QPointer< KisPaintOpPresetUpdateProxy > updateProxy )
overridevirtual

Reimplemented from KisPaintOpSettings.

Definition at line 203 of file kis_grid_paintop_settings.cpp.

204{
206 listWeakToStrong(m_d->uniformProperties);
207
208 if (props.isEmpty()) {
209 {
210 KisIntSliderBasedPaintOpPropertyCallback *prop = new KisIntSliderBasedPaintOpPropertyCallback(KisIntSliderBasedPaintOpPropertyCallback::Int,
211 KoID("grid_divisionlevel", i18n("Division Level")),
212 settings,
213 0);
214
215 prop->setRange(1, 25);
216 prop->setSingleStep(1);
217
218 prop->setReadCallback(
219 [](KisUniformPaintOpProperty *prop) {
220 KisGridOpOptionData option;
221 option.read(prop->settings().data());
222
223 prop->setValue(int(option.grid_division_level));
224 });
225 prop->setWriteCallback(
226 [](KisUniformPaintOpProperty *prop) {
227 KisGridOpOptionData option;
228 option.read(prop->settings().data());
229 option.grid_division_level = prop->value().toInt();
230 option.write(prop->settings().data());
231 });
232
233 QObject::connect(updateProxy, SIGNAL(sigSettingsChanged()), prop, SLOT(requestReadValue()));
234 prop->requestReadValue();
235 props << toQShared(prop);
236 }
237 }
238
239 return KisPaintOpSettings::uniformProperties(settings, updateProxy) + props;
240}
void setValue(const QVariant &value)
KisPaintOpSettingsSP settings() const
Definition KoID.h:30
QSharedPointer< T > toQShared(T *ptr)
Container< QSharedPointer< T > > listWeakToStrong(const Container< QWeakPointer< T > > &container, bool allOrNothing=true)
KisCallbackBasedPaintopProperty< KisSliderBasedPaintOpProperty< int > > KisIntSliderBasedPaintOpPropertyCallback
QList< KisUniformPaintOpPropertyWSP > uniformProperties

References KisGridOpOptionData::grid_division_level, listWeakToStrong(), m_d, KisGridOpOptionData::read(), KisCallbackBasedPaintopProperty< ParentClass >::setReadCallback(), KisCallbackBasedPaintopProperty< ParentClass >::setWriteCallback(), toQShared(), KisPaintOpSettings::uniformProperties, and KisGridOpOptionData::write().

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisGridPaintOpSettings::m_d
private

Definition at line 43 of file kis_grid_paintop_settings.h.

◆ m_modifyOffsetWithShortcut

bool KisGridPaintOpSettings::m_modifyOffsetWithShortcut

Definition at line 46 of file kis_grid_paintop_settings.h.


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