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_NetLine;
39class SI_NetLineAnchor;
40class SI_NetPoint;
41class SI_SymbolPin;
42
43namespace editor {
44
45/*******************************************************************************
46 * Class SchematicEditorState_DrawWire
47 ******************************************************************************/
48
53 Q_OBJECT
54
56 enum class SubState {
57 IDLE,
59 };
60
61public:
65 enum class WireMode {
66 HV,
67 VH,
68 Deg9045,
69 Deg4590,
70 Straight,
71 _COUNT,
72 };
73
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(
88 const GraphicsSceneKeyEvent& e) noexcept override;
89 virtual bool processKeyReleased(
90 const GraphicsSceneKeyEvent& e) noexcept override;
92 const GraphicsSceneMouseEvent& e) noexcept override;
94 const GraphicsSceneMouseEvent& e) noexcept override;
96 const GraphicsSceneMouseEvent& e) noexcept override;
98 const GraphicsSceneMouseEvent& e) noexcept override;
99
100 // Connection to UI
101 WireMode getWireMode() const noexcept { return mCurrentWireMode; }
102 void setWireMode(WireMode mode) noexcept;
103
104 // Operator Overloadings
106 const SchematicEditorState_DrawWire& rhs) = delete;
107
108signals:
110
111private: // Methods
112 bool startPositioning(SchematicGraphicsScene& scene, bool snap,
113 SI_NetPoint* fixedPoint = nullptr) noexcept;
114 bool addNextNetPoint(SchematicGraphicsScene& scene, bool snap) noexcept;
115 bool abortPositioning(bool showErrMsgBox) noexcept;
116 std::shared_ptr<QGraphicsItem> findItem(
117 const Point& pos,
118 const QVector<std::shared_ptr<QGraphicsItem>>& except = {}) noexcept;
119 Point updateNetpointPositions(bool snap) noexcept;
120 Point calcMiddlePointPos(const Point& p1, const Point p2,
121 WireMode mode) const noexcept;
122
123private: // Data
134};
135
136/*******************************************************************************
137 * End of File
138 ******************************************************************************/
139
140} // namespace editor
141} // namespace librepcb
142
143#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:52
WireMode
All available wire modes.
Definition schematiceditorstate_drawwire.h:65
virtual ~SchematicEditorState_DrawWire() noexcept
Definition schematiceditorstate_drawwire.cpp:76
SI_NetPoint * mPositioningNetPoint2
the second netpoint to place
Definition schematiceditorstate_drawwire.h:133
SchematicEditorState_DrawWire & operator=(const SchematicEditorState_DrawWire &rhs)=delete
virtual bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:153
Circuit & mCircuit
Definition schematiceditorstate_drawwire.h:124
WireMode mCurrentWireMode
the current wire mode
Definition schematiceditorstate_drawwire.h:126
virtual bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:206
SI_NetLine * mPositioningNetLine2
line between p1 and p2
Definition schematiceditorstate_drawwire.h:132
virtual bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:166
void setWireMode(WireMode mode) noexcept
Definition schematiceditorstate_drawwire.cpp:226
virtual bool processAbortCommand() noexcept override
Definition schematiceditorstate_drawwire.cpp:107
SI_NetLine * mPositioningNetLine1
line between fixed point and p1
Definition schematiceditorstate_drawwire.h:130
bool addNextNetPoint(SchematicGraphicsScene &scene, bool snap) noexcept
Definition schematiceditorstate_drawwire.cpp:387
bool abortPositioning(bool showErrMsgBox) noexcept
Definition schematiceditorstate_drawwire.cpp:587
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:189
SI_NetLineAnchor * mFixedStartAnchor
the fixed anchor (start point of the line)
Definition schematiceditorstate_drawwire.h:129
WireMode getWireMode() const noexcept
Definition schematiceditorstate_drawwire.h:101
virtual bool processKeyPressed(const GraphicsSceneKeyEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:115
SI_NetPoint * mPositioningNetPoint1
the first netpoint to place
Definition schematiceditorstate_drawwire.h:131
SchematicEditorState_DrawWire(const SchematicEditorState_DrawWire &other)=delete
bool startPositioning(SchematicGraphicsScene &scene, bool snap, SI_NetPoint *fixedPoint=nullptr) noexcept
Definition schematiceditorstate_drawwire.cpp:241
Point calcMiddlePointPos(const Point &p1, const Point p2, WireMode mode) const noexcept
Definition schematiceditorstate_drawwire.cpp:651
virtual bool exit() noexcept override
Definition schematiceditorstate_drawwire.cpp:92
std::shared_ptr< QGraphicsItem > findItem(const Point &pos, const QVector< std::shared_ptr< QGraphicsItem > > &except={}) noexcept
Definition schematiceditorstate_drawwire.cpp:606
virtual bool processKeyReleased(const GraphicsSceneKeyEvent &e) noexcept override
Definition schematiceditorstate_drawwire.cpp:134
SubState
Internal FSM States (substates)
Definition schematiceditorstate_drawwire.h:56
@ POSITIONING_NETPOINT
in this state, an undo command is active!
SubState mSubState
the current substate
Definition schematiceditorstate_drawwire.h:125
Point mCursorPos
the current cursor position
Definition schematiceditorstate_drawwire.h:127
virtual bool entry() noexcept override
Definition schematiceditorstate_drawwire.cpp:84
Point updateNetpointPositions(bool snap) noexcept
Definition schematiceditorstate_drawwire.cpp:618
The schematic editor state base class.
Definition schematiceditorstate.h:58
The SchematicGraphicsScene class.
Definition schematicgraphicsscene.h:67
Definition occmodel.cpp:77
Definition uuid.h:186
Definition graphicsscene.h:52
Definition graphicsscene.h:45
FSM Context.
Definition schematiceditorfsm.h:62