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)  

ImagePrivate.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : ImagePrivate.h
3  Project : LabPlot
4  Description : Worksheet element to draw images
5  --------------------------------------------------------------------
6  Copyright : (C) 2019 by 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 IMAGEPRIVATE_H
30 #define IMAGEPRIVATE_H
31 
32 #include <QGraphicsItem>
33 
35 
36 class QGraphicsSceneHoverEvent;
37 
38 class ImagePrivate: public QGraphicsItem {
39 public:
40  explicit ImagePrivate(Image*);
41 
42  QImage image;
43  QString fileName;
44  qreal opacity{1.0};
47  bool keepRatio{true}; //keep aspect ratio when scaling the image
48  qreal rotationAngle{0.0};
49 
50  // position in parent's coordinate system, the image will be aligned around this point
56 
57  //alignment
60 
61  //border
63  qreal borderOpacity{1.0};
64 
65  QString name() const;
66  void retransform();
67  bool swapVisible(bool on);
68  virtual void recalcShapeAndBoundingRect();
69  void updateImage();
70  void scaleImage();
71  void updatePosition();
72  QPointF positionFromItemPosition(QPointF);
73  void updateBorder();
74 
76  bool suppressRetransform{false};
77  bool m_printing{false};
78  bool m_hovered{false};
79 
80  QRectF boundingRectangle; //bounding rectangle of the text
81  QRectF transformedBoundingRectangle; //bounding rectangle of transformed (rotated etc.) text
82  QPainterPath borderShapePath;
83  QPainterPath imageShape;
84 
85  //reimplemented from QGraphicsItem
86  QRectF boundingRect() const override;
87  QPainterPath shape() const override;
88  void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* widget = nullptr) override;
89  QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
90 
91  Image* const q;
92 
93 private:
94  void contextMenuEvent(QGraphicsSceneContextMenuEvent*) override;
95  void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override;
96  void hoverEnterEvent(QGraphicsSceneHoverEvent*) override;
97  void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override;
98 };
99 
100 #endif
static const QRgb black
Definition: ImageEditor.cpp:38
QString fileName
Definition: ImagePrivate.h:43
bool suppressItemChangeEvent
Definition: ImagePrivate.h:75
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *widget=nullptr) override
Definition: Image.cpp:477
qreal rotationAngle
Definition: ImagePrivate.h:48
QString name() const
Definition: Image.cpp:290
void contextMenuEvent(QGraphicsSceneContextMenuEvent *) override
Definition: Image.cpp:585
bool suppressRetransform
Definition: ImagePrivate.h:76
TextLabel::PositionWrapper position
Definition: ImagePrivate.h:51
void updatePosition()
Definition: Image.cpp:393
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override
Definition: Image.cpp:589
TextLabel::VerticalAlignment verticalAlignment
Definition: ImagePrivate.h:59
QPainterPath borderShapePath
Definition: ImagePrivate.h:82
ImagePrivate(Image *)
Definition: Image.cpp:283
void updateBorder()
Definition: Image.cpp:427
QRectF boundingRect() const override
Definition: Image.cpp:444
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override
Definition: Image.cpp:530
QRectF boundingRectangle
Definition: ImagePrivate.h:80
TextLabel::HorizontalAlignment horizontalAlignment
Definition: ImagePrivate.h:58
QPointF positionFromItemPosition(QPointF)
Definition: Image.cpp:550
void retransform()
Definition: Image.cpp:297
bool swapVisible(bool on)
Definition: Image.cpp:433
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override
Definition: Image.cpp:597
QPainterPath imageShape
Definition: ImagePrivate.h:83
void updateImage()
Definition: Image.cpp:348
QImage image
Definition: ImagePrivate.h:42
Image *const q
Definition: ImagePrivate.h:91
void scaleImage()
Definition: Image.cpp:366
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
Definition: Image.cpp:510
qreal borderOpacity
Definition: ImagePrivate.h:63
virtual void recalcShapeAndBoundingRect()
Definition: Image.cpp:458
QRectF transformedBoundingRectangle
Definition: ImagePrivate.h:81
QPainterPath shape() const override
Definition: Image.cpp:451
A label supporting rendering of html- and tex-formatted texts.
Definition: Image.h:41
static double convertToSceneUnits(const double value, const Worksheet::Unit unit)
Definition: Worksheet.cpp:113