LibrePCB Developers Documentation
Loading...
Searching...
No Matches
boardeditorstate_select.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_BOARDEDITORSTATE_SELECT_H
21#define LIBREPCB_EDITOR_BOARDEDITORSTATE_SELECT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "boardeditorstate.h"
27
29
30#include <QtCore>
31
32#include <memory>
33#include <optional>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40class Angle;
41class BI_Base;
42class BI_Device;
43class BI_Hole;
44class BI_NetLine;
45class BI_NetSegment;
46class BI_Plane;
47class BI_Polygon;
48class BI_StrokeText;
49class BI_Via;
50class BI_Zone;
51class Point;
52
53namespace editor {
54
55class BoardClipboardData;
56class CmdBoardPlaneEdit;
57class CmdBoardPolygonEdit;
58class CmdBoardZoneEdit;
59class CmdDragSelectedBoardItems;
60class UndoCommandGroup;
61
62/*******************************************************************************
63 * Class BoardEditorState_Select
64 ******************************************************************************/
65
70 Q_OBJECT
71
73 QString name;
75 };
76
77public:
78 // Constructors / Destructor
81 explicit BoardEditorState_Select(const Context& context) noexcept;
82 virtual ~BoardEditorState_Select() noexcept;
83
84 // General Methods
85 virtual bool entry() noexcept override;
86 virtual bool exit() noexcept override;
87
88 // Event Handlers
89 virtual bool processImportDxf() noexcept override;
90 virtual bool processSelectAll() noexcept override;
91 virtual bool processCut() noexcept override;
92 virtual bool processCopy() noexcept override;
93 virtual bool processPaste() noexcept override;
94 virtual bool processMove(const Point& delta) noexcept override;
95 virtual bool processRotate(const Angle& rotation) noexcept override;
96 virtual bool processFlip(Qt::Orientation orientation) noexcept override;
97 virtual bool processSnapToGrid() noexcept override;
98 virtual bool processSetLocked(bool locked) noexcept override;
99 virtual bool processChangeLineWidth(int step) noexcept override;
100 virtual bool processResetAllTexts() noexcept override;
101 virtual bool processRemove() noexcept override;
102 virtual bool processEditProperties() noexcept override;
103 virtual bool processAbortCommand() noexcept override;
105 QGraphicsSceneMouseEvent& e) noexcept override;
107 QGraphicsSceneMouseEvent& e) noexcept override;
109 QGraphicsSceneMouseEvent& e) noexcept override;
111 QGraphicsSceneMouseEvent& e) noexcept override;
113 QGraphicsSceneMouseEvent& e) noexcept override;
114 virtual bool processSwitchToBoard(int index) noexcept override;
115
116 // Operator Overloadings
118 delete;
119
120private: // Methods
122 const Point& startPos) noexcept;
123 bool moveSelectedItems(const Point& delta) noexcept;
124 bool rotateSelectedItems(const Angle& angle) noexcept;
125 bool flipSelectedItems(Qt::Orientation orientation) noexcept;
126 bool snapSelectedItemsToGrid() noexcept;
127 bool lockSelectedItems(bool locked) noexcept;
128 bool changeWidthOfSelectedItems(int step) noexcept;
129 bool resetAllTextsOfSelectedItems() noexcept;
130 bool removeSelectedItems() noexcept;
131 void removePolygonVertices(BI_Polygon& polygon,
132 const QVector<int> vertices) noexcept;
133 void removePlaneVertices(BI_Plane& plane,
134 const QVector<int> vertices) noexcept;
135 void removeZoneVertices(BI_Zone& zone, const QVector<int> vertices) noexcept;
136 void startAddingPolygonVertex(BI_Polygon& polygon, int vertex,
137 const Point& pos) noexcept;
138 void startAddingPlaneVertex(BI_Plane& plane, int vertex,
139 const Point& pos) noexcept;
140 void startAddingZoneVertex(BI_Zone& zone, int vertex,
141 const Point& pos) noexcept;
142 bool copySelectedItemsToClipboard() noexcept;
143 bool startPaste(BoardGraphicsScene& scene,
144 std::unique_ptr<BoardClipboardData> data,
145 const std::optional<Point>& fixedPosition);
146 bool abortCommand(bool showErrMsgBox) noexcept;
147 bool findPolygonVerticesAtPosition(const Point& pos) noexcept;
148 bool findPlaneVerticesAtPosition(const Point& pos) noexcept;
149 bool findZoneVerticesAtPosition(const Point& pos) noexcept;
150
159 bool measureSelectedItems(const BI_NetLine& netline) noexcept;
160
176 bool directionBackwards,
177 const BI_NetLine& netline,
178 QSet<Uuid>& visitedNetLines,
179 UnsignedLength& totalLength);
180
181 bool openPropertiesDialog(std::shared_ptr<QGraphicsItem> item);
182 void openDevicePropertiesDialog(BI_Device& device) noexcept;
183 void openViaPropertiesDialog(BI_Via& via) noexcept;
184 void openPlanePropertiesDialog(BI_Plane& plane) noexcept;
185 void openZonePropertiesDialog(BI_Zone& zone) noexcept;
186 void openPolygonPropertiesDialog(BI_Polygon& polygon) noexcept;
188 void openHolePropertiesDialog(BI_Hole& hole) noexcept;
190 const ComponentInstance& cmpInst) const noexcept;
191
192private: // Data
195
198
205
212
219};
220
221/*******************************************************************************
222 * End of File
223 ******************************************************************************/
224
225} // namespace editor
226} // namespace librepcb
227
228#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The BI_Device class.
Definition bi_device.h:57
The BI_Hole class.
Definition bi_hole.h:46
The BI_NetLine class.
Definition bi_netline.h:71
The BI_Plane class.
Definition bi_plane.h:52
The BI_Polygon class.
Definition bi_polygon.h:46
The BI_StrokeText class.
Definition bi_stroketext.h:49
The BI_Via class.
Definition bi_via.h:44
The BI_Zone class.
Definition bi_zone.h:46
The ComponentInstance class.
Definition componentinstance.h:54
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The BoardClipboardData class.
Definition boardclipboarddata.h:64
The "select" state/tool of the board editor (default state)
Definition boardeditorstate_select.h:69
virtual bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_select.cpp:481
std::unique_ptr< CmdDragSelectedBoardItems > mSelectedItemsDragCommand
When dragging items, this undo command will be active.
Definition boardeditorstate_select.h:197
void openPlanePropertiesDialog(BI_Plane &plane) noexcept
Definition boardeditorstate_select.cpp:1839
bool startPaste(BoardGraphicsScene &scene, std::unique_ptr< BoardClipboardData > data, const std::optional< Point > &fixedPosition)
Definition boardeditorstate_select.cpp:1576
bool startMovingSelectedItems(BoardGraphicsScene &scene, const Point &startPos) noexcept
Definition boardeditorstate_select.cpp:1217
virtual bool processEditProperties() noexcept override
Definition boardeditorstate_select.cpp:423
QVector< int > mSelectedPlaneVertices
The plane vertex indices selected for editing (empty if none)
Definition boardeditorstate_select.h:209
virtual bool processGraphicsSceneLeftMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_select.cpp:627
std::unique_ptr< CmdBoardPolygonEdit > mCmdPolygonEdit
The polygon edit command (nullptr if not editing)
Definition boardeditorstate_select.h:204
bool findPlaneVerticesAtPosition(const Point &pos) noexcept
Definition boardeditorstate_select.cpp:1671
bool copySelectedItemsToClipboard() noexcept
Definition boardeditorstate_select.cpp:1559
virtual bool processRemove() noexcept override
Definition boardeditorstate_select.cpp:412
bool rotateSelectedItems(const Angle &angle) noexcept
Definition boardeditorstate_select.cpp:1241
BoardEditorState_Select(const BoardEditorState_Select &other)=delete
virtual bool processChangeLineWidth(int step) noexcept override
Definition boardeditorstate_select.cpp:390
void measureLengthInDirection(BoardGraphicsScene &scene, bool directionBackwards, const BI_NetLine &netline, QSet< Uuid > &visitedNetLines, UnsignedLength &totalLength)
Internal helper method used by measureSelectedItems.
Definition boardeditorstate_select.cpp:1761
BI_Polygon * mSelectedPolygon
The current polygon selected for editing (nullptr if none)
Definition boardeditorstate_select.h:200
virtual bool processSwitchToBoard(int index) noexcept override
Definition boardeditorstate_select.cpp:1207
bool changeWidthOfSelectedItems(int step) noexcept
Definition boardeditorstate_select.cpp:1309
bool openPropertiesDialog(std::shared_ptr< QGraphicsItem > item)
Definition boardeditorstate_select.cpp:1797
virtual bool processAbortCommand() noexcept override
Definition boardeditorstate_select.cpp:473
void openDevicePropertiesDialog(BI_Device &device) noexcept
Definition boardeditorstate_select.cpp:1824
virtual bool processPaste() noexcept override
Definition boardeditorstate_select.cpp:277
void removePolygonVertices(BI_Polygon &polygon, const QVector< int > vertices) noexcept
Definition boardeditorstate_select.cpp:1429
void openZonePropertiesDialog(BI_Zone &zone) noexcept
Definition boardeditorstate_select.cpp:1856
void openViaPropertiesDialog(BI_Via &via) noexcept
Definition boardeditorstate_select.cpp:1832
std::unique_ptr< CmdBoardPlaneEdit > mCmdPlaneEdit
The plane edit command (nullptr if not editing)
Definition boardeditorstate_select.h:211
bool removeSelectedItems() noexcept
Definition boardeditorstate_select.cpp:1414
void startAddingPlaneVertex(BI_Plane &plane, int vertex, const Point &pos) noexcept
Definition boardeditorstate_select.cpp:1523
void openStrokeTextPropertiesDialog(BI_StrokeText &text) noexcept
Definition boardeditorstate_select.cpp:1871
BI_Plane * mSelectedPlane
The current plane selected for editing (nullptr if none)
Definition boardeditorstate_select.h:207
virtual bool processResetAllTexts() noexcept override
Definition boardeditorstate_select.cpp:401
virtual ~BoardEditorState_Select() noexcept
Definition boardeditorstate_select.cpp:120
void removePlaneVertices(BI_Plane &plane, const QVector< int > vertices) noexcept
Definition boardeditorstate_select.cpp:1457
virtual bool processRotate(const Angle &rotation) noexcept override
Definition boardeditorstate_select.cpp:345
virtual bool processSelectAll() noexcept override
Definition boardeditorstate_select.cpp:236
bool findZoneVerticesAtPosition(const Point &pos) noexcept
Definition boardeditorstate_select.cpp:1692
virtual bool processImportDxf() noexcept override
Definition boardeditorstate_select.cpp:153
bool abortCommand(bool showErrMsgBox) noexcept
Definition boardeditorstate_select.cpp:1614
bool mIsUndoCmdActive
An undo command will be active while dragging pasted items.
Definition boardeditorstate_select.h:194
BI_Zone * mSelectedZone
The current zone selected for editing (nullptr if none)
Definition boardeditorstate_select.h:214
void openPolygonPropertiesDialog(BI_Polygon &polygon) noexcept
Definition boardeditorstate_select.cpp:1863
void startAddingZoneVertex(BI_Zone &zone, int vertex, const Point &pos) noexcept
Definition boardeditorstate_select.cpp:1541
QList< DeviceMenuItem > getDeviceMenuItems(const ComponentInstance &cmpInst) const noexcept
Definition boardeditorstate_select.cpp:1887
bool findPolygonVerticesAtPosition(const Point &pos) noexcept
Definition boardeditorstate_select.cpp:1649
virtual bool processCut() noexcept override
Definition boardeditorstate_select.cpp:250
bool resetAllTextsOfSelectedItems() noexcept
Definition boardeditorstate_select.cpp:1398
bool moveSelectedItems(const Point &delta) noexcept
Definition boardeditorstate_select.cpp:1225
QVector< int > mSelectedZoneVertices
The zone vertex indices selected for editing (empty if none)
Definition boardeditorstate_select.h:216
virtual bool processSetLocked(bool locked) noexcept override
Definition boardeditorstate_select.cpp:379
virtual bool exit() noexcept override
Definition boardeditorstate_select.cpp:136
std::unique_ptr< CmdBoardZoneEdit > mCmdZoneEdit
The zone edit command (nullptr if not editing)
Definition boardeditorstate_select.h:218
QVector< int > mSelectedPolygonVertices
The polygon vertex indices selected for editing (empty if none)
Definition boardeditorstate_select.h:202
virtual bool processSnapToGrid() noexcept override
Definition boardeditorstate_select.cpp:368
bool lockSelectedItems(bool locked) noexcept
Definition boardeditorstate_select.cpp:1293
virtual bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_select.cpp:706
void removeZoneVertices(BI_Zone &zone, const QVector< int > vertices) noexcept
Definition boardeditorstate_select.cpp:1483
virtual bool processFlip(Qt::Orientation orientation) noexcept override
Definition boardeditorstate_select.cpp:356
void openHolePropertiesDialog(BI_Hole &hole) noexcept
Definition boardeditorstate_select.cpp:1879
bool flipSelectedItems(Qt::Orientation orientation) noexcept
Definition boardeditorstate_select.cpp:1261
void startAddingPolygonVertex(BI_Polygon &polygon, int vertex, const Point &pos) noexcept
Definition boardeditorstate_select.cpp:1505
bool snapSelectedItemsToGrid() noexcept
Definition boardeditorstate_select.cpp:1277
virtual bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_select.cpp:537
virtual bool processMove(const Point &delta) noexcept override
Definition boardeditorstate_select.cpp:334
virtual bool processCopy() noexcept override
Definition boardeditorstate_select.cpp:265
virtual bool entry() noexcept override
Definition boardeditorstate_select.cpp:127
bool measureSelectedItems(const BI_NetLine &netline) noexcept
Measure the length of the selected items.
Definition boardeditorstate_select.cpp:1713
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_select.cpp:680
The board editor state base class.
Definition boardeditorstate.h:59
The BoardGraphicsScene class.
Definition boardgraphicsscene.h:77
The CmdBoardPlaneEdit class.
Definition cmdboardplaneedit.h:50
The CmdBoardPolygonEdit class.
Definition cmdboardpolygonedit.h:49
The CmdBoardZoneEdit class.
Definition cmdboardzoneedit.h:49
The CmdDragSelectedBoardItems class.
Definition cmddragselectedboarditems.h:58
Definition occmodel.cpp:76
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
Definition uuid.h:186
FSM Context.
Definition boardeditorfsm.h:88
Definition boardeditorstate_select.h:72
Uuid uuid
Definition boardeditorstate_select.h:74
QString name
Definition boardeditorstate_select.h:73