LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bi_footprint.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_FOOTPRINT_H
21 #define LIBREPCB_PROJECT_BI_FOOTPRINT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../graphicsitems/bgi_footprint.h"
27 #include "bi_base.h"
28 #include "bi_stroketext.h"
29 
32 
33 #include <QtCore>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 
40 namespace library {
41 class Footprint;
42 }
43 
44 namespace project {
45 
46 class Board;
47 class BI_Device;
48 class BI_FootprintPad;
49 
50 /*******************************************************************************
51  * Class BI_Footprint
52  ******************************************************************************/
53 
57 class BI_Footprint final : public BI_Base,
58  public SerializableObject,
59  public AttributeProvider {
60  Q_OBJECT
61 
62 public:
63  // Constructors / Destructor
64  BI_Footprint() = delete;
65  BI_Footprint(const BI_Footprint& other) = delete;
66  BI_Footprint(BI_Device& device, const BI_Footprint& other);
67  BI_Footprint(BI_Device& device, const SExpression& node);
68  explicit BI_Footprint(BI_Device& device);
69  ~BI_Footprint() noexcept;
70 
71  // Getters
72  const Uuid& getComponentInstanceUuid() const noexcept;
73  BI_Device& getDeviceInstance() const noexcept { return mDevice; }
74  BI_FootprintPad* getPad(const Uuid& padUuid) const noexcept {
75  return mPads.value(padUuid);
76  }
77  const QMap<Uuid, BI_FootprintPad*>& getPads() const noexcept { return mPads; }
78  const library::Footprint& getLibFootprint() const noexcept;
79  const Angle& getRotation() const noexcept;
80  bool isSelectable() const noexcept override;
81  bool isUsed() const noexcept;
82  BGI_Footprint& getGraphicsItem() noexcept { return *mGraphicsItem; }
83 
84  // StrokeText Methods
85  const QList<BI_StrokeText*>& getStrokeTexts() const noexcept {
86  return mStrokeTexts;
87  }
88  void addStrokeText(BI_StrokeText& text);
89  void removeStrokeText(BI_StrokeText& text);
90 
91  // General Methods
93  void addToBoard() override;
94  void removeFromBoard() override;
95 
97  void serialize(SExpression& root) const override;
98 
99  // Helper Methods
100  Point mapToScene(const Point& relativePos) const noexcept;
101 
102  // Inherited from AttributeProvider
104  QVector<const AttributeProvider*> getAttributeProviderParents() const
105  noexcept override;
106 
107  // Inherited from BI_Base
108  Type_t getType() const noexcept override {
110  }
111  const Point& getPosition() const noexcept override;
112  bool getIsMirrored() const noexcept override;
113  QPainterPath getGrabAreaScenePx() const noexcept override;
114  void setSelected(bool selected) noexcept override;
115 
116  // Operator Overloadings
117  BI_Footprint& operator=(const BI_Footprint& rhs) = delete;
118 
119 private slots:
121  void deviceInstanceMoved(const Point& pos);
122  void deviceInstanceRotated(const Angle& rot);
123  void deviceInstanceMirrored(bool mirrored);
124 
125 signals:
127  void attributesChanged() override;
128 
129 private:
130  void init();
131  void updateGraphicsItemTransform() noexcept;
132 
133  // General
135  QScopedPointer<BGI_Footprint> mGraphicsItem;
138 };
139 
140 /*******************************************************************************
141  * End of File
142  ******************************************************************************/
143 
144 } // namespace project
145 } // namespace librepcb
146 
147 #endif // LIBREPCB_PROJECT_BI_FOOTPRINT_H
void deviceInstanceRotated(const Angle &rot)
Definition: bi_footprint.cpp:295
QScopedPointer< BGI_Footprint > mGraphicsItem
Definition: bi_footprint.h:135
const Uuid & getComponentInstanceUuid() const noexcept
Definition: bi_footprint.cpp:125
void updateGraphicsItemTransform() noexcept
Definition: bi_footprint.cpp:319
BI_Device & mDevice
Definition: bi_footprint.h:134
void deviceInstanceMirrored(bool mirrored)
Definition: bi_footprint.cpp:305
QMap< Uuid, BI_FootprintPad * > mPads
key: footprint pad UUID
Definition: bi_footprint.h:136
bool isUsed() const noexcept
Definition: bi_footprint.cpp:137
BI_FootprintPad * getPad(const Uuid &padUuid) const noexcept
Definition: bi_footprint.h:74
The BI_StrokeText class.
Definition: bi_stroketext.h:56
QPainterPath getGrabAreaScenePx() const noexceptoverride
Definition: bi_footprint.cpp:259
const QMap< Uuid, BI_FootprintPad * > & getPads() const noexcept
Definition: bi_footprint.h:77
The BGI_Footprint class.
Definition: bgi_footprint.h:54
librepcb::project::BI_Footprint
void addStrokeText(BI_StrokeText &text)
Definition: bi_footprint.cpp:148
Type_t
Definition: bi_base.h:57
void addToBoard() override
Definition: bi_footprint.cpp:185
const Angle & getRotation() const noexcept
Definition: bi_footprint.cpp:133
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
Type_t getType() const noexceptoverride
Definition: bi_footprint.h:108
const QList< BI_StrokeText * > & getStrokeTexts() const noexcept
Definition: bi_footprint.h:85
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:43
void deviceInstanceAttributesChanged()
Definition: bi_footprint.cpp:280
void serialize(SExpression &root) const override
Serialize the object into an existing S-Expression node.
Definition: bi_footprint.cpp:219
void removeFromBoard() override
Definition: bi_footprint.cpp:202
void deviceInstanceMoved(const Point &pos)
Definition: bi_footprint.cpp:285
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
The BI_Footprint class.
Definition: bi_footprint.h:57
const Point & getPosition() const noexceptoverride
Definition: bi_footprint.cpp:251
QVector< const AttributeProvider * > getAttributeProviderParents() const noexceptoverride
Get all parent attribute providers (fallback if attribute not found)
Definition: bi_footprint.cpp:242
BGI_Footprint & getGraphicsItem() noexcept
Definition: bi_footprint.h:82
The BI_FootprintPad class.
Definition: bi_footprintpad.h:56
void removeStrokeText(BI_StrokeText &text)
Definition: bi_footprint.cpp:166
The Board Item Base (BI_Base) class.
Definition: bi_base.h:52
void init()
Definition: bi_footprint.cpp:74
void resetStrokeTextsToLibraryFootprint()
Definition: bi_footprint.cpp:180
BI_Device & getDeviceInstance() const noexcept
Definition: bi_footprint.h:73
const library::Footprint & getLibFootprint() const noexcept
Definition: bi_footprint.cpp:129
~BI_Footprint() noexcept
Definition: bi_footprint.cpp:113
The BI_Device class.
Definition: bi_device.h:62
QList< BI_StrokeText * > mStrokeTexts
Definition: bi_footprint.h:137
bool getIsMirrored() const noexceptoverride
Definition: bi_footprint.cpp:255
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
bool isSelectable() const noexceptoverride
Definition: bi_footprint.cpp:263
The SExpression class.
Definition: sexpression.h:57
Point mapToScene(const Point &relativePos) const noexcept
Definition: bi_footprint.cpp:227
The Footprint class represents one footprint variant of a package.
Definition: footprint.h:61
void attributesChanged() override
This signal is emited when the value of attributes has changed.
The AttributeProvider class defines an interface for classes which provides some attributes which can...
Definition: attributeprovider.h:59
void setSelected(bool selected) noexceptoverride
Definition: bi_footprint.cpp:267