KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_geda.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) 2012-2020 Wayne Stambaugh <[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 * This file contains file format knowledge derived from the gEDA/pcb project:
25 *
26 * gEDA/gaf - Copyright (C) 1998-2010 Ales Hvezda
27 * Copyright (C) 1998-2016 gEDA Contributors
28 * Lepton EDA - Copyright (C) 2017-2024 Lepton EDA Contributors
29 *
30 * Both projects are licensed under the GNU General Public License v2 or later.
31 * See https://github.com/lepton-eda/lepton-eda and
32 * https://github.com/rlutz/geda-gaf
33 */
34
39
40#ifndef PCB_IO_GEDA_H_
41#define PCB_IO_GEDA_H_
42
43#include <map>
44#include <string>
45#include <vector>
46
47#include <layer_ids.h>
48#include <pcb_io/pcb_io.h>
49#include <pcb_io/pcb_io_mgr.h>
50
51class BOARD;
52class FOOTPRINT;
53class GPCB_FPL_CACHE;
54class LINE_READER;
55class NETINFO_ITEM;
56
62class PCB_IO_GEDA : public PCB_IO
63{
64public:
65 // Board-level file support
67 {
68 return IO_BASE::IO_FILE_DESC( _HKI( "gEDA / Lepton EDA PCB board file" ), { "pcb" } );
69 }
70
71 bool CanReadBoard( const wxString& aFileName ) const override;
72
73 BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
74 const std::map<std::string, UTF8>* aProperties = nullptr,
75 PROJECT* aProject = nullptr ) override;
76
77 std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints() override;
78
79 // Footprint library support
81 {
82 return IO_BASE::IO_FILE_DESC( _HKI( "gEDA / Lepton EDA PCB footprint file" ), { "fp" } );
83 }
84
86 {
87 return IO_BASE::IO_FILE_DESC( _HKI( "gEDA / Lepton EDA PCB footprint library directory" ), {}, { "fp" },
88 false );
89 }
90
91 FOOTPRINT* ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
92 const std::map<std::string, UTF8>* aProperties ) override;
93
94 void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
95 bool aBestEfforts,
96 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
97
98 FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
99 bool aKeepUUID = false,
100 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
101
102 void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
103 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
104
105 bool DeleteLibrary( const wxString& aLibraryPath,
106 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
107
108 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
109
110 bool IsLibraryWritable( const wxString& aLibraryPath ) override;
111
112 //-----</PLUGIN API>--------------------------------------------------------
113
114 PCB_IO_GEDA();
115
116 PCB_IO_GEDA( int aControlFlags );
117
118 ~PCB_IO_GEDA() override;
119
120private:
121 void validateCache( const wxString& aLibraryPath, bool checkModified = true );
122
123 const FOOTPRINT* getFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
124 const std::map<std::string, UTF8>* aProperties, bool checkModified );
125
126 void init( const std::map<std::string, UTF8>* aProperties );
127
128 friend class GPCB_FPL_CACHE;
129
130 // Board parsing helpers
131 PCB_LAYER_ID mapLayer( int aGedaLayer, const wxString& aLayerName ) const;
132
133 void parseVia( wxArrayString& aParameters, double aConvUnit );
134 FOOTPRINT* parseElement( wxArrayString& aParameters, LINE_READER* aLineReader,
135 double aConvUnit );
136 void parseLayer( wxArrayString& aParameters, LINE_READER* aLineReader, double aConvUnit );
137 void parseNetList( LINE_READER* aLineReader );
138 void parseParameters( wxArrayString& aParameterList, LINE_READER* aLineReader );
139 bool testFlags( const wxString& aFlag, long aMask, const wxChar* aName );
140
141protected:
142 wxString m_error;
144 int m_ctl;
146 wxString m_filename;
147
148 // Board import state
149 std::vector<FOOTPRINT*> m_cachedFootprints;
150 std::map<wxString, NETINFO_ITEM*> m_netMap;
152};
153
154#endif // PCB_IO_GEDA_H_
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition richio.h:66
Handle the data for a net.
Definition netinfo.h:54
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Delete aFootprintName from the library at aLibraryPath.
void parseVia(wxArrayString &aParameters, double aConvUnit)
const IO_BASE::IO_FILE_DESC GetLibraryFileDesc() const override
Get the descriptor for the individual library elements that this IO plugin operates on.
Definition pcb_io_geda.h:80
void parseNetList(LINE_READER *aLineReader)
const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override
Get the descriptor for the library container that this IO plugin operates on.
Definition pcb_io_geda.h:85
bool IsLibraryWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
Returns board file description for the PCB_IO.
Definition pcb_io_geda.h:66
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
std::map< wxString, NETINFO_ITEM * > m_netMap
bool DeleteLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Delete an existing library and returns true, or if library does not exist returns false,...
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
~PCB_IO_GEDA() override
int m_numCopperLayers
wxString m_filename
for saves only, name is in m_reader for loads
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PC...
std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints() override
Return a container with the cached library footprints generated in the last call to Load.
void init(const std::map< std::string, UTF8 > *aProperties)
GPCB_FPL_CACHE * m_cache
Footprint library cache.
bool testFlags(const wxString &aFlag, long aMask, const wxChar *aName)
FOOTPRINT * parseElement(wxArrayString &aParameters, LINE_READER *aLineReader, double aConvUnit)
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
void parseParameters(wxArrayString &aParameterList, LINE_READER *aLineReader)
void parseLayer(wxArrayString &aParameters, LINE_READER *aLineReader, double aConvUnit)
std::vector< FOOTPRINT * > m_cachedFootprints
LINE_READER * m_reader
no ownership here.
friend class GPCB_FPL_CACHE
PCB_LAYER_ID mapLayer(int aGedaLayer, const wxString &aLayerName) const
FOOTPRINT * ImportFootprint(const wxString &aFootprintPath, wxString &aFootprintNameOut, const std::map< std::string, UTF8 > *aProperties) override
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
const FOOTPRINT * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties, bool checkModified)
wxString m_error
for throwing exceptions
PCB_IO(const wxString &aName)
Definition pcb_io.h:337
Container for project specific data.
Definition project.h:65
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
#define _HKI(x)
Definition page_info.cpp:44
Container that describes file type info.
Definition io_base.h:43