1 /* 2 KmPlot - a math. function plotter for the KDE-Desktop 3 4 SPDX-FileCopyrightText: 2006 David Saxton <david@bluehaze.org> 5 6 This file is part of the KDE Project. 7 KmPlot is part of the KDE-EDU Project. 8 9 SPDX-License-Identifier: GPL-2.0-or-later 10 11 */ 12 13 #ifndef PARAMETERANIMATOR_H 14 #define PARAMETERANIMATOR_H 15 16 #include <QDialog> 17 18 class Function; 19 class ParameterAnimatorWidget; 20 class QTimer; 21 22 /** 23 @author David Saxton 24 */ 25 class ParameterAnimator : public QDialog 26 { 27 Q_OBJECT 28 public: 29 ParameterAnimator( QWidget * parent, Function * function ); 30 ~ParameterAnimator(); 31 32 public slots: 33 void gotoInitial(); 34 void gotoFinal(); 35 void stepBackwards( bool step ); 36 void stepForwards( bool step ); 37 void pause(); 38 void updateSpeed(); 39 40 protected slots: 41 void step(); 42 43 protected: 44 /** 45 * Start the timer. 46 */ 47 void startStepping() const; 48 /** 49 * Stop the timer, update the buttons. 50 */ 51 void stopStepping(); 52 /** 53 * Makes the step buttons toggled / untoggled according to the current 54 * state, and show the current value. 55 */ 56 void updateUI(); 57 /** 58 * Gives the current parameter value to the function. 59 */ 60 void updateFunctionParameter(); 61 62 private: 63 enum AnimateMode 64 { 65 StepBackwards, 66 StepForwards, 67 Paused 68 }; 69 70 AnimateMode m_mode; 71 double m_currentValue; 72 Function * m_function; ///< The function that we're currently animating 73 74 ParameterAnimatorWidget *m_widget; 75 QTimer * m_timer; ///< for doing the animation 76 }; 77 78 #endif 79