LibrePCB Developers Documentation
cmdcircleedit.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_CMDCIRCLEEDIT_H
21 #define LIBREPCB_EDITOR_CMDCIRCLEEDIT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../undocommand.h"
27 #include "cmdlistelementinsert.h"
28 #include "cmdlistelementremove.h"
29 #include "cmdlistelementsswap.h"
30 
32 
33 #include <QtCore>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 
40 class Layer;
41 
42 namespace editor {
43 
44 /*******************************************************************************
45  * Class CmdCircleEdit
46  ******************************************************************************/
47 
51 class CmdCircleEdit final : public UndoCommand {
52 public:
53  // Constructors / Destructor
54  CmdCircleEdit() = delete;
55  CmdCircleEdit(const CmdCircleEdit& other) = delete;
56  explicit CmdCircleEdit(Circle& circle) noexcept;
57  ~CmdCircleEdit() noexcept;
58 
59  // Setters
60  void setLayer(const Layer& layer, bool immediate) noexcept;
61  void setLineWidth(const UnsignedLength& width, bool immediate) noexcept;
62  void setIsFilled(bool filled, bool immediate) noexcept;
63  void setIsGrabArea(bool grabArea, bool immediate) noexcept;
64  void setDiameter(const PositiveLength& dia, bool immediate) noexcept;
65  void setCenter(const Point& pos, bool immediate) noexcept;
66  void translate(const Point& deltaPos, bool immediate) noexcept;
67  void snapToGrid(const PositiveLength& gridInterval, bool immediate) noexcept;
68  void rotate(const Angle& angle, const Point& center, bool immediate) noexcept;
69  void mirrorGeometry(Qt::Orientation orientation, const Point& center,
70  bool immediate) noexcept;
71  void mirrorLayer(bool immediate) noexcept;
72 
73  // Operator Overloadings
74  CmdCircleEdit& operator=(const CmdCircleEdit& rhs) = delete;
75 
76 private:
77  // Private Methods
78 
80  bool performExecute() override;
81 
83  void performUndo() override;
84 
86  void performRedo() override;
87 
88  // Private Member Variables
89 
90  // Attributes from the constructor
92 
93  // General Attributes
94  const Layer* mOldLayer;
95  const Layer* mNewLayer;
106 };
107 
108 /*******************************************************************************
109  * Undo Commands
110  ******************************************************************************/
111 
112 using CmdCircleInsert =
114 using CmdCircleRemove =
116 using CmdCirclesSwap =
118 
119 /*******************************************************************************
120  * End of File
121  ******************************************************************************/
122 
123 } // namespace editor
124 } // namespace librepcb
125 
126 #endif
UnsignedLength mNewLineWidth
Definition: cmdcircleedit.h:97
bool mOldIsGrabArea
Definition: cmdcircleedit.h:100
void mirrorLayer(bool immediate) noexcept
Definition: cmdcircleedit.cpp:134
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:46
void setIsGrabArea(bool grabArea, bool immediate) noexcept
Definition: cmdcircleedit.cpp:85
Definition: occmodel.cpp:77
The Layer class provides all supported geometry layers.
Definition: layer.h:40
const Layer * mNewLayer
Definition: cmdcircleedit.h:95
void mirrorGeometry(Qt::Orientation orientation, const Point &center, bool immediate) noexcept
Definition: cmdcircleedit.cpp:124
void setIsFilled(bool filled, bool immediate) noexcept
Definition: cmdcircleedit.cpp:79
void setLayer(const Layer &layer, bool immediate) noexcept
Definition: cmdcircleedit.cpp:66
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
PositiveLength mNewDiameter
Definition: cmdcircleedit.h:103
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
Circle & mCircle
Definition: cmdcircleedit.h:91
bool mNewIsFilled
Definition: cmdcircleedit.h:99
The Circle class.
Definition: circle.h:46
Point mOldCenter
Definition: cmdcircleedit.h:104
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:46
void performRedo() override
Redo the command.
Definition: cmdcircleedit.cpp:163
Point mNewCenter
Definition: cmdcircleedit.h:105
The CmdCircleEdit class.
Definition: cmdcircleedit.h:51
bool mOldIsFilled
Definition: cmdcircleedit.h:98
PositiveLength mOldDiameter
Definition: cmdcircleedit.h:102
void performUndo() override
Undo the command.
Definition: cmdcircleedit.cpp:154
void snapToGrid(const PositiveLength &gridInterval, bool immediate) noexcept
Definition: cmdcircleedit.cpp:110
void setDiameter(const PositiveLength &dia, bool immediate) noexcept
Definition: cmdcircleedit.cpp:91
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
UnsignedLength mOldLineWidth
Definition: cmdcircleedit.h:96
bool performExecute() override
Execute the command the first time.
Definition: cmdcircleedit.cpp:142
void setCenter(const Point &pos, bool immediate) noexcept
Definition: cmdcircleedit.cpp:98
CmdCircleEdit & operator=(const CmdCircleEdit &rhs)=delete
void setLineWidth(const UnsignedLength &width, bool immediate) noexcept
Definition: cmdcircleedit.cpp:72
const Layer * mOldLayer
Definition: cmdcircleedit.h:94
~CmdCircleEdit() noexcept
Definition: cmdcircleedit.cpp:56
void translate(const Point &deltaPos, bool immediate) noexcept
Definition: cmdcircleedit.cpp:104
bool mNewIsGrabArea
Definition: cmdcircleedit.h:101
void rotate(const Angle &angle, const Point &center, bool immediate) noexcept
Definition: cmdcircleedit.cpp:115
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696