diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 46f56a4d29..6c8ba02391 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -158,9 +158,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; @@ -173,10 +172,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; @@ -213,7 +212,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() ) @@ -259,12 +258,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: @@ -282,7 +279,7 @@ bool SCH_EDIT_FRAME::LoadProjectFile() pglayout.SetPageLayout( pg_fullfilename ); - return isRead; + return ret; } @@ -298,8 +295,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 ) @@ -308,7 +304,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 ); } ///@{ diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index e4b47ece92..78fade11b5 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1293,11 +1293,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() ); } diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 36edeebab7..9e0c4a5aa6 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -261,7 +261,7 @@ public: * already been populated and return a reference to the array to the caller. *

*/ - PARAM_CFG_ARRAY& GetProjectFileParametersList(); + PARAM_CFG_ARRAY& GetProjectFileParameters(); /** * Save changes to the project settings to the project (.pro) file. diff --git a/include/config_params.h b/include/config_params.h index 8dd1cddade..37096f6a3d 100644 --- a/include/config_params.h +++ b/include/config_params.h @@ -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 diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index a9a9056723..e11fbb4907 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -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( netclassName ); + if( index == 0 ) + netclass = m_Pt_param->GetDefault(); + else + netclass = std::make_shared( 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 ) ); } diff --git a/pcbnew/dialogs/dialog_board_setup.cpp b/pcbnew/dialogs/dialog_board_setup.cpp index d47759651c..7b9b7227c8 100644 --- a/pcbnew/dialogs/dialog_board_setup.cpp +++ b/pcbnew/dialogs/dialog_board_setup.cpp @@ -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 ); diff --git a/pcbnew/dialogs/dialog_import_settings.cpp b/pcbnew/dialogs/dialog_import_settings.cpp index 847c7a885b..1a3aba920d 100644 --- a/pcbnew/dialogs/dialog_import_settings.cpp +++ b/pcbnew/dialogs/dialog_import_settings.cpp @@ -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 ); } diff --git a/pcbnew/dialogs/dialog_import_settings_base.cpp b/pcbnew/dialogs/dialog_import_settings_base.cpp index 86bca505c1..d21f55589b 100644 --- a/pcbnew/dialogs/dialog_import_settings_base.cpp +++ b/pcbnew/dialogs/dialog_import_settings_base.cpp @@ -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 ); diff --git a/pcbnew/dialogs/dialog_import_settings_base.fbp b/pcbnew/dialogs/dialog_import_settings_base.fbp index 81e189218e..abe519a9fb 100644 --- a/pcbnew/dialogs/dialog_import_settings_base.fbp +++ b/pcbnew/dialogs/dialog_import_settings_base.fbp @@ -815,6 +815,94 @@ + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Predefined Track and Via dimensions + + 0 + + + 0 + + 1 + m_TracksAndViasOpt + 1 + + + public + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxRIGHT|wxLEFT diff --git a/pcbnew/dialogs/dialog_import_settings_base.h b/pcbnew/dialogs/dialog_import_settings_base.h index c03696105f..7f07c46ed7 100644 --- a/pcbnew/dialogs/dialog_import_settings_base.h +++ b/pcbnew/dialogs/dialog_import_settings_base.h @@ -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 ); diff --git a/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp b/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp index 24969a2e6a..53f8458a4a 100644 --- a/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp +++ b/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp @@ -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; +} + diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 61368a73e9..b4db36fb53 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -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();