LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
packageeditorwidget.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_PACKAGEEDITORWIDGET_H
21 #define LIBREPCB_LIBRARY_EDITOR_PACKAGEEDITORWIDGET_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../common/categorylisteditorwidget.h"
27 #include "../common/editorwidgetbase.h"
28 
31 
32 #include <QtCore>
33 #include <QtWidgets>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 
40 class GridProperties;
41 class GraphicsScene;
42 
43 namespace library {
44 
45 class Package;
46 class FootprintGraphicsItem;
47 
48 namespace editor {
49 
50 class PackageEditorFsm;
51 
52 namespace Ui {
53 class PackageEditorWidget;
54 }
55 
56 /*******************************************************************************
57  * Class PackageEditorWidget
58  ******************************************************************************/
59 
65  Q_OBJECT
66 
67 public:
68  // Constructors / Destructor
69  PackageEditorWidget() = delete;
70  PackageEditorWidget(const PackageEditorWidget& other) = delete;
71  PackageEditorWidget(const Context& context, const FilePath& fp,
72  QWidget* parent = nullptr);
73  ~PackageEditorWidget() noexcept;
74 
75  // Getters
76  virtual bool hasGraphicalEditor() const noexcept override { return true; }
77  virtual bool supportsFlip() const noexcept override { return true; }
78 
79  // Setters
80  void setToolsActionGroup(ExclusiveActionGroup* group) noexcept override;
81 
82  // Operator Overloadings
84 
85 public slots:
86  bool save() noexcept override;
87  bool cut() noexcept override;
88  bool copy() noexcept override;
89  bool paste() noexcept override;
90  bool rotateCw() noexcept override;
91  bool rotateCcw() noexcept override;
92  bool mirror() noexcept override;
93  bool flip() noexcept override;
94  bool remove() noexcept override;
95  bool zoomIn() noexcept override;
96  bool zoomOut() noexcept override;
97  bool zoomAll() noexcept override;
98  bool abortCommand() noexcept override;
99  bool editGridProperties() noexcept override;
100 
101 private: // Methods
102  void updateMetadata() noexcept;
103  QString commitMetadata() noexcept;
105  bool graphicsViewEventHandler(QEvent* event) noexcept override;
106  bool toolChangeRequested(Tool newTool) noexcept override;
107  void currentFootprintChanged(int index) noexcept;
108  void memorizePackageInterface() noexcept;
109  bool isInterfaceBroken() const noexcept override;
110  bool runChecks(LibraryElementCheckMessageList& msgs) const override;
111  template <typename MessageType>
112  void fixMsg(const MessageType& msg);
113  template <typename MessageType>
114  bool fixMsgHelper(std::shared_ptr<const LibraryElementCheckMessage> msg,
115  bool applyFix);
116  bool processCheckMessage(
117  std::shared_ptr<const LibraryElementCheckMessage> msg,
118  bool applyFix) override;
119 
120 private: // Data
121  QScopedPointer<Ui::PackageEditorWidget> mUi;
123  QScopedPointer<GraphicsScene> mGraphicsScene;
124  QScopedPointer<Package> mPackage;
125  QScopedPointer<PackageEditorFsm> mFsm;
126 
127  // broken interface detection
130 };
131 
132 /*******************************************************************************
133  * End of File
134  ******************************************************************************/
135 
136 } // namespace editor
137 } // namespace library
138 } // namespace librepcb
139 
140 #endif // LIBREPCB_LIBRARY_EDITOR_PACKAGEEDITORWIDGET_H
bool abortCommand() noexceptoverride
Definition: packageeditorwidget.cpp:253
QVector< std::shared_ptr< const LibraryElementCheckMessage > > LibraryElementCheckMessageList
Definition: libraryelementcheckmessage.h:96
bool rotateCw() noexceptoverride
Definition: packageeditorwidget.cpp:218
The LibraryElementCheckMessage class.
Definition: libraryelementcheckmessage.h:44
bool rotateCcw() noexceptoverride
Definition: packageeditorwidget.cpp:222
bool editGridProperties() noexceptoverride
Definition: packageeditorwidget.cpp:257
The Package class represents a package of a component (including footprint and 3D model) ...
Definition: package.h:56
bool graphicsViewEventHandler(QEvent *event) noexceptoverride
The event handler method.
Definition: packageeditorwidget.cpp:314
bool cut() noexceptoverride
Definition: packageeditorwidget.cpp:206
bool zoomAll() noexceptoverride
Definition: packageeditorwidget.cpp:248
bool processCheckMessage(std::shared_ptr< const LibraryElementCheckMessage > msg, bool applyFix) override
Definition: packageeditorwidget.cpp:484
QScopedPointer< Ui::PackageEditorWidget > mUi
Definition: packageeditorwidget.h:121
bool zoomIn() noexceptoverride
Definition: packageeditorwidget.cpp:238
The ExclusiveActionGroup class groups multiple QAction's together.
Definition: exclusiveactiongroup.h:50
bool runChecks(LibraryElementCheckMessageList &msgs) const override
Definition: packageeditorwidget.cpp:408
bool isInterfaceBroken() const noexceptoverride
Definition: packageeditorwidget.cpp:396
The PackageEditorWidget class.
Definition: packageeditorwidget.h:63
The CategoryListEditorWidget class.
Definition: categorylisteditorwidget.h:117
Tool
Definition: editorwidgetbase.h:76
bool zoomOut() noexceptoverride
Definition: packageeditorwidget.cpp:243
bool copy() noexceptoverride
Definition: packageeditorwidget.cpp:210
The PackageEditorFsm class is the finit state machine (FSM) of the package editor.
Definition: packageeditorfsm.h:63
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
void currentFootprintChanged(int index) noexcept
Definition: packageeditorwidget.cpp:387
QSet< Uuid > mOriginalPadUuids
Definition: packageeditorwidget.h:128
bool save() noexceptoverride
Definition: packageeditorwidget.cpp:186
QScopedPointer< PackageCategoryListEditorWidget > mCategoriesEditorWidget
Definition: packageeditorwidget.h:122
virtual bool supportsFlip() const noexceptoverride
Definition: packageeditorwidget.h:77
FootprintList mOriginalFootprints
Definition: packageeditorwidget.h:129
bool paste() noexceptoverride
Definition: packageeditorwidget.cpp:214
QScopedPointer< Package > mPackage
Definition: packageeditorwidget.h:124
void setToolsActionGroup(ExclusiveActionGroup *group) noexceptoverride
Definition: packageeditorwidget.cpp:155
void memorizePackageInterface() noexcept
Definition: packageeditorwidget.cpp:391
~PackageEditorWidget() noexcept
Definition: packageeditorwidget.cpp:145
The IF_GraphicsViewEventHandler class.
Definition: if_graphicsvieweventhandler.h:40
QScopedPointer< GraphicsScene > mGraphicsScene
Definition: packageeditorwidget.h:123
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
virtual bool hasGraphicalEditor() const noexceptoverride
Definition: packageeditorwidget.h:76
The GraphicsScene class.
Definition: graphicsscene.h:43
PackageEditorWidget & operator=(const PackageEditorWidget &rhs)=delete
bool mirror() noexceptoverride
Definition: packageeditorwidget.cpp:226
bool fixMsgHelper(std::shared_ptr< const LibraryElementCheckMessage > msg, bool applyFix)
Definition: packageeditorwidget.cpp:473
bool toolChangeRequested(Tool newTool) noexceptoverride
Definition: packageeditorwidget.cpp:358
void updateMetadata() noexcept
Definition: packageeditorwidget.cpp:271
QString commitMetadata() noexcept
Definition: packageeditorwidget.cpp:283
The EditorWidgetBase class.
Definition: editorwidgetbase.h:62
QScopedPointer< PackageEditorFsm > mFsm
Definition: packageeditorwidget.h:125
bool flip() noexceptoverride
Definition: packageeditorwidget.cpp:230
bool remove() noexceptoverride
Definition: packageeditorwidget.cpp:234