28#include <wx/checkbox.h>
34 return aLayerName + wxT(
" *" );
40 if( !aLayerName.EndsWith( wxT(
" *" ) ) )
43 return aLayerName.Left( aLayerName.Length() - 2 );
53 if( layerDescription.Name == layerName )
54 return &layerDescription;
64 wxString selectedKiCadLayerName;
68 wxLIST_STATE_SELECTED ) ) != wxNOT_FOUND )
79 wxLIST_STATE_SELECTED ) ) == wxNOT_FOUND,
80 wxT(
"There are more than one KiCad layer selected (unexpected)" ) );
98 if( inputLayerDesc.Name == pureInputLayerName
101 return inputLayerDesc.AutoMapLayer;
118 wxArrayInt rowsToDelete;
121 wxLIST_STATE_SELECTED ) )
125 wxString kiName =
LayerName( selectedKiCadLayerID );
138 if( *iter == selectedLayerName )
145 rowsToDelete.Add( itemIndex );
157 wxArrayInt rowsToDelete;
160 while( ( itemIndex =
m_matched_layers_list->GetNextItem( itemIndex, wxLIST_NEXT_ALL, aStatus ) ) != wxNOT_FOUND )
163 wxString pureSelectedLayerName =
UnwrapRequired( selectedLayerName );
169 rowsToDelete.Add( itemIndex );
181 for(
long n = (
long) aRowsToDelete.GetCount() - 1; 0 <= n; n-- )
182 aListCtrl->DeleteItem( aRowsToDelete[n] );
190 wxArrayInt rowsToDelete;
193 wxLIST_STATE_DONTCARE ) ) != wxNOT_FOUND )
201 wxString kiName =
LayerName( autoMatchLayer );
212 if( *iter == layerName )
219 rowsToDelete.Add( itemIndex );
235 wxString layerName = inLayer.Required ?
WrapRequired( inLayer.Name ) : inLayer.Name;
237 kiCadLayers |= inLayer.PermittedLayers;
240 int maxTextWidth = GetTextExtent(
_(
"Imported Layer" ) ).x;
243 maxTextWidth = std::max( maxTextWidth, GetTextExtent( layer.Name ).x );
246 wxListItem importedLayersHeader;
247 importedLayersHeader.SetId( 0 );
248 importedLayersHeader.SetText(
_(
"Imported Layer" ) );
249 importedLayersHeader.SetWidth( maxTextWidth + 15 );
252 int kicadMaxTextWidth = GetTextExtent( wxT(
"User.Drawings" ) ).x;
254 wxListItem kicadLayersHeader;
255 kicadLayersHeader.SetId( 0 );
256 kicadLayersHeader.SetText(
_(
"KiCad Layer" ) );
257 kicadLayersHeader.SetWidth( kicadMaxTextWidth + 5 );
260 kicadLayersHeader.SetId( 1 );
261 importedLayersHeader.SetWidth( maxTextWidth + 15 );
262 kicadLayersHeader.SetWidth( kicadMaxTextWidth + 5 );
273 item.SetText( importedLayerName );
291 item.SetText( kiName );
311 std::vector<wxString> unmappedLayers;
316 wxASSERT_MSG( layerDesc !=
nullptr, wxT(
"Expected to find layer description" ) );
319 unmappedLayers.push_back( layerDesc->
Name );
322 return unmappedLayers;
326std::map<wxString, PCB_LAYER_ID>
338 wxMessageBox(
_(
"All required layers (marked with '*') must be matched. Please click "
339 "'Auto-Match Layers' to automatically match the remaining layers" ),
340 _(
"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.
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.
LSEQ UIOrder() const
Return the copper, technical and user layers in the order shown in layer widget.
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)