Clearer naming and commenting.
Also some const& hygiene and some formatting.
This commit is contained in:
parent
0a5784fc9e
commit
14a55facf2
|
@ -23,8 +23,8 @@
|
||||||
#include <wx/listctrl.h>
|
#include <wx/listctrl.h>
|
||||||
|
|
||||||
|
|
||||||
DIALOG_IMPORT_CHOOSE_PROJECT::DIALOG_IMPORT_CHOOSE_PROJECT(
|
DIALOG_IMPORT_CHOOSE_PROJECT::DIALOG_IMPORT_CHOOSE_PROJECT( wxWindow* aParent,
|
||||||
wxWindow* aParent, const std::vector<IMPORT_PROJECT_DESC>& aProjectDesc ) :
|
const std::vector<IMPORT_PROJECT_DESC>& aProjectDesc ) :
|
||||||
DIALOG_IMPORT_CHOOSE_PROJECT_BASE( aParent )
|
DIALOG_IMPORT_CHOOSE_PROJECT_BASE( aParent )
|
||||||
{
|
{
|
||||||
m_project_desc = aProjectDesc;
|
m_project_desc = aProjectDesc;
|
||||||
|
@ -49,8 +49,7 @@ DIALOG_IMPORT_CHOOSE_PROJECT::DIALOG_IMPORT_CHOOSE_PROJECT(
|
||||||
{
|
{
|
||||||
m_listCtrl->InsertItem( row, convertName( desc.ComboName, desc.ComboId ) );
|
m_listCtrl->InsertItem( row, convertName( desc.ComboName, desc.ComboId ) );
|
||||||
m_listCtrl->SetItem( row, pcbNameColId, convertName( desc.PCBName, desc.PCBId ) );
|
m_listCtrl->SetItem( row, pcbNameColId, convertName( desc.PCBName, desc.PCBId ) );
|
||||||
m_listCtrl->SetItem( row, schNameColId,
|
m_listCtrl->SetItem( row, schNameColId, convertName( desc.SchematicName, desc.SchematicId ) );
|
||||||
convertName( desc.SchematicName, desc.SchematicId ) );
|
|
||||||
|
|
||||||
++row;
|
++row;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +80,7 @@ void DIALOG_IMPORT_CHOOSE_PROJECT::onClose( wxCloseEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<IMPORT_PROJECT_DESC> DIALOG_IMPORT_CHOOSE_PROJECT::GetProjectSelections()
|
std::vector<IMPORT_PROJECT_DESC> DIALOG_IMPORT_CHOOSE_PROJECT::GetProjects()
|
||||||
{
|
{
|
||||||
std::vector<IMPORT_PROJECT_DESC> result;
|
std::vector<IMPORT_PROJECT_DESC> result;
|
||||||
|
|
||||||
|
@ -100,13 +99,14 @@ std::vector<IMPORT_PROJECT_DESC> DIALOG_IMPORT_CHOOSE_PROJECT::GetProjectSelecti
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<IMPORT_PROJECT_DESC> DIALOG_IMPORT_CHOOSE_PROJECT::GetSelectionsModal(
|
std::vector<IMPORT_PROJECT_DESC>
|
||||||
wxWindow* aParent, const std::vector<IMPORT_PROJECT_DESC>& aProjectDesc )
|
DIALOG_IMPORT_CHOOSE_PROJECT::RunModal( wxWindow* aParent,
|
||||||
|
const std::vector<IMPORT_PROJECT_DESC>& aProjectDesc )
|
||||||
{
|
{
|
||||||
DIALOG_IMPORT_CHOOSE_PROJECT dlg( aParent, aProjectDesc );
|
DIALOG_IMPORT_CHOOSE_PROJECT dlg( aParent, aProjectDesc );
|
||||||
|
|
||||||
if( dlg.ShowModal() != wxID_OK )
|
if( dlg.ShowModal() != wxID_OK )
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
return dlg.GetProjectSelections();
|
return dlg.GetProjects();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,13 +38,13 @@ public:
|
||||||
* @param aProjectDesc are project descriptors.
|
* @param aProjectDesc are project descriptors.
|
||||||
*/
|
*/
|
||||||
static std::vector<IMPORT_PROJECT_DESC>
|
static std::vector<IMPORT_PROJECT_DESC>
|
||||||
GetSelectionsModal( wxWindow* aParent, const std::vector<IMPORT_PROJECT_DESC>& aProjectDesc );
|
RunModal( wxWindow* aParent, const std::vector<IMPORT_PROJECT_DESC>& aProjectDesc );
|
||||||
|
|
||||||
void onItemActivated( wxListEvent& event ) override;
|
void onItemActivated( wxListEvent& event ) override;
|
||||||
|
|
||||||
void onClose( wxCloseEvent& event ) override;
|
void onClose( wxCloseEvent& event ) override;
|
||||||
|
|
||||||
std::vector<IMPORT_PROJECT_DESC> GetProjectSelections();
|
std::vector<IMPORT_PROJECT_DESC> GetProjects();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<IMPORT_PROJECT_DESC> m_project_desc;
|
std::vector<IMPORT_PROJECT_DESC> m_project_desc;
|
||||||
|
|
|
@ -60,7 +60,7 @@ public:
|
||||||
* The function is marked as virtual, so the plugins can implement extra
|
* The function is marked as virtual, so the plugins can implement extra
|
||||||
* logic (e.g., enable warnings or checks)
|
* logic (e.g., enable warnings or checks)
|
||||||
*/
|
*/
|
||||||
virtual void RegisterChooseProjectCallback( CHOOSE_PROJECT_HANDLER aChooseProjectHandler )
|
virtual void RegisterCallback( CHOOSE_PROJECT_HANDLER aChooseProjectHandler )
|
||||||
{
|
{
|
||||||
m_choose_project_handler = aChooseProjectHandler;
|
m_choose_project_handler = aChooseProjectHandler;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1390,14 +1390,10 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType,
|
||||||
DIALOG_HTML_REPORTER errorReporter( this );
|
DIALOG_HTML_REPORTER errorReporter( this );
|
||||||
WX_PROGRESS_REPORTER progressReporter( this, _( "Importing Schematic" ), 1 );
|
WX_PROGRESS_REPORTER progressReporter( this, _( "Importing Schematic" ), 1 );
|
||||||
|
|
||||||
PROJECT_CHOOSER_PLUGIN* projectChooserPlugin =
|
if( PROJECT_CHOOSER_PLUGIN* c_pi = dynamic_cast<PROJECT_CHOOSER_PLUGIN*>( pi.get() ) )
|
||||||
dynamic_cast<PROJECT_CHOOSER_PLUGIN*>( pi.get() );
|
|
||||||
|
|
||||||
if( projectChooserPlugin )
|
|
||||||
{
|
{
|
||||||
projectChooserPlugin->RegisterChooseProjectCallback(
|
c_pi->RegisterCallback( std::bind( DIALOG_IMPORT_CHOOSE_PROJECT::RunModal,
|
||||||
std::bind( DIALOG_IMPORT_CHOOSE_PROJECT::GetSelectionsModal, this,
|
this, std::placeholders::_1 ) );
|
||||||
std::placeholders::_1 ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( eeconfig()->m_System.show_import_issues )
|
if( eeconfig()->m_System.show_import_issues )
|
||||||
|
|
|
@ -184,9 +184,7 @@ void IMPORT_PROJ_HELPER::EasyEDAProProjectHandler()
|
||||||
EASYEDAPRO::ProjectToSelectorDialog( project, false, false );
|
EASYEDAPRO::ProjectToSelectorDialog( project, false, false );
|
||||||
|
|
||||||
if( toImport.size() > 1 )
|
if( toImport.size() > 1 )
|
||||||
{
|
toImport = DIALOG_IMPORT_CHOOSE_PROJECT::RunModal( m_frame, toImport );
|
||||||
toImport = DIALOG_IMPORT_CHOOSE_PROJECT::GetSelectionsModal( m_frame, toImport );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( toImport.size() == 1 )
|
if( toImport.size() == 1 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -107,7 +107,7 @@ set( PCBNEW_DIALOGS
|
||||||
dialogs/dialog_import_settings.cpp
|
dialogs/dialog_import_settings.cpp
|
||||||
dialogs/dialog_import_settings_base.cpp
|
dialogs/dialog_import_settings_base.cpp
|
||||||
dialogs/dialog_imported_layers_base.cpp
|
dialogs/dialog_imported_layers_base.cpp
|
||||||
dialogs/dialog_imported_layers.cpp
|
dialogs/dialog_map_layers.cpp
|
||||||
dialogs/dialog_rule_area_properties.cpp
|
dialogs/dialog_rule_area_properties.cpp
|
||||||
dialogs/dialog_rule_area_properties_base.cpp
|
dialogs/dialog_rule_area_properties_base.cpp
|
||||||
dialogs/dialog_layer_selection_base.cpp
|
dialogs/dialog_layer_selection_base.cpp
|
||||||
|
|
|
@ -20,18 +20,18 @@
|
||||||
|
|
||||||
|
|
||||||
#include <layer_ids.h>
|
#include <layer_ids.h>
|
||||||
#include <dialog_imported_layers.h>
|
#include <dialog_map_layers.h>
|
||||||
|
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
|
|
||||||
|
|
||||||
wxString DIALOG_IMPORTED_LAYERS::WrapRequired( const wxString& aLayerName )
|
wxString DIALOG_MAP_LAYERS::WrapRequired( const wxString& aLayerName )
|
||||||
{
|
{
|
||||||
return aLayerName + wxT( " *" );
|
return aLayerName + wxT( " *" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString DIALOG_IMPORTED_LAYERS::UnwrapRequired( const wxString& aLayerName )
|
wxString DIALOG_MAP_LAYERS::UnwrapRequired( const wxString& aLayerName )
|
||||||
{
|
{
|
||||||
if( !aLayerName.EndsWith( wxT( " *" ) ) )
|
if( !aLayerName.EndsWith( wxT( " *" ) ) )
|
||||||
return aLayerName;
|
return aLayerName;
|
||||||
|
@ -40,8 +40,7 @@ wxString DIALOG_IMPORTED_LAYERS::UnwrapRequired( const wxString& aLayerName )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const INPUT_LAYER_DESC* DIALOG_IMPORTED_LAYERS::GetLayerDescription(
|
const INPUT_LAYER_DESC* DIALOG_MAP_LAYERS::GetLayerDescription( const wxString& aLayerName ) const
|
||||||
const wxString& aLayerName ) const
|
|
||||||
{
|
{
|
||||||
wxString layerName = UnwrapRequired( aLayerName );
|
wxString layerName = UnwrapRequired( aLayerName );
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ const INPUT_LAYER_DESC* DIALOG_IMPORTED_LAYERS::GetLayerDescription(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PCB_LAYER_ID DIALOG_IMPORTED_LAYERS::GetSelectedLayerID()
|
PCB_LAYER_ID DIALOG_MAP_LAYERS::GetSelectedLayerID()
|
||||||
{
|
{
|
||||||
// First check if there is a KiCad element selected
|
// First check if there is a KiCad element selected
|
||||||
wxString selectedKiCadLayerName;
|
wxString selectedKiCadLayerName;
|
||||||
|
@ -86,10 +85,11 @@ PCB_LAYER_ID DIALOG_IMPORTED_LAYERS::GetSelectedLayerID()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PCB_LAYER_ID DIALOG_IMPORTED_LAYERS::GetAutoMatchLayerID( const wxString& aInputLayerName )
|
PCB_LAYER_ID DIALOG_MAP_LAYERS::GetAutoMatchLayerID( const wxString& aInputLayerName )
|
||||||
{
|
{
|
||||||
wxString pureInputLayerName = UnwrapRequired( aInputLayerName );
|
wxString pureInputLayerName = UnwrapRequired( aInputLayerName );
|
||||||
for( INPUT_LAYER_DESC inputLayerDesc : m_input_layers )
|
|
||||||
|
for( const INPUT_LAYER_DESC& inputLayerDesc : m_input_layers )
|
||||||
{
|
{
|
||||||
if( inputLayerDesc.Name == pureInputLayerName
|
if( inputLayerDesc.Name == pureInputLayerName
|
||||||
&& inputLayerDesc.AutoMapLayer != PCB_LAYER_ID::UNSELECTED_LAYER )
|
&& inputLayerDesc.AutoMapLayer != PCB_LAYER_ID::UNSELECTED_LAYER )
|
||||||
|
@ -102,7 +102,7 @@ PCB_LAYER_ID DIALOG_IMPORTED_LAYERS::GetAutoMatchLayerID( const wxString& aInput
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_IMPORTED_LAYERS::AddMappings()
|
void DIALOG_MAP_LAYERS::AddMappings()
|
||||||
{
|
{
|
||||||
PCB_LAYER_ID selectedKiCadLayerID = GetSelectedLayerID();
|
PCB_LAYER_ID selectedKiCadLayerID = GetSelectedLayerID();
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ void DIALOG_IMPORTED_LAYERS::AddMappings()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_IMPORTED_LAYERS::RemoveMappings( int aStatus )
|
void DIALOG_MAP_LAYERS::RemoveMappings( int aStatus )
|
||||||
{
|
{
|
||||||
wxArrayInt rowsToDelete;
|
wxArrayInt rowsToDelete;
|
||||||
int itemIndex = -1;
|
int itemIndex = -1;
|
||||||
|
@ -173,17 +173,14 @@ void DIALOG_IMPORTED_LAYERS::RemoveMappings( int aStatus )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_IMPORTED_LAYERS::DeleteListItems( const wxArrayInt& aRowsToDelete,
|
void DIALOG_MAP_LAYERS::DeleteListItems( const wxArrayInt& aRowsToDelete, wxListCtrl* aListCtrl )
|
||||||
wxListCtrl* aListCtrl )
|
|
||||||
{
|
|
||||||
for( long n = ( aRowsToDelete.GetCount() - 1 ); 0 <= n; n-- )
|
|
||||||
{
|
{
|
||||||
|
for( long n = (long) aRowsToDelete.GetCount() - 1; 0 <= n; n-- )
|
||||||
aListCtrl->DeleteItem( aRowsToDelete[n] );
|
aListCtrl->DeleteItem( aRowsToDelete[n] );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_IMPORTED_LAYERS::OnAutoMatchLayersClicked( wxCommandEvent& event )
|
void DIALOG_MAP_LAYERS::OnAutoMatchLayersClicked( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
// Iterate through each selected layer in the unmatched layers list
|
// Iterate through each selected layer in the unmatched layers list
|
||||||
int itemIndex = -1;
|
int itemIndex = -1;
|
||||||
|
@ -225,14 +222,14 @@ void DIALOG_IMPORTED_LAYERS::OnAutoMatchLayersClicked( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DIALOG_IMPORTED_LAYERS::DIALOG_IMPORTED_LAYERS( wxWindow* aParent,
|
DIALOG_MAP_LAYERS::DIALOG_MAP_LAYERS( wxWindow* aParent,
|
||||||
const std::vector<INPUT_LAYER_DESC>& aLayerDesc ) :
|
const std::vector<INPUT_LAYER_DESC>& aLayerDesc ) :
|
||||||
DIALOG_IMPORTED_LAYERS_BASE( aParent )
|
DIALOG_IMPORTED_LAYERS_BASE( aParent )
|
||||||
{
|
{
|
||||||
LSET kiCadLayers;
|
LSET kiCadLayers;
|
||||||
|
|
||||||
// Read in the input layers
|
// Read in the input layers
|
||||||
for( INPUT_LAYER_DESC inLayer : aLayerDesc )
|
for( const INPUT_LAYER_DESC& inLayer : aLayerDesc )
|
||||||
{
|
{
|
||||||
m_input_layers.push_back( inLayer );
|
m_input_layers.push_back( inLayer );
|
||||||
wxString layerName = inLayer.Required ? WrapRequired( inLayer.Name ) : inLayer.Name;
|
wxString layerName = inLayer.Required ? WrapRequired( inLayer.Name ) : inLayer.Name;
|
||||||
|
@ -269,7 +266,7 @@ DIALOG_IMPORTED_LAYERS::DIALOG_IMPORTED_LAYERS( wxWindow* aParent,
|
||||||
// Load the input layer list to unmatched layers
|
// Load the input layer list to unmatched layers
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
for( wxString importedLayerName : m_unmatched_layer_names )
|
for( const wxString& importedLayerName : m_unmatched_layer_names )
|
||||||
{
|
{
|
||||||
wxListItem item;
|
wxListItem item;
|
||||||
item.SetId( row );
|
item.SetId( row );
|
||||||
|
@ -306,7 +303,7 @@ DIALOG_IMPORTED_LAYERS::DIALOG_IMPORTED_LAYERS( wxWindow* aParent,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<wxString> DIALOG_IMPORTED_LAYERS::GetUnmappedRequiredLayers() const
|
std::vector<wxString> DIALOG_MAP_LAYERS::GetUnmappedRequiredLayers() const
|
||||||
{
|
{
|
||||||
std::vector<wxString> unmappedLayers;
|
std::vector<wxString> unmappedLayers;
|
||||||
|
|
||||||
|
@ -324,10 +321,9 @@ std::vector<wxString> DIALOG_IMPORTED_LAYERS::GetUnmappedRequiredLayers() const
|
||||||
|
|
||||||
|
|
||||||
std::map<wxString, PCB_LAYER_ID>
|
std::map<wxString, PCB_LAYER_ID>
|
||||||
DIALOG_IMPORTED_LAYERS::GetMapModal( wxWindow* aParent,
|
DIALOG_MAP_LAYERS::RunModal( wxWindow* aParent, const std::vector<INPUT_LAYER_DESC>& aLayerDesc )
|
||||||
const std::vector<INPUT_LAYER_DESC>& aLayerDesc )
|
|
||||||
{
|
{
|
||||||
DIALOG_IMPORTED_LAYERS dlg( aParent, aLayerDesc );
|
DIALOG_MAP_LAYERS dlg( aParent, aLayerDesc );
|
||||||
bool dataOk = false;
|
bool dataOk = false;
|
||||||
|
|
||||||
while( !dataOk )
|
while( !dataOk )
|
|
@ -25,10 +25,10 @@
|
||||||
#include <pcb_io/common/plugin_common_layer_mapping.h>
|
#include <pcb_io/common/plugin_common_layer_mapping.h>
|
||||||
|
|
||||||
|
|
||||||
class DIALOG_IMPORTED_LAYERS : public DIALOG_IMPORTED_LAYERS_BASE
|
class DIALOG_MAP_LAYERS : public DIALOG_IMPORTED_LAYERS_BASE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DIALOG_IMPORTED_LAYERS( wxWindow* aParent, const std::vector<INPUT_LAYER_DESC>& aLayerDesc );
|
DIALOG_MAP_LAYERS( wxWindow* aParent, const std::vector<INPUT_LAYER_DESC>& aLayerDesc );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of layers names that are required, but they are not mapped.
|
* Return a list of layers names that are required, but they are not mapped.
|
||||||
|
@ -43,7 +43,7 @@ public:
|
||||||
* @param aLayerDesc
|
* @param aLayerDesc
|
||||||
* @return Mapped layers
|
* @return Mapped layers
|
||||||
*/
|
*/
|
||||||
static std::map<wxString, PCB_LAYER_ID> GetMapModal( wxWindow* aParent,
|
static std::map<wxString, PCB_LAYER_ID> RunModal( wxWindow* aParent,
|
||||||
const std::vector<INPUT_LAYER_DESC>& aLayerDesc );
|
const std::vector<INPUT_LAYER_DESC>& aLayerDesc );
|
||||||
|
|
||||||
private:
|
private:
|
|
@ -63,7 +63,7 @@
|
||||||
#include <pcb_io/cadstar/pcb_io_cadstar_archive.h>
|
#include <pcb_io/cadstar/pcb_io_cadstar_archive.h>
|
||||||
#include <pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h>
|
#include <pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h>
|
||||||
#include <dialogs/dialog_export_2581.h>
|
#include <dialogs/dialog_export_2581.h>
|
||||||
#include <dialogs/dialog_imported_layers.h>
|
#include <dialogs/dialog_map_layers.h>
|
||||||
#include <dialogs/dialog_import_choose_project.h>
|
#include <dialogs/dialog_import_choose_project.h>
|
||||||
#include <tools/pcb_actions.h>
|
#include <tools/pcb_actions.h>
|
||||||
#include "footprint_info_impl.h"
|
#include "footprint_info_impl.h"
|
||||||
|
@ -525,10 +525,9 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
|
|
||||||
if( !lock->Valid() && lock->IsLockedByMe() )
|
if( !lock->Valid() && lock->IsLockedByMe() )
|
||||||
{
|
{
|
||||||
// If we cannot acquire the lock but we appear to be the one who
|
// If we cannot acquire the lock but we appear to be the one who locked it, check to
|
||||||
// locked it, check to see if there is another KiCad instance running.
|
// see if there is another KiCad instance running. If not, then we can override the
|
||||||
// If there is not, then we can override the lock. This could happen if
|
// lock. This could happen if KiCad crashed or was interrupted.
|
||||||
// KiCad crashed or was interrupted
|
|
||||||
|
|
||||||
if( !Pgm().SingleInstance()->IsAnotherRunning() )
|
if( !Pgm().SingleInstance()->IsAnotherRunning() )
|
||||||
lock->OverrideLock();
|
lock->OverrideLock();
|
||||||
|
@ -536,8 +535,10 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
|
|
||||||
if( !lock->Valid() )
|
if( !lock->Valid() )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "PCB '%s' is already open by '%s' at '%s'." ), wx_filename.GetFullName(),
|
msg.Printf( _( "PCB '%s' is already open by '%s' at '%s'." ),
|
||||||
lock->GetUsername(), lock->GetHostname() );
|
wx_filename.GetFullName(),
|
||||||
|
lock->GetUsername(),
|
||||||
|
lock->GetHostname() );
|
||||||
|
|
||||||
if( !AskOverrideLock( this, msg ) )
|
if( !AskOverrideLock( this, msg ) )
|
||||||
return false;
|
return false;
|
||||||
|
@ -562,7 +563,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
|
|
||||||
bool is_new = !wxFileName::IsFileReadable( fullFileName );
|
bool is_new = !wxFileName::IsFileReadable( fullFileName );
|
||||||
|
|
||||||
// If its a non-existent schematic and caller thinks it exists
|
// If its a non-existent PCB and caller thinks it exists
|
||||||
if( is_new && !( aCtl & KICTL_CREATE ) )
|
if( is_new && !( aCtl & KICTL_CREATE ) )
|
||||||
{
|
{
|
||||||
// notify user that fullFileName does not exist, ask if user wants to create it.
|
// notify user that fullFileName does not exist, ask if user wants to create it.
|
||||||
|
@ -609,9 +610,9 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
mgr->LoadProject( pro.GetFullPath() );
|
mgr->LoadProject( pro.GetFullPath() );
|
||||||
|
|
||||||
// Do not allow saving a project if one doesn't exist. This normally happens if we are
|
// Do not allow saving a project if one doesn't exist. This normally happens if we are
|
||||||
// standalone and opening a board that has been moved from its project folder.
|
// opening a board that has been moved from its project folder.
|
||||||
// For converted projects, we don't want to set the read-only flag because we want a project
|
// For converted projects, we don't want to set the read-only flag because we want a
|
||||||
// to be saved for the new file in case things like netclasses got migrated.
|
// project to be saved for the new file in case things like netclasses got migrated.
|
||||||
Prj().SetReadOnly( !pro.Exists() && !converted );
|
Prj().SetReadOnly( !pro.Exists() && !converted );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,20 +633,16 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
BOARD* loadedBoard = nullptr; // it will be set to non-NULL if loaded OK
|
BOARD* loadedBoard = nullptr; // it will be set to non-NULL if loaded OK
|
||||||
IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( pluginType ) );
|
IO_RELEASER<PCB_IO> pi( PCB_IO_MGR::PluginFind( pluginType ) );
|
||||||
|
|
||||||
LAYER_REMAPPABLE_PLUGIN* layerRemappableIO = dynamic_cast<LAYER_REMAPPABLE_PLUGIN*>( pi.get() );
|
if( LAYER_MAPPABLE_PLUGIN* mappable_pi = dynamic_cast<LAYER_MAPPABLE_PLUGIN*>( pi.get() ) )
|
||||||
|
|
||||||
if( layerRemappableIO )
|
|
||||||
{
|
{
|
||||||
layerRemappableIO->RegisterLayerMappingCallback(
|
mappable_pi->RegisterCallback( std::bind( DIALOG_MAP_LAYERS::RunModal,
|
||||||
std::bind( DIALOG_IMPORTED_LAYERS::GetMapModal, this, std::placeholders::_1 ) );
|
this, std::placeholders::_1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
PROJECT_CHOOSER_PLUGIN* projectChooserIO = dynamic_cast<PROJECT_CHOOSER_PLUGIN*>( pi.get() );
|
if( PROJECT_CHOOSER_PLUGIN* chooser_pi = dynamic_cast<PROJECT_CHOOSER_PLUGIN*>( pi.get() ) )
|
||||||
|
|
||||||
if( projectChooserIO )
|
|
||||||
{
|
{
|
||||||
projectChooserIO->RegisterChooseProjectCallback(
|
chooser_pi->RegisterCallback( std::bind( DIALOG_IMPORT_CHOOSE_PROJECT::RunModal,
|
||||||
std::bind( DIALOG_IMPORT_CHOOSE_PROJECT::GetSelectionsModal, this,
|
this,
|
||||||
std::placeholders::_1 ) );
|
std::placeholders::_1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,10 @@
|
||||||
#include <compoundfilereader.h>
|
#include <compoundfilereader.h>
|
||||||
#include <utf.h>
|
#include <utf.h>
|
||||||
|
|
||||||
PCB_IO_ALTIUM_CIRCUIT_MAKER::PCB_IO_ALTIUM_CIRCUIT_MAKER() : PCB_IO( wxS( "Altium Circuit Maker" ) )
|
PCB_IO_ALTIUM_CIRCUIT_MAKER::PCB_IO_ALTIUM_CIRCUIT_MAKER() :
|
||||||
|
PCB_IO( wxS( "Altium Circuit Maker" ) )
|
||||||
{
|
{
|
||||||
RegisterLayerMappingCallback( PCB_IO_ALTIUM_DESIGNER::DefaultLayerMappingCallback );
|
RegisterCallback( PCB_IO_ALTIUM_DESIGNER::DefaultLayerMappingCallback );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include <pcb_io/pcb_io_mgr.h>
|
#include <pcb_io/pcb_io_mgr.h>
|
||||||
#include <pcb_io/common/plugin_common_layer_mapping.h>
|
#include <pcb_io/common/plugin_common_layer_mapping.h>
|
||||||
|
|
||||||
class PCB_IO_ALTIUM_CIRCUIT_MAKER : public PCB_IO, public LAYER_REMAPPABLE_PLUGIN
|
class PCB_IO_ALTIUM_CIRCUIT_MAKER : public PCB_IO, public LAYER_MAPPABLE_PLUGIN
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
|
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
|
||||||
|
|
|
@ -42,9 +42,10 @@
|
||||||
#include <compoundfilereader.h>
|
#include <compoundfilereader.h>
|
||||||
#include <utf.h>
|
#include <utf.h>
|
||||||
|
|
||||||
PCB_IO_ALTIUM_CIRCUIT_STUDIO::PCB_IO_ALTIUM_CIRCUIT_STUDIO() : PCB_IO( wxS( "Altium Circuit Studio" ) )
|
PCB_IO_ALTIUM_CIRCUIT_STUDIO::PCB_IO_ALTIUM_CIRCUIT_STUDIO() :
|
||||||
|
PCB_IO( wxS( "Altium Circuit Studio" ) )
|
||||||
{
|
{
|
||||||
RegisterLayerMappingCallback( PCB_IO_ALTIUM_DESIGNER::DefaultLayerMappingCallback );
|
RegisterCallback( PCB_IO_ALTIUM_DESIGNER::DefaultLayerMappingCallback );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <pcb_io/pcb_io_mgr.h>
|
#include <pcb_io/pcb_io_mgr.h>
|
||||||
#include <pcb_io/common/plugin_common_layer_mapping.h>
|
#include <pcb_io/common/plugin_common_layer_mapping.h>
|
||||||
|
|
||||||
class PCB_IO_ALTIUM_CIRCUIT_STUDIO : public PCB_IO, public LAYER_REMAPPABLE_PLUGIN
|
class PCB_IO_ALTIUM_CIRCUIT_STUDIO : public PCB_IO, public LAYER_MAPPABLE_PLUGIN
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
|
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
|
||||||
|
|
|
@ -41,11 +41,12 @@
|
||||||
#include <compoundfilereader.h>
|
#include <compoundfilereader.h>
|
||||||
#include <utf.h>
|
#include <utf.h>
|
||||||
|
|
||||||
PCB_IO_ALTIUM_DESIGNER::PCB_IO_ALTIUM_DESIGNER() : PCB_IO( wxS( "Altium Designer" ) )
|
PCB_IO_ALTIUM_DESIGNER::PCB_IO_ALTIUM_DESIGNER() :
|
||||||
|
PCB_IO( wxS( "Altium Designer" ) )
|
||||||
{
|
{
|
||||||
m_reporter = &WXLOG_REPORTER::GetInstance();
|
m_reporter = &WXLOG_REPORTER::GetInstance();
|
||||||
|
|
||||||
RegisterLayerMappingCallback( PCB_IO_ALTIUM_DESIGNER::DefaultLayerMappingCallback );
|
RegisterCallback( PCB_IO_ALTIUM_DESIGNER::DefaultLayerMappingCallback );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
class ALTIUM_COMPOUND_FILE;
|
class ALTIUM_COMPOUND_FILE;
|
||||||
|
|
||||||
class PCB_IO_ALTIUM_DESIGNER : public PCB_IO, public LAYER_REMAPPABLE_PLUGIN
|
class PCB_IO_ALTIUM_DESIGNER : public PCB_IO, public LAYER_MAPPABLE_PLUGIN
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// -----<PUBLIC PCB_IO API>--------------------------------------------------
|
// -----<PUBLIC PCB_IO API>--------------------------------------------------
|
||||||
|
|
|
@ -32,10 +32,11 @@
|
||||||
#include <compoundfilereader.h>
|
#include <compoundfilereader.h>
|
||||||
#include <utf.h>
|
#include <utf.h>
|
||||||
|
|
||||||
PCB_IO_SOLIDWORKS::PCB_IO_SOLIDWORKS() : PCB_IO( wxS( "Solidworks PCB" ) )
|
PCB_IO_SOLIDWORKS::PCB_IO_SOLIDWORKS() :
|
||||||
|
PCB_IO( wxS( "Solidworks PCB" ) )
|
||||||
{
|
{
|
||||||
m_reporter = &WXLOG_REPORTER::GetInstance();
|
m_reporter = &WXLOG_REPORTER::GetInstance();
|
||||||
RegisterLayerMappingCallback( PCB_IO_ALTIUM_DESIGNER::DefaultLayerMappingCallback );
|
RegisterCallback( PCB_IO_ALTIUM_DESIGNER::DefaultLayerMappingCallback );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include <pcb_io/pcb_io_mgr.h>
|
#include <pcb_io/pcb_io_mgr.h>
|
||||||
#include <pcb_io/common/plugin_common_layer_mapping.h>
|
#include <pcb_io/common/plugin_common_layer_mapping.h>
|
||||||
|
|
||||||
class PCB_IO_SOLIDWORKS : public PCB_IO, public LAYER_REMAPPABLE_PLUGIN
|
class PCB_IO_SOLIDWORKS : public PCB_IO, public LAYER_MAPPABLE_PLUGIN
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
|
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
|
||||||
|
|
|
@ -49,10 +49,9 @@ std::map<wxString, PCB_LAYER_ID> PCB_IO_CADSTAR_ARCHIVE::DefaultLayerMappingCall
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_IO_CADSTAR_ARCHIVE::RegisterLayerMappingCallback(
|
void PCB_IO_CADSTAR_ARCHIVE::RegisterCallback( LAYER_MAPPING_HANDLER aLayerMappingHandler )
|
||||||
LAYER_MAPPING_HANDLER aLayerMappingHandler )
|
|
||||||
{
|
{
|
||||||
LAYER_REMAPPABLE_PLUGIN::RegisterLayerMappingCallback( aLayerMappingHandler );
|
LAYER_MAPPABLE_PLUGIN::RegisterCallback( aLayerMappingHandler );
|
||||||
m_show_layer_mapping_warnings = false; // only show warnings with default callback
|
m_show_layer_mapping_warnings = false; // only show warnings with default callback
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,8 +59,7 @@ void PCB_IO_CADSTAR_ARCHIVE::RegisterLayerMappingCallback(
|
||||||
PCB_IO_CADSTAR_ARCHIVE::PCB_IO_CADSTAR_ARCHIVE() : PCB_IO( wxS( "CADSTAR PCB Archive" ) )
|
PCB_IO_CADSTAR_ARCHIVE::PCB_IO_CADSTAR_ARCHIVE() : PCB_IO( wxS( "CADSTAR PCB Archive" ) )
|
||||||
{
|
{
|
||||||
m_show_layer_mapping_warnings = true;
|
m_show_layer_mapping_warnings = true;
|
||||||
LAYER_REMAPPABLE_PLUGIN::RegisterLayerMappingCallback(
|
LAYER_MAPPABLE_PLUGIN::RegisterCallback( PCB_IO_CADSTAR_ARCHIVE::DefaultLayerMappingCallback );
|
||||||
PCB_IO_CADSTAR_ARCHIVE::DefaultLayerMappingCallback );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
class PCB_IO_CADSTAR_ARCHIVE : public PCB_IO, public LAYER_REMAPPABLE_PLUGIN
|
class PCB_IO_CADSTAR_ARCHIVE : public PCB_IO, public LAYER_MAPPABLE_PLUGIN
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
|
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
|
||||||
|
@ -62,7 +62,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param aLayerMappingHandler
|
* @param aLayerMappingHandler
|
||||||
*/
|
*/
|
||||||
void RegisterLayerMappingCallback( LAYER_MAPPING_HANDLER aLayerMappingHandler ) override;
|
void RegisterCallback( LAYER_MAPPING_HANDLER aLayerMappingHandler ) override;
|
||||||
|
|
||||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
||||||
bool aBestEfforts, const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
bool aBestEfforts, const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
||||||
|
|
|
@ -58,7 +58,7 @@ using LAYER_MAPPING_HANDLER = std::function<std::map<wxString, PCB_LAYER_ID>( co
|
||||||
/**
|
/**
|
||||||
* @brief Plugin class for import plugins that support remappable layers
|
* @brief Plugin class for import plugins that support remappable layers
|
||||||
*/
|
*/
|
||||||
class LAYER_REMAPPABLE_PLUGIN
|
class LAYER_MAPPABLE_PLUGIN
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -70,12 +70,12 @@ public:
|
||||||
*
|
*
|
||||||
* @param aLayerMappingHandler
|
* @param aLayerMappingHandler
|
||||||
*/
|
*/
|
||||||
virtual void RegisterLayerMappingCallback( LAYER_MAPPING_HANDLER aLayerMappingHandler )
|
virtual void RegisterCallback( LAYER_MAPPING_HANDLER aLayerMappingHandler )
|
||||||
{
|
{
|
||||||
m_layer_mapping_handler = aLayerMappingHandler;
|
m_layer_mapping_handler = aLayerMappingHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~LAYER_REMAPPABLE_PLUGIN() = default;
|
virtual ~LAYER_MAPPABLE_PLUGIN() = default;
|
||||||
protected:
|
protected:
|
||||||
LAYER_MAPPING_HANDLER m_layer_mapping_handler; ///< Callback to get layer mapping
|
LAYER_MAPPING_HANDLER m_layer_mapping_handler; ///< Callback to get layer mapping
|
||||||
};
|
};
|
||||||
|
|
|
@ -222,7 +222,8 @@ void ERULES::parse( wxXmlNode* aRules, std::function<void()> aCheckpoint )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PCB_IO_EAGLE::PCB_IO_EAGLE() : PCB_IO( wxS( "Eagle" ) ),
|
PCB_IO_EAGLE::PCB_IO_EAGLE() :
|
||||||
|
PCB_IO( wxS( "Eagle" ) ),
|
||||||
m_rules( new ERULES() ),
|
m_rules( new ERULES() ),
|
||||||
m_xpath( new XPATH() ),
|
m_xpath( new XPATH() ),
|
||||||
m_progressReporter( nullptr ),
|
m_progressReporter( nullptr ),
|
||||||
|
@ -235,8 +236,7 @@ PCB_IO_EAGLE::PCB_IO_EAGLE() : PCB_IO( wxS( "Eagle" ) ),
|
||||||
|
|
||||||
init( nullptr );
|
init( nullptr );
|
||||||
clear_cu_map();
|
clear_cu_map();
|
||||||
RegisterLayerMappingCallback( std::bind( &PCB_IO_EAGLE::DefaultLayerMappingCallback,
|
RegisterCallback( std::bind( &PCB_IO_EAGLE::DefaultLayerMappingCallback, this, _1 ) );
|
||||||
this, _1 ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ struct ERULES
|
||||||
* Works with Eagle 6.x XML board files and footprints to implement the Pcbnew #PLUGIN API
|
* Works with Eagle 6.x XML board files and footprints to implement the Pcbnew #PLUGIN API
|
||||||
* or a portion of it.
|
* or a portion of it.
|
||||||
*/
|
*/
|
||||||
class PCB_IO_EAGLE : public PCB_IO, public LAYER_REMAPPABLE_PLUGIN
|
class PCB_IO_EAGLE : public PCB_IO, public LAYER_MAPPABLE_PLUGIN
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
|
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
|
||||||
|
|
Loading…
Reference in New Issue