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
KplItem::FilledDiamond
@ FilledDiamond
Filled diamond.
Definition: kplitem.h:89
KplItem::ItemType
ItemType
Item types.
Definition: kplitem.h:56
KplItem::PenType
PenType
Pen types.
Definition: kplitem.h:77
KplItem::FilledHourglass
@ FilledHourglass
Filled hourglass.
Definition: kplitem.h:86
KplItem::Arrow
@ Arrow
Item with single or double-headed arrow.
Definition: kplitem.h:67
KplItem::OpenTriangle
@ OpenTriangle
Open triangle.
Definition: kplitem.h:97
KplItem::OpenDiamond
@ OpenDiamond
Open Diamond.
Definition: kplitem.h:99
KplItem
Kpl item class.
Definition: kplitem.h:41
KplItem::Function3D
@ Function3D
3D function item.
Definition: kplitem.h:63
KplItem::Function
@ Function
2D function item.
Definition: kplitem.h:59
KplItem::relSize
double relSize() const
Returns relative size of item.
Definition: kplitem.h:189
KplItem::Array
@ Array
Item with array of 2D data points.
Definition: kplitem.h:58
KplItem::Umbrella
@ Umbrella
Umbrella-like shape.
Definition: kplitem.h:91
KplItem::Plus
@ Plus
Plus sign cross.
Definition: kplitem.h:93
KplItem::FillStyle
FillStyle
Fill styles.
Definition: kplitem.h:45
KplItem::ParFunction
@ ParFunction
2D parametric function item.
Definition: kplitem.h:60
KplItem::DashLine3
@ DashLine3
Line with wide dashes and short spaces.
Definition: kplitem.h:106
KplItem::Cross
@ Cross
Diagonal cross.
Definition: kplitem.h:94
KplItem::FilledCircle
@ FilledCircle
Filled circle.
Definition: kplitem.h:90
KplItem::DashLine4
@ DashLine4
Line with wide and short dashes.
Definition: kplitem.h:108
KplItem::SolidLine
@ SolidLine
Solid line.
Definition: kplitem.h:102
KplItem::Text
@ Text
Text item.
Definition: kplitem.h:65
KplItem::DashLine1
@ DashLine1
Line with wide dashes and spaces.
Definition: kplitem.h:103
KplItem::Rectangle
@ Rectangle
Item with rectangle or square.
Definition: kplitem.h:69
KplItem::OpenSquare
@ OpenSquare
Open square.
Definition: kplitem.h:98
KplItem::Image
@ Image
Item with EPS image from external file.
Definition: kplitem.h:71
KplItem::DashLine2
@ DashLine2
Line with short dashes and wide spaces.
Definition: kplitem.h:104
KplItem::Dot
@ Dot
Dot-like filled circle.
Definition: kplitem.h:100
KplItem::GridPen
@ GridPen
For grids and tics.
Definition: kplitem.h:79
KplItem::OpenHourglass
@ OpenHourglass
Open hourglass.
Definition: kplitem.h:96
KplItem::FilledTriangle
@ FilledTriangle
Filled triangle.
Definition: kplitem.h:87
KplItem::DashLine5
@ DashLine5
Line with short dashes and short spaces.
Definition: kplitem.h:109
KplItem::FilledOctagon
@ FilledOctagon
Filled octagon.
Definition: kplitem.h:85
KplItem::Ellipse
@ Ellipse
Item with ellipse or circle.
Definition: kplitem.h:70
KplItem::DashDotLine
@ DashDotLine
Dash-dotted line.
Definition: kplitem.h:107
KplItem::NoBrush
@ NoBrush
No brush pattern.
Definition: kplitem.h:46
KplItem::setRelSize
void setRelSize(double relSize)
Sets relative size of item.
Definition: kplitem.h:208
KplItem::Ypsilon
@ Ypsilon
Ypsilon-like shape.
Definition: kplitem.h:92
KplItem::Arc
@ Arc
Item with circular or elliptical arc.
Definition: kplitem.h:68
KplItem::VerPattern
@ VerPattern
Vertical lines.
Definition: kplitem.h:49
KplItem::FramePen
@ FramePen
For rectangular frame.
Definition: kplitem.h:78
KplItem::Legend
@ Legend
Legend item for explaining of symbols or lines.
Definition: kplitem.h:64
KplItem::OpenCircle
@ OpenCircle
Open circle.
Definition: kplitem.h:101
KplItem::Symbol
Symbol
Symbol types.
Definition: kplitem.h:83
KplItem::FDiagPattern
@ FDiagPattern
Forward diagonal lines.
Definition: kplitem.h:52
KplItem::SolidPattern
@ SolidPattern
Uniform color.
Definition: kplitem.h:47
KplItem::FilledSquare
@ FilledSquare
Filled square.
Definition: kplitem.h:88
KplItem::BDiagPattern
@ BDiagPattern
Backward diagonal lines.
Definition: kplitem.h:51
KplItem::Spline
@ Spline
2D spline interpolation item.
Definition: kplitem.h:61
KplItem::Line
@ Line
Item with straight line.
Definition: kplitem.h:66
KplItem::DotLine1
@ DotLine1
Dotted line with wide spaces.
Definition: kplitem.h:105
KplItem::OpenOctagon
@ OpenOctagon
Open octagon.
Definition: kplitem.h:95
KplItem::Array3D
@ Array3D
Item with array of 3D data points.
Definition: kplitem.h:62
KplItem::HorPattern
@ HorPattern
Horizontal lines.
Definition: kplitem.h:48
KplItem::CrossPattern
@ CrossPattern
Crossing horizontal and vertical lines.
Definition: kplitem.h:50