Move paste and mask clearance settings back to board file
These are needed for correct Gerber plotting so need to be stored along with the board file
This commit is contained in:
parent
4f4b95456d
commit
dbb6d0fb4a
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include <settings/nested_settings.h>
|
||||
|
||||
|
||||
NESTED_SETTINGS::NESTED_SETTINGS( const std::string& aName, int aVersion, JSON_SETTINGS* aParent,
|
||||
const std::string& aPath ) :
|
||||
JSON_SETTINGS( aName, SETTINGS_LOC::NESTED, aVersion ),
|
||||
|
@ -54,8 +53,7 @@ bool NESTED_SETTINGS::LoadFromFile( const wxString& aDirectory )
|
|||
{
|
||||
update( ( *m_parent )[ptr] );
|
||||
|
||||
wxLogTrace( traceSettings, "Loaded NESTED_SETTINGS %s with schema %d",
|
||||
GetFilename(), m_schemaVersion );
|
||||
wxLogTrace( traceSettings, "Loaded NESTED_SETTINGS %s", GetFilename() );
|
||||
|
||||
success = true;
|
||||
}
|
||||
|
@ -71,21 +69,14 @@ bool NESTED_SETTINGS::LoadFromFile( const wxString& aDirectory )
|
|||
{
|
||||
int filever = -1;
|
||||
|
||||
if( count( PointerFromString( "meta.version" ) ) )
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
filever = at( PointerFromString( "meta.version" ) ).get<int>();
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
wxLogTrace( traceSettings, "%s: nested settings version could not be read!",
|
||||
m_filename );
|
||||
success = false;
|
||||
}
|
||||
filever = at( PointerFromString( "meta.version" ) ).get<int>();
|
||||
}
|
||||
else
|
||||
catch( ... )
|
||||
{
|
||||
wxLogTrace( traceSettings, "%s: nested settings version could not be read!",
|
||||
m_filename );
|
||||
success = false;
|
||||
}
|
||||
|
||||
|
@ -106,6 +97,10 @@ bool NESTED_SETTINGS::LoadFromFile( const wxString& aDirectory )
|
|||
"%s: warning: nested settings version %d is newer than latest (%d)",
|
||||
m_filename, filever, m_schemaVersion );
|
||||
}
|
||||
else if( filever >= 0 )
|
||||
{
|
||||
wxLogTrace( traceSettings, "%s: schema version %d is current", m_filename, filever );
|
||||
}
|
||||
}
|
||||
|
||||
Load();
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <project/project_file.h>
|
||||
#include <advanced_config.h>
|
||||
|
||||
const int bdsSchemaVersion = 1;
|
||||
const int bdsSchemaVersion = 2;
|
||||
|
||||
|
||||
BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
|
||||
|
@ -169,10 +169,14 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std:
|
|||
// Global mask margins:
|
||||
m_SolderMaskMargin = Millimeter2iu( DEFAULT_SOLDERMASK_CLEARANCE );
|
||||
m_SolderMaskMinWidth = Millimeter2iu( DEFAULT_SOLDERMASK_MIN_WIDTH );
|
||||
m_SolderPasteMargin = 0; // Solder paste margin absolute value
|
||||
m_SolderPasteMarginRatio = 0.0; // Solder paste margin as a ratio of pad size
|
||||
// The final margin is the sum of these 2 values
|
||||
// Usually < 0 because the mask is smaller than pad
|
||||
|
||||
// Solder paste margin absolute value
|
||||
m_SolderPasteMargin = Millimeter2iu( DEFAULT_SOLDERPASTE_CLEARANCE );
|
||||
// Solder paste margin as a ratio of pad size
|
||||
// The final margin is the sum of these 2 values
|
||||
// Usually < 0 because the mask is smaller than pad
|
||||
m_SolderPasteMarginRatio = DEFAULT_SOLDERPASTE_RATIO;
|
||||
|
||||
// Layer thickness for 3D viewer
|
||||
m_boardThickness = Millimeter2iu( DEFAULT_BOARD_THICKNESS_MM );
|
||||
|
||||
|
@ -239,21 +243,6 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std:
|
|||
&m_CopperEdgeClearance, Millimeter2iu( LEGACY_COPPEREDGECLEARANCE ),
|
||||
Millimeter2iu( -0.01 ), Millimeter2iu( 25.0 ), MM_PER_IU ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_SCALED<int>( "rules.solder_mask_clearance",
|
||||
&m_SolderMaskMargin, Millimeter2iu( DEFAULT_SOLDERMASK_CLEARANCE ),
|
||||
Millimeter2iu( -1.0 ), Millimeter2iu( 1.0 ), MM_PER_IU ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_SCALED<int>( "rules.solder_mask_min_width",
|
||||
&m_SolderMaskMinWidth, Millimeter2iu( DEFAULT_SOLDERMASK_MIN_WIDTH ), 0,
|
||||
Millimeter2iu( 1.0 ), MM_PER_IU ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_SCALED<int>( "rules.solder_paste_clearance",
|
||||
&m_SolderPasteMargin, Millimeter2iu( DEFAULT_SOLDERPASTE_CLEARANCE ),
|
||||
Millimeter2iu( -1.0 ), Millimeter2iu( 1.0 ), MM_PER_IU ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<double>( "rules.solder_paste_margin_ratio",
|
||||
&m_SolderPasteMarginRatio, DEFAULT_SOLDERPASTE_RATIO, -0.5, 1.0 ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "rule_severities",
|
||||
[&]() -> nlohmann::json
|
||||
{
|
||||
|
@ -606,6 +595,37 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std:
|
|||
&m_ZoneKeepExternalFillets, false ) );
|
||||
|
||||
registerMigration( 0, 1, std::bind( &BOARD_DESIGN_SETTINGS::migrateSchema0to1, this ) );
|
||||
|
||||
registerMigration( 1, 2,
|
||||
[&]() -> bool
|
||||
{
|
||||
// Schema 1 to 2: move mask and paste margin settings back to board.
|
||||
// The parameters are removed, so we just have to manually load them here and
|
||||
// they will get saved with the board
|
||||
if( OPT<double> optval = Get<double>( "rules.solder_mask_clearance" ) )
|
||||
m_SolderMaskMargin = static_cast<int>( *optval * IU_PER_MM );
|
||||
|
||||
if( OPT<double> optval = Get<double>( "rules.solder_mask_min_width" ) )
|
||||
m_SolderMaskMinWidth = static_cast<int>( *optval * IU_PER_MM );
|
||||
|
||||
if( OPT<double> optval = Get<double>( "rules.solder_paste_clearance" ) )
|
||||
m_SolderPasteMargin = static_cast<int>( *optval * IU_PER_MM );
|
||||
|
||||
if( OPT<double> optval = Get<double>( "rules.solder_paste_margin_ratio" ) )
|
||||
m_SolderPasteMarginRatio = *optval;
|
||||
|
||||
try
|
||||
{
|
||||
at( "rules" ).erase( "solder_mask_clearance" );
|
||||
at( "rules" ).erase( "solder_mask_min_width" );
|
||||
at( "rules" ).erase( "solder_paste_clearance" );
|
||||
at( "rules" ).erase( "solder_paste_margin_ratio" );
|
||||
}
|
||||
catch( ... )
|
||||
{}
|
||||
|
||||
return true;
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -470,6 +470,21 @@ void PCB_IO::formatSetup( const BOARD* aBoard, int aNestLevel ) const
|
|||
|
||||
BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings();
|
||||
|
||||
m_out->Print( aNestLevel+1, "(pad_to_mask_clearance %s)\n",
|
||||
FormatInternalUnits( dsnSettings.m_SolderMaskMargin ).c_str() );
|
||||
|
||||
if( dsnSettings.m_SolderMaskMinWidth )
|
||||
m_out->Print( aNestLevel+1, "(solder_mask_min_width %s)\n",
|
||||
FormatInternalUnits( dsnSettings.m_SolderMaskMinWidth ).c_str() );
|
||||
|
||||
if( dsnSettings.m_SolderPasteMargin != 0 )
|
||||
m_out->Print( aNestLevel+1, "(pad_to_paste_clearance %s)\n",
|
||||
FormatInternalUnits( dsnSettings.m_SolderPasteMargin ).c_str() );
|
||||
|
||||
if( dsnSettings.m_SolderPasteMarginRatio != 0 )
|
||||
m_out->Print( aNestLevel+1, "(pad_to_paste_clearance_ratio %s)\n",
|
||||
Double2Str( dsnSettings.m_SolderPasteMarginRatio ).c_str() );
|
||||
|
||||
if( dsnSettings.m_AuxOrigin != wxPoint( 0, 0 ) )
|
||||
m_out->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n",
|
||||
FormatInternalUnits( dsnSettings.m_AuxOrigin.x ).c_str(),
|
||||
|
|
|
@ -94,7 +94,8 @@ class PCB_TEXT;
|
|||
//#define SEXPR_BOARD_FILE_VERSION 20201116 // Write version and generator string in footprint files.
|
||||
//#define SEXPR_BOARD_FILE_VERSION 20201220 // Add free via token
|
||||
//#define SEXPR_BOARD_FILE_VERSION 20210108 // Pad locking moved from footprint to pads
|
||||
#define SEXPR_BOARD_FILE_VERSION 20210126 // Store pintype alongside pinfunction (in pads).
|
||||
//#define SEXPR_BOARD_FILE_VERSION 20210126 // Store pintype alongside pinfunction (in pads).
|
||||
#define SEXPR_BOARD_FILE_VERSION 20210228 // Move global margins back to board file
|
||||
|
||||
#define BOARD_FILE_HOST_VERSION 20200825 ///< Earlier files than this include the host tag
|
||||
|
||||
|
|
|
@ -1823,25 +1823,21 @@ void PCB_PARSER::parseSetup()
|
|||
|
||||
case T_pad_to_mask_clearance:
|
||||
designSettings.m_SolderMaskMargin = parseBoardUnits( T_pad_to_mask_clearance );
|
||||
m_board->m_LegacyDesignSettingsLoaded = true;
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
case T_solder_mask_min_width:
|
||||
designSettings.m_SolderMaskMinWidth = parseBoardUnits( T_solder_mask_min_width );
|
||||
m_board->m_LegacyDesignSettingsLoaded = true;
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
case T_pad_to_paste_clearance:
|
||||
designSettings.m_SolderPasteMargin = parseBoardUnits( T_pad_to_paste_clearance );
|
||||
m_board->m_LegacyDesignSettingsLoaded = true;
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
case T_pad_to_paste_clearance_ratio:
|
||||
designSettings.m_SolderPasteMarginRatio = parseDouble( T_pad_to_paste_clearance_ratio );
|
||||
m_board->m_LegacyDesignSettingsLoaded = true;
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue