LibrePCB Developers Documentation
Loading...
Searching...
No Matches
boardeditorstate_addvia.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_ADDVIA_H
21#define LIBREPCB_EDITOR_BOARDEDITORSTATE_ADDVIA_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "boardeditorstate.h"
27
29
30#include <QtCore>
31
32#include <memory>
33#include <optional>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40class BI_Via;
41
42namespace editor {
43
44class BoardGraphicsScene;
45class CmdBoardViaEdit;
46
47/*******************************************************************************
48 * Class BoardEditorState_AddVia
49 ******************************************************************************/
50
55 Q_OBJECT
56
57public:
58 // Constructors / Destructor
61 explicit BoardEditorState_AddVia(const Context& context) noexcept;
62 virtual ~BoardEditorState_AddVia() noexcept;
63
64 // General Methods
65 virtual bool entry() noexcept override;
66 virtual bool exit() noexcept override;
67
68 // Event Handlers
70 const GraphicsSceneMouseEvent& e) noexcept override;
72 const GraphicsSceneMouseEvent& e) noexcept override;
74 const GraphicsSceneMouseEvent& e) noexcept override;
75
76 // Connection to UI
77 const PositiveLength& getSize() const noexcept {
79 }
80 void setSize(const PositiveLength& size) noexcept;
81 const PositiveLength& getDrillDiameter() const noexcept {
83 }
84 void setDrillDiameter(const PositiveLength& diameter) noexcept;
85 QVector<std::pair<Uuid, QString>> getAvailableNets() const noexcept;
86 bool getUseAutoNet() const noexcept { return mUseAutoNetSignal; }
87 std::optional<Uuid> getNet() const noexcept { return mCurrentNetSignal; }
88 void setNet(bool autoNet, const std::optional<Uuid>& net) noexcept;
89
90 // Operator Overloadings
92 delete;
93
94signals:
95 void sizeChanged(const PositiveLength& size);
96 void drillDiameterChanged(const PositiveLength& diameter);
97 void netChanged(bool autoNet, const std::optional<Uuid>& net);
98
99private: // Methods
100 bool addVia(const Point& pos) noexcept;
101 bool updatePosition(BoardGraphicsScene& scene, const Point& pos) noexcept;
102 void setNetSignal(NetSignal* netsignal) noexcept;
103 bool fixPosition(const Point& pos) noexcept;
104 bool abortCommand(bool showErrMsgBox) noexcept;
105 void applySelectedNetSignal() noexcept;
107 const Point& pos) noexcept;
108 NetSignal* getCurrentNetSignal() const noexcept;
109
110private: // Data
111 // State
113
114 // Current tool settings
116
119
122
125
126 // Information about the current via to place. Only valid if
127 // mIsUndoCmdActive == true.
130};
131
132/*******************************************************************************
133 * End of File
134 ******************************************************************************/
135
136} // namespace editor
137} // namespace librepcb
138
139#endif
The BI_Via class.
Definition bi_via.h:44
The NetSignal class.
Definition netsignal.h:50
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
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 "add via" state/tool of the board editor.
Definition boardeditorstate_addvia.h:54
void setSize(const PositiveLength &size) noexcept
Definition boardeditorstate_addvia.cpp:141
bool mUseAutoNetSignal
Whether the net signal is determined automatically or not.
Definition boardeditorstate_addvia.h:118
std::optional< Uuid > getNet() const noexcept
Definition boardeditorstate_addvia.h:87
virtual bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_addvia.cpp:115
QVector< std::pair< Uuid, QString > > getAvailableNets() const noexcept
Definition boardeditorstate_addvia.cpp:163
bool addVia(const Point &pos) noexcept
Definition boardeditorstate_addvia.cpp:200
void updateClosestNetSignal(BoardGraphicsScene &scene, const Point &pos) noexcept
Definition boardeditorstate_addvia.cpp:393
bool mClosestNetSignalIsUpToDate
Whether mCurrentNetSignal contains an up-to-date closest net signal.
Definition boardeditorstate_addvia.h:124
BI_Via * mCurrentViaToPlace
Definition boardeditorstate_addvia.h:128
void setDrillDiameter(const PositiveLength &diameter) noexcept
Definition boardeditorstate_addvia.cpp:151
virtual bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_addvia.cpp:124
BoardEditorState_AddVia & operator=(const BoardEditorState_AddVia &rhs)=delete
void setNet(bool autoNet, const std::optional< Uuid > &net) noexcept
Definition boardeditorstate_addvia.cpp:180
virtual ~BoardEditorState_AddVia() noexcept
Definition boardeditorstate_addvia.cpp:82
const PositiveLength & getDrillDiameter() const noexcept
Definition boardeditorstate_addvia.h:81
std::optional< Uuid > mCurrentNetSignal
The current net signal of the via.
Definition boardeditorstate_addvia.h:121
const PositiveLength & getSize() const noexcept
Definition boardeditorstate_addvia.h:77
BoardEditorState_AddVia(const BoardEditorState_AddVia &other)=delete
void applySelectedNetSignal() noexcept
Definition boardeditorstate_addvia.cpp:371
void netChanged(bool autoNet, const std::optional< Uuid > &net)
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_addvia.cpp:132
bool abortCommand(bool showErrMsgBox) noexcept
Definition boardeditorstate_addvia.cpp:346
void setNetSignal(NetSignal *netsignal) noexcept
bool mIsUndoCmdActive
Definition boardeditorstate_addvia.h:112
void drillDiameterChanged(const PositiveLength &diameter)
std::unique_ptr< CmdBoardViaEdit > mCurrentViaEditCmd
Definition boardeditorstate_addvia.h:129
virtual bool exit() noexcept override
Definition boardeditorstate_addvia.cpp:102
bool updatePosition(BoardGraphicsScene &scene, const Point &pos) noexcept
Definition boardeditorstate_addvia.cpp:234
bool getUseAutoNet() const noexcept
Definition boardeditorstate_addvia.h:86
NetSignal * getCurrentNetSignal() const noexcept
Definition boardeditorstate_addvia.cpp:434
Via mCurrentProperties
Definition boardeditorstate_addvia.h:115
bool fixPosition(const Point &pos) noexcept
Definition boardeditorstate_addvia.cpp:249
virtual bool entry() noexcept override
Definition boardeditorstate_addvia.cpp:89
void sizeChanged(const PositiveLength &size)
The board editor state base class.
Definition boardeditorstate.h:60
The BoardGraphicsScene class.
Definition boardgraphicsscene.h:77
The CmdBoardViaEdit class.
Definition cmdboardviaedit.h:49
Definition occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
Definition uuid.h:186
FSM Context.
Definition boardeditorfsm.h:88
Definition graphicsscene.h:45