LibrePCB Developers Documentation
Loading...
Searching...
No Matches
imagegraphicsitem.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_EDITOR_IMAGEGRAPHICSITEM_H
21#define LIBREPCB_EDITOR_IMAGEGRAPHICSITEM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29#include <QtWidgets>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35
36class TransactionalDirectory;
37
38namespace editor {
39
40class GraphicsLayer;
41class GraphicsLayerList;
42class OriginCrossGraphicsItem;
43
44/*******************************************************************************
45 * Class ImageGraphicsItem
46 ******************************************************************************/
47
52class ImageGraphicsItem final : public QGraphicsItem {
53public:
54 // Constructors / Destructor
56 ImageGraphicsItem(const ImageGraphicsItem& other) = delete;
58 const std::shared_ptr<Image>& image,
59 const GraphicsLayerList& layers,
60 QGraphicsItem* parent = nullptr) noexcept;
61 virtual ~ImageGraphicsItem() noexcept;
62
63 // Getters
64 const std::shared_ptr<Image>& getObj() noexcept { return mImage; }
65
70 bool isResizeHandleAtPosition(const Point& pos) const noexcept;
71
72 // Setters
73
83 void setEditable(bool editable) noexcept;
84
85 // Inherited from QGraphicsItem
86 QRectF boundingRect() const noexcept override { return mBoundingRect; }
87 QPainterPath shape() const noexcept override { return mShape; }
88
89 // Operator Overloadings
91
92private: // Methods
93 QVariant itemChange(GraphicsItemChange change,
94 const QVariant& value) noexcept override;
95 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
96 QWidget* widget = 0) noexcept override;
97 void imageEdited(const Image& image, Image::Event event) noexcept;
98 void updatePixmap() noexcept;
99 void updateBoundingRectAndShape() noexcept;
100
101private: // Data
103 std::shared_ptr<Image> mImage;
105 std::shared_ptr<const GraphicsLayer> mBordersLayer;
107
108 // Cached attributes
109 QPixmap mPixmap;
112 QPainterPath mShape;
115
116 // Slots
117 Image::OnEditedSlot mOnEditedSlot;
118};
119
120/*******************************************************************************
121 * End of File
122 ******************************************************************************/
123
124} // namespace editor
125} // namespace librepcb
126
127#endif
The Image class.
Definition image.h:49
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
Helper class to access a subdirectory of TransactionalFileSystem.
Definition transactionaldirectory.h:51
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition graphicslayer.h:53
The GraphicsLayerList class.
Definition graphicslayerlist.h:48
The ImageGraphicsItem class is the graphical representation of a librepcb::Image.
Definition imagegraphicsitem.h:52
ImageGraphicsItem & operator=(const ImageGraphicsItem &rhs)=delete
void updatePixmap() noexcept
Definition imagegraphicsitem.cpp:200
bool isResizeHandleAtPosition(const Point &pos) const noexcept
Definition imagegraphicsitem.cpp:89
QRectF boundingRect() const noexcept override
Definition imagegraphicsitem.h:86
std::shared_ptr< Image > mImage
Definition imagegraphicsitem.h:103
QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition imagegraphicsitem.cpp:108
const std::shared_ptr< Image > & getObj() noexcept
Definition imagegraphicsitem.h:64
QPainterPath mShape
Definition imagegraphicsitem.h:112
qreal mVertexHandleRadiusPx
Definition imagegraphicsitem.h:113
QPainterPath shape() const noexcept override
Definition imagegraphicsitem.h:87
Image::OnEditedSlot mOnEditedSlot
Definition imagegraphicsitem.h:117
QRectF mBoundingRect
Definition imagegraphicsitem.h:111
const TransactionalDirectory & mDir
Definition imagegraphicsitem.h:102
bool mInvalidImage
Definition imagegraphicsitem.h:114
ImageGraphicsItem(const ImageGraphicsItem &other)=delete
QPixmap mPixmap
Definition imagegraphicsitem.h:109
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexcept override
Definition imagegraphicsitem.cpp:116
std::shared_ptr< const GraphicsLayer > mBordersLayer
Definition imagegraphicsitem.h:105
QRectF mImageRectPx
Definition imagegraphicsitem.h:110
std::unique_ptr< OriginCrossGraphicsItem > mOriginCrossGraphicsItem
Definition imagegraphicsitem.h:106
void imageEdited(const Image &image, Image::Event event) noexcept
Definition imagegraphicsitem.cpp:173
bool mEditable
Definition imagegraphicsitem.h:104
void setEditable(bool editable) noexcept
Definition imagegraphicsitem.cpp:99
void updateBoundingRectAndShape() noexcept
Definition imagegraphicsitem.cpp:215
The OriginCrossGraphicsItem class.
Definition origincrossgraphicsitem.h:50
Definition occmodel.cpp:77
Definition uuid.h:186