File indexing completed on 2023-05-30 10:42:17
0001 /* 0002 KmPlot - a math. function plotter for the KDE-Desktop 0003 0004 SPDX-FileCopyrightText: 2004 Fredrik Edemar <f_edemar@linux.se> 0005 SPDX-FileCopyrightText: 2006 David Saxton <david@bluehaze.org> 0006 0007 This file is part of the KDE Project. 0008 KmPlot is part of the KDE-EDU Project. 0009 0010 SPDX-License-Identifier: GPL-2.0-or-later 0011 0012 */ 0013 0014 #ifndef FUNCTIONTOOLS_H 0015 #define FUNCTIONTOOLS_H 0016 0017 #include "function.h" 0018 0019 #include <QDialog> 0020 #include <QPair> 0021 0022 class FunctionToolsWidget; 0023 typedef QPair<Plot, int> EquationPair; 0024 0025 /** 0026 @author Fredrik Edemar, David Saxton 0027 */ 0028 /// FunctionTools handles all the dialogs for the items in the tool-menu. 0029 class FunctionTools : public QDialog 0030 { 0031 Q_OBJECT 0032 public: 0033 explicit FunctionTools(QWidget *parent = 0); 0034 ~FunctionTools(); 0035 0036 enum Mode { FindMinimum, FindMaximum, CalculateArea }; 0037 0038 /** 0039 * Select the right widget to use in the dialog and initialize the plot 0040 * list. 0041 */ 0042 void init(Mode mode); 0043 /** 0044 * Sets the currently selected equation. 0045 */ 0046 void setEquation(const EquationPair &equation); 0047 /** 0048 * \return the currently selected equation. 0049 */ 0050 EquationPair equation() const; 0051 0052 protected Q_SLOTS: 0053 /** 0054 * The user selected a different row in the list of plots. Note that 0055 * \p equation corresponds to the plot in m_equations. 0056 */ 0057 void equationSelected(int equation); 0058 /** 0059 * Called when the min or max range changes. 0060 */ 0061 void rangeEdited(); 0062 0063 protected: 0064 /** 0065 * Updates the list of equation. This creates the list of equation in 0066 * the equations list view and updates m_equations to reflect the 0067 * contents of the list view. 0068 */ 0069 void updateEquationList(); 0070 /** 0071 * Find the minimum in the current range. 0072 */ 0073 void findMinimum(const EquationPair &equation); 0074 /** 0075 * Find the maximum in the current range. 0076 */ 0077 void findMaximum(const EquationPair &equation); 0078 /** 0079 * Find the area under the graph 0080 */ 0081 void calculateArea(const EquationPair &equation); 0082 0083 private: 0084 Mode m_mode; 0085 FunctionToolsWidget *m_widget; 0086 /** 0087 * List of plots and equations. 0088 */ 0089 QVector<EquationPair> m_equations; 0090 }; 0091 0092 #endif