31 return aLayerName + wxT(
" *" );
37 if( !aLayerName.EndsWith( wxT(
" *" ) ) )
40 return aLayerName.Left( aLayerName.Length() - 2 );
50 if( layerDescription.Name == layerName )
51 return &layerDescription;
61 wxString selectedKiCadLayerName;
65 wxLIST_STATE_SELECTED ) ) != wxNOT_FOUND )
71 return PCB_LAYER_ID::UNDEFINED_LAYER;
76 wxLIST_STATE_SELECTED ) ) == wxNOT_FOUND,
77 wxT(
"There are more than one KiCad layer selected (unexpected)" ) );
85 return PCB_LAYER_ID::UNDEFINED_LAYER;
95 if( inputLayerDesc.Name == pureInputLayerName
96 && inputLayerDesc.AutoMapLayer != PCB_LAYER_ID::UNSELECTED_LAYER )
98 return inputLayerDesc.AutoMapLayer;
102 return PCB_LAYER_ID::UNDEFINED_LAYER;
110 if( selectedKiCadLayerID == PCB_LAYER_ID::UNDEFINED_LAYER )
115 wxArrayInt rowsToDelete;
118 wxLIST_STATE_SELECTED ) )
122 wxString kiName =
LayerName( selectedKiCadLayerID );
135 if( *iter == selectedLayerName )
142 rowsToDelete.Add( itemIndex );
154 wxArrayInt rowsToDelete;
161 wxString pureSelectedLayerName =
UnwrapRequired( selectedLayerName );
167 rowsToDelete.Add( itemIndex );
179 for(
long n = (
long) aRowsToDelete.GetCount() - 1; 0 <= n; n-- )
180 aListCtrl->DeleteItem( aRowsToDelete[n] );
188 wxArrayInt rowsToDelete;
191 wxLIST_STATE_DONTCARE ) )
197 if( autoMatchLayer == PCB_LAYER_ID::UNDEFINED_LAYER )
200 wxString kiName =
LayerName( autoMatchLayer );
212 if( *iter == layerName )
219 rowsToDelete.Add( itemIndex );
227 const std::vector<INPUT_LAYER_DESC>& aLayerDesc ) :
236 wxString layerName = inLayer.Required ?
WrapRequired( inLayer.Name ) : inLayer.Name;
238 kiCadLayers |= inLayer.PermittedLayers;
241 int maxTextWidth = GetTextExtent(
_(
"Imported Layer" ) ).x;
244 maxTextWidth = std::max( maxTextWidth, GetTextExtent( layer.Name ).x );
247 wxListItem importedLayersHeader;
248 importedLayersHeader.SetId( 0 );
249 importedLayersHeader.SetText(
_(
"Imported Layer" ) );
250 importedLayersHeader.SetWidth( maxTextWidth + 15 );
253 int kicadMaxTextWidth = GetTextExtent( wxT(
"User.Drawings" ) ).x;
255 wxListItem kicadLayersHeader;
256 kicadLayersHeader.SetId( 0 );
257 kicadLayersHeader.SetText(
_(
"KiCad Layer" ) );
258 kicadLayersHeader.SetWidth( kicadMaxTextWidth + 5 );
261 kicadLayersHeader.SetId( 1 );
262 importedLayersHeader.SetWidth( maxTextWidth + 15 );
263 kicadLayersHeader.SetWidth( kicadMaxTextWidth + 5 );
274 item.SetText( importedLayerName );
292 item.SetText( kiName );
309 std::vector<wxString> unmappedLayers;
314 wxASSERT_MSG( layerDesc !=
nullptr, wxT(
"Expected to find layer description" ) );
317 unmappedLayers.push_back( layerDesc->
Name );
320 return unmappedLayers;
324std::map<wxString, PCB_LAYER_ID>
336 wxMessageBox(
_(
"All required layers (marked with '*') must be matched. "
337 "Please click on 'Auto-Match Layers' to "
338 "automatically match the remaining layers" ),
339 _(
"Unmatched Layers" ), wxICON_ERROR | wxOK );
Class DIALOG_IMPORTED_LAYERS_BASE.
wxListCtrl * m_matched_layers_list
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.
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...
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
LSEQ UIOrder() const
Returns the copper, technical and user layers in the order shown in layer widget.
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)