50 wxEVT_COMMAND_BUTTON_CLICKED,
63 GetSizer()->SetSizeHints(
this );
142 label =
new wxStaticText(
this, wxID_STATIC, msg );
143 flexColumnBoxSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
147 label =
new wxStaticText(
this, wxID_STATIC, fn.GetFullName() );
148 flexColumnBoxSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
152 wxButton * Button =
new wxButton(
this, item_ID, wxT(
"..." ), wxDefaultPosition, wxDefaultSize,
155 flexColumnBoxSizer->Add( Button, 0, wxALIGN_CENTER_VERTICAL | wxALL );
166 msg =
_(
"Do not export" );
167 text =
new wxStaticText(
this, item_ID, msg );
168 text->SetForegroundColour( *wxBLUE );
180 goodSize =
text->GetSize();
186 if( goodSize.x <
text->GetSize().x )
187 goodSize.x =
text->GetSize().x;
189 text->SetLabel( msg );
192 text->SetMinSize( goodSize );
193 flexColumnBoxSizer->Add(
text, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
200 if(
config->m_GerberToPcbLayerMapping.size() == 0 )
203 std::vector<int> gerber2KicadMapping;
208 if( numMappedGerbers > 0 )
211 wxString::Format(
_(
"Gerbers with known layers: %d" ), numMappedGerbers )
212 + wxT(
"\n\n" ) +
_(
"Assign to matching PCB layers?" ),
213 _(
"Automatic Layer Assignment" ), wxOK | wxCANCEL | wxOK_DEFAULT );
215 if( dlg.ShowModal() == wxID_OK )
217 int total_copper = 0;
221 int currLayer = gerber2KicadMapping[ii];
238 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
269 int id =
event.GetSelection();
295 config->m_GerberToPcbLayerMapping.clear();
319 if( (
size_t)ii >=
config->m_GerberToPcbLayerMapping.size() )
337 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
342 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
354 wxFAIL_MSG( wxT(
"Bad layer id" ) );
364 wxFileName fn(
m_Parent->GetGerberLayout()->GetImagesList()->GetGbrImage( ii )->m_FileName );
367 wxString layerName = wxT(
"\"" ) + fn.GetFullName() + wxT(
"\"" );
393 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
401 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
413 if( !wxDialog::TransferDataFromWindow() )
419 int inner_layer_max = 0;
434 wxMessageBox(
_(
"Exported board does not have enough copper layers to handle selected "
445 int numKnownGerbers = 0;
459 return numKnownGerbers;
469 std::map<wxString, PCB_LAYER_ID> altiumExt{
470 { wxT(
"GTL" ),
F_Cu },
501 { wxT(
"GBL" ),
B_Cu },
514 std::map<wxString, PCB_LAYER_ID>::iterator it;
516 int numAltiumMatches = 0;
523 if( ( aGerber2KicadMapping.size() != 0 )
525 return numAltiumMatches;
530 if( aGerber2KicadMapping.size() == 0 )
542 wxString FileExt = fn.GetExt();
546 it = altiumExt.find( FileExt );
548 if( it != altiumExt.end() )
556 aGerber2KicadMapping[ii] = it->second;
566 return numAltiumMatches;
576 std::map<wxString, PCB_LAYER_ID> kicadLayers
635 std::map<wxString, PCB_LAYER_ID>::iterator it;
637 int numKicadMatches = 0;
644 if( ( aGerber2KicadMapping.size() != 0 )
646 return numKicadMatches;
651 if( aGerber2KicadMapping.size() == 0 )
662 wxString layerName = fn.GetName();
668 int dashPos = layerName.Find(
'-',
true );
673 if( dashPos != wxNOT_FOUND )
674 suffix = layerName.Right( layerName.length() - dashPos );
677 it = kicadLayers.find( suffix );
679 if( it != kicadLayers.end() )
687 aGerber2KicadMapping[ii] = it->second;
697 return numKicadMatches;
707 std::map<wxString, PCB_LAYER_ID> kicadLayers
709 { wxT(
"Top" ),
F_Cu },
739 { wxT(
"Bot" ),
B_Cu },
742 { wxT(
"BotPaste" ),
B_Paste },
743 { wxT(
"TopPaste" ),
F_Paste },
744 { wxT(
"BotLegend" ),
B_SilkS },
745 { wxT(
"TopLegend" ),
F_SilkS },
746 { wxT(
"BotSoldermask" ),
B_Mask },
747 { wxT(
"TopSoldermask" ),
F_Mask },
748 { wxT(
"FabricationDrawing" ),
Dwgs_User },
750 { wxT(
"TopAssemblyDrawing" ),
F_Fab },
751 { wxT(
"BotAssemblyDrawing" ),
B_Fab },
757 std::map<wxString, PCB_LAYER_ID>::iterator it;
759 int numKicadMatches = 0;
768 if( ( aGerber2KicadMapping.size() != 0 )
771 return numKicadMatches;
777 if( aGerber2KicadMapping.size() == 0 )
791 wxCHECK( x2, numKicadMatches );
799 if( mapThis.IsSameAs( wxT(
"Inr" ),
false ) )
809 it = kicadLayers.find( mapThis );
811 if( it != kicadLayers.end() )
819 aGerber2KicadMapping[ii] = it->second;
827 return numKicadMatches;
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Class DIALOG_MAP_GERBER_LAYERS_TO_PCB_BASE.
wxFlexGridSizer * m_flexLeftColumnBoxSizer
wxComboBox * m_comboCopperLayersCount
wxButton * m_buttonRetrieve
wxFlexGridSizer * m_flexRightColumnBoxSizer
wxStaticLine * m_staticlineSep
Show the Gerber files loaded and allow the user to choose between Gerber layers and pcb layers.
bool TransferDataFromWindow() override
int m_layersLookUpTable[GERBER_DRAWLAYERS_COUNT]
void OnStoreSetup(wxCommandEvent &event) override
GERBVIEW_FRAME * m_Parent
static int m_exportBoardCopperLayersCount
int findNumKiCadGerbersLoaded(std::vector< int > &aGerber2KicadMapping)
Find number of loaded Gerbers using KiCad naming convention.
wxStaticText * m_layersList[int(GERBER_DRAWLAYERS_COUNT)+1]
void OnResetClick(wxCommandEvent &event) override
int m_gerberActiveLayersCount
void OnSelectLayer(wxCommandEvent &event)
int m_buttonTable[int(GERBER_DRAWLAYERS_COUNT)+1]
int findNumX2GerbersLoaded(std::vector< int > &aGerber2KicadMapping)
Find number of loaded Gerbers using X2 File Functions to define layers.
void OnBrdLayersCountSelection(wxCommandEvent &event) override
int findKnownGerbersLoaded(std::vector< int > &aGerber2KicadMapping)
Find number of loaded Gerbers where the matching KiCad layer can be identified.
void OnGetSetup(wxCommandEvent &event) override
int findNumAltiumGerbersLoaded(std::vector< int > &aGerber2KicadMapping)
Find number of loaded Gerbers using Altium file extensions.
void normalizeBrdLayersCount()
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
X2_ATTRIBUTE_FILEFUNCTION * m_FileFunction
file function parameters, found in a TF command or a G04
wxString m_FileName
Full File Name for this layer.
bool m_IsX2_file
True if a X2 gerber attribute was found in file.
APP_SETTINGS_BASE * KifaceSettings() const
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
X2_ATTRIBUTE_FILEFUNCTION ( from TF.FileFunction in Gerber file) Example file function: TF....
bool IsCopper()
return true if the filefunction type is "Copper"
const wxString & GetBrdLayerSide()
the brd layer Pos: Top, Bot, Inr same as GetBrdLayerId() for non copper type
const wxString & GetFileType()
the type of layer (Copper, Soldermask ... )
const wxString & GetBrdLayerId()
the brd layer identifier: Ln, only for Copper type or Top, Bot for other types
This file is part of the common library.
#define KICAD_MESSAGE_DIALOG
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
size_t CopperLayerToOrdinal(PCB_LAYER_ID aLayer)
Converts KiCad copper layer enum to an ordinal between the front and back layers.
bool IsInnerCopperLayer(int aLayerId)
Test whether a layer is an inner (In1_Cu to In30_Cu) copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
bool IsValidLayer(int aLayerId)
Test whether a given integer is a valid layer index, i.e.
#define GERBER_DRAWLAYERS_COUNT
Number of draw layers in Gerbview.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
EVT_COMMAND_RANGE(ID_MATRIX_0, ID_MATRIX_0+(PINMAP_TYPE_COUNT *PINMAP_TYPE_COUNT) - 1, wxEVT_COMMAND_BUTTON_CLICKED, PANEL_SETUP_PINMAP::changeErrorLevel) PANEL_SETUP_PINMAP