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 
65 class SymbolEditorWidget final : public EditorWidgetBase,
67  Q_OBJECT
68 
69 public:
70  // Constructors / Destructor
71  SymbolEditorWidget() = delete;
72  SymbolEditorWidget(const SymbolEditorWidget& other) = delete;
73  SymbolEditorWidget(const Context& context, const FilePath& fp,
74  QWidget* parent = nullptr);
75  ~SymbolEditorWidget() noexcept;
76 
77  // Getters
78  virtual bool hasGraphicalEditor() const noexcept override { return true; }
79 
80  // Setters
81  void setToolsActionGroup(ExclusiveActionGroup* group) noexcept override;
82 
83  // Operator Overloadings
84  SymbolEditorWidget& operator=(const SymbolEditorWidget& rhs) = delete;
85 
86 public slots:
87  bool save() noexcept override;
88  bool rotateCw() noexcept override;
89  bool rotateCcw() noexcept override;
90  bool remove() noexcept override;
91  bool zoomIn() noexcept override;
92  bool zoomOut() noexcept override;
93  bool zoomAll() noexcept override;
94  bool abortCommand() noexcept override;
95  bool editGridProperties() noexcept override;
96 
97 private: // Methods
98  void updateMetadata() noexcept;
99  QString commitMetadata() noexcept;
101  bool graphicsViewEventHandler(QEvent* event) noexcept override;
102  bool toolChangeRequested(Tool newTool) noexcept override;
103  bool isInterfaceBroken() const noexcept override;
104  bool runChecks(LibraryElementCheckMessageList& msgs) const override;
105  template <typename MessageType>
106  void fixMsg(const MessageType& msg);
107  template <typename MessageType>
108  bool fixMsgHelper(std::shared_ptr<const LibraryElementCheckMessage> msg,
109  bool applyFix);
110  bool processCheckMessage(
111  std::shared_ptr<const LibraryElementCheckMessage> msg,
112  bool applyFix) override;
113 
114 private: // Data
115  QScopedPointer<Ui::SymbolEditorWidget> mUi;
117  QScopedPointer<GraphicsScene> mGraphicsScene;
118  QScopedPointer<Symbol> mSymbol;
120  QScopedPointer<SymbolEditorFsm> mFsm;
121 
122  // broken interface detection
124 };
125 
126 /*******************************************************************************
127  * End of File
128  ******************************************************************************/
129 
130 } // namespace editor
131 } // namespace library
132 } // namespace librepcb
133 
134 #endif // LIBREPCB_LIBRARY_EDITOR_SYMBOLEDITORWIDGET_H
bool editGridProperties() noexceptoverride
Definition: symboleditorwidget.cpp:220
QVector< std::shared_ptr< const LibraryElementCheckMessage > > LibraryElementCheckMessageList
Definition: libraryelementcheckmessage.h:96
bool isInterfaceBroken() const noexceptoverride
Definition: symboleditorwidget.cpp:346
bool graphicsViewEventHandler(QEvent *event) noexceptoverride
The event handler method.
Definition: symboleditorwidget.cpp:277
The LibraryElementCheckMessage class.
Definition: libraryelementcheckmessage.h:44
The SymbolEditorWidget class.
Definition: symboleditorwidget.h:65
bool zoomOut() noexceptoverride
Definition: symboleditorwidget.cpp:206
bool abortCommand() noexceptoverride
Definition: symboleditorwidget.cpp:216
bool processCheckMessage(std::shared_ptr< const LibraryElementCheckMessage > msg, bool applyFix) override
Definition: symboleditorwidget.cpp:423
bool rotateCw() noexceptoverride
Definition: symboleditorwidget.cpp:189
SymbolEditorWidget & operator=(const SymbolEditorWidget &rhs)=delete
bool save() noexceptoverride
Definition: symboleditorwidget.cpp:170
QScopedPointer< Symbol > mSymbol
Definition: symboleditorwidget.h:118
The SymbolEditorFsm class is the finit state machine (FSM) of the symbol editor.
Definition: symboleditorfsm.h:64
bool remove() noexceptoverride
Definition: symboleditorwidget.cpp:197
QString commitMetadata() noexcept
Definition: symboleditorwidget.cpp:246
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:141
The ExclusiveActionGroup class groups multiple QAction's together.
Definition: exclusiveactiongroup.h:53
bool toolChangeRequested(Tool newTool) noexceptoverride
Definition: symboleditorwidget.cpp:321
QScopedPointer< ComponentCategoryListEditorWidget > mCategoriesEditorWidget
Definition: symboleditorwidget.h:116
bool zoomIn() noexceptoverride
Definition: symboleditorwidget.cpp:201
The CategoryListEditorWidget class.
Definition: categorylisteditorwidget.h:123
Tool
Definition: editorwidgetbase.h:79
bool runChecks(LibraryElementCheckMessageList &msgs) const override
Definition: symboleditorwidget.cpp:350
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:130
virtual bool hasGraphicalEditor() const noexceptoverride
Definition: symboleditorwidget.h:78
QScopedPointer< SymbolGraphicsItem > mGraphicsItem
Definition: symboleditorwidget.h:119
QScopedPointer< GraphicsScene > mGraphicsScene
Definition: symboleditorwidget.h:117
The SymbolGraphicsItem class.
Definition: symbolgraphicsitem.h:61
QSet< Uuid > mOriginalSymbolPinUuids
Definition: symboleditorwidget.h:123
bool rotateCcw() noexceptoverride
Definition: symboleditorwidget.cpp:193
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:134
The GraphicsScene class.
Definition: graphicsscene.h:43
bool fixMsgHelper(std::shared_ptr< const LibraryElementCheckMessage > msg, bool applyFix)
Definition: symboleditorwidget.cpp:412
QScopedPointer< Ui::SymbolEditorWidget > mUi
Definition: symboleditorwidget.h:115
bool zoomAll() noexceptoverride
Definition: symboleditorwidget.cpp:211
QScopedPointer< SymbolEditorFsm > mFsm
Definition: symboleditorwidget.h:120
The EditorWidgetBase class.
Definition: editorwidgetbase.h:66
void updateMetadata() noexcept
Definition: symboleditorwidget.cpp:234