LibrePCB Developers Documentation
Loading...
Searching...
No Matches
schematiceditorstate_drawwire.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_DRAWWIRE_H
21#define LIBREPCB_EDITOR_SCHEMATICEDITORSTATE_DRAWWIRE_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 Circuit;
39class SI_NetLine;
40class SI_NetLineAnchor;
41class SI_NetPoint;
42class SI_SymbolPin;
43
44namespace editor {
45
46/*******************************************************************************
47 * Class SchematicEditorState_DrawWire
48 ******************************************************************************/
49
54 Q_OBJECT
55
57 enum class SubState {
58 IDLE,
60 };
61
65 enum class WireMode {
66 HV,
67 VH,
68 Deg9045,
69 Deg4590,
70 Straight,
71 };
72
73public:
74 // Constructors / Destructor
77 delete;
78 explicit SchematicEditorState_DrawWire(const Context& context) noexcept;
79 virtual ~SchematicEditorState_DrawWire() noexcept;
80
81 // General Methods
82 virtual bool entry() noexcept override;
83 virtual bool exit() noexcept override;
84
85 // Event Handlers
86 virtual bool processAbortCommand() noexcept override;
87 virtual bool processKeyPressed(const QKeyEvent& e) noexcept override;
88 virtual bool processKeyReleased(const QKeyEvent& e) noexcept override;
90 QGraphicsSceneMouseEvent& e) noexcept override;
92 QGraphicsSceneMouseEvent& e) noexcept override;
94 QGraphicsSceneMouseEvent& e) noexcept override;
96 QGraphicsSceneMouseEvent& e) noexcept override;
97 virtual bool processSwitchToSchematicPage(int index) noexcept override;
98
99 // Operator Overloadings
101 const SchematicEditorState_DrawWire& rhs) = delete;
102
103private: // Methods
104 bool startPositioning(SchematicGraphicsScene& scene, bool snap,
105 SI_NetPoint* fixedPoint = nullptr) noexcept;
106 bool addNextNetPoint(SchematicGraphicsScene& scene, bool snap) noexcept;
107 bool abortPositioning(bool showErrMsgBox) noexcept;
108 std::shared_ptr<QGraphicsItem> findItem(
109 const Point& pos,
110 const QVector<std::shared_ptr<QGraphicsItem>>& except = {}) noexcept;
111 Point updateNetpointPositions(bool snap) noexcept;
112 void wireModeChanged(WireMode mode) noexcept;
113 Point calcMiddlePointPos(const Point& p1, const Point p2,
114 WireMode mode) const noexcept;
115
116private: // Data
127
128 // Widgets for the command toolbar
129 QPointer<QActionGroup> mWireModeActionGroup;
130};
131
132/*******************************************************************************
133 * End of File
134 ******************************************************************************/
135
136} // namespace editor
137} // namespace librepcb
138
139#endif
The Circuit class represents all electrical connections in a project (drawn in the schematics)
Definition circuit.h:70
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
Definition si_netline.h:44
The SI_NetLine class.
Definition si_netline.h:65
The SI_NetPoint class.
Definition si_netpoint.h:44
The SchematicEditorState_DrawWire class.
Definition schematiceditorstate_drawwire.h:53
WireMode
All available wire modes.
Definition schematiceditorstate_drawwire.h:65
virtual bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:193
virtual ~SchematicEditorState_DrawWire() noexcept
Definition schematiceditorstate_drawwire.cpp:80
SI_NetPoint * mPositioningNetPoint2
the second netpoint to place
Definition schematiceditorstate_drawwire.h:126
Circuit & mCircuit
Definition schematiceditorstate_drawwire.h:117
WireMode mCurrentWireMode
the current wire mode
Definition schematiceditorstate_drawwire.h:119
SI_NetLine * mPositioningNetLine2
line between p1 and p2
Definition schematiceditorstate_drawwire.h:125
virtual bool processAbortCommand() noexcept override
Definition schematiceditorstate_drawwire.cpp:147
virtual bool processKeyPressed(const QKeyEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:155
SI_NetLine * mPositioningNetLine1
line between fixed point and p1
Definition schematiceditorstate_drawwire.h:123
bool addNextNetPoint(SchematicGraphicsScene &scene, bool snap) noexcept
Definition schematiceditorstate_drawwire.cpp:430
void wireModeChanged(WireMode mode) noexcept
Definition schematiceditorstate_drawwire.cpp:694
bool abortPositioning(bool showErrMsgBox) noexcept
Definition schematiceditorstate_drawwire.cpp:630
SI_NetLineAnchor * mFixedStartAnchor
the fixed anchor (start point of the line)
Definition schematiceditorstate_drawwire.h:122
virtual bool processSwitchToSchematicPage(int index) noexcept override
Definition schematiceditorstate_drawwire.cpp:273
SI_NetPoint * mPositioningNetPoint1
the first netpoint to place
Definition schematiceditorstate_drawwire.h:124
SchematicEditorState_DrawWire(const SchematicEditorState_DrawWire &other)=delete
bool startPositioning(SchematicGraphicsScene &scene, bool snap, SI_NetPoint *fixedPoint=nullptr) noexcept
Definition schematiceditorstate_drawwire.cpp:283
Point calcMiddlePointPos(const Point &p1, const Point p2, WireMode mode) const noexcept
Definition schematiceditorstate_drawwire.cpp:701
virtual bool exit() noexcept override
Definition schematiceditorstate_drawwire.cpp:130
std::shared_ptr< QGraphicsItem > findItem(const Point &pos, const QVector< std::shared_ptr< QGraphicsItem > > &except={}) noexcept
Definition schematiceditorstate_drawwire.cpp:649
virtual bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:246
QPointer< QActionGroup > mWireModeActionGroup
Definition schematiceditorstate_drawwire.h:129
virtual bool processKeyReleased(const QKeyEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:174
virtual bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:206
SubState
Internal FSM States (substates)
Definition schematiceditorstate_drawwire.h:57
@ POSITIONING_NETPOINT
in this state, an undo command is active!
SubState mSubState
the current substate
Definition schematiceditorstate_drawwire.h:118
Point mCursorPos
the current cursor position
Definition schematiceditorstate_drawwire.h:120
virtual bool entry() noexcept override
Definition schematiceditorstate_drawwire.cpp:88
Point updateNetpointPositions(bool snap) noexcept
Definition schematiceditorstate_drawwire.cpp:661
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:229
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