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 bool getAutoDrillDiameter() const noexcept {
78 return !mCurrentProperties.getDrillDiameter().has_value();
79 }
80 PositiveLength getDrillDiameter() const noexcept;
81 void setDrillDiameter(const std::optional<PositiveLength>& diameter) noexcept;
82 void saveDrillDiameterInBoard() noexcept;
83 void saveDrillDiameterInNetClass() noexcept;
84 bool getUseAutoSize() const noexcept {
85 return !mCurrentProperties.getSize().has_value();
86 }
87 PositiveLength getSize() const noexcept;
88 void setSize(const std::optional<PositiveLength>& size) noexcept;
89 QVector<std::pair<Uuid, QString>> getAvailableNets() const noexcept;
90 bool getUseAutoNet() const noexcept { return mUseAutoNetSignal; }
91 std::optional<Uuid> getNet() const noexcept { return mCurrentNetSignal; }
92 void setNet(bool autoNet, const std::optional<Uuid>& net) noexcept;
93
94 // Operator Overloadings
96 delete;
97
98signals:
99 void drillDiameterChanged(bool autoDrill, const PositiveLength& diameter);
100 void sizeChanged(bool autoSize, const PositiveLength& size);
101 void netChanged(bool autoNet, const std::optional<Uuid>& net);
102
103private: // Methods
104 bool addVia(const Point& pos) noexcept;
105 bool updatePosition(BoardGraphicsScene& scene, const Point& pos) noexcept;
106 void setNetSignal(NetSignal* netsignal) noexcept;
107 bool fixPosition(const Point& pos) noexcept;
108 bool abortCommand(bool showErrMsgBox) noexcept;
109 void applySelectedNetSignal() noexcept;
111 const Point& pos) noexcept;
112 NetSignal* getCurrentNetSignal() const noexcept;
113
114private: // Data
115 // State
117
118 // Current tool settings
120
123
126
129
130 // Information about the current via to place. Only valid if
131 // mIsUndoCmdActive == true.
134};
135
136/*******************************************************************************
137 * End of File
138 ******************************************************************************/
139
140} // namespace editor
141} // namespace librepcb
142
143#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:55
const std::optional< PositiveLength > & getDrillDiameter() const noexcept
Definition via.h:86
const std::optional< PositiveLength > & getSize() const noexcept
Definition via.h:89
The "add via" state/tool of the board editor.
Definition boardeditorstate_addvia.h:54
bool mUseAutoNetSignal
Whether the net signal is determined automatically or not.
Definition boardeditorstate_addvia.h:122
std::optional< Uuid > getNet() const noexcept
Definition boardeditorstate_addvia.h:91
PositiveLength getDrillDiameter() const noexcept
Definition boardeditorstate_addvia.cpp:145
virtual bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_addvia.cpp:119
QVector< std::pair< Uuid, QString > > getAvailableNets() const noexcept
Definition boardeditorstate_addvia.cpp:262
void saveDrillDiameterInNetClass() noexcept
Definition boardeditorstate_addvia.cpp:208
bool addVia(const Point &pos) noexcept
Definition boardeditorstate_addvia.cpp:305
void updateClosestNetSignal(BoardGraphicsScene &scene, const Point &pos) noexcept
Definition boardeditorstate_addvia.cpp:498
bool mClosestNetSignalIsUpToDate
Whether mCurrentNetSignal contains an up-to-date closest net signal.
Definition boardeditorstate_addvia.h:128
BI_Via * mCurrentViaToPlace
Definition boardeditorstate_addvia.h:132
void sizeChanged(bool autoSize, const PositiveLength &size)
bool getUseAutoSize() const noexcept
Definition boardeditorstate_addvia.h:84
virtual bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_addvia.cpp:128
BoardEditorState_AddVia & operator=(const BoardEditorState_AddVia &rhs)=delete
void setNet(bool autoNet, const std::optional< Uuid > &net) noexcept
Definition boardeditorstate_addvia.cpp:279
virtual ~BoardEditorState_AddVia() noexcept
Definition boardeditorstate_addvia.cpp:86
std::optional< Uuid > mCurrentNetSignal
The current net signal of the via.
Definition boardeditorstate_addvia.h:125
BoardEditorState_AddVia(const BoardEditorState_AddVia &other)=delete
bool getAutoDrillDiameter() const noexcept
Definition boardeditorstate_addvia.h:77
void applySelectedNetSignal() noexcept
Definition boardeditorstate_addvia.cpp:476
void drillDiameterChanged(bool autoDrill, const PositiveLength &diameter)
void netChanged(bool autoNet, const std::optional< Uuid > &net)
void saveDrillDiameterInBoard() noexcept
Definition boardeditorstate_addvia.cpp:189
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_addvia.cpp:136
bool abortCommand(bool showErrMsgBox) noexcept
Definition boardeditorstate_addvia.cpp:451
void setNetSignal(NetSignal *netsignal) noexcept
bool mIsUndoCmdActive
Definition boardeditorstate_addvia.h:116
std::unique_ptr< CmdBoardViaEdit > mCurrentViaEditCmd
Definition boardeditorstate_addvia.h:133
virtual bool exit() noexcept override
Definition boardeditorstate_addvia.cpp:106
void setSize(const std::optional< PositiveLength > &size) noexcept
Definition boardeditorstate_addvia.cpp:239
bool updatePosition(BoardGraphicsScene &scene, const Point &pos) noexcept
Definition boardeditorstate_addvia.cpp:339
bool getUseAutoNet() const noexcept
Definition boardeditorstate_addvia.h:90
NetSignal * getCurrentNetSignal() const noexcept
Definition boardeditorstate_addvia.cpp:545
Via mCurrentProperties
Definition boardeditorstate_addvia.h:119
bool fixPosition(const Point &pos) noexcept
Definition boardeditorstate_addvia.cpp:354
PositiveLength getSize() const noexcept
Definition boardeditorstate_addvia.cpp:229
virtual bool entry() noexcept override
Definition boardeditorstate_addvia.cpp:93
void setDrillDiameter(const std::optional< PositiveLength > &diameter) noexcept
Definition boardeditorstate_addvia.cpp:158
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:99
Definition graphicsscene.h:45