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 
50 static wxString formatWildcardExt( const wxString& aWildcard )
51 {
52  wxString wc;
53 #if defined( __WXGTK__ )
54 
55  for( auto ch : aWildcard )
56  {
57  if( wxIsalpha( ch ) )
58  wc += wxString::Format( "[%c%c]", wxTolower( ch ), wxToupper( ch ) );
59  else
60  wc += ch;
61  }
62 
63  return wc;
64 #else
65  wc = aWildcard;
66 
67  return wc;
68 #endif
69 }
70 
71 wxString AddFileExtListToFilter( const std::vector<std::string>& aExts )
72 {
73  if( aExts.size() == 0 )
74  {
75  // The "all files" wildcard is different on different systems
76  wxString filter;
77  filter << " (" << wxFileSelectorDefaultWildcardStr << ")|"
78  << wxFileSelectorDefaultWildcardStr;
79  return filter;
80  }
81 
82  wxString files_filter = " (";
83 
84  // Add extensions to the info message:
85  for( const auto& ext : aExts )
86  {
87  files_filter << " *." << ext;
88  }
89 
90  files_filter << ")|*.";
91 
92  // Add extensions to the filter list, using a formated string (GTK specific):
93  bool first = true;
94  for( const auto& ext : aExts )
95  {
96  if( !first )
97  files_filter << ";*.";
98 
99  first = false;
100 
101  files_filter << formatWildcardExt( ext );
102  }
103 
104  return files_filter;
105 }
106 
107 
108 const std::string SchematicSymbolFileExtension( "sym" );
109 const std::string SchematicLibraryFileExtension( "lib" );
110 const std::string SchematicBackupFileExtension( "bak" );
111 
112 const std::string VrmlFileExtension( "wrl" );
113 
114 const std::string ProjectFileExtension( "pro" );
115 const std::string SchematicFileExtension( "sch" );
116 const std::string NetlistFileExtension( "net" );
117 const std::string ComponentFileExtension( "cmp" );
118 const std::string GerberFileExtension( "gbr" );
119 const std::string GerberJobFileExtension( "gbrjob" );
120 const std::string HtmlFileExtension( "html" );
121 
122 const std::string LegacyPcbFileExtension( "brd" );
123 const std::string KiCadPcbFileExtension( "kicad_pcb" );
124 const std::string PageLayoutDescrFileExtension( "kicad_wks" );
125 
126 const std::string PdfFileExtension( "pdf" );
127 const std::string MacrosFileExtension( "mcr" );
128 const std::string DrillFileExtension( "drl" );
129 const std::string SVGFileExtension( "svg" );
130 const std::string ReportFileExtension( "rpt" );
131 const std::string FootprintPlaceFileExtension( "pos" );
132 const std::string KiCadLib3DShapesPathExtension( "3dshapes" );
133 
134 const std::string KiCadFootprintLibPathExtension( "pretty" );
135 const std::string LegacyFootprintLibPathExtension( "mod" );
136 const std::string EagleFootprintLibPathExtension( "lbr" );
137 
138 const std::string KiCadFootprintFileExtension( "kicad_mod" );
139 const std::string GedaPcbFootprintLibFileExtension( "fp" );
140 const std::string SpecctraDsnFileExtension( "dsn" );
141 const std::string IpcD356FileExtension( "d356" );
142 
143 const std::string PngFileExtension( "png" );
144 const std::string JpegFileExtension( "jpg" );
145 
146 
148 {
149  return _( "All files" ) + AddFileExtListToFilter( {} );
150 }
151 
152 
154 {
155  return _( "KiCad drawing symbol files" ) + AddFileExtListToFilter( { "sym" } );
156 }
157 
158 
160 {
161  return _( "KiCad symbol library files" ) + AddFileExtListToFilter( { "lib" } );
162 }
163 
164 
166 {
167  return _( "KiCad project files" ) + AddFileExtListToFilter( { "pro" } );
168 }
169 
170 
172 {
173  return _( "KiCad schematic files" ) + AddFileExtListToFilter( { "sch" } );
174 }
175 
176 
178 {
179  return _( "Eagle XML schematic files" ) + AddFileExtListToFilter( { "sch" } );
180 }
181 
182 
184 {
185  return _( "Eagle XML files" ) + AddFileExtListToFilter( { "sch", "brd" } );
186 }
187 
188 
190 {
191  return _( "KiCad netlist files" ) + AddFileExtListToFilter( { "net" } );
192 }
193 
194 
196 {
197  return _( "Gerber files" ) + AddFileExtListToFilter( { "pho" } );
198 }
199 
200 
202 {
203  return _( "KiCad printed circuit board files" ) + AddFileExtListToFilter( { "brd" } );
204 }
205 
206 
208 {
209  return _( "Eagle ver. 6.x XML PCB files" ) + AddFileExtListToFilter( { "brd" } );
210 }
211 
212 
214 {
215  return _( "P-Cad 200x ASCII PCB files" ) + AddFileExtListToFilter( { "pcb" } );
216 }
217 
218 
219 wxString PcbFileWildcard()
220 {
221  return _( "KiCad printed circuit board files" ) + AddFileExtListToFilter( { "kicad_pcb" } );
222 }
223 
224 
226 {
227  return _( "KiCad footprint files" ) + AddFileExtListToFilter( { "kicad_mod" } );
228 }
229 
230 
232 {
233  return _( "KiCad footprint library paths" ) + AddFileExtListToFilter( { "pretty" } );
234 }
235 
236 
238 {
239  return _( "Legacy footprint library files" ) + AddFileExtListToFilter( { "mod" } );
240 }
241 
242 
244 {
245  return _( "Eagle ver. 6.x XML library files" ) + AddFileExtListToFilter( { "lbr" } );
246 }
247 
248 
250 {
251  return _( "Geda PCB footprint library files" ) + AddFileExtListToFilter( { "fp" } );
252 }
253 
254 
256 {
257  return _( "Page layout design files" ) + AddFileExtListToFilter( { "kicad_wks" } );
258 }
259 
260 
261 // Wildcard for cvpcb component to footprint link file
263 {
264  return _( "KiCad symbol footprint link files" ) + AddFileExtListToFilter( { "cmp" } );
265 }
266 
267 
268 // Wildcard for reports and fabrication documents
270 {
271  return _( "Drill files" ) + AddFileExtListToFilter( { "drl", "nc", "xnc" } );
272 }
273 
274 
275 wxString SVGFileWildcard()
276 {
277  return _( "SVG files" ) + AddFileExtListToFilter( { "svg" } );
278 }
279 
280 
282 {
283  return _( "HTML files" ) + AddFileExtListToFilter( { "htm", "html" } );
284 }
285 
286 
287 wxString CsvFileWildcard()
288 {
289  return _( "CSV Files" ) + AddFileExtListToFilter( { "csv" } );
290 }
291 
292 
293 wxString PdfFileWildcard()
294 {
295  return _( "Portable document format files" ) + AddFileExtListToFilter( { "pdf" } );
296 }
297 
298 
299 wxString PSFileWildcard()
300 {
301  return _( "PostScript files" ) + AddFileExtListToFilter( { "ps" } );
302 }
303 
304 
306 {
307  return _( "Report files" ) + AddFileExtListToFilter( { "rpt" } );
308 }
309 
310 
312 {
313  return _( "Footprint place files" ) + AddFileExtListToFilter( { "pos" } );
314 }
315 
316 
318 {
319  return _( "VRML and X3D files" ) + AddFileExtListToFilter( { "wrl", "x3d" } );
320 }
321 
322 
324 {
325  return _( "IDFv3 footprint files" ) + AddFileExtListToFilter( { "idf" } );
326 }
327 
328 
330 {
331  return _( "Text files" ) + AddFileExtListToFilter( { "txt" } );
332 }
333 
334 
336 {
337  return _( "Legacy footprint export files" ) + AddFileExtListToFilter( { "emp" } );
338 }
339 
340 
341 wxString ErcFileWildcard()
342 {
343  return _( "Electronic rule check file" ) + AddFileExtListToFilter( { "erc" } );
344 }
345 
346 
348 {
349  return _( "Spice library file" ) + AddFileExtListToFilter( { "lib" } );
350 }
351 
352 
354 {
355  return _( "SPICE netlist file" ) + AddFileExtListToFilter( { "cir" } );
356 }
357 
358 
360 {
361  return _( "CadStar netlist file" ) + AddFileExtListToFilter( { "frp" } );
362 }
363 
364 
365 wxString EquFileWildcard()
366 {
367  return _( "Symbol footprint association files" ) + AddFileExtListToFilter( { "equ" } );
368 }
369 
370 
371 wxString ZipFileWildcard()
372 {
373  return _( "Zip file" ) + AddFileExtListToFilter( { "zip" } );
374 }
375 
376 
378 {
379  return _( "GenCAD 1.4 board files" ) + AddFileExtListToFilter( { "cad" } );
380 }
381 
382 
383 wxString DxfFileWildcard()
384 {
385  return _( "DXF Files" ) + AddFileExtListToFilter( { "dxf" } );
386 }
387 
388 
390 {
391  return _( "Gerber job file" ) + AddFileExtListToFilter( { "gbrjob" } );
392 }
393 
394 
396 {
397  return _( "Specctra DSN file" ) + AddFileExtListToFilter( { "dsn" } );
398 }
399 
400 
402 {
403  return _( "IPC-D-356 Test Files" ) + AddFileExtListToFilter( { "d356" } );
404 }
405 
406 
408 {
409  return _( "Workbook file" ) + AddFileExtListToFilter( { "wbk" } );
410 }
411 
412 
413 wxString PngFileWildcard()
414 {
415  return _( "PNG file" ) + AddFileExtListToFilter( { "png" } );
416 }
417 
418 
420 {
421  return _( "Jpeg file" ) + AddFileExtListToFilter( { "jpg", "jpeg" } );
422 }
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()
static wxString formatWildcardExt(const wxString &aWildcard)
Format wildcard extension to support case sensitive file dialogs.
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.
const std::string VrmlFileExtension("wrl")
const std::string LegacyPcbFileExtension("brd")
const std::string MacrosFileExtension("mcr")
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()
const std::string SchematicBackupFileExtension("bak")
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")
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")