|
Krita Source Code Documentation
|
#include <kis_tool_freehand_helper.h>
Inheritance diagram for KisToolFreehandHelper:Classes | |
| struct | Private |
Signals | |
| void | requestExplicitUpdateOutline () |
Public Member Functions | |
| void | cursorMoved (const QPointF &cursorPos) |
| void | endPaint () |
| void | initPaint (KoPointerEvent *event, const QPointF &pixelCoords, KisImageWSP image, KisNodeSP currentNode, KisStrokesFacade *strokesFacade, KisNodeSP overrideNode=0, KisDefaultBoundsBaseSP bounds=0) |
| bool | isRunning () const |
| KisToolFreehandHelper (KisPaintingInformationBuilder *infoBuilder, KoCanvasResourceProvider *resourceManager, const KUndo2MagicString &transactionText=KUndo2MagicString(), KisSmoothingOptions *smoothingOptions=0) | |
| void | paintEvent (KoPointerEvent *event) |
| KisOptimizedBrushOutline | paintOpOutline (const QPointF &savedCursorPos, const KoPointerEvent *event, const KisPaintOpSettingsSP globalSettings, KisPaintOpSettings::OutlineMode mode) const |
| void | setSmoothness (KisSmoothingOptionsSP smoothingOptions) |
| KisSmoothingOptionsSP | smoothingOptions () const |
| ~KisToolFreehandHelper () override | |
Private Slots | |
| void | doAirbrushing () |
| void | finishStroke () |
| void | slotSmoothingTypeChanged () |
| void | stabilizerPollAndPaint () |
Private Member Functions | |
| int | computeAirbrushTimerInterval () const |
| qreal | currentPhysicalZoom () const |
| qreal | currentZoom () const |
| KisPaintInformation | getStabilizedPaintInfo (const QQueue< KisPaintInformation > &queue, const KisPaintInformation &lastPaintInfo) |
| void | paint (KisPaintInformation &info) |
| void | paintBezierSegment (KisPaintInformation pi1, KisPaintInformation pi2, QPointF tangent1, QPointF tangent2) |
| void | stabilizerEnd () |
| void | stabilizerStart (KisPaintInformation firstPaintInfo) |
Private Attributes | |
| Private *const | m_d |
Definition at line 31 of file kis_tool_freehand_helper.h.
| KisToolFreehandHelper::KisToolFreehandHelper | ( | KisPaintingInformationBuilder * | infoBuilder, |
| KoCanvasResourceProvider * | resourceManager, | ||
| const KUndo2MagicString & | transactionText = KUndo2MagicString(), | ||
| KisSmoothingOptions * | smoothingOptions = 0 ) |
Definition at line 115 of file kis_tool_freehand_helper.cpp.
|
override |
Definition at line 146 of file kis_tool_freehand_helper.cpp.
References m_d.
|
protected |
Definition at line 719 of file kis_tool_freehand_helper.cpp.
References KisToolFreehandHelper::Private::airbrushingTimer, KisToolFreehandHelper::Private::asyncUpdateHelper, KisStabilizerDelayedPaintHelper::cancel(), KisStrokesFacade::cancelStroke(), KisAsynchronousStrokeUpdateHelper::cancelUpdateStream(), KisAsynchronousStrokeUpdateHelper::isActive(), m_d, KisStabilizerDelayedPaintHelper::running(), KisToolFreehandHelper::Private::stabilizerDelayedPaintHelper, KisToolFreehandHelper::Private::stabilizerPollTimer, KisToolFreehandHelper::Private::strokeId, KisToolFreehandHelper::Private::strokeInfos, KisToolFreehandHelper::Private::strokesFacade, and KisToolFreehandHelper::Private::strokeTimeoutTimer.
|
private |
Definition at line 969 of file kis_tool_freehand_helper.cpp.
References AIRBRUSH_INTERVAL_FACTOR, KisResourcesSnapshot::airbrushingInterval(), m_d, and KisToolFreehandHelper::Private::resources.
|
protectedvirtual |
Reimplemented in KisToolMultihandHelper.
Definition at line 1042 of file kis_tool_freehand_helper.cpp.
|
private |
Definition at line 980 of file kis_tool_freehand_helper.cpp.
References KoCanvasResource::EffectivePhysicalZoom, m_d, KoCanvasResourceProvider::resource(), and KisToolFreehandHelper::Private::resourceManager.
|
private |
Definition at line 975 of file kis_tool_freehand_helper.cpp.
References KoCanvasResource::EffectiveZoom, m_d, KoCanvasResourceProvider::resource(), and KisToolFreehandHelper::Private::resourceManager.
| void KisToolFreehandHelper::cursorMoved | ( | const QPointF & | cursorPos | ) |
Definition at line 232 of file kis_tool_freehand_helper.cpp.
References currentZoom(), KisToolFreehandHelper::Private::lastCursorPos, m_d, and KisPaintOpUtils::PositionHistory::pushThroughHistory().
|
privateslot |
Definition at line 945 of file kis_tool_freehand_helper.cpp.
References KisPaintInformation::canvasMirroredH(), KisPaintInformation::canvasMirroredV(), KisPaintInformation::canvasRotation(), elapsedStrokeTime(), m_d, paint(), KisPaintInformation::perspective(), KisPaintInformation::pos(), KisPaintInformation::pressure(), KisToolFreehandHelper::Private::previousPaintInformation, KisPaintInformation::rotation(), KisPaintInformation::setCanvasMirroredH(), KisPaintInformation::setCanvasMirroredV(), KisPaintInformation::setCanvasRotation(), KisToolFreehandHelper::Private::strokeInfos, KisPaintInformation::tangentialPressure(), KisPaintInformation::xTilt(), and KisPaintInformation::yTilt().
|
protected |
Definition at line 749 of file kis_tool_freehand_helper.cpp.
References m_d, and KisToolFreehandHelper::Private::strokeTime.
| void KisToolFreehandHelper::endPaint | ( | ) |
There might be some timer events still pending, so we should cancel them. Use this flag for the purpose. Please note that we are not in MT here, so no mutex is needed
Definition at line 681 of file kis_tool_freehand_helper.cpp.
References KisStrokesFacade::addJob(), KisToolFreehandHelper::Private::airbrushingTimer, KisToolFreehandHelper::Private::asyncUpdateHelper, KisStrokesFacade::endStroke(), KisAsynchronousStrokeUpdateHelper::endUpdateStream(), finishStroke(), KisToolFreehandHelper::Private::hasPaintAtLeastOnce, KisToolFreehandHelper::Private::infoBuilder, KisAsynchronousStrokeUpdateHelper::isActive(), m_d, KisSmoothingOptions::NO_SMOOTHING, paintAt(), KisToolFreehandHelper::Private::previousPaintInformation, KisPaintingInformationBuilder::reset(), KisToolFreehandHelper::Private::smoothingOptions, KisSmoothingOptions::STABILIZER, stabilizerEnd(), KisToolFreehandHelper::Private::strokeId, KisToolFreehandHelper::Private::strokeInfos, KisToolFreehandHelper::Private::strokesFacade, and KisToolFreehandHelper::Private::strokeTimeoutTimer.
|
privateslot |
Definition at line 929 of file kis_tool_freehand_helper.cpp.
References KisPaintInformation::currentTime(), KisToolFreehandHelper::Private::haveTangent, m_d, KisToolFreehandHelper::Private::olderPaintInformation, paintBezierSegment(), KisPaintInformation::pos(), KisToolFreehandHelper::Private::previousPaintInformation, and KisToolFreehandHelper::Private::previousTangent.
|
private |
The first point is going to be overridden by lastPaintInfo, skip it.
Definition at line 783 of file kis_tool_freehand_helper.cpp.
References KisPaintInformation::canvasMirroredH(), KisPaintInformation::canvasMirroredV(), KisPaintInformation::canvasRotation(), KisPaintInformation::drawingSpeed(), elapsedStrokeTime(), m_d, KisPaintInformation::perspective(), KisPaintInformation::pos(), KisPaintInformation::pressure(), KisPaintInformation::rotation(), KisPaintInformation::setCanvasMirroredH(), KisPaintInformation::setCanvasMirroredV(), KisPaintInformation::setCanvasRotation(), KisToolFreehandHelper::Private::smoothingOptions, KisPaintInformation::tangentialPressure(), KisPaintInformation::xTilt(), and KisPaintInformation::yTilt().
| void KisToolFreehandHelper::initPaint | ( | KoPointerEvent * | event, |
| const QPointF & | pixelCoords, | ||
| KisImageWSP | image, | ||
| KisNodeSP | currentNode, | ||
| KisStrokesFacade * | strokesFacade, | ||
| KisNodeSP | overrideNode = 0, | ||
| KisDefaultBoundsBaseSP | bounds = 0 ) |
| event | The event |
| pixelCoords | The position of the KoPointerEvent, in pixel coordinates. |
| resourceManager | The canvas resource manager |
| image | The image |
| currentNode | The current node |
| strokesFacade | The strokes facade |
| overrideNode | The override node |
| bounds | The bounds |
Definition at line 237 of file kis_tool_freehand_helper.cpp.
References bounds, currentZoom(), KisAlgebra2D::directionBetweenPoints(), elapsedStrokeTime(), KisToolFreehandHelper::Private::infoBuilder, initPaintImpl(), KoPointerEvent::isTouchEvent(), KisToolFreehandHelper::Private::lastCursorPos, m_d, KisPaintOpUtils::PositionHistory::pushThroughHistory(), KisPaintingInformationBuilder::reset(), KisPaintOpUtils::PositionHistory::reset(), KisToolFreehandHelper::Private::resourceManager, KisPaintingInformationBuilder::startStroke(), and KisToolFreehandHelper::Private::strokeTime.
|
protected |
Definition at line 277 of file kis_tool_freehand_helper.cpp.
References KisToolFreehandHelper::Private::airbrushingTimer, KisToolFreehandHelper::Private::asyncUpdateHelper, bounds, computeAirbrushTimerInterval(), createPainters(), KisToolFreehandHelper::Private::distanceHistory, KisToolFreehandHelper::Private::hasLastDrawnPixel, KisToolFreehandHelper::Private::hasPaintAtLeastOnce, KisToolFreehandHelper::Private::haveTangent, KisToolFreehandHelper::Private::history, KisToolFreehandHelper::Private::lastDrawnPixel, LONG_TIME, m_d, KisResourcesSnapshot::needsAirbrushing(), KisResourcesSnapshot::needsSpacingUpdates(), paintAt(), KisToolFreehandHelper::Private::pixelInLineCount, KisPaintInformation::pos(), KisResourcesSnapshot::presetNeedsAsynchronousUpdates(), KisToolFreehandHelper::Private::previousPaintInformation, KisToolFreehandHelper::Private::previousTangent, resourceManager(), KisToolFreehandHelper::Private::resources, KisResourcesSnapshot::setCurrentNode(), KisToolFreehandHelper::Private::smoothingOptions, SPACING_UPDATE_INTERVAL, KisSmoothingOptions::STABILIZER, stabilizerStart(), KisStrokesFacade::startStroke(), KisAsynchronousStrokeUpdateHelper::startUpdateStream(), KisToolFreehandHelper::Private::strokeId, KisToolFreehandHelper::Private::strokeInfos, KisToolFreehandHelper::Private::strokesFacade, FreehandStrokeStrategy::SupportsContinuedInterstrokeData, FreehandStrokeStrategy::SupportsTimedMergeId, TIMING_UPDATE_INTERVAL, and KisToolFreehandHelper::Private::transactionText.
| bool KisToolFreehandHelper::isRunning | ( | ) | const |
Definition at line 272 of file kis_tool_freehand_helper.cpp.
References m_d, and KisToolFreehandHelper::Private::strokeId.
|
private |
Smooth the coordinates out using the history and the distance. This is a heavily modified version of an algo used in Gimp and described in https://bugs.kde.org/show_bug.cgi?id=281267 and https://w.atwiki.jp/sigetch_2007/pages/17.html. The main differences are:
1) It uses 'distance' instead of 'velocity', since time measurements are too unstable in realworld environment
2) There is no 'Quality' parameter, since the number of samples is calculated automatically
3) 'Tail Aggressiveness' is used for controlling the end of the stroke
4) The formula is a little bit different: 'Distance' parameter stands for $3 \Sigma$
Definition at line 472 of file kis_tool_freehand_helper.cpp.
References KisStabilizedEventsSampler::addEvent(), KisToolFreehandHelper::Private::airbrushingTimer, KisPaintInformation::currentTime(), distance(), KisToolFreehandHelper::Private::distanceHistory, KisPaintInformation::drawingSpeed(), KisToolFreehandHelper::Private::effectiveSmoothnessDistance(), KisToolFreehandHelper::Private::hasLastDrawnPixel, KisToolFreehandHelper::Private::haveTangent, KisToolFreehandHelper::Private::history, KisToolFreehandHelper::Private::lastDrawnPixel, m_d, M_PI, KisSmoothingOptions::NO_SMOOTHING, KisToolFreehandHelper::Private::olderPaintInformation, paintBezierSegment(), paintLine(), KisStabilizerDelayedPaintHelper::paintSome(), KisSmoothingOptions::PIXEL_PERFECT, KisToolFreehandHelper::Private::pixelInLineCount, KisPaintInformation::pos(), KisPaintInformation::pressure(), KisToolFreehandHelper::Private::previousPaintInformation, KisToolFreehandHelper::Private::previousTangent, KisStabilizerDelayedPaintHelper::running(), KisPaintInformation::setPos(), KisPaintInformation::setPressure(), KisSmoothingOptions::SIMPLE_SMOOTHING, KisToolFreehandHelper::Private::smoothingOptions, KisToolFreehandHelper::Private::stabilizedSampler, KisSmoothingOptions::STABILIZER, KisToolFreehandHelper::Private::stabilizerDelayedPaintHelper, KisToolFreehandHelper::Private::strokeTimeoutTimer, KisToolFreehandHelper::Private::waitingPixel, and KisSmoothingOptions::WEIGHTED_SMOOTHING.
|
protectedvirtual |
Reimplemented in KisToolMultihandHelper, and KisToolMultihandHelper.
Definition at line 1048 of file kis_tool_freehand_helper.cpp.
References paintAt().
|
protected |
Definition at line 985 of file kis_tool_freehand_helper.cpp.
References KisStrokesFacade::addJob(), KisToolFreehandHelper::Private::hasPaintAtLeastOnce, m_d, KisToolFreehandHelper::Private::strokeId, and KisToolFreehandHelper::Private::strokesFacade.
|
protectedvirtual |
Reimplemented in KisToolMultihandHelper, and KisToolMultihandHelper.
Definition at line 1059 of file kis_tool_freehand_helper.cpp.
References paintBezierCurve().
|
protected |
Definition at line 1004 of file kis_tool_freehand_helper.cpp.
References KisStrokesFacade::addJob(), KisToolFreehandHelper::Private::hasPaintAtLeastOnce, m_d, paintLine(), KisPaintInformation::pos(), KisPaintInformation::setPos(), KisPaintInformation::setPressure(), KisToolFreehandHelper::Private::strokeId, and KisToolFreehandHelper::Private::strokesFacade.
|
private |
Definition at line 355 of file kis_tool_freehand_helper.cpp.
References paintBezierCurve(), KisPaintInformation::pos(), ppVar, and warnKrita.
| void KisToolFreehandHelper::paintEvent | ( | KoPointerEvent * | event | ) |
Definition at line 461 of file kis_tool_freehand_helper.cpp.
References KisPaintingInformationBuilder::continueStroke(), elapsedStrokeTime(), KisToolFreehandHelper::Private::infoBuilder, KisUpdateTimeMonitor::instance(), m_d, paint(), KisPaintInformation::pos(), and KisUpdateTimeMonitor::reportMouseMove().
|
protectedvirtual |
Reimplemented in KisToolMultihandHelper, and KisToolMultihandHelper.
Definition at line 1053 of file kis_tool_freehand_helper.cpp.
References paintLine().
|
protected |
Definition at line 994 of file kis_tool_freehand_helper.cpp.
References KisStrokesFacade::addJob(), KisToolFreehandHelper::Private::hasPaintAtLeastOnce, m_d, KisToolFreehandHelper::Private::strokeId, and KisToolFreehandHelper::Private::strokesFacade.
| KisOptimizedBrushOutline KisToolFreehandHelper::paintOpOutline | ( | const QPointF & | savedCursorPos, |
| const KoPointerEvent * | event, | ||
| const KisPaintOpSettingsSP | globalSettings, | ||
| KisPaintOpSettings::OutlineMode | mode ) const |
When LoD mode is active it may happen that the helper has already started a stroke, but it painted noting, because all the work is being calculated by the scaled-down LodN stroke. So at first we try to fetch the data from the lodN stroke ("buddy") and then check if there is at least something has been painted with this distance information object.
Tiny hack alert: here we fetch the distance information directly from the LodN stroke. Ideally, we should upscale its data, but here we just override it with our local copy of the coordinates.
Definition at line 161 of file kis_tool_freehand_helper.cpp.
References KisOptimizedBrushOutline::addEllipse(), KisResourcesSnapshot::currentPaintOpPreset(), currentPhysicalZoom(), currentZoom(), KisAlgebra2D::directionBetweenPoints(), KisResourcesSnapshot::effectiveZoom(), KisToolFreehandHelper::Private::fakeDabRandomSource, KisToolFreehandHelper::Private::fakeStrokeRandomSource, KisStabilizerDelayedPaintHelper::hasLastPaintInformation(), KisPaintingInformationBuilder::hover(), KisToolFreehandHelper::Private::infoBuilder, KisToolFreehandHelper::Private::lastCursorPos, KisStabilizerDelayedPaintHelper::lastPaintInformation(), m_d, KisDistanceInformation::overrideLastValues(), KisPaintInformation::pos(), KisToolFreehandHelper::Private::previousPaintInformation, KisPaintOpUtils::PositionHistory::pushThroughHistory(), R, KisPaintInformation::registerDistanceInformation(), KisToolFreehandHelper::Private::resources, KisStabilizerDelayedPaintHelper::running(), KisPaintInformation::setPerStrokeRandomSource(), KisPaintInformation::setRandomSource(), KisToolFreehandHelper::Private::smoothingOptions, KisSmoothingOptions::STABILIZER, KisToolFreehandHelper::Private::stabilizerDelayedPaintHelper, and KisToolFreehandHelper::Private::strokeInfos.
|
signal |
The signal is emitted when the outline should be updated explicitly by the tool. Used by Stabilizer option, because it paints on internal timer events instead of the on every paint() event
|
protected |
Definition at line 350 of file kis_tool_freehand_helper.cpp.
References m_d, and KisToolFreehandHelper::Private::resourceManager.
| void KisToolFreehandHelper::setSmoothness | ( | KisSmoothingOptionsSP | smoothingOptions | ) |
Definition at line 151 of file kis_tool_freehand_helper.cpp.
References m_d, KisToolFreehandHelper::Private::smoothingOptions, and smoothingOptions().
|
privateslot |
Definition at line 913 of file kis_tool_freehand_helper.cpp.
References isRunning(), m_d, KisToolFreehandHelper::Private::previousPaintInformation, KisToolFreehandHelper::Private::smoothingOptions, KisSmoothingOptions::STABILIZER, stabilizerEnd(), stabilizerStart(), and KisToolFreehandHelper::Private::usingStabilizer.
| KisSmoothingOptionsSP KisToolFreehandHelper::smoothingOptions | ( | ) | const |
Definition at line 156 of file kis_tool_freehand_helper.cpp.
References m_d, and KisToolFreehandHelper::Private::smoothingOptions.
|
private |
Definition at line 892 of file kis_tool_freehand_helper.cpp.
References KisStabilizedEventsSampler::addFinishingEvent(), KisStabilizerDelayedPaintHelper::end(), m_d, KisStabilizerDelayedPaintHelper::running(), KisToolFreehandHelper::Private::smoothingOptions, KisToolFreehandHelper::Private::stabilizedSampler, KisToolFreehandHelper::Private::stabilizerDelayedPaintHelper, KisToolFreehandHelper::Private::stabilizerDeque, stabilizerPollAndPaint(), KisToolFreehandHelper::Private::stabilizerPollTimer, and KisToolFreehandHelper::Private::usingStabilizer.
|
privateslot |
Definition at line 830 of file kis_tool_freehand_helper.cpp.
References KisStabilizedEventsSampler::clear(), KisResourcesSnapshot::effectiveZoom(), getStabilizedPaintInfo(), m_d, KisResourcesSnapshot::needsAirbrushing(), paintLine(), KisPaintInformation::pos(), pow2(), KisToolFreehandHelper::Private::previousPaintInformation, R, KisStabilizedEventsSampler::range(), requestExplicitUpdateOutline(), KisToolFreehandHelper::Private::resources, KisStabilizerDelayedPaintHelper::running(), KisPaintInformation::setPos(), KisToolFreehandHelper::Private::smoothingOptions, KisToolFreehandHelper::Private::stabilizedSampler, KisToolFreehandHelper::Private::stabilizerDelayedPaintHelper, KisToolFreehandHelper::Private::stabilizerDeque, and KisStabilizerDelayedPaintHelper::update().
|
private |
Definition at line 754 of file kis_tool_freehand_helper.cpp.
References KisStabilizedEventsSampler::addEvent(), KisStabilizedEventsSampler::clear(), KisPaintInformation::drawingSpeed(), KisToolFreehandHelper::Private::effectiveSmoothnessDistance(), m_d, KisToolFreehandHelper::Private::stabilizedSampler, KisConfig::stabilizerDelayedPaint(), KisToolFreehandHelper::Private::stabilizerDelayedPaintHelper, KisToolFreehandHelper::Private::stabilizerDeque, KisToolFreehandHelper::Private::stabilizerPollTimer, KisConfig::stabilizerSampleSize(), KisStabilizerDelayedPaintHelper::start(), and KisToolFreehandHelper::Private::usingStabilizer.
|
private |
Definition at line 153 of file kis_tool_freehand_helper.h.