KiCad PCB EDA Suite
gerbview/files.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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2004-2019 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
25#include <wx/debug.h>
26#include <wx/filedlg.h>
27#include <wx/wfstream.h>
28#include <wx/zipstrm.h>
29#include <reporter.h>
31#include <gerbview_frame.h>
32#include <gerbview_id.h>
33#include <gerber_file_image.h>
35#include <excellon_image.h>
37#include <view/view.h>
40#include <tool/tool_manager.h>
41
42// HTML Messages used more than one time:
43#define MSG_NO_MORE_LAYER _( "<b>No more available layers</b> in GerbView to load files" )
44#define MSG_NOT_LOADED _( "<b>Not loaded:</b> <i>%s</i>" )
45#define MSG_OOM _( "<b>Memory was exhausted reading:</b> <i>%s</i>" )
46
47
48void GERBVIEW_FRAME::OnGbrFileHistory( wxCommandEvent& event )
49{
50 wxString fn;
51
52 fn = GetFileFromHistory( event.GetId(), _( "Gerber files" ) );
53
54 if( !fn.IsEmpty() )
55 {
56 LoadGerberFiles( fn );
57 }
58}
59
60void GERBVIEW_FRAME::OnClearGbrFileHistory( wxCommandEvent& aEvent )
61{
63}
64
65
66void GERBVIEW_FRAME::OnDrlFileHistory( wxCommandEvent& event )
67{
68 wxString fn;
69
70 fn = GetFileFromHistory( event.GetId(), _( "Drill files" ), &m_drillFileHistory );
71
72 if( !fn.IsEmpty() )
73 {
75 }
76}
77
78
79void GERBVIEW_FRAME::OnClearDrlFileHistory( wxCommandEvent& aEvent )
80{
82}
83
84
85void GERBVIEW_FRAME::OnZipFileHistory( wxCommandEvent& event )
86{
87 wxString filename;
88 filename = GetFileFromHistory( event.GetId(), _( "Zip files" ), &m_zipFileHistory );
89
90 if( !filename.IsEmpty() )
91 {
92 LoadZipArchiveFile( filename );
93 }
94}
95
96
97void GERBVIEW_FRAME::OnClearZipFileHistory( wxCommandEvent& aEvent )
98{
100}
101
102
103void GERBVIEW_FRAME::OnJobFileHistory( wxCommandEvent& event )
104{
105 wxString filename = GetFileFromHistory( event.GetId(), _( "Job files" ), &m_jobFileHistory );
106
107 if( !filename.IsEmpty() )
108 LoadGerberJobFile( filename );
109}
110
111
112void GERBVIEW_FRAME::OnClearJobFileHistory( wxCommandEvent& aEvent )
113{
115}
116
117
118bool GERBVIEW_FRAME::LoadFileOrShowDialog( const wxString& aFileName,
119 const wxString& dialogFiletypes,
120 const wxString& dialogTitle, const int filetype )
121{
122 static int lastGerberFileWildcard = 0;
123 wxArrayString filenamesList;
124 wxFileName filename = aFileName;
125 wxString currentPath;
126
127 if( !filename.IsOk() )
128 {
129 // Use the current working directory if the file name path does not exist.
130 if( filename.DirExists() )
131 currentPath = filename.GetPath();
132 else
133 {
134 currentPath = m_mruPath;
135
136 // On wxWidgets 3.1 (bug?) the path in wxFileDialog is ignored when
137 // finishing by the dir separator. Remove it if any:
138 if( currentPath.EndsWith( '\\' ) || currentPath.EndsWith( '/' ) )
139 currentPath.RemoveLast();
140 }
141
142 wxFileDialog dlg( this, dialogTitle, currentPath, filename.GetFullName(), dialogFiletypes,
143 wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE | wxFD_CHANGE_DIR );
144 dlg.SetFilterIndex( lastGerberFileWildcard );
145
146 if( dlg.ShowModal() == wxID_CANCEL )
147 return false;
148
149 lastGerberFileWildcard = dlg.GetFilterIndex();
150 dlg.GetPaths( filenamesList );
151 m_mruPath = currentPath = dlg.GetDirectory();
152 }
153 else
154 {
155 filenamesList.Add( aFileName );
156 currentPath = filename.GetPath();
157 m_mruPath = currentPath;
158 }
159
160 // Set the busy cursor
161 wxBusyCursor wait;
162
163 bool isFirstFile = GetImagesList()->GetLoadedImageCount() == 0;
164
165 std::vector<int> fileTypesVec( filenamesList.Count(), filetype );
166 bool success = LoadListOfGerberAndDrillFiles( currentPath, filenamesList, &fileTypesVec );
167
168 // Auto zoom / sort is only applied when no other files have been loaded
169 if( isFirstFile )
170 {
172 Zoom_Automatique( false );
173 }
174
175 return success;
176}
177
178
179bool GERBVIEW_FRAME::LoadAutodetectedFiles( const wxString& aFileName )
180{
181 // 2 = autodetect files
182 return LoadFileOrShowDialog( aFileName, AllFilesWildcard(), _( "Open Autodetected File(s)" ),
183 2 );
184}
185
186
187bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFileName )
188{
189 wxString filetypes;
190 wxFileName filename = aFileName;
191
192 /* Standard gerber filetypes
193 * (See http://en.wikipedia.org/wiki/Gerber_File)
194 * The .gbr (.pho in legacy files) extension is the default used in Pcbnew; however
195 * there are a lot of other extensions used for gerber files. Because the first letter
196 * is usually g, we accept g* as extension.
197 * (Mainly internal copper layers do not have specific extension, and filenames are like
198 * *.g1, *.g2 *.gb1 ...)
199 * Now (2014) Ucamco (the company which manages the Gerber format) encourages use of .gbr
200 * only and the Gerber X2 file format.
201 */
202 filetypes = _( "Gerber files" ) + AddFileExtListToFilter( { "G*", "PHO" } ) + wxT( "|" );
203
204 /* Special gerber filetypes */
205 filetypes += _( "Top layer" ) + AddFileExtListToFilter( { "GTL" } ) + wxT( "|" );
206 filetypes += _( "Bottom layer" ) + AddFileExtListToFilter( { "GBL" } ) + wxT( "|" );
207 filetypes += _( "Bottom solder resist" ) + AddFileExtListToFilter( { "GBS" } ) + wxT( "|" );
208 filetypes += _( "Top solder resist" ) + AddFileExtListToFilter( { "GTS" } ) + wxT( "|" );
209 filetypes += _( "Bottom overlay" ) + AddFileExtListToFilter( { "GBO" } ) + wxT( "|" );
210 filetypes += _( "Top overlay" ) + AddFileExtListToFilter( { "GTO" } ) + wxT( "|" );
211 filetypes += _( "Bottom paste" ) + AddFileExtListToFilter( { "GBP" } ) + wxT( "|" );
212 filetypes += _( "Top paste" ) + AddFileExtListToFilter( { "GTP" } ) + wxT( "|" );
213 filetypes += _( "Keep-out layer" ) + AddFileExtListToFilter( { "GKO" } ) + wxT( "|" );
214 filetypes += _( "Mechanical layers" )
216 { "GM1", "GM2", "GM3", "GM4", "GM5", "GM6", "GM7", "GM8", "GM9" } )
217 + wxT( "|" );
218 filetypes += _( "Top Pad Master" ) + AddFileExtListToFilter( { "GPT" } ) + wxT( "|" );
219 filetypes += _( "Bottom Pad Master" ) + AddFileExtListToFilter( { "GPB" } ) + wxT( "|" );
220
221 // All filetypes
222 filetypes += AllFilesWildcard();
223
224 // 0 = gerber files
225 return LoadFileOrShowDialog( aFileName, filetypes, _( "Open Gerber File(s)" ), 0 );
226}
227
228
229bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFileName )
230{
231 wxString filetypes = DrillFileWildcard();
232 filetypes << wxT( "|" );
233 filetypes += AllFilesWildcard();
234
235 // 1 = drill files
236 return LoadFileOrShowDialog( aFileName, filetypes, _( "Open NC (Excellon) Drill File(s)" ), 1 );
237}
238
239
241 const wxArrayString& aFilenameList,
242 std::vector<int>* aFileType )
243{
244 wxCHECK_MSG( aFilenameList.Count() == aFileType->size(), false,
245 "Mismatch in file names and file types count" );
246
247 wxFileName filename;
248
249 // Read gerber files: each file is loaded on a new GerbView layer
250 bool success = true;
251 int layer = GetActiveLayer();
252 int firstLoadedLayer = NO_AVAILABLE_LAYERS;
254
255 // Manage errors when loading files
256 wxString msg;
257 WX_STRING_REPORTER reporter( &msg );
258
259 // Create progress dialog (only used if more than 1 file to load
260 std::unique_ptr<WX_PROGRESS_REPORTER> progress = nullptr;
261
262 for( unsigned ii = 0; ii < aFilenameList.GetCount(); ii++ )
263 {
264 filename = aFilenameList[ii];
265
266 if( !filename.IsAbsolute() )
267 filename.SetPath( aPath );
268
269 // Check for non existing files, to avoid creating broken or useless data
270 // and report all in one error list:
271 if( !filename.FileExists() )
272 {
273 wxString warning;
274 warning << wxT( "<b>" ) << _( "File not found:" ) << wxT( "</b><br>" )
275 << filename.GetFullPath() << wxT( "<br>" );
276 reporter.Report( warning, RPT_SEVERITY_WARNING );
277 success = false;
278 continue;
279 }
280
281 if( filename.GetExt() == GerberJobFileExtension.c_str() )
282 {
283 //We cannot read a gerber job file as a gerber plot file: skip it
284 wxString txt;
285 txt.Printf( _( "<b>A gerber job file cannot be loaded as a plot file</b> "
286 "<i>%s</i>" ),
287 filename.GetFullName() );
288 success = false;
289 reporter.Report( txt, RPT_SEVERITY_ERROR );
290 continue;
291 }
292
293
294 m_lastFileName = filename.GetFullPath();
295
296 if( !progress && ( aFilenameList.GetCount() > 1 ) )
297 {
298 progress = std::make_unique<WX_PROGRESS_REPORTER>( this, _( "Loading files..." ), 1,
299 false );
300 progress->SetMaxProgress( aFilenameList.GetCount() - 1 );
301 progress->Report( wxString::Format( _("Loading %u/%zu %s..." ),
302 ii+1,
303 aFilenameList.GetCount(),
304 m_lastFileName ) );
305 }
306 else if( progress )
307 {
308 progress->Report( wxString::Format( _("Loading %u/%zu %s..." ),
309 ii+1,
310 aFilenameList.GetCount(),
311 m_lastFileName ) );
312 progress->KeepRefreshing();
313 }
314
315
316 // Make sure we have a layer available to load into
317 layer = getNextAvailableLayer();
318
319 if( layer == NO_AVAILABLE_LAYERS )
320 {
321 success = false;
323
324 // Report the name of not loaded files:
325 while( ii < aFilenameList.GetCount() )
326 {
327 filename = aFilenameList[ii++];
328 wxString txt = wxString::Format( MSG_NOT_LOADED, filename.GetFullName() );
329 reporter.Report( txt, RPT_SEVERITY_ERROR );
330 }
331 break;
332 }
333
334 SetActiveLayer( layer, false );
335 visibility[ layer ] = true;
336
337 try
338 {
339 // 2 = Autodetect
340 if( ( *aFileType )[ii] == 2 )
341 {
342 if( EXCELLON_IMAGE::TestFileIsExcellon( filename.GetFullPath() ) )
343 ( *aFileType )[ii] = 1;
344 else if( GERBER_FILE_IMAGE::TestFileIsRS274( filename.GetFullPath() ) )
345 ( *aFileType )[ii] = 0;
346 }
347
348 switch( ( *aFileType )[ii] )
349 {
350 case 0:
351
352 if( Read_GERBER_File( filename.GetFullPath() ) )
353 {
354 UpdateFileHistory( filename.GetFullPath() );
355
356 if( firstLoadedLayer == NO_AVAILABLE_LAYERS )
357 {
358 firstLoadedLayer = layer;
359 }
360 }
361
362 break;
363
364 case 1:
365
366 if( Read_EXCELLON_File( filename.GetFullPath() ) )
367 {
368 UpdateFileHistory( filename.GetFullPath(), &m_drillFileHistory );
369
370 // Select the first added layer by default when done loading
371 if( firstLoadedLayer == NO_AVAILABLE_LAYERS )
372 {
373 firstLoadedLayer = layer;
374 }
375 }
376
377 break;
378 default:
379 wxString txt = wxString::Format( MSG_NOT_LOADED, filename.GetFullName() );
380 reporter.Report( txt, RPT_SEVERITY_ERROR );
381 }
382 }
383 catch( const std::bad_alloc& )
384 {
385 wxString txt = wxString::Format( MSG_OOM, filename.GetFullName() );
386 reporter.Report( txt, RPT_SEVERITY_ERROR );
387 success = false;
388 continue;
389 }
390
391 if( progress )
392 progress->AdvanceProgress();
393 }
394
395 if( !success )
396 {
397 wxSafeYield(); // Allows slice of time to redraw the screen
398 // to refresh widgets, before displaying messages
399 HTML_MESSAGE_BOX mbox( this, _( "Errors" ) );
400 mbox.ListSet( msg );
401 mbox.ShowModal();
402 }
403
405
406 if( firstLoadedLayer != NO_AVAILABLE_LAYERS )
407 SetActiveLayer( firstLoadedLayer, true );
408
409 // Synchronize layers tools with actual active layer:
411
413 syncLayerBox( true );
414
415 GetCanvas()->Refresh();
416
417 return success;
418}
419
420
421
422
423bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aReporter )
424{
425 bool foundX2Gerbers = false;
426 wxString msg;
427 int firstLoadedLayer = NO_AVAILABLE_LAYERS;
428
429 // Extract the path of aFullFileName. We use it to store temporary files
430 wxFileName fn( aFullFileName );
431 wxString unzipDir = fn.GetPath();
432
433 wxFFileInputStream zipFile( aFullFileName );
434
435 if( !zipFile.IsOk() )
436 {
437 if( aReporter )
438 {
439 msg.Printf( _( "Zip file '%s' cannot be opened." ), aFullFileName );
440 aReporter->Report( msg, RPT_SEVERITY_ERROR );
441 }
442
443 return false;
444 }
445
446 // Update the list of recent zip files.
447 UpdateFileHistory( aFullFileName, &m_zipFileHistory );
448
449 // The unzipped file in only a temporary file. Give it a filename
450 // which cannot conflict with an usual filename.
451 // TODO: make Read_GERBER_File() and Read_EXCELLON_File() able to
452 // accept a stream, and avoid using a temp file.
453 wxFileName temp_fn( "$tempfile.tmp" );
454 temp_fn.MakeAbsolute( unzipDir );
455 wxString unzipped_tempfile = temp_fn.GetFullPath();
456
457
458 bool success = true;
459 wxZipInputStream zipArchive( zipFile );
460 wxZipEntry* entry;
461 bool reported_no_more_layer = false;
462 KIGFX::VIEW* view = GetCanvas()->GetView();
463
464 while( ( entry = zipArchive.GetNextEntry() ) )
465 {
466 if( entry->IsDir() )
467 continue;
468
469 wxString fname = entry->GetName();
470 wxFileName uzfn = fname;
471 wxString curr_ext = uzfn.GetExt().Lower();
472
473 // The archive contains Gerber and/or Excellon drill files. Use the right loader.
474 // However it can contain a few other files (reports, pdf files...),
475 // which will be skipped.
476 if( curr_ext == GerberJobFileExtension.c_str() )
477 {
478 //We cannot read a gerber job file as a gerber plot file: skip it
479 if( aReporter )
480 {
481 msg.Printf( _( "Skipped file '%s' (gerber job file)." ), entry->GetName() );
482 aReporter->Report( msg, RPT_SEVERITY_WARNING );
483 }
484
485 continue;
486 }
487
488 wxString matchedExt;
489 enum GERBER_ORDER_ENUM order;
490 GERBER_FILE_IMAGE_LIST::GetGerberLayerFromFilename( fname, order, matchedExt );
491
492 int layer = GetActiveLayer();
493
494 if( layer == NO_AVAILABLE_LAYERS )
495 {
496 success = false;
497
498 if( aReporter )
499 {
500 if( !reported_no_more_layer )
502
503 reported_no_more_layer = true;
504
505 // Report the name of not loaded files:
506 msg.Printf( MSG_NOT_LOADED, entry->GetName() );
507 aReporter->Report( msg, RPT_SEVERITY_ERROR );
508 }
509
510 delete entry;
511 continue;
512 }
513
514 // Create the unzipped temporary file:
515 {
516 wxFFileOutputStream temporary_ofile( unzipped_tempfile );
517
518 if( temporary_ofile.Ok() )
519 temporary_ofile.Write( zipArchive );
520 else
521 {
522 success = false;
523
524 if( aReporter )
525 {
526 msg.Printf( _( "<b>Unable to create temporary file '%s'.</b>" ),
527 unzipped_tempfile );
528 aReporter->Report( msg, RPT_SEVERITY_ERROR );
529 }
530 }
531 }
532
533 bool read_ok = true;
534
535 // Try to parse files if we can't tell from file extension
537 {
538 if( EXCELLON_IMAGE::TestFileIsExcellon( unzipped_tempfile ) )
539 {
541 }
542 else if( GERBER_FILE_IMAGE::TestFileIsRS274( unzipped_tempfile ) )
543 {
544 // If we have no way to know what layer it is, just guess
546 }
547 else
548 {
549 if( aReporter )
550 {
551 msg.Printf( _( "Skipped file '%s' (unknown type)." ), entry->GetName() );
552 aReporter->Report( msg, RPT_SEVERITY_WARNING );
553 }
554 }
555 }
556
558 {
559 read_ok = Read_EXCELLON_File( unzipped_tempfile );
560 }
562 {
563 // Read gerber files: each file is loaded on a new GerbView layer
564 read_ok = Read_GERBER_File( unzipped_tempfile );
565
566 if( read_ok )
567 {
569 GetGbrImage( layer )->HasNegativeItems() );
570 }
571 }
572
573 // Select the first added layer by default when done loading
574 if( read_ok && firstLoadedLayer == NO_AVAILABLE_LAYERS )
575 {
576 firstLoadedLayer = layer;
577 }
578
579 delete entry;
580
581 // The unzipped file is only a temporary file, delete it.
582 wxRemoveFile( unzipped_tempfile );
583
584 if( !read_ok )
585 {
586 success = false;
587
588 if( aReporter )
589 {
590 msg.Printf( _( "<b>unzipped file %s read error</b>" ), unzipped_tempfile );
591 aReporter->Report( msg, RPT_SEVERITY_ERROR );
592 }
593 }
594 else
595 {
596 GERBER_FILE_IMAGE* gerber_image = GetGbrImage( layer );
597
598 if( gerber_image )
599 {
600 gerber_image->m_FileName = fname;
601 if( gerber_image->m_IsX2_file )
602 foundX2Gerbers = true;
603 }
604
605 layer = getNextAvailableLayer();
606 SetActiveLayer( layer, false );
607 }
608 }
609
610 if( foundX2Gerbers )
612 else
614
615 // Select the first layer loaded so we don't show another layer on top after
616 if( firstLoadedLayer != NO_AVAILABLE_LAYERS )
617 SetActiveLayer( firstLoadedLayer, true );
618
619 return success;
620}
621
622
623bool GERBVIEW_FRAME::LoadZipArchiveFile( const wxString& aFullFileName )
624{
625#define ZipFileExtension "zip"
626
627 wxFileName filename = aFullFileName;
628 wxString currentPath;
629
630 if( !filename.IsOk() )
631 {
632 // Use the current working directory if the file name path does not exist.
633 if( filename.DirExists() )
634 currentPath = filename.GetPath();
635 else
636 currentPath = m_mruPath;
637
638 wxFileDialog dlg( this, _( "Open Zip File" ), currentPath, filename.GetFullName(),
639 ZipFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR );
640
641 if( dlg.ShowModal() == wxID_CANCEL )
642 return false;
643
644 filename = dlg.GetPath();
645 currentPath = wxGetCwd();
646 m_mruPath = currentPath;
647 }
648 else
649 {
650 currentPath = filename.GetPath();
651 m_mruPath = currentPath;
652 }
653
654 wxString msg;
655 WX_STRING_REPORTER reporter( &msg );
656
657 if( filename.IsOk() )
658 unarchiveFiles( filename.GetFullPath(), &reporter );
659
660 Zoom_Automatique( false );
661
662 // Synchronize layers tools with actual active layer:
666 syncLayerBox();
667
668 if( !msg.IsEmpty() )
669 {
670 wxSafeYield(); // Allows slice of time to redraw the screen
671 // to refresh widgets, before displaying messages
672 HTML_MESSAGE_BOX mbox( this, _( "Messages" ) );
673 mbox.ListSet( msg );
674 mbox.ShowModal();
675 }
676
677 return true;
678}
679
681{
682 wxString gerbFn; // param to be sent with action event.
683
684 for( const wxFileName& file : m_AcceptedFiles )
685 {
686 if( file.GetExt() == ArchiveFileExtension )
687 {
688 wxString fn = file.GetFullPath();
689 // Open zip archive in editor
691 }
692 else
693 {
694 // Store FileName in variable to open later
695 gerbFn += '"' + file.GetFullPath() + '"';
696 }
697 }
698
699 // Open files in editor
700 if( !gerbFn.IsEmpty() )
702}
std::vector< wxFileName > m_AcceptedFiles
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Removes all files from the file history.
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associates files extensions with action to execute.
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetches the file name from the file history list.
wxString m_mruPath
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
static bool TestFileIsExcellon(const wxString &aFullFileName)
Performs a heuristics-based check of whether the file is an Excellon drill file.
unsigned GetLoadedImageCount()
Get number of loaded images.
static void GetGerberLayerFromFilename(const wxString &filename, enum GERBER_ORDER_ENUM &order, wxString &matchedExtension)
Utility function to guess which PCB layer of a gerber/drill file corresponds to based on its file ext...
Hold the image data and parameters for one gerber file and layer parameters.
wxString m_FileName
Full File Name for this layer.
static bool TestFileIsRS274(const wxString &aFullFileName)
Performs a heuristics-based check of whether the file is an RS274 gerber file.
Definition: readgerb.cpp:139
bool m_IsX2_file
True if a X2 gerber attribute was found in file.
void OnDrlFileHistory(wxCommandEvent &event)
Delete the current data and load a drill file in Excellon format selected from history list on curren...
void SortLayersByX2Attributes()
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
bool Read_EXCELLON_File(const wxString &aFullFileName)
bool LoadFileOrShowDialog(const wxString &aFileName, const wxString &dialogFiletypes, const wxString &dialogTitle, const int filetype)
Loads the file provided or shows a dialog to get the file(s) from the user.
bool LoadGerberJobFile(const wxString &aFileName)
Load a Gerber job file, and load gerber files found in job files.
void OnClearDrlFileHistory(wxCommandEvent &aEvent)
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
wxString m_lastFileName
void syncLayerBox(bool aRebuildLayerBox=false)
Update the currently "selected" layer within m_SelLayerBox.
bool LoadGerberFiles(const wxString &aFileName)
Load a given Gerber file or selected file(s), if the filename is empty.
bool unarchiveFiles(const wxString &aFullFileName, REPORTER *aReporter=nullptr)
Extract gerber and drill files from the zip archive, and load them.
FILE_HISTORY m_jobFileHistory
void OnJobFileHistory(wxCommandEvent &event)
Delete the current data and load a gerber job file selected from the history list.
void OnZipFileHistory(wxCommandEvent &event)
Delete the current data and load a zip archive file selected from the history list.
int GetActiveLayer() const
Return the active layer.
GERBER_LAYER_WIDGET * m_LayersManager
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
change the currently active layer to aLayer and update the GERBER_LAYER_WIDGET.
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
bool Read_GERBER_File(const wxString &GERBER_FullFileName)
Definition: readgerb.cpp:41
void SortLayersByFileExtension()
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
bool LoadListOfGerberAndDrillFiles(const wxString &aPath, const wxArrayString &aFilenameList, std::vector< int > *aFileType)
Load a list of Gerber and NC drill files and updates the view based on them.
bool LoadAutodetectedFiles(const wxString &aFileName)
Load a given file or selected file(s), if the filename is empty.
void ReFillLayerWidget()
Change out all the layers in m_Layers; called upon loading new gerber files.
FILE_HISTORY m_zipFileHistory
int getNextAvailableLayer() const
Find the next empty layer.
bool LoadZipArchiveFile(const wxString &aFileName)
Load a zipped archive file.
void OnClearGbrFileHistory(wxCommandEvent &aEvent)
void OnClearZipFileHistory(wxCommandEvent &aEvent)
void DoWithAcceptedFiles() override
Execute action on accepted dropped file.
void OnGbrFileHistory(wxCommandEvent &event)
Delete the current data and loads a Gerber file selected from history list on current layer.
FILE_HISTORY m_drillFileHistory
bool LoadExcellonFiles(const wxString &aFileName)
Load a drill (EXCELLON) file or many files.
void OnClearJobFileHistory(wxCommandEvent &aEvent)
void ListSet(const wxString &aList)
Add a list of items.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
void SetLayerHasNegatives(int aLayer, bool aNegatives=true)
Set the status of negatives presense in a particular layer.
Definition: view.h:442
void UpdateLayerIcons()
Update all layer manager icons (layers only).
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
A wrapper for reporting to a wxString object.
Definition: reporter.h:164
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
Definition: reporter.cpp:59
#define _(s)
#define MSG_NOT_LOADED
#define MSG_OOM
#define MSG_NO_MORE_LAYER
#define NO_AVAILABLE_LAYERS
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 GerberJobFileExtension
const std::string GerberFileExtension
const std::string ArchiveFileExtension
wxString DrillFileWildcard()
wxString AllFilesWildcard()
wxString ZipFileWildcard()
#define GERBER_DRAW_LAYER(x)
Definition: layer_ids.h:423
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
Definition of file extensions used in Kicad.