LibrePCB Developers Documentation
Loading...
Searching...
No Matches
eagleprojectimport.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_EAGLEPROJECTIMPORT_H
21#define LIBREPCB_EAGLEIMPORT_EAGLEPROJECTIMPORT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
28
29#include <QtCore>
30
31#include <memory>
32#include <optional>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace parseagle {
38class Board;
39class Device;
40class DeviceSet;
41class Library;
42class Net;
43class Package;
44class Part;
45class Schematic;
46class Sheet;
47class Symbol;
48class Technology;
49} // namespace parseagle
50
51namespace librepcb {
52
53class Board;
54class Component;
55class Device;
56class FilePath;
57class MessageLogger;
58class NetSignal;
59class Package;
60class Project;
61class ProjectLibrary;
62class Schematic;
63class Symbol;
64
65namespace eagleimport {
66
67class EagleLibraryConverter;
68
69/*******************************************************************************
70 * Class EagleProjectImport
71 ******************************************************************************/
72
76class EagleProjectImport final : public QObject {
77 Q_OBJECT
78
79public:
80 // Constructors / Destructor
81 EagleProjectImport(const EagleProjectImport& other) = delete;
82 explicit EagleProjectImport(QObject* parent = nullptr) noexcept;
83 ~EagleProjectImport() noexcept;
84
85 // Getters
86 std::shared_ptr<MessageLogger> getLogger() const noexcept { return mLogger; }
87 bool isReady() const noexcept { return !mSchematic.isNull(); }
88 const QString& getProjectName() const noexcept { return mProjectName; }
89 int getSheetCount() const noexcept;
90 bool hasBoard() const noexcept { return !mBoard.isNull(); }
91
92 // General Methods
93 void reset() noexcept;
94 QStringList open(const FilePath& sch, const FilePath& brd);
95 void import(Project& project);
96
97 // Operator Overloadings
98 EagleProjectImport& operator=(const EagleProjectImport& rhs) = delete;
99
100private: // Methods
102 ProjectLibrary& library,
103 const QString& libName,
104 const QString& libUrn,
105 const QString& symName);
107 ProjectLibrary& library,
108 const QString& libName,
109 const QString& libUrn,
110 const QString& devSetName);
112 ProjectLibrary& library,
113 const QString& libName,
114 const QString& libUrn,
115 const QString& pkgName);
117 EagleLibraryConverter& converter, ProjectLibrary& library,
118 const QString& devLibName, const QString& devLibUrn,
119 const QString& devSetName, const QString& devName,
120 const QString& pkgLibName, const QString& pkgLibUrn);
121 NetSignal& importNet(Project& project, const parseagle::Net& net);
122 void importLibraries(const QList<parseagle::Library>& libs, bool isBoard);
123 void importSchematic(Project& project, EagleLibraryConverter& converter,
124 const parseagle::Sheet& sheet);
125 void importBoard(Project& project, EagleLibraryConverter& converter);
126 bool hasBuses(const parseagle::Schematic& schematic) const noexcept;
127 std::optional<BoundedUnsignedRatio> tryGetDrcRatio(const QString& nr,
128 const QString& nmin,
129 const QString& nmax) const;
130 std::shared_ptr<const parseagle::Symbol> getSymbol(const QString& libName,
131 const QString& libUrn,
132 const QString& name) const;
133 std::shared_ptr<const parseagle::Package> getPackage(
134 const QString& libName, const QString& libUrn, const QString& name) const;
135 std::shared_ptr<const parseagle::DeviceSet> getDeviceSet(
136 const QString& libName, const QString& libUrn, const QString& name) const;
137 const parseagle::Device& getDevice(const parseagle::DeviceSet& devSet,
138 const QString& name) const;
139 const parseagle::Technology* tryGetTechnology(const parseagle::Device& dev,
140 const QString& name) const;
141 const parseagle::Part& getPart(const QString& name) const;
142
143private: // Data
147 QScopedPointer<parseagle::Board> mBoard;
148
150 QHash<QStringList, std::shared_ptr<const parseagle::Symbol>> mSymbols;
151
153 QHash<QStringList, std::shared_ptr<const parseagle::Package>> mPackages;
154
156 QHash<QStringList, std::shared_ptr<const parseagle::DeviceSet>> mDeviceSets;
157
159 QHash<QStringList, Uuid> mLibSymbolMap;
160
162 QHash<QStringList, Uuid> mLibComponentMap;
163
165 QHash<QStringList, Uuid> mLibComponentGateMap;
166
168 QHash<QStringList, Uuid> mLibPackageMap;
169
171 QHash<QStringList, Uuid> mLibDeviceMap;
172
174 QString libName;
175 QString libUrn;
176 QString devSetName;
177 QString devName;
179 };
180 QHash<QString, ComponentMap> mComponentMap;
181
183 QSet<QString> mSchematicDirNames;
184
186 QHash<QString, Uuid> mNetSignalMap;
187};
188
189/*******************************************************************************
190 * End of File
191 ******************************************************************************/
192
193} // namespace eagleimport
194} // namespace librepcb
195
196#endif
The Board class represents a PCB of a project and is always part of a circuit.
Definition board.h:73
The BoundedUnsignedRatio class represents a ratio limited to a range specified by min/max values.
Definition boundedunsignedratio.h:46
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:127
The Library class represents a library directory.
Definition library.h:46
Generic logger class to pass messages between objects.
Definition messagelogger.h:43
The NetSignal class.
Definition netsignal.h:50
The Package class represents a package of a component (including footprint and 3D model)
Definition package.h:59
The Part class.
Definition part.h:46
The Project class represents a whole (opened) project with all its content.
Definition project.h:71
The ProjectLibrary class.
Definition projectlibrary.h:52
The Schematic class represents one schematic page of a project and is always part of a circuit.
Definition schematic.h:74
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:56
Converts EAGLE library elements to LibrePCB.
Definition eaglelibraryconverter.h:85
Loads and imports an EAGLE project into a librepcb::Project.
Definition eagleprojectimport.h:76
int getSheetCount() const noexcept
Definition eagleprojectimport.cpp:95
QHash< QStringList, Uuid > mLibSymbolMap
Key={libName, libUrn, symName}, Value=libSymUuid.
Definition eagleprojectimport.h:159
QHash< QStringList, std::shared_ptr< const parseagle::Package > > mPackages
Key={libName, libUrn, pkgName}.
Definition eagleprojectimport.h:153
const parseagle::Technology * tryGetTechnology(const parseagle::Device &dev, const QString &name) const
Definition eagleprojectimport.cpp:1335
void reset() noexcept
Definition eagleprojectimport.cpp:103
const Package & importLibraryPackage(EagleLibraryConverter &converter, ProjectLibrary &library, const QString &libName, const QString &libUrn, const QString &pkgName)
Definition eagleprojectimport.cpp:321
QHash< QStringList, Uuid > mLibComponentMap
Key={libName, libUrn, deviceSetName}, Value=libCmpUuid.
Definition eagleprojectimport.h:162
const Device & importLibraryDevice(EagleLibraryConverter &converter, ProjectLibrary &library, const QString &devLibName, const QString &devLibUrn, const QString &devSetName, const QString &devName, const QString &pkgLibName, const QString &pkgLibUrn)
Definition eagleprojectimport.cpp:339
QScopedPointer< parseagle::Board > mBoard
Definition eagleprojectimport.h:147
std::shared_ptr< MessageLogger > getLogger() const noexcept
Definition eagleprojectimport.h:86
QHash< QStringList, Uuid > mLibComponentGateMap
Key={libCmpUuid, gateName}, Value=libCmpGateUuid.
Definition eagleprojectimport.h:165
bool hasBoard() const noexcept
Definition eagleprojectimport.h:90
EagleProjectImport(const EagleProjectImport &other)=delete
const parseagle::Device & getDevice(const parseagle::DeviceSet &devSet, const QString &name) const
Definition eagleprojectimport.cpp:1323
void import(Project &project)
Definition eagleprojectimport.cpp:159
std::shared_ptr< const parseagle::DeviceSet > getDeviceSet(const QString &libName, const QString &libUrn, const QString &name) const
Definition eagleprojectimport.cpp:1312
const Component & importLibraryComponent(EagleLibraryConverter &converter, ProjectLibrary &library, const QString &libName, const QString &libUrn, const QString &devSetName)
Definition eagleprojectimport.cpp:287
const Symbol & importLibrarySymbol(EagleLibraryConverter &converter, ProjectLibrary &library, const QString &libName, const QString &libUrn, const QString &symName)
Definition eagleprojectimport.cpp:269
QHash< QStringList, std::shared_ptr< const parseagle::DeviceSet > > mDeviceSets
Key={libName, libUrn, devSetName}.
Definition eagleprojectimport.h:156
QHash< QStringList, Uuid > mLibPackageMap
Key={libName, libUrn, pkgName}, Value=libPkgUuid.
Definition eagleprojectimport.h:168
const QString & getProjectName() const noexcept
Definition eagleprojectimport.h:88
QHash< QStringList, Uuid > mLibDeviceMap
Key={libName, libUrn, devSetname, devName}, Value=libDevUuid.
Definition eagleprojectimport.h:171
QHash< QString, ComponentMap > mComponentMap
Definition eagleprojectimport.h:180
std::shared_ptr< const parseagle::Symbol > getSymbol(const QString &libName, const QString &libUrn, const QString &name) const
Definition eagleprojectimport.cpp:1290
QScopedPointer< parseagle::Schematic > mSchematic
Definition eagleprojectimport.h:146
NetSignal & importNet(Project &project, const parseagle::Net &net)
Definition eagleprojectimport.cpp:685
QHash< QStringList, std::shared_ptr< const parseagle::Symbol > > mSymbols
Key={libName, libUrn, symName}.
Definition eagleprojectimport.h:150
std::shared_ptr< MessageLogger > mLogger
Definition eagleprojectimport.h:144
void importLibraries(const QList< parseagle::Library > &libs, bool isBoard)
Definition eagleprojectimport.cpp:362
std::optional< BoundedUnsignedRatio > tryGetDrcRatio(const QString &nr, const QString &nmin, const QString &nmax) const
Definition eagleprojectimport.cpp:1271
void importBoard(Project &project, EagleLibraryConverter &converter)
Definition eagleprojectimport.cpp:712
QStringList open(const FilePath &sch, const FilePath &brd)
Definition eagleprojectimport.cpp:121
const parseagle::Part & getPart(const QString &name) const
Definition eagleprojectimport.cpp:1345
QSet< QString > mSchematicDirNames
All already imported schematic directory names.
Definition eagleprojectimport.h:183
bool isReady() const noexcept
Definition eagleprojectimport.h:87
std::shared_ptr< const parseagle::Package > getPackage(const QString &libName, const QString &libUrn, const QString &name) const
Definition eagleprojectimport.cpp:1301
QString mProjectName
Definition eagleprojectimport.h:145
bool hasBuses(const parseagle::Schematic &schematic) const noexcept
Definition eagleprojectimport.cpp:1262
void importSchematic(Project &project, EagleLibraryConverter &converter, const parseagle::Sheet &sheet)
Definition eagleprojectimport.cpp:387
QHash< QString, Uuid > mNetSignalMap
Key=eagleNetName, Value=netSignalUuid.
Definition eagleprojectimport.h:186
Definition occmodel.cpp:76
Definition eaglelibraryconverter.h:38
Definition uuid.h:186
QString libName
Definition eagleprojectimport.h:174
QString devName
Definition eagleprojectimport.h:177
Uuid uuid
Definition eagleprojectimport.h:178
QString libUrn
Definition eagleprojectimport.h:175
QString devSetName
Definition eagleprojectimport.h:176