libkpl  6.0
A Library for Graphical Presentation of Data Sets and Functions
fun3ditem.h
1/***************************************************************************
2 fun3ditem.h - description
3 -------------------
4 begin : Tue Dec 25 2001
5 copyright : (C) 2024 by Werner Stille
6 email : kpl@werner-stille.de
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef FUN3DITEM_H
19#define FUN3DITEM_H
20
21#include "funitem.h"
22#include "threeditem.h"
23
28class Q_DECL_EXPORT Fun3DItem : public ThreeDItem
29{
30public:
32 enum {
33 Type = UserType + Function3D
37 };
93 Fun3DItem(double x0 = 4, double y0 = 3, double width = 15,
94 double height = 10, unsigned colorFrame = 0,
95 unsigned colorGrid = 0, unsigned colorData = 0, bool logX = false,
96 bool logY = false, bool logZ = false,
97 GridMode gridMode = AxesWithLabels, Mode3D mode3D = Grid,
98 double xMax = 15, double yMax = 10, double zMax = 15,
99 const QString& textX = QString(), const QString& textY = QString(),
100 const QString& textZ = QString(),
101 const QString& header = QString(), double relSize = 1,
102 int numDigX = -1, int numDigY = -1, int numDigZ = -1,
103 int minTicX = 5, int minTicY = 2, int minTicZ = 5, int expX = 0,
104 int expY = 0, int expZ = 0, double xMin = 0, double yMin = 0,
105 double zMin = 0, double xTic = 5, double yTic = 2, double zTic = 5,
106 double deltaX = 0, double deltaZ = 0, double phi = 20,
107 double theta = -20, double bx = 7.5, double by = 7.5,
108 double bz = 7.5, double xr = 7.5, double yr = 4, double fx = 1,
109 double fy = 1, double fz = 1, const QString& name = QString(),
110 const QUrl& url = QUrl(), bool showFrame = true,
111 bool collapsed = false, bool visible = true);
127 Fun3DItem(const KConfigGroup* plo, const QUrl& urlPlo, double x0 = 4,
128 double y0 = 3, double width = 15, double height = 10,
129 unsigned colorFrame = 0, unsigned colorGrid = 0,
130 unsigned colorData = 0, GridMode gridMode = AxesWithLabels);
137 int calcTable() const;
145 void exportTable(QTextStream& stream, char separator, char format,
146 int precision) const;
147 double (*funcY)(double, double, const double*);
149 inline const QLibrary* libY() const { return m_libY; };
151 inline QString nameY() const { return m_nameY; };
153 virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
154 QWidget* widget = nullptr) override;
156 inline double* parY() { return m_parY; };
163 bool setFuncY(const QUrl& url, const QString& name);
169 inline void setPar(int i, double value) { m_parY[i] = value; };
171 virtual int type() const override { return Type; };
173 void update();
175 inline const QUrl& urlY() const { return m_urlY; };
184 void writePlo(KConfigGroup* plo, const QUrl& urlPlo, bool absolute,
185 char format, int precision) const;
186
187protected:
189 void unload();
190 mutable double (*funcYo)(double, double, const double*);
191 double m_parY[FunItem::NumParMax];
192 mutable double parYo[FunItem::NumParMax];
193 QString m_nameY;
194 QUrl m_urlY;
195 QLibrary* m_libY;
196};
197
198#endif
@ Type
Specific QGraphicsItem type number of FrameItem for function type().
Definition frameitem.h:46
GridMode
Grid mode.
Definition frameitem.h:37
3D function item class.
Definition fun3ditem.h:29
void exportTable(QTextStream &stream, char separator, char format, int precision) const
Exports function value table to file.
const QUrl & urlY() const
Returns URL of y function library.
Definition fun3ditem.h:175
void setPar(int i, double value)
Sets parameter.
Definition fun3ditem.h:169
virtual int type() const override
Returns specific QGraphicsItem type number.
Definition fun3ditem.h:171
Fun3DItem(const Fun3DItem &f)
Copy constructor.
double * parY()
Returns y function parameter array pointer.
Definition fun3ditem.h:156
void writePlo(KConfigGroup *plo, const QUrl &urlPlo, bool absolute, char format, int precision) const
Writes into plot file.
bool setFuncY(const QUrl &url, const QString &name)
Resolves y function address.
void unload()
Unloads y function library.
QString nameY() const
Returns y function name.
Definition fun3ditem.h:151
~Fun3DItem()
Destructor.
Fun3DItem(double x0=4, double y0=3, double width=15, double height=10, unsigned colorFrame=0, unsigned colorGrid=0, unsigned colorData=0, bool logX=false, bool logY=false, bool logZ=false, GridMode gridMode=AxesWithLabels, Mode3D mode3D=Grid, double xMax=15, double yMax=10, double zMax=15, const QString &textX=QString(), const QString &textY=QString(), const QString &textZ=QString(), const QString &header=QString(), double relSize=1, int numDigX=-1, int numDigY=-1, int numDigZ=-1, int minTicX=5, int minTicY=2, int minTicZ=5, int expX=0, int expY=0, int expZ=0, double xMin=0, double yMin=0, double zMin=0, double xTic=5, double yTic=2, double zTic=5, double deltaX=0, double deltaZ=0, double phi=20, double theta=-20, double bx=7.5, double by=7.5, double bz=7.5, double xr=7.5, double yr=4, double fx=1, double fy=1, double fz=1, const QString &name=QString(), const QUrl &url=QUrl(), bool showFrame=true, bool collapsed=false, bool visible=true)
Constructor.
const QLibrary * libY() const
Returns pointer to library for y function.
Definition fun3ditem.h:149
void update()
Applies changes and forces redrawing.
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override
Paints item.
int calcTable() const
Calculates function value table.
Fun3DItem(const KConfigGroup *plo, const QUrl &urlPlo, double x0=4, double y0=3, double width=15, double height=10, unsigned colorFrame=0, unsigned colorGrid=0, unsigned colorData=0, GridMode gridMode=AxesWithLabels)
Constructor.
static const int NumParMax
Dimension of parameter arrays.
Definition funitem.h:43
3D item class.
Definition threeditem.h:31
Mode3D
3D mode.
Definition threeditem.h:34