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

#include <kis_stabilized_events_sampler.h>

Classes

class  iterator
 
struct  Private
 

Public Member Functions

void addEvent (const KisPaintInformation &pi)
 
void addFinishingEvent (int numSamples)
 
void clear ()
 
 KisStabilizedEventsSampler (int sampleTime=1)
 
std::pair< iterator, iteratorrange () const
 
 ~KisStabilizedEventsSampler ()
 

Private Attributes

const QScopedPointer< Privatem_d
 

Detailed Description

Definition at line 20 of file kis_stabilized_events_sampler.h.

Constructor & Destructor Documentation

◆ KisStabilizedEventsSampler()

KisStabilizedEventsSampler::KisStabilizedEventsSampler ( int sampleTime = 1)

Definition at line 28 of file kis_stabilized_events_sampler.cpp.

29 : m_d(new Private(sampleTime))
30{
31}
const QScopedPointer< Private > m_d

◆ ~KisStabilizedEventsSampler()

KisStabilizedEventsSampler::~KisStabilizedEventsSampler ( )

Definition at line 33 of file kis_stabilized_events_sampler.cpp.

34{
35}

Member Function Documentation

◆ addEvent()

void KisStabilizedEventsSampler::addEvent ( const KisPaintInformation & pi)

Definition at line 47 of file kis_stabilized_events_sampler.cpp.

48{
49 if (!m_d->lastPaintTime.isValid()) {
50 m_d->lastPaintTime.start();
51 }
52
53 m_d->realEvents.append(pi);
54}

References m_d.

◆ addFinishingEvent()

void KisStabilizedEventsSampler::addFinishingEvent ( int numSamples)

Definition at line 56 of file kis_stabilized_events_sampler.cpp.

57{
58 if (m_d->realEvents.size() > 0) {
59 dbgKrita << "DEBUG: KisStabilizedEventsSampler::addFinishingEvent called "
60 "before `realEvents` is cleared";
61 clear();
62 }
63
64 m_d->elapsedTimeOverride = numSamples;
65 m_d->realEvents.append(m_d->lastPaintInformation);
66}
#define dbgKrita
Definition kis_debug.h:45

References clear(), dbgKrita, and m_d.

◆ clear()

void KisStabilizedEventsSampler::clear ( )

Definition at line 37 of file kis_stabilized_events_sampler.cpp.

38{
39 if (!m_d->realEvents.isEmpty()) {
40 m_d->lastPaintInformation = m_d->realEvents.last();
41 }
42
43 m_d->realEvents.clear();
44 m_d->lastPaintTime.start();
45}

References m_d.

◆ range()

std::pair< KisStabilizedEventsSampler::iterator, KisStabilizedEventsSampler::iterator > KisStabilizedEventsSampler::range ( ) const

Definition at line 76 of file kis_stabilized_events_sampler.cpp.

77{
78 const int elapsed = (m_d->lastPaintTime.restart() + m_d->elapsedTimeOverride) / m_d->sampleTime;
79 const qreal alpha = qreal(m_d->realEvents.size()) / elapsed;
80
81 m_d->elapsedTimeOverride = 0;
82
83 return std::make_pair(iterator(this, 0, alpha),
84 iterator(this, elapsed, alpha));
85}

References m_d.

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisStabilizedEventsSampler::m_d
private

Definition at line 71 of file kis_stabilized_events_sampler.h.


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