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  ******************************************************************************/
41 namespace librepcb {
42 
43 class Symbol;
44 
45 namespace editor {
46 
47 class GraphicsScene;
48 class SymbolEditorFsm;
49 class SymbolGraphicsItem;
50 
51 namespace Ui {
52 class SymbolEditorWidget;
53 }
54 
55 /*******************************************************************************
56  * Class SymbolEditorWidget
57  ******************************************************************************/
58 
62 class SymbolEditorWidget final : public EditorWidgetBase,
64  Q_OBJECT
65 
66 public:
67  // Constructors / Destructor
68  SymbolEditorWidget() = delete;
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 
87 public 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 
108 private: // 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;
125  bool execGraphicsExportDialog(GraphicsExportDialog::Output output,
126  const QString& settingsKey) noexcept override;
127  void setGridProperties(const PositiveLength& interval, const LengthUnit& unit,
128  Theme::GridStyle style) noexcept;
129 
130 private: // Data
131  QScopedPointer<Ui::SymbolEditorWidget> mUi;
132  QScopedPointer<CategoryListEditorWidget> mCategoriesEditorWidget;
133  QScopedPointer<GraphicsScene> mGraphicsScene;
135  std::unique_ptr<Symbol> mSymbol;
136  QScopedPointer<SymbolGraphicsItem> mGraphicsItem;
137 
140 
142  QScopedPointer<SymbolEditorFsm> mFsm;
143 };
144 
145 /*******************************************************************************
146  * End of File
147  ******************************************************************************/
148 
149 } // namespace editor
150 } // namespace librepcb
151 
152 #endif
Definition: occmodel.cpp:77
The UndoStackActionGroup class groups an undo-QAction and redo-QAction together and optionally connec...
Definition: undostackactiongroup.h:45
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition: rulecheckmessage.h:104
The ExclusiveActionGroup class groups multiple QAction&#39;s together.
Definition: exclusiveactiongroup.h:54
QScopedPointer< Ui::SymbolEditorWidget > mUi
Definition: symboleditorwidget.h:131
Tool
Definition: editorwidgetbase.h:76
QScopedPointer< CategoryListEditorWidget > mCategoriesEditorWidget
Definition: symboleditorwidget.h:132
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
QScopedPointer< SymbolGraphicsItem > mGraphicsItem
Definition: symboleditorwidget.h:136
The StatusBar class extends QStatusBar for some commonly used fields.
Definition: statusbar.h:45
QScopedPointer< SymbolEditorFsm > mFsm
Editor state machine.
Definition: symboleditorwidget.h:142
std::unique_ptr< Symbol > mSymbol
Definition: symboleditorwidget.h:135
The IF_GraphicsViewEventHandler class.
Definition: if_graphicsvieweventhandler.h:41
The SymbolEditorWidget class.
Definition: symboleditorwidget.h:62
QScopedPointer< GraphicsScene > mGraphicsScene
Definition: symboleditorwidget.h:133
GridStyle
Definition: theme.h:49
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
LengthUnit mLengthUnit
Definition: symboleditorwidget.h:134
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
The EditorWidgetBase class.
Definition: editorwidgetbase.h:62
Output
Definition: graphicsexportdialog.h:83
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition: lengthunit.h:60
QSet< Uuid > mOriginalSymbolPinUuids
Broken interface detection.
Definition: symboleditorwidget.h:139
Definition: editorwidgetbase.h:68