2012-06-08 09:56:42 +00:00
|
|
|
/**
|
|
|
|
* @brief class ZONE_SETTINGS used to handle zones parameters
|
2008-10-23 10:26:06 +00:00
|
|
|
*/
|
|
|
|
|
2012-06-08 09:56:42 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-02-18 09:09:13 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2018-02-18 09:09:13 +00:00
|
|
|
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-06-08 09:56:42 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
2008-10-23 10:26:06 +00:00
|
|
|
|
2019-04-02 08:42:24 +00:00
|
|
|
#include <zone_settings.h>
|
|
|
|
|
2015-05-15 12:49:11 +00:00
|
|
|
#include <convert_to_biu.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
2018-05-25 14:56:04 +00:00
|
|
|
#include <pcb_base_frame.h>
|
|
|
|
#include <class_board.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/color_settings.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <zones.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_zone.h>
|
2018-05-25 14:56:04 +00:00
|
|
|
#include <wx/dataview.h>
|
|
|
|
#include <widgets/color_swatch.h>
|
2008-10-23 10:26:06 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
ZONE_SETTINGS::ZONE_SETTINGS()
|
2008-10-23 10:26:06 +00:00
|
|
|
{
|
2012-01-29 19:29:19 +00:00
|
|
|
m_ZonePriority = 0;
|
2019-12-20 14:11:39 +00:00
|
|
|
m_FillMode = ZONE_FILL_MODE::POLYGONS; // Mode for filling zone
|
2017-08-22 10:02:07 +00:00
|
|
|
// Zone clearance value
|
2019-12-20 14:11:39 +00:00
|
|
|
m_ZoneClearance = Mils2iu( ZONE_CLEARANCE_MIL );
|
2012-06-25 20:59:19 +00:00
|
|
|
// Min thickness value in filled areas (this is the minimum width of copper to fill solid areas) :
|
2019-12-20 14:11:39 +00:00
|
|
|
m_ZoneMinThickness = Mils2iu( ZONE_THICKNESS_MIL );
|
2020-08-07 14:04:34 +00:00
|
|
|
m_HatchThickness = 0; // good value of grid line thickness if m_FillMode = ZFM_GRID_PATTERN
|
|
|
|
m_HatchGap = 0; // good value of grid line gap if m_FillMode = ZFM_GRID_PATTERN
|
|
|
|
m_HatchOrientation = 0.0; // Grid style: orientation of grid lines in degrees
|
|
|
|
m_HatchSmoothingLevel = 0; // Grid pattern smoothing type. 0 = no smoothing
|
|
|
|
m_HatchSmoothingValue = 0.1; // Grid pattern chamfer value relative to the gap value
|
|
|
|
m_HatchHoleMinArea = 0.3; // Min size before holes are dropped (ratio of hole size)
|
|
|
|
m_HatchBorderAlgorithm = 1; // 0 = use zone min thickness; 1 = use hatch width
|
|
|
|
m_NetcodeSelection = 0; // Net code selection for the current zone
|
|
|
|
m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE; // Option to show the zone
|
|
|
|
// outlines only, short
|
|
|
|
// hatches or full hatches
|
2012-02-06 05:44:19 +00:00
|
|
|
|
2020-06-24 02:19:08 +00:00
|
|
|
m_Layers.reset().set( F_Cu );
|
2020-06-26 02:19:51 +00:00
|
|
|
m_Name = wxEmptyString;
|
2020-06-24 02:19:08 +00:00
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
// thickness of the gap in thermal reliefs:
|
2012-06-25 20:59:19 +00:00
|
|
|
m_ThermalReliefGap = Mils2iu( ZONE_THERMAL_RELIEF_GAP_MIL );
|
2013-03-20 14:50:12 +00:00
|
|
|
// thickness of the copper bridge in thermal reliefs:
|
2020-09-17 13:14:45 +00:00
|
|
|
m_ThermalReliefSpokeWidth = Mils2iu( ZONE_THERMAL_RELIEF_COPPER_WIDTH_MIL );
|
2008-10-23 10:26:06 +00:00
|
|
|
|
2020-09-17 13:14:45 +00:00
|
|
|
m_padConnection = ZONE_CONNECTION::THERMAL; // How pads are covered by copper in zone
|
2012-02-06 05:44:19 +00:00
|
|
|
|
|
|
|
m_Zone_45_Only = false;
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
m_cornerSmoothingType = SMOOTHING_NONE;
|
|
|
|
m_cornerRadius = 0;
|
|
|
|
|
2020-06-26 02:19:51 +00:00
|
|
|
m_removeIslands = ISLAND_REMOVAL_MODE::ALWAYS;
|
|
|
|
m_minIslandArea = 0;
|
2020-06-24 02:19:08 +00:00
|
|
|
|
2020-09-21 23:32:07 +00:00
|
|
|
SetIsRuleArea( false );
|
2012-07-14 16:27:25 +00:00
|
|
|
SetDoNotAllowCopperPour( false );
|
2012-07-13 18:55:29 +00:00
|
|
|
SetDoNotAllowVias( true );
|
|
|
|
SetDoNotAllowTracks( true );
|
2020-05-07 00:30:46 +00:00
|
|
|
SetDoNotAllowPads( true );
|
|
|
|
SetDoNotAllowFootprints( false );
|
2008-10-23 10:26:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
ZONE_SETTINGS& ZONE_SETTINGS::operator << ( const ZONE_CONTAINER& aSource )
|
2008-10-23 10:26:06 +00:00
|
|
|
{
|
2020-06-26 02:19:51 +00:00
|
|
|
m_ZonePriority = aSource.GetPriority();
|
|
|
|
m_FillMode = aSource.GetFillMode();
|
2020-09-05 16:00:29 +00:00
|
|
|
m_ZoneClearance = aSource.GetLocalClearance();
|
2020-06-26 02:19:51 +00:00
|
|
|
m_ZoneMinThickness = aSource.GetMinThickness();
|
2020-08-07 14:04:34 +00:00
|
|
|
m_HatchThickness = aSource.GetHatchThickness();
|
|
|
|
m_HatchGap = aSource.GetHatchGap();
|
|
|
|
m_HatchOrientation = aSource.GetHatchOrientation();
|
|
|
|
m_HatchSmoothingLevel = aSource.GetHatchSmoothingLevel();
|
|
|
|
m_HatchSmoothingValue = aSource.GetHatchSmoothingValue();
|
|
|
|
m_HatchBorderAlgorithm = aSource.GetHatchBorderAlgorithm();
|
|
|
|
m_HatchHoleMinArea = aSource.GetHatchHoleMinArea();
|
2020-06-26 02:19:51 +00:00
|
|
|
m_NetcodeSelection = aSource.GetNetCode();
|
|
|
|
m_Name = aSource.GetZoneName();
|
2020-09-17 13:14:45 +00:00
|
|
|
m_ZoneBorderDisplayStyle = aSource.GetHatchStyle();
|
2020-06-26 02:19:51 +00:00
|
|
|
m_ThermalReliefGap = aSource.GetThermalReliefGap();
|
2020-09-17 13:14:45 +00:00
|
|
|
m_ThermalReliefSpokeWidth = aSource.GetThermalReliefSpokeWidth();
|
|
|
|
m_padConnection = aSource.GetPadConnection();
|
2020-06-26 02:19:51 +00:00
|
|
|
m_cornerSmoothingType = aSource.GetCornerSmoothingType();
|
|
|
|
m_cornerRadius = aSource.GetCornerRadius();
|
2020-09-21 23:32:07 +00:00
|
|
|
m_isRuleArea = aSource.GetIsRuleArea();
|
2012-07-14 16:27:25 +00:00
|
|
|
m_keepoutDoNotAllowCopperPour = aSource.GetDoNotAllowCopperPour();
|
2020-06-26 02:19:51 +00:00
|
|
|
m_keepoutDoNotAllowVias = aSource.GetDoNotAllowVias();
|
|
|
|
m_keepoutDoNotAllowTracks = aSource.GetDoNotAllowTracks();
|
|
|
|
m_keepoutDoNotAllowPads = aSource.GetDoNotAllowPads();
|
2020-05-07 00:30:46 +00:00
|
|
|
m_keepoutDoNotAllowFootprints = aSource.GetDoNotAllowFootprints();
|
2020-06-26 02:19:51 +00:00
|
|
|
m_Zone_45_Only = aSource.GetHV45();
|
|
|
|
m_removeIslands = aSource.GetIslandRemovalMode();
|
|
|
|
m_minIslandArea = aSource.GetMinIslandArea();
|
2012-02-06 05:44:19 +00:00
|
|
|
|
2018-01-30 12:55:02 +00:00
|
|
|
m_Layers = aSource.GetLayerSet();
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
return *this;
|
2008-10-23 10:26:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
void ZONE_SETTINGS::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport ) const
|
2008-10-23 10:26:06 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
aTarget.SetFillMode( m_FillMode );
|
2020-09-05 16:00:29 +00:00
|
|
|
aTarget.SetLocalClearance( m_ZoneClearance );
|
2013-03-18 19:36:07 +00:00
|
|
|
aTarget.SetMinThickness( m_ZoneMinThickness );
|
2020-08-07 14:04:34 +00:00
|
|
|
aTarget.SetHatchThickness( m_HatchThickness );
|
|
|
|
aTarget.SetHatchGap( m_HatchGap );
|
|
|
|
aTarget.SetHatchOrientation( m_HatchOrientation );
|
|
|
|
aTarget.SetHatchSmoothingLevel( m_HatchSmoothingLevel );
|
|
|
|
aTarget.SetHatchSmoothingValue( m_HatchSmoothingValue );
|
|
|
|
aTarget.SetHatchBorderAlgorithm( m_HatchBorderAlgorithm );
|
|
|
|
aTarget.SetHatchHoleMinArea( m_HatchHoleMinArea );
|
2013-03-18 19:36:07 +00:00
|
|
|
aTarget.SetThermalReliefGap( m_ThermalReliefGap );
|
2020-09-17 13:14:45 +00:00
|
|
|
aTarget.SetThermalReliefSpokeWidth( m_ThermalReliefSpokeWidth );
|
|
|
|
aTarget.SetPadConnection( m_padConnection );
|
2012-07-13 18:55:29 +00:00
|
|
|
aTarget.SetCornerSmoothingType( m_cornerSmoothingType );
|
|
|
|
aTarget.SetCornerRadius( m_cornerRadius );
|
2020-09-21 23:32:07 +00:00
|
|
|
aTarget.SetIsRuleArea( GetIsRuleArea() );
|
2012-07-14 16:27:25 +00:00
|
|
|
aTarget.SetDoNotAllowCopperPour( GetDoNotAllowCopperPour() );
|
2012-07-13 18:55:29 +00:00
|
|
|
aTarget.SetDoNotAllowVias( GetDoNotAllowVias() );
|
|
|
|
aTarget.SetDoNotAllowTracks( GetDoNotAllowTracks() );
|
2020-05-07 00:30:46 +00:00
|
|
|
aTarget.SetDoNotAllowPads( GetDoNotAllowPads() );
|
|
|
|
aTarget.SetDoNotAllowFootprints( GetDoNotAllowFootprints() );
|
2018-02-20 14:51:40 +00:00
|
|
|
aTarget.SetHV45( m_Zone_45_Only );
|
2020-06-26 02:19:51 +00:00
|
|
|
aTarget.SetIslandRemovalMode( GetIslandRemovalMode() );
|
|
|
|
aTarget.SetMinIslandArea( GetMinIslandArea() );
|
2012-02-06 05:44:19 +00:00
|
|
|
|
2008-12-12 21:30:07 +00:00
|
|
|
if( aFullExport )
|
2008-12-03 10:32:53 +00:00
|
|
|
{
|
2012-01-29 19:29:19 +00:00
|
|
|
aTarget.SetPriority( m_ZonePriority );
|
2020-06-24 02:19:08 +00:00
|
|
|
aTarget.SetLayerSet( m_Layers );
|
2020-06-26 02:19:51 +00:00
|
|
|
aTarget.SetZoneName( m_Name );
|
2018-01-30 12:55:02 +00:00
|
|
|
|
2020-09-21 23:32:07 +00:00
|
|
|
if( !m_isRuleArea )
|
2019-10-29 10:09:54 +00:00
|
|
|
aTarget.SetNetCode( m_NetcodeSelection );
|
2008-12-03 10:32:53 +00:00
|
|
|
}
|
2012-07-30 07:40:25 +00:00
|
|
|
|
2020-08-07 14:04:34 +00:00
|
|
|
// call SetBorderDisplayStyle last, because hatch lines will be rebuilt,
|
2012-07-30 07:40:25 +00:00
|
|
|
// using new parameters values
|
2020-08-07 14:04:34 +00:00
|
|
|
aTarget.SetBorderDisplayStyle( m_ZoneBorderDisplayStyle, aTarget.GetDefaultHatchPitch(),
|
|
|
|
true );
|
2008-10-23 10:26:06 +00:00
|
|
|
}
|
2015-05-15 12:49:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
void ZONE_SETTINGS::SetCornerRadius( int aRadius )
|
|
|
|
{
|
2018-10-07 05:00:19 +00:00
|
|
|
if( aRadius < 0 )
|
2015-05-15 12:49:11 +00:00
|
|
|
m_cornerRadius = 0;
|
|
|
|
else
|
|
|
|
m_cornerRadius = aRadius;
|
2017-11-02 20:41:29 +00:00
|
|
|
}
|
2018-05-25 14:56:04 +00:00
|
|
|
|
|
|
|
|
2018-07-20 21:21:05 +00:00
|
|
|
#ifdef __WXOSX_MAC__
|
|
|
|
const static wxSize LAYER_BITMAP_SIZE( 28, 28 ); // wxCocoa impl unhappy if this isn't square...
|
|
|
|
#else
|
2018-07-22 10:17:35 +00:00
|
|
|
const static wxSize LAYER_BITMAP_SIZE( 24, 16 );
|
2018-07-20 21:21:05 +00:00
|
|
|
#endif
|
2018-05-25 14:56:04 +00:00
|
|
|
|
2020-08-17 12:55:56 +00:00
|
|
|
const static wxSize CHECKERBOARD_SIZE( 8, 8 );
|
|
|
|
|
2020-08-09 11:22:09 +00:00
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
// A helper for setting up a dialog list for specifying zone layers. Used by all three
|
|
|
|
// zone settings dialogs.
|
|
|
|
void ZONE_SETTINGS::SetupLayersList( wxDataViewListCtrl* aList, PCB_BASE_FRAME* aFrame,
|
2019-10-28 09:15:03 +00:00
|
|
|
bool aShowCopper, bool aFpEditorMode )
|
2018-05-25 14:56:04 +00:00
|
|
|
{
|
|
|
|
BOARD* board = aFrame->GetBoard();
|
2020-05-16 17:15:43 +00:00
|
|
|
COLOR4D backgroundColor = aFrame->GetColorSettings()->GetColor( LAYER_PCB_BACKGROUND );
|
2018-05-25 14:56:04 +00:00
|
|
|
LSET layers = aShowCopper ? LSET::AllCuMask( board->GetCopperLayerCount() )
|
|
|
|
: LSET::AllNonCuMask();
|
|
|
|
|
2020-08-09 11:22:09 +00:00
|
|
|
// In the Footprint Editor In1_Cu is used as a proxy for "all inner layers"
|
2020-08-08 23:23:11 +00:00
|
|
|
if( aFpEditorMode )
|
2020-08-09 11:22:09 +00:00
|
|
|
layers.set( In1_Cu );
|
2020-08-08 23:23:11 +00:00
|
|
|
|
2018-05-25 14:56:04 +00:00
|
|
|
wxDataViewColumn* checkColumn = aList->AppendToggleColumn( wxEmptyString );
|
|
|
|
wxDataViewColumn* layerColumn = aList->AppendIconTextColumn( wxEmptyString );
|
2018-07-19 09:09:53 +00:00
|
|
|
wxDataViewColumn* layerIDColumn = aList->AppendTextColumn( wxEmptyString );
|
2018-05-25 14:56:04 +00:00
|
|
|
layerIDColumn->SetHidden( true );
|
|
|
|
|
2018-07-21 22:17:46 +00:00
|
|
|
int textWidth = 0;
|
2018-05-25 14:56:04 +00:00
|
|
|
|
|
|
|
for( LSEQ layer = layers.UIOrder(); layer; ++layer )
|
|
|
|
{
|
|
|
|
PCB_LAYER_ID layerID = *layer;
|
2019-10-28 09:15:03 +00:00
|
|
|
wxString layerName = board->GetLayerName( layerID );
|
2020-08-08 23:23:11 +00:00
|
|
|
|
2019-10-28 09:15:03 +00:00
|
|
|
if( aFpEditorMode && layerID == In1_Cu )
|
|
|
|
layerName = _( "Inner layers" );
|
2018-05-25 14:56:04 +00:00
|
|
|
|
|
|
|
// wxCOL_WIDTH_AUTOSIZE doesn't work on all platforms, so we calculate width here
|
2020-10-25 16:41:38 +00:00
|
|
|
textWidth = std::max( textWidth, KIUI::GetTextSize( layerName, aList ).x );
|
2018-05-25 14:56:04 +00:00
|
|
|
|
2020-05-16 17:15:43 +00:00
|
|
|
COLOR4D layerColor = aFrame->GetColorSettings()->GetColor( layerID );
|
2020-08-17 12:55:56 +00:00
|
|
|
auto bitmap = COLOR_SWATCH::MakeBitmap( layerColor, backgroundColor, LAYER_BITMAP_SIZE,
|
2020-08-18 12:03:03 +00:00
|
|
|
CHECKERBOARD_SIZE, aList->GetBackgroundColour() );
|
2018-05-25 14:56:04 +00:00
|
|
|
wxIcon icon;
|
|
|
|
icon.CopyFromBitmap( bitmap );
|
|
|
|
|
|
|
|
wxVector<wxVariant> row;
|
|
|
|
row.push_back( wxVariant( m_Layers.test( layerID ) ) );
|
|
|
|
row.push_back( wxVariant( wxDataViewIconText( layerName, icon ) ) );
|
2018-07-19 09:09:53 +00:00
|
|
|
row.push_back( wxVariant( wxString::Format( "%i", layerID ) ) );
|
2018-05-25 14:56:04 +00:00
|
|
|
aList->AppendItem( row );
|
|
|
|
|
2020-06-24 02:19:08 +00:00
|
|
|
if( m_Layers.test( layerID ) )
|
2018-05-25 14:56:04 +00:00
|
|
|
aList->SetToggleValue( true, (unsigned) aList->GetItemCount() - 1, 0 );
|
|
|
|
}
|
|
|
|
|
2018-07-22 10:17:35 +00:00
|
|
|
int checkColSize = 22;
|
|
|
|
int layerColSize = textWidth + LAYER_BITMAP_SIZE.x + 15;
|
2018-05-25 14:56:04 +00:00
|
|
|
|
|
|
|
// You'd think the fact that m_layers is a list would encourage wxWidgets not to save room
|
|
|
|
// for the tree expanders... but you'd be wrong. Force indent to 0.
|
|
|
|
aList->SetIndent( 0 );
|
2018-07-22 10:17:35 +00:00
|
|
|
aList->SetMinClientSize( wxSize( checkColSize + layerColSize, aList->GetMinClientSize().y ) );
|
2018-07-21 22:17:46 +00:00
|
|
|
|
2018-07-22 10:17:35 +00:00
|
|
|
checkColumn->SetWidth( checkColSize );
|
|
|
|
layerColumn->SetWidth( layerColSize );
|
2018-05-25 14:56:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|