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
24#include <io/io_base.h>
25#include <pcb_io/pcb_io_mgr.h>
26
27#include <memory>
28#include <utility>
29#include <vector>
30
31#include <config.h>
32#include <wx/arrstr.h>
33#include <i18n_utility.h>
34
35class BOARD;
36class FOOTPRINT;
37class PROJECT;
39
40// MIKE WILLIAMS TODO: convert all of the other stringly-typed IO plugin properties to use constants
42{
43// Used to control whether the stackup of the board passed into the IO plugin is preserved or not.
44// It will NOT keep the stackup from being changed in all cases, as a copper layer increase may require
45// the stackup to grow
46inline constexpr char APPEND_PRESERVE_DESTINATION_STACKUP[] = "append_preserve_destination_stackup";
47}
48
77class PCB_IO : public IO_BASE
78{
79public:
84 {
85 return IO_BASE::IO_FILE_DESC( wxEmptyString, {} );
86 }
87
91 bool IsPCB_IO() const override { return true; }
92
97
103 virtual std::vector<std::pair<wxString, wxString>>
104 EnumerateProjectBoards( const wxString& aFileName ) const
105 {
106 return {};
107 }
108
113 virtual std::vector<IMPORT_PROJECT_DESC> EnumerateProjectEntries( const wxString& aFileName ) const
114 {
115 return {};
116 }
117
118 virtual bool CanReadBoard( const wxString& aFileName ) const;
119
124 virtual bool CanReadFootprint( const wxString& aFileName ) const;
125
129 virtual void SetQueryUserCallback( std::function<bool( wxString aTitle, int aIcon,
130 wxString aMessage,
131 wxString aAction )> aCallback )
132 { }
133
155 std::unique_ptr<BOARD> LoadBoard( const wxString& aFileName,
156 const std::map<std::string, UTF8>* aProperties = nullptr,
157 PROJECT* aProject = nullptr );
158
159
169 void LoadAndAppendBoard( const wxString& aFileName, BOARD& aAppendToMe,
170 const std::map<std::string, UTF8>* aProperties = nullptr, PROJECT* aProject = nullptr );
171
180 virtual std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints();
186 virtual wxString GetImportedDesignRules() const { return wxEmptyString; }
187
188
207 virtual void SaveBoard( const wxString& aFileName, BOARD& aBoard,
208 const std::map<std::string, UTF8>* aProperties = nullptr );
209
224 virtual void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
225 bool aBestEfforts,
226 const std::map<std::string, UTF8>* aProperties = nullptr );
227
234 virtual long long GetLibraryTimestamp( const wxString& aLibraryPath ) const = 0;
235
253 virtual std::unique_ptr<FOOTPRINT> ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
254 const std::map<std::string, UTF8>* aProperties = nullptr );
255
277 virtual std::unique_ptr<FOOTPRINT> FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
278 bool aKeepUUID = false,
279 const std::map<std::string, UTF8>* aProperties = nullptr );
280
288 virtual const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
289 const std::map<std::string, UTF8>* aProperties = nullptr );
290
297 virtual bool CachesEnumeratedFootprints() const { return false; }
298
302 virtual bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
303 const std::map<std::string, UTF8>* aProperties = nullptr );
304
321 virtual void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
322 const std::map<std::string, UTF8>* aProperties = nullptr );
323
338 virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
339 const std::map<std::string, UTF8>* aProperties = nullptr );
340
349 virtual void ClearCachedFootprints( const wxString& aLibraryPath ) {}
350
377 virtual void GetLibraryOptions( std::map<std::string, UTF8>* aListToAppendTo ) const override;
378
379 virtual ~PCB_IO()
380 {};
381
382protected:
383 PCB_IO( const wxString& aName ) :
384 IO_BASE( aName ),
385 m_board( nullptr ),
386 m_props( nullptr )
387 {}
388
400 virtual void loadBoard( const wxString& aFileName, BOARD& aBoard, bool aIsNewLoad,
401 const std::map<std::string, UTF8>* aProperties, PROJECT* aProject );
402
405
407 const std::map<std::string, UTF8>* m_props;
408};
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
IO_BASE()=delete
BOARD * m_board
The board BOARD being worked on, no ownership here.
Definition pcb_io.h:404
virtual bool CanReadFootprint(const wxString &aFileName) const
Check if this PCB_IO can read a footprint from specified file or directory.
Definition pcb_io.cpp:56
virtual bool CachesEnumeratedFootprints() const
Return true if GetEnumeratedFootprint() returns a borrowed pointer from an internal cache.
Definition pcb_io.h:297
virtual std::unique_ptr< 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:160
void LoadAndAppendBoard(const wxString &aFileName, BOARD &aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr)
Same as LoadBoard(), but appends the loaded board to an existing board, which must already exist.
Definition pcb_io.cpp:85
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)
Register a KIDIALOG callback for collecting info from the user.
Definition pcb_io.h:129
virtual bool CanReadBoard(const wxString &aFileName) const
Definition pcb_io.cpp:40
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:105
virtual std::vector< std::pair< wxString, wxString > > EnumerateProjectBoards(const wxString &aFileName) const
Check if this PCB_IO can read the specified board file.
Definition pcb_io.h:104
virtual void ClearCachedFootprints(const wxString &aLibraryPath)
Clear any cached footprint data for the given library path.
Definition pcb_io.h:349
PCB_IO(const wxString &aName)
Definition pcb_io.h:383
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:112
virtual std::unique_ptr< 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:120
bool IsPCB_IO() const override
Work-around for lack of dynamic_cast across compile units on Mac.
Definition pcb_io.h:91
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:185
std::unique_ptr< BOARD > LoadBoard(const wxString &aFileName, 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 new BOA...
Definition pcb_io.cpp:72
virtual ~PCB_IO()
Definition pcb_io.h:379
const std::map< std::string, UTF8 > * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
Definition pcb_io.h:407
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:152
virtual std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints()
Return a container with the cached library footprints generated in the last call to Load.
Definition pcb_io.cpp:99
virtual std::vector< IMPORT_PROJECT_DESC > EnumerateProjectEntries(const wxString &aFileName) const
Return the KiCad projects a project container splits into, one per board entry and one per PCB or sch...
Definition pcb_io.h:113
virtual void loadBoard(const wxString &aFileName, BOARD &aBoard, bool aIsNewLoad, const std::map< std::string, UTF8 > *aProperties, PROJECT *aProject)
Parse aFileName into aBoard.
Definition pcb_io.cpp:92
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 i...
Definition pcb_io.cpp:144
virtual wxString GetImportedDesignRules() const
Return custom DRC rules generated while importing the most recent board.
Definition pcb_io.h:186
virtual const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const
Return board file description for the PCB_IO.
Definition pcb_io.h:83
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:177
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:169
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
Definition project.h:63
Some functions to handle hotkeys in KiCad.
constexpr char APPEND_PRESERVE_DESTINATION_STACKUP[]
Definition pcb_io.h:46
Container that describes file type info.
Definition io_base.h:43