1 #ifndef KIS_TIMING_INFORMATION_H
2 #define KIS_TIMING_INFORMATION_H
3 
4 #include "kritaimage_export.h"
5 
6 /**
7  * A time in milliseconds that is assumed to be longer than any stroke (or other paint operation)
8  * will ever last. This is used instead of infinity to avoid potential errors. The value is
9  * approximately ten years.
10  */
11 const qreal LONG_TIME = 320000000000.0;
12 
13 /**
14  * Contains information about timing settings in a stroke (mainly for airbrushing effects). The
15  * timing settings may be different at different parts of a stroke, e.g. if the airbrush rate is
16  * linked to pressure; a KisTimingInformation represents the effective timing at a single specific
17  * part of a stroke.
18  */
19 class KRITAIMAGE_EXPORT KisTimingInformation
20 {
21 public:
22 
23     /** Makes a KisTimingInformation with timed spacing disabled. */
KisTimingInformation()24     explicit KisTimingInformation()
25         : m_timedSpacingEnabled(false)
26         , m_timedSpacingInterval(LONG_TIME)
27     {
28     }
29 
30     /**
31      * Makes a KisTimingInformation with timed spacing enabled, using the specified interval in
32      * milliseconds.
33      */
KisTimingInformation(qreal interval)34     explicit KisTimingInformation(qreal interval)
35         : m_timedSpacingEnabled(true)
36         , m_timedSpacingInterval(interval)
37     {
38     }
39 
40     /**
41      * @return True if and only if time-based spacing is enabled.
42      */
isTimedSpacingEnabled()43     inline bool isTimedSpacingEnabled() const {
44         return m_timedSpacingEnabled;
45     }
46 
47     /**
48      * @return The desired maximum amount of time between dabs, in milliseconds. Returns LONG_TIME
49      * if time-based spacing is disabled.
50      */
timedSpacingInterval()51     inline qreal timedSpacingInterval() const {
52         return isTimedSpacingEnabled() ?
53                     m_timedSpacingInterval :
54                     LONG_TIME;
55     }
56 
57 private:
58     // Time-interval-based spacing
59     bool m_timedSpacingEnabled;
60     qreal m_timedSpacingInterval;
61 };
62 
63 #endif // KIS_TIMING_INFORMATION_H
64