KiCad PCB EDA Suite
Loading...
Searching...
No Matches
plugin.cpp
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 (C) 2016-2020 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#include <io_mgr.h>
26#include <string_utf8_map.h>
27#include <wx/translation.h>
28
29
30#define FMT_UNIMPLEMENTED wxT( "Plugin \"%s\" does not implement the \"%s\" function." )
31#define NOT_IMPLEMENTED( aCaller ) \
32 THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, \
33 PluginName(), \
34 wxString::FromUTF8( aCaller ) ) );
35
36
37
38BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const STRING_UTF8_MAP* aProperties,
39 PROJECT* aProject, PROGRESS_REPORTER* aProgressReporter )
40{
41 NOT_IMPLEMENTED( __FUNCTION__ );
42}
43
44
46{
47 NOT_IMPLEMENTED( __FUNCTION__ );
48}
49
50void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, const STRING_UTF8_MAP* aProperties )
51{
52 // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
53 NOT_IMPLEMENTED( __FUNCTION__ );
54}
55
56
57void PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
58 bool aBestEfforts, const STRING_UTF8_MAP* aProperties )
59{
60 // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
61 NOT_IMPLEMENTED( __FUNCTION__ );
62}
63
64
65void PLUGIN::PrefetchLib( const wxString&, const STRING_UTF8_MAP* )
66{
67}
68
69
70const FOOTPRINT* PLUGIN::GetEnumeratedFootprint( const wxString& aLibraryPath,
71 const wxString& aFootprintName,
72 const STRING_UTF8_MAP* aProperties )
73{
74 // default implementation
75 return FootprintLoad( aLibraryPath, aFootprintName, false, aProperties );
76}
77
78
79bool PLUGIN::FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
80 const STRING_UTF8_MAP* aProperties )
81{
82 // default implementation
83 return FootprintLoad( aLibraryPath, aFootprintName, true, aProperties ) != nullptr;
84}
85
86
87FOOTPRINT* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
88 bool aKeepUUID, const STRING_UTF8_MAP* aProperties )
89{
90 // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
91 NOT_IMPLEMENTED( __FUNCTION__ );
92}
93
94
95void PLUGIN::FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
96 const STRING_UTF8_MAP* aProperties )
97{
98 // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
99 NOT_IMPLEMENTED( __FUNCTION__ );
100}
101
102
103void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
104 const STRING_UTF8_MAP* aProperties )
105{
106 // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
107 NOT_IMPLEMENTED( __FUNCTION__ );
108}
109
110
111void PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
112{
113 // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
114 NOT_IMPLEMENTED( __FUNCTION__ );
115}
116
117
118bool PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
119{
120 // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
121 NOT_IMPLEMENTED( __FUNCTION__ );
122}
123
124
125bool PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
126{
127 // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
128 NOT_IMPLEMENTED( __FUNCTION__ );
129}
130
131
132void PLUGIN::FootprintLibOptions( STRING_UTF8_MAP* aListToAppendTo ) const
133{
134 // disable all these in another couple of months, after everyone has seen them:
135#if 1
136 (*aListToAppendTo)["debug_level"] = UTF8( _( "Enable <b>debug</b> logging for Footprint*() "
137 "functions in this PLUGIN." ) );
138
139 (*aListToAppendTo)["read_filter_regex"] = UTF8( _( "Regular expression <b>footprint name</b> "
140 "filter." ) );
141
142 (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _( "Enable transaction logging. The "
143 "mere presence of this option "
144 "turns on the logging, no need to "
145 "set a Value." ) );
146
147 (*aListToAppendTo)["username"] = UTF8( _( "User name for <b>login</b> to some special library "
148 "server." ) );
149
150 (*aListToAppendTo)["password"] = UTF8( _( "Password for <b>login</b> to some special library "
151 "server." ) );
152#endif
153
154#if 1
155 // Suitable for a C++ to python PLUGIN::Footprint*() adapter, move it to the adapter
156 // if and when implemented.
157 (*aListToAppendTo)["python_footprint_plugin"] = UTF8( _( "Enter the python module which "
158 "implements the PLUGIN::Footprint*() "
159 "functions." ) );
160#endif
161}
162
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:270
virtual const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr)
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
Definition: plugin.cpp:70
virtual void FootprintLibCreate(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
Create a new empty footprint library at aLibraryPath empty.
Definition: plugin.cpp:111
virtual bool FootprintLibDelete(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
Delete an existing footprint library and returns true, or if library does not exist returns false,...
Definition: plugin.cpp:118
virtual void Save(const wxString &aFileName, BOARD *aBoard, const STRING_UTF8_MAP *aProperties=nullptr)
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be u...
Definition: plugin.cpp:50
virtual BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Load information from some input file format that this PLUGIN implementation knows about into either ...
Definition: plugin.cpp:38
virtual void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const STRING_UTF8_MAP *aProperties=nullptr)
Write aFootprint to an existing library located at aLibraryPath.
Definition: plugin.cpp:95
virtual std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints()
Return a container with the cached library footprints generated in the last call to Load.
Definition: plugin.cpp:45
virtual void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr)
Delete aFootprintName from the library at aLibraryPath.
Definition: plugin.cpp:103
virtual bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr)
Check for the existence of a footprint.
Definition: plugin.cpp:79
virtual FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const STRING_UTF8_MAP *aProperties=nullptr)
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PL...
Definition: plugin.cpp:87
virtual bool IsFootprintLibWritable(const wxString &aLibraryPath)
Return true if the library at aLibraryPath is writable.
Definition: plugin.cpp:125
virtual void FootprintLibOptions(STRING_UTF8_MAP *aListToAppendTo) const
Append supported PLUGIN options to aListToAppenTo along with internationalized descriptions.
Definition: plugin.cpp:132
virtual void PrefetchLib(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
If possible, prefetches the specified library (e.g.
Definition: plugin.cpp:65
virtual void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const STRING_UTF8_MAP *aProperties=nullptr)
Return a list of footprint names contained within the library at aLibraryPath.
Definition: plugin.cpp:57
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
Definition: project.h:64
A name/value tuple with unique names and optional values.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:71
#define _(s)
#define NOT_IMPLEMENTED(aCaller)
Definition: sch_plugin.cpp:29