2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file class_board_design_settings.cpp
|
|
|
|
* BOARD_DESIGN_SETTINGS class functions.
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <layers_id_colors_and_visibility.h>
|
2009-10-28 11:48:47 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <class_board_design_settings.h>
|
2009-10-28 11:48:47 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_track.h>
|
2009-10-28 11:48:47 +00:00
|
|
|
|
2012-04-08 23:32:32 +00:00
|
|
|
#define DEFAULT_BOARD_THICKNESS_DMILS 620
|
|
|
|
|
2009-10-28 11:48:47 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() :
|
|
|
|
m_Pad_Master( 0 )
|
2009-10-28 11:48:47 +00:00
|
|
|
{
|
2011-09-23 13:57:12 +00:00
|
|
|
m_EnabledLayers = ALL_LAYERS; // All layers enabled at first.
|
|
|
|
// SetCopperLayerCount() will adjust this.
|
2012-02-06 05:44:19 +00:00
|
|
|
|
|
|
|
SetVisibleLayers( FULL_LAYERS );
|
|
|
|
|
|
|
|
// set all but hidden text as visible.
|
2012-02-06 15:31:36 +00:00
|
|
|
m_VisibleElements = ~( 1 << MOD_TEXT_INVISIBLE );
|
2011-09-23 13:57:12 +00:00
|
|
|
|
|
|
|
SetCopperLayerCount( 2 ); // Default design is a double sided board
|
|
|
|
|
|
|
|
// via type (VIA_BLIND_BURIED, VIA_THROUGH VIA_MICROVIA).
|
|
|
|
m_CurrentViaType = VIA_THROUGH;
|
|
|
|
|
|
|
|
// if true, when creating a new track starting on an existing track, use this track width
|
|
|
|
m_UseConnectedTrackWidth = false;
|
|
|
|
|
|
|
|
m_MicroViasAllowed = false; // true to allow micro vias
|
2012-04-08 23:32:32 +00:00
|
|
|
|
|
|
|
m_DrawSegmentWidth = DMils2iu( 100 ); // current graphic line width (not EDGE layer)
|
|
|
|
|
|
|
|
m_EdgeSegmentWidth = DMils2iu( 100 ); // current graphic line width (EDGE layer only)
|
|
|
|
m_PcbTextWidth = DMils2iu( 100 ); // current Pcb (not module) Text width
|
|
|
|
|
|
|
|
m_PcbTextSize = wxSize( DMils2iu( 500 ), DMils2iu( 500 ) );
|
|
|
|
// current Pcb (not module) Text size
|
|
|
|
|
|
|
|
m_TrackMinWidth = DMils2iu( 100 ); // track min value for width ((min copper size value
|
|
|
|
m_ViasMinSize = DMils2iu( 350 ); // vias (not micro vias) min diameter
|
|
|
|
m_ViasMinDrill = DMils2iu( 200 ); // vias (not micro vias) min drill diameter
|
|
|
|
m_MicroViasMinSize = DMils2iu( 200 ); // micro vias (not vias) min diameter
|
|
|
|
m_MicroViasMinDrill = DMils2iu( 50 ); // micro vias (not vias) min drill diameter
|
2009-12-07 06:16:11 +00:00
|
|
|
|
2009-11-04 19:08:08 +00:00
|
|
|
// Global mask margins:
|
2012-04-08 23:32:32 +00:00
|
|
|
m_SolderMaskMargin = DMils2iu( 150 ); // Solder mask margin
|
2011-09-23 13:57:12 +00:00
|
|
|
m_SolderPasteMargin = 0; // Solder paste margin absolute value
|
|
|
|
m_SolderPasteMarginRatio = 0.0; // Solder pask margin ratio value of pad size
|
|
|
|
// The final margin is the sum of these 2 values
|
|
|
|
// Usually < 0 because the mask is smaller than pad
|
2009-10-28 11:48:47 +00:00
|
|
|
|
2012-04-08 23:32:32 +00:00
|
|
|
m_ModuleTextSize = wxSize( DMils2iu( 500 ), DMils2iu( 500 ) );
|
|
|
|
m_ModuleTextWidth = DMils2iu( 100 );
|
|
|
|
m_ModuleSegmentWidth = DMils2iu( 100 );
|
2012-02-02 07:23:00 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
// Layer thickness for 3D viewer
|
2012-04-08 23:32:32 +00:00
|
|
|
m_BoardThickness = DMils2iu( DEFAULT_BOARD_THICKNESS_DMILS );
|
2009-10-28 11:48:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
void BOARD_DESIGN_SETTINGS::AppendConfigs( PARAM_CFG_ARRAY* aResult )
|
|
|
|
{
|
|
|
|
m_Pad_Master.AppendConfigs( aResult );
|
|
|
|
|
2012-04-08 23:32:32 +00:00
|
|
|
aResult->push_back( new PARAM_CFG_INT( wxT( "BoardThickness" ), &m_BoardThickness,
|
|
|
|
DMils2iu( DEFAULT_BOARD_THICKNESS_DMILS ), 0, 0xFFFF ) );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2012-04-08 23:32:32 +00:00
|
|
|
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtPcbV" ), &m_PcbTextSize.y,
|
|
|
|
DMils2iu( 600 ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2012-04-08 23:32:32 +00:00
|
|
|
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtPcbH" ), &m_PcbTextSize.x,
|
|
|
|
DMils2iu( 600 ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtModV" ), &m_ModuleTextSize.y,
|
2012-04-08 23:32:32 +00:00
|
|
|
DMils2iu( 500 ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtModH" ), &m_ModuleTextSize.x,
|
2012-04-08 23:32:32 +00:00
|
|
|
DMils2iu( 500 ), TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtModW" ), &m_ModuleTextWidth,
|
2012-04-08 23:32:32 +00:00
|
|
|
DMils2iu( 100 ), 1, TEXTS_MAX_WIDTH ) );
|
|
|
|
|
|
|
|
aResult->push_back( new PARAM_CFG_INT( wxT( "VEgarde" ), &m_SolderMaskMargin,
|
|
|
|
DMils2iu( 100 ), 0, DMils2iu( 10000 ) ) );
|
|
|
|
|
|
|
|
aResult->push_back( new PARAM_CFG_INT( wxT( "DrawLar" ), &m_DrawSegmentWidth,
|
|
|
|
DMils2iu( 120 ), 0, 0xFFFF ) );
|
|
|
|
|
|
|
|
aResult->push_back( new PARAM_CFG_INT( wxT( "EdgeLar" ), &m_EdgeSegmentWidth,
|
|
|
|
DMils2iu( 120 ), 0, 0xFFFF ) );
|
|
|
|
|
|
|
|
aResult->push_back( new PARAM_CFG_INT( wxT( "TxtLar" ), &m_PcbTextWidth,
|
|
|
|
DMils2iu( 120 ), 0, 0xFFFF ) );
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
aResult->push_back( new PARAM_CFG_INT( wxT( "MSegLar" ), &m_ModuleSegmentWidth,
|
2012-04-08 23:32:32 +00:00
|
|
|
DMils2iu( 120 ), 0, 0xFFFF ) );
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-28 11:48:47 +00:00
|
|
|
// see pcbstruct.h
|
2010-01-31 20:01:46 +00:00
|
|
|
int BOARD_DESIGN_SETTINGS::GetVisibleLayers() const
|
2009-10-28 11:48:47 +00:00
|
|
|
{
|
|
|
|
return m_VisibleLayers;
|
|
|
|
}
|
|
|
|
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
void BOARD_DESIGN_SETTINGS::SetVisibleAlls()
|
2010-01-27 20:07:50 +00:00
|
|
|
{
|
|
|
|
SetVisibleLayers( FULL_LAYERS );
|
2012-02-06 07:14:51 +00:00
|
|
|
m_VisibleElements = -1;
|
2010-01-27 20:07:50 +00:00
|
|
|
}
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
void BOARD_DESIGN_SETTINGS::SetVisibleLayers( int aMask )
|
2009-10-28 11:48:47 +00:00
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
// Although Pcbnew uses only 29, GerbView uses all 32 layers
|
2009-11-09 15:55:18 +00:00
|
|
|
m_VisibleLayers = aMask & m_EnabledLayers & FULL_LAYERS;
|
2009-10-28 11:48:47 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
void BOARD_DESIGN_SETTINGS::SetLayerVisibility( int aLayerIndex, bool aNewState )
|
2009-10-28 11:48:47 +00:00
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
// Altough Pcbnew uses only 29, GerbView uses all 32 layers
|
2009-10-28 11:48:47 +00:00
|
|
|
if( aLayerIndex < 0 || aLayerIndex >= 32 )
|
|
|
|
return;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2009-11-04 19:08:08 +00:00
|
|
|
if( aNewState && IsLayerEnabled( aLayerIndex ) )
|
2009-10-28 11:48:47 +00:00
|
|
|
m_VisibleLayers |= 1 << aLayerIndex;
|
|
|
|
else
|
|
|
|
m_VisibleLayers &= ~( 1 << aLayerIndex );
|
|
|
|
}
|
|
|
|
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
void BOARD_DESIGN_SETTINGS::SetElementVisibility( int aElementCategory, bool aNewState )
|
2009-10-28 11:48:47 +00:00
|
|
|
{
|
2010-01-29 20:36:12 +00:00
|
|
|
if( aElementCategory < 0 || aElementCategory >= END_PCB_VISIBLE_LIST )
|
2009-10-28 11:48:47 +00:00
|
|
|
return;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2009-10-28 11:48:47 +00:00
|
|
|
if( aNewState )
|
|
|
|
m_VisibleElements |= 1 << aElementCategory;
|
|
|
|
else
|
|
|
|
m_VisibleElements &= ~( 1 << aElementCategory );
|
|
|
|
}
|
2009-11-04 19:08:08 +00:00
|
|
|
|
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
void BOARD_DESIGN_SETTINGS::SetCopperLayerCount( int aNewLayerCount )
|
2009-10-28 11:48:47 +00:00
|
|
|
{
|
2010-01-21 07:41:30 +00:00
|
|
|
// if( aNewLayerCount < 2 ) aNewLayerCount = 2;
|
|
|
|
|
2009-10-28 11:48:47 +00:00
|
|
|
m_CopperLayerCount = aNewLayerCount;
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2009-10-28 11:48:47 +00:00
|
|
|
// ensure consistency with the m_EnabledLayers member
|
|
|
|
m_EnabledLayers &= ~ALL_CU_LAYERS;
|
2009-12-21 12:05:36 +00:00
|
|
|
m_EnabledLayers |= LAYER_BACK;
|
2009-12-07 03:46:13 +00:00
|
|
|
|
2009-11-04 19:08:08 +00:00
|
|
|
if( m_CopperLayerCount > 1 )
|
2009-12-21 12:05:36 +00:00
|
|
|
m_EnabledLayers |= LAYER_FRONT;
|
2009-12-07 03:46:13 +00:00
|
|
|
|
2009-11-04 19:08:08 +00:00
|
|
|
for( int ii = 1; ii < aNewLayerCount - 1; ii++ )
|
2009-10-28 11:48:47 +00:00
|
|
|
m_EnabledLayers |= 1 << ii;
|
|
|
|
}
|
2009-12-07 03:46:13 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
void BOARD_DESIGN_SETTINGS::SetEnabledLayers( int aMask )
|
2009-12-21 12:05:36 +00:00
|
|
|
{
|
2010-01-21 07:41:30 +00:00
|
|
|
// Back and front layers are always enabled.
|
|
|
|
aMask |= LAYER_BACK | LAYER_FRONT;
|
|
|
|
|
2009-12-21 12:05:36 +00:00
|
|
|
m_EnabledLayers = aMask;
|
|
|
|
|
2010-01-21 07:41:30 +00:00
|
|
|
// A disabled layer cannot be visible
|
|
|
|
m_VisibleLayers &= aMask;
|
2009-12-21 12:05:36 +00:00
|
|
|
|
2010-01-21 07:41:30 +00:00
|
|
|
// update m_CopperLayerCount to ensure its consistency with m_EnabledLayers
|
2009-12-21 12:05:36 +00:00
|
|
|
m_CopperLayerCount = 0;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2010-01-21 07:41:30 +00:00
|
|
|
for( int ii = 0; aMask && ii < NB_COPPER_LAYERS; ii++, aMask >>= 1 )
|
2009-12-21 12:05:36 +00:00
|
|
|
{
|
2010-01-21 07:41:30 +00:00
|
|
|
if( aMask & 1 )
|
|
|
|
m_CopperLayerCount++;
|
2009-12-21 12:05:36 +00:00
|
|
|
}
|
|
|
|
}
|