LibrePCB Developers Documentation
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/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class Angle;
39class Polygon;
40class SI_NetLabel;
41class SI_Polygon;
42class SI_Symbol;
43class SI_Text;
44class Schematic;
45class Text;
46
47namespace editor {
48
49class CmdDragSelectedSchematicItems;
50class CmdPolygonEdit;
51
52/*******************************************************************************
53 * Class SchematicEditorState_Select
54 ******************************************************************************/
55
60 Q_OBJECT
61
62public:
63 // Constructors / Destructor
66 delete;
67 explicit SchematicEditorState_Select(const Context& context) noexcept;
68 virtual ~SchematicEditorState_Select() noexcept;
69
70 // General Methods
71 virtual bool entry() noexcept override;
72 virtual bool exit() noexcept override;
73
74 // Event Handlers
75 virtual bool processSelectAll() noexcept override;
76 virtual bool processCut() noexcept override;
77 virtual bool processCopy() noexcept override;
78 virtual bool processPaste() noexcept override;
79 virtual bool processMove(const Point& delta) noexcept override;
80 virtual bool processRotate(const Angle& rotation) noexcept override;
81 virtual bool processMirror(Qt::Orientation orientation) noexcept override;
82 virtual bool processResetAllTexts() noexcept override;
83 virtual bool processRemove() noexcept override;
84 virtual bool processEditProperties() noexcept override;
85 virtual bool processAbortCommand() noexcept override;
87 QGraphicsSceneMouseEvent& e) noexcept override;
89 QGraphicsSceneMouseEvent& e) noexcept override;
91 QGraphicsSceneMouseEvent& e) noexcept override;
93 QGraphicsSceneMouseEvent& e) noexcept override;
95 QGraphicsSceneMouseEvent& e) noexcept override;
96 virtual bool processSwitchToSchematicPage(int index) noexcept override;
97
98 // Operator Overloadings
100 const SchematicEditorState_Select& rhs) = delete;
101
102private: // Methods
104 const Point& startPos) noexcept;
105 bool moveSelectedItems(const Point& delta) noexcept;
106 bool rotateSelectedItems(const Angle& angle) noexcept;
107 bool mirrorSelectedItems(Qt::Orientation orientation) noexcept;
108 bool resetAllTextsOfSelectedItems() noexcept;
109 bool removeSelectedItems() noexcept;
110 void removePolygonVertices(Polygon& polygon,
111 const QVector<int> vertices) noexcept;
112 void startAddingPolygonVertex(SI_Polygon& polygon, int vertex,
113 const Point& pos) noexcept;
114 bool copySelectedItemsToClipboard() noexcept;
115 bool pasteFromClipboard() noexcept;
116 bool findPolygonVerticesAtPosition(const Point& pos) noexcept;
117 bool openPropertiesDialog(std::shared_ptr<QGraphicsItem> item) noexcept;
118 void openSymbolPropertiesDialog(SI_Symbol& symbol) noexcept;
119 void openNetLabelPropertiesDialog(SI_NetLabel& netlabel) noexcept;
120 void openPolygonPropertiesDialog(Polygon& polygon) noexcept;
121 void openTextPropertiesDialog(Text& text) noexcept;
122
123private: // Data
125 enum class SubState {
126 IDLE,
127 SELECTING,
128 MOVING,
129 MOVING_POLYGON_VERTICES,
130 PASTING,
131 };
132
135 QScopedPointer<CmdDragSelectedSchematicItems> mSelectedItemsDragCommand;
136
142 QScopedPointer<CmdPolygonEdit> mCmdPolygonEdit;
143};
144
145/*******************************************************************************
146 * End of File
147 ******************************************************************************/
148
149} // namespace editor
150} // namespace librepcb
151
152#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
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:59
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
QScopedPointer< CmdDragSelectedSchematicItems > mSelectedItemsDragCommand
Definition: schematiceditorstate_select.h:135
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:138
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:140
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:134
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:125
virtual bool processMove(const Point &delta) noexcept override
Definition: schematiceditorstate_select.cpp:155
SubState mSubState
the current substate
Definition: schematiceditorstate_select.h:133
QScopedPointer< CmdPolygonEdit > mCmdPolygonEdit
The polygon edit command (nullptr if not editing)
Definition: schematiceditorstate_select.h:142
virtual bool processCopy() noexcept override
Definition: schematiceditorstate_select.cpp:135
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:77
FSM Context.
Definition: schematiceditorfsm.h:81