|
libkpl
6.0
A Library for Graphical Presentation of Data Sets and Functions
|
Function item class. More...
#include <funitem.h>

Classes | |
| struct | DataErrorStruct |
| Data error structure. More... | |
Public Types | |
| enum | { Type = UserType + Function } |
| Specific QGraphicsItem type number for function type() More... | |
Public Types inherited from KplItem | |
| enum | FillStyle { NoBrush , SolidPattern , HorPattern , VerPattern , CrossPattern , BDiagPattern , FDiagPattern , DiagCrossPattern } |
| Fill styles. More... | |
| enum | ItemType { Frame = 1 , Array , Function , ParFunction , Spline , Array3D , Function3D , Legend , Text , Line , Arrow , Arc , Rectangle , Ellipse , Image , ScaleBar } |
| Item types. More... | |
| enum | PenType { FramePen , GridPen , DataPen } |
| Pen types. More... | |
| enum | Symbol { Invisible = -17 , FilledOctagon , FilledHourglass , FilledTriangle , FilledSquare , FilledDiamond , FilledCircle , Umbrella , Ypsilon , Plus , Cross , OpenOctagon , OpenHourglass , OpenTriangle , OpenSquare , OpenDiamond , Dot , OpenCircle , SolidLine , DashLine1 , DashLine2 , DotLine1 , DashLine3 , DashDotLine , DashLine4 , DashLine5 , DotLine2 } |
| Symbol types. More... | |
Public Member Functions | |
| FunItem () | |
| Constructor. | |
| FunItem (const FunItem &a) | |
| Copy constructor. | |
| FunItem (const KConfigGroup *plo, const QUrl &urlPlo, unsigned color=0, Symbol symbol=SolidLine, QGraphicsItem *parent=nullptr) | |
| Constructor. | |
| 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. | |
| virtual | ~FunItem () |
| Destructor. | |
| virtual QRectF | boundingRect () const override |
| Calculates bounding rectangle. | |
| int | calcTable () const |
| Calculates function value table. | |
| int | calcTable (bool logX) const |
| Calculates function value table. | |
| double | deltaT () const |
| Returns argument step size. | |
| void | exponent (int &expX, int &expY, double &fx, double &fy, bool logX) const |
| Calculates normalization factors. | |
| void | exportTable (QTextStream &stream, char separator, char format, int precision) const |
| Exports function value table to file. | |
| const QLibrary * | libY () const |
| Returns pointer to library for y function. | |
| void | limits (double &xMin, double &xMax, double &yMin, double &yMax, bool logX) const |
| Calculates minimum and maximum values. | |
| QString | nameY () const |
| Returns y function name. | |
| virtual void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override |
| Paints item. | |
| double * | parY () |
| Returns y function parameter array pointer. | |
| void | setDashOffset () |
| Sets offset for dashed lines. | |
| void | setDeltaT (double deltaT) |
| Sets argument step size. | |
| bool | setFuncY (const QUrl &url, const QString &name) |
| Resolves y function address. | |
| virtual void | setPar (int i, double value, bool yFunc=true) |
| Sets parameter. | |
| void | setTMax (double xMax) |
| Sets maximum argument value. | |
| void | setTMin (double xMin) |
| Sets minimum argument value. | |
| virtual QPainterPath | shape () const override |
| Returns the shape of the plot item. | |
| double | tMax () const |
| Returns maximum argument value. | |
| double | tMin () const |
| Returns minimum argument value. | |
| const double * | tValues () const |
| Returns pointer to argument value array. | |
| virtual int | type () const override |
| Returns specific QGraphicsItem type number. | |
| const QUrl & | urlY () const |
| Returns URL of y function library. | |
| void | writePlo (KConfigGroup *plo, const QUrl &urlPlo, bool absolute, char format, int precision) const |
| Writes into plot file. | |
| double * | yValues () const |
| Returns pointer to y function value array. | |
Public Member Functions inherited from ScaledItem | |
| ScaledItem () | |
| Constructor. | |
| ScaledItem (const ScaledItem &a) | |
| Copy constructor. | |
| ScaledItem (const KConfigGroup *plo, Symbol symbol, unsigned color, QGraphicsItem *parent) | |
| Constructor. | |
| ScaledItem (FillStyle fillStyle, Symbol symbol, unsigned color, double fx, double fy, double xOffset, double yOffset, double relSize, QGraphicsItem *parent) | |
| Constructor. | |
| virtual | ~ScaledItem () |
| Destructor. | |
| unsigned | color () const |
| Returns color. | |
| FillStyle | fillStyle () const |
| Returns fill style. | |
| bool | isNormalized (double fx, double fy) const |
| Checks if both normalization factors are equal to given values. | |
| void | normalize (double fx, double fy) |
| Sets normalization factors. | |
| double | normX () const |
| Returns normalization factor for x values. | |
| double | normY () const |
| Returns normalization factor for y values. | |
| QPixmap | pixmap () const |
| Returns decoration pixmap for item list. | |
| void | readPlo (const KConfigGroup *plo, Symbol symbol, unsigned color) |
| Initializes corresponding to plot file. | |
| void | setColor (unsigned color) |
| Sets color. | |
| void | setFillStyle (FillStyle style) |
| Sets fill style. | |
| void | setNormX (double fx) |
| Sets normalization factor for x values. | |
| void | setNormY (double fy) |
| Sets normalization factor for y values. | |
| void | setProperties (const QTransform &m) |
| Sets properties according to transformation matrix. | |
| void | setSize () |
| Sets size according to transformation matrix. | |
| void | setSymbol (Symbol symbol) |
| Sets symbol type. | |
| void | setXOffset (double xOffset) |
| Sets offset for x values. | |
| void | setYOffset (double yOffset) |
| Sets offset for y values. | |
| Symbol | symbol () const |
| Returns symbol type. | |
| void | update () |
| Applies changes and forces redrawing. | |
| void | updateGeometry () |
| Updates geometry. | |
| void | writePlo (KConfigGroup *plo, bool visible) const |
| Writes into plot file. | |
| double | xOffset () const |
| Returns offset for x values. | |
| double | yOffset () const |
| Returns offset for y values. | |
Public Member Functions inherited from KplItem | |
| KplItem (double relSize=1) | |
| Constructor. | |
| KplItem (const KplItem &a) | |
| Copy constructor. | |
| KplItem (const KConfigGroup *plo) | |
| Constructor. | |
| virtual | ~KplItem () |
| Destructor. | |
| void | readPlo (const KConfigGroup *plo) |
| Initializes corresponding to plot file. | |
| double | relSize () const |
| Returns relative size of item. | |
| void | setRelSize (double relSize) |
| Sets relative size of item. | |
| void | writePlo (KConfigGroup *plo, bool visible=true) const |
| Writes into plot file. | |
Static Public Member Functions | |
| static void | calcTable (const double *x, double *values, double(*func)(double, const double *), const double *par, int n) |
| Calculates function value table. | |
| static bool | errorStructChanged (const DataErrorStruct &e1, const DataErrorStruct &e2) |
| Checks data error structures for differences. | |
| 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. | |
| static bool | parChanged (const double *p1, const double *p2) |
| Checks parameter arrays for differences. | |
| static QString | parToString (const double *par, char format, int precision) |
| Converts parameter array to string. | |
| static void | stringToPar (const QString &s, double *par) |
| Converts string to parameter array values. | |
Static Public Member Functions inherited from ScaledItem | |
| static void | exponent (double a, int &iExp, double &f) |
| Calculates normalization factor. | |
| static bool | limits (double &xMin, double &xMax, const double *values, int n) |
| Calculates minimum and maximum values of an array. | |
Static Public Member Functions inherited from KplItem | |
| static QUrl | absoluteUrl (const QString &path, const QUrl &urlPlo) |
| Constructs absolute file URL. | |
| static QBrush | createBrush (unsigned color, FillStyle fillStyle=NoBrush) |
| Creates brush. | |
| static QPen | createPen (double width, unsigned color, PenType penType, Symbol symbol) |
| Creates pen. | |
| static void | paintSymbol (QPainter *painter, const QRectF &rect, Symbol symbol=OpenCircle) |
| Paints symbol. | |
| static QPixmap | pixmap (Symbol symbol) |
| Returns black decoration pixmap of plot symbol for use in dialog GUI. | |
| static QPixmap | pixmap (QPen pen, Symbol symbol=SolidLine) |
| Returns decoration pixmap of plot symbol for use in item lists. | |
| static QString | path (const QUrl &urlPlo, const QUrl &url, bool absolute=false) |
| Constructs absolute or (if possible) relative file path. | |
| static void | resetDashOffset () |
| Resets offset for dashed lines. | |
| static unsigned | rgb (const QString &color) |
| Converts rgb string to QRgb. | |
| static unsigned | rgbQt1 (unsigned rgb) |
| Converts QRgb to Qt1 QRgb. | |
Public Attributes | |
| double(* | funcY )(double, const double *) |
| y function. | |
Static Public Attributes | |
| static const int | NumParMax = 20 |
| Dimension of parameter arrays. | |
Protected Member Functions | |
| void | init () |
| Performs initialization. | |
| void | paintCond (QPainter *painter) const |
| Paints or calculates bounding area. | |
| void | unload () |
| Unloads y function library. | |
Protected Member Functions inherited from ScaledItem | |
| double | length (const double *x, const double *y, int n) const |
| Calculates line length. | |
| void | plotArray (QPainter *painter, const double *x, const double *y, int n) const |
| Plots array. | |
| void | setProperties () |
| Sets properties according to transformation matrix. | |
Protected Member Functions inherited from KplItem | |
| QPen & | changePenWidth (QPen &pen, double width) const |
| Changes pen width. | |
| QPen | createPen (QGraphicsItem *item, unsigned color=0, PenType penType=DataPen, Symbol symbol=SolidLine) const |
| Creates pen for plot item. | |
| double | penWidth (const QGraphicsItem *item, PenType penType=DataPen) const |
| Calculates pen width for plot item. | |
Protected Attributes | |
| bool | logXo |
| double | m_tMin |
| double | m_tMax |
| double | m_deltaT |
| double | tMino |
| double | tMaxo |
| double | deltaTo |
| double(* | funcYo )(double, const double *) |
| double | m_parY [NumParMax] |
| double | parYo [NumParMax] |
| QVector< double > | m_tValues |
| QVector< double > | m_yValues |
| QString | m_nameY |
| QUrl | m_urlY |
| QLibrary * | m_libY |
Protected Attributes inherited from ScaledItem | |
| FillStyle | m_fillStyle |
| Symbol | m_symbol |
| unsigned | m_color |
| double | m_normX |
| double | m_normY |
| double | m_xOffset |
| double | m_yOffset |
| double | dydx |
| double | myDashOffset |
| QPen | m_pen |
| QPainterPath | bPath |
| QRectF | bRect |
| QRectF | symbRect |
| QTransform | m_matrix |
Protected Attributes inherited from KplItem | |
| double | m_relSize |
Additional Inherited Members | |
Static Protected Member Functions inherited from KplItem | |
| static double | parentWidth (const QGraphicsItem *item) |
| Returns width of item's parent frame or width of scene if the item has no parent item. | |
| static double | penWidthFactor (PenType penType) |
| Returns factor to calculate pen width from frame width. | |
Static Protected Attributes inherited from KplItem | |
| static double | m_dashOffset |
Function item class.
Class for function items showing ordinary functions by lines or markers.
| anonymous enum |
| FunItem::FunItem | ( | const FunItem & | a | ) |
Copy constructor.
| a | source item. |
| FunItem::FunItem | ( | const KConfigGroup * | plo, |
| const QUrl & | urlPlo, | ||
| unsigned | color = 0, | ||
| Symbol | symbol = SolidLine, | ||
| QGraphicsItem * | parent = nullptr ) |
Constructor.
Initializes corresponding to plot file.
| plo | pointer to KConfigGroup object containing item data. |
| urlPlo | URL of plot file. |
| color | default color for function plot. |
| symbol | default symbol type. |
| parent | pointer to parent item. |
| FunItem::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.
Initializes corresponding to arguments.
| url | URL of the function library. |
| name | function name. |
| color | color for function plot. |
| symbol | symbol type. |
| fx | normalization factor for x values. |
| fy | normalization factor for y values. |
| parent | pointer to parent item. |
| xMin | minimum argument value. |
| xMax | maximum argument value. |
| deltaX | argument step size, 0 for automatic. |
| visible | true for visible item. |
| fillStyle | fill style. |
| xOffset | offset for x values. |
| yOffset | offset for x values. |
| relSize | relative size of lines or symbols. |
|
overridevirtual |
Calculates bounding rectangle.
Reimplemented in ParFunItem.
| int FunItem::calcTable | ( | ) | const |
Calculates function value table.
| int FunItem::calcTable | ( | bool | logX | ) | const |
Calculates function value table.
| logX | true for logarithmic steps |
|
static |
Calculates function value table.
| x | array with argument values. |
| values | array for function values. |
| func | function. |
| par | parameter array. |
| n | number of values. |
|
static |
Checks data error structures for differences.
| e1 | first data error structure. |
| e2 | second data error structure. |
| void FunItem::exponent | ( | int & | expX, |
| int & | expY, | ||
| double & | fx, | ||
| double & | fy, | ||
| bool | logX ) const |
Calculates normalization factors.
| expX | reference to logarithm of x normalization factor. |
| expY | reference to logarithm of x normalization factor. |
| fx | reference to x normalization factor. |
| fy | reference to y normalization factor. |
| logX | true for logarithmic x axis. |
| void FunItem::exportTable | ( | QTextStream & | stream, |
| char | separator, | ||
| char | format, | ||
| int | precision ) const |
Exports function value table to file.
| stream | stream for output file. |
| separator | column separator character. |
| format | C format character. |
| precision | number of digits. |
|
static |
Performs fit of parameters of a set of functions to a set of arrays.
| aList | array item list. |
| fList | function item list. |
| bFit | array containing true values for parameters to be fitted. |
| par | parameter array. |
| resVector | array for weighted residuals. |
| sigma | array for data errors. |
| err | array of structures containing the data error settings. |
| nonLin | true for nonlinear fit. |
| tol | tolerance value for stopping nonlinear fit iterations. |
| itMax | maximum number of nonlinear fit iterations. |
| lm | object for Levenberg-Marquardt fits. |
| chiSquare | chi-square. |
| corr | array for parameter correlation matrix. |
| parErr | array for parameter erros. |
| avgErr | average error. |
| parent | parent object for lm. |
| void FunItem::limits | ( | double & | xMin, |
| double & | xMax, | ||
| double & | yMin, | ||
| double & | yMax, | ||
| bool | logX ) const |
Calculates minimum and maximum values.
| xMin | reference to minimum of x values. |
| xMax | reference to maximum of x values. |
| yMin | reference to minimum of y values. |
| yMax | reference to maximum of y values. |
| logX | true for logarithmic x axis. |
|
overridevirtual |
Paints item.
Reimplemented in ParFunItem.
|
protected |
Paints or calculates bounding area.
| painter | QPainter object, 0 for calculating bounding area. |
|
static |
Checks parameter arrays for differences.
| p1 | first parameter array. |
| p2 | second parameter array. |
|
static |
Converts parameter array to string.
| par | parameter array. |
| format | C format character. |
| precision | number of digits. |
|
inline |
Sets argument step size.
| deltaT | step size. |
| bool FunItem::setFuncY | ( | const QUrl & | url, |
| const QString & | name ) |
Resolves y function address.
| url | url of the function library. |
| name | function name. |
|
virtual |
Sets parameter.
| i | parameter index. |
| value | value. |
| yFunc | true for y value function. |
Reimplemented in ParFunItem.
|
inline |
Sets maximum argument value.
| xMax | maximum value. |
|
inline |
Sets minimum argument value.
| xMin | maximum value. |
|
static |
Converts string to parameter array values.
| s | string. |
| par | parameter array. |
|
inlineoverridevirtual |
Returns specific QGraphicsItem type number.
Reimplemented in ParFunItem.
| void FunItem::writePlo | ( | KConfigGroup * | plo, |
| const QUrl & | urlPlo, | ||
| bool | absolute, | ||
| char | format, | ||
| int | precision ) const |
Writes into plot file.
| plo | KConfigGroup object. |
| urlPlo | URL of plot file. |
| absolute | true to save absolute paths. |
| format | C format character. |
| precision | number of digits. |