File indexing completed on 2024-12-22 04:13:03

0001 /*
0002  *  SPDX-FileCopyrightText: 2017 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KISSTROKESPEEDMONITOR_H
0008 #define KISSTROKESPEEDMONITOR_H
0009 
0010 #include <QObject>
0011 
0012 #include "kis_types.h"
0013 #include "kritaui_export.h"
0014 
0015 class KRITAUI_EXPORT KisStrokeSpeedMonitor : public QObject
0016 {
0017     Q_OBJECT
0018 
0019     Q_PROPERTY(QString lastPresetName READ lastPresetName NOTIFY sigStatsUpdated)
0020     Q_PROPERTY(qreal lastPresetSize READ lastPresetSize NOTIFY sigStatsUpdated)
0021 
0022     Q_PROPERTY(qreal lastCursorSpeed READ lastCursorSpeed NOTIFY sigStatsUpdated)
0023     Q_PROPERTY(qreal lastRenderingSpeed READ lastRenderingSpeed NOTIFY sigStatsUpdated)
0024     Q_PROPERTY(qreal lastFps READ lastFps NOTIFY sigStatsUpdated)
0025 
0026     Q_PROPERTY(bool lastStrokeSaturated READ lastCursorSpeed NOTIFY sigStatsUpdated)
0027 
0028     Q_PROPERTY(qreal avgCursorSpeed READ avgCursorSpeed NOTIFY sigStatsUpdated)
0029     Q_PROPERTY(qreal avgRenderingSpeed READ avgRenderingSpeed NOTIFY sigStatsUpdated)
0030     Q_PROPERTY(qreal avgFps READ avgFps NOTIFY sigStatsUpdated)
0031 
0032 public:
0033     KisStrokeSpeedMonitor();
0034     ~KisStrokeSpeedMonitor();
0035 
0036     static KisStrokeSpeedMonitor* instance();
0037 
0038     bool haveStrokeSpeedMeasurement() const;
0039 
0040     void notifyStrokeFinished(qreal cursorSpeed, qreal renderingSpeed, qreal fps, KisPaintOpPresetSP preset);
0041 
0042 
0043     QString lastPresetName() const;
0044     qreal lastPresetSize() const;
0045 
0046     qreal lastCursorSpeed() const;
0047     qreal lastRenderingSpeed() const;
0048     qreal lastFps() const;
0049     bool lastStrokeSaturated() const;
0050 
0051     qreal avgCursorSpeed() const;
0052     qreal avgRenderingSpeed() const;
0053     qreal avgFps() const;
0054 
0055 
0056 Q_SIGNALS:
0057     void sigStatsUpdated();
0058 
0059 public Q_SLOTS:
0060     void setHaveStrokeSpeedMeasurement(bool value);
0061 
0062 private Q_SLOTS:
0063     void resetAccumulatedValues();
0064     void slotConfigChanged();
0065 
0066 private:
0067     struct Private;
0068     const QScopedPointer<Private> m_d;
0069 };
0070 
0071 #endif // KISSTROKESPEEDMONITOR_H