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