LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_LIBRARY_EDITOR_SYMBOLEDITORWIDGET_H
21 #define LIBREPCB_LIBRARY_EDITOR_SYMBOLEDITORWIDGET_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../common/categorylisteditorwidget.h"
27 #include "../common/editorwidgetbase.h"
28 
30 
31 #include <QtCore>
32 #include <QtWidgets>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 
39 class GridProperties;
40 class GraphicsScene;
41 
42 namespace library {
43 
44 class Symbol;
45 class SymbolGraphicsItem;
46 
47 namespace editor {
48 
49 class SymbolEditorFsm;
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  virtual bool hasGraphicalEditor() const noexcept override { return true; }
76 
77  // Setters
78  void setToolsActionGroup(ExclusiveActionGroup* group) noexcept override;
79 
80  // Operator Overloadings
81  SymbolEditorWidget& operator=(const SymbolEditorWidget& rhs) = delete;
82 
83 public slots:
84  bool save() noexcept override;
85  bool cut() noexcept override;
86  bool copy() noexcept override;
87  bool paste() noexcept override;
88  bool rotateCw() noexcept override;
89  bool rotateCcw() noexcept override;
90  bool mirror() noexcept override;
91  bool remove() noexcept override;
92  bool zoomIn() noexcept override;
93  bool zoomOut() noexcept override;
94  bool zoomAll() noexcept override;
95  bool abortCommand() noexcept override;
96  bool editGridProperties() noexcept override;
97 
98 private: // Methods
99  void updateMetadata() noexcept;
100  QString commitMetadata() noexcept;
102  bool graphicsViewEventHandler(QEvent* event) noexcept override;
103  bool toolChangeRequested(Tool newTool) noexcept override;
104  bool isInterfaceBroken() const noexcept override;
105  bool runChecks(LibraryElementCheckMessageList& msgs) const override;
106  template <typename MessageType>
107  void fixMsg(const MessageType& msg);
108  template <typename MessageType>
109  bool fixMsgHelper(std::shared_ptr<const LibraryElementCheckMessage> msg,
110  bool applyFix);
111  bool processCheckMessage(
112  std::shared_ptr<const LibraryElementCheckMessage> msg,
113  bool applyFix) override;
114 
115 private: // Data
116  QScopedPointer<Ui::SymbolEditorWidget> mUi;
118  QScopedPointer<GraphicsScene> mGraphicsScene;
119  QScopedPointer<Symbol> mSymbol;
121  QScopedPointer<SymbolEditorFsm> mFsm;
122 
123  // broken interface detection
125 };
126 
127 /*******************************************************************************
128  * End of File
129  ******************************************************************************/
130 
131 } // namespace editor
132 } // namespace library
133 } // namespace librepcb
134 
135 #endif // LIBREPCB_LIBRARY_EDITOR_SYMBOLEDITORWIDGET_H
bool editGridProperties() noexceptoverride
Definition: symboleditorwidget.cpp:238
QVector< std::shared_ptr< const LibraryElementCheckMessage > > LibraryElementCheckMessageList
Definition: libraryelementcheckmessage.h:96
bool isInterfaceBroken() const noexceptoverride
Definition: symboleditorwidget.cpp:364
bool graphicsViewEventHandler(QEvent *event) noexceptoverride
The event handler method.
Definition: symboleditorwidget.cpp:295
The LibraryElementCheckMessage class.
Definition: libraryelementcheckmessage.h:44
The SymbolEditorWidget class.
Definition: symboleditorwidget.h:62
bool paste() noexceptoverride
Definition: symboleditorwidget.cpp:199
bool zoomOut() noexceptoverride
Definition: symboleditorwidget.cpp:224
bool abortCommand() noexceptoverride
Definition: symboleditorwidget.cpp:234
bool processCheckMessage(std::shared_ptr< const LibraryElementCheckMessage > msg, bool applyFix) override
Definition: symboleditorwidget.cpp:441
bool rotateCw() noexceptoverride
Definition: symboleditorwidget.cpp:203
SymbolEditorWidget & operator=(const SymbolEditorWidget &rhs)=delete
bool save() noexceptoverride
Definition: symboleditorwidget.cpp:171
QScopedPointer< Symbol > mSymbol
Definition: symboleditorwidget.h:119
The SymbolEditorFsm class is the finit state machine (FSM) of the symbol editor.
Definition: symboleditorfsm.h:61
bool remove() noexceptoverride
Definition: symboleditorwidget.cpp:215
QString commitMetadata() noexcept
Definition: symboleditorwidget.cpp:264
bool cut() noexceptoverride
Definition: symboleditorwidget.cpp:191
The Symbol class represents the part of a component which is added to schematics. ...
Definition: symbol.h:57
void setToolsActionGroup(ExclusiveActionGroup *group) noexceptoverride
Definition: symboleditorwidget.cpp:142
The ExclusiveActionGroup class groups multiple QAction's together.
Definition: exclusiveactiongroup.h:50
bool toolChangeRequested(Tool newTool) noexceptoverride
Definition: symboleditorwidget.cpp:339
QScopedPointer< ComponentCategoryListEditorWidget > mCategoriesEditorWidget
Definition: symboleditorwidget.h:117
bool zoomIn() noexceptoverride
Definition: symboleditorwidget.cpp:219
The CategoryListEditorWidget class.
Definition: categorylisteditorwidget.h:117
Tool
Definition: editorwidgetbase.h:76
bool runChecks(LibraryElementCheckMessageList &msgs) const override
Definition: symboleditorwidget.cpp:368
bool mirror() noexceptoverride
Definition: symboleditorwidget.cpp:211
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
virtual bool hasGraphicalEditor() const noexceptoverride
Definition: symboleditorwidget.h:75
QScopedPointer< SymbolGraphicsItem > mGraphicsItem
Definition: symboleditorwidget.h:120
QScopedPointer< GraphicsScene > mGraphicsScene
Definition: symboleditorwidget.h:118
The SymbolGraphicsItem class.
Definition: symbolgraphicsitem.h:58
QSet< Uuid > mOriginalSymbolPinUuids
Definition: symboleditorwidget.h:124
bool rotateCcw() noexceptoverride
Definition: symboleditorwidget.cpp:207
The IF_GraphicsViewEventHandler class.
Definition: if_graphicsvieweventhandler.h:40
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
~SymbolEditorWidget() noexcept
Definition: symboleditorwidget.cpp:135
The GraphicsScene class.
Definition: graphicsscene.h:43
bool fixMsgHelper(std::shared_ptr< const LibraryElementCheckMessage > msg, bool applyFix)
Definition: symboleditorwidget.cpp:430
QScopedPointer< Ui::SymbolEditorWidget > mUi
Definition: symboleditorwidget.h:116
bool copy() noexceptoverride
Definition: symboleditorwidget.cpp:195
bool zoomAll() noexceptoverride
Definition: symboleditorwidget.cpp:229
QScopedPointer< SymbolEditorFsm > mFsm
Definition: symboleditorwidget.h:121
The EditorWidgetBase class.
Definition: editorwidgetbase.h:62
void updateMetadata() noexcept
Definition: symboleditorwidget.cpp:252