LibrePCB Developers Documentation
Loading...
Searching...
No Matches
board2dtab.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_BOARD2DTAB_H
21#define LIBREPCB_EDITOR_BOARD2DTAB_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../dialogs/graphicsexportdialog.h"
27#include "../../utils/dismissablemessagecontext.h"
28#include "../../utils/lengtheditcontext.h"
29#include "../../utils/searchcontext.h"
30#include "../../widgets/if_graphicsvieweventhandler.h"
33#include "windowtab.h"
34
36
37#include <QtCore>
38
39#include <optional>
40
41/*******************************************************************************
42 * Namespace / Forward Declarations
43 ******************************************************************************/
44namespace librepcb {
45
46class Package;
47class RuleCheckMessage;
48
49namespace editor {
50
51class BoardEditor;
52class BoardEditorFsm;
53class FootprintGraphicsItem;
54class GraphicsLayerList;
55class GraphicsLayersModel;
56class ProjectEditor;
57class SlintGraphicsView;
58
59/*******************************************************************************
60 * Class Board2dTab
61 ******************************************************************************/
62
66class Board2dTab final : public WindowTab,
69 Q_OBJECT
70
88
90 Single,
91 Similar,
92 All,
93 };
94
95public:
96 // Signals
98
99 // Constructors / Destructor
100 Board2dTab() = delete;
101 Board2dTab(const Board2dTab& other) = delete;
102 explicit Board2dTab(GuiApplication& app, BoardEditor& editor,
103 QObject* parent = nullptr) noexcept;
104 ~Board2dTab() noexcept;
105
106 // General Methods
107 int getProjectIndex() const noexcept;
108 int getProjectObjectIndex() const noexcept;
109 ui::TabData getUiData() const noexcept override;
110 void setUiData(const ui::TabData& data) noexcept override;
111 ui::Board2dTabData getDerivedUiData() const noexcept;
112 void setDerivedUiData(const ui::Board2dTabData& data) noexcept;
113 void activate() noexcept override;
114 void deactivate() noexcept override;
115 void trigger(ui::TabAction a) noexcept override;
116 slint::Image renderScene(float width, float height,
117 int scene) noexcept override;
119 const QPointF& pos, slint::private_api::PointerEvent e) noexcept override;
121 const QPointF& pos,
122 slint::private_api::PointerScrollEvent e) noexcept override;
124 const slint::private_api::KeyEvent& e) noexcept override;
125 QSet<const Layer*> getVisibleCopperLayers() const noexcept;
126
127 // IF_GraphicsViewEventHandler
129 const GraphicsSceneKeyEvent& e) noexcept override;
131 const GraphicsSceneKeyEvent& e) noexcept override;
133 const GraphicsSceneMouseEvent& e) noexcept override;
135 const GraphicsSceneMouseEvent& e) noexcept override;
137 const GraphicsSceneMouseEvent& e) noexcept override;
139 const GraphicsSceneMouseEvent& e) noexcept override;
141 const GraphicsSceneMouseEvent& e) noexcept override;
142
143 // BoardEditorFsmAdapter
144 BoardGraphicsScene* fsmGetGraphicsScene() noexcept override;
145 bool fsmGetIgnoreLocks() const noexcept override;
146 void fsmSetViewCursor(
147 const std::optional<Qt::CursorShape>& shape) noexcept override;
148 void fsmSetViewGrayOut(bool grayOut) noexcept override;
149 void fsmSetViewInfoBoxText(const QString& text) noexcept override;
150 void fsmSetViewRuler(
151 const std::optional<std::pair<Point, Point>>& pos) noexcept override;
152 void fsmSetSceneCursor(const Point& pos, bool cross,
153 bool circle) noexcept override;
154 QPainterPath fsmCalcPosWithTolerance(
155 const Point& pos, qreal multiplier) const noexcept override;
156 Point fsmMapGlobalPosToScenePos(const QPoint& pos) const noexcept override;
158 const QSet<const NetSignal*>& sigs) noexcept override;
159 void fsmAbortBlockingToolsInOtherEditors() noexcept override;
160 void fsmSetStatusBarMessage(const QString& message,
161 int timeoutMs = -1) noexcept override;
162 void fsmSetFeatures(Features features) noexcept override;
163 void fsmToolLeave() noexcept override;
164 void fsmToolEnter(BoardEditorState_Select& state) noexcept override;
165 void fsmToolEnter(BoardEditorState_DrawTrace& state) noexcept override;
166 void fsmToolEnter(BoardEditorState_AddVia& state) noexcept override;
167 void fsmToolEnter(BoardEditorState_DrawPolygon& state) noexcept override;
168 void fsmToolEnter(BoardEditorState_AddStrokeText& state) noexcept override;
169 void fsmToolEnter(BoardEditorState_DrawPlane& state) noexcept override;
170 void fsmToolEnter(BoardEditorState_DrawZone& state) noexcept override;
171 void fsmToolEnter(BoardEditorState_AddHole& state) noexcept override;
172 void fsmToolEnter(BoardEditorState_AddDevice& state) noexcept override;
173 void fsmToolEnter(BoardEditorState_Measure& state) noexcept override;
174
175 // Operator Overloadings
176 Board2dTab& operator=(const Board2dTab& rhs) = delete;
177
178signals:
180 void netRequested(bool autoNet, const std::optional<Uuid>& net);
181 void layerRequested(const Layer& layer);
182 void filledRequested(bool filled);
183 void mirroredRequested(bool mirrored);
184 void valueRequested(const QString& value);
185 void zoneRuleRequested(Zone::Rule rule, bool enable);
186
187private:
188 void updateEnabledCopperLayers() noexcept;
189 void loadLayersVisibility() noexcept;
190 void storeLayersVisibility() noexcept;
191 void updateMessages() noexcept;
192 void highlightDrcMessage(const std::shared_ptr<const RuleCheckMessage>& msg,
193 bool zoomTo) noexcept;
194 void clearDrcMarker() noexcept;
195 void scheduleUnplacedComponentsUpdate() noexcept;
196 void updateUnplacedComponents() noexcept;
197 void restartIdleTimer() noexcept;
198 void setSelectedUnplacedComponent(int index) noexcept;
199 void setSelectedUnplacedComponentDevice(int index) noexcept;
201 const std::optional<Uuid>& deviceUuid, Package* package,
202 bool packageOwned) noexcept;
203 void setSelectedUnplacedComponentFootprint(int index) noexcept;
212 std::pair<QList<DeviceMetadata>, int> getAvailableDevices(
213 ComponentInstance& cmp) const noexcept;
214 std::optional<Uuid> getSuggestedFootprint(
215 const Uuid& libPkgUuid) const noexcept;
218 const QString& settingsKey) noexcept;
219 void execPickPlaceExportDialog() noexcept;
220 void execD356NetlistExportDialog() noexcept;
221 void execSpecctraExportDialog() noexcept;
222 void execSpecctraImportDialog() noexcept;
223 void goToDevice(const QString& name, int index) noexcept;
224 void applyTheme() noexcept;
225 void requestRepaint() noexcept;
226
227private:
228 // References
235 QVector<QMetaObject::Connection> mActiveConnections;
236
237 // Message handles
240
241 // State
243 Theme::GridStyle mGridStyle;
247
248 // Current tool
250 ui::EditorTool mTool;
251 Qt::CursorShape mToolCursorShape;
254 QVector<std::pair<bool, std::optional<Uuid>>> mToolNetsQt;
255 std::shared_ptr<slint::VectorModel<slint::SharedString>> mToolNets;
256 std::pair<bool, std::optional<Uuid>> mToolNet;
257 QVector<const Layer*> mToolLayersQt;
258 std::shared_ptr<slint::VectorModel<slint::SharedString>> mToolLayers;
263 bool mToolFilled; // Also used for auto-width
265 QString mToolValue;
266 std::shared_ptr<slint::VectorModel<slint::SharedString>>
269
270 // Unplaced components
272 std::shared_ptr<slint::VectorModel<slint::SharedString>>
277 std::shared_ptr<slint::VectorModel<slint::SharedString>>
282 std::shared_ptr<slint::VectorModel<slint::SharedString>>
291
292 // FSM
293 QVector<QMetaObject::Connection> mFsmStateConnections;
294 QScopedPointer<BoardEditorFsm> mFsm;
295
296 // Objects in active state
299 std::unique_ptr<QTimer> mInputIdleTimer;
300 std::unique_ptr<QGraphicsPathItem> mDrcLocationGraphicsItem;
301};
302
303/*******************************************************************************
304 * End of File
305 ******************************************************************************/
306
307} // namespace editor
308} // namespace librepcb
309
310#endif
The Board class represents a PCB of a project and is always part of a circuit.
Definition board.h:73
The ComponentInstance class.
Definition componentinstance.h:54
The Layer class provides all supported geometry layers.
Definition layer.h:42
The NetSignal class.
Definition netsignal.h:50
The Package class represents a package of a component (including footprint and 3D model)
Definition package.h:59
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The Project class represents a whole (opened) project with all its content.
Definition project.h:71
The RuleCheckMessage class.
Definition rulecheckmessage.h:45
The Signal class is used to emit signals on non-QObject derived classes.
Definition signalslot.h:65
Theme class as used by librepcb::WorkspaceSettingsItem_Themes.
Definition theme.h:44
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The Zone class.
Definition zone.h:43
The Board2dTab class.
Definition board2dtab.h:68
slint::Image renderScene(float width, float height, int scene) noexcept override
Definition board2dtab.cpp:826
void updateEnabledCopperLayers() noexcept
Definition board2dtab.cpp:1400
bool graphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition board2dtab.cpp:897
bool mIgnorePlacementLocks
Definition board2dtab.h:245
Features mToolFeatures
Definition board2dtab.h:249
QPointer< ComponentInstance > mUnplacedComponent
Definition board2dtab.h:275
QPointer< Package > mUnplacedComponentPackage
Definition board2dtab.h:280
int mUnplacedComponentFootprintIndex
Definition board2dtab.h:284
QPointF mSceneImagePos
Definition board2dtab.h:244
std::unique_ptr< SlintGraphicsView > mView
Definition board2dtab.h:234
std::pair< bool, std::optional< Uuid > > mToolNet
Definition board2dtab.h:256
Zone::Rules mToolZoneRules
Definition board2dtab.h:268
void fsmSetSceneCursor(const Point &pos, bool cross, bool circle) noexcept override
Definition board2dtab.cpp:971
void applyTheme() noexcept
Definition board2dtab.cpp:2142
bool graphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition board2dtab.cpp:918
std::shared_ptr< slint::VectorModel< slint::SharedString > > mUnplacedComponentDevicesModel
Definition board2dtab.h:278
int mUnplacedComponentIndex
Definition board2dtab.h:274
void layerRequested(const Layer &layer)
void addUnplacedComponentsToBoard(PlaceComponentsMode mode) noexcept
Definition board2dtab.cpp:1817
void updateUnplacedComponents() noexcept
Definition board2dtab.cpp:1479
void setSelectedUnplacedComponentFootprint(int index) noexcept
Definition board2dtab.cpp:1635
QString mToolValue
Definition board2dtab.h:265
int mFrameIndex
Definition board2dtab.h:246
void setSelectedUnplacedComponentDeviceAndPackage(const std::optional< Uuid > &deviceUuid, Package *package, bool packageOwned) noexcept
Definition board2dtab.cpp:1604
std::pair< QList< DeviceMetadata >, int > getAvailableDevices(ComponentInstance &cmp) const noexcept
Get all available devices for a specific component instance.
Definition board2dtab.cpp:1658
bool graphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition board2dtab.cpp:913
DismissableMessageContext mMsgEmptySchematics
Definition board2dtab.h:238
std::unique_ptr< GraphicsLayerList > mLayers
Definition board2dtab.h:233
BoardEditorState_DrawTrace::WireMode mToolWireMode
Definition board2dtab.h:253
BoardGraphicsScene * fsmGetGraphicsScene() noexcept override
Definition board2dtab.cpp:927
std::shared_ptr< slint::VectorModel< slint::SharedString > > mUnplacedComponentsModel
Definition board2dtab.h:273
bool graphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition board2dtab.cpp:903
Signal< Board2dTab > onDerivedUiDataChanged
Definition board2dtab.h:97
void execPickPlaceExportDialog() noexcept
Definition board2dtab.cpp:1945
std::unique_ptr< QGraphicsPathItem > mDrcLocationGraphicsItem
Definition board2dtab.h:300
ui::Board2dTabData getDerivedUiData() const noexcept
Definition board2dtab.cpp:311
LengthEditContext mToolDrill
Definition board2dtab.h:262
bool fsmGetIgnoreLocks() const noexcept override
Definition board2dtab.cpp:931
QVector< std::pair< bool, std::optional< Uuid > > > mToolNetsQt
Definition board2dtab.h:254
Theme::GridStyle mGridStyle
Definition board2dtab.h:243
std::shared_ptr< slint::VectorModel< slint::SharedString > > mToolValueSuggestions
Definition board2dtab.h:267
std::shared_ptr< slint::VectorModel< slint::SharedString > > mToolLayers
Definition board2dtab.h:258
std::optional< Uuid > getSuggestedFootprint(const Uuid &libPkgUuid) const noexcept
Definition board2dtab.cpp:1789
LengthEditContext mToolSize
Definition board2dtab.h:261
void scheduleUnplacedComponentsUpdate() noexcept
Definition board2dtab.cpp:1473
QVector< QMetaObject::Connection > mActiveConnections
Definition board2dtab.h:235
void fsmSetViewCursor(const std::optional< Qt::CursorShape > &shape) noexcept override
Definition board2dtab.cpp:935
bool processSceneScrolled(const QPointF &pos, slint::private_api::PointerScrollEvent e) noexcept override
Definition board2dtab.cpp:857
void execSpecctraImportDialog() noexcept
Definition board2dtab.cpp:2030
void execSpecctraExportDialog() noexcept
Definition board2dtab.cpp:1976
QScopedPointer< BoardEditorFsm > mFsm
Definition board2dtab.h:294
void fsmToolLeave() noexcept override
Definition board2dtab.cpp:1013
ProjectEditor & mProjectEditor
Definition board2dtab.h:229
void fsmAbortBlockingToolsInOtherEditors() noexcept override
Definition board2dtab.cpp:997
void valueRequested(const QString &value)
std::unique_ptr< QTimer > mInputIdleTimer
Definition board2dtab.h:299
void netRequested(bool autoNet, const std::optional< Uuid > &net)
std::shared_ptr< slint::VectorModel< slint::SharedString > > mUnplacedComponentFootprintsModel
Definition board2dtab.h:283
std::unique_ptr< GraphicsLayerList > mUnplacedComponentLayers
Definition board2dtab.h:285
Board2dTab(const Board2dTab &other)=delete
QSet< const Layer * > getVisibleCopperLayers() const noexcept
Definition board2dtab.cpp:871
void requestRepaint() noexcept
Definition board2dtab.cpp:2167
bool processScenePointerEvent(const QPointF &pos, slint::private_api::PointerEvent e) noexcept override
Definition board2dtab.cpp:848
void goToDevice(const QString &name, int index) noexcept
Definition board2dtab.cpp:2101
bool graphicsSceneKeyPressed(const GraphicsSceneKeyEvent &e) noexcept override
Definition board2dtab.cpp:887
Board & mBoard
Definition board2dtab.h:232
std::unique_ptr< BoardGraphicsScene > mScene
Definition board2dtab.h:298
std::unique_ptr< GraphicsScene > mUnplacedComponentGraphicsScene
Definition board2dtab.h:286
QPainterPath fsmCalcPosWithTolerance(const Point &pos, qreal multiplier) const noexcept override
Definition board2dtab.cpp:978
std::shared_ptr< GraphicsLayersModel > mLayersModel
Definition board2dtab.h:297
void setSelectedUnplacedComponentDevice(int index) noexcept
Definition board2dtab.cpp:1566
SearchContext mSearchContext
Definition board2dtab.h:242
void setUiData(const ui::TabData &data) noexcept override
Definition board2dtab.cpp:305
QVector< QMetaObject::Connection > mFsmStateConnections
Definition board2dtab.h:293
std::unique_ptr< FootprintGraphicsItem > mUnplacedComponentGraphicsItem
Definition board2dtab.h:287
bool processSceneKeyEvent(const slint::private_api::KeyEvent &e) noexcept override
Definition board2dtab.cpp:862
void clearDrcMarker() noexcept
Definition board2dtab.cpp:1466
PlaceComponentsMode
Definition board2dtab.h:89
void fsmSetViewGrayOut(bool grayOut) noexcept override
Definition board2dtab.cpp:945
void fsmSetViewRuler(const std::optional< std::pair< Point, Point > > &pos) noexcept override
Definition board2dtab.cpp:964
QHash< Uuid, Uuid > mLastFootprintOfPackage
Definition board2dtab.h:289
void fsmSetViewInfoBoxText(const QString &text) noexcept override
Definition board2dtab.cpp:951
Project & mProject
Definition board2dtab.h:230
const Layer * mToolLayer
Definition board2dtab.h:259
QList< DeviceMetadata > mUnplacedComponentDevices
Definition board2dtab.h:276
void execD356NetlistExportDialog() noexcept
Definition board2dtab.cpp:1951
std::shared_ptr< slint::VectorModel< slint::SharedString > > mToolNets
Definition board2dtab.h:255
int getProjectObjectIndex() const noexcept
Definition board2dtab.cpp:261
BoardEditor & mBoardEditor
Definition board2dtab.h:231
Qt::CursorShape mToolCursorShape
Definition board2dtab.h:251
std::unique_ptr< QTimer > mUnplacedComponentsUpdateTimer
Definition board2dtab.h:290
void fsmSetStatusBarMessage(const QString &message, int timeoutMs=-1) noexcept override
Definition board2dtab.cpp:1001
bool mUnplacedComponentPackageOwned
Definition board2dtab.h:281
void storeLayersVisibility() noexcept
Definition board2dtab.cpp:1416
Point fsmMapGlobalPosToScenePos(const QPoint &pos) const noexcept override
Definition board2dtab.cpp:983
void trigger(ui::TabAction a) noexcept override
Definition board2dtab.cpp:534
void deactivate() noexcept override
Definition board2dtab.cpp:516
void setSelectedUnplacedComponent(int index) noexcept
Definition board2dtab.cpp:1531
DismissableMessageContext mMsgPlaceDevices
Definition board2dtab.h:239
void mirroredRequested(bool mirrored)
void setDerivedUiData(const ui::Board2dTabData &data) noexcept
Definition board2dtab.cpp:376
void highlightDrcMessage(const std::shared_ptr< const RuleCheckMessage > &msg, bool zoomTo) noexcept
Definition board2dtab.cpp:1439
void updateMessages() noexcept
Definition board2dtab.cpp:1426
int mUnplacedComponentDeviceIndex
Definition board2dtab.h:279
void fsmSetHighlightedNetSignals(const QSet< const NetSignal * > &sigs) noexcept override
Definition board2dtab.cpp:992
bool mToolMirrored
Definition board2dtab.h:264
void restartIdleTimer() noexcept
Definition board2dtab.cpp:1525
QString mToolOverlayText
Definition board2dtab.h:252
ui::TabData getUiData() const noexcept override
Definition board2dtab.cpp:265
bool graphicsSceneKeyReleased(const GraphicsSceneKeyEvent &e) noexcept override
Definition board2dtab.cpp:892
void execGraphicsExportDialog(GraphicsExportDialog::Output output, const QString &settingsKey) noexcept
Definition board2dtab.cpp:1893
bool mToolFilled
Definition board2dtab.h:263
QHash< Uuid, Uuid > mLastDeviceOfComponent
Definition board2dtab.h:288
void wireModeRequested(BoardEditorState_DrawTrace::WireMode mode)
void filledRequested(bool filled)
ui::EditorTool mTool
Definition board2dtab.h:250
void fsmSetFeatures(Features features) noexcept override
Definition board2dtab.cpp:1006
LengthEditContext mToolLineWidth
Definition board2dtab.h:260
int getProjectIndex() const noexcept
Definition board2dtab.cpp:257
bool graphicsSceneLeftMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition board2dtab.cpp:908
QVector< const Layer * > mToolLayersQt
Definition board2dtab.h:257
void activate() noexcept override
Definition board2dtab.cpp:453
void zoneRuleRequested(Zone::Rule rule, bool enable)
QList< Uuid > mUnplacedComponents
Definition board2dtab.h:271
void fsmToolEnter(BoardEditorState_Select &state) noexcept override
Definition board2dtab.cpp:1022
void loadLayersVisibility() noexcept
Definition board2dtab.cpp:1408
Interface for the integration of the board editor FSM.
Definition boardeditorfsmadapter.h:63
The board editor finite state machine.
Definition boardeditorfsm.h:57
The BoardEditor class.
Definition boardeditor.h:58
The "add device" state/tool of the board editor.
Definition boardeditorstate_adddevice.h:53
The "add hole" state/tool of the board editor.
Definition boardeditorstate_addhole.h:52
The "add stroke text" state/tool of the board editor.
Definition boardeditorstate_addstroketext.h:52
The "add via" state/tool of the board editor.
Definition boardeditorstate_addvia.h:54
The "draw plane" state/tool of the board editor.
Definition boardeditorstate_drawplane.h:54
The "draw polygon" state/tool of the board editor.
Definition boardeditorstate_drawpolygon.h:52
The "draw trace" state/tool of the board editor.
Definition boardeditorstate_drawtrace.h:55
The "draw zone" state/tool of the board editor.
Definition boardeditorstate_drawzone.h:55
The "measure" state/tool of the board editor.
Definition boardeditorstate_measure.h:45
The "select" state/tool of the board editor (default state)
Definition boardeditorstate_select.h:69
The BoardGraphicsScene class.
Definition boardgraphicsscene.h:77
A handle to a optionally dismissable message in the UI.
Definition dismissablemessagecontext.h:53
The FootprintGraphicsItem class.
Definition footprintgraphicsitem.h:66
This class provides a Dialog (GUI) to choose DXF import settings.
Definition graphicsexportdialog.h:61
The GraphicsLayerList class.
Definition graphicslayerlist.h:48
The GraphicsLayersModel class.
Definition graphicslayersmodel.h:48
The GraphicsScene class.
Definition graphicsscene.h:64
The GuiApplication class.
Definition guiapplication.h:61
The IF_GraphicsViewEventHandler class.
Definition if_graphicsvieweventhandler.h:45
Backend configuration for the LengthEdit UI element.
Definition lengtheditcontext.h:49
The ProjectEditor class.
Definition projecteditor.h:63
The SearchContext class.
Definition searchcontext.h:43
The SlintGraphicsView class.
Definition slintgraphicsview.h:51
The WindowTab class.
Definition windowtab.h:51
Definition occmodel.cpp:77
Definition uuid.h:186
QString packageName
Package library element name.
Definition board2dtab.h:82
Uuid packageUuid
Package library element UUID.
Definition board2dtab.h:79
Uuid deviceUuid
Device library element UUID.
Definition board2dtab.h:73
QString deviceName
Device library element name.
Definition board2dtab.h:76
bool isListedInComponentInstance
Definition board2dtab.h:86
Definition graphicsscene.h:52
Definition graphicsscene.h:45