kicad/pcbnew/class_board_design_settings...

146 lines
4.6 KiB
C++
Raw Normal View History

/**
* @file class_board_design_settings.cpp
* BOARD_DESIGN_SETTINGS class functions.
*/
2009-10-28 11:48:47 +00:00
#include "fctsys.h"
#include "common.h"
#include "layers_id_colors_and_visibility.h"
2009-10-28 11:48:47 +00:00
#include "pcbnew.h"
#include "class_board_design_settings.h"
#include "class_track.h"
2009-10-28 11:48:47 +00:00
BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS()
2009-10-28 11:48:47 +00:00
{
m_EnabledLayers = ALL_LAYERS; // All layers enabled at first.
// SetCopperLayerCount() will adjust this.
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
SetVisibleAlls(); // All layers and all elements visible at first.
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
m_DrawSegmentWidth = 100; // current graphic line width (not EDGE layer)
m_EdgeSegmentWidth = 100; // current graphic line width (EDGE layer only)
m_PcbTextWidth = 100; // current Pcb (not module) Text width
m_PcbTextSize = wxSize( 500, 500 ); // current Pcb (not module) Text size
m_TrackMinWidth = 80; // track min value for width ((min copper size value
m_ViasMinSize = 350; // vias (not micro vias) min diameter
m_ViasMinDrill = 200; // vias (not micro vias) min drill diameter
m_MicroViasMinSize = 200; // micro vias (not vias) min diameter
m_MicroViasMinDrill = 50; // micro vias (not vias) min drill diameter
2009-12-07 06:16:11 +00:00
// Global mask margins:
m_SolderMaskMargin = 150; // Solder mask margin
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
// Layer thickness for 3D viewer
m_BoardThickness = (int)(1.6 * PCB_INTERNAL_UNIT / 25.4);
2009-10-28 11:48:47 +00:00
}
// see pcbstruct.h
int BOARD_DESIGN_SETTINGS::GetVisibleLayers() const
2009-10-28 11:48:47 +00:00
{
return m_VisibleLayers;
}
/**
* Function SetVisibleAlls
* Set the bit-mask of all visible elements categories,
* including enabled layers
*/
void BOARD_DESIGN_SETTINGS::SetVisibleAlls()
{
SetVisibleLayers( FULL_LAYERS );
m_VisibleElements = 0xFFFFFFFF;
}
void BOARD_DESIGN_SETTINGS::SetVisibleLayers( int aMask )
2009-10-28 11:48:47 +00:00
{
// Although Pcbnew uses only 29, GerbView uses all 32 layers
m_VisibleLayers = aMask & m_EnabledLayers & FULL_LAYERS;
2009-10-28 11:48:47 +00:00
}
void BOARD_DESIGN_SETTINGS::SetLayerVisibility( int aLayerIndex, bool aNewState )
2009-10-28 11:48:47 +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;
if( aNewState && IsLayerEnabled( aLayerIndex ) )
2009-10-28 11:48:47 +00:00
m_VisibleLayers |= 1 << aLayerIndex;
else
m_VisibleLayers &= ~( 1 << aLayerIndex );
}
void BOARD_DESIGN_SETTINGS::SetElementVisibility( int aElementCategory, bool aNewState )
2009-10-28 11:48:47 +00:00
{
if( aElementCategory < 0 || aElementCategory >= END_PCB_VISIBLE_LIST )
2009-10-28 11:48:47 +00:00
return;
2009-10-28 11:48:47 +00:00
if( aNewState )
m_VisibleElements |= 1 << aElementCategory;
else
m_VisibleElements &= ~( 1 << aElementCategory );
}
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-10-28 11:48:47 +00:00
// ensure consistency with the m_EnabledLayers member
m_EnabledLayers &= ~ALL_CU_LAYERS;
m_EnabledLayers |= LAYER_BACK;
if( m_CopperLayerCount > 1 )
m_EnabledLayers |= LAYER_FRONT;
for( int ii = 1; ii < aNewLayerCount - 1; ii++ )
2009-10-28 11:48:47 +00:00
m_EnabledLayers |= 1 << ii;
}
/**
* Function SetEnabledLayers
* changes the bit-mask of enabled layers
* @param aMask = The new bit-mask of enabled layers
*/
void BOARD_DESIGN_SETTINGS::SetEnabledLayers( int aMask )
{
2010-01-21 07:41:30 +00:00
// Back and front layers are always enabled.
aMask |= LAYER_BACK | LAYER_FRONT;
m_EnabledLayers = aMask;
2010-01-21 07:41:30 +00:00
// A disabled layer cannot be visible
m_VisibleLayers &= aMask;
2010-01-21 07:41:30 +00:00
// update m_CopperLayerCount to ensure its consistency with m_EnabledLayers
m_CopperLayerCount = 0;
2010-01-21 07:41:30 +00:00
for( int ii = 0; aMask && ii < NB_COPPER_LAYERS; ii++, aMask >>= 1 )
{
2010-01-21 07:41:30 +00:00
if( aMask & 1 )
m_CopperLayerCount++;
}
}