LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
si_base.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_PROJECT_SI_BASE_H
21 #define LIBREPCB_PROJECT_SI_BASE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
27 
28 #include <QtCore>
29 #include <QtWidgets>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 class GraphicsScene;
37 
38 namespace project {
39 
40 class Project;
41 class Circuit;
42 class Schematic;
43 class SGI_Base;
44 
45 /*******************************************************************************
46  * Class SI_Base
47  ******************************************************************************/
48 
52 class SI_Base : public QObject {
53  Q_OBJECT
54 
55 public:
56  // Types
57  enum class Type_t {
58  NetSegment,
59  NetPoint,
60  NetLine,
61  NetLabel,
62  Symbol,
63  SymbolPin,
64  };
65 
66  // Constructors / Destructor
67  SI_Base() = delete;
68  SI_Base(const SI_Base& other) = delete;
69  SI_Base(Schematic& schematic) noexcept;
70  virtual ~SI_Base() noexcept;
71 
72  // Getters
73  Project& getProject() const noexcept;
74  Circuit& getCircuit() const noexcept;
75  Schematic& getSchematic() const noexcept { return mSchematic; }
76  virtual Type_t getType() const noexcept = 0;
77  virtual const Point& getPosition() const noexcept = 0;
78  virtual QPainterPath getGrabAreaScenePx() const noexcept = 0;
79  virtual bool isAddedToSchematic() const noexcept {
80  return mIsAddedToSchematic;
81  }
82  virtual bool isSelected() const noexcept { return mIsSelected; }
83 
84  // Setters
85  virtual void setSelected(bool selected) noexcept;
86 
87  // General Methods
88  virtual void addToSchematic() = 0;
89  virtual void removeFromSchematic() = 0;
90 
91  // Operator Overloadings
92  SI_Base& operator=(const SI_Base& rhs) = delete;
93 
94 protected:
95  // General Methods
96  void addToSchematic(SGI_Base* item) noexcept;
97  void removeFromSchematic(SGI_Base* item) noexcept;
98 
99 protected:
101 
102 private:
103  // General Attributes
106 };
107 
108 /*******************************************************************************
109  * End of File
110  ******************************************************************************/
111 
112 } // namespace project
113 } // namespace librepcb
114 
115 #endif // LIBREPCB_PROJECT_SI_BASE_H
The Circuit class represents all electrical connections in a project (drawed in the schematics) ...
Definition: circuit.h:75
virtual QPainterPath getGrabAreaScenePx() const noexcept=0
librepcb::project::SI_SymbolPin
librepcb::project::SI_NetLine
virtual void setSelected(bool selected) noexcept
Definition: si_base.cpp:70
SI_Base & operator=(const SI_Base &rhs)=delete
The Schematic class represents one schematic page of a project and is always part of a circuit...
Definition: schematic.h:83
The Schematic Item Base (SI_Base) class.
Definition: si_base.h:52
The Project class represents a whole (opened) project with all its content.
Definition: project.h:84
virtual ~SI_Base() noexcept
Definition: si_base.cpp:50
Circuit & getCircuit() const noexcept
Definition: si_base.cpp:62
librepcb::project::SI_NetLabel
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
bool mIsSelected
Definition: si_base.h:105
librepcb::project::SI_NetPoint
librepcb::project::SI_NetSegment
The Schematic Graphics Item Base (SGI_Base) class.
Definition: sgi_base.h:44
virtual void addToSchematic()=0
Type_t
Definition: si_base.h:57
librepcb::project::SI_Symbol
Schematic & getSchematic() const noexcept
Definition: si_base.h:75
virtual void removeFromSchematic()=0
virtual Type_t getType() const noexcept=0
virtual bool isAddedToSchematic() const noexcept
Definition: si_base.h:79
bool mIsAddedToSchematic
Definition: si_base.h:104
Project & getProject() const noexcept
Definition: si_base.cpp:58
virtual bool isSelected() const noexcept
Definition: si_base.h:82
virtual const Point & getPosition() const noexcept=0
Schematic & mSchematic
Definition: si_base.h:100