29#include <wx/checkbox.h>
35 return aLayerName + wxT(
" *" );
41 if( !aLayerName.EndsWith( wxT(
" *" ) ) )
44 return aLayerName.Left( aLayerName.Length() - 2 );
51 return m_board->GetLayerName( aLayer );
63 if( layerDescription.Name == layerName )
64 return &layerDescription;
74 wxString selectedKiCadLayerName;
78 wxLIST_STATE_SELECTED ) ) != wxNOT_FOUND )
89 wxLIST_STATE_SELECTED ) ) == wxNOT_FOUND,
90 wxT(
"There are more than one KiCad layer selected (unexpected)" ) );
108 if( inputLayerDesc.Name == pureInputLayerName
111 return inputLayerDesc.AutoMapLayer;
128 wxArrayInt rowsToDelete;
131 wxLIST_STATE_SELECTED ) )
148 if( *iter == selectedLayerName )
155 rowsToDelete.Add( itemIndex );
168 wxArrayInt rowsToDelete;
171 while( ( itemIndex =
m_matched_layers_list->GetNextItem( itemIndex, wxLIST_NEXT_ALL, aStatus ) ) != wxNOT_FOUND )
174 wxString pureSelectedLayerName =
UnwrapRequired( selectedLayerName );
180 rowsToDelete.Add( itemIndex );
192 for(
long n = (
long) aRowsToDelete.GetCount() - 1; 0 <= n; n-- )
193 aListCtrl->DeleteItem( aRowsToDelete[n] );
201 wxArrayInt rowsToDelete;
204 wxLIST_STATE_DONTCARE ) ) != wxNOT_FOUND )
223 if( *iter == layerName )
230 rowsToDelete.Add( itemIndex );
248 m_input_layers.push_back( inLayer );
249 wxString layerName = inLayer.Required ? WrapRequired( inLayer.Name ) : inLayer.Name;
250 m_unmatched_layer_names.push_back( layerName );
251 kiCadLayers |= inLayer.PermittedLayers;
254 int maxTextWidth = GetTextExtent(
_(
"Imported Layer" ) ).x;
257 maxTextWidth = std::max( maxTextWidth, GetTextExtent( layer.Name ).x );
260 wxListItem importedLayersHeader;
261 importedLayersHeader.SetId( 0 );
262 importedLayersHeader.SetText(
_(
"Imported Layer" ) );
263 importedLayersHeader.SetWidth( maxTextWidth + 15 );
266 int kicadMaxTextWidth = GetTextExtent( wxT(
"User.Drawings" ) ).x;
268 wxListItem kicadLayersHeader;
269 kicadLayersHeader.SetId( 0 );
270 kicadLayersHeader.SetText(
_(
"KiCad Layer" ) );
271 kicadLayersHeader.SetWidth( kicadMaxTextWidth + 5 );
274 kicadLayersHeader.SetId( 1 );
275 importedLayersHeader.SetWidth( maxTextWidth + 15 );
276 kicadLayersHeader.SetWidth( kicadMaxTextWidth + 5 );
287 item.SetText( importedLayerName );
297 LSEQ kicadLayersSeq = kiCadLayers.UIOrder();
305 item.SetText( kiName );
325 std::vector<wxString> unmappedLayers;
330 wxASSERT_MSG( layerDesc !=
nullptr, wxT(
"Expected to find layer description" ) );
333 unmappedLayers.push_back( layerDesc->
Name );
336 return unmappedLayers;
340std::map<wxString, PCB_LAYER_ID>
352 wxMessageBox(
_(
"All required layers (marked with '*') must be matched. Please click "
353 "'Auto-Match Layers' to automatically match the remaining layers" ),
354 _(
"Unmatched Layers" ), wxICON_ERROR | wxOK );
wxListCtrl * m_matched_layers_list
DIALOG_IMPORTED_LAYERS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Edit Mapping of Imported Layers"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxCheckBox * m_cbKeepKiCadLayerNames
wxListCtrl * m_unmatched_layers_list
wxListCtrl * m_kicad_layers_list
std::vector< wxString > GetUnmappedRequiredLayers() const
Return a list of layers names that are required, but they are not mapped.
const INPUT_LAYER_DESC * GetLayerDescription(const wxString &aLayerName) const
void RemoveMappings(int aStatus)
void OnAutoMatchLayersClicked(wxCommandEvent &event) override
std::vector< INPUT_LAYER_DESC > m_input_layers
std::vector< wxString > m_unmatched_layer_names
static wxString UnwrapRequired(const wxString &aLayerName)
std::map< wxString, PCB_LAYER_ID > m_matched_layers_map
PCB_LAYER_ID GetSelectedLayerID()
static std::map< wxString, PCB_LAYER_ID > RunModal(wxWindow *aParent, const std::vector< INPUT_LAYER_DESC > &aLayerDesc)
Create and show a dialog (modal) and returns the data from it after completion.
wxString KiCadLayerName(PCB_LAYER_ID aLayer) const
KiCad layer name to display, using the destination board's names when available.
DIALOG_MAP_LAYERS(wxWindow *aParent, const std::vector< INPUT_LAYER_DESC > &aLayerDesc)
PCB_LAYER_ID GetAutoMatchLayerID(const wxString &aInputLayerName)
static wxString WrapRequired(const wxString &aLayerName)
void DeleteListItems(const wxArrayInt &aRowsToDelete, wxListCtrl *aListCtrl)
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
EDA_BASE_FRAME * m_parentFrame
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)