File indexing completed on 2024-03-24 03:44:17
0001 /************************************************************************************* 0002 * Copyright (C) 2007 by Aleix Pol <aleixpol@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or * 0005 * modify it under the terms of the GNU General Public License * 0006 * as published by the Free Software Foundation; either version 2 * 0007 * of the License, or (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the Free Software * 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 0017 *************************************************************************************/ 0018 0019 #ifndef FUNCTIONEDIT_H 0020 #define FUNCTIONEDIT_H 0021 0022 #include <QLabel> 0023 #include <QLineEdit> 0024 #include <QPushButton> 0025 #include <QWidget> 0026 0027 #include <KColorCombo> 0028 0029 class QTabWidget; 0030 namespace Analitza 0031 { 0032 class Variables; 0033 class Expression; 0034 class PlotsView2D; 0035 class PlotsModel; 0036 class PlaneCurve; 0037 class ExpressionEdit; 0038 } 0039 0040 /** 0041 * The FunctionEdit dialog provides a way to specify functions. 0042 * @author Aleix Pol i Gonzalez 0043 */ 0044 0045 class FunctionEdit : public QWidget 0046 { 0047 Q_OBJECT 0048 public: 0049 /** Constructor. */ 0050 explicit FunctionEdit(QWidget *parent = nullptr); 0051 0052 /** Destructor. */ 0053 ~FunctionEdit(); 0054 0055 /** Retrieves the resulting expression text. */ 0056 Analitza::Expression expression() const; 0057 0058 Analitza::PlaneCurve *createFunction() const; 0059 0060 /** Sets an expression text to the ExpressionEdit widget. */ 0061 void setFunction(const QString &newText); 0062 0063 /** Retrieves the selected color for the function */ 0064 QColor color() const 0065 { 0066 return m_color->color(); 0067 } 0068 0069 /** Sets the selected color for the function.*/ 0070 void setColor(const QColor &newColor); 0071 0072 /** Returns whether we are editing or adding a function. */ 0073 bool editing() const 0074 { 0075 return m_modmode; 0076 } 0077 0078 /** Sets whether we are editing or adding a function. */ 0079 void setEditing(bool m); 0080 0081 /** Sets a name to the function. (Not used YET) */ 0082 void setName(const QString &name) 0083 { 0084 m_name->setText(name); 0085 } 0086 0087 /** Retrieves a name for the function. (Not used YET) */ 0088 QString name() const 0089 { 0090 return m_name->text(); 0091 } 0092 0093 /** Sets the variables class to be used with the graph functions*/ 0094 void setVariables(const QSharedPointer<Analitza::Variables> &v) 0095 { 0096 m_vars = v; 0097 } 0098 0099 QSharedPointer<Analitza::Variables> variables() const 0100 { 0101 return m_vars; 0102 } 0103 0104 void setOptionsShown(bool shown); 0105 0106 void resizeEvent(QResizeEvent *ev) override; 0107 0108 public Q_SLOTS: 0109 /** Clears the dialog. */ 0110 void clear(); 0111 0112 Q_SIGNALS: 0113 /** Tells that the result has been accepted. */ 0114 void accept(); 0115 0116 /** asks the currently edited plot to be removed. */ 0117 void removeEditingPlot(); 0118 0119 private Q_SLOTS: 0120 void edit(); 0121 void ok(); 0122 void colorChange(int); 0123 void updateUplimit(); 0124 void updateDownlimit(); 0125 0126 private: 0127 void setState(const QString &text, bool negative); 0128 void focusInEvent(QFocusEvent *) override; 0129 0130 Analitza::ExpressionEdit *m_func; 0131 Analitza::ExpressionEdit *m_uplimit, *m_downlimit; 0132 double m_calcUplimit, m_calcDownlimit; 0133 QLineEdit *m_name; 0134 QPushButton *m_ok; 0135 QLabel *m_valid; 0136 QLabel *m_validIcon; 0137 Analitza::PlotsView2D *m_graph; 0138 KColorCombo *m_color; 0139 Analitza::PlotsModel *m_funcsModel; 0140 QSharedPointer<Analitza::Variables> m_vars; 0141 0142 bool m_modmode; 0143 QTabWidget *m_viewTabs; 0144 QPushButton *m_remove; 0145 }; 0146 0147 #endif