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) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
9  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
10  * Copyright (C) 1992-2012 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  // 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();
77  m_ZoneClearance = aSource.GetClearance();
79  m_NetcodeSelection = aSource.GetNetCode();
80  m_CurrentZone_Layer = aSource.GetLayer();
87  m_cornerRadius = aSource.GetCornerRadius();
88  m_isKeepout = aSource.GetIsKeepout();
92 
93  return *this;
94 }
95 
96 
97 void ZONE_SETTINGS::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport ) const
98 {
99  aTarget.SetFillMode( m_FillMode );
107  aTarget.SetCornerRadius( m_cornerRadius );
108  aTarget.SetIsKeepout( GetIsKeepout() );
112 
113  if( aFullExport )
114  {
115  aTarget.SetPriority( m_ZonePriority );
116  aTarget.SetNetCode( m_NetcodeSelection );
117  aTarget.SetLayer( m_CurrentZone_Layer );
118  }
119 
120  // call SetHatch last, because hatch lines will be rebuilt,
121  // using new parameters values
122  aTarget.SetHatch( m_Zone_HatchingStyle, aTarget.GetDefaultHatchPitch(), true );
123 }
124 
125 
127 {
128  if( aRadius > Mils2iu( MAX_ZONE_CORNER_RADIUS_MILS ) )
130  else if( aRadius < 0 )
131  m_cornerRadius = 0;
132  else
133  m_cornerRadius = aRadius;
134 };
void SetDoNotAllowTracks(bool aEnable)
Definition: class_zone.h:662
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:610
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
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
int GetMinThickness() const
Definition: class_zone.h:209
bool GetDoNotAllowCopperPour() const
Definition: class_zone.h:655
int GetArcSegmentCount() const
Definition: class_zone.h:198
void SetCornerRadius(unsigned int aRadius)
Definition: class_zone.cpp:476
#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
Classes to handle copper zones.
int GetCornerSmoothingType() const
Definition: class_zone.h:612
void SetArcSegmentCount(int aArcSegCount)
Definition: class_zone.h:197
void SetHatch(int aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Function SetHatch sets all hatch parameters for the zone.
Definition: class_zone.cpp:921
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_MIL
Definition: zones.h:39
int GetThermalReliefCopperBridge(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:467
unsigned int GetCornerRadius() const
Definition: class_zone.h:616
static int GetDefaultHatchPitch()
Function GetDefaultHatchPitchMils.
int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
Definition: class_zone.cpp:610
void SetDoNotAllowVias(bool aEnable)
Definition: class_zone.h:661
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:654
void SetDoNotAllowVias(bool aEnable)
int m_NetcodeSelection
Net code selection for the current zone.
ZoneConnection m_PadConnection
ZoneConnection GetPadConnection(D_PAD *aPad=NULL) const
Definition: class_zone.cpp:815
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:458
int m_ZonePriority
Priority (0 ... N) of the zone.
#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:204
#define ZONE_THICKNESS_MIL
Definition: zones.h:40
void SetThermalReliefCopperBridge(int aThermalReliefCopperBridge)
Definition: class_zone.h:191
Class ZONE_SETTINGS handles zones parameters.
int GetNetCode() const
Function GetNetCode.
void SetDoNotAllowCopperPour(bool aEnable)
Definition: class_zone.h:660
ZONE_SETTINGS()
class ZONE_SETTINGS used to handle zones parameters
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
bool GetDoNotAllowTracks() const
Definition: class_zone.h:657
int GetFillMode() const
Definition: class_zone.h:186
bool GetDoNotAllowVias() const
Definition: class_zone.h:656
bool m_keepoutDoNotAllowCopperPour
void SetCornerRadius(int aRadius)
HATCH_STYLE GetHatchStyle() const
Definition: class_zone.h:549
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:659
void SetPadConnection(ZoneConnection aPadConnection)
Definition: class_zone.h:207
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:185
unsigned int m_cornerRadius
Corner chamfer distance / fillet radius.
void SetMinThickness(int aMinThickness)
Definition: class_zone.h:210
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:188
PCB_LAYER_ID m_CurrentZone_Layer
Layer used to create the current zone.
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