libkpl  5.0
A Library for Graphical Presentation of Data Sets and Functions
parfunitem.h
1 /***************************************************************************
2  parfunitem.h - description
3  -------------------
4 
5  This file is a part of kpl - a program for graphical presentation of
6  data sets and functions.
7 
8  begin : Sun Aug 29 1999
9  copyright : (C) 2017 by Werner Stille
10  email : kpl@werner-stille.de
11  ***************************************************************************/
12 
13 /***************************************************************************
14  * *
15  * This program is free software; you can redistribute it and/or modify *
16  * it under the terms of the GNU General Public License as published by *
17  * the Free Software Foundation; either version 2 of the License, or *
18  * (at your option) any later version. *
19  * *
20  ***************************************************************************/
21 
22 #ifndef PARFUNITEM_H
23 #define PARFUNITEM_H
24 
25 #include "funitem.h"
26 
32 class Q_DECL_EXPORT ParFunItem : public FunItem
33 {
34 public:
36  enum {
37  Type = UserType + ParFunction
42  };
63  ParFunItem(const QUrl& urlX = QUrl(), const QString& nameX = "",
64  const QUrl& urlY = QUrl(), const QString& nameY = "",
65  unsigned color = 0, Symbol symbol = SolidLine, double fx = 1,
66  double fy = 1, QGraphicsItem* parent = 0, double tMin = 0,
67  double tMax = 0, double deltaT = 0, bool visible = true,
68  FillStyle fillStyle = NoBrush, double xOffset = 0,
69  double yOffset = 0, double relSize = 1);
74  ParFunItem(const ParFunItem& a);
83  ParFunItem(const KConfigGroup* plo, const QUrl& urlPlo, unsigned color = 0,
84  Symbol symbol = SolidLine, QGraphicsItem* parent = 0);
86  virtual ~ParFunItem();
88  virtual QRectF boundingRect() const;
93  int calcTable() const;
101  void exponent(int& expX, int& expY, double& fx, double& fy) const;
109  void exportTable(QTextStream& stream, char separator, char format,
110  int precision) const;
112  double (*funcX)(double, const double*);
114  inline const QLibrary* libX() const { return m_libX; };
122  void limits(double& xMin, double& xMax, double& yMin, double& yMax) const;
124  inline QString nameX() const { return m_nameX; };
126  virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
127  QWidget* widget = 0);
129  inline double* parX() { return m_parX; };
131  void setDashOffset();
138  bool setFuncX(const QUrl& url, const QString& name);
145  virtual void setPar(int i, double value, bool yFun);
147  virtual int type() const { return Type; };
149  inline const QUrl& urlX() const { return m_urlX; };
158  void writePlo(KConfigGroup* plo, const QUrl& urlPlo, bool absolute,
159  char format, int precision) const;
161  double* xValues() const;
162 
163 protected:
165  void init();
170  void paintCond(QPainter* painter) const;
172  void unloadX();
173  mutable double (*funcXo)(double, const double*);
174  double m_parX[NumParMax];
175  mutable double parXo[NumParMax];
176  mutable QVector<double> m_xValues;
177  QString m_nameX;
178  QUrl m_urlX;
179  QLibrary* m_libX;
180 };
181 
182 #endif
Parametric function item class.
Definition: parfunitem.h:32
virtual void setPar(int i, double value, bool yFunc=true)
Sets parameter.
void limits(double &xMin, double &xMax, double &yMin, double &yMax, bool logX) const
Calculates minimum and maximum values.
QString nameX() const
Returns x function name.
Definition: parfunitem.h:124
FillStyle
Fill styles.
Definition: kplitem.h:45
Symbol
Symbol types.
Definition: kplitem.h:83
Specific QGraphicsItem type number of FunItem for function type().
Definition: funitem.h:46
double * parX()
Returns x function parameter array pointer.
Definition: parfunitem.h:129
virtual int type() const
Returns specific QGraphicsItem type number.
Definition: parfunitem.h:147
int calcTable() const
Calculates function value table.
virtual QRectF boundingRect() const
Calculates bounding rectangle.
const QLibrary * libX() const
Returns pointer to library for x function.
Definition: parfunitem.h:114
void exponent(int &expX, int &expY, double &fx, double &fy, bool logX) const
Calculates normalization factors.
const QUrl & urlX() const
Returns URL of x function library.
Definition: parfunitem.h:149
Function item class.
Definition: funitem.h:39
void paintCond(QPainter *painter) const
Paints or calculates bounding area.
void setDashOffset()
Sets offset for dashed lines.
void writePlo(KConfigGroup *plo, const QUrl &urlPlo, bool absolute, char format, int precision) const
Writes into plot file.
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Paints item.
void init()
Performs initialization.
static const int NumParMax
Dimension of parameter arrays.
Definition: funitem.h:43
void exportTable(QTextStream &stream, char separator, char format, int precision) const
Exports function value table to file.