KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_kicad_sexpr.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) 2012 CERN.
5 * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef PCB_IO_KICAD_SEXPR_H_
26#define PCB_IO_KICAD_SEXPR_H_
27
28#include <pcb_io/pcb_io.h>
29#include <pcb_io/pcb_io_mgr.h>
30
31#include <richio.h>
32#include <string>
33#include <layer_ids.h>
34#include <boost/ptr_container/ptr_map.hpp>
35#include <wx_filename.h>
37
38class BOARD;
39class BOARD_ITEM;
40class FP_CACHE;
42class NETINFO_MAPPING;
45class PCB_SHAPE;
47class PCB_TARGET;
48class PAD;
49class PCB_GROUP;
50class PCB_GENERATOR;
51class PCB_TRACK;
52class ZONE;
53class PCB_TEXT;
54class PCB_TEXTBOX;
55class PCB_TABLE;
56class EDA_TEXT;
59class PCB_IO_KICAD_SEXPR; // forward decl
60
62
63//#define SEXPR_BOARD_FILE_VERSION 3 // first s-expression format, used legacy cu stack
64//#define SEXPR_BOARD_FILE_VERSION 4 // reversed cu stack, changed Inner* to In* in reverse order
65// // went to 32 Cu layers from 16.
66//----------------- Start of 5.0 development -----------------
67//#define SEXPR_BOARD_FILE_VERSION 20160815 // differential pair settings per net class
68//#define SEXPR_BOARD_FILE_VERSION 20170123 // EDA_TEXT refactor, moved 'hide'
69//#define SEXPR_BOARD_FILE_VERSION 20170920 // long pad names and custom pad shape
70//#define SEXPR_BOARD_FILE_VERSION 20170922 // Keepout zones can exist on multiple layers
71//#define SEXPR_BOARD_FILE_VERSION 20171114 // Save 3D model offset in mm, instead of inches
72//#define SEXPR_BOARD_FILE_VERSION 20171125 // Locked/unlocked FP_TEXT
73//#define SEXPR_BOARD_FILE_VERSION 20171130 // 3D model offset written using "offset" parameter
74//----------------- Start of 6.0 development -----------------
75//#define SEXPR_BOARD_FILE_VERSION 20190331 // hatched zones and chamfered round rect pads
76//#define SEXPR_BOARD_FILE_VERSION 20190421 // curves in custom pads
77//#define SEXPR_BOARD_FILE_VERSION 20190516 // Remove segment count from zones
78//#define SEXPR_BOARD_FILE_VERSION 20190605 // Add layer defaults
79//#define SEXPR_BOARD_FILE_VERSION 20190905 // Add board physical stackup info in setup section
80//#define SEXPR_BOARD_FILE_VERSION 20190907 // Keepout areas in footprints
81//#define SEXPR_BOARD_FILE_VERSION 20191123 // pin function in pads
82//#define SEXPR_BOARD_FILE_VERSION 20200104 // pad property for fabrication
83//#define SEXPR_BOARD_FILE_VERSION 20200119 // arcs in tracks
84//#define SEXPR_BOARD_FILE_VERSION 20200512 // page -> paper
85//#define SEXPR_BOARD_FILE_VERSION 20200518 // save hole_to_hole_min
86//#define SEXPR_BOARD_FILE_VERSION 20200614 // Add support for fp_rects and gr_rects
87//#define SEXPR_BOARD_FILE_VERSION 20200625 // Multilayer zones, zone names, island controls
88//#define SEXPR_BOARD_FILE_VERSION 20200628 // remove visibility settings
89//#define SEXPR_BOARD_FILE_VERSION 20200724 // Add KIID to footprints
90//#define SEXPR_BOARD_FILE_VERSION 20200807 // Add zone hatch advanced settings
91//#define SEXPR_BOARD_FILE_VERSION 20200808 // Add properties to footprints
92//#define SEXPR_BOARD_FILE_VERSION 20200809 // Add REMOVE_UNUSED_LAYERS option to vias and THT pads
93//#define SEXPR_BOARD_FILE_VERSION 20200811 // Add groups
94//#define SEXPR_BOARD_FILE_VERSION 20200818 // Remove Status flag bitmap and setup counts
95//#define SEXPR_BOARD_FILE_VERSION 20200819 // Add board-level properties
96//#define SEXPR_BOARD_FILE_VERSION 20200825 // Remove host information
97//#define SEXPR_BOARD_FILE_VERSION 20200828 // Add new fabrication attributes
98//#define SEXPR_BOARD_FILE_VERSION 20200829 // Remove library name from exported footprints
99//#define SEXPR_BOARD_FILE_VERSION 20200909 // Change DIMENSION format
100//#define SEXPR_BOARD_FILE_VERSION 20200913 // Add leader dimension
101//#define SEXPR_BOARD_FILE_VERSION 20200916 // Add center dimension
102//#define SEXPR_BOARD_FILE_VERSION 20200921 // Add orthogonal dimension
103//#define SEXPR_BOARD_FILE_VERSION 20200922 // Add user name to layer definition.
104//#define SEXPR_BOARD_FILE_VERSION 20201002 // Add groups in footprints (for footprint editor).
105//#define SEXPR_BOARD_FILE_VERSION 20201114 // Add first-class support for filled shapes.
106//#define SEXPR_BOARD_FILE_VERSION 20201115 // module -> footprint and change fill syntax.
107//#define SEXPR_BOARD_FILE_VERSION 20201116 // Write version and generator string in footprint files.
108//#define SEXPR_BOARD_FILE_VERSION 20201220 // Add free via token
109//#define SEXPR_BOARD_FILE_VERSION 20210108 // Pad locking moved from footprint to pads
110//#define SEXPR_BOARD_FILE_VERSION 20210126 // Store pintype alongside pinfunction (in pads).
111//#define SEXPR_BOARD_FILE_VERSION 20210228 // Move global margins back to board file
112//#define SEXPR_BOARD_FILE_VERSION 20210424 // Correct locked flag syntax (remove parens).
113//#define SEXPR_BOARD_FILE_VERSION 20210606 // Change overbar syntax from `~...~` to `~{...}`.
114//#define SEXPR_BOARD_FILE_VERSION 20210623 // Add support for reading/writing arcs in polygons
115//#define SEXPR_BOARD_FILE_VERSION 20210722 // Reading/writing group locked flags
116//#define SEXPR_BOARD_FILE_VERSION 20210824 // Opacity in 3D colors
117//#define SEXPR_BOARD_FILE_VERSION 20210925 // Locked flag for fp_text
118//#define SEXPR_BOARD_FILE_VERSION 20211014 // Arc formatting
119//----------------- Start of 7.0 development -----------------
120//#define SEXPR_BOARD_FILE_VERSION 20211226 // Add radial dimension
121//#define SEXPR_BOARD_FILE_VERSION 20211227 // Add thermal relief spoke angle overrides
122//#define SEXPR_BOARD_FILE_VERSION 20211228 // Add allow_soldermask_bridges footprint attribute
123//#define SEXPR_BOARD_FILE_VERSION 20211229 // Stroke formatting
124//#define SEXPR_BOARD_FILE_VERSION 20211230 // Dimensions in footprints
125//#define SEXPR_BOARD_FILE_VERSION 20211231 // Private footprint layers
126//#define SEXPR_BOARD_FILE_VERSION 20211232 // Fonts
127//#define SEXPR_BOARD_FILE_VERSION 20220131 // Textboxes
128//#define SEXPR_BOARD_FILE_VERSION 20220211 // End support for V5 zone fill strategy
129//#define SEXPR_BOARD_FILE_VERSION 20220225 // Remove TEDIT
130//#define SEXPR_BOARD_FILE_VERSION 20220308 // Knockout text and Locked graphic text property saved
131//#define SEXPR_BOARD_FILE_VERSION 20220331 // Plot on all layers selection setting
132//#define SEXPR_BOARD_FILE_VERSION 20220417 // Automatic dimension precisions
133//#define SEXPR_BOARD_FILE_VERSION 20220427 // Exclude Edge.Cuts & Margin from fp private layers
134//#define SEXPR_BOARD_FILE_VERSION 20220609 // Add teardrop keywords to identify teardrop zones
135//#define SEXPR_BOARD_FILE_VERSION 20220621 // Add Image support
136//#define SEXPR_BOARD_FILE_VERSION 20220815 // Add allow-soldermask-bridges-in-FPs flag
137//#define SEXPR_BOARD_FILE_VERSION 20220818 // First-class storage for net-ties
138//#define SEXPR_BOARD_FILE_VERSION 20220914 // Number boxes for custom-shape pads
139//#define SEXPR_BOARD_FILE_VERSION 20221018 // Via & pad zone-layer-connections
140//----------------- Start of 8.0 development -----------------
141//#define SEXPR_BOARD_FILE_VERSION 20230410 // DNP attribute propagated from schematic to attr
142//#define SEXPR_BOARD_FILE_VERSION 20230517 // Teardrop parameters for pads and vias
143//#define SEXPR_BOARD_FILE_VERSION 20230620 // PCB Fields
144//#define SEXPR_BOARD_FILE_VERSION 20230730 // Connectivity for graphic shapes
145//#define SEXPR_BOARD_FILE_VERSION 20230825 // Textbox explicit border flag
146//#define SEXPR_BOARD_FILE_VERSION 20230906 // Multiple image type support in files
147//#define SEXPR_BOARD_FILE_VERSION 20230913 // Custom-shaped-pad spoke templates
148//#define SEXPR_BOARD_FILE_VERSION 20231007 // Generative objects
149//#define SEXPR_BOARD_FILE_VERSION 20231014 // V8 file format normalization
150//#define SEXPR_BOARD_FILE_VERSION 20231212 // Reference image locking/UUIDs, footprint boolean format
151//#define SEXPR_BOARD_FILE_VERSION 20231231 // Use 'uuid' rather than 'id' for generators and groups
152//#define SEXPR_BOARD_FILE_VERSION 20240108 // Convert teardrop parameters to explicit bools
153//----------------- Start of 9.0 development -----------------
154//#define SEXPR_BOARD_FILE_VERSION 20240201 // Use nullable properties for overrides
155//#define SEXPR_BOARD_FILE_VERSION 20240202 // Tables
156#define SEXPR_BOARD_FILE_VERSION 20240225 // Rationalization of solder_paste_margin
157
158#define BOARD_FILE_HOST_VERSION 20200825
159#define LEGACY_ARC_FORMATTING 20210925
160#define LEGACY_NET_TIES 20220815
162#define FIRST_NORMALIZED_VERISON 20230924
163
164#define CTL_OMIT_PAD_NETS (1 << 1)
165#define CTL_OMIT_UUIDS (1 << 2)
166#define CTL_OMIT_INITIAL_COMMENTS (1 << 3)
167#define CTL_OMIT_PATH (1 << 4)
168#define CTL_OMIT_AT (1 << 5)
170//#define CTL_OMIT_HIDE (1 << 6) // found and defined in eda_text.h
171#define CTL_OMIT_LIBNAME (1 << 7)
173#define CTL_OMIT_FOOTPRINT_VERSION (1 << 8)
175
176// common combinations of the above:
177
179#define CTL_FOR_CLIPBOARD (CTL_OMIT_INITIAL_COMMENTS) // (CTL_OMIT_NETS)
180
182#define CTL_FOR_LIBRARY \
183 ( CTL_OMIT_PAD_NETS | CTL_OMIT_UUIDS | CTL_OMIT_PATH | CTL_OMIT_AT | CTL_OMIT_LIBNAME )
184
187#define CTL_FOR_BOARD (CTL_OMIT_INITIAL_COMMENTS|CTL_OMIT_FOOTPRINT_VERSION)
188
198{
200 std::unique_ptr<FOOTPRINT> m_footprint;
201
202public:
203 FP_CACHE_ITEM( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName );
204
205 const WX_FILENAME& GetFileName() const { return m_filename; }
206 void SetFilePath( const wxString& aFilePath ) { m_filename.SetPath( aFilePath ); }
207 const FOOTPRINT* GetFootprint() const { return m_footprint.get(); }
208};
209
210typedef boost::ptr_map<wxString, FP_CACHE_ITEM> FP_CACHE_FOOTPRINT_MAP;
211
213{
214 PCB_IO_KICAD_SEXPR* m_owner; // Plugin object that owns the cache.
215 wxFileName m_lib_path; // The path of the library.
216 wxString m_lib_raw_path; // For quick comparisons.
217 FP_CACHE_FOOTPRINT_MAP m_footprints; // Map of footprint filename to FOOTPRINT*.
218
219 bool m_cache_dirty; // Stored separately because it's expensive to check
220 // m_cache_timestamp against all the files.
221 long long m_cache_timestamp; // A hash of the timestamps for all the footprint
222 // files.
223
224public:
225 FP_CACHE( PCB_IO_KICAD_SEXPR* aOwner, const wxString& aLibraryPath );
226
227 wxString GetPath() const { return m_lib_raw_path; }
228
229 bool IsWritable() const { return m_lib_path.IsOk() && m_lib_path.IsDirWritable(); }
230
231 bool Exists() const { return m_lib_path.IsOk() && m_lib_path.DirExists(); }
232
234
235 // Most all functions in this class throw IO_ERROR exceptions. There are no
236 // error codes nor user interface calls from here, nor in any PLUGIN.
237 // Catch these exceptions higher up please.
238
244 void Save( FOOTPRINT* aFootprint = nullptr );
245
246 void Load();
247
248 void Remove( const wxString& aFootprintName );
249
255 static long long GetTimestamp( const wxString& aLibPath );
256
260 bool IsModified();
261
273 bool IsPath( const wxString& aPath ) const;
274
275 void SetPath( const wxString& aPath );
276};
277
278
285{
286public:
288 {
289 // Would have used wildcards_and_files_ext.cpp's KiCadPcbFileExtension,
290 // but to be pure, a plugin should not assume that it will always be linked
291 // with the core of the Pcbnew code. (Might someday be a DLL/DSO.) Besides,
292 // file extension policy should be controlled by the plugin.
293 return IO_BASE::IO_FILE_DESC( _HKI( "KiCad printed circuit board files" ), { "kicad_pcb" } );
294 }
295
297 {
298 return IO_BASE::IO_FILE_DESC( _HKI( "KiCad footprint file" ), { "kicad_mod" } );
299 }
300
302 {
303 return IO_BASE::IO_FILE_DESC( _HKI( "KiCad footprint files" ), {}, { "kicad_mod" }, false );
304 }
305
306 void SetQueryUserCallback( std::function<bool( wxString aTitle, int aIcon, wxString aMessage,
307 wxString aOKButtonTitle )> aCallback ) override
308 {
309 m_queryUserCallback = std::move( aCallback );
310 }
311
312 bool CanReadBoard( const wxString& aFileName ) const override;
313
314 void SaveBoard( const wxString& aFileName, BOARD* aBoard,
315 const STRING_UTF8_MAP* aProperties = nullptr ) override;
316
317 BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
318 const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
319
320 BOARD* DoLoad( LINE_READER& aReader, BOARD* aAppendToMe, const STRING_UTF8_MAP* aProperties,
321 PROGRESS_REPORTER* aProgressReporter, unsigned aLineCount );
322
323 void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
324 bool aBestEfforts, const STRING_UTF8_MAP* aProperties = nullptr ) override;
325
326 const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath,
327 const wxString& aFootprintName,
328 const STRING_UTF8_MAP* aProperties = nullptr ) override;
329
330 bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
331 const STRING_UTF8_MAP* aProperties = nullptr ) override;
332
333 FOOTPRINT* ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
334 const STRING_UTF8_MAP* aProperties = nullptr ) override;
335
336 FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
337 bool aKeepUUID = false,
338 const STRING_UTF8_MAP* aProperties = nullptr ) override;
339
340 void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
341 const STRING_UTF8_MAP* aProperties = nullptr ) override;
342
343 void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
344 const STRING_UTF8_MAP* aProperties = nullptr ) override;
345
346 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
347
348 void CreateLibrary( const wxString& aLibraryPath,
349 const STRING_UTF8_MAP* aProperties = nullptr) override;
350
351 bool DeleteLibrary( const wxString& aLibraryPath,
352 const STRING_UTF8_MAP* aProperties = nullptr ) override;
353
354 bool IsLibraryWritable( const wxString& aLibraryPath ) override;
355
356 PCB_IO_KICAD_SEXPR( int aControlFlags = CTL_FOR_BOARD );
357
358 virtual ~PCB_IO_KICAD_SEXPR();
359
367 void Format( const BOARD_ITEM* aItem, int aNestLevel = 0 ) const;
368
369 std::string GetStringOutput( bool doClear )
370 {
371 std::string ret = m_sf.GetString();
372
373 if( doClear )
374 m_sf.Clear();
375
376 return ret;
377 }
378
379 void SetOutputFormatter( OUTPUTFORMATTER* aFormatter ) { m_out = aFormatter; }
380
381 BOARD_ITEM* Parse( const wxString& aClipboardSourceInput );
382
383protected:
384 void validateCache( const wxString& aLibraryPath, bool checkModified = true );
385
386 const FOOTPRINT* getFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
387 const STRING_UTF8_MAP* aProperties, bool checkModified );
388
389 void init( const STRING_UTF8_MAP* aProperties );
390
392 void formatSetup( const BOARD* aBoard, int aNestLevel = 0 ) const;
393
395 void formatGeneral( const BOARD* aBoard, int aNestLevel = 0 ) const;
396
398 void formatBoardLayers( const BOARD* aBoard, int aNestLevel = 0 ) const;
399
401 void formatNetInformation( const BOARD* aBoard, int aNestLevel = 0 ) const;
402
404 void formatProperties( const BOARD* aBoard, int aNestLevel = 0 ) const;
405
407 void formatHeader( const BOARD* aBoard, int aNestLevel = 0 ) const;
408
409 void formatTeardropParameters( const TEARDROP_PARAMETERS& tdParams, int aNestLevel = 0 ) const;
410
411private:
412 void format( const BOARD* aBoard, int aNestLevel = 0 ) const;
413
414 void format( const PCB_DIMENSION_BASE* aDimension, int aNestLevel = 0 ) const;
415
416 void format( const PCB_REFERENCE_IMAGE* aBitmap, int aNestLevel = 0 ) const;
417
418 void format( const PCB_GROUP* aGroup, int aNestLevel = 0 ) const;
419
420 void format( const PCB_SHAPE* aSegment, int aNestLevel = 0 ) const;
421
422 void format( const PCB_TARGET* aTarget, int aNestLevel = 0 ) const;
423
424 void format( const FOOTPRINT* aFootprint, int aNestLevel = 0 ) const;
425
426 void format( const PAD* aPad, int aNestLevel = 0 ) const;
427
428 void format( const PCB_TEXT* aText, int aNestLevel = 0 ) const;
429 void format( const PCB_TEXTBOX* aTextBox, int aNestLevel = 0 ) const;
430
431 void format( const PCB_TABLE* aTable, int aNestLevel = 0 ) const;
432
433 void format( const PCB_GENERATOR* aGenerator, int aNestLevel = 0 ) const;
434
435 void format( const PCB_TRACK* aTrack, int aNestLevel = 0 ) const;
436
437 void format( const ZONE* aZone, int aNestLevel = 0 ) const;
438
439 void formatPolyPts( const SHAPE_LINE_CHAIN& outline, int aNestLevel, bool aCompact,
440 const FOOTPRINT* aParentFP = nullptr ) const;
441
442 void formatRenderCache( const EDA_TEXT* aText, int aNestLevel ) const;
443
444 void formatLayer( PCB_LAYER_ID aLayer, bool aIsKnockout = false ) const;
445
446 void formatLayers( LSET aLayerMask, int aNestLevel = 0 ) const;
447
448 friend class FP_CACHE;
449
450protected:
451 wxString m_error;
452
454
456 wxString m_filename;
457
460 int m_ctl;
463
464 std::function<bool( wxString aTitle, int aIcon, wxString aMsg, wxString aAction )> m_queryUserCallback;
465};
466
467#endif // PCB_IO_KICAD_SEXPR_H_
Container for design settings for a BOARD object.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:281
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:83
Helper class for creating a footprint library cache.
std::unique_ptr< FOOTPRINT > m_footprint
WX_FILENAME m_filename
void SetFilePath(const wxString &aFilePath)
const FOOTPRINT * GetFootprint() const
const WX_FILENAME & GetFileName() const
static long long GetTimestamp(const wxString &aLibPath)
Generate a timestamp representing all source files in the cache (including the parent directory).
FP_CACHE_FOOTPRINT_MAP & GetFootprints()
bool Exists() const
void Save(FOOTPRINT *aFootprint=nullptr)
Save the footprint cache or a single footprint from it to disk.
PCB_IO_KICAD_SEXPR * m_owner
bool IsModified()
Return true if the cache is not up-to-date.
long long m_cache_timestamp
wxString m_lib_raw_path
void SetPath(const wxString &aPath)
wxFileName m_lib_path
bool IsPath(const wxString &aPath) const
Check if aPath is the same as the current cache path.
FP_CACHE_FOOTPRINT_MAP m_footprints
bool IsWritable() const
void Remove(const wxString &aFootprintName)
wxString GetPath() const
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:93
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:574
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:322
Definition: pad.h:59
Abstract dimension API.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
void formatRenderCache(const EDA_TEXT *aText, int aNestLevel) const
const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override
Get the descriptor for the library container that this IO plugin operates on.
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
bool IsLibraryWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
void SaveBoard(const wxString &aFileName, BOARD *aBoard, const STRING_UTF8_MAP *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
void init(const STRING_UTF8_MAP *aProperties)
void formatLayers(LSET aLayerMask, int aNestLevel=0) const
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const STRING_UTF8_MAP *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PC...
const IO_BASE::IO_FILE_DESC GetLibraryFileDesc() const override
Get the descriptor for the individual library elements that this IO plugin operates on.
const FOOTPRINT * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties, bool checkModified)
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
void formatSetup(const BOARD *aBoard, int aNestLevel=0) const
formats the board setup information
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const STRING_UTF8_MAP *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
FP_CACHE * m_cache
Footprint library cache.
void formatPolyPts(const SHAPE_LINE_CHAIN &outline, int aNestLevel, bool aCompact, const FOOTPRINT *aParentFP=nullptr) const
void formatHeader(const BOARD *aBoard, int aNestLevel=0) const
writes everything that comes before the board_items, like settings and layers etc
void formatNetInformation(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
void formatProperties(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const STRING_UTF8_MAP *aProperties=nullptr) override
Write aFootprint to an existing library located at aLibraryPath.
void formatGeneral(const BOARD *aBoard, int aNestLevel=0) const
formats the General section of the file
FOOTPRINT * ImportFootprint(const wxString &aFootprintPath, wxString &aFootprintNameOut, const STRING_UTF8_MAP *aProperties=nullptr) override
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut.
void Format(const BOARD_ITEM *aItem, int aNestLevel=0) const
Output aItem to aFormatter in s-expression format.
void SetQueryUserCallback(std::function< bool(wxString aTitle, int aIcon, wxString aMessage, wxString aOKButtonTitle)> aCallback) override
BOARD * DoLoad(LINE_READER &aReader, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties, PROGRESS_REPORTER *aProgressReporter, unsigned aLineCount)
bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
Check for the existence of a footprint.
wxString m_filename
for saves only, name is in m_reader for loads
void format(const BOARD *aBoard, int aNestLevel=0) const
std::function< bool(wxString aTitle, int aIcon, wxString aMsg, wxString aAction)> m_queryUserCallback
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
Returns board file description for the PCB_IO.
BOARD_ITEM * Parse(const wxString &aClipboardSourceInput)
void formatBoardLayers(const BOARD *aBoard, int aNestLevel=0) const
formats the board layer information
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
Delete aFootprintName from the library at aLibraryPath.
STRING_FORMATTER m_sf
void formatTeardropParameters(const TEARDROP_PARAMETERS &tdParams, int aNestLevel=0) const
void formatLayer(PCB_LAYER_ID aLayer, bool aIsKnockout=false) const
void SetOutputFormatter(OUTPUTFORMATTER *aFormatter)
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
std::string GetStringOutput(bool doClear)
LINE_READER * m_reader
no ownership
wxString m_error
for throwing exceptions
void CreateLibrary(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Create a new empty library at aLibraryPath empty.
bool DeleteLibrary(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Delete an existing library and returns true, or if library does not exist returns false,...
A base class that BOARD loading and saving plugins should derive from.
Definition: pcb_io.h:72
Object to handle a bitmap image that can be inserted in a PCB.
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
Definition: project.h:62
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:433
const std::string & GetString()
Definition: richio.h:456
void Clear()
Clear the buffer and empties the internal string.
Definition: richio.h:446
A name/value tuple with unique names and optional values.
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
A wrapper around a wxFileName which is much more performant with a subset of the API.
Definition: wx_filename.h:50
void SetPath(const wxString &aPath)
Definition: wx_filename.cpp:40
Handle a list of polygons defining a copper zone.
Definition: zone.h:72
#define _HKI(x)
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
#define CTL_FOR_BOARD
The zero arg constructor when PCB_PLUGIN is used for PLUGIN::Load() and PLUGIN::Save()ing a BOARD fil...
boost::ptr_map< wxString, FP_CACHE_ITEM > FP_CACHE_FOOTPRINT_MAP
Container that describes file type info.
Definition: io_base.h:39