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 
78  // Setters
79  void setToolsActionGroup(ExclusiveActionGroup* group) noexcept override;
80 
81  // Operator Overloadings
83 
84 public slots:
85  bool save() noexcept override;
86  bool cut() noexcept override;
87  bool copy() noexcept override;
88  bool paste() noexcept override;
89  bool rotateCw() noexcept override;
90  bool rotateCcw() 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  void currentFootprintChanged(int index) noexcept;
105  void memorizePackageInterface() noexcept;
106  bool isInterfaceBroken() const noexcept override;
107  bool runChecks(LibraryElementCheckMessageList& msgs) const override;
108  template <typename MessageType>
109  void fixMsg(const MessageType& msg);
110  template <typename MessageType>
111  bool fixMsgHelper(std::shared_ptr<const LibraryElementCheckMessage> msg,
112  bool applyFix);
113  bool processCheckMessage(
114  std::shared_ptr<const LibraryElementCheckMessage> msg,
115  bool applyFix) override;
116 
117 private: // Data
118  QScopedPointer<Ui::PackageEditorWidget> mUi;
120  QScopedPointer<GraphicsScene> mGraphicsScene;
121  QScopedPointer<Package> mPackage;
122  QScopedPointer<PackageEditorFsm> mFsm;
123 
124  // broken interface detection
127 };
128 
129 /*******************************************************************************
130  * End of File
131  ******************************************************************************/
132 
133 } // namespace editor
134 } // namespace library
135 } // namespace librepcb
136 
137 #endif // LIBREPCB_LIBRARY_EDITOR_PACKAGEEDITORWIDGET_H
bool abortCommand() noexceptoverride
Definition: packageeditorwidget.cpp:245
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:249
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:306
bool cut() noexceptoverride
Definition: packageeditorwidget.cpp:206
bool zoomAll() noexceptoverride
Definition: packageeditorwidget.cpp:240
bool processCheckMessage(std::shared_ptr< const LibraryElementCheckMessage > msg, bool applyFix) override
Definition: packageeditorwidget.cpp:476
QScopedPointer< Ui::PackageEditorWidget > mUi
Definition: packageeditorwidget.h:118
bool zoomIn() noexceptoverride
Definition: packageeditorwidget.cpp:230
The ExclusiveActionGroup class groups multiple QAction's together.
Definition: exclusiveactiongroup.h:50
bool runChecks(LibraryElementCheckMessageList &msgs) const override
Definition: packageeditorwidget.cpp:400
bool isInterfaceBroken() const noexceptoverride
Definition: packageeditorwidget.cpp:388
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:235
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:379
QSet< Uuid > mOriginalPadUuids
Definition: packageeditorwidget.h:125
bool save() noexceptoverride
Definition: packageeditorwidget.cpp:186
QScopedPointer< PackageCategoryListEditorWidget > mCategoriesEditorWidget
Definition: packageeditorwidget.h:119
FootprintList mOriginalFootprints
Definition: packageeditorwidget.h:126
bool paste() noexceptoverride
Definition: packageeditorwidget.cpp:214
QScopedPointer< Package > mPackage
Definition: packageeditorwidget.h:121
void setToolsActionGroup(ExclusiveActionGroup *group) noexceptoverride
Definition: packageeditorwidget.cpp:155
void memorizePackageInterface() noexcept
Definition: packageeditorwidget.cpp:383
~PackageEditorWidget() noexcept
Definition: packageeditorwidget.cpp:145
The IF_GraphicsViewEventHandler class.
Definition: if_graphicsvieweventhandler.h:40
QScopedPointer< GraphicsScene > mGraphicsScene
Definition: packageeditorwidget.h:120
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 fixMsgHelper(std::shared_ptr< const LibraryElementCheckMessage > msg, bool applyFix)
Definition: packageeditorwidget.cpp:465
bool toolChangeRequested(Tool newTool) noexceptoverride
Definition: packageeditorwidget.cpp:350
void updateMetadata() noexcept
Definition: packageeditorwidget.cpp:263
QString commitMetadata() noexcept
Definition: packageeditorwidget.cpp:275
The EditorWidgetBase class.
Definition: editorwidgetbase.h:62
QScopedPointer< PackageEditorFsm > mFsm
Definition: packageeditorwidget.h:122
bool remove() noexceptoverride
Definition: packageeditorwidget.cpp:226