Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/tool/kis_tool_freehand_helper.cpp
| Context not available. | |||||
| 18 | 18 | | |||
|---|---|---|---|---|---|
| 19 | #include "kis_tool_freehand_helper.h" | 19 | #include "kis_tool_freehand_helper.h" | ||
| 20 | 20 | | |||
| 21 | #include <QBasicTimer> | ||||
| 21 | #include <QTimer> | 22 | #include <QTimer> | ||
| 22 | #include <QQueue> | 23 | #include <QQueue> | ||
| 23 | 24 | | |||
| Context not available. | |||||
| 97 | 98 | | |||
| 98 | // Stabilizer data | 99 | // Stabilizer data | ||
| 99 | QQueue<KisPaintInformation> stabilizerDeque; | 100 | QQueue<KisPaintInformation> stabilizerDeque; | ||
| 100 | QTimer stabilizerPollTimer; | 101 | QBasicTimer stabilizerPollTimer; | ||
| 101 | KisStabilizedEventsSampler stabilizedSampler; | 102 | KisStabilizedEventsSampler stabilizedSampler; | ||
| 102 | KisStabilizerDelayedPaintHelper stabilizerDelayedPaintHelper; | 103 | KisStabilizerDelayedPaintHelper stabilizerDelayedPaintHelper; | ||
| 103 | 104 | | |||
| Context not available. | |||||
| 124 | m_d->strokeTimeoutTimer.setSingleShot(true); | 125 | m_d->strokeTimeoutTimer.setSingleShot(true); | ||
| 125 | connect(&m_d->strokeTimeoutTimer, SIGNAL(timeout()), SLOT(finishStroke())); | 126 | connect(&m_d->strokeTimeoutTimer, SIGNAL(timeout()), SLOT(finishStroke())); | ||
| 126 | connect(&m_d->airbrushingTimer, SIGNAL(timeout()), SLOT(doAirbrushing())); | 127 | connect(&m_d->airbrushingTimer, SIGNAL(timeout()), SLOT(doAirbrushing())); | ||
| 127 | connect(&m_d->stabilizerPollTimer, SIGNAL(timeout()), SLOT(stabilizerPollAndPaint())); | | |||
| 128 | 128 | | |||
| 129 | m_d->stabilizerDelayedPaintHelper.setPaintLineCallback( | 129 | m_d->stabilizerDelayedPaintHelper.setPaintLineCallback( | ||
| 130 | [this](const KisPaintInformation &pi1, const KisPaintInformation &pi2) { | 130 | [this](const KisPaintInformation &pi1, const KisPaintInformation &pi2) { | ||
| 131 | paintLine(pi1, pi2); | 131 | paintLine(pi1, pi2); | ||
| 132 | }); | 132 | }); | ||
| 133 | m_d->stabilizerDelayedPaintHelper.setUpdateOutlineCallback( | | |||
| 134 | [this]() { | | |||
| 135 | emit requestExplicitUpdateOutline(); | | |||
| 136 | }); | | |||
| 137 | } | 133 | } | ||
| 138 | 134 | | |||
| 139 | KisToolFreehandHelper::~KisToolFreehandHelper() | 135 | KisToolFreehandHelper::~KisToolFreehandHelper() | ||
| Context not available. | |||||
| 586 | 582 | | |||
| 587 | if (m_d->smoothingOptions->smoothingType() == KisSmoothingOptions::STABILIZER) { | 583 | if (m_d->smoothingOptions->smoothingType() == KisSmoothingOptions::STABILIZER) { | ||
| 588 | m_d->stabilizedSampler.addEvent(info); | 584 | m_d->stabilizedSampler.addEvent(info); | ||
| 585 | if (m_d->stabilizerDelayedPaintHelper.running()) { | ||||
| 586 | // Paint here so we don't have to rely on the timer | ||||
| 587 | m_d->stabilizerDelayedPaintHelper.paintSome(); | ||||
| 588 | } | ||||
| 589 | } else { | 589 | } else { | ||
| 590 | m_d->previousPaintInformation = info; | 590 | m_d->previousPaintInformation = info; | ||
| 591 | } | 591 | } | ||
| Context not available. | |||||
| 678 | // Poll and draw regularly | 678 | // Poll and draw regularly | ||
| 679 | KisConfig cfg; | 679 | KisConfig cfg; | ||
| 680 | int stabilizerSampleSize = cfg.stabilizerSampleSize(); | 680 | int stabilizerSampleSize = cfg.stabilizerSampleSize(); | ||
| 681 | m_d->stabilizerPollTimer.setInterval(stabilizerSampleSize); | 681 | m_d->stabilizerPollTimer.start(stabilizerSampleSize, Qt::PreciseTimer, this); | ||
| 682 | m_d->stabilizerPollTimer.start(); | | |||
| 683 | 682 | | |||
| 684 | int delayedPaintInterval = cfg.stabilizerDelayedPaintInterval(); | 683 | int delayedPaintInterval = cfg.stabilizerDelayedPaintInterval(); | ||
| 685 | if (delayedPaintInterval < stabilizerSampleSize) { | 684 | if (delayedPaintInterval < stabilizerSampleSize) { | ||
| Context not available. | |||||
| 976 | m_d->canvasMirroredH = mirrored; | 975 | m_d->canvasMirroredH = mirrored; | ||
| 977 | } | 976 | } | ||
| 978 | 977 | | |||
| 978 | void KisToolFreehandHelper::timerEvent(QTimerEvent *event) | ||||
| 979 | { | ||||
| 980 | if (event->timerId() == m_d->stabilizerPollTimer.timerId()) { | ||||
| 981 | stabilizerPollAndPaint(); | ||||
| 982 | } | ||||
| 983 | } | ||||
| Context not available. | |||||