libkpl  4.1
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) 2015 by Werner Stille
10  email : stille@uni-freiburg.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 <math.h>
26 #include <kdemacros.h>
27 #include <QBrush>
28 #include <QPen>
29 #include <QPixmap>
30 #include <QString>
31 
32 class QGraphicsItem;
33 class QPainter;
34 class QPointF;
35 class QRectF;
36 class KConfigGroup;
37 class KUrl;
38 
43 class KDE_EXPORT KplItem
44 {
45 public:
47  enum FillStyle {
55  DiagCrossPattern
56  };
58  enum ItemType {
59  Frame = 1,
67  Text,
68  Line,
70  Arc,
74  ScaleBar
75  };
79  enum PenType {
82  DataPen
83  };
85  enum Symbol {
86  Invisible = -17,
95  Plus,
102  Dot,
112  DotLine2
113  };
115  static const double Deg2rad;
120  KplItem(double relSize = 1);
125  KplItem(const KplItem& a);
130  KplItem(const KConfigGroup* plo);
132  virtual ~KplItem();
139  static KUrl absoluteUrl(const QString& path, const KUrl& urlPlo);
146  static QBrush createBrush(unsigned color, FillStyle fillStyle = NoBrush);
155  static QPen createPen(double width, unsigned color, PenType penType,
156  Symbol symbol);
163  static void paintSymbol(QPainter* painter, const QRectF& rect,
164  Symbol symbol = OpenCircle);
170  static QPixmap pixmap(Symbol symbol);
177  static QPixmap pixmap(QPen pen, Symbol symbol = SolidLine);
182  void readPlo(const KConfigGroup* plo);
190  static QString path(const KUrl& urlPlo, const KUrl& url,
191  bool absolute = false);
193  inline double relSize() const { return m_relSize; };
199  static unsigned rgb(const QString& color);
205  static unsigned rgbQt1(unsigned rgb);
210  inline void setRelSize(double relSize) { m_relSize = relSize; };
216  static QString tempFileName(const QString& suffix = ".tmp");
222  void writePlo(KConfigGroup* plo, bool visible = true) const;
223 
224 protected:
231  QPen& changePenWidth(QPen& pen, double width) const;
240  QPen createPen(QGraphicsItem* item, unsigned color = 0,
241  PenType penType = DataPen, Symbol symbol = SolidLine) const;
248  static double parentWidth(const QGraphicsItem* item);
255  double penWidth(const QGraphicsItem* item, PenType penType = DataPen) const;
261  static double penWidthFactor(PenType penType);
262  static double m_dashOffset;
263  double m_relSize;
264 };
265 
266 #endif
Ypsilon-like shape.
Definition: kplitem.h:94
2D function item.
Definition: kplitem.h:61
Item with single or double-headed arrow.
Definition: kplitem.h:69
Kpl item class.
Definition: kplitem.h:43
FillStyle
Fill styles.
Definition: kplitem.h:47
Crossing horizontal and vertical lines.
Definition: kplitem.h:52
Item with array of 2D data points.
Definition: kplitem.h:60
For grids and tics.
Definition: kplitem.h:81
Dot-like filled circle.
Definition: kplitem.h:102
Symbol
Symbol types.
Definition: kplitem.h:85
Open Diamond.
Definition: kplitem.h:101
Filled diamond.
Definition: kplitem.h:91
Filled octagon.
Definition: kplitem.h:87
Plus sign cross.
Definition: kplitem.h:95
Filled triangle.
Definition: kplitem.h:89
No brush pattern.
Definition: kplitem.h:48
Uniform color.
Definition: kplitem.h:49
void setRelSize(double relSize)
Sets relative size of item.
Definition: kplitem.h:210
Item with array of 3D data points.
Definition: kplitem.h:64
Open hourglass.
Definition: kplitem.h:98
Diagonal cross.
Definition: kplitem.h:96
Umbrella-like shape.
Definition: kplitem.h:93
Line with short dashes and wide spaces.
Definition: kplitem.h:106
PenType
Pen types.
Definition: kplitem.h:79
Filled square.
Definition: kplitem.h:90
Open circle.
Definition: kplitem.h:103
Backward diagonal lines.
Definition: kplitem.h:53
Text item.
Definition: kplitem.h:67
double relSize() const
Returns relative size of item.
Definition: kplitem.h:193
2D parametric function item.
Definition: kplitem.h:62
Filled circle.
Definition: kplitem.h:92
Open triangle.
Definition: kplitem.h:99
Forward diagonal lines.
Definition: kplitem.h:54
Filled hourglass.
Definition: kplitem.h:88
Horizontal lines.
Definition: kplitem.h:50
Line with wide dashes and spaces.
Definition: kplitem.h:105
2D spline interpolation item.
Definition: kplitem.h:63
Open square.
Definition: kplitem.h:100
Legend item for explaining of symbols or lines.
Definition: kplitem.h:66
Item with rectangle or square.
Definition: kplitem.h:71
ItemType
Item types.
Definition: kplitem.h:58
Line with short dashes and short spaces.
Definition: kplitem.h:111
Solid line.
Definition: kplitem.h:104
Vertical lines.
Definition: kplitem.h:51
Line with wide dashes and short spaces.
Definition: kplitem.h:108
Item with EPS image from external file.
Definition: kplitem.h:73
Item with circular or elliptical arc.
Definition: kplitem.h:70
static const double Deg2rad
Factor for converting from degrees to radians.
Definition: kplitem.h:115
For rectangular frame.
Definition: kplitem.h:80
Line with wide and short dashes.
Definition: kplitem.h:110
Open octagon.
Definition: kplitem.h:97
Item with ellipse or circle.
Definition: kplitem.h:72
Dash-dotted line.
Definition: kplitem.h:109
Dotted line with wide spaces.
Definition: kplitem.h:107
3D function item.
Definition: kplitem.h:65
Item with straight line.
Definition: kplitem.h:68