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 <memory>
27#include <utility>
28#include <vector>
29
30#include <config.h>
31#include <wx/arrstr.h>
32#include <i18n_utility.h>
33
34class BOARD;
35class FOOTPRINT;
36class PROJECT;
38
39// MIKE WILLIAMS TODO: convert all of the other stringly-typed IO plugin properties to use constants
41{
42// Used to control whether the stackup of the board passed into the IO plugin is preserved or not.
43// It will NOT keep the stackup from being changed in all cases, as a copper layer increase may require
44// the stackup to grow
45inline constexpr char APPEND_PRESERVE_DESTINATION_STACKUP[] = "append_preserve_destination_stackup";
46}
47
76class PCB_IO : public IO_BASE
77{
78public:
83 {
84 return IO_BASE::IO_FILE_DESC( wxEmptyString, {} );
85 }
86
90 bool IsPCB_IO() const override { return true; }
91
96
102 virtual std::vector<std::pair<wxString, wxString>>
103 EnumerateProjectBoards( const wxString& aFileName ) const
104 {
105 return {};
106 }
107 virtual bool CanReadBoard( const wxString& aFileName ) const;
108
113 virtual bool CanReadFootprint( const wxString& aFileName ) const;
114
118 virtual void SetQueryUserCallback( std::function<bool( wxString aTitle, int aIcon,
119 wxString aMessage,
120 wxString aAction )> aCallback )
121 { }
122
144 std::unique_ptr<BOARD> LoadBoard( const wxString& aFileName,
145 const std::map<std::string, UTF8>* aProperties = nullptr,
146 PROJECT* aProject = nullptr );
147
148
158 void LoadAndAppendBoard( const wxString& aFileName, BOARD& aAppendToMe,
159 const std::map<std::string, UTF8>* aProperties = nullptr, PROJECT* aProject = nullptr );
160
169 virtual std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints();
175 virtual wxString GetImportedDesignRules() const { return wxEmptyString; }
176
177
196 virtual void SaveBoard( const wxString& aFileName, BOARD& aBoard,
197 const std::map<std::string, UTF8>* aProperties = nullptr );
198
213 virtual void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
214 bool aBestEfforts,
215 const std::map<std::string, UTF8>* aProperties = nullptr );
216
223 virtual long long GetLibraryTimestamp( const wxString& aLibraryPath ) const = 0;
224
242 virtual std::unique_ptr<FOOTPRINT> ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
243 const std::map<std::string, UTF8>* aProperties = nullptr );
244
266 virtual std::unique_ptr<FOOTPRINT> FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
267 bool aKeepUUID = false,
268 const std::map<std::string, UTF8>* aProperties = nullptr );
269
277 virtual const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
278 const std::map<std::string, UTF8>* aProperties = nullptr );
279
286 virtual bool CachesEnumeratedFootprints() const { return false; }
287
291 virtual bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
292 const std::map<std::string, UTF8>* aProperties = nullptr );
293
310 virtual void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
311 const std::map<std::string, UTF8>* aProperties = nullptr );
312
327 virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
328 const std::map<std::string, UTF8>* aProperties = nullptr );
329
338 virtual void ClearCachedFootprints( const wxString& aLibraryPath ) {}
339
366 virtual void GetLibraryOptions( std::map<std::string, UTF8>* aListToAppendTo ) const override;
367
368 virtual ~PCB_IO()
369 {};
370
371protected:
372 PCB_IO( const wxString& aName ) :
373 IO_BASE( aName ),
374 m_board( nullptr ),
375 m_props( nullptr )
376 {}
377
389 virtual void loadBoard( const wxString& aFileName, BOARD& aBoard, bool aIsNewLoad,
390 const std::map<std::string, UTF8>* aProperties, PROJECT* aProject );
391
394
396 const std::map<std::string, UTF8>* m_props;
397};
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:410
IO_BASE()=delete
BOARD * m_board
The board BOARD being worked on, no ownership here.
Definition pcb_io.h:393
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:286
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:118
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:103
virtual void ClearCachedFootprints(const wxString &aLibraryPath)
Clear any cached footprint data for the given library path.
Definition pcb_io.h:338
PCB_IO(const wxString &aName)
Definition pcb_io.h:372
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:90
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:368
const std::map< std::string, UTF8 > * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
Definition pcb_io.h:396
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 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:175
virtual const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const
Return board file description for the PCB_IO.
Definition pcb_io.h:82
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:45
Container that describes file type info.
Definition io_base.h:43