LibrePCB Developers Documentation
Loading...
Searching...
No Matches
schematiceditorstate_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_SCHEMATICEDITORSTATE_SELECT_H
21#define LIBREPCB_EDITOR_SCHEMATICEDITORSTATE_SELECT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
29
30#include <QtCore>
31#include <QtWidgets>
32
33#include <memory>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40class Angle;
41class Polygon;
42class SI_NetLabel;
43class SI_Polygon;
44class SI_Symbol;
45class SI_Text;
46class Schematic;
47class Text;
48
49namespace editor {
50
51class CmdDragSelectedSchematicItems;
52class CmdPolygonEdit;
53
54/*******************************************************************************
55 * Class SchematicEditorState_Select
56 ******************************************************************************/
57
62 Q_OBJECT
63
64public:
65 // Constructors / Destructor
68 delete;
69 explicit SchematicEditorState_Select(const Context& context) noexcept;
70 virtual ~SchematicEditorState_Select() noexcept;
71
72 // General Methods
73 virtual bool entry() noexcept override;
74 virtual bool exit() noexcept override;
75
76 // Event Handlers
77 virtual bool processSelectAll() noexcept override;
78 virtual bool processCut() noexcept override;
79 virtual bool processCopy() noexcept override;
80 virtual bool processPaste() noexcept override;
81 virtual bool processMove(const Point& delta) noexcept override;
82 virtual bool processRotate(const Angle& rotation) noexcept override;
83 virtual bool processMirror(Qt::Orientation orientation) noexcept override;
84 virtual bool processResetAllTexts() noexcept override;
85 virtual bool processRemove() noexcept override;
86 virtual bool processEditProperties() noexcept override;
87 virtual bool processAbortCommand() noexcept override;
89 QGraphicsSceneMouseEvent& e) noexcept override;
91 QGraphicsSceneMouseEvent& e) noexcept override;
93 QGraphicsSceneMouseEvent& e) noexcept override;
95 QGraphicsSceneMouseEvent& e) noexcept override;
97 QGraphicsSceneMouseEvent& e) noexcept override;
98 virtual bool processSwitchToSchematicPage(int index) noexcept override;
99
100 // Operator Overloadings
102 const SchematicEditorState_Select& rhs) = delete;
103
104private: // Methods
106 const Point& startPos) noexcept;
107 bool moveSelectedItems(const Point& delta) noexcept;
108 bool rotateSelectedItems(const Angle& angle) noexcept;
109 bool mirrorSelectedItems(Qt::Orientation orientation) noexcept;
110 bool resetAllTextsOfSelectedItems() noexcept;
111 bool removeSelectedItems() noexcept;
112 void removePolygonVertices(Polygon& polygon,
113 const QVector<int> vertices) noexcept;
114 void startAddingPolygonVertex(SI_Polygon& polygon, int vertex,
115 const Point& pos) noexcept;
116 bool copySelectedItemsToClipboard() noexcept;
117 bool pasteFromClipboard() noexcept;
118 bool findPolygonVerticesAtPosition(const Point& pos) noexcept;
119 bool openPropertiesDialog(std::shared_ptr<QGraphicsItem> item) noexcept;
120 void openSymbolPropertiesDialog(SI_Symbol& symbol) noexcept;
121 void openNetLabelPropertiesDialog(SI_NetLabel& netlabel) noexcept;
122 void openPolygonPropertiesDialog(Polygon& polygon) noexcept;
123 void openTextPropertiesDialog(Text& text) noexcept;
124
125private: // Data
127 enum class SubState {
128 IDLE,
129 SELECTING,
130 MOVING,
132 PASTING,
133 };
134
137 std::unique_ptr<CmdDragSelectedSchematicItems> mSelectedItemsDragCommand;
138
144 std::unique_ptr<CmdPolygonEdit> mCmdPolygonEdit;
145};
146
147/*******************************************************************************
148 * End of File
149 ******************************************************************************/
150
151} // namespace editor
152} // namespace librepcb
153
154#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
The Polygon class.
Definition polygon.h:45
The SI_NetLabel class.
Definition si_netlabel.h:49
The SI_Polygon class represents a polygon in a schematic.
Definition si_polygon.h:47
The SI_Symbol class.
Definition si_symbol.h:54
The Text class.
Definition text.h:48
The "select" state/tool of the schematic editor (default state)
Definition schematiceditorstate_select.h:61
virtual bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_select.cpp:275
virtual bool processEditProperties() noexcept override
Definition schematiceditorstate_select.cpp:208
void openTextPropertiesDialog(Text &text) noexcept
Definition schematiceditorstate_select.cpp:925
bool mirrorSelectedItems(Qt::Orientation orientation) noexcept
Definition schematiceditorstate_select.cpp:696
virtual bool processGraphicsSceneLeftMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_select.cpp:403
bool startMovingSelectedItems(SchematicGraphicsScene &scene, const Point &startPos) noexcept
Definition schematiceditorstate_select.cpp:650
bool copySelectedItemsToClipboard() noexcept
Definition schematiceditorstate_select.cpp:793
virtual bool processRemove() noexcept override
Definition schematiceditorstate_select.cpp:197
bool rotateSelectedItems(const Angle &angle) noexcept
Definition schematiceditorstate_select.cpp:675
std::unique_ptr< CmdPolygonEdit > mCmdPolygonEdit
The polygon edit command (nullptr if not editing)
Definition schematiceditorstate_select.h:144
virtual bool processAbortCommand() noexcept override
Definition schematiceditorstate_select.cpp:242
virtual bool processPaste() noexcept override
Definition schematiceditorstate_select.cpp:145
bool removeSelectedItems() noexcept
Definition schematiceditorstate_select.cpp:733
virtual bool processResetAllTexts() noexcept override
Definition schematiceditorstate_select.cpp:187
virtual bool processRotate(const Angle &rotation) noexcept override
Definition schematiceditorstate_select.cpp:165
virtual bool processSelectAll() noexcept override
Definition schematiceditorstate_select.cpp:115
SchematicEditorState_Select(const SchematicEditorState_Select &other)=delete
virtual bool processSwitchToSchematicPage(int index) noexcept override
Definition schematiceditorstate_select.cpp:640
SI_Polygon * mSelectedPolygon
The current polygon selected for editing (nullptr if none)
Definition schematiceditorstate_select.h:140
bool pasteFromClipboard() noexcept
Definition schematiceditorstate_select.cpp:810
bool findPolygonVerticesAtPosition(const Point &pos) noexcept
Definition schematiceditorstate_select.cpp:862
virtual bool processCut() noexcept override
Definition schematiceditorstate_select.cpp:125
bool resetAllTextsOfSelectedItems() noexcept
Definition schematiceditorstate_select.cpp:717
bool moveSelectedItems(const Point &delta) noexcept
Definition schematiceditorstate_select.cpp:659
virtual bool exit() noexcept override
Definition schematiceditorstate_select.cpp:89
void startAddingPolygonVertex(SI_Polygon &polygon, int vertex, const Point &pos) noexcept
Definition schematiceditorstate_select.cpp:774
void openSymbolPropertiesDialog(SI_Symbol &symbol) noexcept
Definition schematiceditorstate_select.cpp:901
QVector< int > mSelectedPolygonVertices
The polygon vertex indices selected for editing (empty if none)
Definition schematiceditorstate_select.h:142
void removePolygonVertices(Polygon &polygon, const QVector< int > vertices) noexcept
Definition schematiceditorstate_select.cpp:748
bool openPropertiesDialog(std::shared_ptr< QGraphicsItem > item) noexcept
Definition schematiceditorstate_select.cpp:882
void openNetLabelPropertiesDialog(SI_NetLabel &netlabel) noexcept
Definition schematiceditorstate_select.cpp:910
virtual bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_select.cpp:469
Point mStartPos
Definition schematiceditorstate_select.h:136
virtual bool processMirror(Qt::Orientation orientation) noexcept override
Definition schematiceditorstate_select.cpp:176
virtual ~SchematicEditorState_Select() noexcept
Definition schematiceditorstate_select.cpp:76
void openPolygonPropertiesDialog(Polygon &polygon) noexcept
Definition schematiceditorstate_select.cpp:917
virtual bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_select.cpp:316
SubState
enum for all possible substates
Definition schematiceditorstate_select.h:127
@ SELECTING
left mouse button pressed to draw selection rect
@ IDLE
left mouse button is not pressed (default state)
@ MOVING
left mouse button pressed to move items
@ MOVING_POLYGON_VERTICES
left mouts butten pressed to move vertices
virtual bool processMove(const Point &delta) noexcept override
Definition schematiceditorstate_select.cpp:155
SubState mSubState
the current substate
Definition schematiceditorstate_select.h:135
virtual bool processCopy() noexcept override
Definition schematiceditorstate_select.cpp:135
std::unique_ptr< CmdDragSelectedSchematicItems > mSelectedItemsDragCommand
Definition schematiceditorstate_select.h:137
virtual bool entry() noexcept override
Definition schematiceditorstate_select.cpp:84
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_select.cpp:444
The schematic editor state base class.
Definition schematiceditorstate.h:57
The SchematicGraphicsScene class.
Definition schematicgraphicsscene.h:67
Definition occmodel.cpp:76
Definition uuid.h:186
FSM Context.
Definition schematiceditorfsm.h:81