2020-10-01 22:47:38 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Roberto Fernandez Bautista <roberto.fer.bau@gmail.com>
|
2021-06-04 16:21:48 +00:00
|
|
|
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-10-01 22:47:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DIALOG_IMPORTED_LAYERS_H
|
|
|
|
#define DIALOG_IMPORTED_LAYERS_H
|
|
|
|
|
|
|
|
#include <dialog_imported_layers_base.h>
|
2020-10-09 16:58:21 +00:00
|
|
|
#include <plugins/common/plugin_common_layer_mapping.h>
|
2020-10-01 22:47:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DIALOG_IMPORTED_LAYERS : public DIALOG_IMPORTED_LAYERS_BASE
|
|
|
|
{
|
2021-06-04 16:21:48 +00:00
|
|
|
public:
|
|
|
|
DIALOG_IMPORTED_LAYERS( wxWindow* aParent, const std::vector<INPUT_LAYER_DESC>& aLayerDesc );
|
2020-10-01 22:47:38 +00:00
|
|
|
|
2021-06-04 16:21:48 +00:00
|
|
|
/**
|
|
|
|
* Return a list of layers names that are required, but they are not mapped.
|
|
|
|
*/
|
|
|
|
std::vector<wxString> GetUnmappedRequiredLayers() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create and show a dialog (modal) and returns the data from it after completion. If the
|
|
|
|
* dialog is closed or cancel is pressed, returns an empty map.
|
|
|
|
*
|
|
|
|
* @param aParent Parent window for the invoked dialog.
|
|
|
|
* @param aLayerDesc
|
|
|
|
* @return Mapped layers
|
|
|
|
*/
|
|
|
|
static std::map<wxString, PCB_LAYER_ID> GetMapModal( wxWindow* aParent,
|
|
|
|
const std::vector<INPUT_LAYER_DESC>& aLayerDesc );
|
2020-10-01 22:47:38 +00:00
|
|
|
|
2021-06-04 16:21:48 +00:00
|
|
|
private:
|
2020-10-01 22:47:38 +00:00
|
|
|
//Helper functions
|
|
|
|
PCB_LAYER_ID GetSelectedLayerID();
|
2021-07-27 12:22:27 +00:00
|
|
|
PCB_LAYER_ID GetAutoMatchLayerID( const wxString& aInputLayerName );
|
2020-10-09 16:58:21 +00:00
|
|
|
|
|
|
|
void AddMappings();
|
|
|
|
void RemoveMappings( int aStatus );
|
|
|
|
void DeleteListItems( const wxArrayInt& aRowsToDelete, wxListCtrl* aListCtrl );
|
|
|
|
|
|
|
|
const INPUT_LAYER_DESC* GetLayerDescription( const wxString& aLayerName ) const;
|
|
|
|
|
|
|
|
static wxString WrapRequired( const wxString& aLayerName );
|
|
|
|
static wxString UnwrapRequired( const wxString& aLayerName );
|
2020-10-01 22:47:38 +00:00
|
|
|
|
|
|
|
//Event Handlers
|
|
|
|
void OnAutoMatchLayersClicked( wxCommandEvent& event ) override;
|
|
|
|
|
|
|
|
void OnUnMatchedDoubleClick( wxListEvent& event ) override { AddMappings(); }
|
|
|
|
void OnAddClicked( wxCommandEvent& event ) override { AddMappings(); }
|
|
|
|
void OnMatchedDoubleClick( wxListEvent& event ) override { RemoveMappings( selected ); }
|
|
|
|
void OnRemoveClicked( wxCommandEvent& event ) override { RemoveMappings( selected ); }
|
|
|
|
void OnRemoveAllClicked( wxCommandEvent& event ) override { RemoveMappings( allitems ); }
|
|
|
|
|
2021-06-04 16:21:48 +00:00
|
|
|
const int selected = wxLIST_STATE_SELECTED;
|
|
|
|
const int allitems = wxLIST_STATE_DONTCARE;
|
2020-10-09 16:58:21 +00:00
|
|
|
|
2021-06-04 16:21:48 +00:00
|
|
|
std::vector<INPUT_LAYER_DESC> m_input_layers;
|
|
|
|
std::vector<wxString> m_unmatched_layer_names;
|
|
|
|
std::map<wxString, PCB_LAYER_ID> m_matched_layers_map;
|
2020-10-01 22:47:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DIALOG_IMPORTED_LAYERS_H
|