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 ******************************************************************************/
26#include "../utils/uiobjectlist.h"
27#include "appwindow.h"
28
32
33#include <QtCore>
34
35#include <memory>
36
37/*******************************************************************************
38 * Namespace / Forward Declarations
39 ******************************************************************************/
40namespace librepcb {
41
42class Board;
43class NetSignal;
44class Project;
45class Workspace;
46
47namespace editor {
48
49class BoardEditor;
50class GuiApplication;
51class RuleCheckMessagesModel;
52class SchematicEditor;
53class SchematicTab;
54class UndoStack;
55
56/*******************************************************************************
57 * Class ProjectEditor
58 ******************************************************************************/
59
63class ProjectEditor final : public QObject {
64 Q_OBJECT
65
66public:
67 // Signals
69
70 // Constructors / Destructor
71 ProjectEditor() = delete;
72 ProjectEditor(const ProjectEditor& other) = delete;
73 explicit ProjectEditor(
74 GuiApplication& app, std::unique_ptr<Project> project, int uiIndex,
75 const std::optional<QList<FileFormatMigration::Message>>& upgradeMessages,
76 QObject* parent = nullptr) noexcept;
77 ~ProjectEditor() noexcept;
78
79 // General Methods
80 GuiApplication& getApp() noexcept { return mApp; }
81 Workspace& getWorkspace() noexcept { return mWorkspace; }
82 Project& getProject() noexcept { return *mProject; }
83 UndoStack& getUndoStack() noexcept { return *mUndoStack; }
84 const QVector<std::shared_ptr<SchematicEditor>>& getSchematics() noexcept {
85 return mSchematics->values();
86 }
87 const QVector<std::shared_ptr<BoardEditor>>& getBoards() noexcept {
88 return mBoards->values();
89 }
90 int getUiIndex() const noexcept { return mUiIndex; }
91 void setUiIndex(int index) noexcept;
92 ui::ProjectData getUiData() const noexcept;
93 void setUiData(const ui::ProjectData& data) noexcept;
94 void trigger(ui::ProjectAction a) noexcept;
95 bool getUseIeee315Symbols() const noexcept { return mUseIeee315Symbols; }
96 std::shared_ptr<const QSet<const NetSignal*>> getHighlightedNetSignals()
97 const noexcept {
99 }
101 const QSet<const NetSignal*>& netSignals) noexcept;
102
103 bool hasUnsavedChanges() const noexcept;
104
105 void undo() noexcept;
106 void redo() noexcept;
107
120 bool requestClose() noexcept;
121
129 bool saveProject() noexcept;
130
138 bool autosaveProject() noexcept;
139
143 void setManualModificationsMade() noexcept;
144
145 void execSetupDialog() noexcept;
146
147 void execOutputJobsDialog(const QString& typeName = QString()) noexcept;
148
149 void execBomGeneratorDialog(const Board* board) noexcept;
150
156 void execLppzExportDialog(QWidget* parent) noexcept;
157
158 std::shared_ptr<SchematicEditor> execNewSheetDialog() noexcept;
159 void execRenameSheetDialog(int index) noexcept;
160 void execDeleteSheetDialog(int index) noexcept;
161
163 std::optional<int> copyFromIndex) noexcept;
164 void execDeleteBoardDialog(int index) noexcept;
165
166 void registerActiveSchematicTab(SchematicTab* tab) noexcept;
167 void unregisterActiveSchematicTab(SchematicTab* tab) noexcept;
168
169 // Operator Overloadings
170 ProjectEditor& operator=(const ProjectEditor& rhs) = delete;
171
172signals:
180 void statusBarMessageChanged(const QString& message, int timeoutMs);
181
195 void abortBlockingToolsInOtherEditors(const void* source);
196
197private:
201 void showUpgradeMessages() noexcept;
202 void scheduleErcRun() noexcept;
203 void runErc() noexcept;
204 void projectSettingsChanged() noexcept;
205
206private:
209 std::unique_ptr<Project> mProject;
213 std::shared_ptr<UiObjectList<SchematicEditor, ui::SchematicData>> mSchematics;
214 std::shared_ptr<UiObjectList<BoardEditor, ui::BoardData>> mBoards;
216
217 std::shared_ptr<QSet<const NetSignal*>> mHighlightedNetSignals;
219
220 // ERC
221 std::shared_ptr<RuleCheckMessagesModel> mErcMessages; // Lazy initialized
225 QTimer mErcTimer;
226
229
232
236};
237
238/*******************************************************************************
239 * End of File
240 ******************************************************************************/
241
242} // namespace editor
243} // namespace librepcb
244
245#endif
The Board class represents a PCB of a project and is always part of a circuit.
Definition board.h:73
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 NetSignal class.
Definition netsignal.h:50
The Project class represents a whole (opened) project with all its content.
Definition project.h:71
The SExpression class.
Definition sexpression.h:69
The Signal class is used to emit signals on non-QObject derived classes.
Definition signalslot.h:65
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition workspace.h:54
The BoardEditor class.
Definition boardeditor.h:58
The GuiApplication class.
Definition guiapplication.h:61
The ProjectEditor class.
Definition projecteditor.h:63
std::shared_ptr< SchematicEditor > execNewSheetDialog() noexcept
Definition projecteditor.cpp:513
ui::ProjectData getUiData() const noexcept
Definition projecteditor.cpp:242
Signal< ProjectEditor > onUiDataChanged
Definition projecteditor.h:68
void projectSettingsChanged() noexcept
Definition projecteditor.cpp:761
void execLppzExportDialog(QWidget *parent) noexcept
Execute the *.lppz export dialog (blocking)
Definition projecteditor.cpp:473
std::unique_ptr< UndoStack > mUndoStack
Definition projecteditor.h:215
void redo() noexcept
Definition projecteditor.cpp:337
bool mUseIeee315Symbols
Definition projecteditor.h:211
std::shared_ptr< RuleCheckMessagesModel > mErcMessages
Definition projecteditor.h:221
void scheduleErcRun() noexcept
Definition projecteditor.cpp:721
bool mManualModificationsMade
Modifications bypassing the undo stack.
Definition projecteditor.h:228
void execRenameSheetDialog(int index) noexcept
Definition projecteditor.cpp:545
Workspace & getWorkspace() noexcept
Definition projecteditor.h:81
ProjectEditor(const ProjectEditor &other)=delete
UndoStack & getUndoStack() noexcept
Definition projecteditor.h:83
bool saveProject() noexcept
Save the whole project to the harddisc.
Definition projecteditor.cpp:368
std::unique_ptr< Project > mProject
Definition projecteditor.h:209
int mUiIndex
Definition projecteditor.h:210
void statusBarMessageChanged(const QString &message, int timeoutMs)
std::shared_ptr< const QSet< const NetSignal * > > getHighlightedNetSignals() const noexcept
Definition projecteditor.h:96
void setUiData(const ui::ProjectData &data) noexcept
Definition projecteditor.cpp:265
void projectLibraryUpdaterRequested(const FilePath &fp)
void setManualModificationsMade() noexcept
Set the flag that manual modifications (no undo stack) are made.
Definition projecteditor.cpp:438
QVector< QPointer< SchematicTab > > mActiveSchematicTabs
Definition projecteditor.h:218
GuiApplication & getApp() noexcept
Definition projecteditor.h:80
QTimer mErcTimer
Definition projecteditor.h:225
void setUiIndex(int index) noexcept
Definition projecteditor.cpp:235
void setHighlightedNetSignals(const QSet< const NetSignal * > &netSignals) noexcept
Definition projecteditor.cpp:317
void unregisterActiveSchematicTab(SchematicTab *tab) noexcept
Definition projecteditor.cpp:654
QString mErcExecutionError
Definition projecteditor.h:224
QTimer mAutoSaveTimer
Definition projecteditor.h:235
std::shared_ptr< QSet< const NetSignal * > > mHighlightedNetSignals
Definition projecteditor.h:217
bool hasUnsavedChanges() const noexcept
Definition projecteditor.cpp:325
int getUiIndex() const noexcept
Definition projecteditor.h:90
void trigger(ui::ProjectAction a) noexcept
Definition projecteditor.cpp:269
std::shared_ptr< UiObjectList< BoardEditor, ui::BoardData > > mBoards
Definition projecteditor.h:214
void execDeleteSheetDialog(int index) noexcept
Definition projecteditor.cpp:566
Workspace & mWorkspace
Definition projecteditor.h:208
void showUpgradeMessages() noexcept
Show a dialog with all project file format upgrade messages.
Definition projecteditor.cpp:662
Project & getProject() noexcept
Definition projecteditor.h:82
bool autosaveProject() noexcept
Make a automatic backup of the project (save to temporary files)
Definition projecteditor.cpp:401
void undo() noexcept
Definition projecteditor.cpp:329
QSet< SExpression > mSupportedErcApprovals
Definition projecteditor.h:222
std::shared_ptr< UiObjectList< SchematicEditor, ui::SchematicData > > mSchematics
Definition projecteditor.h:213
void execBomGeneratorDialog(const Board *board) noexcept
Definition projecteditor.cpp:465
QList< FileFormatMigration::Message > mUpgradeMessages
Definition projecteditor.h:212
const QVector< std::shared_ptr< SchematicEditor > > & getSchematics() noexcept
Definition projecteditor.h:84
bool requestClose() noexcept
Request to close the project.
Definition projecteditor.cpp:345
void registerActiveSchematicTab(SchematicTab *tab) noexcept
Definition projecteditor.cpp:645
void execSetupDialog() noexcept
Definition projecteditor.cpp:446
std::shared_ptr< BoardEditor > execNewBoardDialog(std::optional< int > copyFromIndex) noexcept
Definition projecteditor.cpp:579
void runErc() noexcept
Definition projecteditor.cpp:725
bool getUseIeee315Symbols() const noexcept
Definition projecteditor.h:95
uint mLastAutosaveStateId
The UndoStack state ID of the last successful project (auto)save.
Definition projecteditor.h:231
QSet< SExpression > mDisappearedErcApprovals
Definition projecteditor.h:223
void abortBlockingToolsInOtherEditors(const void *source)
Abort any active (blocking) tools in other editors.
void execDeleteBoardDialog(int index) noexcept
Definition projecteditor.cpp:626
void execOutputJobsDialog(const QString &typeName=QString()) noexcept
Definition projecteditor.cpp:452
GuiApplication & mApp
Definition projecteditor.h:207
const QVector< std::shared_ptr< BoardEditor > > & getBoards() noexcept
Definition projecteditor.h:87
The RuleCheckMessagesModel class.
Definition rulecheckmessagesmodel.h:46
The SchematicEditor class.
Definition schematiceditor.h:50
The SchematicTab class.
Definition schematictab.h:62
The UiObjectList class.
Definition uiobjectlist.h:47
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition undostack.h:106
Definition occmodel.cpp:77
Definition uuid.h:186