LibrePCB Developers Documentation
Loading...
Searching...
No Matches
schematiceditor.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_SCHEMATICEDITOR_H
21#define LIBREPCB_EDITOR_SCHEMATICEDITOR_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../dialogs/graphicsexportdialog.h"
27#include "../../graphics/graphicslayer.h"
28#include "../../widgets/if_graphicsvieweventhandler.h"
29#include "ui_schematiceditor.h"
30
32
33#include <QtCore>
34#include <QtWidgets>
35
36/*******************************************************************************
37 * Namespace / Forward Declarations
38 ******************************************************************************/
39namespace librepcb {
40
41class Project;
42class SI_Symbol;
43class Schematic;
44class Theme;
45
46namespace editor {
47
48class ExclusiveActionGroup;
49class GraphicsView;
50class ProjectEditor;
51class RuleCheckDock;
52class SchematicEditorFsm;
53class SchematicGraphicsScene;
54class SchematicPagesDock;
55class SearchToolBar;
56class StandardEditorCommandHandler;
57class ToolBarProxy;
58class UndoStackActionGroup;
59
60namespace Ui {
61class SchematicEditor;
62}
63
64/*******************************************************************************
65 * Class SchematicEditor
66 ******************************************************************************/
67
71class SchematicEditor final : public QMainWindow,
74 Q_OBJECT
75
76public:
77 // Constructors / Destructor
78 SchematicEditor() = delete;
79 SchematicEditor(const SchematicEditor& other) = delete;
80 explicit SchematicEditor(ProjectEditor& projectEditor, Project& project);
82
83 // Getters
84 ProjectEditor& getProjectEditor() const noexcept { return mProjectEditor; }
85 Project& getProject() const noexcept { return mProject; }
86 int getActiveSchematicIndex() const noexcept { return mActiveSchematicIndex; }
87 Schematic* getActiveSchematic() const noexcept;
91
93 virtual std::shared_ptr<GraphicsLayer> getLayer(
94 const QString& name) const noexcept override {
95 foreach (std::shared_ptr<GraphicsLayer> layer, mLayers) {
96 if (layer->getName() == name) {
97 return layer;
98 }
99 }
100 return nullptr;
101 }
102
103 virtual QList<std::shared_ptr<GraphicsLayer>> getAllLayers()
104 const noexcept override {
105 return mLayers;
106 }
107
108 // Setters
109 bool setActiveSchematicIndex(int index) noexcept;
110
111 // General Methods
112 void abortAllCommands() noexcept;
113 void abortBlockingToolsInOtherEditors() noexcept;
114
115 // Operator Overloadings
116 SchematicEditor& operator=(const SchematicEditor& rhs) = delete;
117
118protected:
119 virtual void closeEvent(QCloseEvent* event) noexcept override;
120
121signals:
122 void activeSchematicChanged(int index);
123
124private:
125 // Private Methods
126 void addLayers(const Theme& theme) noexcept;
127 void createActions() noexcept;
128 void createToolBars() noexcept;
129 void createDockWidgets() noexcept;
130 void createMenus() noexcept;
131 virtual bool graphicsViewEventHandler(QEvent* event) override;
132 void toolRequested(const QVariant& newTool) noexcept;
133 void addSchematic() noexcept;
134 void removeSchematic(int index) noexcept;
135 void renameSchematic(int index) noexcept;
136 QList<SI_Symbol*> getSearchCandidates() noexcept;
137 QStringList getSearchToolBarCompleterList() noexcept;
138 void goToSymbol(const QString& name, int index) noexcept;
139 void updateEmptySchematicMessage() noexcept;
140 void updateComponentToolbarIcons() noexcept;
141 void setGridProperties(const PositiveLength& interval, const LengthUnit& unit,
142 Theme::GridStyle style,
143 bool applyToSchematics) noexcept;
144 void execGridPropertiesDialog() noexcept;
146 const QString& settingsKey) noexcept;
147 bool useIeee315Symbols() const noexcept;
148
149 // General Attributes
152 QScopedPointer<Ui::SchematicEditor> mUi;
156 QList<std::shared_ptr<GraphicsLayer>> mLayers;
158 QHash<Uuid, QRectF> mVisibleSceneRect;
159 QScopedPointer<SchematicEditorFsm> mFsm;
160
161 // Actions
162 QScopedPointer<QAction> mActionAboutLibrePcb;
163 QScopedPointer<QAction> mActionAboutQt;
164 QScopedPointer<QAction> mActionOnlineDocumentation;
165 QScopedPointer<QAction> mActionKeyboardShortcutsReference;
166 QScopedPointer<QAction> mActionWebsite;
167 QScopedPointer<QAction> mActionSaveProject;
168 QScopedPointer<QAction> mActionCloseProject;
169 QScopedPointer<QAction> mActionCloseWindow;
170 QScopedPointer<QAction> mActionQuit;
171 QScopedPointer<QAction> mActionFileManager;
172 QScopedPointer<QAction> mActionBoardEditor;
173 QScopedPointer<QAction> mActionControlPanel;
174 QScopedPointer<QAction> mActionProjectSetup;
175 QScopedPointer<QAction> mActionUpdateLibrary;
176 QScopedPointer<QAction> mActionExportLppz;
177 QScopedPointer<QAction> mActionExportImage;
178 QScopedPointer<QAction> mActionExportPdf;
179 QScopedPointer<QAction> mActionPrint;
180 QScopedPointer<QAction> mActionGenerateBom;
181 QScopedPointer<QAction> mActionOutputJobs;
182 QScopedPointer<QAction> mActionOrderPcb;
183 QScopedPointer<QAction> mActionNewSheet;
184 QScopedPointer<QAction> mActionRenameSheet;
185 QScopedPointer<QAction> mActionRemoveSheet;
186 QScopedPointer<QAction> mActionNextPage;
187 QScopedPointer<QAction> mActionPreviousPage;
188 QScopedPointer<QAction> mActionFind;
189 QScopedPointer<QAction> mActionFindNext;
190 QScopedPointer<QAction> mActionFindPrevious;
191 QScopedPointer<QAction> mActionSelectAll;
192 QScopedPointer<QAction> mActionGridProperties;
193 QScopedPointer<QAction> mActionGridIncrease;
194 QScopedPointer<QAction> mActionGridDecrease;
195 QScopedPointer<QAction> mActionShowPinNumbers;
196 QScopedPointer<QAction> mActionZoomFit;
197 QScopedPointer<QAction> mActionZoomIn;
198 QScopedPointer<QAction> mActionZoomOut;
199 QScopedPointer<QAction> mActionUndo;
200 QScopedPointer<QAction> mActionRedo;
201 QScopedPointer<QAction> mActionCut;
202 QScopedPointer<QAction> mActionCopy;
203 QScopedPointer<QAction> mActionPaste;
204 QScopedPointer<QAction> mActionMoveLeft;
205 QScopedPointer<QAction> mActionMoveRight;
206 QScopedPointer<QAction> mActionMoveUp;
207 QScopedPointer<QAction> mActionMoveDown;
208 QScopedPointer<QAction> mActionRotateCcw;
209 QScopedPointer<QAction> mActionRotateCw;
210 QScopedPointer<QAction> mActionMirrorHorizontal;
211 QScopedPointer<QAction> mActionMirrorVertical;
212 QScopedPointer<QAction> mActionResetAllTexts;
213 QScopedPointer<QAction> mActionProperties;
214 QScopedPointer<QAction> mActionRemove;
215 QScopedPointer<QAction> mActionAbort;
216 QScopedPointer<QAction> mActionToolSelect;
217 QScopedPointer<QAction> mActionToolWire;
218 QScopedPointer<QAction> mActionToolNetLabel;
219 QScopedPointer<QAction> mActionToolPolygon;
220 QScopedPointer<QAction> mActionToolText;
221 QScopedPointer<QAction> mActionToolComponent;
222 QScopedPointer<QAction> mActionToolMeasure;
223 QScopedPointer<QAction> mActionComponentResistor;
224 QScopedPointer<QAction> mActionComponentInductor;
225 QScopedPointer<QAction> mActionComponentCapacitorBipolar;
226 QScopedPointer<QAction> mActionComponentCapacitorUnipolar;
227 QScopedPointer<QAction> mActionComponentGnd;
228 QScopedPointer<QAction> mActionComponentVcc;
229 QScopedPointer<QAction> mActionDockPages;
230 QScopedPointer<QAction> mActionDockErc;
231
232 // Action groups
235
236 // Toolbars
237 QScopedPointer<QToolBar> mToolBarFile;
238 QScopedPointer<QToolBar> mToolBarEdit;
239 QScopedPointer<QToolBar> mToolBarView;
241 QScopedPointer<QToolBar> mToolBarCommand;
242 QScopedPointer<QToolBar> mToolBarTools;
243 QScopedPointer<QToolBar> mToolBarComponents;
244
245 // Docks
247 QScopedPointer<RuleCheckDock> mDockErc;
248
249 // Connections
250 QVector<QMetaObject::Connection> mSchematicConnections;
251};
252
253/*******************************************************************************
254 * End of File
255 ******************************************************************************/
256
257} // namespace editor
258} // namespace librepcb
259
260#endif
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition lengthunit.h:60
The Project class represents a whole (opened) project with all its content.
Definition project.h:71
The SI_Symbol class.
Definition si_symbol.h:54
The Schematic class represents one schematic page of a project and is always part of a circuit.
Definition schematic.h:74
Theme class as used by librepcb::WorkspaceSettingsItem_Themes.
Definition theme.h:44
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The ExclusiveActionGroup class groups multiple QAction's together.
Definition exclusiveactiongroup.h:54
This class provides a Dialog (GUI) to choose DXF import settings.
Definition graphicsexportdialog.h:61
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition graphicslayer.h:53
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers.
Definition graphicslayer.h:111
The IF_GraphicsViewEventHandler class.
Definition if_graphicsvieweventhandler.h:41
The ProjectEditor class.
Definition projecteditor.h:66
The RuleCheckDock class.
Definition rulecheckdock.h:50
The schematic editor finite state machine (FSM)
Definition schematiceditorfsm.h:56
The SchematicEditor class.
Definition schematiceditor.h:73
QScopedPointer< Ui::SchematicEditor > mUi
Definition schematiceditor.h:152
QScopedPointer< QToolBar > mToolBarComponents
Definition schematiceditor.h:243
QScopedPointer< QAction > mActionZoomFit
Definition schematiceditor.h:196
QScopedPointer< QAction > mActionExportImage
Definition schematiceditor.h:177
SchematicEditor(const SchematicEditor &other)=delete
QScopedPointer< QAction > mActionFindPrevious
Definition schematiceditor.h:190
QScopedPointer< QAction > mActionComponentVcc
Definition schematiceditor.h:228
QScopedPointer< UndoStackActionGroup > mUndoStackActionGroup
Definition schematiceditor.h:233
QScopedPointer< QAction > mActionCut
Definition schematiceditor.h:201
QScopedPointer< QAction > mActionExportLppz
Definition schematiceditor.h:176
QList< SI_Symbol * > getSearchCandidates() noexcept
Definition schematiceditor.cpp:1101
QScopedPointer< SchematicGraphicsScene > mGraphicsScene
Definition schematiceditor.h:157
virtual std::shared_ptr< GraphicsLayer > getLayer(const QString &name) const noexcept override
Definition schematiceditor.h:93
QScopedPointer< QAction > mActionResetAllTexts
Definition schematiceditor.h:212
bool setActiveSchematicIndex(int index) noexcept
Definition schematiceditor.cpp:240
QScopedPointer< QAction > mActionZoomIn
Definition schematiceditor.h:197
QScopedPointer< QAction > mActionCopy
Definition schematiceditor.h:202
QScopedPointer< QAction > mActionKeyboardShortcutsReference
Definition schematiceditor.h:165
QScopedPointer< QAction > mActionMirrorHorizontal
Definition schematiceditor.h:210
QScopedPointer< QAction > mActionProjectSetup
Definition schematiceditor.h:174
QScopedPointer< QAction > mActionQuit
Definition schematiceditor.h:170
QScopedPointer< ExclusiveActionGroup > mToolsActionGroup
Definition schematiceditor.h:234
void updateEmptySchematicMessage() noexcept
Definition schematiceditor.cpp:1159
QScopedPointer< QAction > mActionMoveDown
Definition schematiceditor.h:207
QScopedPointer< QAction > mActionGridIncrease
Definition schematiceditor.h:193
virtual QList< std::shared_ptr< GraphicsLayer > > getAllLayers() const noexcept override
Definition schematiceditor.h:103
QScopedPointer< QAction > mActionDockErc
Definition schematiceditor.h:230
QScopedPointer< QAction > mActionOrderPcb
Definition schematiceditor.h:182
QScopedPointer< QAction > mActionGridProperties
Definition schematiceditor.h:192
int getActiveSchematicIndex() const noexcept
Definition schematiceditor.h:86
void addLayers(const Theme &theme) noexcept
Definition schematiceditor.cpp:336
QScopedPointer< QAction > mActionRenameSheet
Definition schematiceditor.h:184
QList< std::shared_ptr< GraphicsLayer > > mLayers
Definition schematiceditor.h:156
QScopedPointer< QAction > mActionRemoveSheet
Definition schematiceditor.h:185
QScopedPointer< QAction > mActionAbort
Definition schematiceditor.h:215
QScopedPointer< QToolBar > mToolBarEdit
Definition schematiceditor.h:238
QScopedPointer< QAction > mActionRotateCcw
Definition schematiceditor.h:208
QScopedPointer< QAction > mActionUpdateLibrary
Definition schematiceditor.h:175
void createMenus() noexcept
Definition schematiceditor.cpp:803
QScopedPointer< QAction > mActionSaveProject
Definition schematiceditor.h:167
QScopedPointer< QAction > mActionAboutLibrePcb
Definition schematiceditor.h:162
QScopedPointer< RuleCheckDock > mDockErc
Definition schematiceditor.h:247
QScopedPointer< QAction > mActionFindNext
Definition schematiceditor.h:189
QScopedPointer< QAction > mActionSelectAll
Definition schematiceditor.h:191
QScopedPointer< QAction > mActionComponentGnd
Definition schematiceditor.h:227
void abortAllCommands() noexcept
Definition schematiceditor.cpp:310
QScopedPointer< QToolBar > mToolBarTools
Definition schematiceditor.h:242
QScopedPointer< QAction > mActionMoveUp
Definition schematiceditor.h:206
void activeSchematicChanged(int index)
QScopedPointer< QToolBar > mToolBarFile
Definition schematiceditor.h:237
QScopedPointer< SchematicPagesDock > mDockPages
Definition schematiceditor.h:246
QScopedPointer< QAction > mActionToolNetLabel
Definition schematiceditor.h:218
QScopedPointer< QAction > mActionPreviousPage
Definition schematiceditor.h:187
void createToolBars() noexcept
Definition schematiceditor.cpp:663
void removeSchematic(int index) noexcept
Definition schematiceditor.cpp:1068
QScopedPointer< QAction > mActionToolComponent
Definition schematiceditor.h:221
QScopedPointer< QAction > mActionCloseWindow
Definition schematiceditor.h:169
QScopedPointer< QAction > mActionNewSheet
Definition schematiceditor.h:183
QScopedPointer< QAction > mActionComponentResistor
Definition schematiceditor.h:223
QScopedPointer< QAction > mActionToolSelect
Definition schematiceditor.h:216
QScopedPointer< QAction > mActionWebsite
Definition schematiceditor.h:166
QScopedPointer< QAction > mActionUndo
Definition schematiceditor.h:199
ProjectEditor & mProjectEditor
Definition schematiceditor.h:150
QScopedPointer< QAction > mActionRotateCw
Definition schematiceditor.h:209
Schematic * getActiveSchematic() const noexcept
Definition schematiceditor.cpp:232
QScopedPointer< SearchToolBar > mToolBarSearch
Definition schematiceditor.h:240
bool useIeee315Symbols() const noexcept
Definition schematiceditor.cpp:1260
void setGridProperties(const PositiveLength &interval, const LengthUnit &unit, Theme::GridStyle style, bool applyToSchematics) noexcept
Definition schematiceditor.cpp:1180
void renameSchematic(int index) noexcept
Definition schematiceditor.cpp:1081
void createDockWidgets() noexcept
Definition schematiceditor.cpp:760
QScopedPointer< QAction > mActionOutputJobs
Definition schematiceditor.h:181
QScopedPointer< QAction > mActionMoveLeft
Definition schematiceditor.h:204
QScopedPointer< QToolBar > mToolBarCommand
Definition schematiceditor.h:241
QScopedPointer< QAction > mActionProperties
Definition schematiceditor.h:213
void updateComponentToolbarIcons() noexcept
Definition schematiceditor.cpp:1165
QScopedPointer< StandardEditorCommandHandler > mStandardCommandHandler
Definition schematiceditor.h:154
QScopedPointer< QAction > mActionCloseProject
Definition schematiceditor.h:168
Project & getProject() const noexcept
Definition schematiceditor.h:85
int mActiveSchematicIndex
Definition schematiceditor.h:155
QScopedPointer< QAction > mActionGenerateBom
Definition schematiceditor.h:180
QScopedPointer< QAction > mActionComponentCapacitorUnipolar
Definition schematiceditor.h:226
QScopedPointer< QAction > mActionDockPages
Definition schematiceditor.h:229
QScopedPointer< QAction > mActionShowPinNumbers
Definition schematiceditor.h:195
Project & mProject
Definition schematiceditor.h:151
QScopedPointer< QAction > mActionExportPdf
Definition schematiceditor.h:178
QScopedPointer< QAction > mActionControlPanel
Definition schematiceditor.h:173
QScopedPointer< QToolBar > mToolBarView
Definition schematiceditor.h:239
void goToSymbol(const QString &name, int index) noexcept
Definition schematiceditor.cpp:1118
QScopedPointer< QAction > mActionToolPolygon
Definition schematiceditor.h:219
QScopedPointer< QAction > mActionOnlineDocumentation
Definition schematiceditor.h:164
QScopedPointer< QAction > mActionFileManager
Definition schematiceditor.h:171
QScopedPointer< QAction > mActionFind
Definition schematiceditor.h:188
QScopedPointer< SchematicEditorFsm > mFsm
Definition schematiceditor.h:159
QScopedPointer< QAction > mActionMoveRight
Definition schematiceditor.h:205
QScopedPointer< QAction > mActionComponentCapacitorBipolar
Definition schematiceditor.h:225
void execGridPropertiesDialog() noexcept
Definition schematiceditor.cpp:1196
virtual void closeEvent(QCloseEvent *event) noexcept override
Definition schematiceditor.cpp:325
void abortBlockingToolsInOtherEditors() noexcept
Definition schematiceditor.cpp:317
QScopedPointer< ToolBarProxy > mCommandToolBarProxy
Definition schematiceditor.h:153
QScopedPointer< QAction > mActionPaste
Definition schematiceditor.h:203
void toolRequested(const QVariant &newTool) noexcept
Definition schematiceditor.cpp:1009
QHash< Uuid, QRectF > mVisibleSceneRect
Definition schematiceditor.h:158
void createActions() noexcept
Definition schematiceditor.cpp:364
SchematicGraphicsScene * getActiveSchematicScene() noexcept
Definition schematiceditor.h:88
QScopedPointer< QAction > mActionPrint
Definition schematiceditor.h:179
QScopedPointer< QAction > mActionGridDecrease
Definition schematiceditor.h:194
QScopedPointer< QAction > mActionNextPage
Definition schematiceditor.h:186
virtual bool graphicsViewEventHandler(QEvent *event) override
The event handler method.
Definition schematiceditor.cpp:911
QScopedPointer< QAction > mActionRedo
Definition schematiceditor.h:200
void addSchematic() noexcept
Definition schematiceditor.cpp:1043
QScopedPointer< QAction > mActionBoardEditor
Definition schematiceditor.h:172
QScopedPointer< QAction > mActionAboutQt
Definition schematiceditor.h:163
QScopedPointer< QAction > mActionMirrorVertical
Definition schematiceditor.h:211
QScopedPointer< QAction > mActionToolMeasure
Definition schematiceditor.h:222
QVector< QMetaObject::Connection > mSchematicConnections
Definition schematiceditor.h:250
QScopedPointer< QAction > mActionRemove
Definition schematiceditor.h:214
void execGraphicsExportDialog(GraphicsExportDialog::Output output, const QString &settingsKey) noexcept
Definition schematiceditor.cpp:1213
ProjectEditor & getProjectEditor() const noexcept
Definition schematiceditor.h:84
QScopedPointer< QAction > mActionToolWire
Definition schematiceditor.h:217
QStringList getSearchToolBarCompleterList() noexcept
Definition schematiceditor.cpp:1110
QScopedPointer< QAction > mActionZoomOut
Definition schematiceditor.h:198
QScopedPointer< QAction > mActionToolText
Definition schematiceditor.h:220
~SchematicEditor()
Definition schematiceditor.cpp:215
QScopedPointer< QAction > mActionComponentInductor
Definition schematiceditor.h:224
The SchematicGraphicsScene class.
Definition schematicgraphicsscene.h:67
The SchematicPagesDock class.
Definition schematicpagesdock.h:59
The SearchToolBar class.
Definition searchtoolbar.h:44
Helper to handle some of the librepcb::editor::EditorCommand actions.
Definition standardeditorcommandhandler.h:48
The ToolBarProxy class allows to map a list of QAction's to one QToolBar.
Definition toolbarproxy.h:45
The UndoStackActionGroup class groups an undo-QAction and redo-QAction together and optionally connec...
Definition undostackactiongroup.h:45
Definition occmodel.cpp:76
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
Definition uuid.h:186