From 14d5685528dce7e19df888d5f4f502b8583c0e5a Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Wed, 29 Feb 2012 09:25:38 -0600 Subject: [PATCH] Load BOARD project settings before loading BOARD in case BOARD has any configuration overrides. Call SetDesignSettings() in PCB_BASE_FRAME::ReadSetup(). --- pcbnew/dialogs/dialog_mask_clearance.cpp | 41 +++++++++++------------ pcbnew/files.cpp | 12 +++---- pcbnew/ioascii.cpp | 2 ++ pcbnew/pcbnew_config.cpp | 42 ++++++++++++------------ 4 files changed, 49 insertions(+), 48 deletions(-) diff --git a/pcbnew/dialogs/dialog_mask_clearance.cpp b/pcbnew/dialogs/dialog_mask_clearance.cpp index 3c7a76a6a8..32c1c3ff76 100644 --- a/pcbnew/dialogs/dialog_mask_clearance.cpp +++ b/pcbnew/dialogs/dialog_mask_clearance.cpp @@ -1,10 +1,10 @@ -///////////////////////////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////////////////////////// // Name: dialog_mask_clearance.cpp // Author: jean-pierre Charras // Modified by: // Created: 17 feb 2009 // Licence: GPL -///////////////////////////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////////////////////////// #include #include @@ -17,15 +17,15 @@ #include /** - * DIALOG_PADS_MASK_CLEARANCE_BASE, derived from DIALOG_PADS_MASK_CLEARANCE_BASE_BASE - * @see dialog_dialog_mask_clearance_base.h and dialog_mask_clearance.cpp, - * automatically created by wxFormBuilder + * Class DIALOG_PADS_MASK_CLEARANCE + * is derived from DIALOG_PADS_MASK_CLEARANCE_BASE. + * @see dialog_dialog_mask_clearance_base.h and dialog_mask_clearance_base.cpp, + * which are maintained by wxFormBuilder */ - -DIALOG_PADS_MASK_CLEARANCE::DIALOG_PADS_MASK_CLEARANCE( PCB_EDIT_FRAME* parent ) : - DIALOG_PADS_MASK_CLEARANCE_BASE( parent ) +DIALOG_PADS_MASK_CLEARANCE::DIALOG_PADS_MASK_CLEARANCE( PCB_EDIT_FRAME* aParent ) : + DIALOG_PADS_MASK_CLEARANCE_BASE( aParent ) { - m_Parent = parent; + m_Parent = aParent; m_BrdSettings = m_Parent->GetBoard()->GetDesignSettings(); MyInit(); @@ -44,30 +44,31 @@ void DIALOG_PADS_MASK_CLEARANCE::MyInit() int Internal_Unit = m_Parent->GetInternalUnits(); PutValueInLocalUnits( *m_SolderMaskMarginCtrl, - m_BrdSettings.m_SolderMaskMargin, + m_BrdSettings.m_SolderMaskMargin, Internal_Unit ); // These 2 parameters are usually < 0, so prepare entering a negative // value, if current is 0 PutValueInLocalUnits( *m_SolderPasteMarginCtrl, - m_BrdSettings.m_SolderPasteMargin, + m_BrdSettings.m_SolderPasteMargin, Internal_Unit ); + if( m_BrdSettings.m_SolderPasteMargin == 0 ) m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->GetValue() ); + wxString msg; msg.Printf( wxT( "%f" ), m_BrdSettings.m_SolderPasteMarginRatio * 100.0 ); - if( m_BrdSettings.m_SolderPasteMarginRatio == 0.0 && - msg[0] == '0') // Sometimes Printf add a sign if the value is small + + // Sometimes Printf adds a sign if the value is small + if( m_BrdSettings.m_SolderPasteMarginRatio == 0.0 && msg[0] == '0' ) m_SolderPasteMarginRatioCtrl->SetValue( wxT( "-" ) + msg ); else m_SolderPasteMarginRatioCtrl->SetValue( msg ); } -/*******************************************************************/ void DIALOG_PADS_MASK_CLEARANCE::OnButtonOkClick( wxCommandEvent& event ) -/*******************************************************************/ { m_BrdSettings.m_SolderMaskMargin = ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, m_Parent->GetInternalUnits() ); @@ -75,13 +76,15 @@ void DIALOG_PADS_MASK_CLEARANCE::OnButtonOkClick( wxCommandEvent& event ) m_BrdSettings.m_SolderPasteMargin = ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, m_Parent->GetInternalUnits() ); - double dtmp = 0; - wxString msg = m_SolderPasteMarginRatioCtrl->GetValue(); + double dtmp = 0; + wxString msg = m_SolderPasteMarginRatioCtrl->GetValue(); + msg.ToDouble( &dtmp ); // A margin ratio de -50% means no paste on a pad, the ratio must be >= 50 % if( dtmp < -50 ) dtmp = -50; + if( dtmp > +100 ) dtmp = +100; @@ -93,10 +96,6 @@ void DIALOG_PADS_MASK_CLEARANCE::OnButtonOkClick( wxCommandEvent& event ) } -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL - */ - void DIALOG_PADS_MASK_CLEARANCE::OnButtonCancelClick( wxCommandEvent& event ) { EndModal( 0 ); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 442759f057..ea1bd2724c 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -258,8 +258,10 @@ this file again." ) ); m_DisplayPadFill = DisplayOpt.DisplayPadFill; m_DisplayViaFill = DisplayOpt.DisplayViaFill; - ReadPcbFile( &reader, false ); + // load project settings before BOARD, in case BOARD file has overrides. LoadProjectSettings( GetScreen()->GetFileName() ); + + ReadPcbFile( &reader, false ); } #else @@ -272,6 +274,9 @@ this file again." ) ); m_DisplayModEdge = DisplayOpt.DisplayModEdge; m_DisplayPadFill = DisplayOpt.DisplayPadFill; m_DisplayViaFill = DisplayOpt.DisplayViaFill; + + // load project settings before BOARD, in case BOARD file has overrides. + LoadProjectSettings( GetScreen()->GetFileName() ); } else { @@ -306,11 +311,6 @@ this file again." ) ); wxMessageBox( msg, _( "Open Board File" ), wxOK | wxICON_ERROR ); } - if( !aAppend ) - { - LoadProjectSettings( GetScreen()->GetFileName() ); - } - if( loadedBoard ) { // we should not ask PLUGINs to do these items: diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index e98b11e26e..1904d5ebc4 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -382,6 +382,8 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) // projects. GetBoard()->m_NetClasses.GetDefault()->SetParams(); + GetBoard()->SetDesignSettings( bds ); + GetBoard()->SetZoneSettings( zoneInfo ); return 0; diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 1df3276a0b..71cf632012 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -103,30 +103,30 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) break; case ID_CONFIG_READ: - { - fn = GetScreen()->GetFileName(); - fn.SetExt( ProjectFileExtension ); - - wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), - fn.GetFullName(), ProjectFileWildcard, - wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); - - if( dlg.ShowModal() == wxID_CANCEL ) - break; - - if( !wxFileExists( dlg.GetPath() ) ) { - wxString msg; - msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) ); - DisplayError( this, msg ); - break; + fn = GetScreen()->GetFileName(); + fn.SetExt( ProjectFileExtension ); + + wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), + fn.GetFullName(), ProjectFileWildcard, + wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); + + if( dlg.ShowModal() == wxID_CANCEL ) + break; + + if( !wxFileExists( dlg.GetPath() ) ) + { + wxString msg; + msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) ); + DisplayError( this, msg ); + break; + } + + LoadProjectSettings( dlg.GetPath() ); } - - LoadProjectSettings( dlg.GetPath() ); break; - } - /* Hotkey IDs */ + // Hotkey IDs case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG: ExportHotkeyConfigToFile( g_Board_Editor_Hokeys_Descr ); break; @@ -144,7 +144,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) DisplayHotkeyList( this, g_Board_Editor_Hokeys_Descr ); break; - /* Macros IDs*/ + // Macros IDs case ID_PREFRENCES_MACROS_SAVE: SaveMacros(); break;