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 
60 class BI_Footprint final : public BI_Base,
61  public SerializableObject,
62  public AttributeProvider {
63  Q_OBJECT
64 
65 public:
66  // Constructors / Destructor
67  BI_Footprint() = delete;
68  BI_Footprint(const BI_Footprint& other) = delete;
69  BI_Footprint(BI_Device& device, const BI_Footprint& other);
70  BI_Footprint(BI_Device& device, const SExpression& node);
71  explicit BI_Footprint(BI_Device& device);
72  ~BI_Footprint() noexcept;
73 
74  // Getters
75  const Uuid& getComponentInstanceUuid() const noexcept;
76  BI_Device& getDeviceInstance() const noexcept { return mDevice; }
77  BI_FootprintPad* getPad(const Uuid& padUuid) const noexcept {
78  return mPads.value(padUuid);
79  }
80  const QMap<Uuid, BI_FootprintPad*>& getPads() const noexcept { return mPads; }
81  const library::Footprint& getLibFootprint() const noexcept;
82  const Angle& getRotation() const noexcept;
83  bool isSelectable() const noexcept override;
84  bool isUsed() const noexcept;
85  BGI_Footprint& getGraphicsItem() noexcept { return *mGraphicsItem; }
86 
87  // StrokeText Methods
88  const QList<BI_StrokeText*>& getStrokeTexts() const noexcept {
89  return mStrokeTexts;
90  }
91  void addStrokeText(BI_StrokeText& text);
92  void removeStrokeText(BI_StrokeText& text);
93 
94  // General Methods
96  void addToBoard() override;
97  void removeFromBoard() override;
98 
100  void serialize(SExpression& root) const override;
101 
102  // Helper Methods
103  Point mapToScene(const Point& relativePos) const noexcept;
104 
105  // Inherited from AttributeProvider
107  QVector<const AttributeProvider*> getAttributeProviderParents() const
108  noexcept override;
109 
110  // Inherited from BI_Base
111  Type_t getType() const noexcept override {
113  }
114  const Point& getPosition() const noexcept override;
115  bool getIsMirrored() const noexcept override;
116  QPainterPath getGrabAreaScenePx() const noexcept override;
117  void setSelected(bool selected) noexcept override;
118 
119  // Operator Overloadings
120  BI_Footprint& operator=(const BI_Footprint& rhs) = delete;
121 
122 private slots:
124  void deviceInstanceMoved(const Point& pos);
125  void deviceInstanceRotated(const Angle& rot);
126  void deviceInstanceMirrored(bool mirrored);
127 
128 signals:
130  void attributesChanged() override;
131 
132 private:
133  void init();
134  void updateGraphicsItemTransform() noexcept;
135 
136  // General
138  QScopedPointer<BGI_Footprint> mGraphicsItem;
141 };
142 
143 /*******************************************************************************
144  * End of File
145  ******************************************************************************/
146 
147 } // namespace project
148 } // namespace librepcb
149 
150 #endif // LIBREPCB_PROJECT_BI_FOOTPRINT_H
void deviceInstanceRotated(const Angle &rot)
Definition: bi_footprint.cpp:295
QScopedPointer< BGI_Footprint > mGraphicsItem
Definition: bi_footprint.h:138
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:137
void deviceInstanceMirrored(bool mirrored)
Definition: bi_footprint.cpp:305
QMap< Uuid, BI_FootprintPad * > mPads
key: footprint pad UUID
Definition: bi_footprint.h:139
bool isUsed() const noexcept
Definition: bi_footprint.cpp:137
BI_FootprintPad * getPad(const Uuid &padUuid) const noexcept
Definition: bi_footprint.h:77
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:80
The BGI_Footprint class.
Definition: bgi_footprint.h:57
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:81
Type_t getType() const noexceptoverride
Definition: bi_footprint.h:111
const QList< BI_StrokeText * > & getStrokeTexts() const noexcept
Definition: bi_footprint.h:88
The SerializableObject class is the base class for all classes which need to be serializable/deserial...
Definition: serializableobject.h:46
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:81
The BI_Footprint class.
Definition: bi_footprint.h:60
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:85
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:76
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:140
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:60
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:62
void setSelected(bool selected) noexceptoverride
Definition: bi_footprint.cpp:267