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

#include <kis_preset_live_preview_view.h>

+ Inheritance diagram for KisPresetLivePreviewView:

Signals

void sigPreviewImageReady (int presetId, QImage previewImage)
 Emitted when a preview image is generated.
 

Public Member Functions

 KisPresetLivePreviewView (QWidget *parent)
 
void requestUpdateStroke ()
 
void requestUpdateStrokeImmediate ()
 
KoCanvasResourceProvider * resourceManager () const
 
void setCachePreviewMode (bool enabled)
 
void setCurrentPreset (KisPaintOpPresetSP preset)
 set the current preset from resource manager for the live preview to use. Good to call this every stroke update in case the preset has changed
 
void setup (KoCanvasResourceProvider *resourceManager)
 one time setup for initialization of many variables. This live preview might be in a UI file, so make sure to call this before starting to use it
 
 ~KisPresetLivePreviewView ()
 

Private Slots

void slotPreviewGenerationCompleted ()
 
void updateStroke ()
 

Private Member Functions

void changeEvent (QEvent *) override
 
void paintBackground (bool cacheMode)
 works as both clearing the previous stroke, providing striped backgrounds for smudging brushes, and text if there is no preview
 
void paintStripedBackground ()
 Paint alternating gray stripes on the paint device.
 
void setupAndPaintStroke ()
 creates and performs the actual stroke that goes on top of the background this is internally and should always be called after the paintBackground()
 

Private Attributes

QGraphicsScene * m_brushPreviewScene {nullptr}
 the scene that can add items like text and the brush stroke image
 
bool m_cachePreviewMode {false}
 
QPointF m_canvasCenterPoint
 
QRect m_canvasSize
 
const KoColorSpace * m_colorSpace {nullptr}
 internally sets the color space for brush preview
 
float m_currentBrushSize {1.0}
 
KisDistanceInformation m_currentDistance
 
KisPaintOpPresetSP m_currentPreset
 
QPainterPath m_curvedLine
 
KisPaintInformation m_curvePointPI1
 
KisPaintInformation m_curvePointPI2
 
KisImageSP m_image
 internally sets the image area for brush preview
 
QImage m_lastPreviewImage
 Last preview image.
 
KisLayerSP m_layer
 internally sets the layer area for brush preview
 
const float m_maxBrushVal {100.0}
 
const qreal m_maxScale {0.3}
 
const float m_maxStrokeScale {1.0}
 
const float m_minBrushVal {10.0}
 the range of brush sizes that will control zooming in/out
 
const qreal m_minScale {1.0}
 range of scale values. 1.0 == 100%
 
const float m_minStrokeScale {0.4}
 multiplier that is used for lengthening the brush stroke points
 
QGraphicsTextItem * m_noPreviewText {nullptr}
 holds the 'no preview available' text object
 
KoColor m_paintColor
 the color which is used for rendering the stroke
 
bool m_previewGenerationInProgress {false}
 
int m_previewPresetId {-1}
 presetId (resource id) associated with the in-flight preview generation.
 
KoCanvasResourceProvider * m_resourceManager {nullptr}
 internally sets the Resource Provider for brush preview (allowing gradients in preview)
 
QGraphicsPixmapItem * m_sceneImageItem {nullptr}
 holds the preview brush stroke data
 
KisSignalCompressor m_updateCompressor
 

Static Private Attributes

static constexpr int DefaultUpdateDelayMs = 100
 

Detailed Description

Widget for displaying a live brush preview of your selected brush. It listens for signalsetting changes that the brush preset outputs and updates the preview accordingly. This class can be added to a UI file similar to how a QGraphicsView is added

Definition at line 34 of file kis_preset_live_preview_view.h.

Constructor & Destructor Documentation

◆ KisPresetLivePreviewView()

KisPresetLivePreviewView::KisPresetLivePreviewView ( QWidget * parent)

◆ ~KisPresetLivePreviewView()

KisPresetLivePreviewView::~KisPresetLivePreviewView ( )

Definition at line 37 of file kis_preset_live_preview_view.cpp.

38{
39 delete m_noPreviewText;
41}
QGraphicsScene * m_brushPreviewScene
the scene that can add items like text and the brush stroke image
QGraphicsTextItem * m_noPreviewText
holds the 'no preview available' text object

References m_brushPreviewScene, and m_noPreviewText.

Member Function Documentation

◆ changeEvent()

void KisPresetLivePreviewView::changeEvent ( QEvent * event)
overrideprivate

Definition at line 488 of file kis_preset_live_preview_view.cpp.

489{
490 QWidget::changeEvent(event);
491 if (event->type() == QEvent::PaletteChange && !m_cachePreviewMode) {
492 if (m_currentPreset) {
494 }
495 }
496}

References m_cachePreviewMode, m_currentPreset, and requestUpdateStroke().

◆ paintBackground()

void KisPresetLivePreviewView::paintBackground ( bool cacheMode)
private

works as both clearing the previous stroke, providing striped backgrounds for smudging brushes, and text if there is no preview

Definition at line 214 of file kis_preset_live_preview_view.cpp.

215{
216 // clean up "no preview" text object if it exists. we will add it later if we need it
217 if (m_noPreviewText) {
218 this->scene()->removeItem(m_noPreviewText);
219 m_noPreviewText = nullptr;
220 }
221
222 const QString paintOpId = m_currentPreset->paintOp().id();
223
224 const QColor backgroundColor = palette().color(QPalette::Window);
225
226 if (cacheMode) {
229 m_paintColor = KoColor(QColor(Qt::white), m_colorSpace);
230 return;
231 }
232
235 }
236 else if (m_currentPreset->settings()->paintOpCompositeOp() == COMPOSITE_ERASE) {
237 // Doesn't really matter what the color is, just has to be something for the eraser to erase, we're just
238 // gonna use the alpha of the result
240 }
241 else {
243 }
244
245 m_paintColor = KoColor(QColor(Qt::white), m_colorSpace);
246 return;
247 }
248
249 const QColor textColor = palette().color(QPalette::Text);
250
253 m_paintColor = KoColor(textColor, m_colorSpace);
254 }
257 m_layer->paintDevice()->fill(m_image->bounds(), KoColor(backgroundColor, m_colorSpace));
258 t.end();
259
260 m_paintColor = KoColor(textColor, m_colorSpace);
261
262 QFont font;
263 font.setPixelSize(14);
264 font.setBold(false);
265
266 m_noPreviewText = this->scene()->addText(i18n("No Preview for this engine"),font);
267 m_noPreviewText->setDefaultTextColor(textColor);
268 m_noPreviewText->setPos(50, this->height()/4);
269
270 return;
271 }
272 else {
274 m_layer->paintDevice()->fill(m_image->bounds(), KoColor(backgroundColor, m_colorSpace));
275 t.end();
276
277 m_paintColor = KoColor(textColor, m_colorSpace);
278 }
279}
const QString COMPOSITE_ERASE
static bool needsStripedBackground(const QString &paintOpId)
True if paint engine needs striped background (colorsmudge, deform, filter).
static bool isNoPreviewEngine(const QString &paintOpId)
True if paint engine has no preview support.
QRect bounds() const override
virtual void clear()
void fill(const QRect &rc, const KoColor &color)
const KoColorSpace * m_colorSpace
internally sets the color space for brush preview
KisImageSP m_image
internally sets the image area for brush preview
KisLayerSP m_layer
internally sets the layer area for brush preview
KoColor m_paintColor
the color which is used for rendering the stroke
void paintStripedBackground()
Paint alternating gray stripes on the paint device.
virtual KisPaintDeviceSP paintDevice() const =0

References KisImage::bounds(), KisPaintDevice::clear(), COMPOSITE_ERASE, KisTransaction::end(), KisPaintDevice::fill(), KisBrushStrokePreviewCache::isNoPreviewEngine(), m_colorSpace, m_currentPreset, m_image, m_layer, m_noPreviewText, m_paintColor, KisBrushStrokePreviewCache::needsStripedBackground(), KisBaseNode::paintDevice(), and paintStripedBackground().

◆ paintStripedBackground()

void KisPresetLivePreviewView::paintStripedBackground ( )
private

Paint alternating gray stripes on the paint device.

Definition at line 192 of file kis_preset_live_preview_view.cpp.

193{
194 const int grayStrips = 20;
195 const float sectionPercent = 1.0f / grayStrips;
196 const int imageWidth = m_layer->image()->width();
197 const int imageHeight = m_layer->image()->height();
198
199 for (int i = 0; i < grayStrips; i++) {
200 KoColor fillColor(m_layer->paintDevice()->colorSpace());
201 fillColor.fromQColor((i % 2) ? QColor(80, 80, 80) : QColor(140, 140, 140));
202
203 const QRect fillRect(imageWidth * sectionPercent * i,
204 0,
205 imageWidth * (sectionPercent * i + sectionPercent),
206 imageHeight);
207
209 m_layer->paintDevice()->fill(fillRect, fillColor);
210 t.end();
211 }
212}
qint32 width() const
qint32 height() const
const KoColorSpace * colorSpace() const
KisImageWSP image

References KisPaintDevice::colorSpace(), KisTransaction::end(), KisPaintDevice::fill(), KoColor::fromQColor(), KisImage::height(), KisBaseNode::image, m_layer, KisBaseNode::paintDevice(), and KisImage::width().

◆ requestUpdateStroke()

void KisPresetLivePreviewView::requestUpdateStroke ( )

◆ requestUpdateStrokeImmediate()

void KisPresetLivePreviewView::requestUpdateStrokeImmediate ( )

◆ resourceManager()

KoCanvasResourceProvider * KisPresetLivePreviewView::resourceManager ( ) const

Definition at line 97 of file kis_preset_live_preview_view.cpp.

98{
99 return m_resourceManager;
100}
KoCanvasResourceProvider * m_resourceManager
internally sets the Resource Provider for brush preview (allowing gradients in preview)

References m_resourceManager.

◆ setCachePreviewMode()

void KisPresetLivePreviewView::setCachePreviewMode ( bool enabled)

Definition at line 92 of file kis_preset_live_preview_view.cpp.

93{
94 m_cachePreviewMode = enabled;
95}

References m_cachePreviewMode.

◆ setCurrentPreset()

void KisPresetLivePreviewView::setCurrentPreset ( KisPaintOpPresetSP preset)

set the current preset from resource manager for the live preview to use. Good to call this every stroke update in case the preset has changed

Parameters
presetthe current preset from the resource manager

Definition at line 73 of file kis_preset_live_preview_view.cpp.

74{
75 m_currentPreset = preset;
76}

References m_currentPreset.

◆ setup()

void KisPresetLivePreviewView::setup ( KoCanvasResourceProvider * resourceManager)

one time setup for initialization of many variables. This live preview might be in a UI file, so make sure to call this before starting to use it

Definition at line 43 of file kis_preset_live_preview_view.cpp.

44{
46
47 // initializing to nullptr helps check later if they actually have something in them
48 m_noPreviewText = nullptr;
49 m_sceneImageItem = nullptr;
50
51 setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
52 setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
53
54
55 // layer image needs to be big enough to get an entire stroke of data
56 m_canvasSize.setWidth(this->width());
57 m_canvasSize.setHeight(this->height());
58
59 m_canvasCenterPoint.setX(m_canvasSize.width()*0.5);
60 m_canvasCenterPoint.setY(m_canvasSize.height()*0.5);
61
63 m_image = new KisImage(0, m_canvasSize.width(), m_canvasSize.height(), m_colorSpace, "stroke sample image");
64
65 m_layer = new KisPaintLayer(m_image, "livePreviewStrokeSample", OPACITY_OPAQUE_U8, m_colorSpace);
66
67 // set scene for the view
68 m_brushPreviewScene = new QGraphicsScene();
69 setScene(m_brushPreviewScene);
70
71}
const quint8 OPACITY_OPAQUE_U8
QGraphicsPixmapItem * m_sceneImageItem
holds the preview brush stroke data
KoCanvasResourceProvider * resourceManager() const
static KoColorSpaceRegistry * instance()
const KoColorSpace * rgb8(const QString &profileName=QString())

References KoColorSpaceRegistry::instance(), m_brushPreviewScene, m_canvasCenterPoint, m_canvasSize, m_colorSpace, m_image, m_layer, m_noPreviewText, m_resourceManager, m_sceneImageItem, OPACITY_OPAQUE_U8, resourceManager(), and KoColorSpaceRegistry::rgb8().

◆ setupAndPaintStroke()

void KisPresetLivePreviewView::setupAndPaintStroke ( )
private

creates and performs the actual stroke that goes on top of the background this is internally and should always be called after the paintBackground()

Definition at line 306 of file kis_preset_live_preview_view.cpp.

307{
308 // limit the brush stroke size. larger brush strokes just don't look good and are CPU intensive
309 // we are making a proxy preset and setting it to the painter...otherwise setting the brush size of the original preset
310 // will fire off signals that make this run in an infinite loop
311 qreal previewSize = qBound(3.0, m_currentPreset->settings()->paintOpSize(), 25.0 ); // constrain live preview brush size
312 //Except for the sketchbrush where it determines the history.
313 if (m_currentPreset->paintOp().id() == "sketchbrush" ||
314 m_currentPreset->paintOp().id() == "spraybrush") {
315 previewSize = qMax(3.0, m_currentPreset->settings()->paintOpSize());
316 }
317
318
319 KisPaintOpPresetSP proxy_preset = m_currentPreset->clone().dynamicCast<KisPaintOpPreset>();
320 KisPaintOpSettingsSP settings = proxy_preset->settings();
321 settings->setPaintOpSize(previewSize);
322
323 if (settings->paintOpCompositeOp() != COMPOSITE_ERASE) {
324 settings->setPaintOpCompositeOp(COMPOSITE_OVER);
325 }
326
327 int maxTextureSize = 200;
328 int textureOffsetX = settings->getInt("Texture/Pattern/MaximumOffsetX")*2;
329 int textureOffsetY = settings->getInt("Texture/Pattern/MaximumOffsetY")*2;
330 double textureScale = settings->getDouble("Texture/Pattern/Scale");
331 if ( textureOffsetX*textureScale> maxTextureSize || textureOffsetY*textureScale > maxTextureSize) {
332 int maxSize = qMax(textureOffsetX, textureOffsetY);
333 double result = qreal(maxTextureSize) / maxSize;
334 settings->setProperty("Texture/Pattern/Scale", result);
335 }
336 if (proxy_preset->paintOp().id() == "spraybrush") {
337
338 QDomElement element;
339 QDomDocument d;
340 QString brushDefinition = settings->getString("brush_definition");
341 if (!brushDefinition.isEmpty()) {
342 d.setContent(brushDefinition);
343 element = d.firstChildElement("Brush");
344
346
347 qreal width = brush->image().width();
348 qreal scale = brush->scale();
349 qreal diameterToBrushRatio = 1.0;
350 qreal diameter = settings->getInt("Spray/diameter");
351 //hack, 1000 being the maximum possible brushsize.
352 if (brush->filename().endsWith(".svg", Qt::CaseInsensitive)) {
353 diameterToBrushRatio = diameter/(1000.0*scale);
354 scale = 25.0 / 1000.0;
355 } else {
356 if (width * scale > 25.0) {
357 diameterToBrushRatio = diameter / (width * scale);
358 scale = 25.0 / width;
359
360 if (!settings->getBool("SprayShape/proportional")) {
361 settings->setProperty("SprayShape/width", qRound(scale * settings->getInt("SprayShape/width")));
362 settings->setProperty("SprayShape/height", qRound(scale * settings->getInt("SprayShape/height")));
363 }
364 }
365 }
366 settings->setProperty("Spray/diameter", int(25.0 * diameterToBrushRatio));
367
368 brush->setScale(scale);
369 d.clear();
370 element = d.createElement("Brush");
371 brush->toXML(d, element);
372 d.appendChild(element);
373 settings->setProperty("brush_definition", d.toString());
374 }
375 }
376
377 proxy_preset->setSettings(settings);
378
379 KisResourcesSnapshotSP resources =
382 0, {},
383 proxy_preset);
384 resources->setOpacity(settings->paintOpOpacity());
385 resources->setMirroring(false, false); // ignore mirroring in toolbar
386
387 if (settings->paintOpCompositeOp() != COMPOSITE_ERASE) {
389 } else {
391 }
392
395
396 KisStrokeStrategy *stroke =
397 new FreehandStrokeStrategy(resources, strokeInfo, kundo2_noi18n("temp_stroke"));
398
399 KisStrokeId strokeId = m_image->startStroke(stroke);
400
401 if (proxy_preset->paintOp().id() == "mypaintbrush") {
402
405 }
406
407 // paint the stroke. The sketchbrush gets a different shape than the others to show how it works
408 if (proxy_preset->paintOp().id() == "sketchbrush"
409 || proxy_preset->paintOp().id() == "curvebrush"
410 || proxy_preset->paintOp().id() == "particlebrush") {
411 qreal startX = m_canvasCenterPoint.x() - (this->width()*0.4);
412 qreal endX = m_canvasCenterPoint.x() + (this->width()*0.4);
413 qreal middle = m_canvasCenterPoint.y();
414 KisPaintInformation pointOne;
415 pointOne.setPressure(0.0);
416 pointOne.setPos(QPointF(startX, middle));
417 KisPaintInformation pointTwo;
418 pointTwo.setPressure(0.0);
419 pointTwo.setPos(QPointF(startX, middle));
420 int repeats = 8;
421
422 for (int i = 0; i < repeats; i++) {
423 pointOne.setPos(pointTwo.pos());
424 pointOne.setPressure(pointTwo.pressure());
425
426 pointTwo.setPressure((1.0/repeats)*(i+1));
427 qreal xPos = ((1.0/repeats) * (i+1) * (endX-startX) )+startX;
428 pointTwo.setPos(QPointF(xPos, middle));
429
430 qreal offset = (this->height()/(repeats*1.5))*(i+1);
431 qreal handleY = middle + offset;
432 if (i%2 == 0) {
433 handleY = middle - offset;
434 }
435
436 m_image->addJob(strokeId,
438 pointOne,
439 QPointF(pointOne.pos().x(),
440 handleY),
441 QPointF(pointTwo.pos().x(),
442 handleY),
443 pointTwo));
445 }
446
447 } else {
448
449 // paint an S curve
450 m_curvePointPI1.setPos(QPointF(m_canvasCenterPoint.x() - (this->width()*0.45),
451 m_canvasCenterPoint.y() + (this->height()*0.2)));
453
454
455 m_curvePointPI2.setPos(QPointF(m_canvasCenterPoint.x() + (this->width()*0.4),
456 m_canvasCenterPoint.y() - (this->height()*0.2) ));
457
459
460 m_image->addJob(strokeId,
463 QPointF(m_canvasCenterPoint.x(),
464 m_canvasCenterPoint.y()-this->height()),
465 QPointF(m_canvasCenterPoint.x(),
466 m_canvasCenterPoint.y()+this->height()),
469 }
470 m_image->endStroke(strokeId);
471
473
474 NotificationStroke *notificationStroke = new NotificationStroke();
475 connect(notificationStroke, SIGNAL(timeout()), SLOT(slotPreviewGenerationCompleted()));
476 KisStrokeId notificationId = m_image->startStroke(notificationStroke);
477 m_image->endStroke(notificationId);
478
479
480 // TODO: if we don't have any regressions because of it until 4.2.8, then
481 // just remove this code.
482 // even though the brush is cloned, the proxy_preset still has some connection to the original preset which will mess brush sizing
483 // we need to return brush size to normal.The normal brush sends out a lot of extra signals, so keeping the proxy for now
484 //proxy_preset->settings()->setPaintOpSize(originalPresetSize);
485
486}
const QString COMPOSITE_OVER
static KisBrushSP fromXML(const QDomElement &element, KisResourcesInterfaceSP resourcesInterface)
static KisResourcesInterfaceSP instance()
void addJob(KisStrokeId id, KisStrokeJobData *data) override
KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy) override
void endStroke(KisStrokeId id) override
void setPos(const QPointF &p)
const QPointF & pos() const
void setCurrentTime(qreal time) const
void setPressure(qreal p)
Set the pressure.
qreal pressure() const
The pressure of the value (from 0.0 to 1.0)
The KisResourcesSnapshot class takes a snapshot of the various resources like colors and settings use...
void setFGColorOverride(const KoColor &color)
void setMirroring(bool horizontal, bool vertical)
void setCompositeOpId(const QString &compositeOpId)
Override the composite op for the snapshot.
KUndo2MagicString kundo2_noi18n(const QString &text)

References KisImage::addJob(), COMPOSITE_ERASE, COMPOSITE_OVER, KisImage::endStroke(), KisBrush::fromXML(), KisGlobalResourcesInterface::instance(), kundo2_noi18n(), m_canvasCenterPoint, m_currentPreset, m_curvePointPI1, m_curvePointPI2, m_image, m_layer, m_paintColor, m_previewGenerationInProgress, m_resourceManager, KisPaintInformation::pos(), KisPaintInformation::pressure(), KisResourcesSnapshot::setCompositeOpId(), KisPaintInformation::setCurrentTime(), KisResourcesSnapshot::setFGColorOverride(), KisResourcesSnapshot::setMirroring(), KisResourcesSnapshot::setOpacity(), KisPaintInformation::setPos(), KisPaintInformation::setPressure(), slotPreviewGenerationCompleted(), and KisImage::startStroke().

◆ sigPreviewImageReady

void KisPresetLivePreviewView::sigPreviewImageReady ( int presetId,
QImage previewImage )
signal

Emitted when a preview image is generated.

Parameters
presetIdThe presetId (resource id).
previewImagePreview image.

◆ slotPreviewGenerationCompleted

void KisPresetLivePreviewView::slotPreviewGenerationCompleted ( )
privateslot

Definition at line 126 of file kis_preset_live_preview_view.cpp.

127{
129
130 if (m_currentPreset->settings()->paintOpCompositeOp() == COMPOSITE_ERASE) {
132 KisPainter painter = KisPainter(dev);
133
134 // TODO: These are configurable for the canvas, figure out what to do with that
135 KoColor checker1(QColor("#dcdcdc"), m_image->colorSpace());
136 KoColor checker2(QColor("#ffffff"), m_image->colorSpace());
137
138 int checkerSize = 12;
139
140 // Just get the upper one, and draw into the unused space
141 int numCheckersV = std::ceil(m_image->height() / (float)checkerSize);
142 int numCheckersH = std::ceil(m_image->width() / (float)checkerSize);
143
144 painter.fill(m_image->bounds().x(), m_image->bounds().y(), m_image->bounds().width(), m_image->bounds().height(), checker2);
145
146 bool altColor = true;
147 for (int y = 0; y < numCheckersV; y++) {
148 for (int x = 0; x < numCheckersH; x++) {
149 altColor = !altColor;
150 if (altColor) {
151 continue;
152 }
153 painter.fill(x * checkerSize, y * checkerSize, checkerSize, checkerSize, checker1);
154 }
155
156 //Only need to do it if there's an even number of squares
157 if (numCheckersH % 2 == 0) {
158 altColor = !altColor;
159 }
160 }
161
165 }
166 painter.bitBlt(m_image->bounds().topLeft(), m_layer->paintDevice(), m_image->bounds());
167
169 } else {
171 }
172
173 if (!m_cachePreviewMode) {
174 // only add the object once...then just update the pixmap so we can move the preview around
175 if (!m_sceneImageItem) {
176 m_sceneImageItem = m_brushPreviewScene->addPixmap(QPixmap::fromImage(m_lastPreviewImage));
177 } else {
178 m_sceneImageItem->setPixmap(QPixmap::fromImage(m_lastPreviewImage));
179 }
180 }
181
182 // Emit preview for caching.
183 const int presetId =
185 if (presetId >= 0 && !m_lastPreviewImage.isNull()) {
187 }
188
190}
const KoColorSpace * colorSpace() const
QImage convertToQImage(const KoColorProfile *dstProfile, qint32 x, qint32 y, qint32 w, qint32 h, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags()) const
void fill(qint32 x, qint32 y, qint32 width, qint32 height, const KoColor &color)
void bitBlt(qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
void setCompositeOpId(const KoCompositeOp *op)
int m_previewPresetId
presetId (resource id) associated with the in-flight preview generation.
void sigPreviewImageReady(int presetId, QImage previewImage)
Emitted when a preview image is generated.
QImage m_lastPreviewImage
Last preview image.

References KisPainter::bitBlt(), KisImage::bounds(), KisImage::colorSpace(), COMPOSITE_ERASE, KisPaintDevice::convertToQImage(), KisPainter::fill(), KisImage::height(), m_brushPreviewScene, m_cachePreviewMode, m_currentPreset, m_image, m_lastPreviewImage, m_layer, m_previewGenerationInProgress, m_previewPresetId, m_sceneImageItem, KisBrushStrokePreviewCache::needsStripedBackground(), KisBaseNode::paintDevice(), KisPainter::setCompositeOpId(), sigPreviewImageReady(), and KisImage::width().

◆ updateStroke

void KisPresetLivePreviewView::updateStroke ( )
privateslot

Definition at line 102 of file kis_preset_live_preview_view.cpp.

103{
104 if (!m_currentPreset) {
105 return;
106 }
107
110 return;
111 }
112
113 m_previewPresetId = m_currentPreset->resourceId();
114
115 // do not paint a stroke if we are any of these engines (they have some issue currently)
119 return;
120 }
121
124}
void setupAndPaintStroke()
creates and performs the actual stroke that goes on top of the background this is internally and shou...
void paintBackground(bool cacheMode)
works as both clearing the previous stroke, providing striped backgrounds for smudging brushes,...

References KisBrushStrokePreviewCache::isNoPreviewEngine(), m_cachePreviewMode, m_currentPreset, m_previewGenerationInProgress, m_previewPresetId, m_updateCompressor, paintBackground(), setupAndPaintStroke(), slotPreviewGenerationCompleted(), and KisSignalCompressor::start().

Member Data Documentation

◆ DefaultUpdateDelayMs

constexpr int KisPresetLivePreviewView::DefaultUpdateDelayMs = 100
staticconstexprprivate

Definition at line 76 of file kis_preset_live_preview_view.h.

◆ m_brushPreviewScene

QGraphicsScene* KisPresetLivePreviewView::m_brushPreviewScene {nullptr}
private

the scene that can add items like text and the brush stroke image

Definition at line 94 of file kis_preset_live_preview_view.h.

94{nullptr};

◆ m_cachePreviewMode

bool KisPresetLivePreviewView::m_cachePreviewMode {false}
private

Definition at line 130 of file kis_preset_live_preview_view.h.

130{false};

◆ m_canvasCenterPoint

QPointF KisPresetLivePreviewView::m_canvasCenterPoint
private

convenience variable used internally when positioning the objects and points in the scene

Definition at line 109 of file kis_preset_live_preview_view.h.

◆ m_canvasSize

QRect KisPresetLivePreviewView::m_canvasSize
private

holds the width and height of the image of the brush preview Probably can later add set functions to make this customizable It is hard-coded to 1200 x 400 for right now for image size

Definition at line 105 of file kis_preset_live_preview_view.h.

◆ m_colorSpace

const KoColorSpace* KisPresetLivePreviewView::m_colorSpace {nullptr}
private

internally sets the color space for brush preview

Definition at line 88 of file kis_preset_live_preview_view.h.

88{nullptr};

◆ m_currentBrushSize

float KisPresetLivePreviewView::m_currentBrushSize {1.0}
private

internal reference for internal brush size used to check if our brush size has changed do zooming and other things internally if it has changed

Definition at line 126 of file kis_preset_live_preview_view.h.

126{1.0};

◆ m_currentDistance

KisDistanceInformation KisPresetLivePreviewView::m_currentDistance
private

internal variables for constructing the stroke start and end shape there are two points that construct the "S" curve with this

Definition at line 113 of file kis_preset_live_preview_view.h.

◆ m_currentPreset

KisPaintOpPresetSP KisPresetLivePreviewView::m_currentPreset
private

internally stores the current preset. See setCurrentPreset(KisPaintOpPresetSP preset) for setting this externally

Definition at line 121 of file kis_preset_live_preview_view.h.

◆ m_curvedLine

QPainterPath KisPresetLivePreviewView::m_curvedLine
private

Definition at line 114 of file kis_preset_live_preview_view.h.

◆ m_curvePointPI1

KisPaintInformation KisPresetLivePreviewView::m_curvePointPI1
private

Definition at line 115 of file kis_preset_live_preview_view.h.

◆ m_curvePointPI2

KisPaintInformation KisPresetLivePreviewView::m_curvePointPI2
private

Definition at line 116 of file kis_preset_live_preview_view.h.

◆ m_image

KisImageSP KisPresetLivePreviewView::m_image
private

internally sets the image area for brush preview

Definition at line 82 of file kis_preset_live_preview_view.h.

◆ m_lastPreviewImage

QImage KisPresetLivePreviewView::m_lastPreviewImage
private

Last preview image.

Definition at line 165 of file kis_preset_live_preview_view.h.

◆ m_layer

KisLayerSP KisPresetLivePreviewView::m_layer
private

internally sets the layer area for brush preview

Definition at line 85 of file kis_preset_live_preview_view.h.

◆ m_maxBrushVal

const float KisPresetLivePreviewView::m_maxBrushVal {100.0}
private

Definition at line 134 of file kis_preset_live_preview_view.h.

134{100.0};

◆ m_maxScale

const qreal KisPresetLivePreviewView::m_maxScale {0.3}
private

Definition at line 138 of file kis_preset_live_preview_view.h.

138{0.3};

◆ m_maxStrokeScale

const float KisPresetLivePreviewView::m_maxStrokeScale {1.0}
private

Definition at line 142 of file kis_preset_live_preview_view.h.

142{1.0}; // for larger brush stroke

◆ m_minBrushVal

const float KisPresetLivePreviewView::m_minBrushVal {10.0}
private

the range of brush sizes that will control zooming in/out

Definition at line 133 of file kis_preset_live_preview_view.h.

133{10.0};

◆ m_minScale

const qreal KisPresetLivePreviewView::m_minScale {1.0}
private

range of scale values. 1.0 == 100%

Definition at line 137 of file kis_preset_live_preview_view.h.

137{1.0};

◆ m_minStrokeScale

const float KisPresetLivePreviewView::m_minStrokeScale {0.4}
private

multiplier that is used for lengthening the brush stroke points

Definition at line 141 of file kis_preset_live_preview_view.h.

141{0.4}; // for smaller brush stroke

◆ m_noPreviewText

QGraphicsTextItem* KisPresetLivePreviewView::m_noPreviewText {nullptr}
private

holds the 'no preview available' text object

Definition at line 100 of file kis_preset_live_preview_view.h.

100{nullptr};

◆ m_paintColor

KoColor KisPresetLivePreviewView::m_paintColor
private

the color which is used for rendering the stroke

Definition at line 91 of file kis_preset_live_preview_view.h.

◆ m_previewGenerationInProgress

bool KisPresetLivePreviewView::m_previewGenerationInProgress {false}
private

Definition at line 128 of file kis_preset_live_preview_view.h.

128{false};

◆ m_previewPresetId

int KisPresetLivePreviewView::m_previewPresetId {-1}
private

presetId (resource id) associated with the in-flight preview generation.

Definition at line 168 of file kis_preset_live_preview_view.h.

168{-1};

◆ m_resourceManager

KoCanvasResourceProvider* KisPresetLivePreviewView::m_resourceManager {nullptr}
private

internally sets the Resource Provider for brush preview (allowing gradients in preview)

Definition at line 79 of file kis_preset_live_preview_view.h.

79{nullptr};

◆ m_sceneImageItem

QGraphicsPixmapItem* KisPresetLivePreviewView::m_sceneImageItem {nullptr}
private

holds the preview brush stroke data

Definition at line 97 of file kis_preset_live_preview_view.h.

97{nullptr};

◆ m_updateCompressor

KisSignalCompressor KisPresetLivePreviewView::m_updateCompressor
private

Definition at line 129 of file kis_preset_live_preview_view.h.


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