KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_plugin.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-2023 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_PLUGIN_H
26#define PCB_PLUGIN_H
27
28#include <io_mgr.h>
29#include <richio.h>
30#include <string>
31#include <layer_ids.h>
32#include <boost/ptr_container/ptr_map.hpp>
33#include <wx_filename.h>
35
36class BOARD;
37class BOARD_ITEM;
38class FP_CACHE;
39class PCB_PARSER;
40class NETINFO_MAPPING;
43class PCB_SHAPE;
44class PCB_BITMAP;
45class PCB_TARGET;
46class PAD;
47class PCB_GROUP;
48class PCB_TRACK;
49class ZONE;
50class PCB_TEXT;
51class PCB_TEXTBOX;
52class EDA_TEXT;
55class PCB_PLUGIN; // forward decl
56
58
59//#define SEXPR_BOARD_FILE_VERSION 3 // first s-expression format, used legacy cu stack
60//#define SEXPR_BOARD_FILE_VERSION 4 // reversed cu stack, changed Inner* to In* in reverse order
61// // went to 32 Cu layers from 16.
62//----------------- Start of 5.0 development -----------------
63//#define SEXPR_BOARD_FILE_VERSION 20160815 // differential pair settings per net class
64//#define SEXPR_BOARD_FILE_VERSION 20170123 // EDA_TEXT refactor, moved 'hide'
65//#define SEXPR_BOARD_FILE_VERSION 20170920 // long pad names and custom pad shape
66//#define SEXPR_BOARD_FILE_VERSION 20170922 // Keepout zones can exist on multiple layers
67//#define SEXPR_BOARD_FILE_VERSION 20171114 // Save 3D model offset in mm, instead of inches
68//#define SEXPR_BOARD_FILE_VERSION 20171125 // Locked/unlocked FP_TEXT
69//#define SEXPR_BOARD_FILE_VERSION 20171130 // 3D model offset written using "offset" parameter
70//----------------- Start of 6.0 development -----------------
71//#define SEXPR_BOARD_FILE_VERSION 20190331 // hatched zones and chamfered round rect pads
72//#define SEXPR_BOARD_FILE_VERSION 20190421 // curves in custom pads
73//#define SEXPR_BOARD_FILE_VERSION 20190516 // Remove segment count from zones
74//#define SEXPR_BOARD_FILE_VERSION 20190605 // Add layer defaults
75//#define SEXPR_BOARD_FILE_VERSION 20190905 // Add board physical stackup info in setup section
76//#define SEXPR_BOARD_FILE_VERSION 20190907 // Keepout areas in footprints
77//#define SEXPR_BOARD_FILE_VERSION 20191123 // pin function in pads
78//#define SEXPR_BOARD_FILE_VERSION 20200104 // pad property for fabrication
79//#define SEXPR_BOARD_FILE_VERSION 20200119 // arcs in tracks
80//#define SEXPR_BOARD_FILE_VERSION 20200512 // page -> paper
81//#define SEXPR_BOARD_FILE_VERSION 20200518 // save hole_to_hole_min
82//#define SEXPR_BOARD_FILE_VERSION 20200614 // Add support for fp_rects and gr_rects
83//#define SEXPR_BOARD_FILE_VERSION 20200625 // Multilayer zones, zone names, island controls
84//#define SEXPR_BOARD_FILE_VERSION 20200628 // remove visibility settings
85//#define SEXPR_BOARD_FILE_VERSION 20200724 // Add KIID to footprints
86//#define SEXPR_BOARD_FILE_VERSION 20200807 // Add zone hatch advanced settings
87//#define SEXPR_BOARD_FILE_VERSION 20200808 // Add properties to footprints
88//#define SEXPR_BOARD_FILE_VERSION 20200809 // Add REMOVE_UNUSED_LAYERS option to vias and THT pads
89//#define SEXPR_BOARD_FILE_VERSION 20200811 // Add groups
90//#define SEXPR_BOARD_FILE_VERSION 20200818 // Remove Status flag bitmap and setup counts
91//#define SEXPR_BOARD_FILE_VERSION 20200819 // Add board-level properties
92//#define SEXPR_BOARD_FILE_VERSION 20200825 // Remove host information
93//#define SEXPR_BOARD_FILE_VERSION 20200828 // Add new fabrication attributes
94//#define SEXPR_BOARD_FILE_VERSION 20200829 // Remove library name from exported footprints
95//#define SEXPR_BOARD_FILE_VERSION 20200909 // Change DIMENSION format
96//#define SEXPR_BOARD_FILE_VERSION 20200913 // Add leader dimension
97//#define SEXPR_BOARD_FILE_VERSION 20200916 // Add center dimension
98//#define SEXPR_BOARD_FILE_VERSION 20200921 // Add orthogonal dimension
99//#define SEXPR_BOARD_FILE_VERSION 20200922 // Add user name to layer definition.
100//#define SEXPR_BOARD_FILE_VERSION 20201002 // Add groups in footprints (for footprint editor).
101//#define SEXPR_BOARD_FILE_VERSION 20201114 // Add first-class support for filled shapes.
102//#define SEXPR_BOARD_FILE_VERSION 20201115 // module -> footprint and change fill syntax.
103//#define SEXPR_BOARD_FILE_VERSION 20201116 // Write version and generator string in footprint files.
104//#define SEXPR_BOARD_FILE_VERSION 20201220 // Add free via token
105//#define SEXPR_BOARD_FILE_VERSION 20210108 // Pad locking moved from footprint to pads
106//#define SEXPR_BOARD_FILE_VERSION 20210126 // Store pintype alongside pinfunction (in pads).
107//#define SEXPR_BOARD_FILE_VERSION 20210228 // Move global margins back to board file
108//#define SEXPR_BOARD_FILE_VERSION 20210424 // Correct locked flag syntax (remove parens).
109//#define SEXPR_BOARD_FILE_VERSION 20210606 // Change overbar syntax from `~...~` to `~{...}`.
110//#define SEXPR_BOARD_FILE_VERSION 20210623 // Add support for reading/writing arcs in polygons
111//#define SEXPR_BOARD_FILE_VERSION 20210722 // Reading/writing group locked flags
112//#define SEXPR_BOARD_FILE_VERSION 20210824 // Opacity in 3D colors
113//#define SEXPR_BOARD_FILE_VERSION 20210925 // Locked flag for fp_text
114//#define SEXPR_BOARD_FILE_VERSION 20211014 // Arc formatting
115//----------------- Start of 7.0 development -----------------
116//#define SEXPR_BOARD_FILE_VERSION 20211226 // Add radial dimension
117//#define SEXPR_BOARD_FILE_VERSION 20211227 // Add thermal relief spoke angle overrides
118//#define SEXPR_BOARD_FILE_VERSION 20211228 // Add allow_soldermask_bridges footprint attribute
119//#define SEXPR_BOARD_FILE_VERSION 20211229 // Stroke formatting
120//#define SEXPR_BOARD_FILE_VERSION 20211230 // Dimensions in footprints
121//#define SEXPR_BOARD_FILE_VERSION 20211231 // Private footprint layers
122//#define SEXPR_BOARD_FILE_VERSION 20211232 // Fonts
123//#define SEXPR_BOARD_FILE_VERSION 20220131 // Textboxes
124//#define SEXPR_BOARD_FILE_VERSION 20220211 // End support for V5 zone fill strategy
125//#define SEXPR_BOARD_FILE_VERSION 20220225 // Remove TEDIT
126//#define SEXPR_BOARD_FILE_VERSION 20220308 // Knockout text and Locked graphic text property saved
127//#define SEXPR_BOARD_FILE_VERSION 20220331 // Plot on all layers selection setting
128//#define SEXPR_BOARD_FILE_VERSION 20220417 // Automatic dimension precisions
129//#define SEXPR_BOARD_FILE_VERSION 20220427 // Exclude Edge.Cuts & Margin from fp private layers
130//#define SEXPR_BOARD_FILE_VERSION 20220609 // Add teardrop keywords to identify teardrop zones
131//#define SEXPR_BOARD_FILE_VERSION 20220621 // Add Image support
132//#define SEXPR_BOARD_FILE_VERSION 20220815 // Add allow-soldermask-bridges-in-FPs flag
133//#define SEXPR_BOARD_FILE_VERSION 20220818 // First-class storage for net-ties
134//#define SEXPR_BOARD_FILE_VERSION 20220914 // Number boxes for custom-shape pads
135//#define SEXPR_BOARD_FILE_VERSION 20221018 // Via & pad zone-layer-connections
136//----------------- Start of 8.0 development -----------------
137//#define SEXPR_BOARD_FILE_VERSION 20230410 // DNP attribute propagated from schematic to attr
138//#define SEXPR_BOARD_FILE_VERSION 20230517 // Teardrop parameters for pads and vias
139//#define SEXPR_BOARD_FILE_VERSION 20230620 // PCB Fields
140//#define SEXPR_BOARD_FILE_VERSION 20230730 // Connectivity for graphic shapes
141//#define SEXPR_BOARD_FILE_VERSION 20230825 // Textbox explicit border flag
142//#define SEXPR_BOARD_FILE_VERSION 20230906 // Multiple image type support in files
143#define SEXPR_BOARD_FILE_VERSION 20230913 // Custom-shaped-pad spoke templates
144
145#define BOARD_FILE_HOST_VERSION 20200825
146#define LEGACY_ARC_FORMATTING 20210925
147#define LEGACY_NET_TIES 20220815
149
150#define CTL_OMIT_PAD_NETS (1 << 1)
151#define CTL_OMIT_TSTAMPS (1 << 2)
152#define CTL_OMIT_INITIAL_COMMENTS (1 << 3)
153#define CTL_OMIT_PATH (1 << 4)
154#define CTL_OMIT_AT (1 << 5)
156//#define CTL_OMIT_HIDE (1 << 6) // found and defined in eda_text.h
157#define CTL_OMIT_LIBNAME (1 << 7)
159#define CTL_OMIT_FOOTPRINT_VERSION (1 << 8)
161
162// common combinations of the above:
163
165#define CTL_FOR_CLIPBOARD (CTL_OMIT_INITIAL_COMMENTS) // (CTL_OMIT_NETS)
166
168#define CTL_FOR_LIBRARY \
169 ( CTL_OMIT_PAD_NETS | CTL_OMIT_TSTAMPS | CTL_OMIT_PATH | CTL_OMIT_AT | CTL_OMIT_LIBNAME )
170
173#define CTL_FOR_BOARD (CTL_OMIT_INITIAL_COMMENTS|CTL_OMIT_FOOTPRINT_VERSION)
174
184{
186 std::unique_ptr<FOOTPRINT> m_footprint;
187
188public:
189 FP_CACHE_ITEM( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName );
190
191 const WX_FILENAME& GetFileName() const { return m_filename; }
192 void SetFilePath( const wxString& aFilePath ) { m_filename.SetPath( aFilePath ); }
193 const FOOTPRINT* GetFootprint() const { return m_footprint.get(); }
194};
195
196typedef boost::ptr_map<wxString, FP_CACHE_ITEM> FP_CACHE_FOOTPRINT_MAP;
197
199{
200 PCB_PLUGIN* m_owner; // Plugin object that owns the cache.
201 wxFileName m_lib_path; // The path of the library.
202 wxString m_lib_raw_path; // For quick comparisons.
203 FP_CACHE_FOOTPRINT_MAP m_footprints; // Map of footprint filename to FOOTPRINT*.
204
205 bool m_cache_dirty; // Stored separately because it's expensive to check
206 // m_cache_timestamp against all the files.
207 long long m_cache_timestamp; // A hash of the timestamps for all the footprint
208 // files.
209
210public:
211 FP_CACHE( PCB_PLUGIN* aOwner, const wxString& aLibraryPath );
212
213 wxString GetPath() const { return m_lib_raw_path; }
214
215 bool IsWritable() const { return m_lib_path.IsOk() && m_lib_path.IsDirWritable(); }
216
217 bool Exists() const { return m_lib_path.IsOk() && m_lib_path.DirExists(); }
218
220
221 // Most all functions in this class throw IO_ERROR exceptions. There are no
222 // error codes nor user interface calls from here, nor in any PLUGIN.
223 // Catch these exceptions higher up please.
224
230 void Save( FOOTPRINT* aFootprint = nullptr );
231
232 void Load();
233
234 void Remove( const wxString& aFootprintName );
235
241 static long long GetTimestamp( const wxString& aLibPath );
242
246 bool IsModified();
247
259 bool IsPath( const wxString& aPath ) const;
260
261 void SetPath( const wxString& aPath );
262};
263
264
270class PCB_PLUGIN : public PLUGIN
271{
272public:
273 const wxString PluginName() const override
274 {
275 return wxT( "KiCad" );
276 }
277
279 {
280 // Would have used wildcards_and_files_ext.cpp's KiCadPcbFileExtension,
281 // but to be pure, a plugin should not assume that it will always be linked
282 // with the core of the Pcbnew code. (Might someday be a DLL/DSO.) Besides,
283 // file extension policy should be controlled by the plugin.
284 return PLUGIN_FILE_DESC( _HKI( "KiCad printed circuit board files" ), { "kicad_pcb" } );
285 }
286
288 {
289 return PLUGIN_FILE_DESC( _HKI( "KiCad footprint file" ), { "kicad_mod" } );
290 }
291
293 {
294 return PLUGIN_FILE_DESC( _HKI( "KiCad footprint files" ), {}, { "kicad_mod" }, false );
295 }
296
297 void SetQueryUserCallback( std::function<bool( wxString aTitle, int aIcon, wxString aMessage,
298 wxString aOKButtonTitle )> aCallback ) override
299 {
300 m_queryUserCallback = std::move( aCallback );
301 }
302
303 bool CanReadBoard( const wxString& aFileName ) const override;
304
305 void SaveBoard( const wxString& aFileName, BOARD* aBoard,
306 const STRING_UTF8_MAP* aProperties = nullptr ) override;
307
308 BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
309 const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr,
310 PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
311
312 BOARD* DoLoad( LINE_READER& aReader, BOARD* aAppendToMe, const STRING_UTF8_MAP* aProperties,
313 PROGRESS_REPORTER* aProgressReporter, unsigned aLineCount );
314
315 void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
316 bool aBestEfforts, const STRING_UTF8_MAP* aProperties = nullptr ) override;
317
318 const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath,
319 const wxString& aFootprintName,
320 const STRING_UTF8_MAP* aProperties = nullptr ) override;
321
322 bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
323 const STRING_UTF8_MAP* aProperties = nullptr ) override;
324
325 FOOTPRINT* ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
326 const STRING_UTF8_MAP* aProperties = nullptr ) override;
327
328 FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
329 bool aKeepUUID = false,
330 const STRING_UTF8_MAP* aProperties = nullptr ) override;
331
332 void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
333 const STRING_UTF8_MAP* aProperties = nullptr ) override;
334
335 void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
336 const STRING_UTF8_MAP* aProperties = nullptr ) override;
337
338 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
339
340 void FootprintLibCreate( const wxString& aLibraryPath,
341 const STRING_UTF8_MAP* aProperties = nullptr) override;
342
343 bool FootprintLibDelete( const wxString& aLibraryPath,
344 const STRING_UTF8_MAP* aProperties = nullptr ) override;
345
346 bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
347
348 PCB_PLUGIN( int aControlFlags = CTL_FOR_BOARD );
349
350 virtual ~PCB_PLUGIN();
351
359 void Format( const BOARD_ITEM* aItem, int aNestLevel = 0 ) const;
360
361 std::string GetStringOutput( bool doClear )
362 {
363 std::string ret = m_sf.GetString();
364
365 if( doClear )
366 m_sf.Clear();
367
368 return ret;
369 }
370
371 void SetOutputFormatter( OUTPUTFORMATTER* aFormatter ) { m_out = aFormatter; }
372
373 BOARD_ITEM* Parse( const wxString& aClipboardSourceInput );
374
375protected:
376 void validateCache( const wxString& aLibraryPath, bool checkModified = true );
377
378 const FOOTPRINT* getFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
379 const STRING_UTF8_MAP* aProperties, bool checkModified );
380
381 void init( const STRING_UTF8_MAP* aProperties );
382
384 void formatSetup( const BOARD* aBoard, int aNestLevel = 0 ) const;
385
387 void formatGeneral( const BOARD* aBoard, int aNestLevel = 0 ) const;
388
390 void formatBoardLayers( const BOARD* aBoard, int aNestLevel = 0 ) const;
391
393 void formatNetInformation( const BOARD* aBoard, int aNestLevel = 0 ) const;
394
396 void formatProperties( const BOARD* aBoard, int aNestLevel = 0 ) const;
397
399 void formatHeader( const BOARD* aBoard, int aNestLevel = 0 ) const;
400
401 void formatTeardropParameters( const TEARDROP_PARAMETERS& tdParams, int aNestLevel = 0 ) const;
402
403private:
404 void format( const BOARD* aBoard, int aNestLevel = 0 ) const;
405
406 void format( const PCB_DIMENSION_BASE* aDimension, int aNestLevel = 0 ) const;
407
408 void format( const PCB_BITMAP* aBitmap, int aNestLevel = 0 ) const;
409
410 void format( const PCB_GROUP* aGroup, int aNestLevel = 0 ) const;
411
412 void format( const PCB_SHAPE* aSegment, int aNestLevel = 0 ) const;
413
414 void format( const PCB_TARGET* aTarget, int aNestLevel = 0 ) const;
415
416 void format( const FOOTPRINT* aFootprint, int aNestLevel = 0 ) const;
417
418 void format( const PAD* aPad, int aNestLevel = 0 ) const;
419
420 void format( const PCB_TEXT* aText, int aNestLevel = 0 ) const;
421 void format( const PCB_TEXTBOX* aTextBox, int aNestLevel = 0 ) const;
422
423 void format( const PCB_TRACK* aTrack, int aNestLevel = 0 ) const;
424
425 void format( const ZONE* aZone, int aNestLevel = 0 ) const;
426
427 void formatPolyPts( const SHAPE_LINE_CHAIN& outline, int aNestLevel, bool aCompact,
428 const FOOTPRINT* aParentFP = nullptr ) const;
429
430 void formatRenderCache( const EDA_TEXT* aText, int aNestLevel ) const;
431
432 void formatLayer( PCB_LAYER_ID aLayer, bool aIsKnockout = false ) const;
433
434 void formatLayers( LSET aLayerMask, int aNestLevel = 0 ) const;
435
436 friend class FP_CACHE;
437
438protected:
439 wxString m_error;
441
444
446 wxString m_filename;
447
450 int m_ctl;
453
454 std::function<bool( wxString aTitle, int aIcon, wxString aMsg, wxString aAction )> m_queryUserCallback;
455};
456
457#endif // PCB_PLUGIN_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:271
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
Helper class for creating a footprint library cache.
Definition: pcb_plugin.h:184
std::unique_ptr< FOOTPRINT > m_footprint
Definition: pcb_plugin.h:186
WX_FILENAME m_filename
Definition: pcb_plugin.h:185
void SetFilePath(const wxString &aFilePath)
Definition: pcb_plugin.h:192
const FOOTPRINT * GetFootprint() const
Definition: pcb_plugin.h:193
const WX_FILENAME & GetFileName() const
Definition: pcb_plugin.h:191
static long long GetTimestamp(const wxString &aLibPath)
Generate a timestamp representing all source files in the cache (including the parent directory).
Definition: pcb_plugin.cpp:264
FP_CACHE_FOOTPRINT_MAP & GetFootprints()
Definition: pcb_plugin.h:219
bool Exists() const
Definition: pcb_plugin.h:217
void Save(FOOTPRINT *aFootprint=nullptr)
Save the footprint cache or a single footprint from it to disk.
Definition: pcb_plugin.cpp:84
bool IsModified()
Return true if the cache is not up-to-date.
Definition: pcb_plugin.cpp:256
long long m_cache_timestamp
Definition: pcb_plugin.h:207
bool m_cache_dirty
Definition: pcb_plugin.h:205
wxString m_lib_raw_path
Definition: pcb_plugin.h:202
void SetPath(const wxString &aPath)
Definition: pcb_plugin.cpp:243
PCB_PLUGIN * m_owner
Definition: pcb_plugin.h:200
wxFileName m_lib_path
Definition: pcb_plugin.h:201
bool IsPath(const wxString &aPath) const
Check if aPath is the same as the current cache path.
Definition: pcb_plugin.cpp:237
void Load()
Definition: pcb_plugin.cpp:154
FP_CACHE_FOOTPRINT_MAP m_footprints
Definition: pcb_plugin.h:203
bool IsWritable() const
Definition: pcb_plugin.h:215
void Remove(const wxString &aFootprintName)
Definition: pcb_plugin.cpp:218
wxString GetPath() const
Definition: pcb_plugin.h:213
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:552
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:322
Definition: pad.h:58
Object to handle a bitmap image that can be inserted in a PCB.
Definition: pcb_bitmap.h:42
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...
Definition: pcb_parser.h:74
A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
Definition: pcb_plugin.h:271
void formatSetup(const BOARD *aBoard, int aNestLevel=0) const
formats the board setup information
Definition: pcb_plugin.cpp:538
PLUGIN_FILE_DESC GetBoardFileDesc() const override
Returns board file description for the PLUGIN.
Definition: pcb_plugin.h:278
void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const STRING_UTF8_MAP *aProperties=nullptr) override
Write aFootprint to an existing library located at aLibraryPath.
BOARD * m_board
which BOARD, no ownership here
Definition: pcb_plugin.h:440
LINE_READER * m_reader
no ownership
Definition: pcb_plugin.h:445
const wxString PluginName() const override
Return a brief hard coded name for this PLUGIN.
Definition: pcb_plugin.h:273
PLUGIN_FILE_DESC GetFootprintFileDesc() const override
Returns footprint file description for the PLUGIN.
Definition: pcb_plugin.h:287
void init(const STRING_UTF8_MAP *aProperties)
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.
bool FootprintLibDelete(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Delete an existing footprint library and returns true, or if library does not exist returns false,...
FP_CACHE * m_cache
Footprint library cache.
Definition: pcb_plugin.h:443
std::function< bool(wxString aTitle, int aIcon, wxString aMsg, wxString aAction)> m_queryUserCallback
Definition: pcb_plugin.h:454
void formatLayer(PCB_LAYER_ID aLayer, bool aIsKnockout=false) const
Definition: pcb_plugin.cpp:449
void formatPolyPts(const SHAPE_LINE_CHAIN &outline, int aNestLevel, bool aCompact, const FOOTPRINT *aParentFP=nullptr) const
Definition: pcb_plugin.cpp:457
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 PLUGIN implementation knows about or it can be u...
Definition: pcb_plugin.cpp:293
BOARD_ITEM * Parse(const wxString &aClipboardSourceInput)
Definition: pcb_plugin.cpp:333
void formatHeader(const BOARD *aBoard, int aNestLevel=0) const
writes everything that comes before the board_items, like settings and layers etc
Definition: pcb_plugin.cpp:721
void formatLayers(LSET aLayerMask, int aNestLevel=0) const
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
wxString m_error
for throwing exceptions
Definition: pcb_plugin.h:439
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PLUGIN can read the specified board file.
Definition: pcb_plugin.cpp:272
bool IsFootprintLibWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Load information from some input file format that this PLUGIN implementation knows about into either ...
void SetOutputFormatter(OUTPUTFORMATTER *aFormatter)
Definition: pcb_plugin.h:371
void formatRenderCache(const EDA_TEXT *aText, int aNestLevel) const
Definition: pcb_plugin.cpp:510
wxString m_filename
for saves only, name is in m_reader for loads
Definition: pcb_plugin.h:446
STRING_FORMATTER m_sf
Definition: pcb_plugin.h:448
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:449
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.
const STRING_UTF8_MAP * m_props
passed via Save() or Load(), no ownership, may be NULL
Definition: pcb_plugin.h:442
BOARD * DoLoad(LINE_READER &aReader, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties, PROGRESS_REPORTER *aProgressReporter, unsigned aLineCount)
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
Definition: pcb_plugin.h:451
void format(const BOARD *aBoard, int aNestLevel=0) const
Definition: pcb_plugin.cpp:773
void formatNetInformation(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
Definition: pcb_plugin.cpp:691
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
Delete aFootprintName from the library at aLibraryPath.
PLUGIN_FILE_DESC GetFootprintLibDesc() const override
Returns footprint library description for the PLUGIN.
Definition: pcb_plugin.h:292
std::string GetStringOutput(bool doClear)
Definition: pcb_plugin.h:361
void SetQueryUserCallback(std::function< bool(wxString aTitle, int aIcon, wxString aMessage, wxString aOKButtonTitle)> aCallback) override
Definition: pcb_plugin.h:297
bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
Check for the existence of a footprint.
void FootprintLibCreate(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Create a new empty footprint library at aLibraryPath empty.
void formatProperties(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
Definition: pcb_plugin.cpp:707
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 PL...
void formatTeardropParameters(const TEARDROP_PARAMETERS &tdParams, int aNestLevel=0) const
Definition: pcb_plugin.cpp:755
const FOOTPRINT * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties, bool checkModified)
void formatBoardLayers(const BOARD *aBoard, int aNestLevel=0) const
formats the board layer information
Definition: pcb_plugin.cpp:621
void formatGeneral(const BOARD *aBoard, int aNestLevel=0) const
formats the General section of the file
Definition: pcb_plugin.cpp:601
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
void Format(const BOARD_ITEM *aItem, int aNestLevel=0) const
Output aItem to aFormatter in s-expression format.
Definition: pcb_plugin.cpp:354
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.
virtual ~PCB_PLUGIN()
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:270
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:427
const std::string & GetString()
Definition: richio.h:450
void Clear()
Clear the buffer and empties the internal string.
Definition: richio.h:440
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...
Definition: pcb_plugin.h:173
boost::ptr_map< wxString, FP_CACHE_ITEM > FP_CACHE_FOOTPRINT_MAP
Definition: pcb_plugin.h:196
Container that describes file type info.