File indexing completed on 2025-01-26 03:34:18
0001 /* 0002 File : XYEquationCurve.h 0003 Project : LabPlot 0004 Description : A xy-curve defined by a mathematical equation 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2014-2021 Alexander Semke <alexander.semke@web.de> 0007 SPDX-FileCopyrightText: 2023 Stefan Gerlach <stefan.gerlach@uni.kn> 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #ifndef XYEQUATIONCURVE_H 0012 #define XYEQUATIONCURVE_H 0013 0014 #include "backend/worksheet/plots/cartesian/XYCurve.h" 0015 0016 class XYEquationCurvePrivate; 0017 0018 #ifdef SDK 0019 #include "labplot_export.h" 0020 class LABPLOT_EXPORT XYEquationCurve : public XYCurve { 0021 #else 0022 class XYEquationCurve : public XYCurve { 0023 #endif 0024 Q_OBJECT 0025 Q_ENUMS(EquationType) 0026 0027 public: 0028 enum class EquationType { Cartesian, Polar, Parametric, Implicit, Neutral }; 0029 0030 struct EquationData { 0031 EquationData() 0032 : min(QLatin1String("0")) 0033 , max(QLatin1String("1")){}; 0034 0035 EquationType type{EquationType::Cartesian}; 0036 QString expression1; // Expression for Cartesian, Polar, ... 0037 QString expression2; // Second expression for Parametric 0038 QString min; // localized strings to support expressions 0039 QString max; 0040 int count{1000}; // number of points of the curve 0041 }; 0042 0043 explicit XYEquationCurve(const QString& name); 0044 ~XYEquationCurve() override; 0045 0046 void recalculate(); 0047 bool dataAvailable() const; 0048 QIcon icon() const override; 0049 void save(QXmlStreamWriter*) const override; 0050 bool load(XmlStreamReader*, bool preview) override; 0051 0052 CLASS_D_ACCESSOR_DECL(EquationData, equationData, EquationData) 0053 0054 typedef XYEquationCurvePrivate Private; 0055 0056 protected: 0057 XYEquationCurve(const QString& name, XYEquationCurvePrivate* dd); 0058 0059 private: 0060 Q_DECLARE_PRIVATE(XYEquationCurve) 0061 void init(); 0062 0063 public Q_SLOTS: 0064 void createDataSpreadsheet(); 0065 0066 Q_SIGNALS: 0067 void equationDataChanged(const XYEquationCurve::EquationData&); 0068 }; 0069 0070 #endif