KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 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
21#include <wx/debug.h>
22#include <wx/filedlg.h>
23#include <wx/wfstream.h>
24#include <wx/zipstrm.h>
25#include <reporter.h>
27#include <gerbview_frame.h>
28#include <gerbview_id.h>
29#include <gerber_file_image.h>
31#include <excellon_image.h>
32#include <lset.h>
34#include <view/view.h>
37#include <tool/tool_manager.h>
38#include <kiplatform/ui.h>
39
40// HTML Messages used more than one time:
41#define MSG_NO_MORE_LAYER _( "<b>No more available layers</b> in GerbView to load files" )
42#define MSG_NOT_LOADED _( "<b>Not loaded:</b> <i>%s</i>" )
43#define MSG_OOM _( "<b>Memory was exhausted reading:</b> <i>%s</i>" )
44
45
46void GERBVIEW_FRAME::OnGbrFileHistory( wxCommandEvent& event )
47{
48 wxString filename = GetFileFromHistory( event.GetId(), _( "Gerber files" ) );
49
50 if( !filename.IsEmpty() )
51 LoadGerberFiles( filename );
52}
53
54void GERBVIEW_FRAME::OnClearGbrFileHistory( wxCommandEvent& aEvent )
55{
57}
58
59
60void GERBVIEW_FRAME::OnDrlFileHistory( wxCommandEvent& event )
61{
62 wxString filename = GetFileFromHistory( event.GetId(), _( "Drill files" ), &m_drillFileHistory );
63
64 if( !filename.IsEmpty() )
65 LoadExcellonFiles( filename );
66}
67
68
69void GERBVIEW_FRAME::OnClearDrlFileHistory( wxCommandEvent& aEvent )
70{
71 m_drillFileHistory.ClearFileHistory();
72
73 if( GetMenuBar() )
74 {
76 GetMenuBar()->Refresh();
77 }
78}
79
80
81void GERBVIEW_FRAME::OnZipFileHistory( wxCommandEvent& event )
82{
83 wxString filename = GetFileFromHistory( event.GetId(), _( "Zip files" ), &m_zipFileHistory );
84
85 if( !filename.IsEmpty() )
86 LoadZipArchiveFile( filename );
87}
88
89
90void GERBVIEW_FRAME::OnClearZipFileHistory( wxCommandEvent& aEvent )
91{
92 m_zipFileHistory.ClearFileHistory();
93
94 if( GetMenuBar() )
95 {
97 GetMenuBar()->Refresh();
98 }
99}
100
101
102void GERBVIEW_FRAME::OnJobFileHistory( wxCommandEvent& event )
103{
104 wxString filename = GetFileFromHistory( event.GetId(), _( "Job files" ), &m_jobFileHistory );
105
106 if( !filename.IsEmpty() )
107 LoadGerberJobFile( filename );
108}
109
110
111void GERBVIEW_FRAME::OnClearJobFileHistory( wxCommandEvent& aEvent )
112{
113 m_jobFileHistory.ClearFileHistory();
114
115 if( GetMenuBar() )
116 {
118 GetMenuBar()->Refresh();
119 }
120}
121
122
123bool GERBVIEW_FRAME::LoadFileOrShowDialog( const wxString& aFileName,
124 const wxString& dialogFiletypes,
125 const wxString& dialogTitle, const int filetype )
126{
127 static int lastGerberFileWildcard = 0;
128 wxArrayString filenamesList;
129 wxFileName filename = aFileName;
130 wxString currentPath;
131
132 if( !filename.IsOk() )
133 {
134 // Use the current working directory if the file name path does not exist.
135 if( filename.DirExists() )
136 currentPath = filename.GetPath();
137 else
138 {
139 currentPath = m_mruPath;
140
141 // On wxWidgets 3.1 (bug?) the path in wxFileDialog is ignored when
142 // finishing by the dir separator. Remove it if any:
143 if( currentPath.EndsWith( '\\' ) || currentPath.EndsWith( '/' ) )
144 currentPath.RemoveLast();
145 }
146
147 wxFileDialog dlg( this, dialogTitle, currentPath, filename.GetFullName(), dialogFiletypes,
148 wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE | wxFD_CHANGE_DIR );
149
151
152 wxArrayString dummy1, dummy2;
153 const int nWildcards = wxParseCommonDialogsFilter( dialogFiletypes, dummy1, dummy2 );
154
155 if( lastGerberFileWildcard >= 0 && lastGerberFileWildcard < nWildcards )
156 dlg.SetFilterIndex( lastGerberFileWildcard );
157
158 if( dlg.ShowModal() == wxID_CANCEL )
159 return false;
160
161 lastGerberFileWildcard = dlg.GetFilterIndex();
162 dlg.GetPaths( filenamesList );
163 m_mruPath = currentPath = dlg.GetDirectory();
164 }
165 else
166 {
167 filenamesList.Add( aFileName );
168 currentPath = filename.GetPath();
169 m_mruPath = currentPath;
170 }
171
172 // Set the busy cursor
173 wxBusyCursor wait;
174
175 bool isFirstFile = GetImagesList()->GetLoadedImageCount() == 0;
176
177 std::vector<int> fileTypesVec( filenamesList.Count(), filetype );
178 bool success = LoadListOfGerberAndDrillFiles( currentPath, filenamesList, &fileTypesVec );
179
180 // Auto zoom / sort is only applied when no other files have been loaded
181 if( isFirstFile )
182 {
183 int ly = GetActiveLayer();
184
186 Zoom_Automatique( false );
187
188 // Ensure the initial active graphic layer is updated after sorting.
189 SetActiveLayer( ly, true );
190 }
191
192 return success;
193}
194
195
196bool GERBVIEW_FRAME::LoadAutodetectedFiles( const wxString& aFileName )
197{
198 // 2 = autodetect files
199 return LoadFileOrShowDialog( aFileName, FILEEXT::AllFilesWildcard(), _( "Open Autodetected File(s)" ),
200 2 );
201}
202
203
204bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFileName )
205{
206 wxString filetypes;
207 wxFileName filename = aFileName;
208
209 /* Standard gerber filetypes
210 * (See http://en.wikipedia.org/wiki/Gerber_File)
211 * The .gbr (.pho in legacy files) extension is the default used in Pcbnew; however
212 * there are a lot of other extensions used for gerber files. Because the first letter
213 * is usually g, we accept g* as extension.
214 * (Mainly internal copper layers do not have specific extension, and filenames are like
215 * *.g1, *.g2 *.gb1 ...)
216 * Now (2014) Ucamco (the company which manages the Gerber format) encourages use of .gbr
217 * only and the Gerber X2 file format.
218 */
219 filetypes = _( "Gerber files" ) + wxT( " (*.g*; *.pho)|" )
220 + AddFileExtListToFilter( { "g*", "pho", "gbr", "gtl", "gbl", "gto", "gbo", "gts", "gbs",
221 "gtp", "gbp", "gta", "gba", "gko", "gpt", "gpb", "gm1", "gm2",
222 "gm3", "gm4", "gm5", "gm6", "gm7", "gm8", "gm9", "g1", "g2",
223 "g3", "g4", "g5", "g6", "g7", "g8", "g9" } )
224 .AfterFirst( '|' )
225 + wxT( "|" );
226
227 /* Special gerber filetypes */
228 filetypes += _( "Top layer" ) + AddFileExtListToFilter( { "gtl" } ) + wxT( "|" );
229 filetypes += _( "Bottom layer" ) + AddFileExtListToFilter( { "gbl" } ) + wxT( "|" );
230 filetypes += _( "Bottom solder resist" ) + AddFileExtListToFilter( { "gbs" } ) + wxT( "|" );
231 filetypes += _( "Top solder resist" ) + AddFileExtListToFilter( { "gts" } ) + wxT( "|" );
232 filetypes += _( "Bottom overlay" ) + AddFileExtListToFilter( { "gbo" } ) + wxT( "|" );
233 filetypes += _( "Top overlay" ) + AddFileExtListToFilter( { "gto" } ) + wxT( "|" );
234 filetypes += _( "Bottom paste" ) + AddFileExtListToFilter( { "gbp" } ) + wxT( "|" );
235 filetypes += _( "Top paste" ) + AddFileExtListToFilter( { "gtp" } ) + wxT( "|" );
236 filetypes += _( "Keep-out layer" ) + AddFileExtListToFilter( { "gko" } ) + wxT( "|" );
237 filetypes += _( "Mechanical layers" )
239 { "gm1", "gm2", "gm3", "gm4", "gm5", "gm6", "gm7", "gm8", "gm9" } )
240 + wxT( "|" );
241 filetypes += _( "Top Pad Master" ) + AddFileExtListToFilter( { "gpt" } ) + wxT( "|" );
242 filetypes += _( "Bottom Pad Master" ) + AddFileExtListToFilter( { "gpb" } ) + wxT( "|" );
243
244 // All filetypes
245 filetypes += FILEEXT::AllFilesWildcard();
246
247 // 0 = gerber files
248 return LoadFileOrShowDialog( aFileName, filetypes, _( "Open Gerber File(s)" ), 0 );
249}
250
251
252bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFileName )
253{
254 wxString filetypes = FILEEXT::DrillFileWildcard();
255 filetypes << wxT( "|" );
256 filetypes += FILEEXT::AllFilesWildcard();
257
258 // 1 = drill files
259 return LoadFileOrShowDialog( aFileName, filetypes, _( "Open NC (Excellon) Drill File(s)" ), 1 );
260}
261
262
264 const wxArrayString& aFilenameList,
265 std::vector<int>* aFileType )
266{
267 wxCHECK_MSG( aFilenameList.Count() == aFileType->size(), false,
268 "Mismatch in file names and file types count" );
269
270 wxFileName filename;
271
272 // Read gerber files: each file is loaded on a new GerbView layer
273 bool success = true;
274 int layer = GetActiveLayer();
275 int firstLoadedLayer = NO_AVAILABLE_LAYERS;
277
278 // Manage errors when loading files
280
281 // Create progress dialog (only used if more than 1 file to load
282 std::unique_ptr<WX_PROGRESS_REPORTER> progress = nullptr;
283
284 for( unsigned ii = 0; ii < aFilenameList.GetCount(); ii++ )
285 {
286 filename = aFilenameList[ii];
287
288 if( !filename.IsAbsolute() )
289 filename.SetPath( aPath );
290
291 // Check for non existing files, to avoid creating broken or useless data
292 // and report all in one error list:
293 if( !filename.FileExists() )
294 {
295 wxString warning;
296 warning << wxT( "<b>" ) << _( "File not found:" ) << wxT( "</b><br>" )
297 << filename.GetFullPath() << wxT( "<br>" );
298 reporter.Report( warning, RPT_SEVERITY_WARNING );
299 success = false;
300 continue;
301 }
302
303 if( filename.GetExt() == FILEEXT::GerberJobFileExtension.c_str() )
304 {
305 //We cannot read a gerber job file as a gerber plot file: skip it
306 wxString txt;
307 txt.Printf( _( "<b>A gerber job file cannot be loaded as a plot file</b> "
308 "<i>%s</i>" ),
309 filename.GetFullName() );
310 success = false;
311 reporter.Report( txt, RPT_SEVERITY_ERROR );
312 continue;
313 }
314
315
316 m_lastFileName = filename.GetFullPath();
317
318 if( !progress && ( aFilenameList.GetCount() > 1 ) )
319 {
320 progress = std::make_unique<WX_PROGRESS_REPORTER>( this, _( "Load Files" ), 1, PR_CAN_ABORT );
321 progress->SetMaxProgress( aFilenameList.GetCount() - 1 );
322 progress->Report( wxString::Format( _("Loading %u/%zu %s..." ),
323 ii+1,
324 aFilenameList.GetCount(),
325 m_lastFileName ) );
326 }
327 else if( progress )
328 {
329 progress->Report( wxString::Format( _("Loading %u/%zu %s..." ),
330 ii+1,
331 aFilenameList.GetCount(),
332 m_lastFileName ) );
333 progress->KeepRefreshing();
334 }
335
336
337 // Make sure we have a layer available to load into
338 layer = getNextAvailableLayer();
339
340 if( layer == NO_AVAILABLE_LAYERS )
341 {
342 success = false;
344
345 // Report the name of not loaded files:
346 while( ii < aFilenameList.GetCount() )
347 {
348 filename = aFilenameList[ii++];
349 wxString txt = wxString::Format( MSG_NOT_LOADED, filename.GetFullName() );
350 reporter.Report( txt, RPT_SEVERITY_ERROR );
351 }
352 break;
353 }
354
355 SetActiveLayer( layer, false );
356 visibility[ layer ] = true;
357
358 try
359 {
360 // 2 = Autodetect
361 if( ( *aFileType )[ii] == 2 )
362 {
363 if( EXCELLON_IMAGE::TestFileIsExcellon( filename.GetFullPath() ) )
364 ( *aFileType )[ii] = 1;
365 else if( GERBER_FILE_IMAGE::TestFileIsRS274( filename.GetFullPath() ) )
366 ( *aFileType )[ii] = 0;
367 }
368
369 switch( ( *aFileType )[ii] )
370 {
371 case 0:
372
373 if( Read_GERBER_File( filename.GetFullPath() ) )
374 {
375 UpdateFileHistory( filename.GetFullPath() );
376
377 if( firstLoadedLayer == NO_AVAILABLE_LAYERS )
378 {
379 firstLoadedLayer = layer;
380 }
381 }
382
383 break;
384
385 case 1:
386
387 if( Read_EXCELLON_File( filename.GetFullPath() ) )
388 {
389 UpdateFileHistory( filename.GetFullPath(), &m_drillFileHistory );
390
391 // Select the first added layer by default when done loading
392 if( firstLoadedLayer == NO_AVAILABLE_LAYERS )
393 {
394 firstLoadedLayer = layer;
395 }
396 }
397
398 break;
399 default:
400 wxString txt = wxString::Format( MSG_NOT_LOADED, filename.GetFullName() );
401 reporter.Report( txt, RPT_SEVERITY_ERROR );
402 }
403 }
404 catch( const std::bad_alloc& )
405 {
406 wxString txt = wxString::Format( MSG_OOM, filename.GetFullName() );
407 reporter.Report( txt, RPT_SEVERITY_ERROR );
408 success = false;
409 continue;
410 }
411
412 if( progress )
413 progress->AdvanceProgress();
414 }
415
416 if( !success )
417 {
418 wxSafeYield(); // Allows slice of time to redraw the screen
419 // to refresh widgets, before displaying messages
420 HTML_MESSAGE_BOX mbox( this, _( "Errors" ) );
421 mbox.ListSet( reporter.GetMessages() );
422 mbox.ShowModal();
423 }
424
426
427 if( firstLoadedLayer != NO_AVAILABLE_LAYERS )
428 SetActiveLayer( firstLoadedLayer, true );
429
430 // Synchronize layers tools with actual active layer:
432
433 m_LayersManager->UpdateLayerIcons();
434 syncLayerBox( true );
435
436 GetCanvas()->Refresh();
437
438 return success;
439}
440
441
442bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aReporter )
443{
444 bool foundX2Gerbers = false;
445 wxString msg;
446 int firstLoadedLayer = NO_AVAILABLE_LAYERS;
448
449 // Extract the path of aFullFileName. We use it to store temporary files
450 wxFileName fn( aFullFileName );
451 wxString unzipDir = fn.GetPath();
452
453 wxFFileInputStream zipFile( aFullFileName );
454
455 if( !zipFile.IsOk() )
456 {
457 if( aReporter )
458 {
459 msg.Printf( _( "Zip file '%s' cannot be opened." ), aFullFileName );
460 aReporter->Report( msg, RPT_SEVERITY_ERROR );
461 }
462
463 return false;
464 }
465
466 // Update the list of recent zip files.
467 UpdateFileHistory( aFullFileName, &m_zipFileHistory );
468
469 // The unzipped file in only a temporary file. Give it a filename
470 // which cannot conflict with an usual filename.
471 // TODO: make Read_GERBER_File() and Read_EXCELLON_File() able to
472 // accept a stream, and avoid using a temp file.
473 wxFileName temp_fn( "$tempfile.tmp" );
474 temp_fn.MakeAbsolute( unzipDir );
475 wxString unzipped_tempfile = temp_fn.GetFullPath();
476
477
478 bool success = true;
479 wxZipInputStream zipArchive( zipFile );
480 wxZipEntry* entry;
481 bool reported_no_more_layer = false;
482 KIGFX::VIEW* view = GetCanvas()->GetView();
483
484 while( ( entry = zipArchive.GetNextEntry() ) != nullptr )
485 {
486 if( entry->IsDir() )
487 continue;
488
489 wxString fname = entry->GetName();
490 wxFileName uzfn = fname;
491 wxString curr_ext = uzfn.GetExt().Lower();
492
493 // The archive contains Gerber and/or Excellon drill files. Use the right loader.
494 // However it can contain a few other files (reports, pdf files...),
495 // which will be skipped.
496 if( curr_ext == FILEEXT::GerberJobFileExtension.c_str() )
497 {
498 //We cannot read a gerber job file as a gerber plot file: skip it
499 if( aReporter )
500 {
501 msg.Printf( _( "Skipped file '%s' (gerber job file)." ), entry->GetName() );
502 aReporter->Report( msg, RPT_SEVERITY_WARNING );
503 }
504
505 continue;
506 }
507
508 wxString matchedExt;
509 enum GERBER_ORDER_ENUM order;
510 GERBER_FILE_IMAGE_LIST::GetGerberLayerFromFilename( fname, order, matchedExt );
511
512 int layer = getNextAvailableLayer();
513
514 if( layer == NO_AVAILABLE_LAYERS )
515 {
516 success = false;
517
518 if( aReporter )
519 {
520 if( !reported_no_more_layer )
522
523 reported_no_more_layer = true;
524
525 // Report the name of not loaded files:
526 msg.Printf( MSG_NOT_LOADED, entry->GetName() );
527 aReporter->Report( msg, RPT_SEVERITY_ERROR );
528 }
529
530 delete entry;
531 continue;
532 }
533
534 SetActiveLayer( layer, false );
535
536 // Create the unzipped temporary file:
537 {
538 wxFFileOutputStream temporary_ofile( unzipped_tempfile );
539
540 if( temporary_ofile.Ok() )
541 temporary_ofile.Write( zipArchive );
542 else
543 {
544 success = false;
545
546 if( aReporter )
547 {
548 msg.Printf( _( "<b>Unable to create temporary file '%s'.</b>" ),
549 unzipped_tempfile );
550 aReporter->Report( msg, RPT_SEVERITY_ERROR );
551 }
552 }
553 }
554
555 bool read_ok = true;
556
557 // Try to parse files if we can't tell from file extension
559 {
560 if( EXCELLON_IMAGE::TestFileIsExcellon( unzipped_tempfile ) )
561 {
563 }
564 else if( GERBER_FILE_IMAGE::TestFileIsRS274( unzipped_tempfile ) )
565 {
566 // If we have no way to know what layer it is, just guess
568 }
569 else
570 {
571 if( aReporter )
572 {
573 msg.Printf( _( "Skipped file '%s' (unknown type)." ), entry->GetName() );
574 aReporter->Report( msg, RPT_SEVERITY_WARNING );
575 }
576 }
577 }
578
580 {
581 read_ok = Read_EXCELLON_File( unzipped_tempfile );
582 }
584 {
585 // Read gerber files: each file is loaded on a new GerbView layer
586 read_ok = Read_GERBER_File( unzipped_tempfile );
587
588 if( read_ok )
589 {
590 if( GERBER_FILE_IMAGE* gbrImage = GetGbrImage( layer ) )
591 view->SetLayerHasNegatives( GERBER_DRAW_LAYER( layer ), gbrImage->HasNegativeItems() );
592 }
593 }
594
595 // Select the first added layer by default when done loading
596 if( read_ok && firstLoadedLayer == NO_AVAILABLE_LAYERS )
597 {
598 firstLoadedLayer = layer;
599 }
600
601 delete entry;
602
603 // The unzipped file is only a temporary file, delete it.
604 wxRemoveFile( unzipped_tempfile );
605
606 if( !read_ok )
607 {
608 success = false;
609
610 if( aReporter )
611 {
612 msg.Printf( _( "<b>unzipped file %s read error</b>" ), unzipped_tempfile );
613 aReporter->Report( msg, RPT_SEVERITY_ERROR );
614 }
615 }
616 else
617 {
618 GERBER_FILE_IMAGE* gerber_image = GetGbrImage( layer );
619 visibility[ layer ] = true;
620
621 if( gerber_image )
622 {
623 gerber_image->m_FileName = fname;
624 if( gerber_image->m_IsX2_file )
625 foundX2Gerbers = true;
626 }
627
628 layer = getNextAvailableLayer();
629 SetActiveLayer( layer, false );
630 }
631 }
632
633 if( foundX2Gerbers )
635 else
637
639
640 // Select the first layer loaded so we don't show another layer on top after
641 if( firstLoadedLayer != NO_AVAILABLE_LAYERS )
642 SetActiveLayer( firstLoadedLayer, true );
643
644 return success;
645}
646
647
648bool GERBVIEW_FRAME::LoadZipArchiveFile( const wxString& aFullFileName )
649{
650#define ZipFileExtension "zip"
651
652 wxFileName filename = aFullFileName;
653 wxString currentPath;
654
655 if( !filename.IsOk() )
656 {
657 // Use the current working directory if the file name path does not exist.
658 if( filename.DirExists() )
659 currentPath = filename.GetPath();
660 else
661 currentPath = m_mruPath;
662
663 wxFileDialog dlg( this, _( "Open Zip File" ), currentPath, filename.GetFullName(),
665 wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR );
666
668
669 if( dlg.ShowModal() == wxID_CANCEL )
670 return false;
671
672 filename = dlg.GetPath();
673 currentPath = wxGetCwd();
674 m_mruPath = currentPath;
675 }
676 else
677 {
678 currentPath = filename.GetPath();
679 m_mruPath = currentPath;
680 }
681
683
684 if( filename.IsOk() )
685 unarchiveFiles( filename.GetFullPath(), &reporter );
686
687 Zoom_Automatique( false );
688
689 // Synchronize layers tools with actual active layer:
692 m_LayersManager->UpdateLayerIcons();
693 syncLayerBox();
694
695 if( reporter.HasMessage() )
696 {
697 wxSafeYield(); // Allows slice of time to redraw the screen
698 // to refresh widgets, before displaying messages
699 HTML_MESSAGE_BOX mbox( this, _( "Messages" ) );
700 mbox.ListSet( reporter.GetMessages() );
701 mbox.ShowModal();
702 }
703
704 return true;
705}
706
707
709{
710 m_drillFileHistory.ClearFileHistory();
711 m_zipFileHistory.ClearFileHistory();
712 m_jobFileHistory.ClearFileHistory();
713
715}
716
717
719{
720 wxString gerbFn; // param to be sent with action event.
721
722 for( const wxFileName& file : m_AcceptedFiles )
723 {
724 if( file.GetExt() == FILEEXT::ArchiveFileExtension )
725 {
726 wxString fn = file.GetFullPath();
727 // Open zip archive in editor
728 m_toolManager->RunAction<wxString*>( *m_acceptedExts.at( FILEEXT::ArchiveFileExtension ), &fn );
729 }
730 else
731 {
732 // Store FileName in variable to open later
733 gerbFn += '"' + file.GetFullPath() + '"';
734 }
735 }
736
737 // Open files in editor
738 if( !gerbFn.IsEmpty() )
739 m_toolManager->RunAction<wxString*>( *m_acceptedExts.at( FILEEXT::GerberFileExtension ), &gerbFn );
740}
int ShowModal() override
std::vector< wxFileName > m_AcceptedFiles
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
virtual void ClearFileHistory()
Remove all files from the file history.
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associate file extensions with action to execute.
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetch the file name from the file history list.
void ReCreateMenuBar()
Recreate the menu bar.
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
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:134
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(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
void ClearFileHistory() override
Remove all files from the file history.
bool Read_GERBER_File(const wxString &GERBER_FullFileName)
Definition readgerb.cpp:37
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:63
void SetLayerHasNegatives(int aLayer, bool aNegatives=true)
Set the status of negatives presense in a particular layer.
Definition view.h:473
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Definition reporter.h:102
TOOL_MANAGER * m_toolManager
A wrapper for reporting to a wxString object.
Definition reporter.h:242
#define _(s)
#define MSG_NOT_LOADED
#define MSG_OOM
#define MSG_NO_MORE_LAYER
#define NO_AVAILABLE_LAYERS
static const std::string GerberJobFileExtension
static const std::string GerberFileExtension
static const std::string ArchiveFileExtension
static wxString AllFilesWildcard()
static wxString DrillFileWildcard()
static wxString ZipFileWildcard()
#define GERBER_DRAW_LAYER(x)
Definition layer_ids.h:562
void AllowNetworkFileSystems(wxDialog *aDialog)
Configure a file dialog to show network and virtual file systems.
Definition wxgtk/ui.cpp:521
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
IbisParser parser & reporter
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
Definition of file extensions used in Kicad.
#define PR_CAN_ABORT