Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_stabilized_events_sampler.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef __KIS_STABILIZED_EVENTS_SAMPLER_H
8#define __KIS_STABILIZED_EVENTS_SAMPLER_H
9
10#include <QScopedPointer>
11
12#include <boost/iterator/iterator_facade.hpp>
13
14#include "kritaui_export.h"
15
18
19
20class KRITAUI_EXPORT KisStabilizedEventsSampler
21{
22public:
23 KisStabilizedEventsSampler(int sampleTime = 1);
25
26 void clear();
27 void addEvent(const KisPaintInformation &pi);
28 void addFinishingEvent(int numSamples);
29
30public:
31 class KRITAUI_EXPORT iterator :
32 public boost::iterator_facade <iterator,
33 KisPaintInformation const,
34 boost::forward_traversal_tag >
35 {
36 public:
38 : m_sampler(0),
39 m_index(0),
40 m_alpha(0) {}
41
42 iterator(const KisStabilizedEventsSampler* sampler, int index, qreal alpha)
43 : m_sampler(sampler),
44 m_index(index),
45 m_alpha(alpha) {}
46
47 private:
48 friend class boost::iterator_core_access;
49
50 void increment() {
51 m_index++;
52 }
53
54 bool equal(iterator const& other) const {
55 return m_index == other.m_index &&
56 m_sampler == other.m_sampler;
57 }
58
59 const KisPaintInformation& dereference() const;
60
61 private:
64 qreal m_alpha;
65 };
66
67 std::pair<iterator, iterator> range() const;
68
69private:
70 struct Private;
71 const QScopedPointer<Private> m_d;
72};
73
74
75#endif /* __KIS_STABILIZED_EVENTS_SAMPLER_H */
iterator(const KisStabilizedEventsSampler *sampler, int index, qreal alpha)
const KisStabilizedEventsSampler * m_sampler
const QScopedPointer< Private > m_d