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

Public Types | |
| enum | { Type = UserType + Spline } | 
| 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 | |
| SplineItem (int degree=3, int derivOrder=0, double xLow=0, 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.   | |
| SplineItem (const SplineItem &a) | |
| Copy constructor.  | |
| SplineItem (const KConfigGroup *plo, unsigned color=0, Symbol symbol=SolidLine, QGraphicsItem *parent=nullptr) | |
| Constructor.   | |
| virtual | ~SplineItem () | 
| Destructor.  | |
| virtual QRectF | boundingRect () const override | 
| Calculates bounding rectangle.  | |
| int | calcTable (bool logX) const | 
| Calculates spline value table.   | |
| int | calcTable (const double *x, double *values, int n=1, int derivOrder=0, double xLow=0) const | 
| Calculates spline value table.   | |
| void | copySpline (const SplineItem *a) | 
| Copies spline data.   | |
| int | degree () const | 
| Returns degree of spline.  | |
| double | deltaX () const | 
| Returns argument step size.  | |
| int | derivOrder () const | 
| Returns order of derivative.  | |
| 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 spline value table to file.   | |
| int | fit (const ArrayItem *ai, double xMin, double xMax, double *chiSquare=nullptr, int *numKnots=nullptr, double smooth=0, FunItem::DataErrorStruct *err=nullptr, double *avgErr=nullptr) | 
| Performs smoothing spline fit.   | |
| int | fit (const double *x, const double *y, const double *errors, int n, double xMin, double xMax, double *chiSquare=nullptr, int *numKnots=nullptr, double smooth=0, FunItem::DataErrorStruct *err=nullptr, double *avgErr=nullptr) | 
| Performs smoothing spline fit.   | |
| int | interpolation (const double *x, const double *y, int n, double xMin, double xMax) | 
| Performs interpolating (non-smoothing) spline fit.   | |
| void | limits (double &xMin, double &xMax, double &yMin, double &yMax, bool logX) const | 
| Calculates minimum and maximum values.   | |
| int | numKnots () const | 
| Returns number of knots.  | |
| virtual void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override | 
| Paints item.  | |
| int | roots (QVector< double > &zero, int derivOrder=0, double offset=0) const | 
| Finds roots of a cubic spline or its derivatives.   | |
| void | setDashOffset () | 
| Sets offset for dashed lines.  | |
| void | setDegree (int degree) | 
| Sets degree of spline.   | |
| void | setDeltaX (double deltaX) | 
| Sets argument step size.   | |
| void | setDerivOrder (int derivOrder) | 
| Sets order of derivative.   | |
| void | setXLow (double xLow) | 
| Sets lower x limit for spline integral.   | |
| void | setXMax (double xMax) | 
| Sets maximum argument value.   | |
| void | setXMin (double xMin) | 
| Sets minimum argument value.   | |
| virtual QPainterPath | shape () const override | 
| Returns the shape of the plot item.  | |
| virtual int | type () const override | 
| Returns specific QGraphicsItem type number.  | |
| void | writePlo (KConfigGroup *plo, char format, int precision) const | 
| Writes into plot file.   | |
| double | xLow () const | 
| Returns lower x limit for spline integral.  | |
| double | xMax () const | 
| Returns maximum argument value.  | |
| double | xMin () const | 
| Returns minimum argument value.  | |
| double * | xValues () const | 
| Returns pointer to x function value array.  | |
| 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 int | sortArrays (const double *x0, const double *y0, const double *errors0, int &n, FunItem::DataErrorStruct *err, double *x, double *y, double *errors) | 
| Sorts arrays and calculates error column.   | |
  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.   | |
Protected Member Functions | |
| void | paintCond (QPainter *painter) const | 
| Paints or calculates bounding area.   | |
  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 | 
| int | m_degree | 
| int | m_numKnots | 
| int | m_derivOrder | 
| int | degreeo | 
| int | numKnotso | 
| int | derivOrdero | 
| double | m_xMin | 
| double | m_xMax | 
| double | m_deltaX | 
| double | m_xLow | 
| double | xMino | 
| double | xMaxo | 
| double | deltaXo | 
| double | xLowo | 
| QVector< double > | m_xValues | 
| QVector< double > | m_yValues | 
| QVector< double > | t | 
| QVector< double > | c | 
  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 | 
Spline item class.
Class for smoothing spline items for plotting spline interpolations, derivatives or integrals by lines or markers.
| anonymous enum | 
Specific QGraphicsItem type number for function type()
| Enumerator | |
|---|---|
| Type | Specific QGraphicsItem type number of SplineItem for function type().  | 
| SplineItem::SplineItem | ( | int | degree = 3, | 
| int | derivOrder = 0, | ||
| double | xLow = 0, | ||
| 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.
| degree | degree of spline. | 
| derivOrder | order of derivative. | 
| xLow | lower x limit for spline integral. | 
| color | color for 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. | 
| visible | true for visible item. | 
| fillStyle | > 0 for filled polygon representation. | 
| xOffset | offset for x values. | 
| yOffset | offset for x values. | 
| relSize | relative size of lines or symbols. | 
| SplineItem::SplineItem | ( | const KConfigGroup * | plo, | 
| unsigned | color = 0, | ||
| Symbol | symbol = SolidLine, | ||
| QGraphicsItem * | parent = nullptr ) | 
Constructor.
Initializes corresponding to plot file.
| plo | pointer to KConfigGroup object containing item data. | 
| color | default color for function plot. | 
| symbol | default symbol type. | 
| parent | pointer to parent item. | 
| int SplineItem::calcTable | ( | bool | logX | ) | const | 
Calculates spline value table.
| logX | true for logarithmic steps | 
| int SplineItem::calcTable | ( | const double * | x, | 
| double * | values, | ||
| int | n = 1, | ||
| int | derivOrder = 0, | ||
| double | xLow = 0 ) const | 
Calculates spline value table.
| x | array with x values. | 
| values | array for y values. | 
| n | number of points. | 
| derivOrder | order of derivative. | 
| xLow | lower x limit in case of spline integral. | 
| void SplineItem::copySpline | ( | const SplineItem * | a | ) | 
Copies spline data.
| a | pointer to source item. | 
| void SplineItem::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 SplineItem::exportTable | ( | QTextStream & | stream, | 
| char | separator, | ||
| char | format, | ||
| int | precision ) const | 
Exports spline value table to file.
| stream | stream for output file. | 
| separator | column separator character. | 
| format | C format character. | 
| precision | number of digits. | 
| int SplineItem::fit | ( | const ArrayItem * | ai, | 
| double | xMin, | ||
| double | xMax, | ||
| double * | chiSquare = nullptr, | ||
| int * | numKnots = nullptr, | ||
| double | smooth = 0, | ||
| FunItem::DataErrorStruct * | err = nullptr, | ||
| double * | avgErr = nullptr ) | 
Performs smoothing spline fit.
| ai | pointer to array item. | 
| xMin | lower boundary of approximation interval. | 
| xMax | upper boundary of approximation interval. | 
| chiSquare | chi-square. | 
| numKnots | number of knots. | 
| smooth | smoothing factor. | 
| err | pointer to structure containing the data error settings. | 
| avgErr | average error. | 
| int SplineItem::fit | ( | const double * | x, | 
| const double * | y, | ||
| const double * | errors, | ||
| int | n, | ||
| double | xMin, | ||
| double | xMax, | ||
| double * | chiSquare = nullptr, | ||
| int * | numKnots = nullptr, | ||
| double | smooth = 0, | ||
| FunItem::DataErrorStruct * | err = nullptr, | ||
| double * | avgErr = nullptr ) | 
Performs smoothing spline fit.
| x | array with x values. | 
| y | array with y values. | 
| errors | array with error values. | 
| n | number of points. | 
| xMin | lower boundary of approximation interval. | 
| xMax | upper boundary of approximation interval. | 
| chiSquare | chi-square. | 
| numKnots | number of knots. | 
| smooth | smoothing factor. | 
| err | pointer to structure containing the data error settings. | 
| avgErr | average error. | 
| int SplineItem::interpolation | ( | const double * | x, | 
| const double * | y, | ||
| int | n, | ||
| double | xMin, | ||
| double | xMax ) | 
Performs interpolating (non-smoothing) spline fit.
| x | array with x values. | 
| y | array with y values. | 
| n | number of points. | 
| xMin | lower boundary of approximation interval. | 
| xMax | upper boundary of approximation interval. | 
| void SplineItem::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. | 
      
  | 
  protected | 
Paints or calculates bounding area.
| painter | QPainter object, 0 for calculating bounding area. | 
| int SplineItem::roots | ( | QVector< double > & | zero, | 
| int | derivOrder = 0, | ||
| double | offset = 0 ) const | 
Finds roots of a cubic spline or its derivatives.
| zero | array for roots. | 
| derivOrder | order of derivative. | 
| offset | value of the spline or derivative. | 
      
  | 
  inline | 
Sets degree of spline.
| degree | degree. | 
      
  | 
  inline | 
Sets argument step size.
| deltaX | step size. | 
      
  | 
  inline | 
Sets order of derivative.
| derivOrder | order. | 
      
  | 
  inline | 
Sets lower x limit for spline integral.
| xLow | lower x limit. | 
      
  | 
  inline | 
Sets maximum argument value.
| xMax | maximum argument value. | 
      
  | 
  inline | 
Sets minimum argument value.
| xMin | minimum argument value. | 
      
  | 
  static | 
Sorts arrays and calculates error column.
| x0 | array with x values. | 
| y0 | array with y values. | 
| errors0 | array with error values. | 
| n | number of points. | 
| err | pointer to structure containing the data error settings. | 
| x | array for sorted x values. | 
| y | array for y values. | 
| errors | array for error values. | 
| void SplineItem::writePlo | ( | KConfigGroup * | plo, | 
| char | format, | ||
| int | precision ) const | 
Writes into plot file.
| plo | KConfigGroup object. | 
| format | C format character. | 
| precision | number of digits. |