12#include <QGraphicsPixmapItem>
23 : QGraphicsView(parent),
43 setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
44 setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
129 for (
int i=0; i < grayStrips; i++ ) {
131 float sectionPercent = 1.0 / (float)grayStrips;
132 bool isAlternating = i % 2;
172 font.setPixelSize(14);
175 m_noPreviewText = this->scene()->addText(i18n(
"No Preview for this engine"),font);
222 qreal previewSize = qBound(3.0,
m_currentPreset->settings()->paintOpSize(), 25.0 );
232 settings->setPaintOpSize(previewSize);
234 int maxTextureSize = 200;
235 int textureOffsetX = settings->getInt(
"Texture/Pattern/MaximumOffsetX")*2;
236 int textureOffsetY = settings->getInt(
"Texture/Pattern/MaximumOffsetY")*2;
237 double textureScale = settings->getDouble(
"Texture/Pattern/Scale");
238 if ( textureOffsetX*textureScale> maxTextureSize || textureOffsetY*textureScale > maxTextureSize) {
239 int maxSize = qMax(textureOffsetX, textureOffsetY);
240 double result = qreal(maxTextureSize) / maxSize;
241 settings->setProperty(
"Texture/Pattern/Scale", result);
243 if (proxy_preset->paintOp().id() ==
"spraybrush") {
247 QString brushDefinition = settings->getString(
"brush_definition");
248 if (!brushDefinition.isEmpty()) {
249 d.setContent(brushDefinition,
false);
250 element = d.firstChildElement(
"Brush");
254 qreal width = brush->image().width();
255 qreal scale = brush->scale();
256 qreal diameterToBrushRatio = 1.0;
257 qreal diameter = settings->getInt(
"Spray/diameter");
259 if (brush->filename().endsWith(
".svg", Qt::CaseInsensitive)) {
260 diameterToBrushRatio = diameter/(1000.0*scale);
261 scale = 25.0 / 1000.0;
263 if (width * scale > 25.0) {
264 diameterToBrushRatio = diameter / (width * scale);
265 scale = 25.0 / width;
267 if (!settings->getBool(
"SprayShape/proportional")) {
268 settings->setProperty(
"SprayShape/width", qRound(scale * settings->getInt(
"SprayShape/width")));
269 settings->setProperty(
"SprayShape/height", qRound(scale * settings->getInt(
"SprayShape/height")));
273 settings->setProperty(
"Spray/diameter",
int(25.0 * diameterToBrushRatio));
275 brush->setScale(scale);
277 element = d.createElement(
"Brush");
278 brush->toXML(d, element);
279 d.appendChild(element);
280 settings->setProperty(
"brush_definition", d.toString());
284 proxy_preset->setSettings(settings);
291 resources->
setOpacity(settings->paintOpOpacity());
302 if (proxy_preset->paintOp().id() ==
"mypaintbrush") {
309 if (proxy_preset->paintOp().id() ==
"sketchbrush"
310 || proxy_preset->paintOp().id() ==
"curvebrush"
311 || proxy_preset->paintOp().id() ==
"particlebrush") {
317 pointOne.
setPos(QPointF(startX, middle));
320 pointTwo.
setPos(QPointF(startX, middle));
323 for (
int i = 0; i < repeats; i++) {
328 qreal xPos = ((1.0/repeats) * (i+1) * (endX-startX) )+startX;
329 pointTwo.
setPos(QPointF(xPos, middle));
331 qreal offset = (this->height()/(repeats*1.5))*(i+1);
332 qreal handleY = middle + offset;
334 handleY = middle - offset;
340 QPointF(pointOne.
pos().x(),
342 QPointF(pointTwo.
pos().x(),
391 QWidget::changeEvent(event);
392 if (event->type() == QEvent::PaletteChange) {
399#include "kis_preset_live_preview_view.moc"
const quint8 OPACITY_OPAQUE_U8
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
static KisBrushSP fromXML(const QDomElement &element, KisResourcesInterfaceSP resourcesInterface)
static KisResourcesInterfaceSP instance()
void addJob(KisStrokeId id, KisStrokeJobData *data) override
KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy) override
QRect bounds() const override
void endStroke(KisStrokeId id) override
void fill(const QRect &rc, const KoColor &color)
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
KisPaintOpPresetSP m_currentPreset
QGraphicsScene * m_brushPreviewScene
the scene that can add items like text and the brush stroke image
const KoColorSpace * m_colorSpace
internally sets the color space for brush preview
~KisPresetLivePreviewView()
void changeEvent(QEvent *) override
KisPresetLivePreviewView(QWidget *parent)
void setupAndPaintStroke()
creates and performs the actual stroke that goes on top of the background this is internally and shou...
KoCanvasResourceProvider * m_resourceManager
internally sets the Resource Provider for brush preview (allowing gradients in preview)
void setCurrentPreset(KisPaintOpPresetSP preset)
set the current preset from resource manager for the live preview to use. Good to call this every str...
QGraphicsTextItem * m_noPreviewText
holds the 'no preview available' text object
KisImageSP m_image
internally sets the image area for brush preview
void paintBackground()
works as both clearing the previous stroke, providing striped backgrounds for smudging brushes,...
QGraphicsPixmapItem * m_sceneImageItem
holds the preview brush stroke data
void requestUpdateStroke()
KisLayerSP m_layer
internally sets the layer area for brush preview
KisSignalCompressor m_updateCompressor
void setup(KoCanvasResourceProvider *resourceManager)
one time setup for initialization of many variables. This live preview might be in a UI file,...
KisPaintInformation m_curvePointPI1
bool m_previewGenerationInProgress
QPointF m_canvasCenterPoint
KoColor m_paintColor
the color which is used for rendering the stroke
void slotPreviewGenerationCompleted()
KisPaintInformation m_curvePointPI2
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 setOpacity(qreal opacity)
void enableJob(JobType type, bool enable=true, KisStrokeJobData::Sequentiality sequentiality=KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::Exclusivity exclusivity=KisStrokeJobData::NORMAL)
void setClearsRedoOnStart(bool value)
void fromQColor(const QColor &c)
Convenient function for converting from a QColor.
void initStrokeCallback() override
void cancelStrokeCallback() override
KUndo2MagicString kundo2_noi18n(const QString &text)
rgba palette[MAX_PALETTE]
virtual KisPaintDeviceSP paintDevice() const =0
static KoColorSpaceRegistry * instance()
const KoColorSpace * rgb8(const QString &profileName=QString())