LibrePCB Developers Documentation
Loading...
Searching...
No Matches
backgroundimagesetupdialog.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_BACKGROUNDIMAGESETUPDIALOG_H
21#define LIBREPCB_EDITOR_BACKGROUNDIMAGESETUPDIALOG_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../widgets/if_graphicsvieweventhandler.h"
27
30
31#include <QtCore>
32#include <QtWidgets>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38namespace editor {
39
40namespace Ui {
42}
43
44/*******************************************************************************
45 * Class BackgroundImageSetupDialog
46 ******************************************************************************/
47
51class BackgroundImageSetupDialog final : public QDialog,
53 Q_OBJECT
54
55public:
56 // Types
57 enum class State {
58 Idle,
59 Crop,
60 Rotate,
63 };
64
65 // Constructors / Destructor
68 explicit BackgroundImageSetupDialog(const QString& settingsPrefix,
69 QWidget* parent = nullptr) noexcept;
71
72 // General Methods
73 const QImage& getImage() const noexcept { return mImage; }
74 const Angle& getRotation() const noexcept { return mRotation; }
75 const QList<std::pair<QPointF, Point>>& getReferences() const noexcept {
76 return mReferences;
77 }
78 void setData(const QImage& image, const Angle& rotation,
79 const QList<std::pair<QPointF, Point>>& references) noexcept;
80
81 // Operator Overloadings
83 delete;
84
85private:
86 void keyPressEvent(QKeyEvent* event) noexcept override;
88 const GraphicsSceneMouseEvent& e) noexcept override;
90 const GraphicsSceneMouseEvent& e) noexcept override;
92 const GraphicsSceneMouseEvent& e) noexcept override;
93 void startScreenshot() noexcept;
94 void screenshotCountdownTick() noexcept;
95 void takeScreenshot() noexcept;
96 void pasteFromClipboard() noexcept;
97 void loadFromFile() noexcept;
98 void updateUi(QString msg = QString()) noexcept;
99 void fitImageInView() noexcept;
100 void updateAnchors() noexcept;
101 void updateStatusMsg() noexcept;
102 static QImage cropImage(const QImage& img, const QPainterPath& p) noexcept;
103
104 QScopedPointer<Ui::BackgroundImageSetupDialog> mUi;
105 const QString mSettingsPrefix;
106
107 // State
109 QImage mImage;
111 QList<std::pair<QPointF, Point>> mLoadedReferences;
112 QList<std::pair<QPointF, Point>> mReferences;
113 QPointer<QScreen> mScreen;
115
116 // Widgets & graphics items
117 QScopedPointer<QWidget> mRotateWidget;
118 QScopedPointer<QGraphicsPixmapItem> mImageGraphicsItem;
119 std::shared_ptr<QGraphicsPathItem> mCursorGraphicsItem;
120 QScopedPointer<QGraphicsPathItem> mCropGraphicsItem;
121
122 // Always in sync with #mReferences
123 QList<std::shared_ptr<QGraphicsPathItem>> mReferenceGraphicsItems;
124 QList<std::shared_ptr<QGraphicsLineItem>> mReferenceLineGraphicsItems;
125 QList<std::shared_ptr<QWidget>> mReferenceWidgets;
126};
127
128/*******************************************************************************
129 * End of File
130 ******************************************************************************/
131
132} // namespace editor
133} // namespace librepcb
134
135#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
Dialog (GUI) to configure the background image of a 2D view.
Definition backgroundimagesetupdialog.h:52
void screenshotCountdownTick() noexcept
Definition backgroundimagesetupdialog.cpp:345
int mCountdownSecs
Definition backgroundimagesetupdialog.h:114
bool graphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition backgroundimagesetupdialog.cpp:263
const Angle & getRotation() const noexcept
Definition backgroundimagesetupdialog.h:74
QScopedPointer< QGraphicsPixmapItem > mImageGraphicsItem
Definition backgroundimagesetupdialog.h:118
const QImage & getImage() const noexcept
Definition backgroundimagesetupdialog.h:73
std::shared_ptr< QGraphicsPathItem > mCursorGraphicsItem
Definition backgroundimagesetupdialog.h:119
QList< std::shared_ptr< QGraphicsPathItem > > mReferenceGraphicsItems
Definition backgroundimagesetupdialog.h:123
void updateStatusMsg() noexcept
Definition backgroundimagesetupdialog.cpp:532
State mState
Definition backgroundimagesetupdialog.h:108
bool graphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition backgroundimagesetupdialog.cpp:276
QList< std::pair< QPointF, Point > > mLoadedReferences
Definition backgroundimagesetupdialog.h:111
void fitImageInView() noexcept
Definition backgroundimagesetupdialog.cpp:512
QScopedPointer< QGraphicsPathItem > mCropGraphicsItem
Definition backgroundimagesetupdialog.h:120
void setData(const QImage &image, const Angle &rotation, const QList< std::pair< QPointF, Point > > &references) noexcept
Definition backgroundimagesetupdialog.cpp:232
QList< std::pair< QPointF, Point > > mReferences
Definition backgroundimagesetupdialog.h:112
State
Definition backgroundimagesetupdialog.h:57
void updateUi(QString msg=QString()) noexcept
Definition backgroundimagesetupdialog.cpp:415
const QString mSettingsPrefix
Definition backgroundimagesetupdialog.h:105
static QImage cropImage(const QImage &img, const QPainterPath &p) noexcept
Definition backgroundimagesetupdialog.cpp:598
Angle mRotation
Definition backgroundimagesetupdialog.h:110
void takeScreenshot() noexcept
Definition backgroundimagesetupdialog.cpp:359
QList< std::shared_ptr< QGraphicsLineItem > > mReferenceLineGraphicsItems
Definition backgroundimagesetupdialog.h:124
QPointer< QScreen > mScreen
Definition backgroundimagesetupdialog.h:113
void startScreenshot() noexcept
Definition backgroundimagesetupdialog.cpp:322
BackgroundImageSetupDialog(const BackgroundImageSetupDialog &other)=delete
void loadFromFile() noexcept
Definition backgroundimagesetupdialog.cpp:391
void keyPressEvent(QKeyEvent *event) noexcept override
Definition backgroundimagesetupdialog.cpp:247
const QList< std::pair< QPointF, Point > > & getReferences() const noexcept
Definition backgroundimagesetupdialog.h:75
void pasteFromClipboard() noexcept
Definition backgroundimagesetupdialog.cpp:378
QImage mImage
Definition backgroundimagesetupdialog.h:109
QList< std::shared_ptr< QWidget > > mReferenceWidgets
Definition backgroundimagesetupdialog.h:125
void updateAnchors() noexcept
Definition backgroundimagesetupdialog.cpp:521
BackgroundImageSetupDialog & operator=(const BackgroundImageSetupDialog &rhs)=delete
bool graphicsSceneLeftMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition backgroundimagesetupdialog.cpp:304
QScopedPointer< Ui::BackgroundImageSetupDialog > mUi
Definition backgroundimagesetupdialog.h:104
QScopedPointer< QWidget > mRotateWidget
Definition backgroundimagesetupdialog.h:117
The IF_GraphicsViewEventHandler class.
Definition if_graphicsvieweventhandler.h:45
Definition occmodel.cpp:77
Definition uuid.h:186
Definition graphicsscene.h:45