30 return aLayerName + wxT(
" *" );
36 if( !aLayerName.EndsWith( wxT(
" *" ) ) )
39 return aLayerName.Left( aLayerName.Length() - 2 );
44 const wxString& aLayerName )
const
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;
94 if( inputLayerDesc.Name == pureInputLayerName
95 && inputLayerDesc.AutoMapLayer != PCB_LAYER_ID::UNSELECTED_LAYER )
97 return inputLayerDesc.AutoMapLayer;
101 return PCB_LAYER_ID::UNDEFINED_LAYER;
109 if( selectedKiCadLayerID == PCB_LAYER_ID::UNDEFINED_LAYER )
114 wxArrayInt rowsToDelete;
117 wxLIST_STATE_SELECTED ) )
121 wxString kiName =
LayerName( selectedKiCadLayerID );
134 if( *iter == selectedLayerName )
141 rowsToDelete.Add( itemIndex );
153 wxArrayInt rowsToDelete;
160 wxString pureSelectedLayerName =
UnwrapRequired( selectedLayerName );
166 rowsToDelete.Add( itemIndex );
177 wxListCtrl* aListCtrl )
179 for(
long n = ( aRowsToDelete.GetCount() - 1 ); 0 <= n; n-- )
181 aListCtrl->DeleteItem( aRowsToDelete[n] );
190 wxArrayInt rowsToDelete;
193 wxLIST_STATE_DONTCARE ) )
199 if( autoMatchLayer == PCB_LAYER_ID::UNDEFINED_LAYER )
202 wxString kiName =
LayerName( autoMatchLayer );
214 if( *iter == layerName )
221 rowsToDelete.Add( itemIndex );
229 const std::vector<INPUT_LAYER_DESC>& aLayerDesc ) :
238 wxString layerName = inLayer.Required ?
WrapRequired( inLayer.Name ) : inLayer.Name;
240 kiCadLayers |= inLayer.PermittedLayers;
243 int maxTextWidth = GetTextExtent(
_(
"Imported Layer" ) ).x;
246 maxTextWidth = std::max( maxTextWidth, GetTextExtent( layer.Name ).x );
249 wxListItem importedLayersHeader;
250 importedLayersHeader.SetId( 0 );
251 importedLayersHeader.SetText(
_(
"Imported Layer" ) );
252 importedLayersHeader.SetWidth( maxTextWidth + 15 );
255 int kicadMaxTextWidth = GetTextExtent( wxT(
"User.Drawings" ) ).x;
257 wxListItem kicadLayersHeader;
258 kicadLayersHeader.SetId( 0 );
259 kicadLayersHeader.SetText(
_(
"KiCad Layer" ) );
260 kicadLayersHeader.SetWidth( kicadMaxTextWidth + 5 );
263 kicadLayersHeader.SetId( 1 );
264 importedLayersHeader.SetWidth( maxTextWidth + 15 );
265 kicadLayersHeader.SetWidth( kicadMaxTextWidth + 5 );
276 item.SetText( importedLayerName );
286 LSEQ kicadLayersSeq = kiCadLayers.
Seq();
294 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>
328 const std::vector<INPUT_LAYER_DESC>& aLayerDesc )
339 wxMessageBox(
_(
"All required layers (marked with '*') must be matched. "
340 "Please click on 'Auto-Match Layers' to "
341 "automatically match the remaining layers" ),
342 _(
"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::map< wxString, PCB_LAYER_ID > m_matched_layers_map
static wxString WrapRequired(const wxString &aLayerName)
DIALOG_IMPORTED_LAYERS(wxWindow *aParent, const std::vector< INPUT_LAYER_DESC > &aLayerDesc)
static wxString UnwrapRequired(const wxString &aLayerName)
std::vector< INPUT_LAYER_DESC > m_input_layers
const INPUT_LAYER_DESC * GetLayerDescription(const wxString &aLayerName) const
PCB_LAYER_ID GetAutoMatchLayerID(const wxString &aInputLayerName)
void OnAutoMatchLayersClicked(wxCommandEvent &event) override
PCB_LAYER_ID GetSelectedLayerID()
std::vector< wxString > GetUnmappedRequiredLayers() const
Return a list of layers names that are required, but they are not mapped.
void DeleteListItems(const wxArrayInt &aRowsToDelete, wxListCtrl *aListCtrl)
static std::map< wxString, PCB_LAYER_ID > GetMapModal(wxWindow *aParent, const std::vector< INPUT_LAYER_DESC > &aLayerDesc)
Create and show a dialog (modal) and returns the data from it after completion.
void RemoveMappings(int aStatus)
std::vector< wxString > m_unmatched_layer_names
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 Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
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)