LibrePCB Developers Documentation
cmdsymbolpinedit.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_CMDSYMBOLPINEDIT_H
21 #define LIBREPCB_EDITOR_CMDSYMBOLPINEDIT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../cmd/cmdlistelementinsert.h"
27 #include "../../cmd/cmdlistelementremove.h"
28 #include "../../cmd/cmdlistelementsswap.h"
29 #include "../../undocommand.h"
30 
32 
33 #include <QtCore>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 namespace editor {
40 
41 /*******************************************************************************
42  * Class CmdSymbolPinEdit
43  ******************************************************************************/
44 
48 class CmdSymbolPinEdit final : public UndoCommand {
49 public:
50  // Constructors / Destructor
51  CmdSymbolPinEdit() = delete;
52  CmdSymbolPinEdit(const CmdSymbolPinEdit& other) = delete;
53  explicit CmdSymbolPinEdit(std::shared_ptr<SymbolPin> pin) noexcept;
54  ~CmdSymbolPinEdit() noexcept;
55 
56  // Setters
57  void setName(const CircuitIdentifier& name, bool immediate) noexcept;
58  void setLength(const UnsignedLength& length, bool immediate) noexcept;
59  void setNamePosition(const Point& position, bool immediate) noexcept;
60  void setNameRotation(const Angle& rotation, bool immediate) noexcept;
61  void setNameHeight(const PositiveLength& height, bool immediate) noexcept;
62  void setNameAlignment(const Alignment& align, bool immediate) noexcept;
63  void setPosition(const Point& pos, bool immediate) noexcept;
64  void translate(const Point& deltaPos, bool immediate) noexcept;
65  void snapToGrid(const PositiveLength& gridInterval, bool immediate) noexcept;
66  void setRotation(const Angle& angle, bool immediate) noexcept;
67  void rotate(const Angle& angle, const Point& center, bool immediate) noexcept;
68  void mirror(Qt::Orientation orientation, const Point& center,
69  bool immediate) noexcept;
70 
71  // Operator Overloadings
72  CmdSymbolPinEdit& operator=(const CmdSymbolPinEdit& rhs) = delete;
73 
74 private:
75  // Private Methods
76 
78  bool performExecute() override;
79 
81  void performUndo() override;
82 
84  void performRedo() override;
85 
86  // Private Member Variables
87 
88  // Attributes from the constructor
89  std::shared_ptr<SymbolPin> mPin;
90 
91  // General Attributes
108 };
109 
110 /*******************************************************************************
111  * Undo Commands
112  ******************************************************************************/
113 
114 using CmdSymbolPinInsert =
117 using CmdSymbolPinRemove =
118  CmdListElementRemove<SymbolPin, SymbolPinListNameProvider,
120 using CmdSymbolPinsSwap =
122 
123 /*******************************************************************************
124  * End of File
125  ******************************************************************************/
126 
127 } // namespace editor
128 } // namespace librepcb
129 
130 #endif
Angle mOldRotation
Definition: cmdsymbolpinedit.h:98
void setLength(const UnsignedLength &length, bool immediate) noexcept
Definition: cmdsymbolpinedit.cpp:80
Angle mNewRotation
Definition: cmdsymbolpinedit.h:99
UnsignedLength mNewLength
Definition: cmdsymbolpinedit.h:95
Point mOldPos
Definition: cmdsymbolpinedit.h:96
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:46
The Alignment class.
Definition: alignment.h:115
Angle mNewNameRotation
Definition: cmdsymbolpinedit.h:103
PositiveLength mNewNameHeight
Definition: cmdsymbolpinedit.h:105
void setNameRotation(const Angle &rotation, bool immediate) noexcept
Definition: cmdsymbolpinedit.cpp:94
Definition: occmodel.cpp:77
void setPosition(const Point &pos, bool immediate) noexcept
Definition: cmdsymbolpinedit.cpp:115
void rotate(const Angle &angle, const Point &center, bool immediate) noexcept
Definition: cmdsymbolpinedit.cpp:140
void setNameAlignment(const Alignment &align, bool immediate) noexcept
Definition: cmdsymbolpinedit.cpp:108
void setName(const CircuitIdentifier &name, bool immediate) noexcept
Definition: cmdsymbolpinedit.cpp:73
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
Definition: symbolpin.h:153
Alignment mOldNameAlignment
Definition: cmdsymbolpinedit.h:106
CircuitIdentifier mOldName
Definition: cmdsymbolpinedit.h:92
The CmdSymbolPinEdit class.
Definition: cmdsymbolpinedit.h:48
void mirror(Qt::Orientation orientation, const Point &center, bool immediate) noexcept
Definition: cmdsymbolpinedit.cpp:151
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:79
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:46
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:46
bool performExecute() override
Execute the command the first time.
Definition: cmdsymbolpinedit.cpp:170
Point mNewPos
Definition: cmdsymbolpinedit.h:97
~CmdSymbolPinEdit() noexcept
Definition: cmdsymbolpinedit.cpp:59
Angle mOldNameRotation
Definition: cmdsymbolpinedit.h:102
void setNameHeight(const PositiveLength &height, bool immediate) noexcept
Definition: cmdsymbolpinedit.cpp:101
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition: circuitidentifier.h:96
PositiveLength mOldNameHeight
Definition: cmdsymbolpinedit.h:104
void translate(const Point &deltaPos, bool immediate) noexcept
Definition: cmdsymbolpinedit.cpp:121
void setRotation(const Angle &angle, bool immediate) noexcept
Definition: cmdsymbolpinedit.cpp:133
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:46
The SymbolPin class represents one pin of a symbol.
Definition: symbolpin.h:51
Alignment mNewNameAlignment
Definition: cmdsymbolpinedit.h:107
Event
Definition: symbolpin.h:56
void performUndo() override
Undo the command.
Definition: cmdsymbolpinedit.cpp:184
void performRedo() override
Redo the command.
Definition: cmdsymbolpinedit.cpp:195
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
CmdSymbolPinEdit & operator=(const CmdSymbolPinEdit &rhs)=delete
UnsignedLength mOldLength
Definition: cmdsymbolpinedit.h:94
void snapToGrid(const PositiveLength &gridInterval, bool immediate) noexcept
Definition: cmdsymbolpinedit.cpp:128
CircuitIdentifier mNewName
Definition: cmdsymbolpinedit.h:93
void setNamePosition(const Point &position, bool immediate) noexcept
Definition: cmdsymbolpinedit.cpp:87
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696
Point mNewNamePosition
Definition: cmdsymbolpinedit.h:101
std::shared_ptr< SymbolPin > mPin
Definition: cmdsymbolpinedit.h:89
Point mOldNamePosition
Definition: cmdsymbolpinedit.h:100