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