KiCad PCB EDA Suite
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-2022 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 <string>
30#include <layer_ids.h>
31#include <boost/ptr_container/ptr_map.hpp>
32#include <wx_filename.h>
34
35class BOARD;
36class BOARD_ITEM;
37class FP_CACHE;
38class PCB_PARSER;
39class NETINFO_MAPPING;
42class FP_SHAPE;
43class PCB_SHAPE;
44class PCB_BITMAP;
45class PCB_TARGET;
46class PAD;
47class FP_TEXT;
48class FP_TEXTBOX;
49class PCB_GROUP;
50class PCB_TRACK;
51class ZONE;
52class PCB_TEXT;
53class PCB_TEXTBOX;
54class EDA_TEXT;
56class PCB_PLUGIN; // forward decl
57
59
60//#define SEXPR_BOARD_FILE_VERSION 3 // first s-expression format, used legacy cu stack
61//#define SEXPR_BOARD_FILE_VERSION 4 // reversed cu stack, changed Inner* to In* in reverse order
62// // went to 32 Cu layers from 16.
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//#define SEXPR_BOARD_FILE_VERSION 20190331 // hatched zones and chamfered round rect pads
71//#define SEXPR_BOARD_FILE_VERSION 20190421 // curves in custom pads
72//#define SEXPR_BOARD_FILE_VERSION 20190516 // Remove segment count from zones
73//#define SEXPR_BOARD_FILE_VERSION 20190605 // Add layer defaults
74//#define SEXPR_BOARD_FILE_VERSION 20190905 // Add board physical stackup info in setup section
75//#define SEXPR_BOARD_FILE_VERSION 20190907 // Keepout areas in footprints
76//#define SEXPR_BOARD_FILE_VERSION 20191123 // pin function in pads
77//#define SEXPR_BOARD_FILE_VERSION 20200104 // pad property for fabrication
78//#define SEXPR_BOARD_FILE_VERSION 20200119 // arcs in tracks
79//#define SEXPR_BOARD_FILE_VERSION 20200512 // page -> paper
80//#define SEXPR_BOARD_FILE_VERSION 20200518 // save hole_to_hole_min
81//#define SEXPR_BOARD_FILE_VERSION 20200614 // Add support for fp_rects and gr_rects
82//#define SEXPR_BOARD_FILE_VERSION 20200625 // Multilayer zones, zone names, island controls
83//#define SEXPR_BOARD_FILE_VERSION 20200628 // remove visibility settings
84//#define SEXPR_BOARD_FILE_VERSION 20200724 // Add KIID to footprints
85//#define SEXPR_BOARD_FILE_VERSION 20200807 // Add zone hatch advanced settings
86//#define SEXPR_BOARD_FILE_VERSION 20200808 // Add properties to footprints
87//#define SEXPR_BOARD_FILE_VERSION 20200809 // Add REMOVE_UNUSED_LAYERS option to vias and THT pads
88//#define SEXPR_BOARD_FILE_VERSION 20200811 // Add groups
89//#define SEXPR_BOARD_FILE_VERSION 20200818 // Remove Status flag bitmap and setup counts
90//#define SEXPR_BOARD_FILE_VERSION 20200819 // Add board-level properties
91//#define SEXPR_BOARD_FILE_VERSION 20200825 // Remove host information
92//#define SEXPR_BOARD_FILE_VERSION 20200828 // Add new fabrication attributes
93//#define SEXPR_BOARD_FILE_VERSION 20200829 // Remove library name from exported footprints
94//#define SEXPR_BOARD_FILE_VERSION 20200909 // Change DIMENSION format
95//#define SEXPR_BOARD_FILE_VERSION 20200913 // Add leader dimension
96//#define SEXPR_BOARD_FILE_VERSION 20200916 // Add center dimension
97//#define SEXPR_BOARD_FILE_VERSION 20200921 // Add orthogonal dimension
98//#define SEXPR_BOARD_FILE_VERSION 20200922 // Add user name to layer definition.
99//#define SEXPR_BOARD_FILE_VERSION 20201002 // Add groups in footprints (for footprint editor).
100//#define SEXPR_BOARD_FILE_VERSION 20201114 // Add first-class support for filled shapes.
101//#define SEXPR_BOARD_FILE_VERSION 20201115 // module -> footprint and change fill syntax.
102//#define SEXPR_BOARD_FILE_VERSION 20201116 // Write version and generator string in footprint files.
103//#define SEXPR_BOARD_FILE_VERSION 20201220 // Add free via token
104//#define SEXPR_BOARD_FILE_VERSION 20210108 // Pad locking moved from footprint to pads
105//#define SEXPR_BOARD_FILE_VERSION 20210126 // Store pintype alongside pinfunction (in pads).
106//#define SEXPR_BOARD_FILE_VERSION 20210228 // Move global margins back to board file
107//#define SEXPR_BOARD_FILE_VERSION 20210424 // Correct locked flag syntax (remove parens).
108//#define SEXPR_BOARD_FILE_VERSION 20210606 // Change overbar syntax from `~...~` to `~{...}`.
109//#define SEXPR_BOARD_FILE_VERSION 20210623 // Add support for reading/writing arcs in polygons
110//#define SEXPR_BOARD_FILE_VERSION 20210722 // Reading/writing group locked flags
111//#define SEXPR_BOARD_FILE_VERSION 20210824 // Opacity in 3D colors
112//#define SEXPR_BOARD_FILE_VERSION 20210925 // Locked flag for fp_text
113//#define SEXPR_BOARD_FILE_VERSION 20211014 // Arc formatting
114//#define SEXPR_BOARD_FILE_VERSION 20211226 // Add radial dimension
115//#define SEXPR_BOARD_FILE_VERSION 20211227 // Add thermal relief spoke angle overrides
116//#define SEXPR_BOARD_FILE_VERSION 20211228 // Add allow_soldermask_bridges footprint attribute
117//#define SEXPR_BOARD_FILE_VERSION 20211229 // Stroke formatting
118//#define SEXPR_BOARD_FILE_VERSION 20211230 // Dimensions in footprints
119//#define SEXPR_BOARD_FILE_VERSION 20211231 // Private footprint layers
120//#define SEXPR_BOARD_FILE_VERSION 20211232 // Fonts
121//#define SEXPR_BOARD_FILE_VERSION 20220131 // Textboxes
122//#define SEXPR_BOARD_FILE_VERSION 20220211 // End support for V5 zone fill strategy
123//#define SEXPR_BOARD_FILE_VERSION 20220225 // Remove TEDIT
124//#define SEXPR_BOARD_FILE_VERSION 20220308 // Knockout text and Locked graphic text property saved
125//#define SEXPR_BOARD_FILE_VERSION 20220331 // Plot on all layers selection setting
126//#define SEXPR_BOARD_FILE_VERSION 20220417 // Automatic dimension precisions
127//#define SEXPR_BOARD_FILE_VERSION 20220427 // Exclude Edge.Cuts & Margin from fp private layers
128//#define SEXPR_BOARD_FILE_VERSION 20220609 // Add teardrop keywords to identify teardrop zones
129//#define SEXPR_BOARD_FILE_VERSION 20220621 // Add Image support
130//#define SEXPR_BOARD_FILE_VERSION 20220815 // Add allow-soldermask-bridges-in-FPs flag
131//#define SEXPR_BOARD_FILE_VERSION 20220818 // First-class storage for net-ties
132//#define SEXPR_BOARD_FILE_VERSION 20220914 // Number boxes for custom-shape pads
133#define SEXPR_BOARD_FILE_VERSION 20221018 // Via & pad zone-layer-connections
134
135#define BOARD_FILE_HOST_VERSION 20200825
136#define LEGACY_ARC_FORMATTING 20210925
137#define LEGACY_NET_TIES 20220815
139
140#define CTL_OMIT_PAD_NETS (1 << 1)
141#define CTL_OMIT_TSTAMPS (1 << 2)
142#define CTL_OMIT_INITIAL_COMMENTS (1 << 3)
143#define CTL_OMIT_PATH (1 << 4)
144#define CTL_OMIT_AT (1 << 5)
146//#define CTL_OMIT_HIDE (1 << 6) // found and defined in eda_text.h
147#define CTL_OMIT_LIBNAME (1 << 7)
149#define CTL_OMIT_FOOTPRINT_VERSION (1 << 8)
151
152// common combinations of the above:
153
155#define CTL_FOR_CLIPBOARD (CTL_OMIT_INITIAL_COMMENTS) // (CTL_OMIT_NETS)
156
158#define CTL_FOR_LIBRARY \
159 ( CTL_OMIT_PAD_NETS | CTL_OMIT_TSTAMPS | CTL_OMIT_PATH | CTL_OMIT_AT | CTL_OMIT_LIBNAME )
160
163#define CTL_FOR_BOARD (CTL_OMIT_INITIAL_COMMENTS|CTL_OMIT_FOOTPRINT_VERSION)
164
174{
176 std::unique_ptr<FOOTPRINT> m_footprint;
177
178public:
179 FP_CACHE_ITEM( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName );
180
181 const WX_FILENAME& GetFileName() const { return m_filename; }
182 void SetFilePath( const wxString& aFilePath ) { m_filename.SetPath( aFilePath ); }
183 const FOOTPRINT* GetFootprint() const { return m_footprint.get(); }
184};
185
186typedef boost::ptr_map<wxString, FP_CACHE_ITEM> FP_CACHE_FOOTPRINT_MAP;
187
189{
190 PCB_PLUGIN* m_owner; // Plugin object that owns the cache.
191 wxFileName m_lib_path; // The path of the library.
192 wxString m_lib_raw_path; // For quick comparisons.
193 FP_CACHE_FOOTPRINT_MAP m_footprints; // Map of footprint filename to FOOTPRINT*.
194
195 bool m_cache_dirty; // Stored separately because it's expensive to check
196 // m_cache_timestamp against all the files.
197 long long m_cache_timestamp; // A hash of the timestamps for all the footprint
198 // files.
199
200public:
201 FP_CACHE( PCB_PLUGIN* aOwner, const wxString& aLibraryPath );
202
203 wxString GetPath() const { return m_lib_raw_path; }
204
205 bool IsWritable() const { return m_lib_path.IsOk() && m_lib_path.IsDirWritable(); }
206
207 bool Exists() const { return m_lib_path.IsOk() && m_lib_path.DirExists(); }
208
210
211 // Most all functions in this class throw IO_ERROR exceptions. There are no
212 // error codes nor user interface calls from here, nor in any PLUGIN.
213 // Catch these exceptions higher up please.
214
220 void Save( FOOTPRINT* aFootprint = nullptr );
221
222 void Load();
223
224 void Remove( const wxString& aFootprintName );
225
231 static long long GetTimestamp( const wxString& aLibPath );
232
236 bool IsModified();
237
249 bool IsPath( const wxString& aPath ) const;
250
251 void SetPath( const wxString& aPath );
252};
253
254
260class PCB_PLUGIN : public PLUGIN
261{
262public:
263 const wxString PluginName() const override
264 {
265 return wxT( "KiCad" );
266 }
267
268 const wxString GetFileExtension() const override
269 {
270 // Would have used wildcards_and_files_ext.cpp's KiCadPcbFileExtension,
271 // but to be pure, a plugin should not assume that it will always be linked
272 // with the core of the Pcbnew code. (Might someday be a DLL/DSO.) Besides,
273 // file extension policy should be controlled by the plugin.
274 return wxT( "kicad_pcb" );
275 }
276
277 void SetQueryUserCallback( std::function<bool( wxString aTitle, int aIcon, wxString aMessage,
278 wxString aOKButtonTitle )> aCallback ) override
279 {
280 m_queryUserCallback = &aCallback;
281 }
282
283 void Save( const wxString& aFileName, BOARD* aBoard,
284 const STRING_UTF8_MAP* aProperties = nullptr ) override;
285
286 BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe,
287 const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr,
288 PROGRESS_REPORTER* aProgressReporter = nullptr ) override;
289
290 BOARD* DoLoad( LINE_READER& aReader, BOARD* aAppendToMe, const STRING_UTF8_MAP* aProperties,
291 PROGRESS_REPORTER* aProgressReporter, unsigned aLineCount );
292
293 void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
294 bool aBestEfforts, const STRING_UTF8_MAP* aProperties = nullptr ) override;
295
296 const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath,
297 const wxString& aFootprintName,
298 const STRING_UTF8_MAP* aProperties = nullptr ) override;
299
300 bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
301 const STRING_UTF8_MAP* aProperties = nullptr ) override;
302
303 FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
304 bool aKeepUUID = false,
305 const STRING_UTF8_MAP* aProperties = nullptr ) override;
306
307 void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
308 const STRING_UTF8_MAP* aProperties = nullptr ) override;
309
310 void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
311 const STRING_UTF8_MAP* aProperties = nullptr ) override;
312
313 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
314
315 void FootprintLibCreate( const wxString& aLibraryPath,
316 const STRING_UTF8_MAP* aProperties = nullptr) override;
317
318 bool FootprintLibDelete( const wxString& aLibraryPath,
319 const STRING_UTF8_MAP* aProperties = nullptr ) override;
320
321 bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
322
323 PCB_PLUGIN( int aControlFlags = CTL_FOR_BOARD );
324
325 virtual ~PCB_PLUGIN();
326
334 void Format( const BOARD_ITEM* aItem, int aNestLevel = 0 ) const;
335
336 std::string GetStringOutput( bool doClear )
337 {
338 std::string ret = m_sf.GetString();
339
340 if( doClear )
341 m_sf.Clear();
342
343 return ret;
344 }
345
346 void SetOutputFormatter( OUTPUTFORMATTER* aFormatter ) { m_out = aFormatter; }
347
348 BOARD_ITEM* Parse( const wxString& aClipboardSourceInput );
349
350protected:
351 void validateCache( const wxString& aLibraryPath, bool checkModified = true );
352
353 const FOOTPRINT* getFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
354 const STRING_UTF8_MAP* aProperties, bool checkModified );
355
356 void init( const STRING_UTF8_MAP* aProperties );
357
359 void formatSetup( const BOARD* aBoard, int aNestLevel = 0 ) const;
360
362 void formatGeneral( const BOARD* aBoard, int aNestLevel = 0 ) const;
363
365 void formatBoardLayers( const BOARD* aBoard, int aNestLevel = 0 ) const;
366
368 void formatNetInformation( const BOARD* aBoard, int aNestLevel = 0 ) const;
369
371 void formatProperties( const BOARD* aBoard, int aNestLevel = 0 ) const;
372
374 void formatHeader( const BOARD* aBoard, int aNestLevel = 0 ) const;
375
376private:
377 void format( const BOARD* aBoard, int aNestLevel = 0 ) const;
378
379 void format( const PCB_DIMENSION_BASE* aDimension, int aNestLevel = 0 ) const;
380
381 void format( const FP_SHAPE* aFPShape, int aNestLevel = 0 ) const;
382
383 void format( const PCB_BITMAP* aBitmap, int aNestLevel = 0 ) const;
384
385 void format( const PCB_GROUP* aGroup, int aNestLevel = 0 ) const;
386
387 void format( const PCB_SHAPE* aSegment, int aNestLevel = 0 ) const;
388
389 void format( const PCB_TARGET* aTarget, int aNestLevel = 0 ) const;
390
391 void format( const FOOTPRINT* aFootprint, int aNestLevel = 0 ) const;
392
393 void format( const PAD* aPad, int aNestLevel = 0 ) const;
394
395 void format( const PCB_TEXT* aText, int aNestLevel = 0 ) const;
396 void format( const PCB_TEXTBOX* aTextBox, int aNestLevel = 0 ) const;
397
398 void format( const FP_TEXT* aText, int aNestLevel = 0 ) const;
399 void format( const FP_TEXTBOX* aTextBox, int aNestLevel = 0 ) const;
400
401 void format( const PCB_TRACK* aTrack, int aNestLevel = 0 ) const;
402
403 void format( const ZONE* aZone, int aNestLevel = 0 ) const;
404
405 void formatPolyPts( const SHAPE_LINE_CHAIN& outline, int aNestLevel, bool aCompact ) const;
406
407 void formatRenderCache( const EDA_TEXT* aText, int aNestLevel ) const;
408
409 void formatLayer( PCB_LAYER_ID aLayer, bool aIsKnockout = false ) const;
410
411 void formatLayers( LSET aLayerMask, int aNestLevel = 0 ) const;
412
413 friend class FP_CACHE;
414
415protected:
416 wxString m_error;
418
421
423 wxString m_filename;
424
427 int m_ctl;
430
431 std::function<bool( wxString aTitle, int aIcon, wxString aMsg, wxString aAction )>* m_queryUserCallback;
432};
433
434#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:70
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:269
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
Helper class for creating a footprint library cache.
Definition: pcb_plugin.h:174
std::unique_ptr< FOOTPRINT > m_footprint
Definition: pcb_plugin.h:176
WX_FILENAME m_filename
Definition: pcb_plugin.h:175
FP_CACHE_ITEM(FOOTPRINT *aFootprint, const WX_FILENAME &aFileName)
Definition: pcb_plugin.cpp:69
void SetFilePath(const wxString &aFilePath)
Definition: pcb_plugin.h:182
const FOOTPRINT * GetFootprint() const
Definition: pcb_plugin.h:183
const WX_FILENAME & GetFileName() const
Definition: pcb_plugin.h:181
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:263
FP_CACHE_FOOTPRINT_MAP & GetFootprints()
Definition: pcb_plugin.h:209
bool Exists() const
Definition: pcb_plugin.h:207
void Save(FOOTPRINT *aFootprint=nullptr)
Save the footprint cache or a single footprint from it to disk.
Definition: pcb_plugin.cpp:85
bool IsModified()
Return true if the cache is not up-to-date.
Definition: pcb_plugin.cpp:255
long long m_cache_timestamp
Definition: pcb_plugin.h:197
bool m_cache_dirty
Definition: pcb_plugin.h:195
wxString m_lib_raw_path
Definition: pcb_plugin.h:192
void SetPath(const wxString &aPath)
Definition: pcb_plugin.cpp:242
PCB_PLUGIN * m_owner
Definition: pcb_plugin.h:190
FP_CACHE(PCB_PLUGIN *aOwner, const wxString &aLibraryPath)
Definition: pcb_plugin.cpp:75
wxFileName m_lib_path
Definition: pcb_plugin.h:191
bool IsPath(const wxString &aPath) const
Check if aPath is the same as the current cache path.
Definition: pcb_plugin.cpp:236
void Load()
Definition: pcb_plugin.cpp:152
FP_CACHE_FOOTPRINT_MAP m_footprints
Definition: pcb_plugin.h:193
bool IsWritable() const
Definition: pcb_plugin.h:205
void Remove(const wxString &aFootprintName)
Definition: pcb_plugin.cpp:217
wxString GetPath() const
Definition: pcb_plugin.h:203
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:81
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:532
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:310
Definition: pad.h:60
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:261
void formatSetup(const BOARD *aBoard, int aNestLevel=0) const
formats the board setup information
Definition: pcb_plugin.cpp:510
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:417
LINE_READER * m_reader
no ownership here.
Definition: pcb_plugin.h:422
const wxString PluginName() const override
Return a brief hard coded name for this PLUGIN.
Definition: pcb_plugin.h:263
void formatPolyPts(const SHAPE_LINE_CHAIN &outline, int aNestLevel, bool aCompact) const
Definition: pcb_plugin.cpp:423
void init(const STRING_UTF8_MAP *aProperties)
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:420
void formatLayer(PCB_LAYER_ID aLayer, bool aIsKnockout=false) const
Definition: pcb_plugin.cpp:415
BOARD_ITEM * Parse(const wxString &aClipboardSourceInput)
Definition: pcb_plugin.cpp:310
std::function< bool(wxString aTitle, int aIcon, wxString aMsg, wxString aAction)> * m_queryUserCallback
Definition: pcb_plugin.h:431
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:689
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:416
const wxString GetFileExtension() const override
Returns the file extension for the PLUGIN.
Definition: pcb_plugin.h:268
bool IsFootprintLibWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
BOARD * Load(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:346
void formatRenderCache(const EDA_TEXT *aText, int aNestLevel) const
Definition: pcb_plugin.cpp:476
wxString m_filename
for saves only, name is in m_reader for loads
Definition: pcb_plugin.h:423
STRING_FORMATTER m_sf
Definition: pcb_plugin.h:425
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:426
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:419
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:428
void format(const BOARD *aBoard, int aNestLevel=0) const
Definition: pcb_plugin.cpp:707
void formatNetInformation(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
Definition: pcb_plugin.cpp:659
PCB_PLUGIN(int aControlFlags=CTL_FOR_BOARD)
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
Delete aFootprintName from the library at aLibraryPath.
std::string GetStringOutput(bool doClear)
Definition: pcb_plugin.h:336
void SetQueryUserCallback(std::function< bool(wxString aTitle, int aIcon, wxString aMessage, wxString aOKButtonTitle)> aCallback) override
Definition: pcb_plugin.h:277
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:675
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...
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:589
void formatGeneral(const BOARD *aBoard, int aNestLevel=0) const
formats the General section of the file
Definition: pcb_plugin.cpp:573
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
void Save(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:271
void Format(const BOARD_ITEM *aItem, int aNestLevel=0) const
Output aItem to aFormatter in s-expression format.
Definition: pcb_plugin.cpp:331
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:64
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:415
const std::string & GetString()
Definition: richio.h:438
void Clear()
Clear the buffer and empties the internal string.
Definition: richio.h:428
A name/value tuple with unique names and optional values.
A wrapper around a wxFileName which is much more performant with a subset of the API.
Definition: wx_filename.h:49
void SetPath(const wxString &aPath)
Definition: wx_filename.cpp:40
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
#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:163
boost::ptr_map< wxString, FP_CACHE_ITEM > FP_CACHE_FOOTPRINT_MAP
Definition: pcb_plugin.h:186