LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bi_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_BI_BASE_H
21 #define LIBREPCB_PROJECT_BI_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 Board;
43 class BGI_Base;
44 
45 /*******************************************************************************
46  * Class BI_Base
47  ******************************************************************************/
48 
52 class BI_Base : public QObject {
53  Q_OBJECT
54 
55 public:
56  // Types
57  enum class Type_t {
58  NetSegment,
59  NetPoint,
60  NetLine,
61  Via,
62  Device,
63  Footprint,
64  FootprintPad,
65  Polygon,
66  StrokeText,
67  Hole,
68  Plane,
69  AirWire,
70  };
71 
72  // Constructors / Destructor
73  BI_Base() = delete;
74  BI_Base(const BI_Base& other) = delete;
75  BI_Base(Board& board) noexcept;
76  virtual ~BI_Base() noexcept;
77 
78  // Getters
79  Project& getProject() const noexcept;
80  Circuit& getCircuit() const noexcept;
81  Board& getBoard() const noexcept { return mBoard; }
82  virtual Type_t getType() const noexcept = 0;
83  virtual const Point& getPosition() const noexcept = 0;
84  virtual bool getIsMirrored() const noexcept = 0;
85  virtual QPainterPath getGrabAreaScenePx() const noexcept = 0;
86  virtual bool isAddedToBoard() const noexcept { return mIsAddedToBoard; }
87  virtual bool isSelectable() const noexcept = 0;
88  virtual bool isSelected() const noexcept { return mIsSelected; }
89 
90  // Setters
91  virtual void setSelected(bool selected) noexcept;
92 
93  // General Methods
94  virtual void addToBoard() = 0;
95  virtual void removeFromBoard() = 0;
96 
97  // Operator Overloadings
98  BI_Base& operator=(const BI_Base& rhs) = delete;
99 
100 protected:
101  // General Methods
102  void addToBoard(QGraphicsItem* item) noexcept;
103  void removeFromBoard(QGraphicsItem* item) noexcept;
104 
105 protected:
107 
108 private:
109  // General Attributes
112 };
113 
114 /*******************************************************************************
115  * End of File
116  ******************************************************************************/
117 
118 } // namespace project
119 } // namespace librepcb
120 
121 #endif // LIBREPCB_PROJECT_BI_BASE_H
The Circuit class represents all electrical connections in a project (drawed in the schematics) ...
Definition: circuit.h:75
librepcb::project::BI_Device
virtual Type_t getType() const noexcept=0
virtual bool getIsMirrored() const noexcept=0
librepcb::project::BI_AirWire
librepcb::project::BI_Polygon
librepcb::project::BI_Footprint
virtual bool isAddedToBoard() const noexcept
Definition: bi_base.h:86
bool mIsSelected
Definition: bi_base.h:111
Type_t
Definition: bi_base.h:57
virtual const Point & getPosition() const noexcept=0
librepcb::project::BI_NetLine
librepcb::project::BI_Via
The Project class represents a whole (opened) project with all its content.
Definition: project.h:82
virtual void setSelected(bool selected) noexcept
Definition: bi_base.cpp:67
librepcb::project::BI_StrokeText
virtual bool isSelectable() const noexcept=0
virtual QPainterPath getGrabAreaScenePx() const noexcept=0
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
virtual void removeFromBoard()=0
librepcb::project::BI_NetSegment
BI_Base & operator=(const BI_Base &rhs)=delete
The Board Item Base (BI_Base) class.
Definition: bi_base.h:52
librepcb::project::BI_NetPoint
Project & getProject() const noexcept
Definition: bi_base.cpp:55
virtual void addToBoard()=0
librepcb::project::BI_FootprintPad
virtual bool isSelected() const noexcept
Definition: bi_base.h:88
virtual ~BI_Base() noexcept
Definition: bi_base.cpp:47
bool mIsAddedToBoard
Definition: bi_base.h:110
Board & mBoard
Definition: bi_base.h:106
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:82
Circuit & getCircuit() const noexcept
Definition: bi_base.cpp:59
Board & getBoard() const noexcept
Definition: bi_base.h:81
librepcb::project::BI_Plane
librepcb::project::BI_Hole