KiCad PCB EDA Suite
Loading...
Searching...
No Matches
odb_entity.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
5 * Author: SYSUEric <[email protected]>.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef _ODB_ENTITY_H_
22#define _ODB_ENTITY_H_
23
24
25#include <optional>
26#include <vector>
27#include <map>
28#include <wx/string.h>
29#include <iostream>
30#include <functional>
31#include "odb_feature.h"
32#include "odb_eda_data.h"
33#include "odb_netlist.h"
34#include "odb_component.h"
35
36
37class BOARD;
38class ODB_TREE_WRITER;
39class BOARD_ITEM;
40class PCB_IO_ODBPP;
41
43{
44public:
45 ODB_ENTITY_BASE( BOARD* aBoard, PCB_IO_ODBPP* aPlugin ) : m_board( aBoard ), m_plugin( aPlugin )
46 {
47 }
48
49 ODB_ENTITY_BASE() : m_board( nullptr ), m_plugin( nullptr ) {}
50
51 virtual ~ODB_ENTITY_BASE() = default;
52 virtual void GenerateFiles( ODB_TREE_WRITER& writer ) {}
53 virtual bool CreateDirectoryTree( ODB_TREE_WRITER& writer );
54 virtual std::string GetEntityName() = 0;
55 virtual void InitEntityData() {}
56
57
58protected:
60 std::vector<std::string> m_fileName;
62};
63
64enum class ODB_SUBTYPE;
65enum class ODB_POLARITY;
66enum class ODB_CONTEXT;
67enum class ODB_TYPE;
68
70{
71public:
72 ODB_MATRIX_ENTITY( BOARD* aBoard, PCB_IO_ODBPP* aPlugin ) : ODB_ENTITY_BASE( aBoard, aPlugin )
73 {
74 }
75
76 virtual ~ODB_MATRIX_ENTITY() = default;
77
78 inline virtual std::string GetEntityName() override { return "matrix"; }
79
81 {
82 std::optional<std::pair<wxString, wxString>> m_span; // !< start, end
83 std::optional<ODB_SUBTYPE> m_addType;
84 std::optional<ODB_DIELECTRIC_TYPE> m_diType;
85
86 uint32_t m_rowNumber;
87 wxString m_layerName;
90 ODB_POLARITY m_polarity = ODB_POLARITY::POSITIVE;
91
92 MATRIX_LAYER( uint32_t aRow, const wxString& aLayerName ) :
93 m_rowNumber( aRow ), m_layerName( ODB::GenLegalEntityName( aLayerName ) )
94 {
95 }
96 };
97
98 virtual void GenerateFiles( ODB_TREE_WRITER& writer ) override;
99 virtual void InitEntityData() override;
100 void InitMatrixLayerData();
101
102 void AddStep( const wxString& aStepName );
103 void AddMatrixLayerField( MATRIX_LAYER& aMLayer, PCB_LAYER_ID aLayer );
104 void AddDrillMatrixLayer();
105 void AddCOMPMatrixLayer( PCB_LAYER_ID aCompSide );
106
107private:
108 std::map<wxString, unsigned int> m_matrixSteps;
109 std::vector<MATRIX_LAYER> m_matrixLayers;
110 unsigned int m_row = 1;
111 unsigned int m_col = 1;
112 bool m_hasBotComp = false;
113};
114
116{
117public:
119 virtual ~ODB_MISC_ENTITY() = default;
120 inline virtual std::string GetEntityName() override { return "misc"; }
121
122 //TODO
123 // bool AddAttrList();
124 // bool AddSysAttrFiles();
125 virtual void GenerateFiles( ODB_TREE_WRITER& writer ) override;
126
127private:
128 std::map<wxString, wxString> m_info;
129 // ODB_ATTRLIST m_attrlist;
130};
131
132class FEATURES_MANAGER;
133class ODB_LAYER_ENTITY;
135{
136public:
137 ODB_STEP_ENTITY( BOARD* aBoard, PCB_IO_ODBPP* aPlugin ) :
138 ODB_ENTITY_BASE( aBoard, aPlugin ), m_profile( nullptr ), m_netlist( aBoard )
139 {
140 }
141
142 virtual ~ODB_STEP_ENTITY() = default;
143
144 inline virtual std::string GetEntityName() override { return "pcb"; }
145
146 void InitEdaData();
149 void MakeLayerEntity();
153
154 virtual bool CreateDirectoryTree( ODB_TREE_WRITER& writer ) override;
155
156 virtual void InitEntityData() override;
157 void GenerateLayerFiles( ODB_TREE_WRITER& writer );
158 void GenerateEdaFiles( ODB_TREE_WRITER& writer );
160 void GenerateProfileFile( ODB_TREE_WRITER& writer );
162
163 virtual void GenerateFiles( ODB_TREE_WRITER& writer ) override;
164
165private:
166 // ODB_ATTRLIST m_attrList;
167 std::map<wxString, std::shared_ptr<ODB_LAYER_ENTITY>> m_layerEntityMap;
168 std::unique_ptr<FEATURES_MANAGER> m_profile;
169
171 std::unordered_map<wxString, wxString> m_stephdr;
173};
174
175
177{
178public:
179 ODB_LAYER_ENTITY( BOARD* aBoard, PCB_IO_ODBPP* aPlugin,
180 std::map<int, std::vector<BOARD_ITEM*>>& aMap, const PCB_LAYER_ID& aLayerID,
181 const wxString& aLayerName );
182
183 virtual ~ODB_LAYER_ENTITY() = default;
184
185 inline virtual std::string GetEntityName() override { return "layers"; }
186 virtual void InitEntityData() override;
187 void InitFeatureData();
189 void InitDrillData();
190
192
193
194 void GenAttrList( ODB_TREE_WRITER& writer );
195 void GenComponents( ODB_TREE_WRITER& writer );
196 void GenTools( ODB_TREE_WRITER& writer );
197
198 void GenFeatures( ODB_TREE_WRITER& writer );
199
200 virtual void GenerateFiles( ODB_TREE_WRITER& writer ) override;
201
202private:
203 std::map<int, std::vector<BOARD_ITEM*>> m_layerItems;
206 // ODB_ATTRLIST m_attrList;
207 std::optional<ODB_DRILL_TOOLS> m_tools;
208 std::optional<COMPONENTS_MANAGER> m_compTop;
209 std::optional<COMPONENTS_MANAGER> m_compBot;
210 std::unique_ptr<FEATURES_MANAGER> m_featuresMgr;
211};
212
214{
215public:
217
218 virtual ~ODB_SYMBOLS_ENTITY() = default;
219
220 inline virtual std::string GetEntityName() override { return "symbols"; }
221
222 //TODO
223 // virtual void GenerateFiles( ODB_TREE_WRITER& writer );
224};
225
227{
228public:
229 ODB_FONTS_ENTITY() = default;
230 virtual ~ODB_FONTS_ENTITY() = default;
231
232 inline virtual std::string GetEntityName() override { return "fonts"; }
233
234 virtual void GenerateFiles( ODB_TREE_WRITER& writer ) override;
235};
236
238{
239public:
240 ODB_WHEELS_ENTITY() = default;
241 virtual ~ODB_WHEELS_ENTITY() = default;
242
243 inline virtual std::string GetEntityName() override { return "wheels"; }
244
245 // TODO
246 // virtual void GenerateFiles( ODB_TREE_WRITER& writer );
247};
248
250{
251public:
252 ODB_INPUT_ENTITY() = default;
253 virtual ~ODB_INPUT_ENTITY() = default;
254
255 inline virtual std::string GetEntityName() override { return "input"; }
256
257 // TODO
258 // virtual void GenerateFiles( ODB_TREE_WRITER &writer );
259};
260
262{
263public:
264 ODB_USER_ENTITY() = default;
265 virtual ~ODB_USER_ENTITY() = default;
266
267 inline virtual std::string GetEntityName() override { return "user"; }
268
269 // TODO
270 // virtual void GenerateFiles( ODB_TREE_WRITER &writer );
271};
272
273#endif // _ODB_ENTITY_H_
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
virtual ~ODB_ENTITY_BASE()=default
virtual void InitEntityData()
Definition: odb_entity.h:55
virtual std::string GetEntityName()=0
virtual bool CreateDirectoryTree(ODB_TREE_WRITER &writer)
Definition: odb_entity.cpp:62
virtual void GenerateFiles(ODB_TREE_WRITER &writer)
Definition: odb_entity.h:52
BOARD * m_board
Definition: odb_entity.h:59
PCB_IO_ODBPP * m_plugin
Definition: odb_entity.h:61
std::vector< std::string > m_fileName
Definition: odb_entity.h:60
ODB_ENTITY_BASE(BOARD *aBoard, PCB_IO_ODBPP *aPlugin)
Definition: odb_entity.h:45
ODB_FONTS_ENTITY()=default
virtual std::string GetEntityName() override
Definition: odb_entity.h:232
virtual ~ODB_FONTS_ENTITY()=default
virtual void GenerateFiles(ODB_TREE_WRITER &writer) override
Definition: odb_fonts.cpp:666
ODB_INPUT_ENTITY()=default
virtual std::string GetEntityName() override
Definition: odb_entity.h:255
virtual ~ODB_INPUT_ENTITY()=default
virtual std::string GetEntityName() override
Definition: odb_entity.h:185
void GenFeatures(ODB_TREE_WRITER &writer)
Definition: odb_entity.cpp:636
PCB_LAYER_ID m_layerID
Definition: odb_entity.h:204
void InitFeatureData()
Definition: odb_entity.cpp:434
void GenComponents(ODB_TREE_WRITER &writer)
Definition: odb_entity.cpp:621
wxString m_matrixLayerName
Definition: odb_entity.h:205
std::optional< COMPONENTS_MANAGER > m_compTop
Definition: odb_entity.h:208
virtual void GenerateFiles(ODB_TREE_WRITER &writer) override
Definition: odb_entity.cpp:603
std::optional< COMPONENTS_MANAGER > m_compBot
Definition: odb_entity.h:209
std::optional< ODB_DRILL_TOOLS > m_tools
Definition: odb_entity.h:207
void GenTools(ODB_TREE_WRITER &writer)
Definition: odb_entity.cpp:650
std::map< int, std::vector< BOARD_ITEM * > > m_layerItems
Definition: odb_entity.h:203
virtual ~ODB_LAYER_ENTITY()=default
void AddLayerFeatures()
ODB_COMPONENT & InitComponentData(const FOOTPRINT *aFp, const EDA_DATA::PACKAGE &aPkg)
Definition: odb_entity.cpp:462
virtual void InitEntityData() override
Definition: odb_entity.cpp:419
void GenAttrList(ODB_TREE_WRITER &writer)
Definition: odb_entity.cpp:644
std::unique_ptr< FEATURES_MANAGER > m_featuresMgr
Definition: odb_entity.h:210
virtual std::string GetEntityName() override
Definition: odb_entity.h:78
void AddStep(const wxString &aStepName)
Definition: odb_entity.cpp:104
virtual ~ODB_MATRIX_ENTITY()=default
ODB_MATRIX_ENTITY(BOARD *aBoard, PCB_IO_ODBPP *aPlugin)
Definition: odb_entity.h:72
unsigned int m_col
Definition: odb_entity.h:111
void InitMatrixLayerData()
Definition: odb_entity.cpp:118
std::vector< MATRIX_LAYER > m_matrixLayers
Definition: odb_entity.h:109
void AddMatrixLayerField(MATRIX_LAYER &aMLayer, PCB_LAYER_ID aLayer)
Definition: odb_entity.cpp:191
virtual void GenerateFiles(ODB_TREE_WRITER &writer) override
Definition: odb_entity.cpp:356
std::map< wxString, unsigned int > m_matrixSteps
Definition: odb_entity.h:108
unsigned int m_row
Definition: odb_entity.h:110
void AddDrillMatrixLayer()
Definition: odb_entity.cpp:251
virtual void InitEntityData() override
Definition: odb_entity.cpp:110
void AddCOMPMatrixLayer(PCB_LAYER_ID aCompSide)
Definition: odb_entity.cpp:333
virtual std::string GetEntityName() override
Definition: odb_entity.h:120
std::map< wxString, wxString > m_info
Definition: odb_entity.h:128
virtual ~ODB_MISC_ENTITY()=default
virtual void GenerateFiles(ODB_TREE_WRITER &writer) override
Definition: odb_entity.cpp:91
virtual std::string GetEntityName() override
Definition: odb_entity.h:144
std::unordered_map< wxString, wxString > m_stephdr
Definition: odb_entity.h:171
void GenerateProfileFile(ODB_TREE_WRITER &writer)
Definition: odb_entity.cpp:785
ODB_STEP_ENTITY(BOARD *aBoard, PCB_IO_ODBPP *aPlugin)
Definition: odb_entity.h:137
EDA_DATA m_edaData
Definition: odb_entity.h:170
void GenerateStepHeaderFile(ODB_TREE_WRITER &writer)
Definition: odb_entity.cpp:807
void GenerateEdaFiles(ODB_TREE_WRITER &writer)
Definition: odb_entity.cpp:847
virtual void InitEntityData() override
Definition: odb_entity.cpp:589
void GenerateLayerFiles(ODB_TREE_WRITER &writer)
Definition: odb_entity.cpp:834
virtual ~ODB_STEP_ENTITY()=default
std::map< wxString, std::shared_ptr< ODB_LAYER_ENTITY > > m_layerEntityMap
Definition: odb_entity.h:167
ODB_NET_LIST m_netlist
Definition: odb_entity.h:172
std::unique_ptr< FEATURES_MANAGER > m_profile
Definition: odb_entity.h:168
bool AddStepHeader()
virtual bool CreateDirectoryTree(ODB_TREE_WRITER &writer) override
Definition: odb_entity.cpp:863
void GenerateNetlistsFiles(ODB_TREE_WRITER &writer)
Definition: odb_entity.cpp:855
void InitNetListData()
void MakeLayerEntity()
Definition: odb_entity.cpp:879
virtual void GenerateFiles(ODB_TREE_WRITER &writer) override
Definition: odb_entity.cpp:762
ODB_SYMBOLS_ENTITY()=default
virtual ~ODB_SYMBOLS_ENTITY()=default
virtual std::string GetEntityName() override
Definition: odb_entity.h:220
virtual std::string GetEntityName() override
Definition: odb_entity.h:267
virtual ~ODB_USER_ENTITY()=default
ODB_USER_ENTITY()=default
virtual std::string GetEntityName() override
Definition: odb_entity.h:243
virtual ~ODB_WHEELS_ENTITY()=default
ODB_WHEELS_ENTITY()=default
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
Definition: odb_util.cpp:32
ODB_SUBTYPE
Definition: odb_util.h:53
ODB_TYPE
Definition: odb_util.h:34
ODB_POLARITY
Definition: odb_util.h:15
ODB_CONTEXT
Definition: odb_util.h:21
std::optional< ODB_SUBTYPE > m_addType
Definition: odb_entity.h:83
std::optional< ODB_DIELECTRIC_TYPE > m_diType
Definition: odb_entity.h:84
MATRIX_LAYER(uint32_t aRow, const wxString &aLayerName)
Definition: odb_entity.h:92
std::optional< std::pair< wxString, wxString > > m_span
Definition: odb_entity.h:82