LibrePCB Developers Documentation
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
83  PackageEditorWidget& operator=(const PackageEditorWidget& rhs) = delete;
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;
122  QScopedPointer<PackageCategoryListEditorWidget> mCategoriesEditorWidget;
123  QScopedPointer<GraphicsScene> mGraphicsScene;
124  QScopedPointer<Package> mPackage;
125  QScopedPointer<PackageEditorFsm> mFsm;
126 
127  // broken interface detection
128  QSet<Uuid> mOriginalPadUuids;
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
QVector< std::shared_ptr< const LibraryElementCheckMessage > > LibraryElementCheckMessageList
Definition: libraryelementcheckmessage.h:96
Definition: mainwindow.h:10
Definition: alignment.cpp:30
QScopedPointer< Ui::PackageEditorWidget > mUi
Definition: packageeditorwidget.h:121
The ExclusiveActionGroup class groups multiple QAction&#39;s together.
Definition: exclusiveactiongroup.h:50
virtual bool supportsFlip() const noexcept override
Definition: packageeditorwidget.h:77
The PackageEditorWidget class.
Definition: packageeditorwidget.h:63
Tool
Definition: editorwidgetbase.h:76
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
QSet< Uuid > mOriginalPadUuids
Definition: packageeditorwidget.h:128
QScopedPointer< PackageCategoryListEditorWidget > mCategoriesEditorWidget
Definition: packageeditorwidget.h:122
FootprintList mOriginalFootprints
Definition: packageeditorwidget.h:129
QScopedPointer< Package > mPackage
Definition: packageeditorwidget.h:124
virtual bool hasGraphicalEditor() const noexcept override
Definition: packageeditorwidget.h:76
The IF_GraphicsViewEventHandler class.
Definition: if_graphicsvieweventhandler.h:40
QScopedPointer< GraphicsScene > mGraphicsScene
Definition: packageeditorwidget.h:123
The EditorWidgetBase class.
Definition: editorwidgetbase.h:62
QScopedPointer< PackageEditorFsm > mFsm
Definition: packageeditorwidget.h:125