LibrePCB Developers Documentation
symboleditorwidget.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_SYMBOLEDITORWIDGET_H
21#define LIBREPCB_EDITOR_SYMBOLEDITORWIDGET_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../widgets/if_graphicsvieweventhandler.h"
27#include "../cat/categorylisteditorwidget.h"
28#include "../editorwidgetbase.h"
29
32
33#include <QtCore>
34#include <QtWidgets>
35
36#include <memory>
37
38/*******************************************************************************
39 * Namespace / Forward Declarations
40 ******************************************************************************/
41namespace librepcb {
42
43class Symbol;
44
45namespace editor {
46
47class GraphicsScene;
48class SymbolEditorFsm;
49class SymbolGraphicsItem;
50
51namespace Ui {
52class SymbolEditorWidget;
53}
54
55/*******************************************************************************
56 * Class SymbolEditorWidget
57 ******************************************************************************/
58
64 Q_OBJECT
65
66public:
67 // Constructors / Destructor
69 SymbolEditorWidget(const SymbolEditorWidget& other) = delete;
70 SymbolEditorWidget(const Context& context, const FilePath& fp,
71 QWidget* parent = nullptr);
72 ~SymbolEditorWidget() noexcept;
73
74 // Getters
75 QSet<Feature> getAvailableFeatures() const noexcept override;
76
77 // Setters
78 void connectEditor(UndoStackActionGroup& undoStackActionGroup,
79 ExclusiveActionGroup& toolsActionGroup,
80 QToolBar& commandToolBar,
81 StatusBar& statusBar) noexcept override;
82 void disconnectEditor() noexcept override;
83
84 // Operator Overloadings
85 SymbolEditorWidget& operator=(const SymbolEditorWidget& rhs) = delete;
86
87public slots:
88 bool save() noexcept override;
89 bool selectAll() noexcept override;
90 bool cut() noexcept override;
91 bool copy() noexcept override;
92 bool paste() noexcept override;
93 bool move(Qt::ArrowType direction) noexcept override;
94 bool rotate(const librepcb::Angle& rotation) noexcept override;
95 bool mirror(Qt::Orientation orientation) noexcept override;
96 bool snapToGrid() noexcept override;
97 bool remove() noexcept override;
98 bool editProperties() noexcept override;
99 bool zoomIn() noexcept override;
100 bool zoomOut() noexcept override;
101 bool zoomAll() noexcept override;
102 bool abortCommand() noexcept override;
103 bool importDxf() noexcept override;
104 bool editGridProperties() noexcept override;
105 bool increaseGridInterval() noexcept override;
106 bool decreaseGridInterval() noexcept override;
107
108private: // Methods
109 void updateMetadata() noexcept;
110 QString commitMetadata() noexcept;
112 bool graphicsViewEventHandler(QEvent* event) noexcept override;
113 bool toolChangeRequested(Tool newTool,
114 const QVariant& mode) noexcept override;
115 bool isInterfaceBroken() const noexcept override;
116 bool runChecks(RuleCheckMessageList& msgs) const override;
117 template <typename MessageType>
118 void fixMsg(const MessageType& msg);
119 template <typename MessageType>
120 bool fixMsgHelper(std::shared_ptr<const RuleCheckMessage> msg, bool applyFix);
121 bool processRuleCheckMessage(std::shared_ptr<const RuleCheckMessage> msg,
122 bool applyFix) override;
123 void ruleCheckApproveRequested(std::shared_ptr<const RuleCheckMessage> msg,
124 bool approve) noexcept override;
126 const QString& settingsKey) noexcept override;
127 void setGridProperties(const PositiveLength& interval, const LengthUnit& unit,
128 Theme::GridStyle style) noexcept;
129
130private: // Data
131 QScopedPointer<Ui::SymbolEditorWidget> mUi;
135 std::unique_ptr<Symbol> mSymbol;
137
140
142 QScopedPointer<SymbolEditorFsm> mFsm;
143};
144
145/*******************************************************************************
146 * End of File
147 ******************************************************************************/
148
149} // namespace editor
150} // namespace librepcb
151
152#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
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 RuleCheckMessage class.
Definition: rulecheckmessage.h:45
The Symbol class represents the part of a component which is added to schematics.
Definition: symbol.h:55
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:58
The CategoryListEditorWidget class.
Definition: categorylisteditorwidget.h:54
The EditorWidgetBase class.
Definition: editorwidgetbase.h:62
Tool
Definition: editorwidgetbase.h:76
Feature
Definition: editorwidgetbase.h:95
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 GraphicsScene class.
Definition: graphicsscene.h:45
The IF_GraphicsViewEventHandler class.
Definition: if_graphicsvieweventhandler.h:41
The StatusBar class extends QStatusBar for some commonly used fields.
Definition: statusbar.h:45
The SymbolEditorFsm class is the finit state machine (FSM) of the symbol editor.
Definition: symboleditorfsm.h:56
The SymbolEditorWidget class.
Definition: symboleditorwidget.h:63
bool graphicsViewEventHandler(QEvent *event) noexcept override
Definition: symboleditorwidget.cpp:409
bool copy() noexcept override
Definition: symboleditorwidget.cpp:281
bool mirror(Qt::Orientation orientation) noexcept override
Definition: symboleditorwidget.cpp:297
bool save() noexcept override
Definition: symboleditorwidget.cpp:249
QScopedPointer< SymbolEditorFsm > mFsm
Editor state machine.
Definition: symboleditorwidget.h:142
bool execGraphicsExportDialog(GraphicsExportDialog::Output output, const QString &settingsKey) noexcept override
Definition: symboleditorwidget.cpp:602
SymbolEditorWidget(const SymbolEditorWidget &other)=delete
void setGridProperties(const PositiveLength &interval, const LengthUnit &unit, Theme::GridStyle style) noexcept
Definition: symboleditorwidget.cpp:635
void updateMetadata() noexcept
Definition: symboleditorwidget.cpp:365
bool increaseGridInterval() noexcept override
Definition: symboleditorwidget.cpp:345
QScopedPointer< GraphicsScene > mGraphicsScene
Definition: symboleditorwidget.h:133
QSet< Uuid > mOriginalSymbolPinUuids
Broken interface detection.
Definition: symboleditorwidget.h:139
bool abortCommand() noexcept override
Definition: symboleditorwidget.cpp:328
bool editGridProperties() noexcept override
Definition: symboleditorwidget.cpp:336
LengthUnit mLengthUnit
Definition: symboleditorwidget.h:134
void ruleCheckApproveRequested(std::shared_ptr< const RuleCheckMessage > msg, bool approve) noexcept override
Definition: symboleditorwidget.cpp:596
std::unique_ptr< Symbol > mSymbol
Definition: symboleditorwidget.h:135
bool snapToGrid() noexcept override
Definition: symboleditorwidget.cpp:301
QScopedPointer< SymbolGraphicsItem > mGraphicsItem
Definition: symboleditorwidget.h:136
QScopedPointer< CategoryListEditorWidget > mCategoriesEditorWidget
Definition: symboleditorwidget.h:132
bool paste() noexcept override
Definition: symboleditorwidget.cpp:285
~SymbolEditorWidget() noexcept
Definition: symboleditorwidget.cpp:176
void connectEditor(UndoStackActionGroup &undoStackActionGroup, ExclusiveActionGroup &toolsActionGroup, QToolBar &commandToolBar, StatusBar &statusBar) noexcept override
Definition: symboleditorwidget.cpp:205
bool cut() noexcept override
Definition: symboleditorwidget.cpp:277
bool importDxf() noexcept override
Definition: symboleditorwidget.cpp:332
bool decreaseGridInterval() noexcept override
Definition: symboleditorwidget.cpp:352
bool rotate(const librepcb::Angle &rotation) noexcept override
Definition: symboleditorwidget.cpp:293
bool selectAll() noexcept override
Definition: symboleditorwidget.cpp:273
bool zoomAll() noexcept override
Definition: symboleditorwidget.cpp:323
bool move(Qt::ArrowType direction) noexcept override
Definition: symboleditorwidget.cpp:289
QScopedPointer< Ui::SymbolEditorWidget > mUi
Definition: symboleditorwidget.h:131
void fixMsg(const MessageType &msg)
bool editProperties() noexcept override
Definition: symboleditorwidget.cpp:309
QString commitMetadata() noexcept
Definition: symboleditorwidget.cpp:378
bool fixMsgHelper(std::shared_ptr< const RuleCheckMessage > msg, bool applyFix)
Definition: symboleditorwidget.cpp:571
bool toolChangeRequested(Tool newTool, const QVariant &mode) noexcept override
Definition: symboleditorwidget.cpp:465
void disconnectEditor() noexcept override
Definition: symboleditorwidget.cpp:234
bool isInterfaceBroken() const noexcept override
Definition: symboleditorwidget.cpp:496
QSet< Feature > getAvailableFeatures() const noexcept override
Definition: symboleditorwidget.cpp:191
bool zoomIn() noexcept override
Definition: symboleditorwidget.cpp:313
bool zoomOut() noexcept override
Definition: symboleditorwidget.cpp:318
bool runChecks(RuleCheckMessageList &msgs) const override
Definition: symboleditorwidget.cpp:500
bool remove() noexcept override
Definition: symboleditorwidget.cpp:305
bool processRuleCheckMessage(std::shared_ptr< const RuleCheckMessage > msg, bool applyFix) override
Definition: symboleditorwidget.cpp:582
The SymbolGraphicsItem class.
Definition: symbolgraphicsitem.h:56
The UndoStackActionGroup class groups an undo-QAction and redo-QAction together and optionally connec...
Definition: undostackactiongroup.h:45
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition: rulecheckmessage.h:104
Definition: editorwidgetbase.h:68