LibrePCB Developers Documentation
Loading...
Searching...
No Matches
projecteditor.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_PROJECTEDITOR_H
21#define LIBREPCB_EDITOR_PROJECTEDITOR_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
30
31#include <QtCore>
32#include <QtWidgets>
33
34#include <memory>
35#include <optional>
36
37/*******************************************************************************
38 * Namespace / Forward Declarations
39 ******************************************************************************/
40
41class QMainWindow;
42
43namespace librepcb {
44
45class Board;
46class ComponentInstance;
47class FilePath;
48class LengthUnit;
49class Project;
50class Workspace;
51
52namespace editor {
53
54class BoardEditor;
55class MenuBuilder;
56class SchematicEditor;
57class UndoStack;
58
59/*******************************************************************************
60 * Class ProjectEditor
61 ******************************************************************************/
62
66class ProjectEditor final : public QObject {
67 Q_OBJECT
68
69public:
70 // Constructors / Destructor
71 ProjectEditor() = delete;
72 ProjectEditor(const Project& other) = delete;
73
77 ProjectEditor(Workspace& workspace, Project& project,
78 const std::optional<QList<FileFormatMigration::Message>>&
79 upgradeMessages);
80
84 ~ProjectEditor() noexcept;
85
86 // Getters: General
87
88 Workspace& getWorkspace() const noexcept { return mWorkspace; }
89 Project& getProject() const noexcept { return mProject; }
90 const QString& getUpgradeMessageLabelText() const noexcept {
92 }
93 const LengthUnit& getDefaultLengthUnit() const noexcept;
94
100 UndoStack& getUndoStack() const noexcept { return *mUndoStack; }
101
103 const ComponentInstance& cmp,
104 const std::optional<Uuid>& filterDev = std::nullopt) const noexcept;
105
106 // General Methods
107
109 const std::optional<Uuid>& filterDev,
110 QPointer<QWidget> editor, QMenu* root) const noexcept;
111
123 void abortBlockingToolsInOtherEditors(QWidget* editor) noexcept;
124
143 bool windowIsAboutToClose(QMainWindow& window) noexcept;
144
145 // Operator Overloadings
146 ProjectEditor& operator=(const Project& rhs) = delete;
147
148public slots:
149
155 void showUpgradeMessages(QWidget* parent) noexcept;
156
165 void showAllRequiredEditors() noexcept;
166
170 void showSchematicEditor() noexcept;
171
175 void showBoardEditor() noexcept;
176
182 void execLppzExportDialog(QWidget* parent = nullptr) noexcept;
183
189 void execOrderPcbDialog(QWidget* parent = nullptr) noexcept;
190
198 bool saveProject() noexcept;
199
207 bool autosaveProject() noexcept;
208
235 bool closeAndDestroy(bool askForSave, QWidget* msgBoxParent = 0) noexcept;
236
242 }
243
251 bool approve) noexcept;
252
253 std::shared_ptr<const QSet<const NetSignal*>> getHighlightedNetSignals()
254 const noexcept {
256 }
258 const QSet<const NetSignal*>& netSignals) noexcept;
259 void clearHighlightedNetSignals() noexcept;
260
261signals:
262 void ercFinished(const RuleCheckMessageList& messages);
269 void showTemporaryStatusBarMessage(const QString& message, int timeoutMs);
270
271private: // Methods
272 void runErc() noexcept;
273 void saveErcMessageApprovals(const QSet<SExpression>& approvals) noexcept;
274 int getCountOfVisibleEditorWindows() const noexcept;
275 void searchAndOpenDatasheet(const QString& mpn, const QString& manufacturer,
276 QPointer<QWidget> parent) const noexcept;
277
278private: // Data
283
287
291
292 std::shared_ptr<QSet<const NetSignal*>> mHighlightedNetSignals;
293
297
300
303};
304
305/*******************************************************************************
306 * End of File
307 ******************************************************************************/
308
309} // namespace editor
310} // namespace librepcb
311
312#endif
The ComponentInstance class.
Definition componentinstance.h:54
Base class for any file format migration.
Definition fileformatmigration.h:46
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition lengthunit.h:60
The NetSignal class.
Definition netsignal.h:50
The Project class represents a whole (opened) project with all its content.
Definition project.h:71
The RuleCheckMessage class.
Definition rulecheckmessage.h:45
The SExpression class.
Definition sexpression.h:69
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition workspace.h:54
The BoardEditor class.
Definition boardeditor.h:79
Helper to easily create a QMenu.
Definition menubuilder.h:42
The ProjectEditor class.
Definition projecteditor.h:66
const LengthUnit & getDefaultLengthUnit() const noexcept
Definition projecteditor.cpp:154
BoardEditor * mBoardEditor
The board editor (GUI)
Definition projecteditor.h:296
void setErcMessageApproved(const RuleCheckMessage &msg, bool approve) noexcept
Approve/unapprove an ERC message.
Definition projecteditor.cpp:582
void execLppzExportDialog(QWidget *parent=nullptr) noexcept
Execute the *.lppz export dialog (blocking!)
Definition projecteditor.cpp:429
void showTemporaryStatusBarMessage(const QString &message, int timeoutMs)
void showUpgradeMessages(QWidget *parent) noexcept
Show a dialog with all project file format upgrade messages.
Definition projecteditor.cpp:341
void addResourcesToMenu(MenuBuilder &mb, const ComponentInstance &cmp, const std::optional< Uuid > &filterDev, QPointer< QWidget > editor, QMenu *root) const noexcept
Definition projecteditor.cpp:230
bool mManualModificationsMade
Modifications bypassing the undo stack.
Definition projecteditor.h:302
void showBoardEditor() noexcept
Open the board editor window and bring it to the front.
Definition projecteditor.cpp:423
void openProjectLibraryUpdaterClicked(const FilePath &fp)
bool closeAndDestroy(bool askForSave, QWidget *msgBoxParent=0) noexcept
Close the project (this will destroy this object!)
Definition projecteditor.cpp:545
ProjectEditor & operator=(const Project &rhs)=delete
void execOrderPcbDialog(QWidget *parent=nullptr) noexcept
Execute the PCB order dialog (blocking!)
Definition projecteditor.cpp:468
bool saveProject() noexcept
Save the whole project to the harddisc.
Definition projecteditor.cpp:487
std::shared_ptr< const QSet< const NetSignal * > > getHighlightedNetSignals() const noexcept
Definition projecteditor.h:253
void setManualModificationsMade() noexcept
Set the flag that manual modifications (no undo stack) are made.
Definition projecteditor.h:240
Workspace & getWorkspace() const noexcept
Definition projecteditor.h:88
const QString & getUpgradeMessageLabelText() const noexcept
Definition projecteditor.h:90
SchematicEditor * mSchematicEditor
The schematic editor (GUI)
Definition projecteditor.h:295
void ercFinished(const RuleCheckMessageList &messages)
void setHighlightedNetSignals(const QSet< const NetSignal * > &netSignals) noexcept
Definition projecteditor.cpp:593
Project & getProject() const noexcept
Definition projecteditor.h:89
Project & mProject
Definition projecteditor.h:280
QTimer mAutoSaveTimer
Definition projecteditor.h:286
void showAllRequiredEditors() noexcept
Open the schematic and/or the board editor window.
Definition projecteditor.cpp:400
bool windowIsAboutToClose(QMainWindow &window) noexcept
Inform the editor that a project related window is about to close.
Definition projecteditor.cpp:325
std::shared_ptr< QSet< const NetSignal * > > mHighlightedNetSignals
Definition projecteditor.h:292
void saveErcMessageApprovals(const QSet< SExpression > &approvals) noexcept
Definition projecteditor.cpp:631
Workspace & mWorkspace
Definition projecteditor.h:279
int getCountOfVisibleEditorWindows() const noexcept
Definition projecteditor.cpp:638
bool autosaveProject() noexcept
Make a automatic backup of the project (save to temporary files)
Definition projecteditor.cpp:515
ResourceList getComponentResources(const ComponentInstance &cmp, const std::optional< Uuid > &filterDev=std::nullopt) const noexcept
Definition projecteditor.cpp:158
QSet< SExpression > mSupportedErcApprovals
Definition projecteditor.h:288
QList< FileFormatMigration::Message > mUpgradeMessages
Definition projecteditor.h:281
void clearHighlightedNetSignals() noexcept
Definition projecteditor.cpp:601
UndoStack & getUndoStack() const noexcept
Get a reference to the undo stack of the project.
Definition projecteditor.h:100
QString mUpgradeMessageLabelText
Definition projecteditor.h:282
void searchAndOpenDatasheet(const QString &mpn, const QString &manufacturer, QPointer< QWidget > parent) const noexcept
Definition projecteditor.cpp:649
void runErc() noexcept
Definition projecteditor.cpp:609
ProjectEditor(const Project &other)=delete
UndoStack * mUndoStack
See The undo/redo system (Command Design Pattern).
Definition projecteditor.h:294
~ProjectEditor() noexcept
The destructor.
Definition projecteditor.cpp:123
uint mLastAutosaveStateId
The UndoStack state ID of the last successful project (auto)save.
Definition projecteditor.h:299
QSet< SExpression > mDisappearedErcApprovals
Definition projecteditor.h:289
void abortBlockingToolsInOtherEditors(QWidget *editor) noexcept
Abort any active (blocking) tools in other editors.
Definition projecteditor.cpp:314
void showSchematicEditor() noexcept
Open the schematic editor window and bring it to the front.
Definition projecteditor.cpp:417
RuleCheckMessageList mErcMessages
Definition projecteditor.h:290
The SchematicEditor class.
Definition schematiceditor.h:73
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition undostack.h:106
Definition occmodel.cpp:76
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition rulecheckmessage.h:104
Definition uuid.h:186