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, see <https://www.gnu.org/licenses/>.
19 *
20 * This file contains file format knowledge derived from the gEDA/pcb project:
21 *
22 * gEDA/gaf - Copyright (C) 1998-2010 Ales Hvezda
23 * Copyright (C) 1998-2016 gEDA Contributors
24 * Lepton EDA - Copyright (C) 2017-2024 Lepton EDA Contributors
25 *
26 * Both projects are licensed under the GNU General Public License v2 or later.
27 * See https://github.com/lepton-eda/lepton-eda and
28 * https://github.com/rlutz/geda-gaf
29 */
30
35
36#ifndef PCB_IO_GEDA_H_
37#define PCB_IO_GEDA_H_
38
39#include <map>
40#include <string>
41#include <vector>
42
43#include <layer_ids.h>
44#include <pcb_io/pcb_io.h>
45#include <pcb_io/pcb_io_mgr.h>
46
47class BOARD;
48class FOOTPRINT;
49class GPCB_FPL_CACHE;
50class LINE_READER;
51class NETINFO_ITEM;
52
58class PCB_IO_GEDA : public PCB_IO
59{
60public:
61 // Board-level file support
63 {
64 return IO_BASE::IO_FILE_DESC( _HKI( "gEDA / Lepton EDA PCB board file" ), { "pcb" } );
65 }
66
67 bool CanReadBoard( const wxString& aFileName ) const override;
68
69 BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
70 const std::map<std::string, UTF8>* aProperties = nullptr,
71 PROJECT* aProject = nullptr ) override;
72
73 std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints() override;
74
75 // Footprint library support
77 {
78 return IO_BASE::IO_FILE_DESC( _HKI( "gEDA / Lepton EDA PCB footprint file" ), { "fp" } );
79 }
80
82 {
83 return IO_BASE::IO_FILE_DESC( _HKI( "gEDA / Lepton EDA PCB footprint library directory" ), {}, { "fp" },
84 false );
85 }
86
87 FOOTPRINT* ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
88 const std::map<std::string, UTF8>* aProperties ) override;
89
90 void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
91 bool aBestEfforts,
92 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
93
94 FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
95 bool aKeepUUID = false,
96 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
97
98 void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
99 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
100
101 bool DeleteLibrary( const wxString& aLibraryPath,
102 const std::map<std::string, UTF8>* aProperties = nullptr ) override;
103
104 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
105
106 bool IsLibraryWritable( const wxString& aLibraryPath ) override;
107
108 //-----</PLUGIN API>--------------------------------------------------------
109
110 PCB_IO_GEDA();
111
112 PCB_IO_GEDA( int aControlFlags );
113
114 ~PCB_IO_GEDA() override;
115
116private:
117 void validateCache( const wxString& aLibraryPath, bool checkModified = true );
118
119 const FOOTPRINT* getFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
120 const std::map<std::string, UTF8>* aProperties, bool checkModified );
121
122 void init( const std::map<std::string, UTF8>* aProperties );
123
124 friend class GPCB_FPL_CACHE;
125
126 // Board parsing helpers
127 PCB_LAYER_ID mapLayer( int aGedaLayer, const wxString& aLayerName ) const;
128
129 void parseVia( wxArrayString& aParameters, double aConvUnit );
130 FOOTPRINT* parseElement( wxArrayString& aParameters, LINE_READER* aLineReader,
131 double aConvUnit );
132 void parseLayer( wxArrayString& aParameters, LINE_READER* aLineReader, double aConvUnit );
133 void parseNetList( LINE_READER* aLineReader );
134 void parseParameters( wxArrayString& aParameterList, LINE_READER* aLineReader );
135 bool testFlags( const wxString& aFlag, long aMask, const wxChar* aName );
136
137protected:
138 wxString m_error;
140 int m_ctl;
142 wxString m_filename;
143
144 // Board import state
145 std::vector<FOOTPRINT*> m_cachedFootprints;
146 std::map<wxString, NETINFO_ITEM*> m_netMap;
148};
149
150#endif // PCB_IO_GEDA_H_
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition richio.h:62
Handle the data for a net.
Definition netinfo.h:46
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:76
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:81
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:62
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:342
Container for project specific data.
Definition project.h:62
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
#define _HKI(x)
Definition page_info.cpp:40
Container that describes file type info.
Definition io_base.h:43