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_NetLabel;
47class SI_NetLine;
48class SI_NetPoint;
49class SI_NetSegment;
50class SI_Polygon;
51class SI_Symbol;
52class SI_SymbolPin;
53class SI_Text;
54
55/*******************************************************************************
56 * Class Schematic
57 ******************************************************************************/
58
74class Schematic final : public QObject {
75 Q_OBJECT
76
77public:
78 // Constructors / Destructor
79 Schematic() = delete;
80 Schematic(const Schematic& other) = delete;
81 Schematic(Project& project, std::unique_ptr<TransactionalDirectory> directory,
82 const QString& directoryName, const Uuid& uuid,
83 const ElementName& name);
84 ~Schematic() noexcept;
85
86 // Getters: General
87 Project& getProject() const noexcept { return mProject; }
88 const QString& getDirectoryName() const noexcept { return mDirectoryName; }
90 bool isEmpty() const noexcept;
91
92 // Getters: Attributes
93 const Uuid& getUuid() const noexcept { return mUuid; }
94 const ElementName& getName() const noexcept { return mName; }
95 const PositiveLength& getGridInterval() const noexcept {
96 return mGridInterval;
97 }
98 const LengthUnit& getGridUnit() const noexcept { return mGridUnit; }
99
100 // Setters: Attributes
101 void setName(const ElementName& name) noexcept;
102 void setGridInterval(const PositiveLength& interval) noexcept {
103 if (interval != mGridInterval) {
104 mGridInterval = interval;
106 }
107 }
108 void setGridUnit(const LengthUnit& unit) noexcept { mGridUnit = unit; }
109
110 // Symbol Methods
111 const QMap<Uuid, SI_Symbol*>& getSymbols() const noexcept { return mSymbols; }
112 void addSymbol(SI_Symbol& symbol);
113 void removeSymbol(SI_Symbol& symbol);
114
115 // NetSegment Methods
116 const QMap<Uuid, SI_NetSegment*>& getNetSegments() const noexcept {
117 return mNetSegments;
118 }
119 void addNetSegment(SI_NetSegment& netsegment);
120 void removeNetSegment(SI_NetSegment& netsegment);
121
122 // Polygon Methods
123 const QMap<Uuid, SI_Polygon*>& getPolygons() const noexcept {
124 return mPolygons;
125 }
126 void addPolygon(SI_Polygon& polygon);
127 void removePolygon(SI_Polygon& polygon);
128
129 // Text Methods
130 const QMap<Uuid, SI_Text*>& getTexts() const noexcept { return mTexts; }
131 void addText(SI_Text& text);
132 void removeText(SI_Text& text);
133
134 // General Methods
135 void addToProject();
136 void removeFromProject();
137 void save();
138 void updateAllNetLabelAnchors() noexcept;
139
140 // Operator Overloadings
141 Schematic& operator=(const Schematic& rhs) = delete;
142 bool operator==(const Schematic& rhs) const noexcept {
143 return (this == &rhs);
144 }
145 bool operator!=(const Schematic& rhs) const noexcept {
146 return (this != &rhs);
147 }
148
149signals:
150 void nameChanged(const ElementName& name);
151 void gridIntervalChanged(const PositiveLength& interval);
152 void symbolAdded(SI_Symbol& symbol);
156 void polygonAdded(SI_Polygon& polygon);
158 void textAdded(SI_Text& text);
159 void textRemoved(SI_Text& text);
160
162
163private:
164 // General
166 const QString mDirectoryName;
167 std::unique_ptr<TransactionalDirectory> mDirectory;
169
170 // Attributes
175
176 QMap<Uuid, SI_Symbol*> mSymbols;
177 QMap<Uuid, SI_NetSegment*> mNetSegments;
178 QMap<Uuid, SI_Polygon*> mPolygons;
179 QMap<Uuid, SI_Text*> mTexts;
180};
181
182/*******************************************************************************
183 * End of File
184 ******************************************************************************/
185
186} // namespace librepcb
187
188#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_NetSegment class.
Definition si_netsegment.h:53
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:74
TransactionalDirectory & getDirectory() noexcept
Definition schematic.h:89
void setName(const ElementName &name) noexcept
Definition schematic.cpp:101
void netSegmentRemoved(SI_NetSegment &netSegment)
const LengthUnit & getGridUnit() const noexcept
Definition schematic.h:98
PositiveLength mGridInterval
Definition schematic.h:173
const QMap< Uuid, SI_Symbol * > & getSymbols() const noexcept
Definition schematic.h:111
const PositiveLength & getGridInterval() const noexcept
Definition schematic.h:95
const QString mDirectoryName
Definition schematic.h:166
LengthUnit mGridUnit
Definition schematic.h:174
void addNetSegment(SI_NetSegment &netsegment)
Definition schematic.cpp:142
void nameChanged(const ElementName &name)
void textAdded(SI_Text &text)
const QMap< Uuid, SI_Text * > & getTexts() const noexcept
Definition schematic.h:130
void removePolygon(SI_Polygon &polygon)
Definition schematic.cpp:188
void polygonAdded(SI_Polygon &polygon)
const ElementName & getName() const noexcept
Definition schematic.h:94
Uuid mUuid
Definition schematic.h:171
Schematic(const Schematic &other)=delete
const QMap< Uuid, SI_Polygon * > & getPolygons() const noexcept
Definition schematic.h:123
ElementName mName
Definition schematic.h:172
void gridIntervalChanged(const PositiveLength &interval)
bool mIsAddedToProject
Definition schematic.h:168
void removeText(SI_Text &text)
Definition schematic.cpp:217
void textRemoved(SI_Text &text)
void addText(SI_Text &text)
Definition schematic.cpp:202
void setGridUnit(const LengthUnit &unit) noexcept
Definition schematic.h:108
void symbolAdded(SI_Symbol &symbol)
Project & getProject() const noexcept
Definition schematic.h:87
QMap< Uuid, SI_Symbol * > mSymbols
Definition schematic.h:176
void polygonRemoved(SI_Polygon &polygon)
void addToProject()
Definition schematic.cpp:230
void addPolygon(SI_Polygon &polygon)
Definition schematic.cpp:172
Project & mProject
A reference to the Project object (from the ctor)
Definition schematic.h:165
~Schematic() noexcept
Definition schematic.cpp:74
void removeNetSegment(SI_NetSegment &netsegment)
Definition schematic.cpp:158
void save()
Definition schematic.cpp:297
void netSegmentAdded(SI_NetSegment &netSegment)
const Uuid & getUuid() const noexcept
Definition schematic.h:93
bool operator!=(const Schematic &rhs) const noexcept
Definition schematic.h:145
void symbolRemoved(SI_Symbol &symbol)
QMap< Uuid, SI_Polygon * > mPolygons
Definition schematic.h:178
std::unique_ptr< TransactionalDirectory > mDirectory
Definition schematic.h:167
bool isEmpty() const noexcept
Definition schematic.cpp:92
QMap< Uuid, SI_Text * > mTexts
Definition schematic.h:179
QMap< Uuid, SI_NetSegment * > mNetSegments
Definition schematic.h:177
void removeFromProject()
Definition schematic.cpp:265
void addSymbol(SI_Symbol &symbol)
Definition schematic.cpp:113
void setGridInterval(const PositiveLength &interval) noexcept
Definition schematic.h:102
void updateAllNetLabelAnchors() noexcept
Definition schematic.cpp:331
void removeSymbol(SI_Symbol &symbol)
Definition schematic.cpp:129
const QString & getDirectoryName() const noexcept
Definition schematic.h:88
const QMap< Uuid, SI_NetSegment * > & getNetSegments() const noexcept
Definition schematic.h:116
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