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
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37class Circuit;
38class SI_BusJunction;
39class SI_NetLabel;
40class SI_NetLine;
41class SI_NetLineAnchor;
42class SI_NetPoint;
43class SI_NetSegment;
44class SI_SymbolPin;
45
46namespace editor {
47
48/*******************************************************************************
49 * Class SchematicEditorState_DrawWire
50 ******************************************************************************/
51
56 Q_OBJECT
57
59 enum class SubState {
60 IDLE,
62 };
63
64public:
68 enum class WireMode {
69 HV,
70 VH,
71 Deg9045,
72 Deg4590,
73 Straight,
74 _COUNT,
75 };
76
77 // Constructors / Destructor
80 delete;
81 explicit SchematicEditorState_DrawWire(const Context& context) noexcept;
82 virtual ~SchematicEditorState_DrawWire() noexcept;
83
84 // General Methods
85 virtual bool entry() noexcept override;
86 virtual bool exit() noexcept override;
87
88 // Event Handlers
89 virtual bool processAbortCommand() noexcept override;
90 virtual bool processKeyPressed(
91 const GraphicsSceneKeyEvent& e) noexcept override;
92 virtual bool processKeyReleased(
93 const GraphicsSceneKeyEvent& e) noexcept override;
95 const GraphicsSceneMouseEvent& e) noexcept override;
97 const GraphicsSceneMouseEvent& e) noexcept override;
99 const GraphicsSceneMouseEvent& e) noexcept override;
101 const GraphicsSceneMouseEvent& e) noexcept override;
102
103 // Connection to UI
104 WireMode getWireMode() const noexcept { return mCurrentWireMode; }
105 void setWireMode(WireMode mode) noexcept;
106
107 // Operator Overloadings
109 const SchematicEditorState_DrawWire& rhs) = delete;
110
111signals:
113
114private: // Methods
115 bool startPositioning(SchematicGraphicsScene& scene, bool snap,
116 bool interactive,
117 SI_NetPoint* fixedPoint = nullptr) noexcept;
118 bool addNextNetPoint(SchematicGraphicsScene& scene, bool snap,
119 bool interactive) noexcept;
120 bool abortPositioning(bool showErrMsgBox, bool simplifySegment) noexcept;
121 std::shared_ptr<QGraphicsItem> findItem(
122 const Point& pos,
123 const QVector<std::shared_ptr<QGraphicsItem>>& except = {}) noexcept;
124 Point updateNetpointPositions(bool snap) noexcept;
125 void updateNetLabelPosition(const Point& pos, const Point& dirPos) noexcept;
126 Point calcMiddlePointPos(const Point& p1, const Point p2,
127 WireMode mode) const noexcept;
128 std::optional<NetSignal*> determineNetForBusMember(
129 SI_BusJunction& junction) const noexcept;
130
131private: // Data
145};
146
147/*******************************************************************************
148 * End of File
149 ******************************************************************************/
150
151} // namespace editor
152} // namespace librepcb
153
154#endif
The Circuit class represents all electrical connections in a project (drawn in the schematics)
Definition circuit.h:72
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The SI_BusJunction class.
Definition si_busjunction.h:45
The SI_NetLabel class.
Definition si_netlabel.h:48
Definition si_netline.h:43
The SI_NetLine class.
Definition si_netline.h:64
The SI_NetPoint class.
Definition si_netpoint.h:44
The SI_NetSegment class.
Definition si_netsegment.h:55
The SchematicEditorState_DrawWire class.
Definition schematiceditorstate_drawwire.h:55
WireMode
All available wire modes.
Definition schematiceditorstate_drawwire.h:68
virtual ~SchematicEditorState_DrawWire() noexcept
Definition schematiceditorstate_drawwire.cpp:88
SI_NetPoint * mPositioningNetPoint2
the second netpoint to place
Definition schematiceditorstate_drawwire.h:143
SchematicEditorState_DrawWire & operator=(const SchematicEditorState_DrawWire &rhs)=delete
void updateNetLabelPosition(const Point &pos, const Point &dirPos) noexcept
Definition schematiceditorstate_drawwire.cpp:791
virtual bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:165
Circuit & mCircuit
Definition schematiceditorstate_drawwire.h:132
WireMode mCurrentWireMode
the current wire mode
Definition schematiceditorstate_drawwire.h:134
virtual bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:220
SI_NetLine * mPositioningNetLine2
line between p1 and p2
Definition schematiceditorstate_drawwire.h:142
SI_NetSegment * mCurrentNetSegment
Definition schematiceditorstate_drawwire.h:138
virtual bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:178
void setWireMode(WireMode mode) noexcept
Definition schematiceditorstate_drawwire.cpp:240
virtual bool processAbortCommand() noexcept override
Definition schematiceditorstate_drawwire.cpp:119
SI_NetLine * mPositioningNetLine1
line between fixed point and p1
Definition schematiceditorstate_drawwire.h:140
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:202
SI_NetLineAnchor * mFixedStartAnchor
Definition schematiceditorstate_drawwire.h:136
WireMode getWireMode() const noexcept
Definition schematiceditorstate_drawwire.h:104
virtual bool processKeyPressed(const GraphicsSceneKeyEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:127
std::optional< NetSignal * > determineNetForBusMember(SI_BusJunction &junction) const noexcept
Definition schematiceditorstate_drawwire.cpp:838
SI_NetPoint * mPositioningNetPoint1
the first netpoint to place
Definition schematiceditorstate_drawwire.h:141
SchematicEditorState_DrawWire(const SchematicEditorState_DrawWire &other)=delete
Point calcMiddlePointPos(const Point &p1, const Point p2, WireMode mode) const noexcept
Definition schematiceditorstate_drawwire.cpp:803
bool startPositioning(SchematicGraphicsScene &scene, bool snap, bool interactive, SI_NetPoint *fixedPoint=nullptr) noexcept
Definition schematiceditorstate_drawwire.cpp:255
virtual bool exit() noexcept override
Definition schematiceditorstate_drawwire.cpp:104
std::shared_ptr< QGraphicsItem > findItem(const Point &pos, const QVector< std::shared_ptr< QGraphicsItem > > &except={}) noexcept
Definition schematiceditorstate_drawwire.cpp:723
virtual bool processKeyReleased(const GraphicsSceneKeyEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:146
bool addNextNetPoint(SchematicGraphicsScene &scene, bool snap, bool interactive) noexcept
Definition schematiceditorstate_drawwire.cpp:437
bool abortPositioning(bool showErrMsgBox, bool simplifySegment) noexcept
Definition schematiceditorstate_drawwire.cpp:686
SubState
Internal FSM States (substates)
Definition schematiceditorstate_drawwire.h:59
@ POSITIONING_NETPOINT
in this state, an undo command is active!
SubState mSubState
the current substate
Definition schematiceditorstate_drawwire.h:133
Point mCursorPos
the current cursor position
Definition schematiceditorstate_drawwire.h:135
virtual bool entry() noexcept override
Definition schematiceditorstate_drawwire.cpp:96
SI_NetLabel * mPositioningNetLabel
if net is forced, the label to place
Definition schematiceditorstate_drawwire.h:144
Point updateNetpointPositions(bool snap) noexcept
Definition schematiceditorstate_drawwire.cpp:735
The schematic editor state base class.
Definition schematiceditorstate.h:58
The SchematicGraphicsScene class.
Definition schematicgraphicsscene.h:76
Definition occmodel.cpp:77
Definition uuid.h:186
Definition graphicsscene.h:52
Definition graphicsscene.h:45
FSM Context.
Definition schematiceditorfsm.h:65