KiCad PCB EDA Suite
dialog_imported_layers.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2020 Roberto Fernandez Bautista <roberto.fer.bau@gmail.com>
5  * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef DIALOG_IMPORTED_LAYERS_H
22 #define DIALOG_IMPORTED_LAYERS_H
23 
26 
27 
29 {
30 private:
31  const int selected = wxLIST_STATE_SELECTED;
32  const int allitems = wxLIST_STATE_DONTCARE;
33 
34  std::vector<INPUT_LAYER_DESC> m_input_layers;
35  std::vector<wxString> m_unmatched_layer_names;
36  std::map<wxString, PCB_LAYER_ID> m_matched_layers_map;
37 
38  //Helper functions
40  PCB_LAYER_ID GetAutoMatchLayerID( wxString aInputLayerName );
41 
42  void AddMappings();
43  void RemoveMappings( int aStatus );
44  void DeleteListItems( const wxArrayInt& aRowsToDelete, wxListCtrl* aListCtrl );
45 
46  const INPUT_LAYER_DESC* GetLayerDescription( const wxString& aLayerName ) const;
47 
48  static wxString WrapRequired( const wxString& aLayerName );
49  static wxString UnwrapRequired( const wxString& aLayerName );
50 
51  //Event Handlers
52  void OnAutoMatchLayersClicked( wxCommandEvent& event ) override;
53 
54  void OnUnMatchedDoubleClick( wxListEvent& event ) override { AddMappings(); }
55  void OnAddClicked( wxCommandEvent& event ) override { AddMappings(); }
56  void OnMatchedDoubleClick( wxListEvent& event ) override { RemoveMappings( selected ); }
57  void OnRemoveClicked( wxCommandEvent& event ) override { RemoveMappings( selected ); }
58  void OnRemoveAllClicked( wxCommandEvent& event ) override { RemoveMappings( allitems ); }
59 
60 public:
61  DIALOG_IMPORTED_LAYERS( wxWindow* aParent, const std::vector<INPUT_LAYER_DESC>& aLayerDesc );
62 
66  std::vector<wxString> GetUnmappedRequiredLayers() const;
67 
76  static std::map<wxString, PCB_LAYER_ID> GetMapModal( wxWindow* aParent,
77  const std::vector<INPUT_LAYER_DESC>& aLayerDesc );
78 };
79 
80 #endif // DIALOG_IMPORTED_LAYERS_H
void DeleteListItems(const wxArrayInt &aRowsToDelete, wxListCtrl *aListCtrl)
Class DIALOG_IMPORTED_LAYERS_BASE.
std::vector< wxString > m_unmatched_layer_names
void OnUnMatchedDoubleClick(wxListEvent &event) override
void OnMatchedDoubleClick(wxListEvent &event) override
PCB_LAYER_ID GetAutoMatchLayerID(wxString aInputLayerName)
static wxString WrapRequired(const wxString &aLayerName)
Describes an imported layer and how it could be mapped to KiCad Layers.
void OnRemoveAllClicked(wxCommandEvent &event) override
void OnAddClicked(wxCommandEvent &event) override
PCB_LAYER_ID
A quick note on layer IDs:
static wxString UnwrapRequired(const wxString &aLayerName)
std::vector< wxString > GetUnmappedRequiredLayers() const
Return a list of layers names that are required, but they are not mapped.
void OnRemoveClicked(wxCommandEvent &event) override
DIALOG_IMPORTED_LAYERS(wxWindow *aParent, const std::vector< INPUT_LAYER_DESC > &aLayerDesc)
static std::map< wxString, PCB_LAYER_ID > GetMapModal(wxWindow *aParent, const std::vector< INPUT_LAYER_DESC > &aLayerDesc)
Creates and shows a dialog (modal) and returns the data from it after completion.
const INPUT_LAYER_DESC * GetLayerDescription(const wxString &aLayerName) const
std::vector< INPUT_LAYER_DESC > m_input_layers
void OnAutoMatchLayersClicked(wxCommandEvent &event) override
std::map< wxString, PCB_LAYER_ID > m_matched_layers_map