Load BOARD project settings before loading BOARD in case BOARD has

any configuration overrides.

Call SetDesignSettings() in PCB_BASE_FRAME::ReadSetup().
This commit is contained in:
Dick Hollenbeck 2012-02-29 09:25:38 -06:00
parent 75d2dc7311
commit c41752fdf4
4 changed files with 49 additions and 48 deletions

View File

@ -1,10 +1,10 @@
///////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////
// Name: dialog_mask_clearance.cpp // Name: dialog_mask_clearance.cpp
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Modified by: // Modified by:
// Created: 17 feb 2009 // Created: 17 feb 2009
// Licence: GPL // Licence: GPL
///////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////
#include <fctsys.h> #include <fctsys.h>
#include <confirm.h> #include <confirm.h>
@ -17,15 +17,15 @@
#include <dialog_mask_clearance.h> #include <dialog_mask_clearance.h>
/** /**
* DIALOG_PADS_MASK_CLEARANCE_BASE, derived from DIALOG_PADS_MASK_CLEARANCE_BASE_BASE * Class DIALOG_PADS_MASK_CLEARANCE
* @see dialog_dialog_mask_clearance_base.h and dialog_mask_clearance.cpp, * is derived from DIALOG_PADS_MASK_CLEARANCE_BASE.
* automatically created by wxFormBuilder * @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* aParent ) :
DIALOG_PADS_MASK_CLEARANCE::DIALOG_PADS_MASK_CLEARANCE( PCB_EDIT_FRAME* parent ) : DIALOG_PADS_MASK_CLEARANCE_BASE( aParent )
DIALOG_PADS_MASK_CLEARANCE_BASE( parent )
{ {
m_Parent = parent; m_Parent = aParent;
m_BrdSettings = m_Parent->GetBoard()->GetDesignSettings(); m_BrdSettings = m_Parent->GetBoard()->GetDesignSettings();
MyInit(); MyInit();
@ -44,30 +44,31 @@ void DIALOG_PADS_MASK_CLEARANCE::MyInit()
int Internal_Unit = m_Parent->GetInternalUnits(); int Internal_Unit = m_Parent->GetInternalUnits();
PutValueInLocalUnits( *m_SolderMaskMarginCtrl, PutValueInLocalUnits( *m_SolderMaskMarginCtrl,
m_BrdSettings.m_SolderMaskMargin, m_BrdSettings.m_SolderMaskMargin,
Internal_Unit ); Internal_Unit );
// These 2 parameters are usually < 0, so prepare entering a negative // These 2 parameters are usually < 0, so prepare entering a negative
// value, if current is 0 // value, if current is 0
PutValueInLocalUnits( *m_SolderPasteMarginCtrl, PutValueInLocalUnits( *m_SolderPasteMarginCtrl,
m_BrdSettings.m_SolderPasteMargin, m_BrdSettings.m_SolderPasteMargin,
Internal_Unit ); Internal_Unit );
if( m_BrdSettings.m_SolderPasteMargin == 0 ) if( m_BrdSettings.m_SolderPasteMargin == 0 )
m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) +
m_SolderPasteMarginCtrl->GetValue() ); m_SolderPasteMarginCtrl->GetValue() );
wxString msg; wxString msg;
msg.Printf( wxT( "%f" ), m_BrdSettings.m_SolderPasteMarginRatio * 100.0 ); 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 ); m_SolderPasteMarginRatioCtrl->SetValue( wxT( "-" ) + msg );
else else
m_SolderPasteMarginRatioCtrl->SetValue( msg ); m_SolderPasteMarginRatioCtrl->SetValue( msg );
} }
/*******************************************************************/
void DIALOG_PADS_MASK_CLEARANCE::OnButtonOkClick( wxCommandEvent& event ) void DIALOG_PADS_MASK_CLEARANCE::OnButtonOkClick( wxCommandEvent& event )
/*******************************************************************/
{ {
m_BrdSettings.m_SolderMaskMargin = m_BrdSettings.m_SolderMaskMargin =
ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, m_Parent->GetInternalUnits() ); ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, m_Parent->GetInternalUnits() );
@ -75,13 +76,15 @@ void DIALOG_PADS_MASK_CLEARANCE::OnButtonOkClick( wxCommandEvent& event )
m_BrdSettings.m_SolderPasteMargin = m_BrdSettings.m_SolderPasteMargin =
ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, m_Parent->GetInternalUnits() ); ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, m_Parent->GetInternalUnits() );
double dtmp = 0; double dtmp = 0;
wxString msg = m_SolderPasteMarginRatioCtrl->GetValue(); wxString msg = m_SolderPasteMarginRatioCtrl->GetValue();
msg.ToDouble( &dtmp ); msg.ToDouble( &dtmp );
// A margin ratio de -50% means no paste on a pad, the ratio must be >= 50 % // A margin ratio de -50% means no paste on a pad, the ratio must be >= 50 %
if( dtmp < -50 ) if( dtmp < -50 )
dtmp = -50; dtmp = -50;
if( dtmp > +100 ) if( dtmp > +100 )
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 ) void DIALOG_PADS_MASK_CLEARANCE::OnButtonCancelClick( wxCommandEvent& event )
{ {
EndModal( 0 ); EndModal( 0 );

View File

@ -258,8 +258,10 @@ this file again." ) );
m_DisplayPadFill = DisplayOpt.DisplayPadFill; m_DisplayPadFill = DisplayOpt.DisplayPadFill;
m_DisplayViaFill = DisplayOpt.DisplayViaFill; m_DisplayViaFill = DisplayOpt.DisplayViaFill;
ReadPcbFile( &reader, false ); // load project settings before BOARD, in case BOARD file has overrides.
LoadProjectSettings( GetScreen()->GetFileName() ); LoadProjectSettings( GetScreen()->GetFileName() );
ReadPcbFile( &reader, false );
} }
#else #else
@ -272,6 +274,9 @@ this file again." ) );
m_DisplayModEdge = DisplayOpt.DisplayModEdge; m_DisplayModEdge = DisplayOpt.DisplayModEdge;
m_DisplayPadFill = DisplayOpt.DisplayPadFill; m_DisplayPadFill = DisplayOpt.DisplayPadFill;
m_DisplayViaFill = DisplayOpt.DisplayViaFill; m_DisplayViaFill = DisplayOpt.DisplayViaFill;
// load project settings before BOARD, in case BOARD file has overrides.
LoadProjectSettings( GetScreen()->GetFileName() );
} }
else else
{ {
@ -306,11 +311,6 @@ this file again." ) );
wxMessageBox( msg, _( "Open Board File" ), wxOK | wxICON_ERROR ); wxMessageBox( msg, _( "Open Board File" ), wxOK | wxICON_ERROR );
} }
if( !aAppend )
{
LoadProjectSettings( GetScreen()->GetFileName() );
}
if( loadedBoard ) if( loadedBoard )
{ {
// we should not ask PLUGINs to do these items: // we should not ask PLUGINs to do these items:

View File

@ -382,6 +382,8 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
// projects. // projects.
GetBoard()->m_NetClasses.GetDefault()->SetParams(); GetBoard()->m_NetClasses.GetDefault()->SetParams();
GetBoard()->SetDesignSettings( bds );
GetBoard()->SetZoneSettings( zoneInfo ); GetBoard()->SetZoneSettings( zoneInfo );
return 0; return 0;

View File

@ -103,30 +103,30 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
break; break;
case ID_CONFIG_READ: 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; fn = GetScreen()->GetFileName();
msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) ); fn.SetExt( ProjectFileExtension );
DisplayError( this, msg );
break; 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; break;
}
/* Hotkey IDs */ // Hotkey IDs
case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG: case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
ExportHotkeyConfigToFile( g_Board_Editor_Hokeys_Descr ); ExportHotkeyConfigToFile( g_Board_Editor_Hokeys_Descr );
break; break;
@ -144,7 +144,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
DisplayHotkeyList( this, g_Board_Editor_Hokeys_Descr ); DisplayHotkeyList( this, g_Board_Editor_Hokeys_Descr );
break; break;
/* Macros IDs*/ // Macros IDs
case ID_PREFRENCES_MACROS_SAVE: case ID_PREFRENCES_MACROS_SAVE:
SaveMacros(); SaveMacros();
break; break;