KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_odbpp.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 The 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
22#ifndef _PCB_IO_ODBPP_H_
23#define _PCB_IO_ODBPP_H_
24
25#include <pcb_io/pcb_io.h>
26#include <pcb_io/pcb_io_mgr.h>
28
29#include <eda_shape.h>
30#include <layer_ids.h> // PCB_LAYER_ID
31#include <font/font.h>
33#include <stroke_params.h>
34#include <memory>
35#include "odb_entity.h"
36
37class BOARD;
38class BOARD_ITEM;
39class EDA_TEXT;
40class FOOTPRINT;
42class NETINFO_ITEM;
43class PAD;
44class PCB_SHAPE;
45class PCB_VIA;
47class SHAPE_POLY_SET;
48class SHAPE_SEGMENT;
49class EDA_DATA;
50
51
52class PCB_IO_ODBPP : public PCB_IO
53{
54public:
55 PCB_IO_ODBPP() : PCB_IO( wxS( "ODBPlusPlus" ) ) { m_board = nullptr; }
56
57 ~PCB_IO_ODBPP() override;
58
59 void SaveBoard( const wxString& aFileName, BOARD* aBoard,
60 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
62 {
63 return IO_BASE::IO_FILE_DESC( _HKI( "ODB++ Production File" ), { "ZIP" } );
64 }
65
67 {
68 // No library description for this plugin
69 return IO_BASE::IO_FILE_DESC( wxEmptyString, {} );
70 }
71
72
73 std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints() override;
74
75 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override { return 0; }
76
77 // Reading currently disabled
78 bool CanReadBoard( const wxString& aFileName ) const override { return false; }
79
80 // Reading currently disabled
81 bool CanReadFootprint( const wxString& aFileName ) const override { return false; }
82
83 // Reading currently disabled
84 bool CanReadLibrary( const wxString& aFileName ) const override { return false; }
85
86public:
87 inline std::vector<std::pair<PCB_LAYER_ID, wxString>>& GetLayerNameList()
88 {
89 return m_layer_name_list;
90 }
91
92 inline std::map<PCB_LAYER_ID, std::map<int, std::vector<BOARD_ITEM*>>>& GetLayerElementsMap()
93 {
94 return m_layer_elements;
95 }
96
97 inline std::vector<std::shared_ptr<FOOTPRINT>>& GetLoadedFootprintList()
98 {
100 }
101
102 inline std::map<std::pair<PCB_LAYER_ID, PCB_LAYER_ID>, std::vector<BOARD_ITEM*>>&
104 {
105 return m_drill_layers;
106 }
107
108 inline std::map<std::tuple<ODB_AUX_LAYER_TYPE, PCB_LAYER_ID, PCB_LAYER_ID>,
109 std::vector<BOARD_ITEM*>>&
111 {
112 return m_auxilliary_layers;
113 }
114
115 inline std::map<std::pair<PCB_LAYER_ID, PCB_LAYER_ID>, std::vector<BOARD_ITEM*>>&
117 {
118 return m_slot_holes;
119 }
120
121 inline std::map<const PAD*, EDA_DATA::SUB_NET_TOEPRINT*>& GetPadSubnetMap()
122 {
123 return m_topeprint_subnets;
124 }
125
126 inline std::map<std::pair<PCB_LAYER_ID, ZONE*>, EDA_DATA::SUB_NET_PLANE*>& GetPlaneSubnetMap()
127 {
128 return m_plane_subnets;
129 }
130
131 inline std::map<PCB_TRACK*, EDA_DATA::SUB_NET*>& GetViaTraceSubnetMap()
132 {
133 return m_via_trace_subnets;
134 }
135
136
137 std::shared_ptr<ODB_TREE_WRITER> m_writer;
138
139 bool GenerateFiles( ODB_TREE_WRITER& writer );
140 bool ExportODB( const wxString& aFileName );
141 void CreateEntity();
142
144
145 // Frees the memory allocated for the loaded footprints in #m_loaded_footprints.
147
148 static double m_scale;
149 static double m_symbolScale;
150 static int m_sigfig;
151 static std::string m_unitsStr;
152
153private:
154 template <typename T, typename... Args>
155 void Make( Args&&... args )
156 {
157 std::shared_ptr<ODB_ENTITY_BASE> entity =
158 std::make_shared<T>( std::forward<Args>( args )... );
159
160 if( entity )
161 m_entities.push_back( entity );
162 }
163
165
166 std::vector<std::shared_ptr<FOOTPRINT>> m_loaded_footprints;
167
168 std::vector<std::pair<PCB_LAYER_ID, wxString>>
169 m_layer_name_list; //<! layer name in matrix entity to the internal layer id
170
171 std::map<std::pair<PCB_LAYER_ID, PCB_LAYER_ID>, std::vector<BOARD_ITEM*>>
172 m_drill_layers; //<! Drill sets are output as layers (to/from pairs)
173
174 std::map<std::tuple<ODB_AUX_LAYER_TYPE, PCB_LAYER_ID, PCB_LAYER_ID>, std::vector<BOARD_ITEM*>>
175 m_auxilliary_layers; //<! Auxilliary layers, from/to pairs or simple (depending on type)
176
177 std::map<std::pair<PCB_LAYER_ID, PCB_LAYER_ID>, std::vector<BOARD_ITEM*>>
178 m_slot_holes; //<! Storage vector of slotted holes that need to be output as cutouts
179
180 std::map<PCB_LAYER_ID, std::map<int, std::vector<BOARD_ITEM*>>>
181 m_layer_elements; //<! Storage map of layer to element list
182
183 std::map<const PAD*, EDA_DATA::SUB_NET_TOEPRINT*> m_topeprint_subnets;
184
185 std::map<std::pair<PCB_LAYER_ID, ZONE*>, EDA_DATA::SUB_NET_PLANE*> m_plane_subnets;
186
187 std::map<PCB_TRACK*, EDA_DATA::SUB_NET*> m_via_trace_subnets;
188
189 std::vector<std::shared_ptr<ODB_ENTITY_BASE>> m_entities;
190};
191
192#endif // _PCB_IO_ODBPP_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:296
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
Handle the data for a net.
Definition: netinfo.h:56
Definition: pad.h:54
std::map< std::pair< PCB_LAYER_ID, ZONE * >, EDA_DATA::SUB_NET_PLANE * > & GetPlaneSubnetMap()
Definition: pcb_io_odbpp.h:126
static int m_sigfig
Definition: pcb_io_odbpp.h:150
BOARD * m_board
Definition: pcb_io_odbpp.h:164
std::map< PCB_TRACK *, EDA_DATA::SUB_NET * > & GetViaTraceSubnetMap()
Definition: pcb_io_odbpp.h:131
std::shared_ptr< ODB_TREE_WRITER > m_writer
Definition: pcb_io_odbpp.h:137
~PCB_IO_ODBPP() override
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
Definition: pcb_io_odbpp.h:78
std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints() override
Return a container with the cached library footprints generated in the last call to Load.
void ClearLoadedFootprints()
void Make(Args &&... args)
Definition: pcb_io_odbpp.h:155
std::vector< std::shared_ptr< FOOTPRINT > > & GetLoadedFootprintList()
Definition: pcb_io_odbpp.h:97
std::map< std::pair< PCB_LAYER_ID, ZONE * >, EDA_DATA::SUB_NET_PLANE * > m_plane_subnets
Definition: pcb_io_odbpp.h:185
bool CanReadFootprint(const wxString &aFileName) const override
Checks if this PCB_IO can read a footprint from specified file or directory.
Definition: pcb_io_odbpp.h:81
std::map< std::tuple< ODB_AUX_LAYER_TYPE, PCB_LAYER_ID, PCB_LAYER_ID >, std::vector< BOARD_ITEM * > > m_auxilliary_layers
Definition: pcb_io_odbpp.h:175
std::map< std::pair< PCB_LAYER_ID, PCB_LAYER_ID >, std::vector< BOARD_ITEM * > > m_drill_layers
Definition: pcb_io_odbpp.h:172
void CreateEntity()
std::vector< std::pair< PCB_LAYER_ID, wxString > > & GetLayerNameList()
Definition: pcb_io_odbpp.h:87
bool ExportODB(const wxString &aFileName)
static double m_symbolScale
Definition: pcb_io_odbpp.h:149
std::vector< std::shared_ptr< FOOTPRINT > > m_loaded_footprints
Definition: pcb_io_odbpp.h:166
std::map< std::pair< PCB_LAYER_ID, PCB_LAYER_ID >, std::vector< BOARD_ITEM * > > & GetSlotHolesMap()
Definition: pcb_io_odbpp.h:116
std::map< const PAD *, EDA_DATA::SUB_NET_TOEPRINT * > & GetPadSubnetMap()
Definition: pcb_io_odbpp.h:121
std::map< PCB_LAYER_ID, std::map< int, std::vector< BOARD_ITEM * > > > & GetLayerElementsMap()
Definition: pcb_io_odbpp.h:92
std::vector< std::pair< PCB_LAYER_ID, wxString > > m_layer_name_list
Definition: pcb_io_odbpp.h:169
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
Returns board file description for the PCB_IO.
Definition: pcb_io_odbpp.h:61
std::vector< std::shared_ptr< ODB_ENTITY_BASE > > m_entities
Definition: pcb_io_odbpp.h:189
void SaveBoard(const wxString &aFileName, BOARD *aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...
std::map< const PAD *, EDA_DATA::SUB_NET_TOEPRINT * > m_topeprint_subnets
Definition: pcb_io_odbpp.h:183
std::map< std::tuple< ODB_AUX_LAYER_TYPE, PCB_LAYER_ID, PCB_LAYER_ID >, std::vector< BOARD_ITEM * > > & GetAuxilliaryLayerItemsMap()
Definition: pcb_io_odbpp.h:110
std::map< std::pair< PCB_LAYER_ID, PCB_LAYER_ID >, std::vector< BOARD_ITEM * > > m_slot_holes
Definition: pcb_io_odbpp.h:178
const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override
Get the descriptor for the library container that this IO plugin operates on.
Definition: pcb_io_odbpp.h:66
static std::string m_unitsStr
Definition: pcb_io_odbpp.h:151
static double m_scale
Definition: pcb_io_odbpp.h:148
std::map< PCB_LAYER_ID, std::map< int, std::vector< BOARD_ITEM * > > > m_layer_elements
Definition: pcb_io_odbpp.h:181
bool GenerateFiles(ODB_TREE_WRITER &writer)
std::map< PCB_TRACK *, EDA_DATA::SUB_NET * > m_via_trace_subnets
Definition: pcb_io_odbpp.h:187
bool CreateDirectories(ODB_TREE_WRITER &writer)
std::map< std::pair< PCB_LAYER_ID, PCB_LAYER_ID >, std::vector< BOARD_ITEM * > > & GetDrillLayerItemsMap()
Definition: pcb_io_odbpp.h:103
bool CanReadLibrary(const wxString &aFileName) const override
Checks if this IO object can read the specified library file/directory.
Definition: pcb_io_odbpp.h:84
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
Definition: pcb_io_odbpp.h:75
A base class that BOARD loading and saving plugins should derive from.
Definition: pcb_io.h:71
A progress reporter interface for use in multi-threaded environments.
Represent a set of closed polygons.
#define _HKI(x)
Container that describes file type info.
Definition: io_base.h:43