LibrePCB Developers Documentation
Loading...
Searching...
No Matches
symboleditorstate_addimage.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_SYMBOLEDITORSTATE_ADDIMAGE_H
21#define LIBREPCB_EDITOR_SYMBOLEDITORSTATE_ADDIMAGE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "symboleditorstate.h"
27
29
30#include <QtCore>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38namespace editor {
39
40class CmdImageEdit;
41class ImageGraphicsItem;
42
43/*******************************************************************************
44 * Class SymbolEditorState_AddImage
45 ******************************************************************************/
46
51 Q_OBJECT
52
53public:
54 // Constructors / Destructor
57 explicit SymbolEditorState_AddImage(const Context& context) noexcept;
59
60 // General Methods
61 bool entry() noexcept override;
62 bool exit() noexcept override;
63
64 // Event Handlers
66 const GraphicsSceneMouseEvent& e) noexcept override;
68 const GraphicsSceneMouseEvent& e) noexcept override;
70 const GraphicsSceneMouseEvent& e) noexcept override;
71 bool processRotate(const Angle& rotation) noexcept override;
72 bool processAddImage(const QByteArray& data, const QString& format,
73 const QString& basename) noexcept override;
74
75 // Operator Overloadings
77 delete;
78
79private: // Methods
80 bool start(const Point& pos, QByteArray data, QString format,
81 QString basename) noexcept;
82 void updateSize(const Point& pos) noexcept;
83 bool finish(const Point& pos) noexcept;
84 bool abort(bool showErrMsgBox) noexcept;
85
86private:
87 enum class State { Positioning, Resizing };
88
89 // State
92
93 // Current tool settings
95
96 // Information about the current image to place
97 std::unique_ptr<CmdImageEdit> mCurrentEditCmd;
98 std::shared_ptr<Image> mCurrentImage;
100 std::shared_ptr<ImageGraphicsItem> mCurrentGraphicsItem;
101};
102
103/*******************************************************************************
104 * End of File
105 ******************************************************************************/
106
107} // namespace editor
108} // namespace librepcb
109
110#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
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
The SymbolEditorState_AddImage class.
Definition symboleditorstate_addimage.h:50
bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_addimage.cpp:96
bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_addimage.cpp:134
bool finish(const Point &pos) noexcept
Definition symboleditorstate_addimage.cpp:247
State mState
Definition symboleditorstate_addimage.h:90
bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_addimage.cpp:114
State
Definition symboleditorstate_addimage.h:87
std::shared_ptr< Image > mCurrentImage
Definition symboleditorstate_addimage.h:98
Image mCurrentProperties
Definition symboleditorstate_addimage.h:94
bool mUndoCmdActive
Definition symboleditorstate_addimage.h:91
bool processRotate(const Angle &rotation) noexcept override
Definition symboleditorstate_addimage.cpp:140
std::unique_ptr< CmdImageEdit > mCurrentEditCmd
Definition symboleditorstate_addimage.h:97
void updateSize(const Point &pos) noexcept
Definition symboleditorstate_addimage.cpp:235
bool abort(bool showErrMsgBox) noexcept
Definition symboleditorstate_addimage.cpp:271
bool exit() noexcept override
Definition symboleditorstate_addimage.cpp:81
~SymbolEditorState_AddImage() noexcept
Definition symboleditorstate_addimage.cpp:64
SymbolEditorState_AddImage(const SymbolEditorState_AddImage &other)=delete
std::shared_ptr< ImageGraphicsItem > mCurrentGraphicsItem
Definition symboleditorstate_addimage.h:100
qreal mCurrentImageAspectRatio
Definition symboleditorstate_addimage.h:99
bool processAddImage(const QByteArray &data, const QString &format, const QString &basename) noexcept override
Definition symboleditorstate_addimage.cpp:150
bool entry() noexcept override
Definition symboleditorstate_addimage.cpp:72
bool start(const Point &pos, QByteArray data, QString format, QString basename) noexcept
Definition symboleditorstate_addimage.cpp:162
The SymbolEditorState class is the base class of all symbol editor FSM states.
Definition symboleditorstate.h:56
Definition occmodel.cpp:77
Definition graphicsscene.h:45
Definition symboleditorfsm.h:79