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 RuleCheckMessage;
46class Workspace;
47
48namespace editor {
49
50class BoardEditor;
51class GuiApplication;
52class RuleCheckMessagesModel;
53class SchematicEditor;
54class SchematicTab;
55class UndoStack;
56
57/*******************************************************************************
58 * Class ProjectEditor
59 ******************************************************************************/
60
64class ProjectEditor final : public QObject {
65 Q_OBJECT
66
67public:
68 // Signals
70
71 // Constructors / Destructor
72 ProjectEditor() = delete;
73 ProjectEditor(const ProjectEditor& other) = delete;
74 explicit ProjectEditor(
75 GuiApplication& app, std::unique_ptr<Project> project, int uiIndex,
76 const std::optional<ProjectLoader::MigrationLog>& migrationLog,
77 QObject* parent = nullptr) noexcept;
78 ~ProjectEditor() noexcept;
79
80 // General Methods
81 GuiApplication& getApp() noexcept { return mApp; }
82 Workspace& getWorkspace() noexcept { return mWorkspace; }
83 Project& getProject() noexcept { return *mProject; }
84 UndoStack& getUndoStack() noexcept { return *mUndoStack; }
85 const QVector<std::shared_ptr<SchematicEditor>>& getSchematics() noexcept {
86 return mSchematics->values();
87 }
88 const QVector<std::shared_ptr<BoardEditor>>& getBoards() noexcept {
89 return mBoards->values();
90 }
91 int getUiIndex() const noexcept { return mUiIndex; }
92 void setUiIndex(int index) noexcept;
93 ui::ProjectData getUiData() const noexcept;
94 void setUiData(const ui::ProjectData& data) noexcept;
95 void trigger(ui::ProjectAction a) noexcept;
96 bool getUseIeee315Symbols() const noexcept { return mUseIeee315Symbols; }
97 std::shared_ptr<const QSet<const NetSignal*>> getHighlightedNetSignals()
98 const noexcept {
100 }
102 const QSet<const NetSignal*>& netSignals) noexcept;
103
104 bool hasUnsavedChanges() const noexcept;
105
106 void undo() noexcept;
107 void redo() noexcept;
108
121 bool requestClose() noexcept;
122
130 bool saveProject() noexcept;
131
139 bool autosaveProject() noexcept;
140
144 void setManualModificationsMade() noexcept;
145
146 void execSetupDialog() noexcept;
147
148 void execOutputJobsDialog(const QString& typeName = QString()) noexcept;
149
150 void execBomReviewDialog(const Board* board) noexcept;
151
157 void execLppzExportDialog(QWidget* parent) noexcept;
158
159 std::shared_ptr<SchematicEditor> execNewSheetDialog() noexcept;
160 void execRenameSheetDialog(int index) noexcept;
161 void execDeleteSheetDialog(int index) noexcept;
162
164 std::optional<int> copyFromIndex) noexcept;
165 void execDeleteBoardDialog(int index) noexcept;
166
167 void registerActiveSchematicTab(SchematicTab* tab) noexcept;
168 void unregisterActiveSchematicTab(SchematicTab* tab) noexcept;
169
170 // Operator Overloadings
171 ProjectEditor& operator=(const ProjectEditor& rhs) = delete;
172
173signals:
180 bool zoomTo, int windowId);
184 void statusBarMessageChanged(const QString& message, int timeoutMs);
185
199 void abortBlockingToolsInOtherEditors(const void* source);
200
201private:
205 void openMigrationLog() noexcept;
206 void scheduleErcRun() noexcept;
207 void runErc() noexcept;
208 void projectSettingsChanged() noexcept;
209 void refreshBuses() noexcept;
210
211private:
214 std::unique_ptr<Project> mProject;
217 std::optional<ProjectLoader::MigrationLog> mMigrationLog;
218 std::shared_ptr<slint::VectorModel<ui::BusData>> mBuses; // Lazy initialized
219 std::shared_ptr<UiObjectList<SchematicEditor, ui::SchematicData>> mSchematics;
220 std::shared_ptr<UiObjectList<BoardEditor, ui::BoardData>> mBoards;
222
223 std::shared_ptr<QSet<const NetSignal*>> mHighlightedNetSignals;
225
226 // ERC
227 std::shared_ptr<RuleCheckMessagesModel> mErcMessages; // Lazy initialized
231 QTimer mErcTimer;
232
235
238
242
245 QVector<QMetaObject::Connection> mConnections;
246};
247
248/*******************************************************************************
249 * End of File
250 ******************************************************************************/
251
252} // namespace editor
253} // namespace librepcb
254
255#endif
The Board class represents a PCB of a project and is always part of a circuit.
Definition board.h:74
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
Helper to load a librepcb::Project from the file system.
Definition projectloader.h:52
The RuleCheckMessage class.
Definition rulecheckmessage.h:45
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:75
The ProjectEditor class.
Definition projecteditor.h:64
std::shared_ptr< SchematicEditor > execNewSheetDialog() noexcept
Definition projecteditor.cpp:549
ui::ProjectData getUiData() const noexcept
Definition projecteditor.cpp:266
Signal< ProjectEditor > onUiDataChanged
Definition projecteditor.h:69
void projectSettingsChanged() noexcept
Definition projecteditor.cpp:761
void execLppzExportDialog(QWidget *parent) noexcept
Execute the *.lppz export dialog (blocking)
Definition projecteditor.cpp:507
std::unique_ptr< UndoStack > mUndoStack
Definition projecteditor.h:221
void redo() noexcept
Definition projecteditor.cpp:364
bool mUseIeee315Symbols
Definition projecteditor.h:216
std::shared_ptr< RuleCheckMessagesModel > mErcMessages
Definition projecteditor.h:227
void scheduleErcRun() noexcept
Definition projecteditor.cpp:717
bool mManualModificationsMade
Modifications bypassing the undo stack.
Definition projecteditor.h:234
void execRenameSheetDialog(int index) noexcept
Definition projecteditor.cpp:581
QVector< QMetaObject::Connection > mConnections
Definition projecteditor.h:245
Workspace & getWorkspace() noexcept
Definition projecteditor.h:82
ProjectEditor(const ProjectEditor &other)=delete
UndoStack & getUndoStack() noexcept
Definition projecteditor.h:84
bool saveProject() noexcept
Save the whole project to the harddisc.
Definition projecteditor.cpp:395
std::unique_ptr< Project > mProject
Definition projecteditor.h:214
int mUiIndex
Definition projecteditor.h:215
void statusBarMessageChanged(const QString &message, int timeoutMs)
std::shared_ptr< const QSet< const NetSignal * > > getHighlightedNetSignals() const noexcept
Definition projecteditor.h:97
void setUiData(const ui::ProjectData &data) noexcept
Definition projecteditor.cpp:290
void projectLibraryUpdaterRequested(const FilePath &fp)
void setManualModificationsMade() noexcept
Set the flag that manual modifications (no undo stack) are made.
Definition projecteditor.cpp:472
void openMigrationLog() noexcept
Open the HTML with all project file format upgrade messages.
Definition projecteditor.cpp:698
QVector< QPointer< SchematicTab > > mActiveSchematicTabs
Definition projecteditor.h:224
GuiApplication & getApp() noexcept
Definition projecteditor.h:81
QTimer mErcTimer
Definition projecteditor.h:231
void setUiIndex(int index) noexcept
Definition projecteditor.cpp:259
void setHighlightedNetSignals(const QSet< const NetSignal * > &netSignals) noexcept
Definition projecteditor.cpp:342
void unregisterActiveSchematicTab(SchematicTab *tab) noexcept
Definition projecteditor.cpp:690
void refreshBuses() noexcept
Definition projecteditor.cpp:775
QString mErcExecutionError
Definition projecteditor.h:230
QTimer mAutoSaveTimer
Definition projecteditor.h:241
std::shared_ptr< QSet< const NetSignal * > > mHighlightedNetSignals
Definition projecteditor.h:223
bool hasUnsavedChanges() const noexcept
Definition projecteditor.cpp:350
int getUiIndex() const noexcept
Definition projecteditor.h:91
void trigger(ui::ProjectAction a) noexcept
Definition projecteditor.cpp:294
std::shared_ptr< UiObjectList< BoardEditor, ui::BoardData > > mBoards
Definition projecteditor.h:220
std::optional< ProjectLoader::MigrationLog > mMigrationLog
Definition projecteditor.h:217
void execDeleteSheetDialog(int index) noexcept
Definition projecteditor.cpp:602
Workspace & mWorkspace
Definition projecteditor.h:213
Project & getProject() noexcept
Definition projecteditor.h:83
bool autosaveProject() noexcept
Make a automatic backup of the project (save to temporary files)
Definition projecteditor.cpp:435
void undo() noexcept
Definition projecteditor.cpp:356
QSet< SExpression > mSupportedErcApprovals
Definition projecteditor.h:228
std::shared_ptr< UiObjectList< SchematicEditor, ui::SchematicData > > mSchematics
Definition projecteditor.h:219
const QVector< std::shared_ptr< SchematicEditor > > & getSchematics() noexcept
Definition projecteditor.h:85
bool requestClose() noexcept
Request to close the project.
Definition projecteditor.cpp:372
void ercMessageHighlightRequested(std::shared_ptr< const RuleCheckMessage > msg, bool zoomTo, int windowId)
void registerActiveSchematicTab(SchematicTab *tab) noexcept
Definition projecteditor.cpp:681
void execSetupDialog() noexcept
Definition projecteditor.cpp:480
std::shared_ptr< BoardEditor > execNewBoardDialog(std::optional< int > copyFromIndex) noexcept
Definition projecteditor.cpp:615
void runErc() noexcept
Definition projecteditor.cpp:721
bool getUseIeee315Symbols() const noexcept
Definition projecteditor.h:96
uint mLastAutosaveStateId
The UndoStack state ID of the last successful project (auto)save.
Definition projecteditor.h:237
QSet< SExpression > mDisappearedErcApprovals
Definition projecteditor.h:229
void abortBlockingToolsInOtherEditors(const void *source)
Abort any active (blocking) tools in other editors.
void execDeleteBoardDialog(int index) noexcept
Definition projecteditor.cpp:662
void execOutputJobsDialog(const QString &typeName=QString()) noexcept
Definition projecteditor.cpp:486
GuiApplication & mApp
Definition projecteditor.h:212
void execBomReviewDialog(const Board *board) noexcept
Definition projecteditor.cpp:499
const QVector< std::shared_ptr< BoardEditor > > & getBoards() noexcept
Definition projecteditor.h:88
std::shared_ptr< slint::VectorModel< ui::BusData > > mBuses
Definition projecteditor.h:218
The RuleCheckMessagesModel class.
Definition rulecheckmessagesmodel.h:46
The SchematicEditor class.
Definition schematiceditor.h:50
The SchematicTab class.
Definition schematictab.h:63
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