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, 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#pragma once
26
27#include <io/io_base.h>
28#include <pcb_io/pcb_io_mgr.h>
29
30#include <cstdint>
31#include <config.h>
32#include <vector>
33#include <wx/arrstr.h>
34#include <i18n_utility.h>
35
36class BOARD;
37class FOOTPRINT;
38class PROJECT;
40
69class PCB_IO : public IO_BASE
70{
71public:
76 {
77 return IO_BASE::IO_FILE_DESC( wxEmptyString, {} );
78 }
79
83 bool IsPCB_IO() const override { return true; }
84
89 virtual bool CanReadBoard( const wxString& aFileName ) const;
90
95 virtual bool CanReadFootprint( const wxString& aFileName ) const;
96
100 virtual void SetQueryUserCallback( std::function<bool( wxString aTitle, int aIcon,
101 wxString aMessage,
102 wxString aAction )> aCallback )
103 { }
104
131 virtual BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
132 const std::map<std::string, UTF8>* aProperties = nullptr,
133 PROJECT* aProject = nullptr );
134
143 virtual std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints();
144
163 virtual void SaveBoard( const wxString& aFileName, BOARD* aBoard,
164 const std::map<std::string, UTF8>* aProperties = nullptr );
165
180 virtual void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
181 bool aBestEfforts,
182 const std::map<std::string, UTF8>* aProperties = nullptr );
183
190 virtual long long GetLibraryTimestamp( const wxString& aLibraryPath ) const = 0;
191
209 virtual FOOTPRINT* ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
210 const std::map<std::string, UTF8>* aProperties = nullptr );
211
233 virtual FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
234 bool aKeepUUID = false,
235 const std::map<std::string, UTF8>* aProperties = nullptr );
236
241 virtual const FOOTPRINT* GetEnumeratedFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
242 const std::map<std::string, UTF8>* aProperties = nullptr );
243
247 virtual bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
248 const std::map<std::string, UTF8>* aProperties = nullptr );
249
266 virtual void FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
267 const std::map<std::string, UTF8>* aProperties = nullptr );
268
283 virtual void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
284 const std::map<std::string, UTF8>* aProperties = nullptr );
285
313 virtual void GetLibraryOptions( std::map<std::string, UTF8>* aListToAppendTo ) const override;
314
315 virtual ~PCB_IO()
316 {};
317
318protected:
319 PCB_IO( const wxString& aName ) :
320 IO_BASE( aName ),
321 m_board( nullptr ),
322 m_props( nullptr )
323 {}
324
327
329 const std::map<std::string, UTF8>* m_props;
330};
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
IO_BASE()=delete
BOARD * m_board
The board BOARD being worked on, no ownership here.
Definition pcb_io.h:326
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:58
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:100
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PCB_IO can read the specified board file.
Definition pcb_io.cpp:42
PCB_IO(const wxString &aName)
Definition pcb_io.h:319
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:103
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:95
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:87
bool IsPCB_IO() const override
Work-around for lack of dynamic_cast across compile units on Mac.
Definition pcb_io.h:83
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:168
virtual ~PCB_IO()
Definition pcb_io.h:315
const std::map< std::string, UTF8 > * m_props
Properties passed via Save() or Load(), no ownership, may be NULL.
Definition pcb_io.h:329
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:136
virtual std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints()
Return a container with the cached library footprints generated in the last call to Load.
Definition pcb_io.cpp:81
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:74
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:127
virtual const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const
Returns board file description for the PCB_IO.
Definition pcb_io.h:75
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:160
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:144
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:152
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
Definition project.h:65
Some functions to handle hotkeys in KiCad.
Container that describes file type info.
Definition io_base.h:43