LibrePCB Developers Documentation
boardeditor.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_PROJECT_BOARDEDITOR_H
21 #define LIBREPCB_PROJECT_BOARDEDITOR_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
27 #include <librepcb/common/uuid.h>
30 
31 #include <QtCore>
32 #include <QtWidgets>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 
39 class GraphicsView;
40 class UndoStackActionGroup;
41 class ExclusiveActionGroup;
42 
43 namespace project {
44 
45 class Project;
46 class ComponentInstance;
47 
48 namespace editor {
49 
50 class ProjectEditor;
51 class ErcMsgDock;
52 class UnplacedComponentsDock;
53 class BoardLayersDock;
54 class BoardDesignRuleCheckMessagesDock;
55 class BES_FSM;
56 
57 namespace Ui {
58 class BoardEditor;
59 }
60 
61 /*******************************************************************************
62  * Class BoardEditor
63  ******************************************************************************/
64 
68 class BoardEditor final : public QMainWindow,
70  Q_OBJECT
71 
72 public:
73  // Constructors / Destructor
74  explicit BoardEditor(ProjectEditor& projectEditor, Project& project);
75  ~BoardEditor();
76 
77  // Getters
78  ProjectEditor& getProjectEditor() const noexcept { return mProjectEditor; }
79  Project& getProject() const noexcept { return mProject; }
80  Board* getActiveBoard() const noexcept { return mActiveBoard.data(); }
81 
82  // Setters
83  void setActiveBoardIndex(int index) noexcept;
84 
85  // General Methods
86  void abortAllCommands() noexcept;
87 
88 protected:
89  void closeEvent(QCloseEvent* event);
90 
91 public slots:
92 
93  void boardAdded(int newIndex);
94  void boardRemoved(int oldIndex);
95 
96 private slots:
97 
98  // Actions
99  void on_actionProjectClose_triggered();
100  void on_actionNewBoard_triggered();
101  void on_actionCopyBoard_triggered();
102  void on_actionRemoveBoard_triggered();
103  void on_actionGrid_triggered();
104  void on_actionPrint_triggered();
105  void on_actionExportAsPdf_triggered();
106  void on_actionExportAsSvg_triggered();
107  void on_actionGenerateFabricationData_triggered();
108  void on_actionGenerateBom_triggered();
109  void on_actionGeneratePickPlace_triggered();
110  void on_actionProjectProperties_triggered();
111  void on_actionUpdateLibrary_triggered();
112  void on_actionLayerStackSetup_triggered();
113  void on_actionModifyDesignRules_triggered();
114  void on_actionDesignRuleCheck_triggered();
115  void on_actionRebuildPlanes_triggered();
116  void on_actionShowAllPlanes_triggered();
117  void on_actionHideAllPlanes_triggered();
118  void on_tabBar_currentChanged(int index);
119  void on_lblUnplacedComponentsNote_linkActivated();
120  void boardListActionGroupTriggered(QAction* action);
121 
122 private:
123  // make some methods inaccessible...
124  BoardEditor() = delete;
125  BoardEditor(const BoardEditor& other) = delete;
126  BoardEditor& operator=(const BoardEditor& rhs) = delete;
127 
128  // Private Methods
129  bool graphicsViewEventHandler(QEvent* event);
130  void toolActionGroupChangeTriggered(const QVariant& newTool) noexcept;
131  void unplacedComponentsCountChanged(int count) noexcept;
132  void highlightDrcMessage(const BoardDesignRuleCheckMessage& msg,
133  bool zoomTo) noexcept;
134  void clearDrcMarker() noexcept;
135  QStringList getSearchToolBarCompleterList() noexcept;
136  void goToDevice(const QString& name) noexcept;
137 
138  // General Attributes
141  Ui::BoardEditor* mUi;
143  QScopedPointer<UndoStackActionGroup> mUndoStackActionGroup;
144  QScopedPointer<ExclusiveActionGroup> mToolsActionGroup;
145 
146  // DRC
148  QHash<Uuid, QList<BoardDesignRuleCheckMessage>>
150  QScopedPointer<QGraphicsPathItem> mDrcLocationGraphicsItem;
151 
152  // Misc
153  QPointer<Board> mActiveBoard;
154  QList<QAction*> mBoardListActions;
155  QActionGroup mBoardListActionGroup;
156 
157  // Docks
161  QScopedPointer<BoardDesignRuleCheckMessagesDock> mDrcMessagesDock;
162 
163  // Finite State Machine
165 };
166 
167 /*******************************************************************************
168  * End of File
169  ******************************************************************************/
170 
171 } // namespace editor
172 } // namespace project
173 } // namespace librepcb
174 
175 #endif // LIBREPCB_PROJECT_BOARDEDITOR_H
QScopedPointer< BoardDesignRuleCheckMessagesDock > mDrcMessagesDock
Definition: boardeditor.h:161
ProjectEditor & getProjectEditor() const noexcept
Definition: boardeditor.h:78
Definition: boarddesignrulecheck.h:57
Definition: mainwindow.h:10
The BoardEditor class.
Definition: boardeditor.h:68
Definition: airwiresbuilder.cpp:32
QList< QAction * > mBoardListActions
Definition: boardeditor.h:154
BoardLayersDock * mBoardLayersDock
Definition: boardeditor.h:160
Project & mProject
Definition: boardeditor.h:140
QScopedPointer< ExclusiveActionGroup > mToolsActionGroup
Definition: boardeditor.h:144
The GraphicsView class.
Definition: graphicsview.h:47
The Project class represents a whole (opened) project with all its content.
Definition: project.h:80
Board * getActiveBoard() const noexcept
Definition: boardeditor.h:80
Ui::BoardEditor * mUi
Definition: boardeditor.h:141
QPointer< Board > mActiveBoard
Definition: boardeditor.h:153
The ErcMsgDock class.
Definition: ercmsgdock.h:52
The ProjectEditor class.
Definition: projecteditor.h:63
Project & getProject() const noexcept
Definition: boardeditor.h:79
GraphicsView * mGraphicsView
Definition: boardeditor.h:142
The BoardDesignRuleCheckMessage class represents a message produced by the design rule check (DRC) ...
Definition: boarddesignrulecheckmessage.h:44
The BoardLayersDock class.
Definition: boardlayersdock.h:57
The UnplacedComponentsDock class.
Definition: unplacedcomponentsdock.h:69
The BES_FSM (Board Editor Finite State Machine) class.
Definition: bes_fsm.h:44
UnplacedComponentsDock * mUnplacedComponentsDock
Definition: boardeditor.h:159
QActionGroup mBoardListActionGroup
Definition: boardeditor.h:155
ErcMsgDock * mErcMsgDock
Definition: boardeditor.h:158
BoardDesignRuleCheck::Options mDrcOptions
Definition: boardeditor.h:147
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:83
The IF_GraphicsViewEventHandler class.
Definition: if_graphicsvieweventhandler.h:40
ProjectEditor & mProjectEditor
Definition: boardeditor.h:139
QScopedPointer< UndoStackActionGroup > mUndoStackActionGroup
Definition: boardeditor.h:143
QScopedPointer< QGraphicsPathItem > mDrcLocationGraphicsItem
Definition: boardeditor.h:150
BES_FSM * mFsm
Definition: boardeditor.h:164
QHash< Uuid, QList< BoardDesignRuleCheckMessage > > mDrcMessages
Key: Board UUID.
Definition: boardeditor.h:149