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
28#include <config.h>
29#include <vector>
30#include <wx/arrstr.h>
31#include <i18n_utility.h>
32
33class BOARD;
34class FOOTPRINT;
35class PROJECT;
37
38// MIKE WILLIAMS TODO: convert all of the other stringly-typed IO plugin properties to use constants
40{
41// Used to control whether the stackup of the board passed into the IO plugin is preserved or not.
42// It will NOT keep the stackup from being changed in all cases, as a copper layer increase may require
43// the stackup to grow
44inline constexpr char APPEND_PRESERVE_DESTINATION_STACKUP[] = "append_preserve_destination_stackup";
45}
46
75class PCB_IO : public IO_BASE
76{
77public:
82 {
83 return IO_BASE::IO_FILE_DESC( wxEmptyString, {} );
84 }
85
89 bool IsPCB_IO() const override { return true; }
90
95 virtual bool CanReadBoard( const wxString& aFileName ) const;
96
101 virtual bool CanReadFootprint( const wxString& aFileName ) const;
102
106 virtual void SetQueryUserCallback( std::function<bool( wxString aTitle, int aIcon,
107 wxString aMessage,
108 wxString aAction )> aCallback )
109 { }
110
132 std::unique_ptr<BOARD> LoadBoard( const wxString& aFileName,
133 const std::map<std::string, UTF8>* aProperties = nullptr,
134 PROJECT* aProject = nullptr );
135
136
143 void LoadAndAppendBoard( const wxString& aFileName, BOARD& aAppendToMe,
144 const std::map<std::string, UTF8>* aProperties = nullptr, PROJECT* aProject = nullptr );
145
154 virtual std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints();
155
174 virtual void SaveBoard( const wxString& aFileName, BOARD& aBoard,
175 const std::map<std::string, UTF8>* aProperties = nullptr );
176
191 virtual void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
192 bool aBestEfforts,
193 const std::map<std::string, UTF8>* aProperties = nullptr );
194
201 virtual long long GetLibraryTimestamp( const wxString& aLibraryPath ) const = 0;
202
220 virtual std::unique_ptr<FOOTPRINT> ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
221 const std::map<std::string, UTF8>* aProperties = nullptr );
222
244 virtual std::unique_ptr<FOOTPRINT> FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
245 bool aKeepUUID = false,
246 const std::map<std::string, UTF8>* aProperties = nullptr );
247
255 virtual const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
256 const std::map<std::string, UTF8>* aProperties = nullptr );
257
264 virtual bool CachesEnumeratedFootprints() const { return false; }
265
269 virtual bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
270 const std::map<std::string, UTF8>* aProperties = nullptr );
271
288 virtual void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
289 const std::map<std::string, UTF8>* aProperties = nullptr );
290
305 virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
306 const std::map<std::string, UTF8>* aProperties = nullptr );
307
316 virtual void ClearCachedFootprints( const wxString& aLibraryPath ) {}
317
345 virtual void GetLibraryOptions( std::map<std::string, UTF8>* aListToAppendTo ) const override;
346
347 virtual ~PCB_IO()
348 {};
349
350protected:
351 PCB_IO( const wxString& aName ) :
352 IO_BASE( aName ),
353 m_board( nullptr ),
354 m_props( nullptr )
355 {}
356
364 virtual void loadBoard( const wxString& aFileName, BOARD& aBoard, bool aIsNewLoad,
365 const std::map<std::string, UTF8>* aProperties, PROJECT* aProject );
366
369
371 const std::map<std::string, UTF8>* m_props;
372};
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
IO_BASE()=delete
BOARD * m_board
The board BOARD being worked on, no ownership here.
Definition pcb_io.h:368
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:56
virtual bool CachesEnumeratedFootprints() const
Return true if GetEnumeratedFootprint() returns a borrowed pointer from an internal cache.
Definition pcb_io.h:264
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)
Registers a KIDIALOG callback for collecting info from the user.
Definition pcb_io.h:106
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PCB_IO can read the specified board file.
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 void ClearCachedFootprints(const wxString &aLibraryPath)
Clear any cached footprint data for the given library path.
Definition pcb_io.h:316
PCB_IO(const wxString &aName)
Definition pcb_io.h:351
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:89
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:347
const std::map< std::string, UTF8 > * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
Definition pcb_io.h:371
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 const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const
Returns board file description for the PCB_IO.
Definition pcb_io.h:81
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:44
Container that describes file type info.
Definition io_base.h:43