File indexing completed on 2024-04-14 03:40:47

0001 /*
0002     KmPlot - a math. function plotter for the KDE-Desktop
0003 
0004     SPDX-FileCopyrightText: 2006 David Saxton <david@bluehaze.org>
0005 
0006     This file is part of the KDE Project.
0007     KmPlot is part of the KDE-EDU Project.
0008 
0009     SPDX-License-Identifier: GPL-2.0-or-later
0010 
0011 */
0012 
0013 #ifndef PARAMETERANIMATOR_H
0014 #define PARAMETERANIMATOR_H
0015 
0016 #include <QDialog>
0017 
0018 class Function;
0019 class ParameterAnimatorWidget;
0020 class QTimer;
0021 
0022 /**
0023 @author David Saxton
0024  */
0025 class ParameterAnimator : public QDialog
0026 {
0027     Q_OBJECT
0028 public:
0029     ParameterAnimator(QWidget *parent, Function *function);
0030     ~ParameterAnimator();
0031 
0032 public slots:
0033     void gotoInitial();
0034     void gotoFinal();
0035     void stepBackwards(bool step);
0036     void stepForwards(bool step);
0037     void pause();
0038     void updateSpeed();
0039 
0040 protected slots:
0041     void step();
0042 
0043 protected:
0044     /**
0045      * Start the timer.
0046      */
0047     void startStepping() const;
0048     /**
0049      * Stop the timer, update the buttons.
0050      */
0051     void stopStepping();
0052     /**
0053      * Makes the step buttons toggled / untoggled according to the current
0054      * state, and show the current value.
0055      */
0056     void updateUI();
0057     /**
0058      * Gives the current parameter value to the function.
0059      */
0060     void updateFunctionParameter();
0061 
0062 private:
0063     enum AnimateMode { StepBackwards, StepForwards, Paused };
0064 
0065     AnimateMode m_mode;
0066     double m_currentValue;
0067     Function *m_function; ///< The function that we're currently animating
0068 
0069     ParameterAnimatorWidget *m_widget;
0070     QTimer *m_timer; ///< for doing the animation
0071 };
0072 
0073 #endif