KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io.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) 2011-2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
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, see <https://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <io/io_base.h>
24#include <pcb_io/pcb_io_mgr.h>
25
26#include <cstdint>
27#include <config.h>
28#include <vector>
29#include <wx/arrstr.h>
30#include <i18n_utility.h>
31
32class BOARD;
33class FOOTPRINT;
34class PROJECT;
36
37// MIKE WILLIAMS TODO: convert all of the other stringly-typed IO plugin properties to use constants
39{
40// Used to control whether the stackup of the board passed into the IO plugin is preserved or not.
41// It will NOT keep the stackup from being changed in all cases, as a copper layer increase may require
42// the stackup to grow
43inline constexpr char APPEND_PRESERVE_DESTINATION_STACKUP[] = "append_preserve_destination_stackup";
44}
45
74class PCB_IO : public IO_BASE
75{
76public:
81 {
82 return IO_BASE::IO_FILE_DESC( wxEmptyString, {} );
83 }
84
88 bool IsPCB_IO() const override { return true; }
89
94 virtual bool CanReadBoard( const wxString& aFileName ) const;
95
100 virtual bool CanReadFootprint( const wxString& aFileName ) const;
101
105 virtual void SetQueryUserCallback( std::function<bool( wxString aTitle, int aIcon,
106 wxString aMessage,
107 wxString aAction )> aCallback )
108 { }
109
136 virtual BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
137 const std::map<std::string, UTF8>* aProperties = nullptr,
138 PROJECT* aProject = nullptr );
139
148 virtual std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints();
149
168 virtual void SaveBoard( const wxString& aFileName, BOARD* aBoard,
169 const std::map<std::string, UTF8>* aProperties = nullptr );
170
185 virtual void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
186 bool aBestEfforts,
187 const std::map<std::string, UTF8>* aProperties = nullptr );
188
195 virtual long long GetLibraryTimestamp( const wxString& aLibraryPath ) const = 0;
196
214 virtual FOOTPRINT* ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
215 const std::map<std::string, UTF8>* aProperties = nullptr );
216
238 virtual FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
239 bool aKeepUUID = false,
240 const std::map<std::string, UTF8>* aProperties = nullptr );
241
246 virtual const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
247 const std::map<std::string, UTF8>* aProperties = nullptr );
248
255 virtual bool CachesEnumeratedFootprints() const { return false; }
256
260 virtual bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
261 const std::map<std::string, UTF8>* aProperties = nullptr );
262
279 virtual void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
280 const std::map<std::string, UTF8>* aProperties = nullptr );
281
296 virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
297 const std::map<std::string, UTF8>* aProperties = nullptr );
298
307 virtual void ClearCachedFootprints( const wxString& aLibraryPath ) {}
308
336 virtual void GetLibraryOptions( std::map<std::string, UTF8>* aListToAppendTo ) const override;
337
338 virtual ~PCB_IO()
339 {};
340
341protected:
342 PCB_IO( const wxString& aName ) :
343 IO_BASE( aName ),
344 m_board( nullptr ),
345 m_props( nullptr )
346 {}
347
350
352 const std::map<std::string, UTF8>* m_props;
353};
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
IO_BASE()=delete
BOARD * m_board
The board BOARD being worked on, no ownership here.
Definition pcb_io.h:349
virtual bool CanReadFootprint(const wxString &aFileName) const
Checks if this PCB_IO can read a footprint from specified file or directory.
Definition pcb_io.cpp:54
virtual bool CachesEnumeratedFootprints() const
Return true if GetEnumeratedFootprint() returns a borrowed pointer from an internal cache.
Definition pcb_io.h:255
virtual long long GetLibraryTimestamp(const wxString &aLibraryPath) const =0
Generate a timestamp representing all the files in the library (including the library directory).
virtual void SetQueryUserCallback(std::function< bool(wxString aTitle, int aIcon, wxString aMessage, wxString aAction)> aCallback)
Registers a KIDIALOG callback for collecting info from the user.
Definition pcb_io.h:105
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PCB_IO can read the specified board file.
Definition pcb_io.cpp:38
virtual void ClearCachedFootprints(const wxString &aLibraryPath)
Clear any cached footprint data for the given library path.
Definition pcb_io.h:307
PCB_IO(const wxString &aName)
Definition pcb_io.h:342
virtual FOOTPRINT * ImportFootprint(const wxString &aFootprintPath, wxString &aFootprintNameOut, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut.
Definition pcb_io.cpp:99
virtual void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const std::map< std::string, UTF8 > *aProperties=nullptr)
Return a list of footprint names contained within the library at aLibraryPath.
Definition pcb_io.cpp:91
virtual void SaveBoard(const wxString &aFileName, BOARD *aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr)
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...
Definition pcb_io.cpp:83
bool IsPCB_IO() const override
Work-around for lack of dynamic_cast across compile units on Mac.
Definition pcb_io.h:88
virtual void GetLibraryOptions(std::map< std::string, UTF8 > *aListToAppendTo) const override
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.
Definition pcb_io.cpp:164
virtual ~PCB_IO()
Definition pcb_io.h:338
const std::map< std::string, UTF8 > * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
Definition pcb_io.h:352
virtual bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Check for the existence of a footprint.
Definition pcb_io.cpp:132
virtual std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints()
Return a container with the cached library footprints generated in the last call to Load.
Definition pcb_io.cpp:77
virtual BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr)
Load information from some input file format that this PCB_IO implementation knows about into either ...
Definition pcb_io.cpp:70
virtual const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr)
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
Definition pcb_io.cpp:123
virtual const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const
Returns board file description for the PCB_IO.
Definition pcb_io.h:80
virtual void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Delete aFootprintName from the library at aLibraryPath.
Definition pcb_io.cpp:156
virtual FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PC...
Definition pcb_io.cpp:140
virtual void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const std::map< std::string, UTF8 > *aProperties=nullptr)
Write aFootprint to an existing library located at aLibraryPath.
Definition pcb_io.cpp:148
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
Definition project.h:62
Some functions to handle hotkeys in KiCad.
constexpr char APPEND_PRESERVE_DESTINATION_STACKUP[]
Definition pcb_io.h:43
Container that describes file type info.
Definition io_base.h:43