Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_liquify_paint_helper.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
7
8#include <QElapsedTimer>
9#include <QPainterPath>
10
11#include "kis_algebra_2d.h"
12#include "KoPointerEvent.h"
18#include "kis_liquify_paintop.h"
20
45
46
48 : m_d(new Private(converter))
49{
50}
51
55
66
68{
70 m_d->previousPaintInfo.registerDistanceInformation(&m_d->previousDistanceInfo);
71
72 return KisLiquifyPaintop::brushOutline(props, m_d->previousPaintInfo);
73}
74
77{
78 m_d->paintOp.reset(new KisLiquifyPaintop(props, worker));
79}
80
82{
84
85 m_d->strokeTime.start();
87 m_d->infoBuilder->startStroke(event, m_d->strokeTime.elapsed(), manager);
88
89 m_d->updatePreviousPaintInfo(pi);
90 m_d->hasPaintedAtLeastOnce = false;
91}
92
94{
96
98 m_d->infoBuilder->continueStroke(event, m_d->strokeTime.elapsed());
99
100 KisPaintOpUtils::paintLine(*m_d->paintOp.data(),
101 m_d->previousPaintInfo,
102 pi,
103 &m_d->currentDistance,
104 false, false);
105
106 m_d->updatePreviousPaintInfo(pi);
107 m_d->hasPaintedAtLeastOnce = true;
108}
109
111{
112 KIS_ASSERT_RECOVER(m_d->paintOp) { return false; }
113
114 if (!m_d->hasPaintedAtLeastOnce) {
116 m_d->infoBuilder->continueStroke(event, m_d->strokeTime.elapsed());
117
118 pi.paintAt(*m_d->paintOp.data(), &m_d->previousDistanceInfo);
119 }
120
121 m_d->paintOp.reset();
122
123 return !m_d->hasPaintedAtLeastOnce;
124}
125
127{
128 QPointF imagePoint = m_d->converter->documentToImage(event->pos());
129 KisPaintInformation pi = m_d->infoBuilder->hover(imagePoint, event, bool(m_d->paintOp));
130
131 m_d->updatePreviousPaintInfo(pi);
132}
const QScopedPointer< Private > m_d
QPainterPath brushOutline(const KisLiquifyProperties &props)
void continuePaint(KoPointerEvent *event)
void startPaint(KoPointerEvent *event, const KoCanvasResourceProvider *manager)
void configurePaintOp(const KisLiquifyProperties &_props, KisLiquifyTransformWorker *worker)
void hoverPaint(KoPointerEvent *event)
bool endPaint(KoPointerEvent *event)
KisLiquifyPaintHelper(const KisCoordinatesConverter *converter)
static QPainterPath brushOutline(const KisLiquifyProperties &props, const KisPaintInformation &info)
void paintAt(PaintOp &op, KisDistanceInformation *distanceInfo)
const QPointF & pos() const
QPointF pushThroughHistory(const QPointF &pt, qreal zoom)
QPoint pos() const
return the position in widget coordinates
#define KIS_ASSERT_RECOVER(cond)
Definition kis_assert.h:55
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75
qreal directionBetweenPoints(const QPointF &p1, const QPointF &p2, qreal defaultAngle)
void paintLine(PaintOp &op, const KisPaintInformation &pi1, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance, bool fanCornersEnabled, qreal fanCornersStep)
QScopedPointer< KisPaintingInformationBuilder > infoBuilder
Private(const KisCoordinatesConverter *_converter)
QScopedPointer< KisLiquifyPaintop > paintOp
void updatePreviousPaintInfo(const KisPaintInformation &info)
const KisCoordinatesConverter * converter
KisPaintOpUtils::PositionHistory lastOutlinePos