LibrePCB Developers Documentation
deviceeditorwidget.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_EDITOR_DEVICEEDITORWIDGET_H
21#define LIBREPCB_EDITOR_DEVICEEDITORWIDGET_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../cat/categorylisteditorwidget.h"
27#include "../editorwidgetbase.h"
28
30
31#include <QtCore>
32#include <QtWidgets>
33
34#include <memory>
35
36/*******************************************************************************
37 * Namespace / Forward Declarations
38 ******************************************************************************/
39namespace librepcb {
40
41class Component;
42class Device;
43class Package;
44class Symbol;
45
46namespace editor {
47
48class DefaultGraphicsLayerProvider;
49class FootprintGraphicsItem;
50class GraphicsScene;
51class SymbolGraphicsItem;
52
53namespace Ui {
54class DeviceEditorWidget;
55}
56
57/*******************************************************************************
58 * Class DeviceEditorWidget
59 ******************************************************************************/
60
65 Q_OBJECT
66
67public:
68 // Constructors / Destructor
70 DeviceEditorWidget(const DeviceEditorWidget& other) = delete;
71 DeviceEditorWidget(const Context& context, const FilePath& fp,
72 QWidget* parent = nullptr);
73 ~DeviceEditorWidget() noexcept;
74
75 // Getters
76 QSet<Feature> getAvailableFeatures() const noexcept override;
77
78 // Operator Overloadings
79 DeviceEditorWidget& operator=(const DeviceEditorWidget& rhs) = delete;
80
81public slots:
82 bool save() noexcept override;
83 bool zoomIn() noexcept override;
84 bool zoomOut() noexcept override;
85 bool zoomAll() noexcept override;
86
87private: // Methods
88 void updateMetadata() noexcept;
89 QString commitMetadata() noexcept;
90 void btnChooseComponentClicked() noexcept;
91 void btnChoosePackageClicked() noexcept;
92 void updateDeviceComponentUuid(const Uuid& uuid) noexcept;
93 void updateComponentPreview() noexcept;
94 void updateDevicePackageUuid(const Uuid& uuid) noexcept;
95 void updatePackagePreview() noexcept;
96 void setSelectedPart(int index) noexcept;
97 void memorizeDeviceInterface() noexcept;
98 bool isInterfaceBroken() const noexcept override;
99 bool runChecks(RuleCheckMessageList& msgs) const override;
100 template <typename MessageType>
101 void fixMsg(const MessageType& msg);
102 template <typename MessageType>
103 bool fixMsgHelper(std::shared_ptr<const RuleCheckMessage> msg, bool applyFix);
104 bool processRuleCheckMessage(std::shared_ptr<const RuleCheckMessage> msg,
105 bool applyFix) override;
106 void ruleCheckApproveRequested(std::shared_ptr<const RuleCheckMessage> msg,
107 bool approve) noexcept override;
108
109private: // Data
110 QScopedPointer<Ui::DeviceEditorWidget> mUi;
112 std::unique_ptr<Device> mDevice;
114
115 // component
116 std::shared_ptr<Component> mComponent;
118 QList<std::shared_ptr<Symbol>> mSymbols;
120
121 // package
122 QScopedPointer<Package> mPackage;
125
126 // broken interface detection
130};
131
132/*******************************************************************************
133 * End of File
134 ******************************************************************************/
135
136} // namespace editor
137} // namespace librepcb
138
139#endif
The Component class represents a "generic" device in the library.
Definition: component.h:73
The Device class represents an instance of a component (a "real" component)
Definition: device.h:55
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
The Package class represents a package of a component (including footprint and 3D model)
Definition: package.h:59
The RuleCheckMessage class.
Definition: rulecheckmessage.h:45
The Symbol class represents the part of a component which is added to schematics.
Definition: symbol.h:55
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The CategoryListEditorWidget class.
Definition: categorylisteditorwidget.h:54
The DefaultGraphicsLayerProvider class.
Definition: defaultgraphicslayerprovider.h:46
The DeviceEditorWidget class.
Definition: deviceeditorwidget.h:64
void btnChoosePackageClicked() noexcept
Definition: deviceeditorwidget.cpp:320
QScopedPointer< Ui::DeviceEditorWidget > mUi
Definition: deviceeditorwidget.h:110
bool save() noexcept override
Definition: deviceeditorwidget.cpp:190
tl::optional< Uuid > mOriginalPackageUuid
Definition: deviceeditorwidget.h:128
void updateDeviceComponentUuid(const Uuid &uuid) noexcept
Definition: deviceeditorwidget.cpp:365
void updateMetadata() noexcept
Definition: deviceeditorwidget.cpp:236
void setSelectedPart(int index) noexcept
Definition: deviceeditorwidget.cpp:464
QList< std::shared_ptr< SymbolGraphicsItem > > mSymbolGraphicsItems
Definition: deviceeditorwidget.h:119
void btnChooseComponentClicked() noexcept
Definition: deviceeditorwidget.cpp:280
QScopedPointer< DefaultGraphicsLayerProvider > mGraphicsLayerProvider
Definition: deviceeditorwidget.h:113
QScopedPointer< GraphicsScene > mComponentGraphicsScene
Definition: deviceeditorwidget.h:117
DeviceEditorWidget(const DeviceEditorWidget &other)=delete
void updatePackagePreview() noexcept
Definition: deviceeditorwidget.cpp:453
void ruleCheckApproveRequested(std::shared_ptr< const RuleCheckMessage > msg, bool approve) noexcept override
Definition: deviceeditorwidget.cpp:534
QScopedPointer< GraphicsScene > mPackageGraphicsScene
Definition: deviceeditorwidget.h:123
QScopedPointer< CategoryListEditorWidget > mCategoriesEditorWidget
Definition: deviceeditorwidget.h:111
DevicePadSignalMap mOriginalPadSignalMap
Definition: deviceeditorwidget.h:129
~DeviceEditorWidget() noexcept
Definition: deviceeditorwidget.cpp:169
std::shared_ptr< Component > mComponent
Definition: deviceeditorwidget.h:116
void updateComponentPreview() noexcept
Definition: deviceeditorwidget.cpp:394
bool zoomAll() noexcept override
Definition: deviceeditorwidget.cpp:226
QScopedPointer< Package > mPackage
Definition: deviceeditorwidget.h:122
QScopedPointer< FootprintGraphicsItem > mFootprintGraphicsItem
Definition: deviceeditorwidget.h:124
std::unique_ptr< Device > mDevice
Definition: deviceeditorwidget.h:112
void fixMsg(const MessageType &msg)
QString commitMetadata() noexcept
Definition: deviceeditorwidget.cpp:249
bool fixMsgHelper(std::shared_ptr< const RuleCheckMessage > msg, bool applyFix)
Definition: deviceeditorwidget.cpp:515
bool isInterfaceBroken() const noexcept override
Definition: deviceeditorwidget.cpp:482
void updateDevicePackageUuid(const Uuid &uuid) noexcept
Definition: deviceeditorwidget.cpp:426
QList< std::shared_ptr< Symbol > > mSymbols
Definition: deviceeditorwidget.h:118
QSet< Feature > getAvailableFeatures() const noexcept override
Definition: deviceeditorwidget.cpp:179
bool zoomIn() noexcept override
Definition: deviceeditorwidget.cpp:214
bool zoomOut() noexcept override
Definition: deviceeditorwidget.cpp:220
bool runChecks(RuleCheckMessageList &msgs) const override
Definition: deviceeditorwidget.cpp:489
void memorizeDeviceInterface() noexcept
Definition: deviceeditorwidget.cpp:476
tl::optional< Uuid > mOriginalComponentUuid
Definition: deviceeditorwidget.h:127
bool processRuleCheckMessage(std::shared_ptr< const RuleCheckMessage > msg, bool applyFix) override
Definition: deviceeditorwidget.cpp:526
The EditorWidgetBase class.
Definition: editorwidgetbase.h:62
Feature
Definition: editorwidgetbase.h:95
The FootprintGraphicsItem class.
Definition: footprintgraphicsitem.h:66
The GraphicsScene class.
Definition: graphicsscene.h:45
The SymbolGraphicsItem class.
Definition: symbolgraphicsitem.h:56
Definition: occmodel.cpp:77
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition: rulecheckmessage.h:104
Definition: uuid.h:183
Definition: editorwidgetbase.h:68