labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Image.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : Image.h
3  Project : LabPlot
4  Description : Worksheet element to draw images
5  --------------------------------------------------------------------
6  Copyright : (C) 2019 Alexander Semke (alexander.semke@web.de)
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  * This program is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU General Public License for more details. *
21  * *
22  * You should have received a copy of the GNU General Public License *
23  * along with this program; if not, write to the Free Software *
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
25  * Boston, MA 02110-1301 USA *
26  * *
27  ***************************************************************************/
28 
29 #ifndef IMAGE_H
30 #define IMAGE_H
31 
32 #include "backend/lib/macros.h"
34 
35 #include <QPen>
36 
37 class QBrush;
38 class QFont;
39 class ImagePrivate;
40 
41 class Image : public WorksheetElement {
42  Q_OBJECT
43 
44 public:
45  explicit Image(const QString& name);
46  ~Image() override;
47 
48  QIcon icon() const override;
49  QMenu* createContextMenu() override;
50  QGraphicsItem* graphicsItem() const override;
51  void setParentGraphicsItem(QGraphicsItem*);
52 
53  void save(QXmlStreamWriter*) const override;
54  bool load(XmlStreamReader*, bool preview) override;
55  void loadThemeConfig(const KConfig&) override;
56  void saveThemeConfig(const KConfig&) override;
57 
58  CLASS_D_ACCESSOR_DECL(QString, fileName, FileName)
59  BASIC_D_ACCESSOR_DECL(qreal, opacity, Opacity)
60  BASIC_D_ACCESSOR_DECL(int, width, Width)
61  BASIC_D_ACCESSOR_DECL(int, height, Height)
62  BASIC_D_ACCESSOR_DECL(bool, keepRatio, KeepRatio)
64  void setPosition(QPointF);
67  BASIC_D_ACCESSOR_DECL(qreal, rotationAngle, RotationAngle)
68 
69  CLASS_D_ACCESSOR_DECL(QPen, borderPen, BorderPen)
70  BASIC_D_ACCESSOR_DECL(qreal, borderOpacity, BorderOpacity)
71 
72  void setVisible(bool on) override;
73  bool isVisible() const override;
74  void setPrinting(bool) override;
75 
76  void retransform() override;
77  void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override;
78 
80 
81 private slots:
82  //SLOTs for changes triggered via QActions in the context menu
83  void visibilityChanged();
84 
85 protected:
87  Image(const QString&, ImagePrivate*);
88 
89 private:
90  Q_DECLARE_PRIVATE(Image)
91  void init();
92 
93  QAction* visibilityAction{nullptr};
94 
95 signals:
96  void fileNameChanged(const QString&);
97  void opacityChanged(float);
98  void widthChanged(int);
99  void heightChanged(int);
100  void keepRatioChanged(bool);
104  void rotationAngleChanged(qreal);
105  void borderPenChanged(QPen&);
106  void borderOpacityChanged(float);
107  void visibleChanged(bool);
108  void changed();
109 };
110 
111 #endif
QString name() const
A label supporting rendering of html- and tex-formatted texts.
Definition: Image.h:41
void changed()
void init()
Definition: Image.cpp:67
void heightChanged(int)
void save(QXmlStreamWriter *) const override
Save as XML.
Definition: Image.cpp:609
void positionChanged(const WorksheetElement::PositionWrapper &)
void horizontalAlignmentChanged(WorksheetElement::HorizontalAlignment)
void visibilityChanged()
Definition: Image.cpp:275
void setVisible(bool on) override
Show/hide the element.
Definition: Image.cpp:257
void borderPenChanged(QPen &)
void verticalAlignmentChanged(WorksheetElement::VerticalAlignment)
QMenu * createContextMenu() override
Return a new context menu.
Definition: Image.cpp:134
~Image() override
QGraphicsItem * graphicsItem() const override
Return the graphics item representing this element.
Definition: Image.cpp:98
ImagePrivate *const d_ptr
Definition: Image.h:86
void setParentGraphicsItem(QGraphicsItem *)
Definition: Image.cpp:102
void setPrinting(bool) override
Switches the printing mode on/off.
Definition: Image.cpp:267
void fileNameChanged(const QString &)
Image(const QString &name)
Definition: Image.cpp:55
void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override
Definition: Image.cpp:113
void loadThemeConfig(const KConfig &) override
Definition: Image.cpp:721
void setPosition(QPointF)
Definition: Image.cpp:202
ImagePrivate Private
Definition: Image.h:79
void visibleChanged(bool)
void rotationAngleChanged(qreal)
bool isVisible() const override
Return whether the element is (at least) partially visible.
Definition: Image.cpp:262
void saveThemeConfig(const KConfig &) override
Definition: Image.cpp:725
void widthChanged(int)
QIcon icon() const override
Definition: Image.cpp:130
void retransform() override
Tell the element to newly transform its graphics item into its coordinate system.
Definition: Image.cpp:108
bool load(XmlStreamReader *, bool preview) override
Load from XML.
Definition: Image.cpp:647
void opacityChanged(float)
QAction * visibilityAction
Definition: Image.h:93
void keepRatioChanged(bool)
void borderOpacityChanged(float)
Base class for all Worksheet children.
XML stream parser that supports errors as well as warnings. This class also adds line and column numb...
#define CLASS_D_ACCESSOR_DECL(type, method, Method)
Definition: macros.h:134
#define BASIC_D_ACCESSOR_DECL(type, method, Method)
Definition: macros.h:107