libkpl  5.0
A Library for Graphical Presentation of Data Sets and Functions
imageitem.h
1 /***************************************************************************
2  imageitem.h - description
3  -------------------
4  begin : Don Jun 5 2003
5  copyright : (C) 2017 by Werner Stille
6  email : kpl@werner-stille.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef IMAGEITEM_H
19 #define IMAGEITEM_H
20 
21 #include <QGraphicsPixmapItem>
22 #include <QUrl>
23 #include "decoitem.h"
24 
29 class Q_DECL_EXPORT ImageItem : public DecoItem, public QGraphicsPixmapItem
30 {
31 public:
33  enum {Type = UserType + Image
37  };
49  ImageItem(double x0 = 1, double y0 = 1, QGraphicsItem* parent = 0,
50  const QUrl& url = QUrl(), bool visible = true, double scaleX = 1,
51  double scaleY = 1, double dir = 0);
56  ImageItem(const ImageItem& a);
63  ImageItem(const KConfigGroup* plo, const QUrl& urlPlo,
64  QGraphicsItem* parent = 0);
66  virtual ~ImageItem();
77  static bool boundingBox(const QUrl& url, QString& filename, double* x1,
78  double* y1, double* x2, double* y2);
84  static bool checkBoundingBox(const QUrl& url);
86  inline double dir() const { return m_dir; };
88  virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
89  QWidget* widget);
96  void renderPS(QPixmap* pixmap, int dpiX, int dpiY);
109  static void renderPS(const QString& psFile, const QString& imageFile,
110  int width, int height, double x0 = 0, double y0 = 0,
111  double scaleX = 1, double scaleY = 1,
112  const char format[] = "pbmraw");
114  inline double scaleX() const { return m_scaleX; };
116  inline double scaleY() const { return m_scaleY; };
121  inline void setDir( double dir) { m_dir = dir; };
126  void setProperties(const QTransform& m);
131  inline void setScaleX(double f) { m_scaleX = f; };
136  inline void setScaleY(double f) { m_scaleY = f; };
141  inline void setUrl(const QUrl& url) { m_url = url; };
143  virtual int type() const { return Type; };
145  inline const QUrl& url() const { return m_url; };
147  void update();
154  void writePlo(KConfigGroup* plo, const QUrl& urlPlo, bool absolute) const;
155 
156 protected:
158  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
160  void setProperties();
161  double m_scaleX, m_scaleY, m_dir;
162  QUrl m_url;
163 };
164 
165 #endif
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void writePlo(KConfigGroup *plo, bool visible) const
Writes into plot file.
void update(const QRectF &rect)
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
void setScaleX(double f)
Sets horizontal scaling factor.
Definition: imageitem.h:131
double scaleY() const
Returns vertical scaling factor.
Definition: imageitem.h:116
void setScaleY(double f)
Sets vertical scaling factor.
Definition: imageitem.h:136
virtual int type() const
Returns specific QGraphicsItem type number.
Definition: imageitem.h:143
const QUrl & url() const
Returns URL of PostScript file.
Definition: imageitem.h:145
void setDir(double dir)
Sets rotation angle.
Definition: imageitem.h:121
double dir() const
Returns rotation angle in deg.
Definition: imageitem.h:86
Decoration item class.
Definition: decoitem.h:35
Image item class.
Definition: imageitem.h:29
double scaleX() const
Returns horizontal scaling factor.
Definition: imageitem.h:114
void setUrl(const QUrl &url)
Sets URL.
Definition: imageitem.h:141