LibrePCB Developers Documentation
Loading...
Searching...
No Matches
eaglelibraryimport.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_EAGLEIMPORT_EAGLELIBRARYIMPORT_H
21#define LIBREPCB_EAGLEIMPORT_EAGLELIBRARYIMPORT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
28
29#include <QtCore>
30
31#include <memory>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace parseagle {
37class Device;
38class DeviceSet;
39class Package;
40class Symbol;
41class Wire;
42} // namespace parseagle
43
44namespace librepcb {
45
46class MessageLogger;
47
48namespace eagleimport {
49
50struct EagleLibraryConverterSettings;
51
52/*******************************************************************************
53 * Class EagleLibraryImport
54 ******************************************************************************/
55
59class EagleLibraryImport final : public QThread {
60 Q_OBJECT
61
62public:
63 struct Symbol {
64 QString displayName; // Same as symbol->getName()
65 QString description; // Same as symbol->getDescription()
66 Qt::CheckState checkState;
67 std::shared_ptr<parseagle::Symbol> symbol;
68 };
69
70 struct Package {
71 QString displayName; // Same as package->getName()
72 QString description; // Same as package->getDescription()
73 Qt::CheckState checkState;
74 std::shared_ptr<parseagle::Package> package;
75 };
76
77 struct Component {
78 QString displayName; // Like deviceSet->getName() but without trailing [-_]
79 QString description; // Same as deviceSet->getDescription()
80 Qt::CheckState checkState;
81 QSet<QString> symbolDisplayNames;
82 std::shared_ptr<parseagle::DeviceSet> deviceSet;
83 };
84
85 struct Device {
86 QString displayName; // Built from names of deviceSet and device
87 QString description; // Same as deviceSet->getDescription()
88 Qt::CheckState checkState;
91 std::shared_ptr<parseagle::Device> device;
92 std::shared_ptr<parseagle::DeviceSet> deviceSet;
93 };
94
95 // Constructors / Destructor
96 EagleLibraryImport(const EagleLibraryImport& other) = delete;
97 EagleLibraryImport(const FilePath& dstLibFp,
98 QObject* parent = nullptr) noexcept;
99 ~EagleLibraryImport() noexcept;
100
101 // Getters
102 std::shared_ptr<MessageLogger> getLogger() const noexcept { return mLogger; }
103 const FilePath& getLoadedFilePath() const noexcept { return mLoadedFilePath; }
104 int getTotalElementsCount() const noexcept;
105 int getCheckedElementsCount() const noexcept;
106 int getCheckedSymbolsCount() const noexcept;
107 int getCheckedPackagesCount() const noexcept;
108 int getCheckedComponentsCount() const noexcept;
109 int getCheckedDevicesCount() const noexcept;
110 const QVector<Symbol>& getSymbols() const noexcept { return mSymbols; }
111 const QVector<Package>& getPackages() const noexcept { return mPackages; }
112 const QVector<Component>& getComponents() const noexcept {
113 return mComponents;
114 }
115 const QVector<Device>& getDevices() const noexcept { return mDevices; }
116
117 // Setters
118 void setNamePrefix(const QString& prefix) noexcept;
119 void setSymbolCategories(const QSet<Uuid>& uuids) noexcept;
120 void setPackageCategories(const QSet<Uuid>& uuids) noexcept;
121 void setComponentCategories(const QSet<Uuid>& uuids) noexcept;
122 void setDeviceCategories(const QSet<Uuid>& uuids) noexcept;
123 void setSymbolChecked(const QString& name, bool checked) noexcept;
124 void setPackageChecked(const QString& name, bool checked) noexcept;
125 void setComponentChecked(const QString& name, bool checked) noexcept;
126 void setDeviceChecked(const QString& name, bool checked) noexcept;
127
128 // General Methods
129 void reset() noexcept;
130 QStringList open(const FilePath& lbr);
131
132 // Operator Overloadings
133 EagleLibraryImport& operator=(const EagleLibraryImport& rhs) = delete;
134
135signals:
136 void symbolCheckStateChanged(const QString& name, Qt::CheckState state);
137 void packageCheckStateChanged(const QString& name, Qt::CheckState state);
138 void componentCheckStateChanged(const QString& name, Qt::CheckState state);
139 void progressStatus(const QString& status);
140 void progressPercent(int percent);
141 void finished();
142
143private: // Methods
144 template <typename T>
145 int getCheckedElementsCount(const QVector<T>& elements) const noexcept;
146 template <typename T>
147 void setElementChecked(QVector<T>& elements, const QString& name,
148 bool checked) noexcept;
149 void updateDependencies() noexcept;
150 template <typename T>
151 bool setElementDependent(T& element, bool dependent) noexcept;
152 void run() noexcept override;
153
154private: // Data
158
159 // State
160 bool mAbort;
162
163 // Library elements
164 QVector<Symbol> mSymbols;
167 QVector<Device> mDevices;
168};
169
170/*******************************************************************************
171 * End of File
172 ******************************************************************************/
173
174} // namespace eagleimport
175} // namespace librepcb
176
177#endif
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
Generic logger class to pass messages between objects.
Definition messagelogger.h:43
EAGLE library (*.lbr) import.
Definition eaglelibraryimport.h:59
int getCheckedElementsCount() const noexcept
Definition eaglelibraryimport.cpp:73
const QVector< Package > & getPackages() const noexcept
Definition eaglelibraryimport.h:111
void run() noexcept override
Definition eaglelibraryimport.cpp:318
const QVector< Device > & getDevices() const noexcept
Definition eaglelibraryimport.h:115
QVector< Device > mDevices
Definition eaglelibraryimport.h:167
int getCheckedDevicesCount() const noexcept
Definition eaglelibraryimport.cpp:90
const QVector< Component > & getComponents() const noexcept
Definition eaglelibraryimport.h:112
void reset() noexcept
Definition eaglelibraryimport.cpp:144
void setPackageCategories(const QSet< Uuid > &uuids) noexcept
Definition eaglelibraryimport.cpp:106
void packageCheckStateChanged(const QString &name, Qt::CheckState state)
bool mAbort
Definition eaglelibraryimport.h:160
std::shared_ptr< MessageLogger > getLogger() const noexcept
Definition eaglelibraryimport.h:102
void updateDependencies() noexcept
Definition eaglelibraryimport.cpp:271
int getTotalElementsCount() const noexcept
Definition eaglelibraryimport.cpp:68
int getCheckedComponentsCount() const noexcept
Definition eaglelibraryimport.cpp:86
const FilePath & getLoadedFilePath() const noexcept
Definition eaglelibraryimport.h:103
QVector< Package > mPackages
Definition eaglelibraryimport.h:165
QVector< Symbol > mSymbols
Definition eaglelibraryimport.h:164
QVector< Component > mComponents
Definition eaglelibraryimport.h:166
const QVector< Symbol > & getSymbols() const noexcept
Definition eaglelibraryimport.h:110
void setDeviceChecked(const QString &name, bool checked) noexcept
Definition eaglelibraryimport.cpp:135
int getCheckedSymbolsCount() const noexcept
Definition eaglelibraryimport.cpp:78
void setElementChecked(QVector< T > &elements, const QString &name, bool checked) noexcept
Definition eaglelibraryimport.cpp:255
void setNamePrefix(const QString &prefix) noexcept
Definition eaglelibraryimport.cpp:98
void setSymbolCategories(const QSet< Uuid > &uuids) noexcept
Definition eaglelibraryimport.cpp:102
std::shared_ptr< MessageLogger > mLogger
Definition eaglelibraryimport.h:157
void componentCheckStateChanged(const QString &name, Qt::CheckState state)
bool setElementDependent(T &element, bool dependent) noexcept
Definition eaglelibraryimport.cpp:306
QStringList open(const FilePath &lbr)
Definition eaglelibraryimport.cpp:152
void symbolCheckStateChanged(const QString &name, Qt::CheckState state)
void progressStatus(const QString &status)
void setComponentCategories(const QSet< Uuid > &uuids) noexcept
Definition eaglelibraryimport.cpp:111
int getCheckedPackagesCount() const noexcept
Definition eaglelibraryimport.cpp:82
FilePath mLoadedFilePath
Definition eaglelibraryimport.h:161
EagleLibraryImport(const EagleLibraryImport &other)=delete
void setDeviceCategories(const QSet< Uuid > &uuids) noexcept
Definition eaglelibraryimport.cpp:116
void setPackageChecked(const QString &name, bool checked) noexcept
Definition eaglelibraryimport.cpp:125
void setSymbolChecked(const QString &name, bool checked) noexcept
Definition eaglelibraryimport.cpp:120
const FilePath mDestinationLibraryFp
Definition eaglelibraryimport.h:155
QScopedPointer< EagleLibraryConverterSettings > mSettings
Definition eaglelibraryimport.h:156
void setComponentChecked(const QString &name, bool checked) noexcept
Definition eaglelibraryimport.cpp:130
Definition occmodel.cpp:76
Definition eaglelibraryconverter.h:38
Definition uuid.h:186
Settings for librepcb::eagleimport::EagleLibraryConverter.
Definition eaglelibraryconverter.h:64
Qt::CheckState checkState
Definition eaglelibraryimport.h:80
QString description
Definition eaglelibraryimport.h:79
QSet< QString > symbolDisplayNames
Definition eaglelibraryimport.h:81
QString displayName
Definition eaglelibraryimport.h:78
std::shared_ptr< parseagle::DeviceSet > deviceSet
Definition eaglelibraryimport.h:82
Definition eaglelibraryimport.h:85
std::shared_ptr< parseagle::Device > device
Definition eaglelibraryimport.h:91
Qt::CheckState checkState
Definition eaglelibraryimport.h:88
QString description
Definition eaglelibraryimport.h:87
QString packageDisplayName
Definition eaglelibraryimport.h:90
QString displayName
Definition eaglelibraryimport.h:86
QString componentDisplayName
Definition eaglelibraryimport.h:89
std::shared_ptr< parseagle::DeviceSet > deviceSet
Definition eaglelibraryimport.h:92
Definition eaglelibraryimport.h:70
std::shared_ptr< parseagle::Package > package
Definition eaglelibraryimport.h:74
Qt::CheckState checkState
Definition eaglelibraryimport.h:73
QString description
Definition eaglelibraryimport.h:72
QString displayName
Definition eaglelibraryimport.h:71
Definition eaglelibraryimport.h:63
Qt::CheckState checkState
Definition eaglelibraryimport.h:66
QString description
Definition eaglelibraryimport.h:65
std::shared_ptr< parseagle::Symbol > symbol
Definition eaglelibraryimport.h:67
QString displayName
Definition eaglelibraryimport.h:64