Fixes for importing board setup properties.

Save/restore default netclass.
Read layers back in with correct syntax ('.' between keyword and layer name).
Write layers to project file.
Read/write layer enablement bits.
Don't set solder paste margin min to 0 (most of them are negative).

Fixes: lp:1811990
* https://bugs.launchpad.net/kicad/+bug/1811990
This commit is contained in:
Jeff Young 2019-03-07 04:55:14 +00:00
parent 8e2d82ebdb
commit 3da5396c8d
12 changed files with 197 additions and 66 deletions

View File

@ -159,9 +159,8 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event )
fn = g_RootSheet->GetScreen()->GetFileName();
fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( this, _( "Load Project File" ), fn.GetPath(),
fn.GetFullName(), ProjectFileWildcard(),
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
wxFileDialog dlg( this, _( "Load Project File" ), fn.GetPath(), fn.GetFullName(),
ProjectFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( dlg.ShowModal() == wxID_CANCEL )
break;
@ -174,10 +173,10 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event )
{
// Read library list and library path list
Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH,
GetProjectFileParametersList() );
GetProjectFileParameters() );
// Read schematic editor setup
Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH_EDITOR,
GetProjectFileParametersList() );
Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH_EDIT,
GetProjectFileParameters() );
}
}
break;
@ -214,7 +213,7 @@ void SCH_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent )
}
PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParametersList()
PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParameters()
{
if( !m_projectFileParams.empty() )
@ -278,12 +277,10 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParametersList()
bool SCH_EDIT_FRAME::LoadProjectFile()
{
// Read library list and library path list
bool isRead = Prj().ConfigLoad( Kiface().KifaceSearch(),
GROUP_SCH, GetProjectFileParametersList() );
bool ret = Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH, GetProjectFileParameters() );
// Read schematic editor setup
isRead = isRead && Prj().ConfigLoad( Kiface().KifaceSearch(),
GROUP_SCH_EDITOR, GetProjectFileParametersList() );
ret &= Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH_EDIT, GetProjectFileParameters() );
// Verify some values, because the config file can be edited by hand,
// and have bad values:
@ -301,7 +298,7 @@ bool SCH_EDIT_FRAME::LoadProjectFile()
pglayout.SetPageLayout( pg_fullfilename );
return isRead;
return ret;
}
@ -317,8 +314,7 @@ void SCH_EDIT_FRAME::SaveProjectSettings( bool aAskForSave )
if( aAskForSave )
{
wxFileDialog dlg( this, _( "Save Project File" ),
fn.GetPath(), fn.GetFullName(),
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), fn.GetFullName(),
ProjectFileWildcard(), wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
@ -327,7 +323,9 @@ void SCH_EDIT_FRAME::SaveProjectSettings( bool aAskForSave )
fn = dlg.GetPath();
}
prj.ConfigSave( Kiface().KifaceSearch(), GROUP_SCH_EDITOR, GetProjectFileParametersList() );
wxString path = fn.GetFullPath();
prj.ConfigSave( Kiface().KifaceSearch(), GROUP_SCH_EDIT, GetProjectFileParameters(), path );
}
///@{

View File

@ -1305,11 +1305,7 @@ void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
if( fn.GetName() != NAMELESS_PROJECT )
{
// was: wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParametersList() );
Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_SCH_EDITOR,
GetProjectFileParametersList() );
}
Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_SCH_EDIT, GetProjectFileParameters() );
}

View File

@ -300,7 +300,7 @@ public:
* already been populated and return a reference to the array to the caller.
* </p>
*/
PARAM_CFG_ARRAY& GetProjectFileParametersList();
PARAM_CFG_ARRAY& GetProjectFileParameters();
/**
* Save changes to the project settings to the project (.pro) file.

View File

@ -42,7 +42,7 @@ using KIGFX::COLOR4D;
/// Names of sub sections where to store project info in *.pro project config files
#define GROUP_PCB wxT( "/pcbnew" ) /// parameters for Pcbnew/Modedit
#define GROUP_SCH wxT( "/eeschema" ) /// library list and lib paths list
#define GROUP_SCH_EDITOR wxT( "/schematic_editor" ) /// parameters for schematic editor
#define GROUP_SCH_EDIT wxT( "/schematic_editor" ) /// parameters for schematic editor
/// (and few for component editor).
/// Does not store libs list
#define GROUP_PCB_LIBS wxT( "/pcbnew/libraries" ) /// PCB library list, should be removed soon

View File

@ -41,6 +41,7 @@
#define LayerKeyPrefix wxT( "Layer" )
#define LayerNameKey wxT( "Name" )
#define LayerTypeKey wxT( "Type" )
#define LayerEnabledKey wxT( "Enabled" )
#define NetclassNameKey wxT( "Name" )
#define ClearanceKey wxT( "Clearance" )
@ -77,29 +78,38 @@ public:
BOARD* board = m_Pt_param;
BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
LSET enabledLayers = bds.GetEnabledLayers();
wxString oldPath = aConfig->GetPath();
wxString layerKeyPrefix = LayerKeyPrefix;
bds.SetCopperLayerCount( aConfig->Read( CopperLayerCountKey, 2 ) );
double thickness = aConfig->ReadDouble( BoardThicknessKey, DEFAULT_BOARD_THICKNESS_MM );
bds.SetBoardThickness( Millimeter2iu( thickness ) );
for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
{
PCB_LAYER_ID layer = *seq;
wxString path = layerKeyPrefix + wxT( "." ) + board->GetStandardLayerName( layer );
wxString layerName;
int layerType;
bool layerEnabled;
aConfig->SetPath( oldPath );
aConfig->SetPath( LayerKeyPrefix + board->GetStandardLayerName( layer ) );
aConfig->SetPath( path );
if( aConfig->Read( LayerNameKey, &layerName ) )
board->SetLayerName( layer, layerName );
if( aConfig->Read( LayerTypeKey, &layerType ) )
board->SetLayerType( layer, (LAYER_T) layerType );
if( aConfig->Read( LayerEnabledKey, &layerEnabled ) )
enabledLayers.set( layer, layerEnabled );
}
board->SetEnabledLayers( enabledLayers );
aConfig->SetPath( oldPath );
}
@ -116,25 +126,23 @@ public:
aConfig->Write( CopperLayerCountKey, board->GetCopperLayerCount() );
aConfig->Write( BoardThicknessKey, Iu2Millimeter( bds.GetBoardThickness() ) );
for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
{
PCB_LAYER_ID layer = *seq;
wxString stdName = board->GetStandardLayerName( layer );
wxString layerName = board->GetLayerName( layer );
LAYER_T layerType = board->GetLayerType( layer );
wxString path = layerKeyPrefix + wxT( "." ) + board->GetStandardLayerName( layer );
wxString layerName = board->GetLayerName( layer );
LAYER_T layerType = board->GetLayerType( layer );
aConfig->SetPath( oldPath );
aConfig->SetPath( layerKeyPrefix + wxT( "." ) + stdName );
aConfig->SetPath( path );
if( layerName == stdName && layerType == LT_SIGNAL )
{
aConfig->DeleteGroup( aConfig->GetPath() );
}
else
if( IsCopperLayer( layer ) )
{
aConfig->Write( LayerNameKey, layerName );
aConfig->Write( LayerTypeKey, (int) layerType );
}
aConfig->Write( LayerEnabledKey, board->IsLayerEnabled( layer ) );
}
aConfig->SetPath( oldPath );
@ -320,19 +328,28 @@ public:
m_Pt_param->Clear();
for( int index = 1; ; ++index )
for( int index = 0; ; ++index )
{
wxString pathIndex = wxString() << index;
wxString netclassName;
wxString path = "";
NETCLASSPTR netclass;
wxString netclassName;
if( index == 0 )
path = "Default";
else
path << index;
aConfig->SetPath( oldPath );
aConfig->SetPath( m_Ident );
aConfig->SetPath( pathIndex );
aConfig->SetPath( path );
if( !aConfig->Read( NetclassNameKey, &netclassName ) )
break;
NETCLASSPTR netclass = std::make_shared<NETCLASS>( netclassName );
if( index == 0 )
netclass = m_Pt_param->GetDefault();
else
netclass = std::make_shared<NETCLASS>( netclassName );
#define READ_MM( aKey, aDefault ) Millimeter2iu( aConfig->ReadDouble( aKey, aDefault ) )
netclass->SetClearance( READ_MM( ClearanceKey, netclass->GetClearance() ) );
@ -345,7 +362,8 @@ public:
netclass->SetDiffPairGap( READ_MM( dPairGapKey, netclass->GetDiffPairGap() ) );
netclass->SetDiffPairViaGap( READ_MM( dPairViaGapKey, netclass->GetDiffPairViaGap() ) );
m_Pt_param->Add( netclass );
if( index > 0 )
m_Pt_param->Add( netclass );
}
aConfig->SetPath( oldPath );
@ -356,17 +374,32 @@ public:
if( !m_Pt_param || !aConfig )
return;
wxString oldPath = aConfig->GetPath();
int index = 1;
wxString oldPath = aConfig->GetPath();
NETCLASSES::const_iterator nc = m_Pt_param->begin();
for( NETCLASSES::const_iterator nc = m_Pt_param->begin(); nc != m_Pt_param->end(); ++nc )
for( int index = 0; index <= m_Pt_param->GetCount(); ++index )
{
wxString pathIndex = wxString() << index++;
NETCLASSPTR netclass = nc->second;
wxString path = "";
NETCLASSPTR netclass;
if( index == 0 )
path = "Default";
else
path << index;
aConfig->SetPath( oldPath );
aConfig->SetPath( m_Ident );
aConfig->SetPath( pathIndex );
aConfig->SetPath( path );
if( index == 0 )
{
netclass = m_Pt_param->GetDefault();
}
else
{
netclass = nc->second;
++nc;
}
aConfig->Write( NetclassNameKey, netclass->GetName() );
@ -645,7 +678,7 @@ void BOARD_DESIGN_SETTINGS::AppendConfigs( BOARD* aBoard, PARAM_CFG_ARRAY* aResu
aResult->push_back( new PARAM_CFG_DOUBLE( wxT( "SolderPasteRatio" ),
&m_SolderPasteMarginRatio,
DEFAULT_SOLDERPASTE_RATIO, 0, 10.0 ) );
DEFAULT_SOLDERPASTE_RATIO, -0.5, 1.0 ) );
}

View File

@ -82,6 +82,8 @@ void DIALOG_BOARD_SETUP::OnAuxiliaryAction( wxCommandEvent& event )
m_constraints->ImportSettingsFrom( dummyBoard );
if( importDlg.m_NetclassesOpt->GetValue() )
m_netclasses->ImportSettingsFrom( dummyBoard );
if( importDlg.m_TracksAndViasOpt->GetValue() )
m_tracksAndVias->ImportSettingsFrom( dummyBoard );
if( importDlg.m_MaskAndPasteOpt->GetValue() )
m_maskAndPaste->ImportSettingsFrom( dummyBoard );

View File

@ -86,5 +86,6 @@ void DIALOG_IMPORT_SETTINGS::OnSelectAll( wxCommandEvent& event )
m_TextAndGraphicsOpt->SetValue( true );
m_ConstraintsOpt->SetValue( true );
m_NetclassesOpt->SetValue( true );
m_TracksAndViasOpt->SetValue( true );
m_MaskAndPasteOpt->SetValue( true );
}

View File

@ -57,6 +57,9 @@ DIALOG_IMPORT_SETTINGS_BASE::DIALOG_IMPORT_SETTINGS_BASE( wxWindow* parent, wxWi
m_NetclassesOpt = new wxCheckBox( this, wxID_ANY, _("Net Classes"), wxDefaultPosition, wxDefaultSize, 0 );
bmiddleSizer->Add( m_NetclassesOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_TracksAndViasOpt = new wxCheckBox( this, wxID_ANY, _("Predefined Track and Via dimensions"), wxDefaultPosition, wxDefaultSize, 0 );
bmiddleSizer->Add( m_TracksAndViasOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_MaskAndPasteOpt = new wxCheckBox( this, wxID_ANY, _("Solder Mask/Paste defaults"), wxDefaultPosition, wxDefaultSize, 0 );
bmiddleSizer->Add( m_MaskAndPasteOpt, 0, wxRIGHT|wxLEFT, 5 );

View File

@ -815,6 +815,94 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Predefined Track and Via dimensions</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_TracksAndViasOpt</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">public</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxRIGHT|wxLEFT</property>

View File

@ -57,6 +57,7 @@ class DIALOG_IMPORT_SETTINGS_BASE : public DIALOG_SHIM
wxCheckBox* m_TextAndGraphicsOpt;
wxCheckBox* m_ConstraintsOpt;
wxCheckBox* m_NetclassesOpt;
wxCheckBox* m_TracksAndViasOpt;
wxCheckBox* m_MaskAndPasteOpt;
DIALOG_IMPORT_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Import Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );

View File

@ -334,24 +334,6 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::validateData()
}
void PANEL_SETUP_TRACKS_AND_VIAS::ImportSettingsFrom( BOARD* aBoard )
{
m_trackWidthsGrid->CommitPendingChanges( true );
m_viaSizesGrid->CommitPendingChanges( true );
m_diffPairsGrid->CommitPendingChanges( true );
// Note: do not change the board, as we need to get the current nets from it for
// netclass memberships. All the netclass definitions and dimension lists are in
// the BOARD_DESIGN_SETTINGS.
BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
m_BrdSettings = &aBoard->GetDesignSettings();
TransferDataToWindow();
m_BrdSettings = savedSettings;
}
void PANEL_SETUP_TRACKS_AND_VIAS::AppendTrackWidth( const int aWidth )
{
int i = m_trackWidthsGrid->GetNumberRows();
@ -362,6 +344,7 @@ void PANEL_SETUP_TRACKS_AND_VIAS::AppendTrackWidth( const int aWidth )
m_trackWidthsGrid->SetCellValue( i, TR_WIDTH_COL, val );
}
void PANEL_SETUP_TRACKS_AND_VIAS::AppendViaSize( const int aSize, const int aDrill )
{
int i = m_viaSizesGrid->GetNumberRows();
@ -378,6 +361,7 @@ void PANEL_SETUP_TRACKS_AND_VIAS::AppendViaSize( const int aSize, const int aDri
}
}
void PANEL_SETUP_TRACKS_AND_VIAS::AppendDiffPairs( const int aWidth, const int aGap,
const int aViaGap )
{
@ -412,6 +396,7 @@ void PANEL_SETUP_TRACKS_AND_VIAS::OnAddTrackWidthsClick( wxCommandEvent& aEvent
m_trackWidthsGrid->ShowCellEditControl();
}
void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveTrackWidthsClick( wxCommandEvent& event )
{
int curRow = m_trackWidthsGrid->GetGridCursorRow();
@ -426,6 +411,7 @@ void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveTrackWidthsClick( wxCommandEvent& even
m_trackWidthsGrid->SetGridCursor( curRow, m_trackWidthsGrid->GetGridCursorCol() );
}
void PANEL_SETUP_TRACKS_AND_VIAS::OnAddViaSizesClick( wxCommandEvent& event )
{
AppendViaSize( 0, 0 );
@ -437,6 +423,7 @@ void PANEL_SETUP_TRACKS_AND_VIAS::OnAddViaSizesClick( wxCommandEvent& event )
m_viaSizesGrid->ShowCellEditControl();
}
void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveViaSizesClick( wxCommandEvent& event )
{
int curRow = m_viaSizesGrid->GetGridCursorRow();
@ -451,6 +438,7 @@ void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveViaSizesClick( wxCommandEvent& event )
m_viaSizesGrid->SetGridCursor( curRow, m_viaSizesGrid->GetGridCursorCol() );
}
void PANEL_SETUP_TRACKS_AND_VIAS::OnAddDiffPairsClick( wxCommandEvent& event )
{
AppendDiffPairs( 0, 0, 0 );
@ -462,6 +450,7 @@ void PANEL_SETUP_TRACKS_AND_VIAS::OnAddDiffPairsClick( wxCommandEvent& event )
m_diffPairsGrid->ShowCellEditControl();
}
void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveDiffPairsClick( wxCommandEvent& event )
{
int curRow = m_diffPairsGrid->GetGridCursorRow();
@ -475,3 +464,23 @@ void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveDiffPairsClick( wxCommandEvent& event
m_diffPairsGrid->MakeCellVisible( curRow, m_diffPairsGrid->GetGridCursorCol() );
m_diffPairsGrid->SetGridCursor( curRow, m_diffPairsGrid->GetGridCursorCol() );
}
void PANEL_SETUP_TRACKS_AND_VIAS::ImportSettingsFrom( BOARD* aBoard )
{
m_trackWidthsGrid->CommitPendingChanges( true );
m_viaSizesGrid->CommitPendingChanges( true );
m_diffPairsGrid->CommitPendingChanges( true );
// Note: do not change the board, as we need to get the current nets from it for
// netclass memberships. All the netclass definitions and dimension lists are in
// the BOARD_DESIGN_SETTINGS.
BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
m_BrdSettings = &aBoard->GetDesignSettings();
TransferDataToWindow();
m_BrdSettings = savedSettings;
}

View File

@ -737,7 +737,7 @@ void PCB_EDIT_FRAME::DoShowBoardSetupDialog( const wxString& aInitialPage,
if( dlg.ShowModal() == wxID_OK )
{
Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters() );
SaveProjectSettings( false );
UpdateUserInterface();
ReCreateAuxiliaryToolbar();