LibrePCB Developers Documentation
pickplacedata.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_PICKPLACEDATA_H
21 #define LIBREPCB_CORE_PICKPLACEDATA_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../types/angle.h"
27 #include "../types/point.h"
28 
29 #include <QtCore>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 /*******************************************************************************
37  * Class PickPlaceDataItem
38  ******************************************************************************/
39 
46 class PickPlaceDataItem final {
47  Q_DECLARE_TR_FUNCTIONS(PickPlaceDataItem)
48 
49 public:
50  enum class BoardSide {
51  Top,
52  Bottom,
53  };
54 
55  // ATTENTION: When modifying items, adjust PickPlaceCsvWriter and
56  // PickPlaceOutputJob as well!
57  enum class Type : int {
58  Tht,
59  Smt,
60  Mixed,
61  Fiducial,
62  Other,
63  };
64 
65  // Constructors / Destructor
66  PickPlaceDataItem() = delete;
67  PickPlaceDataItem(const QString& designator, const QString& value,
68  const QString& deviceName, const QString& packageName,
69  const Point& position, const Angle& rotation,
70  BoardSide boardSide, Type type, bool mount) noexcept
71  : mDesignator(designator),
72  mValue(value),
73  mDeviceName(deviceName),
74  mPackageName(packageName),
75  mPosition(position),
76  mRotation(rotation),
77  mBoardSide(boardSide),
78  mType(type),
79  mMount(mount) {}
80  PickPlaceDataItem(const PickPlaceDataItem& other) noexcept
81  : mDesignator(other.mDesignator),
82  mValue(other.mValue),
83  mDeviceName(other.mDeviceName),
84  mPackageName(other.mPackageName),
85  mPosition(other.mPosition),
86  mRotation(other.mRotation),
87  mBoardSide(other.mBoardSide),
88  mType(other.mType),
89  mMount(other.mMount) {}
90  ~PickPlaceDataItem() noexcept {}
91 
92  // Getters
93  const QString& getDesignator() const noexcept { return mDesignator; }
94  const QString& getValue() const noexcept { return mValue; }
95  const QString& getDeviceName() const noexcept { return mDeviceName; }
96  const QString& getPackageName() const noexcept { return mPackageName; }
97  const Point& getPosition() const noexcept { return mPosition; }
98  const Angle& getRotation() const noexcept { return mRotation; }
99  BoardSide getBoardSide() const noexcept { return mBoardSide; }
100  Type getType() const noexcept { return mType; }
101  bool isMount() const noexcept { return mMount; }
102 
103  // Setters
104  void setDesignator(const QString& value) noexcept { mDesignator = value; }
105 
106  // Operator Overloadings
108  mDesignator = rhs.mDesignator;
109  mValue = rhs.mValue;
110  mDeviceName = rhs.mDeviceName;
111  mPackageName = rhs.mPackageName;
112  mPosition = rhs.mPosition;
113  mRotation = rhs.mRotation;
114  mBoardSide = rhs.mBoardSide;
115  mType = rhs.mType;
116  mMount = rhs.mMount;
117  return *this;
118  }
119 
120 private:
121  QString mDesignator;
122  QString mValue;
123  QString mDeviceName;
124  QString mPackageName;
129  bool mMount;
130 };
131 
132 /*******************************************************************************
133  * Class PickPlaceData
134  ******************************************************************************/
135 
140 class PickPlaceData final {
141  Q_DECLARE_TR_FUNCTIONS(PickPlaceData)
142 
143 public:
144  // Constructors / Destructor
145  PickPlaceData() = delete;
146  PickPlaceData(const PickPlaceData& other) noexcept = delete;
147  PickPlaceData(const QString& projectName, const QString& projectVersion,
148  const QString& boardName) noexcept;
149  ~PickPlaceData() noexcept;
150 
151  // Getters
152  const QString& getProjectName() const noexcept { return mProjectName; }
153  const QString& getProjectVersion() const noexcept { return mProjectVersion; }
154  const QString& getBoardName() const noexcept { return mBoardName; }
155  const QList<PickPlaceDataItem>& getItems() const noexcept { return mItems; }
156 
157  // General Methods
158  void addItem(const PickPlaceDataItem& item) noexcept;
159 
160  // Operator Overloadings
161  PickPlaceData& operator=(const PickPlaceData& rhs) noexcept = delete;
162 
163 private:
164  QString mProjectName;
166  QString mBoardName;
167  QList<PickPlaceDataItem> mItems;
168 };
169 
170 /*******************************************************************************
171  * Non-Member Functions
172  ******************************************************************************/
173 
174 inline uint qHash(PickPlaceDataItem::Type key, uint seed = 0) noexcept {
175  return ::qHash(static_cast<int>(key), seed);
176 }
177 
178 /*******************************************************************************
179  * End of File
180  ******************************************************************************/
181 
182 } // namespace librepcb
183 
184 #endif
~PickPlaceDataItem() noexcept
Definition: pickplacedata.h:90
Type
Definition: pickplacedata.h:57
const QString & getBoardName() const noexcept
Definition: pickplacedata.h:154
Type getType() const noexcept
Definition: pickplacedata.h:100
QString mDeviceName
Definition: pickplacedata.h:123
void setDesignator(const QString &value) noexcept
Definition: pickplacedata.h:104
QString mBoardName
Definition: pickplacedata.h:166
Definition: occmodel.cpp:76
BoardSide mBoardSide
Definition: pickplacedata.h:127
The librepcb::PickPlaceDataItem class represents one item of a pick&place file.
Definition: pickplacedata.h:46
QString mValue
Definition: pickplacedata.h:122
QList< PickPlaceDataItem > mItems
Definition: pickplacedata.h:167
const Point & getPosition() const noexcept
Definition: pickplacedata.h:97
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:76
Angle mRotation
Definition: pickplacedata.h:126
BoardSide getBoardSide() const noexcept
Definition: pickplacedata.h:99
QString mPackageName
Definition: pickplacedata.h:124
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
QString mProjectVersion
Definition: pickplacedata.h:165
Type mType
Definition: pickplacedata.h:128
PickPlaceDataItem(const QString &designator, const QString &value, const QString &deviceName, const QString &packageName, const Point &position, const Angle &rotation, BoardSide boardSide, Type type, bool mount) noexcept
Definition: pickplacedata.h:67
uint qHash(PickPlaceDataItem::Type key, uint seed=0) noexcept
Definition: pickplacedata.h:174
Point mPosition
Definition: pickplacedata.h:125
The librepcb::PickPlaceData class represents the content of a pick&place file.
Definition: pickplacedata.h:140
bool isMount() const noexcept
Definition: pickplacedata.h:101
QString mProjectName
Definition: pickplacedata.h:164
const QString & getPackageName() const noexcept
Definition: pickplacedata.h:96
const QString & getProjectVersion() const noexcept
Definition: pickplacedata.h:153
const QString & getValue() const noexcept
Definition: pickplacedata.h:94
const QString & getDeviceName() const noexcept
Definition: pickplacedata.h:95
BoardSide
Definition: pickplacedata.h:50
PickPlaceDataItem(const PickPlaceDataItem &other) noexcept
Definition: pickplacedata.h:80
QString mDesignator
Definition: pickplacedata.h:121
const QList< PickPlaceDataItem > & getItems() const noexcept
Definition: pickplacedata.h:155
const QString & getDesignator() const noexcept
Definition: pickplacedata.h:93
bool mMount
False means "do not mount".
Definition: pickplacedata.h:129
uint qHash(const AttributeKey &key, uint seed=0) noexcept
Definition: attributekey.h:118
const Angle & getRotation() const noexcept
Definition: pickplacedata.h:98
const QString & getProjectName() const noexcept
Definition: pickplacedata.h:152
PickPlaceDataItem & operator=(const PickPlaceDataItem &rhs) noexcept
Definition: pickplacedata.h:107