libkpl  5.0
A Library for Graphical Presentation of Data Sets and Functions
kplscene.h
1 //
2 // C++ Interface: kplscene
3 //
4 // Description:
5 //
6 //
7 // Author: Werner Stille <tille@uni-freiburg.de>, (C) 2017
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12 #ifndef KPLSCENE_H
13 #define KPLSCENE_H
14 
15 #include <QSizeF>
16 #include <QGraphicsScene>
17 #include <QUrl>
18 #include "arrayitem.h"
19 #include "frameitem.h"
20 
21 class QPointF;
22 class QPrinter;
23 class QString;
24 class QTransform;
25 class FrameItem;
26 
34 class Q_DECL_EXPORT KplScene : public QGraphicsScene
35 {
36  Q_OBJECT
37 public:
43  KplScene(const QSizeF& size = QSizeF(21, 14.8), QObject* parent = 0);
45  ~KplScene();
52  bool exportImage(const QUrl& url, bool boundingBox = true);
61  static bool framelike(int type);
69  void insertItem(QGraphicsItem* item, int z = -1);
75  QList<QGraphicsItem*> items(Qt::SortOrder order) const;
81  QPointF map(const QPointF& p) const;
87  QPointF mapInv(const QPointF& p) const;
89  inline const QTransform& matrix() const { return m_matrix; };
94  void print(QPrinter* printer);
123  bool readData(const QUrl& url,
125  bool autoPathHeader = false, bool autoNorm = true,
126  bool logX = false, bool logY = false, double x0 = 4,
127  double y0 = 3, double width = 15, double height = 10,
128  unsigned colorFrame = 0, unsigned colorGrid = 0,
129  unsigned colorData = 0,
131  const QString& xText = "x", const QString& yText = "y",
132  const QString& header = "", double relSize = 1, int colX = 0,
133  int colY = 1, int colErr = 2, bool errorBars = false,
141  bool readPlo(const QUrl& url, QWidget* window = 0);
162  static bool readPlo(const QUrl& url, QList<QGraphicsItem*>& list,
163  QWidget* window = 0, unsigned colorFrame = 0,
164  unsigned colorGrid = 0, unsigned colorData = 0,
166  double x0 = 4, double y0 = 3, double width = 15,
167  double height = 10,
169  int colX = 0, int colY = 0, int colErr = 0,
170  bool errorBars = false);
180  bool savePlo(const QUrl& url, bool absolute = true, char format = 'g',
181  int precision = 6) const;
192  static bool savePlo(const QUrl& url, const QList<QGraphicsItem*>& list,
193  bool absolute = true, char format = 'g',
194  int precision = 6);
202  bool savePS(const QUrl& url = QUrl(), bool landscape = false,
203  bool boundingBox = true);
205  inline const QSizeF size() const { return m_size; };
207  void setDashOffsets() const;
212  void setProperties(QGraphicsItem* item) const;
217  void setSize(const QSizeF& size);
223  QPointF steps(int z = -1) const;
228  void updatePos(QGraphicsItem* item);
229 
230 signals:
237  void mouseMoved(const QPointF& pos, const FrameItem* frame);
243  void mousePressed(const QPointF& pos, Qt::MouseButtons buttons);
248  void positionChanged(QGraphicsItem* item);
253  void previewCreated(const QString& filename);
254 
255 protected:
261  FrameItem* frame(int z = -1) const;
267  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* e);
272  virtual void mousePressEvent(QGraphicsSceneMouseEvent* e);
273  double m_sx, m_sy;
274  QTransform m_matrix, m_inv;
275  QSizeF m_size;
276 };
277 
278 #endif
GridMode
Grid mode.
Definition: frameitem.h:37
Symbol
Symbol types.
Definition: kplitem.h:83
QList< QGraphicsItem * > items(Qt::SortOrder order) const
const QTransform & matrix() const
Returns matrix for transformation from cm to pixel units.
Definition: kplscene.h:89
typedef MouseButtons
const QSizeF size() const
Returns scene size in cm units.
Definition: kplscene.h:205
virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
DecimalCharacter
Decimal character.
Definition: arrayitem.h:43
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
Open circle.
Definition: kplitem.h:101
Kpl graphics scene class.
Definition: kplscene.h:34
Axes with tics and labels.
Definition: frameitem.h:40
Solid line.
Definition: kplitem.h:102
Decimal point.
Definition: arrayitem.h:44
Frame item class.
Definition: frameitem.h:33