54 wxEVT_COMMAND_BUTTON_CLICKED,
67 GetSizer()->SetSizeHints(
this );
146 label =
new wxStaticText(
this, wxID_STATIC, msg );
147 flexColumnBoxSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
151 label =
new wxStaticText(
this, wxID_STATIC, fn.GetFullName() );
152 flexColumnBoxSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
156 wxButton * Button =
new wxButton(
this, item_ID, wxT(
"..." ), wxDefaultPosition,
157 wxDefaultSize, wxBU_EXACTFIT );
159 flexColumnBoxSizer->Add( Button, 0, wxALIGN_CENTER_VERTICAL | wxALL );
170 msg =
_(
"Do not export" );
171 text =
new wxStaticText(
this, item_ID, msg );
172 text->SetForegroundColour( *wxBLUE );
184 goodSize =
text->GetSize();
190 if( goodSize.x <
text->GetSize().x )
191 goodSize.x =
text->GetSize().x;
193 text->SetLabel( msg );
196 text->SetMinSize( goodSize );
197 flexColumnBoxSizer->Add(
text, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
204 if(
config->m_GerberToPcbLayerMapping.size() == 0 )
207 std::vector<int> gerber2KicadMapping;
212 if( numMappedGerbers > 0 )
215 int returnVal = wxMessageBox(
216 _(
"Gerbers with known layers: " + wxString::Format( wxT(
"%i" ), numMappedGerbers )
217 +
"\n\nAssign to matching KiCad PCB layers?" ),
218 _(
"Automatic Layer Assignment" ), wxOK | wxCANCEL | wxOK_DEFAULT );
220 if( returnVal == wxOK )
224 int currLayer = gerber2KicadMapping[ii];
238 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
265 int id =
event.GetSelection();
291 config->m_GerberToPcbLayerMapping.clear();
315 if( (
size_t)ii >=
config->m_GerberToPcbLayerMapping.size() )
333 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
338 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
350 wxFAIL_MSG( wxT(
"Bad layer id" ) );
363 wxString layerName = wxT(
"\"" ) + fn.GetFullName() + wxT(
"\"" );
389 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
397 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
409 if( !wxDialog::TransferDataFromWindow() )
415 int inner_layer_max = 0;
430 wxMessageBox(
_(
"Exported board does not have enough copper layers to handle selected "
441 int numKnownGerbers = 0;
457 return numKnownGerbers;
467 std::map<wxString, PCB_LAYER_ID> altiumExt{
468 { wxT(
"GTL" ),
F_Cu },
499 { wxT(
"GBL" ),
B_Cu },
512 std::map<wxString, PCB_LAYER_ID>::iterator it;
514 int numAltiumMatches = 0;
521 if( ( aGerber2KicadMapping.size() != 0 )
523 return numAltiumMatches;
528 if( aGerber2KicadMapping.size() == 0 )
540 wxString FileExt = fn.GetExt();
544 it = altiumExt.find( FileExt );
546 if( it != altiumExt.end() )
554 aGerber2KicadMapping[ii] = it->second;
564 return numAltiumMatches;
574 std::map<wxString, PCB_LAYER_ID> kicadLayers
624 std::map<wxString, PCB_LAYER_ID>::iterator it;
626 int numKicadMatches = 0;
633 if( ( aGerber2KicadMapping.size() != 0 )
635 return numKicadMatches;
640 if( aGerber2KicadMapping.size() == 0 )
651 wxString layerName = fn.GetName();
657 int dashPos = layerName.Find(
'-',
true );
662 if( dashPos != wxNOT_FOUND )
663 suffix = layerName.Right( layerName.length() - dashPos );
666 it = kicadLayers.find( suffix );
668 if( it != kicadLayers.end() )
676 aGerber2KicadMapping[ii] = it->second;
686 return numKicadMatches;
696 std::map<wxString, PCB_LAYER_ID> kicadLayers
698 { wxT(
"Top" ),
F_Cu },
728 { wxT(
"Bot" ),
B_Cu },
731 { wxT(
"BotPaste" ),
B_Paste },
732 { wxT(
"TopPaste" ),
F_Paste },
733 { wxT(
"BotLegend" ),
B_SilkS },
734 { wxT(
"TopLegend" ),
F_SilkS },
735 { wxT(
"BotSoldermask" ),
B_Mask },
736 { wxT(
"TopSoldermask" ),
F_Mask },
737 { wxT(
"FabricationDrawing" ),
Dwgs_User },
739 { wxT(
"TopAssemblyDrawing" ),
Eco1_User },
740 { wxT(
"BotAssemblyDrawing" ),
Eco2_User },
746 std::map<wxString, PCB_LAYER_ID>::iterator it;
748 int numKicadMatches = 0;
757 if( ( aGerber2KicadMapping.size() != 0 )
759 return numKicadMatches;
764 if( aGerber2KicadMapping.size() == 0 )
778 wxCHECK( x2, numKicadMatches );
786 if( mapThis.IsSameAs( wxT(
"Inr" ),
false ) )
796 it = kicadLayers.find( mapThis );
798 if( it != kicadLayers.end() )
806 aGerber2KicadMapping[ii] = it->second;
814 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...