KiCad PCB EDA Suite
Loading...
Searching...
No Matches
api_handler_fp_libraries.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 * @author Jon Evans <[email protected]>
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * 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
22
23#include <footprint.h>
25#include <pgm_base.h>
26#include <project_pcb.h>
28
29#include <api/board/board_types.pb.h>
30
31
36
37
39 const wxString& aNickname ) const
40{
41 return static_cast<FOOTPRINT_LIBRARY_ADAPTER&>( aAdapter ).GetFootprintNames( aNickname, true );
42}
43
44
45bool API_HANDLER_FP_LIBRARIES::packLibraryItem( const LIB_ID& aId, google::protobuf::Any& aOutput ) const
46{
48 static_cast<FOOTPRINT_LIBRARY_ADAPTER*>( adapterForProject( Pgm().GetSettingsManager().Prj() ) );
49
50 std::unique_ptr<FOOTPRINT> footprint( adapter->LoadFootprint( aId, false ) );
51
52 if( !footprint )
53 return false;
54
55 kiapi::board::types::Footprint definition;
56 footprint->SerializeDefinition( &definition );
57
58 aOutput.PackFrom( definition );
59 return true;
60}
LIBRARY_MANAGER_ADAPTER * adapterForProject(PROJECT &aProject) const override
std::vector< wxString > getItemNames(LIBRARY_MANAGER_ADAPTER &aAdapter, const wxString &aNickname) const override
Returns the names of all entries in the given library, or an empty vector if the library is not loade...
bool packLibraryItem(const LIB_ID &aId, google::protobuf::Any &aOutput) const override
An interface to the global shared library manager that is schematic-specific and linked to one projec...
FOOTPRINT * LoadFootprint(const wxString &aNickname, const wxString &aName, bool aKeepUUID)
Load a FOOTPRINT having aName from the library given by aNickname.
The interface used by the classes that actually can load IO plugins for the different parts of KiCad ...
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
Container for project specific data.
Definition project.h:63
PROJECT & Prj()
Definition kicad.cpp:727
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE