KiCad PCB EDA Suite
wildcards_and_files_ext.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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
31 
32 
33 wxString formatWildcardExt( const wxString& aWildcard )
34 {
35  wxString wc;
36 #if defined( __WXGTK__ )
37 
38  for( auto ch : aWildcard )
39  {
40  if( wxIsalpha( ch ) )
41  wc += wxString::Format( "[%c%c]", wxTolower( ch ), wxToupper( ch ) );
42  else
43  wc += ch;
44  }
45 
46  return wc;
47 #else
48  wc = aWildcard;
49 
50  return wc;
51 #endif
52 }
53 
54 
55 wxString AddFileExtListToFilter( const std::vector<std::string>& aExts )
56 {
57  if( aExts.size() == 0 )
58  {
59  // The "all files" wildcard is different on different systems
60  wxString filter;
61  filter << " (" << wxFileSelectorDefaultWildcardStr << ")|"
62  << wxFileSelectorDefaultWildcardStr;
63  return filter;
64  }
65 
66  wxString files_filter = " (";
67 
68  // Add extensions to the info message:
69  for( const auto& ext : aExts )
70  {
71  files_filter << " *." << ext;
72  }
73 
74  files_filter << ")|*.";
75 
76  // Add extensions to the filter list, using a formated string (GTK specific):
77  bool first = true;
78  for( const auto& ext : aExts )
79  {
80  if( !first )
81  files_filter << ";*.";
82 
83  first = false;
84 
85  files_filter << formatWildcardExt( ext );
86  }
87 
88  return files_filter;
89 }
90 
91 
92 const std::string SchematicSymbolFileExtension( "sym" );
93 const std::string SchematicLibraryFileExtension( "lib" );
94 
95 const std::string VrmlFileExtension( "wrl" );
96 
97 const std::string ProjectFileExtension( "pro" );
98 const std::string SchematicFileExtension( "sch" );
99 const std::string NetlistFileExtension( "net" );
100 const std::string ComponentFileExtension( "cmp" );
101 const std::string GerberFileExtension( "gbr" );
102 const std::string GerberJobFileExtension( "gbrjob" );
103 const std::string HtmlFileExtension( "html" );
104 const std::string EquFileExtension( "equ" );
105 
106 const std::string LegacyPcbFileExtension( "brd" );
107 const std::string KiCadPcbFileExtension( "kicad_pcb" );
108 const std::string PageLayoutDescrFileExtension( "kicad_wks" );
109 
110 const std::string PdfFileExtension( "pdf" );
111 const std::string MacrosFileExtension( "mcr" );
112 const std::string DrillFileExtension( "drl" );
113 const std::string SVGFileExtension( "svg" );
114 const std::string ReportFileExtension( "rpt" );
115 const std::string FootprintPlaceFileExtension( "pos" );
116 const std::string KiCadLib3DShapesPathExtension( "3dshapes" );
117 
118 const std::string KiCadFootprintLibPathExtension( "pretty" );
119 const std::string LegacyFootprintLibPathExtension( "mod" );
120 const std::string EagleFootprintLibPathExtension( "lbr" );
121 
122 const std::string KiCadFootprintFileExtension( "kicad_mod" );
123 const std::string GedaPcbFootprintLibFileExtension( "fp" );
124 const std::string SpecctraDsnFileExtension( "dsn" );
125 const std::string IpcD356FileExtension( "d356" );
126 
127 const std::string PngFileExtension( "png" );
128 const std::string JpegFileExtension( "jpg" );
129 
130 
132 {
133  return _( "All files" ) + AddFileExtListToFilter( {} );
134 }
135 
136 
138 {
139  return _( "KiCad drawing symbol files" ) + AddFileExtListToFilter( { "sym" } );
140 }
141 
142 
144 {
145  return _( "KiCad symbol library files" ) + AddFileExtListToFilter( { "lib" } );
146 }
147 
148 
150 {
151  return _( "KiCad project files" ) + AddFileExtListToFilter( { "pro" } );
152 }
153 
154 
156 {
157  return _( "KiCad schematic files" ) + AddFileExtListToFilter( { "sch" } );
158 }
159 
160 
162 {
163  return _( "Eagle XML schematic files" ) + AddFileExtListToFilter( { "sch" } );
164 }
165 
166 
168 {
169  return _( "Eagle XML files" ) + AddFileExtListToFilter( { "sch", "brd" } );
170 }
171 
172 
174 {
175  return _( "KiCad netlist files" ) + AddFileExtListToFilter( { "net" } );
176 }
177 
178 
180 {
181  return _( "Gerber files" ) + AddFileExtListToFilter( { "pho" } );
182 }
183 
184 
186 {
187  return _( "KiCad printed circuit board files" ) + AddFileExtListToFilter( { "brd" } );
188 }
189 
190 
192 {
193  return _( "Eagle ver. 6.x XML PCB files" ) + AddFileExtListToFilter( { "brd" } );
194 }
195 
196 
198 {
199  return _( "P-Cad 200x ASCII PCB files" ) + AddFileExtListToFilter( { "pcb" } );
200 }
201 
202 
203 wxString PcbFileWildcard()
204 {
205  return _( "KiCad printed circuit board files" ) + AddFileExtListToFilter( { "kicad_pcb" } );
206 }
207 
208 
210 {
211  return _( "KiCad footprint files" ) + AddFileExtListToFilter( { "kicad_mod" } );
212 }
213 
214 
216 {
217  return _( "KiCad footprint library paths" ) + AddFileExtListToFilter( { "pretty" } );
218 }
219 
220 
222 {
223  return _( "Legacy footprint library files" ) + AddFileExtListToFilter( { "mod" } );
224 }
225 
226 
228 {
229  return _( "Eagle ver. 6.x XML library files" ) + AddFileExtListToFilter( { "lbr" } );
230 }
231 
232 
234 {
235  return _( "Geda PCB footprint library files" ) + AddFileExtListToFilter( { "fp" } );
236 }
237 
238 
240 {
241  return _( "Page layout design files" ) + AddFileExtListToFilter( { "kicad_wks" } );
242 }
243 
244 
245 // Wildcard for cvpcb component to footprint link file
247 {
248  return _( "KiCad symbol footprint link files" ) + AddFileExtListToFilter( { "cmp" } );
249 }
250 
251 
252 // Wildcard for reports and fabrication documents
254 {
255  return _( "Drill files" ) + AddFileExtListToFilter( { "drl", "nc", "xnc" } );
256 }
257 
258 
259 wxString SVGFileWildcard()
260 {
261  return _( "SVG files" ) + AddFileExtListToFilter( { "svg" } );
262 }
263 
264 
266 {
267  return _( "HTML files" ) + AddFileExtListToFilter( { "htm", "html" } );
268 }
269 
270 
271 wxString CsvFileWildcard()
272 {
273  return _( "CSV Files" ) + AddFileExtListToFilter( { "csv" } );
274 }
275 
276 
277 wxString PdfFileWildcard()
278 {
279  return _( "Portable document format files" ) + AddFileExtListToFilter( { "pdf" } );
280 }
281 
282 
283 wxString PSFileWildcard()
284 {
285  return _( "PostScript files" ) + AddFileExtListToFilter( { "ps" } );
286 }
287 
288 
290 {
291  return _( "Report files" ) + AddFileExtListToFilter( { "rpt" } );
292 }
293 
294 
296 {
297  return _( "Footprint place files" ) + AddFileExtListToFilter( { "pos" } );
298 }
299 
300 
302 {
303  return _( "VRML and X3D files" ) + AddFileExtListToFilter( { "wrl", "x3d" } );
304 }
305 
306 
308 {
309  return _( "IDFv3 footprint files" ) + AddFileExtListToFilter( { "idf" } );
310 }
311 
312 
314 {
315  return _( "Text files" ) + AddFileExtListToFilter( { "txt" } );
316 }
317 
318 
320 {
321  return _( "Legacy footprint export files" ) + AddFileExtListToFilter( { "emp" } );
322 }
323 
324 
325 wxString ErcFileWildcard()
326 {
327  return _( "Electronic rule check file" ) + AddFileExtListToFilter( { "erc" } );
328 }
329 
330 
332 {
333  return _( "Spice library file" ) + AddFileExtListToFilter( { "lib" } );
334 }
335 
336 
338 {
339  return _( "SPICE netlist file" ) + AddFileExtListToFilter( { "cir" } );
340 }
341 
342 
344 {
345  return _( "CadStar netlist file" ) + AddFileExtListToFilter( { "frp" } );
346 }
347 
348 
349 wxString EquFileWildcard()
350 {
351  return _( "Symbol footprint association files" ) + AddFileExtListToFilter( { "equ" } );
352 }
353 
354 
355 wxString ZipFileWildcard()
356 {
357  return _( "Zip file" ) + AddFileExtListToFilter( { "zip" } );
358 }
359 
360 
362 {
363  return _( "GenCAD 1.4 board files" ) + AddFileExtListToFilter( { "cad" } );
364 }
365 
366 
367 wxString DxfFileWildcard()
368 {
369  return _( "DXF Files" ) + AddFileExtListToFilter( { "dxf" } );
370 }
371 
372 
374 {
375  return _( "Gerber job file" ) + AddFileExtListToFilter( { "gbrjob" } );
376 }
377 
378 
380 {
381  return _( "Specctra DSN file" ) + AddFileExtListToFilter( { "dsn" } );
382 }
383 
384 
386 {
387  return _( "IPC-D-356 Test Files" ) + AddFileExtListToFilter( { "d356" } );
388 }
389 
390 
392 {
393  return _( "Workbook file" ) + AddFileExtListToFilter( { "wbk" } );
394 }
395 
396 
397 wxString PngFileWildcard()
398 {
399  return _( "PNG file" ) + AddFileExtListToFilter( { "png" } );
400 }
401 
402 
404 {
405  return _( "Jpeg file" ) + AddFileExtListToFilter( { "jpg", "jpeg" } );
406 }
wxString GerberFileWildcard()
wxString SchematicSymbolFileWildcard()
const std::string GerberFileExtension("gbr")
wxString PageLayoutDescrFileWildcard()
const std::string ComponentFileExtension("cmp")
const std::string KiCadFootprintFileExtension("kicad_mod")
wxString SchematicFileWildcard()
wxString EaglePcbFileWildcard()
wxString EagleFootprintLibPathWildcard()
wxString SVGFileWildcard()
wxString ComponentFileWildcard()
wxString SpiceNetlistFileWildcard()
wxString PdfFileWildcard()
wxString DxfFileWildcard()
const std::string KiCadPcbFileExtension("kicad_pcb")
wxString SchematicLibraryFileWildcard()
wxString ZipFileWildcard()
wxString CsvFileWildcard()
wxString JpegFileWildcard()
const std::string PngFileExtension("png")
wxString LegacyFootprintLibPathWildcard()
wxString AllFilesWildcard()
wxString EquFileWildcard()
const std::string LegacyFootprintLibPathExtension("mod")
const std::string KiCadLib3DShapesPathExtension("3dshapes")
3D shapes default libpath
const std::string SchematicLibraryFileExtension("lib")
wxString LegacyPcbFileWildcard()
const std::string IpcD356FileExtension("d356")
wxString PSFileWildcard()
const std::string SVGFileExtension("svg")
const std::string PageLayoutDescrFileExtension("kicad_wks")
wxString GencadFileWildcard()
wxString ReportFileWildcard()
const std::string SchematicSymbolFileExtension("sym")
const std::string HtmlFileExtension("html")
wxString NetlistFileWildcard()
wxString HtmlFileWildcard()
const std::string DrillFileExtension("drl")
wxString ModLegacyExportFileWildcard()
Definition of file extensions used in Kicad.
wxString formatWildcardExt(const wxString &aWildcard)
Format wildcard extension to support case sensitive file dialogs.
const std::string VrmlFileExtension("wrl")
const std::string LegacyPcbFileExtension("brd")
const std::string MacrosFileExtension("mcr")
#define _(s)
wxString DrillFileWildcard()
wxString IpcD356FileWildcard()
wxString PngFileWildcard()
const std::string KiCadFootprintLibPathExtension("pretty")
KICAD PLUGIN libpath.
const std::string ReportFileExtension("rpt")
wxString ProjectFileWildcard()
const std::string GerberJobFileExtension("gbrjob")
const std::string GedaPcbFootprintLibFileExtension("fp")
wxString ErcFileWildcard()
wxString KiCadFootprintLibPathWildcard()
wxString GerberJobFileWildcard()
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
wxString EagleSchematicFileWildcard()
wxString FootprintPlaceFileWildcard()
const std::string SchematicFileExtension("sch")
wxString Shapes3DFileWildcard()
wxString SpiceLibraryFileWildcard()
const std::string JpegFileExtension("jpg")
const std::string PdfFileExtension("pdf")
wxString PcbFileWildcard()
const std::string SpecctraDsnFileExtension("dsn")
wxString TextFileWildcard()
wxString SpecctraDsnFileWildcard()
wxString IDF3DFileWildcard()
const std::string NetlistFileExtension("net")
const std::string EquFileExtension("equ")
wxString EagleFilesWildcard()
wxString WorkbookFileWildcard()
const std::string ProjectFileExtension("pro")
wxString PCadPcbFileWildcard()
const std::string EagleFootprintLibPathExtension("lbr")
wxString KiCadFootprintLibFileWildcard()
wxString GedaPcbFootprintLibFileWildcard()
wxString CadstarNetlistFileWildcard()
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
const std::string FootprintPlaceFileExtension("pos")