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 );
158 wxArrayInt rowsToDelete;
161 while( ( itemIndex =
m_matched_layers_list->GetNextItem( itemIndex, wxLIST_NEXT_ALL, aStatus ) ) != wxNOT_FOUND )
164 wxString pureSelectedLayerName =
UnwrapRequired( selectedLayerName );
170 rowsToDelete.Add( itemIndex );
182 for(
long n = (
long) aRowsToDelete.GetCount() - 1; 0 <= n; n-- )
183 aListCtrl->DeleteItem( aRowsToDelete[n] );
191 wxArrayInt rowsToDelete;
194 wxLIST_STATE_DONTCARE ) ) != wxNOT_FOUND )
202 wxString kiName =
LayerName( autoMatchLayer );
213 if( *iter == layerName )
220 rowsToDelete.Add( itemIndex );
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 );
312 std::vector<wxString> unmappedLayers;
317 wxASSERT_MSG( layerDesc !=
nullptr, wxT(
"Expected to find layer description" ) );
320 unmappedLayers.push_back( layerDesc->
Name );
323 return unmappedLayers;
327std::map<wxString, PCB_LAYER_ID>
339 wxMessageBox(
_(
"All required layers (marked with '*') must be matched. Please click "
340 "'Auto-Match Layers' to automatically match the remaining layers" ),
341 _(
"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)