LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36
37class BI_FootprintPad;
38class BI_NetLine;
39class BI_NetLineAnchor;
40class BI_NetPoint;
41class BI_NetSegment;
42class BI_Via;
43class Layer;
44class NetSignal;
45
46namespace editor {
47
48/*******************************************************************************
49 * Class BoardEditorState_DrawTrace
50 ******************************************************************************/
51
56 Q_OBJECT
57
58public:
62 enum class WireMode {
63 HV,
64 VH,
65 Deg9045,
66 Deg4590,
67 Straight,
68 _COUNT,
69 };
70
71 // Constructors / Destructor
74 explicit BoardEditorState_DrawTrace(const Context& context) noexcept;
75 virtual ~BoardEditorState_DrawTrace() noexcept;
76
77 // General Methods
78 virtual bool entry() noexcept override;
79 virtual bool exit() noexcept override;
80
81 // Event Handlers
82 virtual bool processAbortCommand() noexcept override;
83 virtual bool processKeyPressed(
84 const GraphicsSceneKeyEvent& e) noexcept override;
85 virtual bool processKeyReleased(
86 const GraphicsSceneKeyEvent& e) noexcept override;
88 const GraphicsSceneMouseEvent& e) noexcept override;
90 const GraphicsSceneMouseEvent& e) noexcept override;
92 const GraphicsSceneMouseEvent& e) noexcept override;
94 const GraphicsSceneMouseEvent& e) noexcept override;
95
96 // Connection to UI
97 WireMode getWireMode() const noexcept { return mCurrentWireMode; }
98 void setWireMode(WireMode mode) noexcept;
99 QSet<const Layer*> getAvailableLayers() noexcept;
100 const Layer& getLayer() const noexcept { return *mCurrentLayer; }
101 void setLayer(const Layer& layer) noexcept;
102 bool getAutoWidth() const noexcept { return mCurrentAutoWidth; }
103 void setAutoWidth(bool autoWidth) noexcept;
104 const PositiveLength& getWidth() const noexcept { return mCurrentWidth; }
105 void setWidth(const PositiveLength& width) noexcept;
106 const PositiveLength& getViaSize() const noexcept {
108 }
109 void setViaSize(const PositiveLength& size) noexcept;
110 const PositiveLength& getViaDrillDiameter() const noexcept {
112 }
113 void setViaDrillDiameter(const PositiveLength& diameter) noexcept;
114
115 // Operator Overloadings
117 delete;
118
119signals:
121 void layerChanged(const Layer& layer);
122 void autoWidthChanged(bool autoWidth);
123 void widthChanged(const PositiveLength& width);
126
127private:
134
149 bool startPositioning(Board& board, const Point& pos,
150 BI_NetPoint* fixedPoint = nullptr,
151 BI_Via* fixedVia = nullptr,
152 BI_FootprintPad* fixedPad = nullptr) noexcept;
153
162 bool addNextNetPoint(BoardGraphicsScene& scene) noexcept;
163
168 bool abortPositioning(bool showErrMsgBox) noexcept;
169
179 void updateNetpointPositions() noexcept;
180
194 void showVia(bool isVisible) noexcept;
195
197
206 Point calcMiddlePointPos(const Point& p1, const Point p2,
207 WireMode mode) const noexcept;
208
209 // State
213 bool mAddVia;
220
233};
234
235/*******************************************************************************
236 * End of File
237 ******************************************************************************/
238
239} // namespace editor
240} // namespace librepcb
241
242#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:78
The Via class represents a via of a board.
Definition via.h:52
const PositiveLength & getDrillDiameter() const noexcept
Definition via.h:85
const PositiveLength & getSize() const noexcept
Definition via.h:84
The "draw trace" state/tool of the board editor.
Definition boardeditorstate_drawtrace.h:55
WireMode
All available wire modes.
Definition boardeditorstate_drawtrace.h:62
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:317
const PositiveLength & getViaDrillDiameter() const noexcept
Definition boardeditorstate_drawtrace.h:110
bool addNextNetPoint(BoardGraphicsScene &scene) noexcept
Finalize the BI_NetLines and connect them to other existing traces if necessary.
Definition boardeditorstate_drawtrace.cpp:485
BI_NetLine * mPositioningNetLine2
line between p1 and p2
Definition boardeditorstate_drawtrace.h:231
virtual bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_drawtrace.cpp:168
const PositiveLength & getWidth() const noexcept
Definition boardeditorstate_drawtrace.h:104
const Layer * mCurrentLayer
the current board layer name
Definition boardeditorstate_drawtrace.h:212
const Layer * mViaLayer
Layer where the via was started.
Definition boardeditorstate_drawtrace.h:217
bool mAddVia
whether a via add is requested
Definition boardeditorstate_drawtrace.h:213
BI_NetLine * mPositioningNetLine1
line between fixed point and p1
Definition boardeditorstate_drawtrace.h:229
bool mCurrentAutoWidth
automatically adjust wire width
Definition boardeditorstate_drawtrace.h:223
WireMode mCurrentWireMode
the current wire mode
Definition boardeditorstate_drawtrace.h:211
virtual ~BoardEditorState_DrawTrace() noexcept
Definition boardeditorstate_drawtrace.cpp:95
virtual bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_drawtrace.cpp:205
PositiveLength mCurrentWidth
the current wire width
Definition boardeditorstate_drawtrace.h:222
void updateNetpointPositions() noexcept
Update the currently active traces according to the set parameters.
Definition boardeditorstate_drawtrace.cpp:700
void setLayer(const Layer &layer) noexcept
Definition boardeditorstate_drawtrace.cpp:240
BI_NetPoint * mPositioningNetPoint2
the second netpoint to place
Definition boardeditorstate_drawtrace.h:232
QSet< const Layer * > getAvailableLayers() noexcept
Definition boardeditorstate_drawtrace.cpp:236
Point mTargetPos
Definition boardeditorstate_drawtrace.h:218
void setViaDrillDiameter(const PositiveLength &diameter) noexcept
Definition boardeditorstate_drawtrace.cpp:304
virtual bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_drawtrace.cpp:179
BI_NetLineAnchor * mFixedStartAnchor
Definition boardeditorstate_drawtrace.h:225
void setWireMode(WireMode mode) noexcept
Definition boardeditorstate_drawtrace.cpp:225
BI_Via * mTempVia
Definition boardeditorstate_drawtrace.h:214
void setWidth(const PositiveLength &width) noexcept
Definition boardeditorstate_drawtrace.cpp:284
virtual bool processAbortCommand() noexcept override
Definition boardeditorstate_drawtrace.cpp:123
const Layer & getLayer() const noexcept
Definition boardeditorstate_drawtrace.h:100
void viaDrillDiameterChanged(const PositiveLength &diameter)
BoardEditorState_DrawTrace(const BoardEditorState_DrawTrace &other)=delete
bool abortPositioning(bool showErrMsgBox) noexcept
Abort or cancel the current drawing of the trace.
Definition boardeditorstate_drawtrace.cpp:674
void setViaSize(const PositiveLength &size) noexcept
Definition boardeditorstate_drawtrace.cpp:295
Via mCurrentViaProperties
Definition boardeditorstate_drawtrace.h:215
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_drawtrace.cpp:200
WireMode getWireMode() const noexcept
Definition boardeditorstate_drawtrace.h:97
BI_NetPoint * mPositioningNetPoint1
the first netpoint to place
Definition boardeditorstate_drawtrace.h:230
virtual bool processKeyPressed(const GraphicsSceneKeyEvent &e) noexcept override
Definition boardeditorstate_drawtrace.cpp:134
bool getAutoWidth() const noexcept
Definition boardeditorstate_drawtrace.h:102
bool mCurrentSnapActive
the current active snap to target
Definition boardeditorstate_drawtrace.h:224
const PositiveLength & getViaSize() const noexcept
Definition boardeditorstate_drawtrace.h:106
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:837
virtual bool exit() noexcept override
Definition boardeditorstate_drawtrace.cpp:110
void viaSizeChanged(const PositiveLength &size)
BI_NetSegment * mCurrentNetSegment
Definition boardeditorstate_drawtrace.h:227
void widthChanged(const PositiveLength &width)
void setAutoWidth(bool autoWidth) noexcept
Definition boardeditorstate_drawtrace.cpp:273
virtual bool processKeyReleased(const GraphicsSceneKeyEvent &e) noexcept override
Definition boardeditorstate_drawtrace.cpp:151
void showVia(bool isVisible) noexcept
Sets the BI_Via of the currently active trace.
Definition boardeditorstate_drawtrace.cpp:759
BoardEditorState_DrawTrace & operator=(const BoardEditorState_DrawTrace &rhs)=delete
BI_NetLineAnchor * combineAnchors(BI_NetLineAnchor &a, BI_NetLineAnchor &b)
Definition boardeditorstate_drawtrace.cpp:802
SubState
Internal FSM States (substates)
Definition boardeditorstate_drawtrace.h:129
@ SubState_Idle
idle state [initial state]
Definition boardeditorstate_drawtrace.h:130
@ SubState_PositioningNetPoint
in this state, an undo command is active!
Definition boardeditorstate_drawtrace.h:132
@ SubState_Initializing
beginning to start
Definition boardeditorstate_drawtrace.h:131
SubState mSubState
the current substate
Definition boardeditorstate_drawtrace.h:210
Point mCursorPos
the current cursor position
Definition boardeditorstate_drawtrace.h:221
virtual bool entry() noexcept override
Definition boardeditorstate_drawtrace.cpp:102
The board editor state base class.
Definition boardeditorstate.h:60
The BoardGraphicsScene class.
Definition boardgraphicsscene.h:77
Definition occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
FSM Context.
Definition boardeditorfsm.h:88
Definition graphicsscene.h:52
Definition graphicsscene.h:45