libkpl  5.0
A Library for Graphical Presentation of Data Sets and Functions
kplitem.h
1 /***************************************************************************
2  kplitem.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 : Wed Aug 25 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 KPLITEM_H
23 #define KPLITEM_H
24 
25 #include <QBrush>
26 #include <QPen>
27 #include <QPixmap>
28 #include <QString>
29 
30 class QGraphicsItem;
31 class QPainter;
32 class QPointF;
33 class QRectF;
34 class KConfigGroup;
35 class QUrl;
36 
41 class Q_DECL_EXPORT KplItem
42 {
43 public:
45  enum FillStyle {
53  DiagCrossPattern
54  };
56  enum ItemType {
57  Frame = 1,
65  Text,
66  Line,
68  Arc,
72  ScaleBar
73  };
77  enum PenType {
80  DataPen
81  };
83  enum Symbol {
84  Invisible = -17,
93  Plus,
100  Dot,
110  DotLine2
111  };
116  KplItem(double relSize = 1);
121  KplItem(const KplItem& a);
126  KplItem(const KConfigGroup* plo);
128  virtual ~KplItem();
135  static QUrl absoluteUrl(const QString& path, const QUrl& urlPlo);
142  static QBrush createBrush(unsigned color, FillStyle fillStyle = NoBrush);
151  static QPen createPen(double width, unsigned color, PenType penType,
152  Symbol symbol);
159  static void paintSymbol(QPainter* painter, const QRectF& rect,
160  Symbol symbol = OpenCircle);
166  static QPixmap pixmap(Symbol symbol);
173  static QPixmap pixmap(QPen pen, Symbol symbol = SolidLine);
178  void readPlo(const KConfigGroup* plo);
186  static QString path(const QUrl& urlPlo, const QUrl& url,
187  bool absolute = false);
189  inline double relSize() const { return m_relSize; };
191  static void resetDashOffset();
197  static unsigned rgb(const QString& color);
203  static unsigned rgbQt1(unsigned rgb);
208  inline void setRelSize(double relSize) { m_relSize = relSize; };
214  void writePlo(KConfigGroup* plo, bool visible = true) const;
215 
216 protected:
223  QPen& changePenWidth(QPen& pen, double width) const;
232  QPen createPen(QGraphicsItem* item, unsigned color = 0,
233  PenType penType = DataPen, Symbol symbol = SolidLine) const;
240  static double parentWidth(const QGraphicsItem* item);
247  double penWidth(const QGraphicsItem* item, PenType penType = DataPen) const;
253  static double penWidthFactor(PenType penType);
254  static double m_dashOffset;
255  double m_relSize;
256 };
257 
258 #endif
Ypsilon-like shape.
Definition: kplitem.h:92
2D function item.
Definition: kplitem.h:59
Item with single or double-headed arrow.
Definition: kplitem.h:67
Kpl item class.
Definition: kplitem.h:41
FillStyle
Fill styles.
Definition: kplitem.h:45
Crossing horizontal and vertical lines.
Definition: kplitem.h:50
Item with array of 2D data points.
Definition: kplitem.h:58
For grids and tics.
Definition: kplitem.h:79
Dot-like filled circle.
Definition: kplitem.h:100
Symbol
Symbol types.
Definition: kplitem.h:83
Open Diamond.
Definition: kplitem.h:99
Filled diamond.
Definition: kplitem.h:89
Filled octagon.
Definition: kplitem.h:85
Plus sign cross.
Definition: kplitem.h:93
Filled triangle.
Definition: kplitem.h:87
No brush pattern.
Definition: kplitem.h:46
Uniform color.
Definition: kplitem.h:47
void setRelSize(double relSize)
Sets relative size of item.
Definition: kplitem.h:208
Item with array of 3D data points.
Definition: kplitem.h:62
Open hourglass.
Definition: kplitem.h:96
Diagonal cross.
Definition: kplitem.h:94
Umbrella-like shape.
Definition: kplitem.h:91
Line with short dashes and wide spaces.
Definition: kplitem.h:104
PenType
Pen types.
Definition: kplitem.h:77
Filled square.
Definition: kplitem.h:88
Open circle.
Definition: kplitem.h:101
Backward diagonal lines.
Definition: kplitem.h:51
Text item.
Definition: kplitem.h:65
double relSize() const
Returns relative size of item.
Definition: kplitem.h:189
2D parametric function item.
Definition: kplitem.h:60
Filled circle.
Definition: kplitem.h:90
Open triangle.
Definition: kplitem.h:97
Forward diagonal lines.
Definition: kplitem.h:52
Filled hourglass.
Definition: kplitem.h:86
Horizontal lines.
Definition: kplitem.h:48
Line with wide dashes and spaces.
Definition: kplitem.h:103
2D spline interpolation item.
Definition: kplitem.h:61
Open square.
Definition: kplitem.h:98
Legend item for explaining of symbols or lines.
Definition: kplitem.h:64
Item with rectangle or square.
Definition: kplitem.h:69
ItemType
Item types.
Definition: kplitem.h:56
Line with short dashes and short spaces.
Definition: kplitem.h:109
Solid line.
Definition: kplitem.h:102
Vertical lines.
Definition: kplitem.h:49
Line with wide dashes and short spaces.
Definition: kplitem.h:106
Item with EPS image from external file.
Definition: kplitem.h:71
Item with circular or elliptical arc.
Definition: kplitem.h:68
For rectangular frame.
Definition: kplitem.h:78
Line with wide and short dashes.
Definition: kplitem.h:108
Open octagon.
Definition: kplitem.h:95
Item with ellipse or circle.
Definition: kplitem.h:70
Dash-dotted line.
Definition: kplitem.h:107
Dotted line with wide spaces.
Definition: kplitem.h:105
3D function item.
Definition: kplitem.h:63
Item with straight line.
Definition: kplitem.h:66