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 The 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#include <ctl_flags.h>
31
32#include <richio.h>
33#include <string>
34#include <optional>
35#include <layer_ids.h>
36#include <zone_settings.h>
37#include <lset.h>
38#include <boost/ptr_container/ptr_map.hpp>
39#include <wx_filename.h>
41
42class BOARD;
43class BOARD_ITEM;
44class FP_CACHE;
45class LSET;
47class NETINFO_MAPPING;
50class PCB_POINT;
52class PCB_SHAPE;
53class PCB_TARGET;
54class PAD;
55class PADSTACK;
56class PCB_GROUP;
57class PCB_GENERATOR;
58class PCB_TRACK;
59class ZONE;
60class PCB_TEXT;
61class PCB_TEXTBOX;
62class PCB_TABLE;
63class EDA_TEXT;
66class PCB_IO_KICAD_SEXPR; // forward decl
67
68// clang-format off
70
71//#define SEXPR_BOARD_FILE_VERSION 3 // first s-expression format, used legacy cu stack
72//#define SEXPR_BOARD_FILE_VERSION 4 // reversed cu stack, changed Inner* to In* in reverse order
73// // went to 32 Cu layers from 16.
74//----------------- Start of 5.0 development -----------------
75//#define SEXPR_BOARD_FILE_VERSION 20160815 // differential pair settings per net class
76//#define SEXPR_BOARD_FILE_VERSION 20170123 // EDA_TEXT refactor, moved 'hide'
77//#define SEXPR_BOARD_FILE_VERSION 20170920 // long pad names and custom pad shape
78//#define SEXPR_BOARD_FILE_VERSION 20170922 // Keepout zones can exist on multiple layers
79//#define SEXPR_BOARD_FILE_VERSION 20171114 // Save 3D model offset in mm, instead of inches
80//#define SEXPR_BOARD_FILE_VERSION 20171125 // Locked/unlocked FP_TEXT
81//#define SEXPR_BOARD_FILE_VERSION 20171130 // 3D model offset written using "offset" parameter
82//----------------- Start of 6.0 development -----------------
83//#define SEXPR_BOARD_FILE_VERSION 20190331 // hatched zones and chamfered round rect pads
84//#define SEXPR_BOARD_FILE_VERSION 20190421 // curves in custom pads
85//#define SEXPR_BOARD_FILE_VERSION 20190516 // Remove segment count from zones
86//#define SEXPR_BOARD_FILE_VERSION 20190605 // Add layer defaults
87//#define SEXPR_BOARD_FILE_VERSION 20190905 // Add board physical stackup info in setup section
88//#define SEXPR_BOARD_FILE_VERSION 20190907 // Keepout areas in footprints
89//#define SEXPR_BOARD_FILE_VERSION 20191123 // pin function in pads
90//#define SEXPR_BOARD_FILE_VERSION 20200104 // pad property for fabrication
91//#define SEXPR_BOARD_FILE_VERSION 20200119 // arcs in tracks
92//#define SEXPR_BOARD_FILE_VERSION 20200512 // page -> paper
93//#define SEXPR_BOARD_FILE_VERSION 20200518 // save hole_to_hole_min
94//#define SEXPR_BOARD_FILE_VERSION 20200614 // Add support for fp_rects and gr_rects
95//#define SEXPR_BOARD_FILE_VERSION 20200625 // Multilayer zones, zone names, island controls
96//#define SEXPR_BOARD_FILE_VERSION 20200628 // remove visibility settings
97//#define SEXPR_BOARD_FILE_VERSION 20200724 // Add KIID to footprints
98//#define SEXPR_BOARD_FILE_VERSION 20200807 // Add zone hatch advanced settings
99//#define SEXPR_BOARD_FILE_VERSION 20200808 // Add properties to footprints
100//#define SEXPR_BOARD_FILE_VERSION 20200809 // Add REMOVE_UNUSED_LAYERS option to vias and THT pads
101//#define SEXPR_BOARD_FILE_VERSION 20200811 // Add groups
102//#define SEXPR_BOARD_FILE_VERSION 20200818 // Remove Status flag bitmap and setup counts
103//#define SEXPR_BOARD_FILE_VERSION 20200819 // Add board-level properties
104//#define SEXPR_BOARD_FILE_VERSION 20200825 // Remove host information
105//#define SEXPR_BOARD_FILE_VERSION 20200828 // Add new fabrication attributes
106//#define SEXPR_BOARD_FILE_VERSION 20200829 // Remove library name from exported footprints
107//#define SEXPR_BOARD_FILE_VERSION 20200909 // Change DIMENSION format
108//#define SEXPR_BOARD_FILE_VERSION 20200913 // Add leader dimension
109//#define SEXPR_BOARD_FILE_VERSION 20200916 // Add center dimension
110//#define SEXPR_BOARD_FILE_VERSION 20200921 // Add orthogonal dimension
111//#define SEXPR_BOARD_FILE_VERSION 20200922 // Add user name to layer definition.
112//#define SEXPR_BOARD_FILE_VERSION 20201002 // Add groups in footprints (for footprint editor).
113//#define SEXPR_BOARD_FILE_VERSION 20201114 // Add first-class support for filled shapes.
114//#define SEXPR_BOARD_FILE_VERSION 20201115 // module -> footprint and change fill syntax.
115//#define SEXPR_BOARD_FILE_VERSION 20201116 // Write version and generator string in footprint files.
116//#define SEXPR_BOARD_FILE_VERSION 20201220 // Add free via token
117//#define SEXPR_BOARD_FILE_VERSION 20210108 // Pad locking moved from footprint to pads
118//#define SEXPR_BOARD_FILE_VERSION 20210126 // Store pintype alongside pinfunction (in pads).
119//#define SEXPR_BOARD_FILE_VERSION 20210228 // Move global margins back to board file
120//#define SEXPR_BOARD_FILE_VERSION 20210424 // Correct locked flag syntax (remove parens).
121//#define SEXPR_BOARD_FILE_VERSION 20210606 // Change overbar syntax from `~...~` to `~{...}`.
122//#define SEXPR_BOARD_FILE_VERSION 20210623 // Add support for reading/writing arcs in polygons
123//#define SEXPR_BOARD_FILE_VERSION 20210722 // Reading/writing group locked flags
124//#define SEXPR_BOARD_FILE_VERSION 20210824 // Opacity in 3D colors
125//#define SEXPR_BOARD_FILE_VERSION 20210925 // Locked flag for fp_text
126//#define SEXPR_BOARD_FILE_VERSION 20211014 // Arc formatting
127//----------------- Start of 7.0 development -----------------
128//#define SEXPR_BOARD_FILE_VERSION 20211226 // Add radial dimension
129//#define SEXPR_BOARD_FILE_VERSION 20211227 // Add thermal relief spoke angle overrides
130//#define SEXPR_BOARD_FILE_VERSION 20211228 // Add allow_soldermask_bridges footprint attribute
131//#define SEXPR_BOARD_FILE_VERSION 20211229 // Stroke formatting
132//#define SEXPR_BOARD_FILE_VERSION 20211230 // Dimensions in footprints
133//#define SEXPR_BOARD_FILE_VERSION 20211231 // Private footprint layers
134//#define SEXPR_BOARD_FILE_VERSION 20211232 // Fonts
135//#define SEXPR_BOARD_FILE_VERSION 20220131 // Textboxes
136//#define SEXPR_BOARD_FILE_VERSION 20220211 // End support for V5 zone fill strategy
137//#define SEXPR_BOARD_FILE_VERSION 20220225 // Remove TEDIT
138//#define SEXPR_BOARD_FILE_VERSION 20220308 // Knockout text and Locked graphic text property saved
139//#define SEXPR_BOARD_FILE_VERSION 20220331 // Plot on all layers selection setting
140//#define SEXPR_BOARD_FILE_VERSION 20220417 // Automatic dimension precisions
141//#define SEXPR_BOARD_FILE_VERSION 20220427 // Exclude Edge.Cuts & Margin from fp private layers
142//#define SEXPR_BOARD_FILE_VERSION 20220609 // Add teardrop keywords to identify teardrop zones
143//#define SEXPR_BOARD_FILE_VERSION 20220621 // Add Image support
144//#define SEXPR_BOARD_FILE_VERSION 20220815 // Add allow-soldermask-bridges-in-FPs flag
145//#define SEXPR_BOARD_FILE_VERSION 20220818 // First-class storage for net-ties
146//#define SEXPR_BOARD_FILE_VERSION 20220914 // Number boxes for custom-shape pads
147//#define SEXPR_BOARD_FILE_VERSION 20221018 // Via & pad zone-layer-connections
148//----------------- Start of 8.0 development -----------------
149//#define SEXPR_BOARD_FILE_VERSION 20230410 // DNP attribute propagated from schematic to attr
150//#define SEXPR_BOARD_FILE_VERSION 20230517 // Teardrop parameters for pads and vias
151//#define SEXPR_BOARD_FILE_VERSION 20230620 // PCB Fields
152//#define SEXPR_BOARD_FILE_VERSION 20230730 // Connectivity for graphic shapes
153//#define SEXPR_BOARD_FILE_VERSION 20230825 // Textbox explicit border flag
154//#define SEXPR_BOARD_FILE_VERSION 20230906 // Multiple image type support in files
155//#define SEXPR_BOARD_FILE_VERSION 20230913 // Custom-shaped-pad spoke templates
156//#define SEXPR_BOARD_FILE_VERSION 20231007 // Generative objects
157//#define SEXPR_BOARD_FILE_VERSION 20231014 // V8 file format normalization
158//#define SEXPR_BOARD_FILE_VERSION 20231212 // Reference image locking/UUIDs, footprint boolean format
159//#define SEXPR_BOARD_FILE_VERSION 20231231 // Use 'uuid' rather than 'id' for generators and groups
160//#define SEXPR_BOARD_FILE_VERSION 20240108 // Convert teardrop parameters to explicit bools
161//----------------- Start of 9.0 development -----------------
162//#define SEXPR_BOARD_FILE_VERSION 20240201 // Use nullable properties for overrides
163//#define SEXPR_BOARD_FILE_VERSION 20240202 // Tables
164//#define SEXPR_BOARD_FILE_VERSION 20240225 // Rationalization of solder_paste_margin
165//#define SEXPR_BOARD_FILE_VERSION 20240609 // Add 'tenting' keyword
166//#define SEXPR_BOARD_FILE_VERSION 20240617 // Table angles
167//#define SEXPR_BOARD_FILE_VERSION 20240703 // User layer types
168//#define SEXPR_BOARD_FILE_VERSION 20240706 // Embedded Files
169//#define SEXPR_BOARD_FILE_VERSION 20240819 // Embedded Files - Update hash algorithm to Murmur3
170//#define SEXPR_BOARD_FILE_VERSION 20240928 // Component classes
171//#define SEXPR_BOARD_FILE_VERSION 20240929 // Complex padstacks
172//#define SEXPR_BOARD_FILE_VERSION 20241006 // Via stacks
173//#define SEXPR_BOARD_FILE_VERSION 20241007 // Tracks can have soldermask layer and margin
174//#define SEXPR_BOARD_FILE_VERSION 20241009 // Evolve placement rule areas file format
175//#define SEXPR_BOARD_FILE_VERSION 20241010 // Graphic shapes can have soldermask layer and margin
176//#define SEXPR_BOARD_FILE_VERSION 20241030 // Dimension arrow directions, suppress_zeroes normalization
177//#define SEXPR_BOARD_FILE_VERSION 20241129 // Normalise keep_text_aligned and fill properties
178//#define SEXPR_BOARD_FILE_VERSION 20241228 // Convert teardrop curve points to bool
179//#define SEXPR_BOARD_FILE_VERSION 20241229 // Expand User layers to arbitrary count
180//----------------- Start of 10.0 development -----------------
181//#define SEXPR_BOARD_FILE_VERSION 20250210 // Knockout for textboxes
182//#define SEXPR_BOARD_FILE_VERSION 20250222 // Hatching for PCB shapes
183//#define SEXPR_BOARD_FILE_VERSION 20250228 // ipc-4761 via protection features
184//#define SEXPR_BOARD_FILE_VERSION 20250302 // Zone Hatching Offsets
185//#define SEXPR_BOARD_FILE_VERSION 20250309 // Component class dynamic assignment rules
186//#define SEXPR_BOARD_FILE_VERSION 20250324 // Jumper pads
187//#define SEXPR_BOARD_FILE_VERSION 20250401 // Time domain length tuning
188//#define SEXPR_BOARD_FILE_VERSION 20250513 // Groups can have design block lib_id
189//#define SEXPR_BOARD_FILE_VERSION 20250801 // (island) -> (island yes/no)
190//#define SEXPR_BOARD_FILE_VERSION 20250811 // press-fit pad fabr prop support
191//#define SEXPR_BOARD_FILE_VERSION 20250818 // Support for custom layer counts in footprints
192//#define SEXPR_BOARD_FILE_VERSION 20250829 // Support Rounded Rectangles
193//#define SEXPR_BOARD_FILE_VERSION 20250901 // PCB points
194#define SEXPR_BOARD_FILE_VERSION 20250907 // uuids for tables
195
196#define BOARD_FILE_HOST_VERSION 20200825
197#define LEGACY_ARC_FORMATTING 20210925
198#define LEGACY_NET_TIES 20220815
200#define FIRST_NORMALIZED_VERISON 20230924
201// clang-format on
202
203// common combinations of the above:
204
206#define CTL_FOR_CLIPBOARD (CTL_OMIT_INITIAL_COMMENTS) // (CTL_OMIT_NETS)
207
209#define CTL_FOR_LIBRARY \
210 ( CTL_OMIT_PAD_NETS | CTL_OMIT_UUIDS | CTL_OMIT_PATH | CTL_OMIT_AT | CTL_OMIT_LIBNAME )
211
214#define CTL_FOR_BOARD (CTL_OMIT_INITIAL_COMMENTS|CTL_OMIT_FOOTPRINT_VERSION)
215
225{
227 std::unique_ptr<FOOTPRINT> m_footprint;
228
229public:
230 FP_CACHE_ENTRY( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName );
231
232 const WX_FILENAME& GetFileName() const { return m_filename; }
233 void SetFilePath( const wxString& aFilePath ) { m_filename.SetPath( aFilePath ); }
234 std::unique_ptr<FOOTPRINT>& GetFootprint() { return m_footprint; }
235};
236
238{
239 PCB_IO_KICAD_SEXPR* m_owner; // Plugin object that owns the cache.
240 wxFileName m_lib_path; // The path of the library.
241 wxString m_lib_raw_path; // For quick comparisons.
242
243 boost::ptr_map<wxString, FP_CACHE_ENTRY> m_footprints; // Map of footprint filename to
244 // cache entry.
245
246 bool m_cache_dirty; // Stored separately because it's expensive to check
247 // m_cache_timestamp against all the files.
248 long long m_cache_timestamp; // A hash of the timestamps for all the footprint
249 // files.
250
251public:
252 FP_CACHE( PCB_IO_KICAD_SEXPR* aOwner, const wxString& aLibraryPath );
253
254 wxString GetPath() const { return m_lib_raw_path; }
255
256 bool IsWritable() const { return m_lib_path.IsOk() && m_lib_path.IsDirWritable(); }
257
258 bool Exists() const { return m_lib_path.IsOk() && m_lib_path.DirExists(); }
259
260 boost::ptr_map<wxString, FP_CACHE_ENTRY>& GetFootprints() { return m_footprints; }
261
262 // Most all functions in this class throw IO_ERROR exceptions. There are no
263 // error codes nor user interface calls from here, nor in any PLUGIN.
264 // Catch these exceptions higher up please.
265
271 void Save( FOOTPRINT* aFootprintFilter = nullptr );
272
273 void Load();
274
275 void Remove( const wxString& aFootprintName );
276
282 static long long GetTimestamp( const wxString& aLibPath );
283
287 bool IsModified();
288
300 bool IsPath( const wxString& aPath ) const;
301
302 void SetPath( const wxString& aPath );
303};
304
305
312{
313public:
315 {
316 // Would have used wildcards_and_files_ext.cpp's KiCadPcbFileExtension,
317 // but to be pure, a plugin should not assume that it will always be linked
318 // with the core of the Pcbnew code. (Might someday be a DLL/DSO.) Besides,
319 // file extension policy should be controlled by the plugin.
320 return IO_BASE::IO_FILE_DESC( _HKI( "KiCad printed circuit board files" ), { "kicad_pcb" } );
321 }
322
324 {
325 return IO_BASE::IO_FILE_DESC( _HKI( "KiCad footprint file" ), { "kicad_mod" } );
326 }
327
329 {
330 return IO_BASE::IO_FILE_DESC( _HKI( "KiCad footprint files" ), {}, { "kicad_mod" }, false );
331 }
332
333 void SetQueryUserCallback( std::function<bool( wxString aTitle, int aIcon, wxString aMessage,
334 wxString aOKButtonTitle )> aCallback ) override
335 {
336 m_queryUserCallback = std::move( aCallback );
337 }
338
339 bool CanReadBoard( const wxString& aFileName ) const override;
340
341 void SaveBoard( const wxString& aFileName, BOARD* aBoard,
342 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
343
344 BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
345 const std::map<std::string, UTF8>* aProperties = nullptr,
346 PROJECT* aProject = nullptr ) override;
347
348 BOARD* DoLoad( LINE_READER& aReader, BOARD* aAppendToMe, const std::map<std::string,
349 UTF8>* aProperties, PROGRESS_REPORTER* aProgressReporter, unsigned aLineCount );
350
351 void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
352 bool aBestEfforts, const std::map<std::string,
353 UTF8>* aProperties = nullptr ) override;
354
355 const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath,
356 const wxString& aFootprintName,
357 const std::map<std::string,
358 UTF8>* aProperties = nullptr ) override;
359
360 bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
361 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
362
363 FOOTPRINT* ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
364 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
365
366 FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
367 bool aKeepUUID = false,
368 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
369
370 void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
371 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
372
373 void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
374 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
375
376 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
377
378 void CreateLibrary( const wxString& aLibraryPath,
379 const std::map<std::string, UTF8>* aProperties = nullptr) override;
380
381 bool DeleteLibrary( const wxString& aLibraryPath,
382 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
383
384 bool IsLibraryWritable( const wxString& aLibraryPath ) override;
385
386 PCB_IO_KICAD_SEXPR( int aControlFlags = CTL_FOR_BOARD );
387
388 virtual ~PCB_IO_KICAD_SEXPR();
389
396 void Format( const BOARD_ITEM* aItem ) const;
397
398 std::string GetStringOutput( bool doClear )
399 {
400 std::string ret = m_sf.GetString();
401
402 if( doClear )
403 m_sf.Clear();
404
405 return ret;
406 }
407
408 void SetOutputFormatter( OUTPUTFORMATTER* aFormatter ) { m_out = aFormatter; }
409
410 BOARD_ITEM* Parse( const wxString& aClipboardSourceInput );
411
412protected:
413 void validateCache( const wxString& aLibraryPath, bool checkModified = true );
414
415 const FOOTPRINT* getFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
416 const std::map<std::string, UTF8>* aProperties,
417 bool checkModified );
418
419 void init( const std::map<std::string, UTF8>* aProperties );
420
422 void formatSetup( const BOARD* aBoard ) const;
423
425 void formatGeneral( const BOARD* aBoard ) const;
426
428 void formatBoardLayers( const BOARD* aBoard ) const;
429
431 void formatNetInformation( const BOARD* aBoard ) const;
432
434 void formatProperties( const BOARD* aBoard ) const;
435
437 void formatHeader( const BOARD* aBoard ) const;
438
439 void formatTeardropParameters( const TEARDROP_PARAMETERS& tdParams ) const;
440
441private:
442 void format( const BOARD* aBoard ) const;
443
444 void format( const PCB_DIMENSION_BASE* aDimension ) const;
445
446 void format( const PCB_REFERENCE_IMAGE* aBitmap ) const;
447
448 void format( const PCB_GROUP* aGroup ) const;
449
450 void format( const PCB_SHAPE* aSegment ) const;
451
452 void format( const PCB_TARGET* aTarget ) const;
453 void format( const PCB_POINT* aPoint ) const;
454
455 void format( const FOOTPRINT* aFootprint ) const;
456
457 void format( const PAD* aPad ) const;
458
459 void format( const PCB_TEXT* aText ) const;
460 void format( const PCB_TEXTBOX* aTextBox ) const;
461
462 void format( const PCB_TABLE* aTable ) const;
463
464 void format( const PCB_GENERATOR* aGenerator ) const;
465
466 void format( const PCB_TRACK* aTrack ) const;
467
468 void format( const ZONE* aZone ) const;
469
470 void format( const ZONE_LAYER_PROPERTIES& aZoneLayerProperties, int aNestLevel,
471 PCB_LAYER_ID aLayer ) const;
472
473 void formatPolyPts( const SHAPE_LINE_CHAIN& outline,
474 const FOOTPRINT* aParentFP = nullptr ) const;
475
476 void formatRenderCache( const EDA_TEXT* aText ) const;
477
478 void formatLayer( PCB_LAYER_ID aLayer, bool aIsKnockout = false ) const;
479
480 void formatLayers( LSET aLayerMask, bool aEnumerateLayers, bool aIsZone = false ) const;
481
482 friend class FP_CACHE;
483
484protected:
485 wxString m_error;
486
488
490 wxString m_filename;
491
494 int m_ctl;
497
498 std::function<bool( wxString aTitle, int aIcon, wxString aMsg, wxString aAction )> m_queryUserCallback;
499};
500
501#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:79
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:317
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:79
std::unique_ptr< FOOTPRINT > m_footprint
WX_FILENAME m_filename
void SetFilePath(const wxString &aFilePath)
FP_CACHE_ENTRY(FOOTPRINT *aFootprint, const WX_FILENAME &aFileName)
const WX_FILENAME & GetFileName() const
std::unique_ptr< FOOTPRINT > & GetFootprint()
static long long GetTimestamp(const wxString &aLibPath)
Generate a timestamp representing all source files in the cache (including the parent directory).
bool Exists() const
boost::ptr_map< wxString, FP_CACHE_ENTRY > m_footprints
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.
void Save(FOOTPRINT *aFootprintFilter=nullptr)
Save the footprint cache or a single footprint from it to disk.
FP_CACHE(PCB_IO_KICAD_SEXPR *aOwner, const wxString &aLibraryPath)
bool IsWritable() const
boost::ptr_map< wxString, FP_CACHE_ENTRY > & GetFootprints()
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 lset.h:37
An interface used to output 8 bit text in a convenient way.
Definition richio.h:322
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
Definition padstack.h:125
Definition pad.h:54
Abstract dimension API.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:53
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.
BOARD * DoLoad(LINE_READER &aReader, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties, PROGRESS_REPORTER *aProgressReporter, unsigned aLineCount)
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override
Get the descriptor for the library container that this IO plugin operates on.
void formatProperties(const BOARD *aBoard) const
formats the Nets and Netclasses
FOOTPRINT * ImportFootprint(const wxString &aFootprintPath, wxString &aFootprintNameOut, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut.
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Delete aFootprintName from the library at aLibraryPath.
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 formatTeardropParameters(const TEARDROP_PARAMETERS &tdParams) const
bool DeleteLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Delete an existing library and returns true, or if library does not exist returns false,...
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
void formatNetInformation(const BOARD *aBoard) const
formats the Nets and Netclasses
const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
void CreateLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Create a new empty library at aLibraryPath empty.
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
void formatPolyPts(const SHAPE_LINE_CHAIN &outline, const FOOTPRINT *aParentFP=nullptr) const
const IO_BASE::IO_FILE_DESC GetLibraryFileDesc() const override
Get the descriptor for the individual library elements that this IO plugin operates on.
FP_CACHE * m_cache
Footprint library cache.
void formatBoardLayers(const BOARD *aBoard) const
formats the board layer information
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PC...
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Check for the existence of a footprint.
void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aFootprint to an existing library located at aLibraryPath.
void format(const BOARD *aBoard) const
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...
void formatLayers(LSET aLayerMask, bool aEnumerateLayers, bool aIsZone=false) const
void formatGeneral(const BOARD *aBoard) const
formats the General section of the file
void SetQueryUserCallback(std::function< bool(wxString aTitle, int aIcon, wxString aMessage, wxString aOKButtonTitle)> aCallback) override
void formatSetup(const BOARD *aBoard) const
formats the board setup information
wxString m_filename
for saves only, name is in m_reader for loads
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 init(const std::map< std::string, UTF8 > *aProperties)
STRING_FORMATTER m_sf
void Format(const BOARD_ITEM *aItem) const
Output aItem to aFormatter in s-expression format.
void formatLayer(PCB_LAYER_ID aLayer, bool aIsKnockout=false) const
void formatHeader(const BOARD *aBoard) const
writes everything that comes before the board_items, like settings and layers etc
const FOOTPRINT * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties, bool checkModified)
void SetOutputFormatter(OUTPUTFORMATTER *aFormatter)
PCB_IO_KICAD_SEXPR(int aControlFlags=CTL_FOR_BOARD)
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
std::string GetStringOutput(bool doClear)
void formatRenderCache(const EDA_TEXT *aText) const
LINE_READER * m_reader
no ownership
wxString m_error
for throwing exceptions
PCB_IO(const wxString &aName)
Definition pcb_io.h:318
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
Definition pcb_point.h:43
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:65
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:449
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition utf8.h:72
A wrapper around a wxFileName which is much more performant with a subset of the API.
Definition wx_filename.h:50
Handle a list of polygons defining a copper zone.
Definition zone.h:74
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
#define _HKI(x)
Definition page_info.cpp:44
#define CTL_FOR_BOARD
The zero arg constructor when PCB_PLUGIN is used for PLUGIN::Load() and PLUGIN::Save()ing a BOARD fil...
Container that describes file type info.
Definition io_base.h:43
Class ZONE_SETTINGS used to handle zones parameters in dialogs.