59 wxEVT_COMMAND_BUTTON_CLICKED,
72 GetSizer()->SetSizeHints(
this );
151 label =
new wxStaticText(
this, wxID_STATIC, msg );
152 flexColumnBoxSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
156 label =
new wxStaticText(
this, wxID_STATIC, fn.GetFullName() );
157 flexColumnBoxSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
161 wxButton * Button =
new wxButton(
this, item_ID, wxT(
"..." ), wxDefaultPosition,
162 wxDefaultSize, wxBU_EXACTFIT );
164 flexColumnBoxSizer->Add( Button, 0, wxALIGN_CENTER_VERTICAL | wxALL );
175 msg =
_(
"Do not export" );
176 text =
new wxStaticText(
this, item_ID, msg );
177 text->SetForegroundColour( *wxBLUE );
189 goodSize =
text->GetSize();
195 if( goodSize.x <
text->GetSize().x )
196 goodSize.x =
text->GetSize().x;
198 text->SetLabel( msg );
201 text->SetMinSize( goodSize );
202 flexColumnBoxSizer->Add(
text, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
209 if(
config->m_GerberToPcbLayerMapping.size() == 0 )
212 std::vector<int> gerber2KicadMapping;
217 if( numMappedGerbers > 0 )
220 int returnVal = wxMessageBox(
221 _(
"Gerbers with known layers: " +
wxString::Format( wxT(
"%i" ), numMappedGerbers )
222 +
"\n\nAssign to matching KiCad PCB layers?" ),
223 _(
"Automatic Layer Assignment" ), wxOK | wxCANCEL | wxOK_DEFAULT );
225 if( returnVal == wxOK )
229 int currLayer = gerber2KicadMapping[ii];
243 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
270 int id =
event.GetSelection();
296 config->m_GerberToPcbLayerMapping.clear();
320 if( (
size_t)ii >=
config->m_GerberToPcbLayerMapping.size() )
338 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
343 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
355 wxFAIL_MSG( wxT(
"Bad layer id" ) );
368 wxString layerName = wxT(
"\"" ) + fn.GetFullName() + wxT(
"\"" );
394 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
402 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
414 if( !wxDialog::TransferDataFromWindow() )
420 int inner_layer_max = 0;
435 wxMessageBox(
_(
"Exported board does not have enough copper layers to handle selected "
446 int numKnownGerbers = 0;
462 return numKnownGerbers;
472 std::map<wxString, PCB_LAYER_ID> altiumExt{
473 { wxT(
"GTL" ),
F_Cu },
504 { wxT(
"GBL" ),
B_Cu },
517 std::map<wxString, PCB_LAYER_ID>::iterator it;
519 int numAltiumMatches = 0;
526 if( ( aGerber2KicadMapping.size() != 0 )
528 return numAltiumMatches;
533 if( aGerber2KicadMapping.size() == 0 )
545 wxString FileExt = fn.GetExt();
549 it = altiumExt.find( FileExt );
551 if( it != altiumExt.end() )
559 aGerber2KicadMapping[ii] = it->second;
569 return numAltiumMatches;
579 std::map<wxString, PCB_LAYER_ID> kicadLayers
629 std::map<wxString, PCB_LAYER_ID>::iterator it;
631 int numKicadMatches = 0;
638 if( ( aGerber2KicadMapping.size() != 0 )
640 return numKicadMatches;
645 if( aGerber2KicadMapping.size() == 0 )
656 wxString layerName = fn.GetName();
662 int dashPos = layerName.Find(
'-',
true );
667 if( dashPos != wxNOT_FOUND )
668 suffix = layerName.Right( layerName.length() - dashPos );
671 it = kicadLayers.find( suffix );
673 if( it != kicadLayers.end() )
681 aGerber2KicadMapping[ii] = it->second;
691 return numKicadMatches;
701 std::map<wxString, PCB_LAYER_ID> kicadLayers
703 { wxT(
"Top" ),
F_Cu },
733 { wxT(
"Bot" ),
B_Cu },
736 { wxT(
"BotPaste" ),
B_Paste },
737 { wxT(
"TopPaste" ),
F_Paste },
738 { wxT(
"BotLegend" ),
B_SilkS },
739 { wxT(
"TopLegend" ),
F_SilkS },
740 { wxT(
"BotSoldermask" ),
B_Mask },
741 { wxT(
"TopSoldermask" ),
F_Mask },
742 { wxT(
"FabricationDrawing" ),
Dwgs_User },
744 { wxT(
"TopAssemblyDrawing" ),
Eco1_User },
745 { wxT(
"BotAssemblyDrawing" ),
Eco2_User },
751 std::map<wxString, PCB_LAYER_ID>::iterator it;
753 int numKicadMatches = 0;
762 if( ( aGerber2KicadMapping.size() != 0 )
764 return numKicadMatches;
769 if( aGerber2KicadMapping.size() == 0 )
783 wxCHECK( x2, numKicadMatches );
791 if( mapThis.IsSameAs( wxT(
"Inr" ),
false ) )
801 it = kicadLayers.find( mapThis );
803 if( it != kicadLayers.end() )
811 aGerber2KicadMapping[ii] = it->second;
819 return numKicadMatches;
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
GERBER_FILE_IMAGE_LIST * GetImagesList() const
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.
int SelectPCBLayer(int aDefaultLayer, int aCopperLayerCount, const wxString &aGerberName)
Show the dialog box for layer selection.
GBR_LAYOUT * GetGerberLayout() const
APP_SETTINGS_BASE * KifaceSettings() const
Class LAYERS_MAP_DIALOG_BASE.
wxStaticLine * m_staticlineSep
wxButton * m_buttonRetrieve
wxComboBox * m_comboCopperLayersCount
wxFlexGridSizer * m_flexLeftColumnBoxSizer
wxFlexGridSizer * m_flexRightColumnBoxSizer
Show the Gerber files loaded and allow the user to choose between Gerber layers and pcb layers.
void OnStoreSetup(wxCommandEvent &event) override
int findNumX2GerbersLoaded(std::vector< int > &aGerber2KicadMapping)
Find number of loaded Gerbers using X2 File Functions to define layers.
void OnBrdLayersCountSelection(wxCommandEvent &event) override
GERBVIEW_FRAME * m_Parent
void OnSelectLayer(wxCommandEvent &event)
void normalizeBrdLayersCount()
static int m_exportBoardCopperLayersCount
int findNumAltiumGerbersLoaded(std::vector< int > &aGerber2KicadMapping)
Find number of loaded Gerbers using Altium file extensions.
wxStaticText * m_layersList[int(GERBER_DRAWLAYERS_COUNT)+1]
int findKnownGerbersLoaded(std::vector< int > &aGerber2KicadMapping)
Find number of loaded Gerbers where the matching KiCad layer can be identified.
int findNumKiCadGerbersLoaded(std::vector< int > &aGerber2KicadMapping)
Find number of loaded Gerbers using KiCad naming convention.
void OnGetSetup(wxCommandEvent &event) override
bool TransferDataFromWindow() override
int m_layersLookUpTable[GERBER_DRAWLAYERS_COUNT]
int m_buttonTable[int(GERBER_DRAWLAYERS_COUNT)+1]
int m_gerberActiveLayersCount
void OnResetClick(wxCommandEvent &event) override
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
const wxString GetPCBDefaultLayerName(int aLayerNumber)
EVT_COMMAND_RANGE(ID_BUTTON_0, ID_BUTTON_0+GERBER_DRAWLAYERS_COUNT-1, wxEVT_COMMAND_BUTTON_CLICKED, LAYERS_MAP_DIALOG::OnSelectLayer) LAYERS_MAP_DIALOG
bool IsValidLayer(int aLayerId)
Test whether a given integer is a valid layer index, i.e.
#define GERBER_DRAWLAYERS_COUNT
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.