53 wxEVT_COMMAND_BUTTON_CLICKED,
66 GetSizer()->SetSizeHints(
this );
145 label =
new wxStaticText(
this, wxID_STATIC, msg );
146 flexColumnBoxSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
150 label =
new wxStaticText(
this, wxID_STATIC, fn.GetFullName() );
151 flexColumnBoxSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
155 wxButton * Button =
new wxButton(
this, item_ID, wxT(
"..." ), wxDefaultPosition,
156 wxDefaultSize, wxBU_EXACTFIT );
158 flexColumnBoxSizer->Add( Button, 0, wxALIGN_CENTER_VERTICAL | wxALL );
169 msg =
_(
"Do not export" );
170 text =
new wxStaticText(
this, item_ID, msg );
171 text->SetForegroundColour( *wxBLUE );
183 goodSize =
text->GetSize();
189 if( goodSize.x <
text->GetSize().x )
190 goodSize.x =
text->GetSize().x;
192 text->SetLabel( msg );
195 text->SetMinSize( goodSize );
196 flexColumnBoxSizer->Add(
text, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
203 if(
config->m_GerberToPcbLayerMapping.size() == 0 )
206 std::vector<int> gerber2KicadMapping;
211 if( numMappedGerbers > 0 )
214 int returnVal = wxMessageBox(
215 wxString::Format(
_(
"Gerbers with known layers: %d" ), numMappedGerbers ) + wxT(
"\n\n" )
216 +
_(
"Assign to matching PCB layers?" ),
217 _(
"Automatic Layer Assignment" ), wxOK | wxCANCEL | wxOK_DEFAULT );
219 if( returnVal == wxOK )
221 int total_copper = 0;
225 int currLayer = gerber2KicadMapping[ii];
242 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
273 int id =
event.GetSelection();
299 config->m_GerberToPcbLayerMapping.clear();
323 if( (
size_t)ii >=
config->m_GerberToPcbLayerMapping.size() )
341 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
346 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
358 wxFAIL_MSG( wxT(
"Bad layer id" ) );
371 wxString layerName = wxT(
"\"" ) + fn.GetFullName() + wxT(
"\"" );
397 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
405 m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
417 if( !wxDialog::TransferDataFromWindow() )
423 int inner_layer_max = 0;
438 wxMessageBox(
_(
"Exported board does not have enough copper layers to handle selected "
449 int numKnownGerbers = 0;
463 return numKnownGerbers;
473 std::map<wxString, PCB_LAYER_ID> altiumExt{
474 { wxT(
"GTL" ),
F_Cu },
505 { wxT(
"GBL" ),
B_Cu },
518 std::map<wxString, PCB_LAYER_ID>::iterator it;
520 int numAltiumMatches = 0;
527 if( ( aGerber2KicadMapping.size() != 0 )
529 return numAltiumMatches;
534 if( aGerber2KicadMapping.size() == 0 )
546 wxString FileExt = fn.GetExt();
550 it = altiumExt.find( FileExt );
552 if( it != altiumExt.end() )
560 aGerber2KicadMapping[ii] = it->second;
570 return numAltiumMatches;
580 std::map<wxString, PCB_LAYER_ID> kicadLayers
639 std::map<wxString, PCB_LAYER_ID>::iterator it;
641 int numKicadMatches = 0;
648 if( ( aGerber2KicadMapping.size() != 0 )
650 return numKicadMatches;
655 if( aGerber2KicadMapping.size() == 0 )
666 wxString layerName = fn.GetName();
672 int dashPos = layerName.Find(
'-',
true );
677 if( dashPos != wxNOT_FOUND )
678 suffix = layerName.Right( layerName.length() - dashPos );
681 it = kicadLayers.find( suffix );
683 if( it != kicadLayers.end() )
691 aGerber2KicadMapping[ii] = it->second;
701 return numKicadMatches;
711 std::map<wxString, PCB_LAYER_ID> kicadLayers
713 { wxT(
"Top" ),
F_Cu },
743 { wxT(
"Bot" ),
B_Cu },
746 { wxT(
"BotPaste" ),
B_Paste },
747 { wxT(
"TopPaste" ),
F_Paste },
748 { wxT(
"BotLegend" ),
B_SilkS },
749 { wxT(
"TopLegend" ),
F_SilkS },
750 { wxT(
"BotSoldermask" ),
B_Mask },
751 { wxT(
"TopSoldermask" ),
F_Mask },
752 { wxT(
"FabricationDrawing" ),
Dwgs_User },
754 { wxT(
"TopAssemblyDrawing" ),
F_Fab },
755 { wxT(
"BotAssemblyDrawing" ),
B_Fab },
761 std::map<wxString, PCB_LAYER_ID>::iterator it;
763 int numKicadMatches = 0;
772 if( ( aGerber2KicadMapping.size() != 0 )
774 return numKicadMatches;
779 if( aGerber2KicadMapping.size() == 0 )
793 wxCHECK( x2, numKicadMatches );
801 if( mapThis.IsSameAs( wxT(
"Inr" ),
false ) )
811 it = kicadLayers.find( mapThis );
813 if( it != kicadLayers.end() )
821 aGerber2KicadMapping[ii] = it->second;
829 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
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
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 IsCopperLayer(int aLayerId)
Test whether a layer is a 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.
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...