libkpl  5.0
A Library for Graphical Presentation of Data Sets and Functions
scaleditem.h
1 //
2 // C++ Interface: scaleditem
3 //
4 // Description:
5 //
6 //
7 // Author: Werner Stille <kpl@werner-stille.de>, (C) 2017
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12 #ifndef SCALEDITEM_H
13 #define SCALEDITEM_H
14 
15 #include <QGraphicsItem>
16 #include <QPainterPath>
17 #include <QRectF>
18 #include "kplitem.h"
19 
24 class Q_DECL_EXPORT ScaledItem : public KplItem, public QGraphicsItem
25 {
26 public:
28  ScaledItem();
33  ScaledItem(const ScaledItem& a);
41  ScaledItem(const KConfigGroup* plo, Symbol symbol, unsigned color,
42  QGraphicsItem* parent);
55  ScaledItem(FillStyle fillStyle, Symbol symbol, unsigned color, double fx,
56  double fy, double xOffset, double yOffset, double relSize,
57  QGraphicsItem* parent);
59  virtual ~ScaledItem();
61  inline unsigned color() const { return m_color; };
68  static void exponent(double a, int& iExp, double& f);
70  inline FillStyle fillStyle() const { return m_fillStyle; };
77  inline bool isNormalized(double fx, double fy) const
78  { return (m_normX == fx) && (m_normY == fy); };
87  static bool limits(double& xMin, double& xMax, const double* values, int n);
93  inline void normalize(double fx, double fy) { m_normX = fx; m_normY = fy; };
95  inline double normX() const { return m_normX; };
97  inline double normY() const { return m_normY; };
99  QPixmap pixmap() const;
106  void readPlo(const KConfigGroup* plo, Symbol symbol, unsigned color);
111  inline void setColor(unsigned color) { m_color = color; };
116  inline void setFillStyle(FillStyle style) { m_fillStyle = style; };
121  inline void setNormX(double fx) { m_normX = fx; };
126  inline void setNormY(double fy) { m_normY = fy; };
131  void setProperties(const QTransform& m);
133  void setSize();
138  inline void setSymbol(Symbol symbol) { m_symbol = symbol; };
143  inline void setXOffset(double xOffset) { m_xOffset = xOffset; };
148  inline void setYOffset(double yOffset) { m_yOffset = yOffset; };
150  inline Symbol symbol() const { return m_symbol; };
152  void update();
154  void updateGeometry();
160  void writePlo(KConfigGroup* plo, bool visible) const;
162  inline double xOffset() const { return m_xOffset; };
164  inline double yOffset() const { return m_yOffset; };
165 
166 protected:
174  double length(const double* x, const double* y, int n) const;
183  void plotArray(QPainter* painter, const double* x, const double* y,
184  int n) const;
186  void setProperties();
187  FillStyle m_fillStyle;
188  Symbol m_symbol;
189  unsigned m_color;
190  double m_normX, m_normY, m_xOffset, m_yOffset, dydx, myDashOffset;
191  mutable QPen m_pen;
192  mutable QPainterPath bPath;
193  mutable QRectF bRect;
194  QRectF symbRect;
195  QTransform m_matrix;
196 };
197 
198 #endif
Kpl item class.
Definition: kplitem.h:41
void setFillStyle(FillStyle style)
Sets fill style.
Definition: scaleditem.h:116
FillStyle fillStyle() const
Returns fill style.
Definition: scaleditem.h:70
Symbol
Symbol types.
Definition: kplitem.h:83
double normY() const
Returns normalization factor for y values.
Definition: scaleditem.h:97
void setNormX(double fx)
Sets normalization factor for x values.
Definition: scaleditem.h:121
void setYOffset(double yOffset)
Sets offset for y values.
Definition: scaleditem.h:148
void setColor(unsigned color)
Sets color.
Definition: scaleditem.h:111
unsigned color() const
Returns color.
Definition: scaleditem.h:61
bool isNormalized(double fx, double fy) const
Checks if both normalization factors are equal to given values.
Definition: scaleditem.h:77
void update(const QRectF &rect)
double xOffset() const
Returns offset for x values.
Definition: scaleditem.h:162
void setXOffset(double xOffset)
Sets offset for x values.
Definition: scaleditem.h:143
double yOffset() const
Returns offset for y values.
Definition: scaleditem.h:164
void writePlo(KConfigGroup *plo, bool visible=true) const
Writes into plot file.
void setSymbol(Symbol symbol)
Sets symbol type.
Definition: scaleditem.h:138
void normalize(double fx, double fy)
Sets normalization factors.
Definition: scaleditem.h:93
static QPixmap pixmap(Symbol symbol)
Returns black decoration pixmap of plot symbol for use in dialog GUI.
double normX() const
Returns normalization factor for x values.
Definition: scaleditem.h:95
Scaled item class.
Definition: scaleditem.h:24
void setNormY(double fy)
Sets normalization factor for y values.
Definition: scaleditem.h:126
Symbol symbol() const
Returns symbol type.
Definition: scaleditem.h:150
void readPlo(const KConfigGroup *plo)
Initializes corresponding to plot file.