KiCad PCB EDA Suite
class_zone_settings.cpp
Go to the documentation of this file.
1 
5 /*
6  * This program source code file is part of KiCad, a free EDA CAD application.
7  *
8  * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
9  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
10  * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, you may find one here:
24  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
25  * or you may search the http://www.gnu.org website for the version 2 license,
26  * or you may write to the Free Software Foundation, Inc.,
27  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
28  */
29 
30 #include <fctsys.h>
31 
32 #include <convert_to_biu.h>
33 #include <pcbnew.h>
34 #include <zones.h>
35 
36 #include <class_zone.h>
37 
39 {
40  m_ZonePriority = 0;
41  m_FillMode = 0; // Mode for filling zone : 1 use segments, 0 use polygons
42  // Zone clearance value
44  // Min thickness value in filled areas (this is the minimum width of copper to fill solid areas) :
46  m_NetcodeSelection = 0; // Net code selection for the current zone
47  m_CurrentZone_Layer = F_Cu; // Layer used to create the current zone
48  m_Zone_HatchingStyle = ZONE_CONTAINER::DIAGONAL_EDGE; // Option to show the zone area (outlines only, short hatches or full hatches
49 
50  m_ArcToSegmentsCount = ARC_APPROX_SEGMENTS_COUNT_LOW_DEF; // Option to select number of segments to approximate a circle
51  // ARC_APPROX_SEGMENTS_COUNT_LOW_DEF
52  // or ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF segments
53 
54  // thickness of the gap in thermal reliefs:
56  // thickness of the copper bridge in thermal reliefs:
58 
59  m_PadConnection = PAD_ZONE_CONN_THERMAL; // How pads are covered by copper in zone
60 
61  m_Zone_45_Only = false;
62 
64  m_cornerRadius = 0;
65 
66  SetIsKeepout( false );
67  SetDoNotAllowCopperPour( false );
68  SetDoNotAllowVias( true );
69  SetDoNotAllowTracks( true );
70 }
71 
72 
74 {
75  m_ZonePriority = aSource.GetPriority();
76  m_FillMode = aSource.GetFillMode();
79  m_NetcodeSelection = aSource.GetNetCode();
86  m_cornerRadius = aSource.GetCornerRadius();
87  m_isKeepout = aSource.GetIsKeepout();
91 
92  m_CurrentZone_Layer = aSource.GetLayer();
93  m_Layers = aSource.GetLayerSet();
94 
95  return *this;
96 }
97 
98 
99 void ZONE_SETTINGS::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport ) const
100 {
101  aTarget.SetFillMode( m_FillMode );
109  aTarget.SetCornerRadius( m_cornerRadius );
110  aTarget.SetIsKeepout( GetIsKeepout() );
114 
115  if( aFullExport )
116  {
117  aTarget.SetPriority( m_ZonePriority );
118  aTarget.SetNetCode( m_NetcodeSelection );
119 
120  // Keepout zones can have multiple layers
121  if( m_isKeepout )
122  {
123  aTarget.SetLayerSet( m_Layers );
124  }
125  else
126  {
127  aTarget.SetLayer( m_CurrentZone_Layer );
128  }
129  }
130 
131  // call SetHatch last, because hatch lines will be rebuilt,
132  // using new parameters values
133  aTarget.SetHatch( m_Zone_HatchingStyle, aTarget.GetDefaultHatchPitch(), true );
134 }
135 
136 
138 {
139  if( aRadius > Mils2iu( MAX_ZONE_CORNER_RADIUS_MILS ) )
141  else if( aRadius < 0 )
142  m_cornerRadius = 0;
143  else
144  m_cornerRadius = aRadius;
145 }
void SetDoNotAllowTracks(bool aEnable)
Definition: class_zone.h:680
int m_Zone_HatchingStyle
Option to show the zone area (outlines only, short hatches or full hatches.
void SetCornerSmoothingType(int aType)
Definition: class_zone.h:628
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
int m_ArcToSegmentsCount
Option to select number of segments to approximate a circle 16 or 32 segments.
const bool GetDoNotAllowTracks() const
int GetMinThickness() const
Definition: class_zone.h:224
bool GetDoNotAllowCopperPour() const
Definition: class_zone.h:673
int GetArcSegmentCount() const
Definition: class_zone.h:213
void SetCornerRadius(unsigned int aRadius)
Definition: class_zone.cpp:653
#define ARC_APPROX_SEGMENTS_COUNT_LOW_DEF
Definition: pcbnew.h:41
long m_ThermalReliefCopperBridge
thickness of the copper bridge in thermal reliefs
const bool GetDoNotAllowCopperPour() const
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:182
Classes to handle copper zones.
int GetCornerSmoothingType() const
Definition: class_zone.h:630
void SetArcSegmentCount(int aArcSegCount)
Definition: class_zone.h:212
void SetHatch(int aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Function SetHatch sets all hatch parameters for the zone.
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_MIL
Definition: zones.h:39
int GetThermalReliefCopperBridge(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:644
unsigned int GetCornerRadius() const
Definition: class_zone.h:634
static int GetDefaultHatchPitch()
Function GetDefaultHatchPitchMils.
void SetDoNotAllowVias(bool aEnable)
Definition: class_zone.h:679
void ExportSetting(ZONE_CONTAINER &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
void SetPriority(unsigned aPriority)
Function SetPriority.
Definition: class_zone.h:113
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:672
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_zone.cpp:237
void SetDoNotAllowVias(bool aEnable)
int m_NetcodeSelection
Net code selection for the current zone.
ZoneConnection m_PadConnection
void SetLayerSet(LSET aLayerSet)
Definition: class_zone.cpp:217
ZoneConnection GetPadConnection(D_PAD *aPad=NULL) const
int m_cornerSmoothingType
Corner smoothing type.
const bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
int GetThermalReliefGap(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:635
int m_ZonePriority
Priority (0 ... N) of the zone.
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
Definition: class_zone.cpp:209
#define ZONE_CLEARANCE_MIL
Definition: zones.h:42
int m_ZoneClearance
Clearance value.
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
void SetIsKeepout(bool aEnable)
void SetDoNotAllowTracks(bool aEnable)
void SetZoneClearance(int aZoneClearance)
Definition: class_zone.h:219
#define ZONE_THICKNESS_MIL
Definition: zones.h:40
void SetThermalReliefCopperBridge(int aThermalReliefCopperBridge)
Definition: class_zone.h:206
Class ZONE_SETTINGS handles zones parameters.
int GetNetCode() const
Function GetNetCode.
void SetDoNotAllowCopperPour(bool aEnable)
Definition: class_zone.h:678
ZONE_SETTINGS()
class ZONE_SETTINGS used to handle zones parameters
bool GetDoNotAllowTracks() const
Definition: class_zone.h:675
int GetFillMode() const
Definition: class_zone.h:201
bool GetDoNotAllowVias() const
Definition: class_zone.h:674
bool m_keepoutDoNotAllowCopperPour
void SetCornerRadius(int aRadius)
HATCH_STYLE GetHatchStyle() const
Definition: class_zone.h:564
int m_FillMode
Mode for filling zone : 1 use segments, 0 use polygons.
const bool GetDoNotAllowVias() const
void SetDoNotAllowCopperPour(bool aEnable)
#define ZONE_THERMAL_RELIEF_GAP_MIL
Definition: zones.h:38
void SetIsKeepout(bool aEnable)
Definition: class_zone.h:677
void SetPadConnection(ZoneConnection aPadConnection)
Definition: class_zone.h:222
unsigned GetPriority() const
Function GetPriority.
Definition: class_zone.h:119
void SetFillMode(int aFillMode)
How to fill areas: 0 = use filled polygons, 1 => fill with segments.
Definition: class_zone.h:200
unsigned int m_cornerRadius
Corner chamfer distance / fillet radius.
void SetMinThickness(int aMinThickness)
Definition: class_zone.h:225
ZONE_SETTINGS & operator<<(const ZONE_CONTAINER &aSource)
operator << ( const ZONE_CONTAINER& ) was Function ImportSetting copies settings from a given zone in...
Use thermal relief for pads.
Definition: zones.h:58
void SetThermalReliefGap(int aThermalReliefGap)
Definition: class_zone.h:203
PCB_LAYER_ID m_CurrentZone_Layer
Layer used to create the current zone.
int GetZoneClearance() const
Definition: class_zone.h:218
long m_ThermalReliefGap
thickness of the gap in thermal reliefs
int m_ZoneMinThickness
Min thickness value in filled areas.
#define MAX_ZONE_CORNER_RADIUS_MILS