LibrePCB Developers Documentation
Loading...
Searching...
No Matches
schematiceditorstate_drawbus.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_DRAWBUS_H
21#define LIBREPCB_EDITOR_SCHEMATICEDITORSTATE_DRAWBUS_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
28
31
32#include <QtCore>
33
34#include <optional>
35
36/*******************************************************************************
37 * Namespace / Forward Declarations
38 ******************************************************************************/
39namespace librepcb {
40
41class Circuit;
42class SI_BusJunction;
43class SI_BusLabel;
44class SI_BusLine;
45class SI_BusSegment;
46
47namespace editor {
48
49/*******************************************************************************
50 * Class SchematicEditorState_DrawBus
51 ******************************************************************************/
52
57 Q_OBJECT
58
60 enum class SubState {
61 IDLE,
63 };
64
65public:
67
68 // Constructors / Destructor
71 delete;
72 explicit SchematicEditorState_DrawBus(const Context& context) noexcept;
73 virtual ~SchematicEditorState_DrawBus() noexcept;
74
75 // General Methods
76 virtual bool entry() noexcept override;
77 virtual bool exit() noexcept override;
78
79 // Event Handlers
80 virtual bool processAbortCommand() noexcept override;
81 virtual bool processKeyPressed(
82 const GraphicsSceneKeyEvent& e) noexcept override;
83 virtual bool processKeyReleased(
84 const GraphicsSceneKeyEvent& e) noexcept override;
86 const GraphicsSceneMouseEvent& e) noexcept override;
88 const GraphicsSceneMouseEvent& e) noexcept override;
90 const GraphicsSceneMouseEvent& e) noexcept override;
92 const GraphicsSceneMouseEvent& e) noexcept override;
93
94 // Connection to UI
95 void selectBus(const std::optional<Uuid> uuid) noexcept;
96 WireMode getWireMode() const noexcept { return mCurrentWireMode; }
97 void setWireMode(WireMode mode) noexcept;
98
99 // Operator Overloadings
101 const SchematicEditorState_DrawBus& rhs) = delete;
102
103signals:
105
106private: // Methods
107 bool startPositioning(SchematicGraphicsScene& scene, bool snap,
108 SI_BusJunction* fixedPoint = nullptr) noexcept;
109 bool addNextJunction(SchematicGraphicsScene& scene, bool snap) noexcept;
110 bool abortPositioning(bool showErrMsgBox, bool simplifySegment) noexcept;
111 std::shared_ptr<QGraphicsItem> findItem(
112 const Point& pos,
113 const QVector<std::shared_ptr<QGraphicsItem>>& except = {}) noexcept;
114 Point updateJunctionPositions(bool snap) noexcept;
115 void updateLabelPosition(const Point& pos, const Point& dirPos) noexcept;
116 Point calcMiddlePointPos(const Point& p1, const Point p2,
117 WireMode mode) const noexcept;
118
119private: // Data
133
134 std::optional<Uuid> mPreSelectedBus;
135};
136
137/*******************************************************************************
138 * End of File
139 ******************************************************************************/
140
141} // namespace editor
142} // namespace librepcb
143
144#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_BusLabel class.
Definition si_buslabel.h:48
The SI_BusLine class.
Definition si_busline.h:47
The SI_BusSegment class.
Definition si_bussegment.h:52
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The SchematicEditorState_DrawBus class.
Definition schematiceditorstate_drawbus.h:56
virtual bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawbus.cpp:155
SI_BusJunction * mPositioningJunction1
the first netpoint to place
Definition schematiceditorstate_drawbus.h:129
SI_BusLine * mPositioningLine2
line between p1 and p2
Definition schematiceditorstate_drawbus.h:130
Circuit & mCircuit
Definition schematiceditorstate_drawbus.h:120
SchematicEditorState_DrawBus & operator=(const SchematicEditorState_DrawBus &rhs)=delete
void updateLabelPosition(const Point &pos, const Point &dirPos) noexcept
Definition schematiceditorstate_drawbus.cpp:599
std::optional< Uuid > mPreSelectedBus
If tool was started with given bus.
Definition schematiceditorstate_drawbus.h:134
WireMode mCurrentWireMode
the current wire mode
Definition schematiceditorstate_drawbus.h:122
virtual bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawbus.cpp:207
SI_BusLine * mPositioningLine1
line between fixed point and p1
Definition schematiceditorstate_drawbus.h:128
void selectBus(const std::optional< Uuid > uuid) noexcept
Definition schematiceditorstate_drawbus.cpp:227
virtual bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawbus.cpp:168
void setWireMode(WireMode mode) noexcept
Definition schematiceditorstate_drawbus.cpp:232
virtual bool processAbortCommand() noexcept override
Definition schematiceditorstate_drawbus.cpp:109
SchematicEditorState_DrawBus(const SchematicEditorState_DrawBus &other)=delete
SchematicEditorState_DrawWire::WireMode WireMode
Definition schematiceditorstate_drawbus.h:66
SI_BusJunction * mFixedStartAnchor
Definition schematiceditorstate_drawbus.h:124
Point updateJunctionPositions(bool snap) noexcept
Definition schematiceditorstate_drawbus.cpp:557
virtual ~SchematicEditorState_DrawBus() noexcept
Definition schematiceditorstate_drawbus.cpp:76
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawbus.cpp:191
WireMode getWireMode() const noexcept
Definition schematiceditorstate_drawbus.h:96
virtual bool processKeyPressed(const GraphicsSceneKeyEvent &e) noexcept override
Definition schematiceditorstate_drawbus.cpp:117
SI_BusJunction * mPositioningJunction2
the second netpoint to place
Definition schematiceditorstate_drawbus.h:131
bool addNextJunction(SchematicGraphicsScene &scene, bool snap) noexcept
Definition schematiceditorstate_drawbus.cpp:361
SI_BusSegment * mCurrentSegment
Definition schematiceditorstate_drawbus.h:126
Point calcMiddlePointPos(const Point &p1, const Point p2, WireMode mode) const noexcept
Definition schematiceditorstate_drawbus.cpp:612
virtual bool exit() noexcept override
Definition schematiceditorstate_drawbus.cpp:94
std::shared_ptr< QGraphicsItem > findItem(const Point &pos, const QVector< std::shared_ptr< QGraphicsItem > > &except={}) noexcept
Definition schematiceditorstate_drawbus.cpp:546
SI_BusLabel * mPositioningLabel
Only if bus was preselected.
Definition schematiceditorstate_drawbus.h:132
virtual bool processKeyReleased(const GraphicsSceneKeyEvent &e) noexcept override
Definition schematiceditorstate_drawbus.cpp:136
bool abortPositioning(bool showErrMsgBox, bool simplifySegment) noexcept
Definition schematiceditorstate_drawbus.cpp:510
bool startPositioning(SchematicGraphicsScene &scene, bool snap, SI_BusJunction *fixedPoint=nullptr) noexcept
Definition schematiceditorstate_drawbus.cpp:247
SubState
Internal FSM States (substates)
Definition schematiceditorstate_drawbus.h:60
@ POSITIONING_JUNCTION
in this state, an undo command is active!
SubState mSubState
the current substate
Definition schematiceditorstate_drawbus.h:121
Point mCursorPos
the current cursor position
Definition schematiceditorstate_drawbus.h:123
virtual bool entry() noexcept override
Definition schematiceditorstate_drawbus.cpp:84
WireMode
All available wire modes.
Definition schematiceditorstate_drawwire.h:68
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