27#include "scaleditem.h"
43 static const int NumParMax = 20;
46 Type = UserType + Function
71 double parErrMod[NumParMax];
92 FunItem(
const KConfigGroup* plo,
const QUrl& urlPlo,
unsigned color = 0,
93 Symbol symbol = SolidLine, QGraphicsItem* parent =
nullptr);
112 FunItem(
const QUrl& url,
const QString& name,
unsigned color = 0,
113 Symbol symbol = SolidLine,
double fx = 1,
double fy = 1,
114 QGraphicsItem* parent =
nullptr,
double xMin = 0,
double xMax = 0,
115 double deltaX = 0,
bool visible =
true,
116 FillStyle fillStyle = NoBrush,
double xOffset = 0,
117 double yOffset = 0,
double relSize = 1);
131 double (*func)(
double,
const double*),
132 const double* par,
int n);
145 inline double deltaT()
const {
return m_deltaT; };
162 void exponent(
int& expX,
int& expY,
double& fx,
double& fy,
bool logX)
const;
170 void exportTable(QTextStream& stream,
char separator,
char format,
171 int precision)
const;
192 static int fit(
const QList<const ArrayItem*>* aList, QList<FunItem*>* fList,
193 const bool* bFit,
double* par,
194 QVector<double>* resVector =
nullptr,
195 QVector<double>* sigma =
nullptr,
197 double tol = 1e-14,
int itMax = 100,
LMFit* lm =
nullptr,
198 double* chiSquare =
nullptr,
double* corr =
nullptr,
199 double* parErr =
nullptr,
double* avgErr =
nullptr,
200 QObject* parent =
nullptr);
202 double (*funcY)(double,
const double*);
204 inline const QLibrary*
libY()
const {
return m_libY; };
213 void limits(
double& xMin,
double& xMax,
double& yMin,
double& yMax,
216 inline QString
nameY()
const {
return m_nameY; };
218 virtual void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option,
219 QWidget* widget =
nullptr)
override;
234 static QString
parToString(
const double* par,
char format,
int precision);
236 inline double*
parY() {
return m_parY; };
243 inline void setDeltaT(
double deltaT) { m_deltaT = deltaT; };
250 bool setFuncY(
const QUrl& url,
const QString& name);
257 virtual void setPar(
int i,
double value,
bool yFunc =
true);
262 inline void setTMax(
double xMax) { m_tMax = xMax; };
267 inline void setTMin(
double xMin) { m_tMin = xMin; };
269 virtual QPainterPath
shape()
const override;
277 inline double tMax()
const {
return m_tMax; };
279 inline double tMin()
const {
return m_tMin; };
283 virtual int type()
const override {
return Type; };
285 inline const QUrl&
urlY()
const {
return m_urlY; };
294 void writePlo(KConfigGroup* plo,
const QUrl& urlPlo,
bool absolute,
295 char format,
int precision)
const;
310 double m_tMin, m_tMax, m_deltaT;
311 mutable double tMino, tMaxo, deltaTo;
312 mutable double (*funcYo)(double,
const double*);
313 double m_parY[NumParMax];
314 mutable double parYo[NumParMax];
315 mutable QVector<double> m_tValues, m_yValues;
Array item class.
Definition arrayitem.h:37
Function item class.
Definition funitem.h:40
void limits(double &xMin, double &xMax, double &yMin, double &yMax, bool logX) const
Calculates minimum and maximum values.
void writePlo(KConfigGroup *plo, const QUrl &urlPlo, bool absolute, char format, int precision) const
Writes into plot file.
double * parY()
Returns y function parameter array pointer.
Definition funitem.h:236
void init()
Performs initialization.
const double * tValues() const
Returns pointer to argument value array.
FunItem(const QUrl &url, const QString &name, unsigned color=0, Symbol symbol=SolidLine, double fx=1, double fy=1, QGraphicsItem *parent=nullptr, double xMin=0, double xMax=0, double deltaX=0, bool visible=true, FillStyle fillStyle=NoBrush, double xOffset=0, double yOffset=0, double relSize=1)
Constructor.
static QString parToString(const double *par, char format, int precision)
Converts parameter array to string.
int calcTable() const
Calculates function value table.
FunItem(const FunItem &a)
Copy constructor.
const QLibrary * libY() const
Returns pointer to library for y function.
Definition funitem.h:204
virtual int type() const override
Returns specific QGraphicsItem type number.
Definition funitem.h:283
double * yValues() const
Returns pointer to y function value array.
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override
Paints item.
int calcTable(bool logX) const
Calculates function value table.
void exportTable(QTextStream &stream, char separator, char format, int precision) const
Exports function value table to file.
static void stringToPar(const QString &s, double *par)
Converts string to parameter array values.
static int fit(const QList< const ArrayItem * > *aList, QList< FunItem * > *fList, const bool *bFit, double *par, QVector< double > *resVector=nullptr, QVector< double > *sigma=nullptr, FunItem::DataErrorStruct *err=nullptr, bool nonLin=true, double tol=1e-14, int itMax=100, LMFit *lm=nullptr, double *chiSquare=nullptr, double *corr=nullptr, double *parErr=nullptr, double *avgErr=nullptr, QObject *parent=nullptr)
Performs fit of parameters of a set of functions to a set of arrays.
double tMax() const
Returns maximum argument value.
Definition funitem.h:277
double tMin() const
Returns minimum argument value.
Definition funitem.h:279
void unload()
Unloads y function library.
QString nameY() const
Returns y function name.
Definition funitem.h:216
static bool errorStructChanged(const DataErrorStruct &e1, const DataErrorStruct &e2)
Checks data error structures for differences.
virtual QPainterPath shape() const override
Returns the shape of the plot item.
void setTMax(double xMax)
Sets maximum argument value.
Definition funitem.h:262
virtual void setPar(int i, double value, bool yFunc=true)
Sets parameter.
virtual QRectF boundingRect() const override
Calculates bounding rectangle.
void setDeltaT(double deltaT)
Sets argument step size.
Definition funitem.h:243
const QUrl & urlY() const
Returns URL of y function library.
Definition funitem.h:285
FunItem(const KConfigGroup *plo, const QUrl &urlPlo, unsigned color=0, Symbol symbol=SolidLine, QGraphicsItem *parent=nullptr)
Constructor.
void setTMin(double xMin)
Sets minimum argument value.
Definition funitem.h:267
void setDashOffset()
Sets offset for dashed lines.
bool setFuncY(const QUrl &url, const QString &name)
Resolves y function address.
static bool parChanged(const double *p1, const double *p2)
Checks parameter arrays for differences.
double deltaT() const
Returns argument step size.
Definition funitem.h:145
virtual ~FunItem()
Destructor.
static void calcTable(const double *x, double *values, double(*func)(double, const double *), const double *par, int n)
Calculates function value table.
void paintCond(QPainter *painter) const
Paints or calculates bounding area.
void exponent(int &expX, int &expY, double &fx, double &fy, bool logX) const
Calculates normalization factors.
FillStyle
Fill styles.
Definition kplitem.h:45
Symbol
Symbol types.
Definition kplitem.h:83
Parameter fit class.
Definition lmfit.h:42
Scaled item class.
Definition scaleditem.h:25
Data error structure.
Definition funitem.h:52
DataErrorStruct()
Initializes structure.
Definition funitem.h:62
QString errModPath
Path of library containing error model function.
Definition funitem.h:75
bool fitErrCol
True for using error column of array item instead of error model function.
Definition funitem.h:67
ErrorModelArgument errModArg
Error model function argument.
Definition funitem.h:69
ErrorModelArgument
Error model function argument.
Definition funitem.h:57
@ ColX
x column.
Definition funitem.h:58
QString errModName
Name of error model function.
Definition funitem.h:73