LibrePCB Developers Documentation
Loading...
Searching...
No Matches
schematic.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_CORE_SCHEMATIC_H
21#define LIBREPCB_CORE_SCHEMATIC_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../fileio/filepath.h"
27#include "../../fileio/transactionaldirectory.h"
28#include "../../types/elementname.h"
29#include "../../types/lengthunit.h"
30#include "../../types/uuid.h"
31
32#include <QtCore>
33
34#include <memory>
35
36/*******************************************************************************
37 * Namespace / Forward Declarations
38 ******************************************************************************/
39namespace librepcb {
40
41class ComponentInstance;
42class NetSignal;
43class Point;
44class Project;
45class SI_Base;
46class SI_BusSegment;
47class SI_Image;
48class SI_NetLabel;
49class SI_NetLine;
50class SI_NetPoint;
51class SI_NetSegment;
52class SI_Polygon;
53class SI_Symbol;
54class SI_SymbolPin;
55class SI_Text;
56
57/*******************************************************************************
58 * Class Schematic
59 ******************************************************************************/
60
81class Schematic final : public QObject {
82 Q_OBJECT
83
84public:
85 // Constructors / Destructor
86 Schematic() = delete;
87 Schematic(const Schematic& other) = delete;
88 Schematic(Project& project, std::unique_ptr<TransactionalDirectory> directory,
89 const QString& directoryName, const Uuid& uuid,
90 const ElementName& name);
91 ~Schematic() noexcept;
92
93 // Getters: General
94 Project& getProject() const noexcept { return mProject; }
95 const QString& getDirectoryName() const noexcept { return mDirectoryName; }
97 const TransactionalDirectory& getDirectory() const noexcept {
98 return *mDirectory;
99 }
100 bool isEmpty() const noexcept;
101
102 // Getters: Attributes
103 const Uuid& getUuid() const noexcept { return mUuid; }
104 const ElementName& getName() const noexcept { return mName; }
105 const PositiveLength& getGridInterval() const noexcept {
106 return mGridInterval;
107 }
108 const LengthUnit& getGridUnit() const noexcept { return mGridUnit; }
109
110 // Setters: Attributes
111 void setName(const ElementName& name) noexcept;
112 void setGridInterval(const PositiveLength& interval) noexcept {
113 mGridInterval = interval;
114 }
115 void setGridUnit(const LengthUnit& unit) noexcept { mGridUnit = unit; }
116
117 // Symbol Methods
118 const QMap<Uuid, SI_Symbol*>& getSymbols() const noexcept { return mSymbols; }
119 void addSymbol(SI_Symbol& symbol);
120 void removeSymbol(SI_Symbol& symbol);
121
122 // BusSegment Methods
123 const QMap<Uuid, SI_BusSegment*>& getBusSegments() const noexcept {
124 return mBusSegments;
125 }
128
129 // NetSegment Methods
130 const QMap<Uuid, SI_NetSegment*>& getNetSegments() const noexcept {
131 return mNetSegments;
132 }
133 void addNetSegment(SI_NetSegment& netsegment);
134 void removeNetSegment(SI_NetSegment& netsegment);
135
136 // Polygon Methods
137 const QMap<Uuid, SI_Polygon*>& getPolygons() const noexcept {
138 return mPolygons;
139 }
140 void addPolygon(SI_Polygon& polygon);
141 void removePolygon(SI_Polygon& polygon);
142
143 // Text Methods
144 const QMap<Uuid, SI_Text*>& getTexts() const noexcept { return mTexts; }
145 void addText(SI_Text& text);
146 void removeText(SI_Text& text);
147
148 // Image Methods
149 const QMap<Uuid, SI_Image*>& getImages() const noexcept { return mImages; }
150 void addImage(SI_Image& image);
151 void removeImage(SI_Image& image);
152
153 // General Methods
154 void addToProject();
155 void removeFromProject();
156 void save();
157 void updateAllLabelAnchors() noexcept;
158
159 // Operator Overloadings
160 Schematic& operator=(const Schematic& rhs) = delete;
161 bool operator==(const Schematic& rhs) const noexcept {
162 return (this == &rhs);
163 }
164 bool operator!=(const Schematic& rhs) const noexcept {
165 return (this != &rhs);
166 }
167
168signals:
169 void nameChanged(const ElementName& name);
170 void symbolAdded(SI_Symbol& symbol);
176 void polygonAdded(SI_Polygon& polygon);
178 void textAdded(SI_Text& text);
179 void textRemoved(SI_Text& text);
180 void imageAdded(SI_Image& image);
181 void imageRemoved(SI_Image& image);
182
184
185private:
186 // General
188 const QString mDirectoryName;
189 std::unique_ptr<TransactionalDirectory> mDirectory;
191
192 // Attributes
197
198 // User settings
199 // Those are stored in settings.user.lp and usually not under version control.
200 // Therefore it is allowed to add/remove settings without introducing a new
201 // file format version.
202 // (no such settings yet)
203
204 // Items
205 QMap<Uuid, SI_Symbol*> mSymbols;
206 QMap<Uuid, SI_BusSegment*> mBusSegments;
207 QMap<Uuid, SI_NetSegment*> mNetSegments;
208 QMap<Uuid, SI_Polygon*> mPolygons;
209 QMap<Uuid, SI_Text*> mTexts;
210 QMap<Uuid, SI_Image*> mImages;
211};
212
213/*******************************************************************************
214 * End of File
215 ******************************************************************************/
216
217} // namespace librepcb
218
219#endif
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition lengthunit.h:62
The Project class represents a whole (opened) project with all its content.
Definition project.h:71
The SI_BusSegment class.
Definition si_bussegment.h:52
The SI_Image class represents an image in a schematic.
Definition si_image.h:45
The SI_NetSegment class.
Definition si_netsegment.h:55
The SI_Polygon class represents a polygon in a schematic.
Definition si_polygon.h:47
The SI_Symbol class.
Definition si_symbol.h:54
The SI_Text class represents a text label in a schematic.
Definition si_text.h:48
The Schematic class represents one schematic page of a project and is always part of a circuit.
Definition schematic.h:81
QMap< Uuid, SI_Image * > mImages
Definition schematic.h:210
TransactionalDirectory & getDirectory() noexcept
Definition schematic.h:96
const TransactionalDirectory & getDirectory() const noexcept
Definition schematic.h:97
void updateAllLabelAnchors() noexcept
Definition schematic.cpp:441
void setName(const ElementName &name) noexcept
Definition schematic.cpp:108
void netSegmentRemoved(SI_NetSegment &netSegment)
const LengthUnit & getGridUnit() const noexcept
Definition schematic.h:108
PositiveLength mGridInterval
Definition schematic.h:195
const QMap< Uuid, SI_Symbol * > & getSymbols() const noexcept
Definition schematic.h:118
const PositiveLength & getGridInterval() const noexcept
Definition schematic.h:105
void busSegmentRemoved(SI_BusSegment &s)
const QString mDirectoryName
Definition schematic.h:188
LengthUnit mGridUnit
Definition schematic.h:196
void addNetSegment(SI_NetSegment &netsegment)
Definition schematic.cpp:178
void nameChanged(const ElementName &name)
void textAdded(SI_Text &text)
const QMap< Uuid, SI_Text * > & getTexts() const noexcept
Definition schematic.h:144
void removePolygon(SI_Polygon &polygon)
Definition schematic.cpp:224
void polygonAdded(SI_Polygon &polygon)
void removeBusSegment(SI_BusSegment &s)
Definition schematic.cpp:165
const ElementName & getName() const noexcept
Definition schematic.h:104
Uuid mUuid
Definition schematic.h:193
void imageAdded(SI_Image &image)
Schematic(const Schematic &other)=delete
const QMap< Uuid, SI_Polygon * > & getPolygons() const noexcept
Definition schematic.h:137
ElementName mName
Definition schematic.h:194
void removeImage(SI_Image &image)
Definition schematic.cpp:288
bool mIsAddedToProject
Definition schematic.h:190
void addImage(SI_Image &image)
Definition schematic.cpp:266
void busSegmentAdded(SI_BusSegment &s)
void removeText(SI_Text &text)
Definition schematic.cpp:253
void addBusSegment(SI_BusSegment &s)
Definition schematic.cpp:149
void textRemoved(SI_Text &text)
void addText(SI_Text &text)
Definition schematic.cpp:238
void setGridUnit(const LengthUnit &unit) noexcept
Definition schematic.h:115
void symbolAdded(SI_Symbol &symbol)
Project & getProject() const noexcept
Definition schematic.h:94
QMap< Uuid, SI_Symbol * > mSymbols
Definition schematic.h:205
void polygonRemoved(SI_Polygon &polygon)
void imageRemoved(SI_Image &image)
void addToProject()
Definition schematic.cpp:301
void addPolygon(SI_Polygon &polygon)
Definition schematic.cpp:208
QMap< Uuid, SI_BusSegment * > mBusSegments
Definition schematic.h:206
Project & mProject
A reference to the Project object (from the ctor)
Definition schematic.h:187
~Schematic() noexcept
Definition schematic.cpp:76
const QMap< Uuid, SI_BusSegment * > & getBusSegments() const noexcept
Definition schematic.h:123
void removeNetSegment(SI_NetSegment &netsegment)
Definition schematic.cpp:194
void save()
Definition schematic.cpp:386
void netSegmentAdded(SI_NetSegment &netSegment)
const Uuid & getUuid() const noexcept
Definition schematic.h:103
bool operator!=(const Schematic &rhs) const noexcept
Definition schematic.h:164
void symbolRemoved(SI_Symbol &symbol)
QMap< Uuid, SI_Polygon * > mPolygons
Definition schematic.h:208
std::unique_ptr< TransactionalDirectory > mDirectory
Definition schematic.h:189
const QMap< Uuid, SI_Image * > & getImages() const noexcept
Definition schematic.h:149
bool isEmpty() const noexcept
Definition schematic.cpp:98
QMap< Uuid, SI_Text * > mTexts
Definition schematic.h:209
QMap< Uuid, SI_NetSegment * > mNetSegments
Definition schematic.h:207
void removeFromProject()
Definition schematic.cpp:345
void addSymbol(SI_Symbol &symbol)
Definition schematic.cpp:120
void setGridInterval(const PositiveLength &interval) noexcept
Definition schematic.h:112
void removeSymbol(SI_Symbol &symbol)
Definition schematic.cpp:136
const QString & getDirectoryName() const noexcept
Definition schematic.h:95
const QMap< Uuid, SI_NetSegment * > & getNetSegments() const noexcept
Definition schematic.h:130
Helper class to access a subdirectory of TransactionalFileSystem.
Definition transactionaldirectory.h:51
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
Definition occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition elementname.h:84