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  void setStatusBar(StatusBar* statusbar) noexcept override;
82 
83  // Operator Overloadings
84  PackageEditorWidget& operator=(const PackageEditorWidget& rhs) = delete;
85 
86 public slots:
87  bool save() noexcept override;
88  bool cut() noexcept override;
89  bool copy() noexcept override;
90  bool paste() noexcept override;
91  bool rotateCw() noexcept override;
92  bool rotateCcw() noexcept override;
93  bool mirror() noexcept override;
94  bool flip() noexcept override;
95  bool remove() noexcept override;
96  bool zoomIn() noexcept override;
97  bool zoomOut() noexcept override;
98  bool zoomAll() noexcept override;
99  bool abortCommand() noexcept override;
100  bool editGridProperties() noexcept override;
101 
102 private: // Methods
103  void updateMetadata() noexcept;
104  QString commitMetadata() noexcept;
106  bool graphicsViewEventHandler(QEvent* event) noexcept override;
107  bool toolChangeRequested(Tool newTool) noexcept override;
108  void currentFootprintChanged(int index) noexcept;
109  void memorizePackageInterface() noexcept;
110  bool isInterfaceBroken() const noexcept override;
111  bool runChecks(LibraryElementCheckMessageList& msgs) const override;
112  template <typename MessageType>
113  void fixMsg(const MessageType& msg);
114  template <typename MessageType>
115  bool fixMsgHelper(std::shared_ptr<const LibraryElementCheckMessage> msg,
116  bool applyFix);
117  bool processCheckMessage(
118  std::shared_ptr<const LibraryElementCheckMessage> msg,
119  bool applyFix) override;
120 
121 private: // Data
122  QScopedPointer<Ui::PackageEditorWidget> mUi;
123  QScopedPointer<PackageCategoryListEditorWidget> mCategoriesEditorWidget;
124  QScopedPointer<GraphicsScene> mGraphicsScene;
125  QScopedPointer<Package> mPackage;
126  QScopedPointer<PackageEditorFsm> mFsm;
127 
128  // broken interface detection
129  QSet<Uuid> mOriginalPadUuids;
131 };
132 
133 /*******************************************************************************
134  * End of File
135  ******************************************************************************/
136 
137 } // namespace editor
138 } // namespace library
139 } // namespace librepcb
140 
141 #endif // LIBREPCB_LIBRARY_EDITOR_PACKAGEEDITORWIDGET_H
QVector< std::shared_ptr< const LibraryElementCheckMessage > > LibraryElementCheckMessageList
Definition: libraryelementcheckmessage.h:96
Definition: mainwindow.h:10
Definition: airwiresbuilder.cpp:32
QScopedPointer< Ui::PackageEditorWidget > mUi
Definition: packageeditorwidget.h:122
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:77
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
The StatusBar class extends QStatusBar for some commonly used fields.
Definition: statusbar.h:44
QSet< Uuid > mOriginalPadUuids
Definition: packageeditorwidget.h:129
QScopedPointer< PackageCategoryListEditorWidget > mCategoriesEditorWidget
Definition: packageeditorwidget.h:123
FootprintList mOriginalFootprints
Definition: packageeditorwidget.h:130
QScopedPointer< Package > mPackage
Definition: packageeditorwidget.h:125
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:124
The EditorWidgetBase class.
Definition: editorwidgetbase.h:63
QScopedPointer< PackageEditorFsm > mFsm
Definition: packageeditorwidget.h:126