File indexing completed on 2024-05-12 15:28:07
0001 /*************************************************************************** 0002 File : XYFitCurveDock.h 0003 Project : LabPlot 0004 -------------------------------------------------------------------- 0005 Copyright : (C) 2014 Alexander Semke (alexander.semke@web.de) 0006 Copyright : (C) 2017-2018 Stefan Gerlach (stefan.gerlach@uni.kn) 0007 Description : widget for editing properties of equation curves 0008 0009 ***************************************************************************/ 0010 0011 /*************************************************************************** 0012 * * 0013 * This program is free software; you can redistribute it and/or modify * 0014 * it under the terms of the GNU General Public License as published by * 0015 * the Free Software Foundation; either version 2 of the License, or * 0016 * (at your option) any later version. * 0017 * * 0018 * This program is distributed in the hope that it will be useful, * 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0021 * GNU General Public License for more details. * 0022 * * 0023 * You should have received a copy of the GNU General Public License * 0024 * along with this program; if not, write to the Free Software * 0025 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0026 * Boston, MA 02110-1301 USA * 0027 * * 0028 ***************************************************************************/ 0029 0030 #ifndef XYFITCURVEDOCK_H 0031 #define XYFITCURVEDOCK_H 0032 0033 #include "kdefrontend/dockwidgets/XYCurveDock.h" 0034 #include "backend/worksheet/plots/cartesian/XYFitCurve.h" 0035 #include "ui_xyfitcurvedockgeneraltab.h" 0036 0037 class TreeViewComboBox; 0038 class FitParametersWidget; 0039 class KMessageWidget; 0040 0041 class XYFitCurveDock: public XYCurveDock { 0042 Q_OBJECT 0043 0044 public: 0045 explicit XYFitCurveDock(QWidget* parent); 0046 void setCurves(QList<XYCurve*>); 0047 void setupGeneral() override; 0048 0049 private: 0050 void initGeneralTab() override; 0051 void showFitResult(); 0052 void updateSettings(const AbstractColumn*); 0053 bool eventFilter(QObject*, QEvent*) override; 0054 0055 Ui::XYFitCurveDockGeneralTab uiGeneralTab; 0056 TreeViewComboBox* cbDataSourceCurve{nullptr}; 0057 TreeViewComboBox* cbXDataColumn{nullptr}; 0058 TreeViewComboBox* cbYDataColumn{nullptr}; 0059 TreeViewComboBox* cbXErrorColumn{nullptr}; 0060 TreeViewComboBox* cbYErrorColumn{nullptr}; 0061 FitParametersWidget* fitParametersWidget{nullptr}; 0062 0063 XYFitCurve* m_fitCurve{nullptr}; 0064 XYFitCurve::FitData m_fitData; 0065 QList<double> parameters; 0066 QList<double> parameterValues; 0067 bool m_parametersValid{true}; 0068 KMessageWidget* m_messageWidget{nullptr}; 0069 0070 protected: 0071 void setModel() override; 0072 0073 private slots: 0074 //SLOTs for changes triggered in XYFitCurveDock 0075 //general tab 0076 void dataSourceTypeChanged(int); 0077 void dataSourceCurveChanged(const QModelIndex&); 0078 void xWeightChanged(int); 0079 void yWeightChanged(int); 0080 void categoryChanged(int); 0081 void modelTypeChanged(int); 0082 void xDataColumnChanged(const QModelIndex&); 0083 void yDataColumnChanged(const QModelIndex&); 0084 void xErrorColumnChanged(const QModelIndex&); 0085 void yErrorColumnChanged(const QModelIndex&); 0086 0087 void showDataOptions(bool); 0088 void showWeightsOptions(bool); 0089 void showFitOptions(bool); 0090 void showParameters(bool); 0091 void showResults(bool); 0092 0093 void showConstants(); 0094 void showFunctions(); 0095 void updateParameterList(); 0096 void parametersChanged(bool updateParameterWidget = true); 0097 void parametersValid(bool); 0098 void showOptions(); 0099 void insertFunction(const QString&) const; 0100 void insertConstant(const QString&) const; 0101 void setPlotXRange(); 0102 void recalculateClicked(); 0103 void updateModelEquation(); 0104 void expressionChanged(); 0105 void enableRecalculate(); 0106 void resultParametersContextMenuRequest(QPoint); 0107 void resultGoodnessContextMenuRequest(QPoint); 0108 void resultLogContextMenuRequest(QPoint); 0109 void resultCopy(bool copyAll = false); 0110 void resultCopyAll(); 0111 0112 //SLOTs for changes triggered in XYCurve 0113 //General-Tab 0114 void curveDescriptionChanged(const AbstractAspect*); 0115 void curveDataSourceTypeChanged(XYAnalysisCurve::DataSourceType); 0116 void curveDataSourceCurveChanged(const XYCurve*); 0117 void curveXDataColumnChanged(const AbstractColumn*); 0118 void curveYDataColumnChanged(const AbstractColumn*); 0119 void curveXErrorColumnChanged(const AbstractColumn*); 0120 void curveYErrorColumnChanged(const AbstractColumn*); 0121 void curveFitDataChanged(const XYFitCurve::FitData&); 0122 void dataChanged(); 0123 void curveVisibilityChanged(bool); 0124 }; 0125 0126 #endif