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
38{
40 {
43 m_IsBackdrill = false;
44 m_IsNonPlated = false;
45 }
46
47 ODB_DRILL_SPAN( PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer, bool aIsBackdrill,
48 bool aIsNonPlated )
49 {
50 m_StartLayer = aStartLayer;
51 m_EndLayer = aEndLayer;
52 m_IsBackdrill = aIsBackdrill;
53 m_IsNonPlated = aIsNonPlated;
54 }
55
60
65
66 std::pair<PCB_LAYER_ID, PCB_LAYER_ID> Pair() const
67 {
68 return std::make_pair( TopLayer(), BottomLayer() );
69 }
70
71 bool operator<( const ODB_DRILL_SPAN& aOther ) const
72 {
73 if( TopLayer() != aOther.TopLayer() )
74 return TopLayer() < aOther.TopLayer();
75
76 if( BottomLayer() != aOther.BottomLayer() )
77 return BottomLayer() < aOther.BottomLayer();
78
79 if( m_IsBackdrill != aOther.m_IsBackdrill )
80 return m_IsBackdrill && !aOther.m_IsBackdrill;
81
82 if( m_IsNonPlated != aOther.m_IsNonPlated )
83 return m_IsNonPlated && !aOther.m_IsNonPlated;
84
85 if( m_StartLayer != aOther.m_StartLayer )
86 return m_StartLayer < aOther.m_StartLayer;
87
88 return m_EndLayer < aOther.m_EndLayer;
89 }
90
95};
96
97class BOARD;
98class BOARD_ITEM;
99class EDA_TEXT;
100class FOOTPRINT;
102class NETINFO_ITEM;
103class PAD;
104class PCB_SHAPE;
105class PCB_VIA;
107class SHAPE_POLY_SET;
108class SHAPE_SEGMENT;
109class EDA_DATA;
110
111
112class PCB_IO_ODBPP : public PCB_IO
113{
114public:
115 PCB_IO_ODBPP() : PCB_IO( wxS( "ODBPlusPlus" ) ) { m_board = nullptr; }
116
117 ~PCB_IO_ODBPP() override;
118
119 void SaveBoard( const wxString& aFileName, BOARD* aBoard,
120 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
121
123 {
124 return IO_BASE::IO_FILE_DESC( _HKI( "ODB++ Production File" ), { "ZIP" }, {}, true, false, true );
125 }
126
128 {
129 // No library description for this plugin
130 return IO_BASE::IO_FILE_DESC( wxEmptyString, {} );
131 }
132
133
134 std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints() override;
135
136 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override { return 0; }
137
138 // Reading currently disabled
139 bool CanReadBoard( const wxString& aFileName ) const override { return false; }
140
141 // Reading currently disabled
142 bool CanReadFootprint( const wxString& aFileName ) const override { return false; }
143
144 // Reading currently disabled
145 bool CanReadLibrary( const wxString& aFileName ) const override { return false; }
146
147public:
148 inline std::vector<std::pair<PCB_LAYER_ID, wxString>>& GetLayerNameList()
149 {
150 return m_layer_name_list;
151 }
152
153 inline std::map<PCB_LAYER_ID, std::map<int, std::vector<BOARD_ITEM*>>>& GetLayerElementsMap()
154 {
155 return m_layer_elements;
156 }
157
158 inline std::vector<std::shared_ptr<FOOTPRINT>>& GetLoadedFootprintList()
159 {
160 return m_loaded_footprints;
161 }
162
163 inline std::map<ODB_DRILL_SPAN, std::vector<BOARD_ITEM*>>& GetDrillLayerItemsMap()
164 {
165 return m_drill_layers;
166 }
167
168 inline std::map<ODB_DRILL_SPAN, wxString>& GetDrillSpanNameMap()
169 {
170 return m_drill_span_names;
171 }
172
173 inline std::map<std::tuple<ODB_AUX_LAYER_TYPE, PCB_LAYER_ID, PCB_LAYER_ID>,
174 std::vector<BOARD_ITEM*>>&
179
180 inline std::map<std::pair<PCB_LAYER_ID, PCB_LAYER_ID>, std::vector<BOARD_ITEM*>>&
182 {
183 return m_slot_holes;
184 }
185
186 inline std::map<const PAD*, EDA_DATA::SUB_NET_TOEPRINT*>& GetPadSubnetMap()
187 {
188 return m_topeprint_subnets;
189 }
190
191 inline std::map<std::pair<PCB_LAYER_ID, ZONE*>, EDA_DATA::SUB_NET_PLANE*>& GetPlaneSubnetMap()
192 {
193 return m_plane_subnets;
194 }
195
196 inline std::map<PCB_TRACK*, EDA_DATA::SUB_NET*>& GetViaTraceSubnetMap()
197 {
198 return m_via_trace_subnets;
199 }
200
201
202 std::shared_ptr<ODB_TREE_WRITER> m_writer;
203
204 bool GenerateFiles( ODB_TREE_WRITER& writer );
205 bool ExportODB( const wxString& aFileName );
206 void CreateEntity();
207
209
210 // Frees the memory allocated for the loaded footprints in #m_loaded_footprints.
212
213 static double m_scale;
214 static double m_symbolScale;
215 static int m_sigfig;
216 static std::string m_unitsStr;
217
218private:
219 template <typename T, typename... Args>
220 void Make( Args&&... args )
221 {
222 std::shared_ptr<ODB_ENTITY_BASE> entity =
223 std::make_shared<T>( std::forward<Args>( args )... );
224
225 if( entity )
226 m_entities.push_back( entity );
227 }
228
230
231 std::vector<std::shared_ptr<FOOTPRINT>> m_loaded_footprints;
232
233 std::vector<std::pair<PCB_LAYER_ID, wxString>>
234 m_layer_name_list; //<! layer name in matrix entity to the internal layer id
235
236 std::map<ODB_DRILL_SPAN, std::vector<BOARD_ITEM*>>
237 m_drill_layers; //<! Drill sets are output as layers (to/from pairs)
238 std::map<ODB_DRILL_SPAN, wxString> m_drill_span_names;
239
240 std::map<std::tuple<ODB_AUX_LAYER_TYPE, PCB_LAYER_ID, PCB_LAYER_ID>, std::vector<BOARD_ITEM*>>
241 m_auxilliary_layers; //<! Auxilliary layers, from/to pairs or simple (depending on type)
242
243 std::map<std::pair<PCB_LAYER_ID, PCB_LAYER_ID>, std::vector<BOARD_ITEM*>>
244 m_slot_holes; //<! Storage vector of slotted holes that need to be output as cutouts
245
246 std::map<PCB_LAYER_ID, std::map<int, std::vector<BOARD_ITEM*>>>
247 m_layer_elements; //<! Storage map of layer to element list
248
249 std::map<const PAD*, EDA_DATA::SUB_NET_TOEPRINT*> m_topeprint_subnets;
250
251 std::map<std::pair<PCB_LAYER_ID, ZONE*>, EDA_DATA::SUB_NET_PLANE*> m_plane_subnets;
252
253 std::map<PCB_TRACK*, EDA_DATA::SUB_NET*> m_via_trace_subnets;
254
255 std::vector<std::shared_ptr<ODB_ENTITY_BASE>> m_entities;
256};
257
258#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:83
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
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:54
Definition pad.h:55
std::map< std::pair< PCB_LAYER_ID, ZONE * >, EDA_DATA::SUB_NET_PLANE * > & GetPlaneSubnetMap()
static int m_sigfig
BOARD * m_board
std::map< PCB_TRACK *, EDA_DATA::SUB_NET * > & GetViaTraceSubnetMap()
std::shared_ptr< ODB_TREE_WRITER > m_writer
~PCB_IO_ODBPP() override
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
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)
std::vector< std::shared_ptr< FOOTPRINT > > & GetLoadedFootprintList()
std::map< std::pair< PCB_LAYER_ID, ZONE * >, EDA_DATA::SUB_NET_PLANE * > m_plane_subnets
bool CanReadFootprint(const wxString &aFileName) const override
Checks if this PCB_IO can read a footprint from specified file or directory.
std::map< std::tuple< ODB_AUX_LAYER_TYPE, PCB_LAYER_ID, PCB_LAYER_ID >, std::vector< BOARD_ITEM * > > m_auxilliary_layers
std::map< ODB_DRILL_SPAN, wxString > & GetDrillSpanNameMap()
void CreateEntity()
std::vector< std::pair< PCB_LAYER_ID, wxString > > & GetLayerNameList()
bool ExportODB(const wxString &aFileName)
static double m_symbolScale
std::vector< std::shared_ptr< FOOTPRINT > > m_loaded_footprints
std::map< ODB_DRILL_SPAN, std::vector< BOARD_ITEM * > > m_drill_layers
std::map< std::pair< PCB_LAYER_ID, PCB_LAYER_ID >, std::vector< BOARD_ITEM * > > & GetSlotHolesMap()
std::map< const PAD *, EDA_DATA::SUB_NET_TOEPRINT * > & GetPadSubnetMap()
std::map< PCB_LAYER_ID, std::map< int, std::vector< BOARD_ITEM * > > > & GetLayerElementsMap()
std::map< ODB_DRILL_SPAN, wxString > m_drill_span_names
std::map< ODB_DRILL_SPAN, std::vector< BOARD_ITEM * > > & GetDrillLayerItemsMap()
std::vector< std::pair< PCB_LAYER_ID, wxString > > m_layer_name_list
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
Returns board file description for the PCB_IO.
std::vector< std::shared_ptr< ODB_ENTITY_BASE > > m_entities
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
std::map< std::tuple< ODB_AUX_LAYER_TYPE, PCB_LAYER_ID, PCB_LAYER_ID >, std::vector< BOARD_ITEM * > > & GetAuxilliaryLayerItemsMap()
std::map< std::pair< PCB_LAYER_ID, PCB_LAYER_ID >, std::vector< BOARD_ITEM * > > m_slot_holes
const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override
Get the descriptor for the library container that this IO plugin operates on.
static std::string m_unitsStr
static double m_scale
std::map< PCB_LAYER_ID, std::map< int, std::vector< BOARD_ITEM * > > > m_layer_elements
bool GenerateFiles(ODB_TREE_WRITER &writer)
std::map< PCB_TRACK *, EDA_DATA::SUB_NET * > m_via_trace_subnets
bool CreateDirectories(ODB_TREE_WRITER &writer)
bool CanReadLibrary(const wxString &aFileName) const override
Checks if this IO object can read the specified library file/directory.
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
PCB_IO(const wxString &aName)
Definition pcb_io.h:319
A progress reporter interface for use in multi-threaded environments.
Represent a set of closed polygons.
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ B_Cu
Definition layer_ids.h:65
@ F_Cu
Definition layer_ids.h:64
#define _HKI(x)
Definition page_info.cpp:44
Container that describes file type info.
Definition io_base.h:43
std::pair< PCB_LAYER_ID, PCB_LAYER_ID > Pair() const
PCB_LAYER_ID BottomLayer() const
PCB_LAYER_ID m_EndLayer
ODB_DRILL_SPAN(PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer, bool aIsBackdrill, bool aIsNonPlated)
PCB_LAYER_ID m_StartLayer
PCB_LAYER_ID TopLayer() const
bool operator<(const ODB_DRILL_SPAN &aOther) const