LibrePCB Developers Documentation
boardeditorstate_drawtrace.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_BOARDEDITORSTATE_DRAWTRACE_H
21#define LIBREPCB_EDITOR_BOARDEDITORSTATE_DRAWTRACE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "boardeditorstate.h"
27
29
30#include <QtCore>
31#include <QtWidgets>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class BI_FootprintPad;
39class BI_NetLine;
40class BI_NetLineAnchor;
41class BI_NetPoint;
42class BI_NetSegment;
43class BI_Via;
44class Layer;
45class NetSignal;
46
47namespace editor {
48
49class LayerComboBox;
50class PositiveLengthEdit;
51
52/*******************************************************************************
53 * Class BoardEditorState_DrawTrace
54 ******************************************************************************/
55
60 Q_OBJECT
61
62public:
63 // Constructors / Destructor
66 explicit BoardEditorState_DrawTrace(const Context& context) noexcept;
67 virtual ~BoardEditorState_DrawTrace() noexcept;
68
69 // General Methods
70 virtual bool entry() noexcept override;
71 virtual bool exit() noexcept override;
72
73 // Event Handlers
74 virtual bool processAbortCommand() noexcept override;
75 virtual bool processKeyPressed(const QKeyEvent& e) noexcept override;
76 virtual bool processKeyReleased(const QKeyEvent& e) noexcept override;
78 QGraphicsSceneMouseEvent& e) noexcept override;
80 QGraphicsSceneMouseEvent& e) noexcept override;
82 QGraphicsSceneMouseEvent& e) noexcept override;
84 QGraphicsSceneMouseEvent& e) noexcept override;
85 virtual bool processSwitchToBoard(int index) noexcept override;
86
87 // Operator Overloadings
89 delete;
90
91private:
93 enum SubState {
97 };
98
102 enum class WireMode {
103 HV,
104 VH,
105 Deg9045,
106 Deg4590,
107 Straight,
108 };
109
124 bool startPositioning(Board& board, const Point& pos,
125 BI_NetPoint* fixedPoint = nullptr,
126 BI_Via* fixedVia = nullptr,
127 BI_FootprintPad* fixedPad = nullptr) noexcept;
128
137 bool addNextNetPoint(BoardGraphicsScene& scene) noexcept;
138
143 bool abortPositioning(bool showErrMsgBox) noexcept;
144
154 void updateNetpointPositions() noexcept;
155
169 void showVia(bool isVisible) noexcept;
170
172
173 // Callback Functions for the Gui elements
174 void wireModeChanged(WireMode mode) noexcept;
175 void layerChanged(const Layer& layer) noexcept;
176 void sizeEditValueChanged(const PositiveLength& value) noexcept;
177 void drillDiameterEditValueChanged(const PositiveLength& value) noexcept;
178 void wireWidthEditValueChanged(const PositiveLength& value) noexcept;
179 void wireAutoWidthEditToggled(const bool checked) noexcept;
180
189 Point calcMiddlePointPos(const Point& p1, const Point p2,
190 WireMode mode) const noexcept;
191
192 // State
196 bool mAddVia;
200 tl::optional<const Layer&> mViaLayer;
203
216
217 // Widgets for the command toolbar
222 QPointer<QActionGroup> mWireModeActionGroup;
223};
224
225/*******************************************************************************
226 * End of File
227 ******************************************************************************/
228
229} // namespace editor
230} // namespace librepcb
231
232#endif
The BI_FootprintPad class.
Definition: bi_footprintpad.h:48
Definition: bi_netline.h:46
The BI_NetLine class.
Definition: bi_netline.h:71
The BI_NetPoint class.
Definition: bi_netpoint.h:46
The BI_NetSegment class.
Definition: bi_netsegment.h:52
The BI_Via class.
Definition: bi_via.h:44
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:73
The Layer class provides all supported geometry layers.
Definition: layer.h:42
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
The Via class represents a via of a board.
Definition: via.h:52
The "draw trace" state/tool of the board editor.
Definition: boardeditorstate_drawtrace.h:59
WireMode
All available wire modes.
Definition: boardeditorstate_drawtrace.h:102
bool startPositioning(Board &board, const Point &pos, BI_NetPoint *fixedPoint=nullptr, BI_Via *fixedVia=nullptr, BI_FootprintPad *fixedPad=nullptr) noexcept
Begin drawing the next BI_NetLine.
Definition: boardeditorstate_drawtrace.cpp:377
virtual bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_drawtrace.cpp:308
QPointer< PositiveLengthEdit > mSizeEdit
Definition: boardeditorstate_drawtrace.h:219
bool addNextNetPoint(BoardGraphicsScene &scene) noexcept
Finalize the BI_NetLines and connect them to other existing traces if necessary.
Definition: boardeditorstate_drawtrace.cpp:542
BI_NetLine * mPositioningNetLine2
line between p1 and p2
Definition: boardeditorstate_drawtrace.h:214
const Layer * mCurrentLayer
the current board layer name
Definition: boardeditorstate_drawtrace.h:195
bool mAddVia
whether a via add is requested
Definition: boardeditorstate_drawtrace.h:196
BI_NetLine * mPositioningNetLine1
line between fixed point and p1
Definition: boardeditorstate_drawtrace.h:212
QPointer< PositiveLengthEdit > mWidthEdit
Definition: boardeditorstate_drawtrace.h:221
bool mCurrentAutoWidth
automatically adjust wire width
Definition: boardeditorstate_drawtrace.h:206
WireMode mCurrentWireMode
the current wire mode
Definition: boardeditorstate_drawtrace.h:194
virtual ~BoardEditorState_DrawTrace() noexcept
Definition: boardeditorstate_drawtrace.cpp:98
PositiveLength mCurrentWidth
the current wire width
Definition: boardeditorstate_drawtrace.h:205
void updateNetpointPositions() noexcept
Update the currently active traces according to the set parameters.
Definition: boardeditorstate_drawtrace.cpp:757
tl::optional< const Layer & > mViaLayer
Layer where the via was started.
Definition: boardeditorstate_drawtrace.h:200
BI_NetPoint * mPositioningNetPoint2
the second netpoint to place
Definition: boardeditorstate_drawtrace.h:215
Point mTargetPos
Definition: boardeditorstate_drawtrace.h:201
virtual bool processSwitchToBoard(int index) noexcept override
Definition: boardeditorstate_drawtrace.cpp:368
BI_NetLineAnchor * mFixedStartAnchor
Definition: boardeditorstate_drawtrace.h:208
BI_Via * mTempVia
Definition: boardeditorstate_drawtrace.h:197
virtual bool processAbortCommand() noexcept override
Definition: boardeditorstate_drawtrace.cpp:263
virtual bool processKeyPressed(const QKeyEvent &e) noexcept override
Definition: boardeditorstate_drawtrace.cpp:274
void drillDiameterEditValueChanged(const PositiveLength &value) noexcept
Definition: boardeditorstate_drawtrace.cpp:938
QPointer< PositiveLengthEdit > mDrillEdit
Definition: boardeditorstate_drawtrace.h:220
BoardEditorState_DrawTrace(const BoardEditorState_DrawTrace &other)=delete
void wireModeChanged(WireMode mode) noexcept
Definition: boardeditorstate_drawtrace.cpp:894
bool abortPositioning(bool showErrMsgBox) noexcept
Abort or cancel the current drawing of the trace.
Definition: boardeditorstate_drawtrace.cpp:731
void wireAutoWidthEditToggled(const bool checked) noexcept
Definition: boardeditorstate_drawtrace.cpp:951
void layerChanged(const Layer &layer) noexcept
Definition: boardeditorstate_drawtrace.cpp:899
Via mCurrentViaProperties
Definition: boardeditorstate_drawtrace.h:198
BI_NetPoint * mPositioningNetPoint1
the first netpoint to place
Definition: boardeditorstate_drawtrace.h:213
bool mCurrentSnapActive
the current active snap to target
Definition: boardeditorstate_drawtrace.h:207
Point calcMiddlePointPos(const Point &p1, const Point p2, WireMode mode) const noexcept
Calculate the 'middle point' of two point, according to the chosen WireMode.
Definition: boardeditorstate_drawtrace.cpp:956
virtual bool exit() noexcept override
Definition: boardeditorstate_drawtrace.cpp:248
BI_NetSegment * mCurrentNetSegment
Definition: boardeditorstate_drawtrace.h:210
QPointer< LayerComboBox > mLayerComboBox
Definition: boardeditorstate_drawtrace.h:218
virtual bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_drawtrace.cpp:345
QPointer< QActionGroup > mWireModeActionGroup
Definition: boardeditorstate_drawtrace.h:222
void showVia(bool isVisible) noexcept
Sets the BI_Via of the currently active trace.
Definition: boardeditorstate_drawtrace.cpp:816
BI_NetLineAnchor * combineAnchors(BI_NetLineAnchor &a, BI_NetLineAnchor &b)
Definition: boardeditorstate_drawtrace.cpp:859
virtual bool processKeyReleased(const QKeyEvent &e) noexcept override
Definition: boardeditorstate_drawtrace.cpp:291
virtual bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_drawtrace.cpp:319
SubState
Internal FSM States (substates)
Definition: boardeditorstate_drawtrace.h:93
@ SubState_Idle
idle state [initial state]
Definition: boardeditorstate_drawtrace.h:94
@ SubState_PositioningNetPoint
in this state, an undo command is active!
Definition: boardeditorstate_drawtrace.h:96
@ SubState_Initializing
beginning to start
Definition: boardeditorstate_drawtrace.h:95
SubState mSubState
the current substate
Definition: boardeditorstate_drawtrace.h:193
void sizeEditValueChanged(const PositiveLength &value) noexcept
Definition: boardeditorstate_drawtrace.cpp:932
Point mCursorPos
the current cursor position
Definition: boardeditorstate_drawtrace.h:204
virtual bool entry() noexcept override
Definition: boardeditorstate_drawtrace.cpp:105
void wireWidthEditValueChanged(const PositiveLength &value) noexcept
Definition: boardeditorstate_drawtrace.cpp:944
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_drawtrace.cpp:340
The board editor state base class.
Definition: boardeditorstate.h:59
The BoardGraphicsScene class.
Definition: boardgraphicsscene.h:77
The LayerComboBox class.
Definition: layercombobox.h:47
The PositiveLengthEdit class is a widget to view/edit librepcb::PositiveLength values.
Definition: positivelengthedit.h:42
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
Definition: uuid.h:183
FSM Context.
Definition: boardeditorfsm.h:88