LibrePCB Developers Documentation
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 ******************************************************************************/
29#include <optional/tl/optional.hpp>
30
31#include <QtCore>
32
33#include <memory>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38
39class QMainWindow;
40
41namespace librepcb {
42
43class Board;
44class FilePath;
45class LengthUnit;
46class Project;
47class Workspace;
48
49namespace editor {
50
51class BoardEditor;
52class SchematicEditor;
53class UndoStack;
54
55/*******************************************************************************
56 * Class ProjectEditor
57 ******************************************************************************/
58
62class ProjectEditor final : public QObject {
63 Q_OBJECT
64
65public:
66 // Constructors / Destructor
67 ProjectEditor() = delete;
68 ProjectEditor(const Project& other) = delete;
69
74 Workspace& workspace, Project& project,
75 const tl::optional<QList<FileFormatMigration::Message>>& upgradeMessages);
76
80 ~ProjectEditor() noexcept;
81
82 // Getters: General
83
84 Workspace& getWorkspace() const noexcept { return mWorkspace; }
85 Project& getProject() const noexcept { return mProject; }
86 const QString& getUpgradeMessageLabelText() const noexcept {
88 }
89 const LengthUnit& getDefaultLengthUnit() const noexcept;
90
96 UndoStack& getUndoStack() const noexcept { return *mUndoStack; }
97
98 // General Methods
99
111 void abortBlockingToolsInOtherEditors(QWidget* editor) noexcept;
112
131 bool windowIsAboutToClose(QMainWindow& window) noexcept;
132
133 // Operator Overloadings
134 ProjectEditor& operator=(const Project& rhs) = delete;
135
136public slots:
137
143 void showUpgradeMessages(QWidget* parent) noexcept;
144
153 void showAllRequiredEditors() noexcept;
154
158 void showSchematicEditor() noexcept;
159
163 void showBoardEditor() noexcept;
164
170 void execLppzExportDialog(QWidget* parent = nullptr) noexcept;
171
177 void execOrderPcbDialog(QWidget* parent = nullptr) noexcept;
178
186 bool saveProject() noexcept;
187
195 bool autosaveProject() noexcept;
196
223 bool closeAndDestroy(bool askForSave, QWidget* msgBoxParent = 0) noexcept;
224
230 }
231
239 bool approve) noexcept;
240
241 std::shared_ptr<const QSet<const NetSignal*>> getHighlightedNetSignals()
242 const noexcept {
244 }
246 const QSet<const NetSignal*>& netSignals) noexcept;
247 void clearHighlightedNetSignals() noexcept;
248
249signals:
250 void ercFinished(const RuleCheckMessageList& messages);
257 void showTemporaryStatusBarMessage(const QString& message, int timeoutMs);
258
259private: // Methods
260 void runErc() noexcept;
261 void saveErcMessageApprovals(const QSet<SExpression>& approvals) noexcept;
262 int getCountOfVisibleEditorWindows() const noexcept;
263
264private: // Data
269
273
277
278 std::shared_ptr<QSet<const NetSignal*>> mHighlightedNetSignals;
279
283
286
289};
290
291/*******************************************************************************
292 * End of File
293 ******************************************************************************/
294
295} // namespace editor
296} // namespace librepcb
297
298#endif
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:129
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
The ProjectEditor class.
Definition: projecteditor.h:62
const LengthUnit & getDefaultLengthUnit() const noexcept
Definition: projecteditor.cpp:144
BoardEditor * mBoardEditor
The board editor (GUI)
Definition: projecteditor.h:282
void setErcMessageApproved(const RuleCheckMessage &msg, bool approve) noexcept
Approve/unapprove an ERC message.
Definition: projecteditor.cpp:420
void execLppzExportDialog(QWidget *parent=nullptr) noexcept
Execute the *.lppz export dialog (blocking!)
Definition: projecteditor.cpp:267
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:179
bool mManualModificationsMade
Modifications bypassing the undo stack.
Definition: projecteditor.h:288
void showBoardEditor() noexcept
Open the board editor window and bring it to the front.
Definition: projecteditor.cpp:261
void openProjectLibraryUpdaterClicked(const FilePath &fp)
bool closeAndDestroy(bool askForSave, QWidget *msgBoxParent=0) noexcept
Close the project (this will destroy this object!)
Definition: projecteditor.cpp:383
ProjectEditor & operator=(const Project &rhs)=delete
void execOrderPcbDialog(QWidget *parent=nullptr) noexcept
Execute the PCB order dialog (blocking!)
Definition: projecteditor.cpp:306
bool saveProject() noexcept
Save the whole project to the harddisc.
Definition: projecteditor.cpp:325
std::shared_ptr< const QSet< const NetSignal * > > getHighlightedNetSignals() const noexcept
Definition: projecteditor.h:241
void setManualModificationsMade() noexcept
Set the flag that manual modifications (no undo stack) are made.
Definition: projecteditor.h:228
Workspace & getWorkspace() const noexcept
Definition: projecteditor.h:84
const QString & getUpgradeMessageLabelText() const noexcept
Definition: projecteditor.h:86
SchematicEditor * mSchematicEditor
The schematic editor (GUI)
Definition: projecteditor.h:281
void ercFinished(const RuleCheckMessageList &messages)
void setHighlightedNetSignals(const QSet< const NetSignal * > &netSignals) noexcept
Definition: projecteditor.cpp:431
Project & getProject() const noexcept
Definition: projecteditor.h:85
Project & mProject
Definition: projecteditor.h:266
QTimer mAutoSaveTimer
Definition: projecteditor.h:272
void showAllRequiredEditors() noexcept
Open the schematic and/or the board editor window.
Definition: projecteditor.cpp:238
bool windowIsAboutToClose(QMainWindow &window) noexcept
Inform the editor that a project related window is about to close.
Definition: projecteditor.cpp:163
std::shared_ptr< QSet< const NetSignal * > > mHighlightedNetSignals
Definition: projecteditor.h:278
void saveErcMessageApprovals(const QSet< SExpression > &approvals) noexcept
Definition: projecteditor.cpp:469
Workspace & mWorkspace
Definition: projecteditor.h:265
int getCountOfVisibleEditorWindows() const noexcept
Definition: projecteditor.cpp:476
bool autosaveProject() noexcept
Make a automatic backup of the project (save to temporary files)
Definition: projecteditor.cpp:353
QSet< SExpression > mSupportedErcApprovals
Definition: projecteditor.h:274
QList< FileFormatMigration::Message > mUpgradeMessages
Definition: projecteditor.h:267
void clearHighlightedNetSignals() noexcept
Definition: projecteditor.cpp:439
UndoStack & getUndoStack() const noexcept
Get a reference to the undo stack of the project.
Definition: projecteditor.h:96
QString mUpgradeMessageLabelText
Definition: projecteditor.h:268
void runErc() noexcept
Definition: projecteditor.cpp:447
ProjectEditor(const Project &other)=delete
UndoStack * mUndoStack
See The undo/redo system (Command Design Pattern).
Definition: projecteditor.h:280
~ProjectEditor() noexcept
The destructor.
Definition: projecteditor.cpp:113
uint mLastAutosaveStateId
The UndoStack state ID of the last successful project (auto)save.
Definition: projecteditor.h:285
QSet< SExpression > mDisappearedErcApprovals
Definition: projecteditor.h:275
void abortBlockingToolsInOtherEditors(QWidget *editor) noexcept
Abort any active (blocking) tools in other editors.
Definition: projecteditor.cpp:152
void showSchematicEditor() noexcept
Open the schematic editor window and bring it to the front.
Definition: projecteditor.cpp:255
RuleCheckMessageList mErcMessages
Definition: projecteditor.h:276
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:77
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition: rulecheckmessage.h:104