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 mGridInterval = interval;
104 }
105 void setGridUnit(const LengthUnit& unit) noexcept { mGridUnit = unit; }
106
107 // Symbol Methods
108 const QMap<Uuid, SI_Symbol*>& getSymbols() const noexcept { return mSymbols; }
109 void addSymbol(SI_Symbol& symbol);
110 void removeSymbol(SI_Symbol& symbol);
111
112 // NetSegment Methods
113 const QMap<Uuid, SI_NetSegment*>& getNetSegments() const noexcept {
114 return mNetSegments;
115 }
116 void addNetSegment(SI_NetSegment& netsegment);
117 void removeNetSegment(SI_NetSegment& netsegment);
118
119 // Polygon Methods
120 const QMap<Uuid, SI_Polygon*>& getPolygons() const noexcept {
121 return mPolygons;
122 }
123 void addPolygon(SI_Polygon& polygon);
124 void removePolygon(SI_Polygon& polygon);
125
126 // Text Methods
127 const QMap<Uuid, SI_Text*>& getTexts() const noexcept { return mTexts; }
128 void addText(SI_Text& text);
129 void removeText(SI_Text& text);
130
131 // General Methods
132 void addToProject();
133 void removeFromProject();
134 void save();
135 void updateAllNetLabelAnchors() noexcept;
136
137 // Operator Overloadings
138 Schematic& operator=(const Schematic& rhs) = delete;
139 bool operator==(const Schematic& rhs) const noexcept {
140 return (this == &rhs);
141 }
142 bool operator!=(const Schematic& rhs) const noexcept {
143 return (this != &rhs);
144 }
145
146signals:
147 void symbolAdded(SI_Symbol& symbol);
151 void polygonAdded(SI_Polygon& polygon);
153 void textAdded(SI_Text& text);
154 void textRemoved(SI_Text& text);
155
157
158private:
159 // General
161 const QString mDirectoryName;
162 std::unique_ptr<TransactionalDirectory> mDirectory;
164
165 // Attributes
170
171 QMap<Uuid, SI_Symbol*> mSymbols;
172 QMap<Uuid, SI_NetSegment*> mNetSegments;
173 QMap<Uuid, SI_Polygon*> mPolygons;
174 QMap<Uuid, SI_Text*> mTexts;
175};
176
177/*******************************************************************************
178 * End of File
179 ******************************************************************************/
180
181} // namespace librepcb
182
183#endif
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition lengthunit.h:60
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:168
const QMap< Uuid, SI_Symbol * > & getSymbols() const noexcept
Definition schematic.h:108
const PositiveLength & getGridInterval() const noexcept
Definition schematic.h:95
const QString mDirectoryName
Definition schematic.h:161
LengthUnit mGridUnit
Definition schematic.h:169
void addNetSegment(SI_NetSegment &netsegment)
Definition schematic.cpp:139
void textAdded(SI_Text &text)
const QMap< Uuid, SI_Text * > & getTexts() const noexcept
Definition schematic.h:127
void removePolygon(SI_Polygon &polygon)
Definition schematic.cpp:185
void polygonAdded(SI_Polygon &polygon)
const ElementName & getName() const noexcept
Definition schematic.h:94
Uuid mUuid
Definition schematic.h:166
Schematic(const Schematic &other)=delete
const QMap< Uuid, SI_Polygon * > & getPolygons() const noexcept
Definition schematic.h:120
ElementName mName
Definition schematic.h:167
bool mIsAddedToProject
Definition schematic.h:163
void removeText(SI_Text &text)
Definition schematic.cpp:214
void textRemoved(SI_Text &text)
void addText(SI_Text &text)
Definition schematic.cpp:199
void setGridUnit(const LengthUnit &unit) noexcept
Definition schematic.h:105
void symbolAdded(SI_Symbol &symbol)
Project & getProject() const noexcept
Definition schematic.h:87
QMap< Uuid, SI_Symbol * > mSymbols
Definition schematic.h:171
void polygonRemoved(SI_Polygon &polygon)
void addToProject()
Definition schematic.cpp:227
void addPolygon(SI_Polygon &polygon)
Definition schematic.cpp:169
Project & mProject
A reference to the Project object (from the ctor)
Definition schematic.h:160
~Schematic() noexcept
Definition schematic.cpp:74
void removeNetSegment(SI_NetSegment &netsegment)
Definition schematic.cpp:155
void save()
Definition schematic.cpp:294
void netSegmentAdded(SI_NetSegment &netSegment)
const Uuid & getUuid() const noexcept
Definition schematic.h:93
bool operator!=(const Schematic &rhs) const noexcept
Definition schematic.h:142
void symbolRemoved(SI_Symbol &symbol)
QMap< Uuid, SI_Polygon * > mPolygons
Definition schematic.h:173
std::unique_ptr< TransactionalDirectory > mDirectory
Definition schematic.h:162
bool isEmpty() const noexcept
Definition schematic.cpp:92
QMap< Uuid, SI_Text * > mTexts
Definition schematic.h:174
QMap< Uuid, SI_NetSegment * > mNetSegments
Definition schematic.h:172
void removeFromProject()
Definition schematic.cpp:262
void addSymbol(SI_Symbol &symbol)
Definition schematic.cpp:110
void setGridInterval(const PositiveLength &interval) noexcept
Definition schematic.h:102
void updateAllNetLabelAnchors() noexcept
Definition schematic.cpp:328
void removeSymbol(SI_Symbol &symbol)
Definition schematic.cpp:126
const QString & getDirectoryName() const noexcept
Definition schematic.h:88
const QMap< Uuid, SI_NetSegment * > & getNetSegments() const noexcept
Definition schematic.h:113
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:76
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition elementname.h:84