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 (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
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::pair<PCB_LAYER_ID, PCB_LAYER_ID>, std::vector<BOARD_ITEM*>>&
110 {
111 return m_slot_holes;
112 }
113
114 inline std::map<const PAD*, EDA_DATA::SUB_NET_TOEPRINT*>& GetPadSubnetMap()
115 {
116 return m_topeprint_subnets;
117 }
118
119 inline std::map<std::pair<PCB_LAYER_ID, ZONE*>, EDA_DATA::SUB_NET_PLANE*>& GetPlaneSubnetMap()
120 {
121 return m_plane_subnets;
122 }
123
124 inline std::map<PCB_TRACK*, EDA_DATA::SUB_NET*>& GetViaTraceSubnetMap()
125 {
126 return m_via_trace_subnets;
127 }
128
129
130 std::shared_ptr<ODB_TREE_WRITER> m_writer;
131
132 bool GenerateFiles( ODB_TREE_WRITER& writer );
133 bool ExportODB( const wxString& aFileName );
134 void CreateEntity();
135
137
138 // Frees the memory allocated for the loaded footprints in #m_loaded_footprints.
140
141 static double m_scale;
142 static double m_symbolScale;
143 static int m_sigfig;
144 static std::string m_unitsStr;
145
146private:
147 template <typename T, typename... Args>
148 void Make( Args&&... args )
149 {
150 std::shared_ptr<ODB_ENTITY_BASE> entity =
151 std::make_shared<T>( std::forward<Args>( args )... );
152
153 if( entity )
154 m_entities.push_back( entity );
155 }
156
158
159 std::vector<std::shared_ptr<FOOTPRINT>> m_loaded_footprints;
160
161 std::vector<std::pair<PCB_LAYER_ID, wxString>>
162 m_layer_name_list; //<! layer name in matrix entity to the internal layer id
163
164 std::map<std::pair<PCB_LAYER_ID, PCB_LAYER_ID>, std::vector<BOARD_ITEM*>>
165 m_drill_layers; //<! Drill sets are output as layers (to/from pairs)
166
167 std::map<std::pair<PCB_LAYER_ID, PCB_LAYER_ID>, std::vector<BOARD_ITEM*>>
168 m_slot_holes; //<! Storage vector of slotted holes that need to be output as cutouts
169
170 std::map<PCB_LAYER_ID, std::map<int, std::vector<BOARD_ITEM*>>>
171 m_layer_elements; //<! Storage map of layer to element list
172
173 std::map<const PAD*, EDA_DATA::SUB_NET_TOEPRINT*> m_topeprint_subnets;
174
175 std::map<std::pair<PCB_LAYER_ID, ZONE*>, EDA_DATA::SUB_NET_PLANE*> m_plane_subnets;
176
177 std::map<PCB_TRACK*, EDA_DATA::SUB_NET*> m_via_trace_subnets;
178
179 std::vector<std::shared_ptr<ODB_ENTITY_BASE>> m_entities;
180};
181
182#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:290
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:79
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:119
static int m_sigfig
Definition: pcb_io_odbpp.h:143
BOARD * m_board
Definition: pcb_io_odbpp.h:157
std::map< PCB_TRACK *, EDA_DATA::SUB_NET * > & GetViaTraceSubnetMap()
Definition: pcb_io_odbpp.h:124
std::shared_ptr< ODB_TREE_WRITER > m_writer
Definition: pcb_io_odbpp.h:130
~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:148
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:175
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::pair< PCB_LAYER_ID, PCB_LAYER_ID >, std::vector< BOARD_ITEM * > > m_drill_layers
Definition: pcb_io_odbpp.h:165
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:142
std::vector< std::shared_ptr< FOOTPRINT > > m_loaded_footprints
Definition: pcb_io_odbpp.h:159
std::map< std::pair< PCB_LAYER_ID, PCB_LAYER_ID >, std::vector< BOARD_ITEM * > > & GetSlotHolesMap()
Definition: pcb_io_odbpp.h:109
std::map< const PAD *, EDA_DATA::SUB_NET_TOEPRINT * > & GetPadSubnetMap()
Definition: pcb_io_odbpp.h:114
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:162
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:179
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:173
std::map< std::pair< PCB_LAYER_ID, PCB_LAYER_ID >, std::vector< BOARD_ITEM * > > m_slot_holes
Definition: pcb_io_odbpp.h:168
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:144
static double m_scale
Definition: pcb_io_odbpp.h:141
std::map< PCB_LAYER_ID, std::map< int, std::vector< BOARD_ITEM * > > > m_layer_elements
Definition: pcb_io_odbpp.h:171
bool GenerateFiles(ODB_TREE_WRITER &writer)
std::map< PCB_TRACK *, EDA_DATA::SUB_NET * > m_via_trace_subnets
Definition: pcb_io_odbpp.h:177
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