KiCad PCB EDA Suite
class_board_design_settings.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2009-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2015 KiCad Developers, see CHANGELOG.TXT for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef BOARD_DESIGN_SETTINGS_H_
26 #define BOARD_DESIGN_SETTINGS_H_
27 
28 #include <class_pad.h>
29 #include <class_track.h>
30 #include <class_netclass.h>
31 #include <config_params.h>
32 
33 // Some default values for the board editor and the fp editor (given in mm)
34 #define DEFAULT_TEXT_MODULE_SIZE 1.0
35 #define DEFAULT_GR_MODULE_THICKNESS 0.15 // given in mm
36 
37 // Board thickness, mainly for 3D view:
38 #define DEFAULT_BOARD_THICKNESS_MM 1.6
39 
40 // Default values for some board items (given in mm)
41 #define DEFAULT_TEXT_PCB_SIZE 1.5
42 #define DEFAULT_TEXT_PCB_THICKNESS 0.3
43 #define DEFAULT_PCB_EDGE_THICKNESS 0.15
44 #define DEFAULT_GRAPHIC_THICKNESS 0.2
45 
46 #define DEFAULT_SOLDERMASK_CLEARANCE 0.2
47 #define DEFAULT_SOLDERMASK_MIN_WIDTH Millimeter2iu( 0.0 )
48 
49 #define DEFAULT_CUSTOMTRACKWIDTH 0.2
50 #define DEFAULT_TRACKMINWIDTH 0.2 // track width min value
51 #define DEFAULT_VIASMINSIZE 0.4 // vias (not micro vias) min diameter
52 #define DEFAULT_VIASMINDRILL 0.3 // vias (not micro vias) min drill diameter
53 #define DEFAULT_MICROVIASMINSIZE 0.2 // micro vias (not vias) min diameter
54 #define DEFAULT_MICROVIASMINDRILL 0.1 // micro vias (not vias) min drill diameter
55 
62 {
63  int m_Diameter; // <= 0 means use Netclass via diameter
64  int m_Drill; // <= 0 means use Netclass via drill
65 
67  {
68  m_Diameter = 0;
69  m_Drill = 0;
70  }
71 
72  VIA_DIMENSION( int aDiameter, int aDrill )
73  {
74  m_Diameter = aDiameter;
75  m_Drill = aDrill;
76  }
77 
78  bool operator==( const VIA_DIMENSION& aOther ) const
79  {
80  return ( m_Diameter == aOther.m_Diameter ) && ( m_Drill == aOther.m_Drill );
81  }
82 
83  bool operator<( const VIA_DIMENSION& aOther ) const
84  {
85  if( m_Diameter != aOther.m_Diameter )
86  return m_Diameter < aOther.m_Diameter;
87 
88  return m_Drill < aOther.m_Drill;
89  }
90 };
91 
92 
98 {
99 public:
100  // The first value is the current netclass via size
102  std::vector<VIA_DIMENSION> m_ViasDimensionsList;
103 
104  // The first value is the current netclass track width
106  std::vector<int> m_TrackWidthList;
107 
110 
114 
120  wxSize m_PcbTextSize;
126 
127  // Global mask margins:
130  // 2 areas near than m_SolderMaskMinWidth
131  // are merged
134 
136  // Variables used in footprint edition (default value in item/footprint creation)
138  // Note: the default layer is the active layer
141 
142  wxString m_RefDefaultText;
143  // if empty, use footprint name as default
146  // should be a PCB_LAYER_ID, but use an int
147  // to save this param in config
148 
150  // if empty, use footprint name as default
153  // should be a PCB_LAYER_ID, but use an int
154  // to save this param in config
155 
156  // Miscellaneous
159 
161  // when importing values or create a new pad
162 
163 private:
166  unsigned m_viaSizeIndex;
167 
168  // Index for m_TrackWidthList to select the value.
171 
174 
177 
180 
182 
185 
188 
192 
193 public:
195 
200  inline NETCLASSPTR GetDefault() const
201  {
202  return m_NetClasses.GetDefault();
203  }
204 
209  inline const wxString& GetCurrentNetClassName() const
210  {
211  return m_currentNetClassName;
212  }
213 
218  inline bool UseNetClassTrack() const
219  {
220  return ( m_trackWidthIndex == 0 && !m_useCustomTrackVia );
221  }
222 
227  inline bool UseNetClassVia() const
228  {
229  return ( m_viaSizeIndex == 0 && !m_useCustomTrackVia );
230  }
231 
240  bool SetCurrentNetClass( const wxString& aNetClassName );
241 
247 
253 
260 
267 
272  inline unsigned GetTrackWidthIndex() const { return m_trackWidthIndex; }
273 
280  void SetTrackWidthIndex( unsigned aIndex );
281 
288  inline int GetCurrentTrackWidth() const
289  {
290  return m_useCustomTrackVia ? m_customTrackWidth : m_TrackWidthList[m_trackWidthIndex];
291  }
292 
300  inline void SetCustomTrackWidth( int aWidth )
301  {
302  m_customTrackWidth = aWidth;
303  }
304 
309  inline int GetCustomTrackWidth() const
310  {
311  return m_customTrackWidth;
312  }
313 
318  inline unsigned GetViaSizeIndex() const
319  {
320  return m_viaSizeIndex;
321  }
322 
329  void SetViaSizeIndex( unsigned aIndex );
330 
337  inline int GetCurrentViaSize() const
338  {
339  if( m_useCustomTrackVia )
340  return m_customViaSize.m_Diameter;
341  else
342  return m_ViasDimensionsList[m_viaSizeIndex].m_Diameter;
343  }
344 
352  inline void SetCustomViaSize( int aSize )
353  {
354  m_customViaSize.m_Diameter = aSize;
355  }
356 
361  inline int GetCustomViaSize() const
362  {
363  return m_customViaSize.m_Diameter;
364  }
365 
372  int GetCurrentViaDrill() const;
373 
381  inline void SetCustomViaDrill( int aDrill )
382  {
383  m_customViaSize.m_Drill = aDrill;
384  }
385 
390  inline int GetCustomViaDrill() const
391  {
392  return m_customViaSize.m_Drill;
393  }
394 
402  inline void UseCustomTrackViaSize( bool aEnabled )
403  {
404  m_useCustomTrackVia = aEnabled;
405  }
406 
411  inline bool UseCustomTrackViaSize() const
412  {
413  return m_useCustomTrackVia;
414  }
415 
421  inline LSET GetVisibleLayers() const
422  {
423  return m_visibleLayers;
424  }
425 
431  void SetVisibleAlls();
432 
438  inline void SetVisibleLayers( LSET aMask )
439  {
440  m_visibleLayers = aMask & m_enabledLayers;
441  }
442 
449  inline bool IsLayerVisible( PCB_LAYER_ID aLayerId ) const
450  {
451  // If a layer is disabled, it is automatically invisible
452  return (m_visibleLayers & m_enabledLayers)[aLayerId];
453  }
454 
461  void SetLayerVisibility( PCB_LAYER_ID aLayerId, bool aNewState );
462 
468  inline int GetVisibleElements() const
469  {
470  return m_visibleElements;
471  }
472 
478  inline void SetVisibleElements( int aMask )
479  {
480  m_visibleElements = aMask;
481  }
482 
491  inline bool IsElementVisible( GAL_LAYER_ID aElementCategory ) const
492  {
493  return ( m_visibleElements & ( 1 << GAL_LAYER_INDEX( aElementCategory ) ) );
494  }
495 
503  void SetElementVisibility( GAL_LAYER_ID aElementCategory, bool aNewState );
504 
510  inline LSET GetEnabledLayers() const
511  {
512  return m_enabledLayers;
513  }
514 
520  void SetEnabledLayers( LSET aMask );
521 
528  inline bool IsLayerEnabled( PCB_LAYER_ID aLayerId ) const
529  {
530  return m_enabledLayers[aLayerId];
531  }
532 
537  inline int GetCopperLayerCount() const
538  {
539  return m_copperLayerCount;
540  }
541 
547  void SetCopperLayerCount( int aNewLayerCount );
548 
555  void AppendConfigs( PARAM_CFG_ARRAY* aResult );
556 
557  inline int GetBoardThickness() const { return m_boardThickness; }
558  inline void SetBoardThickness( int aThickness ) { m_boardThickness = aThickness; }
559 
560 private:
561  void formatNetClass( NETCLASS* aNetClass, OUTPUTFORMATTER* aFormatter, int aNestLevel,
562  int aControlBits ) const;
563 };
564 
565 #endif // BOARD_DESIGN_SETTINGS_H_
int GetCurrentMicroViaSize()
Function GetCurrentMicroViaSize.
unsigned m_trackWidthIndex
0 is the index selection of the default value Netclass
wxString m_RefDefaultText
Default ref text on fp creation.
int m_SolderMaskMargin
Solder mask margin.
VIA_DIMENSION m_customViaSize
Custom via size (used after UseCustomTrackViaSize( true ) was called).
void SetCopperLayerCount(int aNewLayerCount)
Function SetCopperLayerCount do what its name says...
Struct VIA_DIMENSION is a small helper container to handle a stock of specific vias each with unique ...
void SetEnabledLayers(LSET aMask)
Function SetEnabledLayers changes the bit-mask of enabled layers.
A list of parameters type.
bool m_ValueDefaultVisibility
Default value text visibility on fp creation.
void SetTrackWidthIndex(unsigned aIndex)
Function SetTrackWidthIndex sets the current track width list index to aIndex.
VIATYPE_T m_CurrentViaType
via type (VIA_BLIND_BURIED, VIA_THROUGH VIA_MICROVIA)
int GetCurrentViaDrill() const
Function GetCurrentViaDrill.
int GetVisibleElements() const
Function GetVisibleElements returns a bit-mask of all the element categories that are visible...
wxString m_currentNetClassName
Current net class name used to display netclass info.
bool operator<(const VIA_DIMENSION &aOther) const
NETCLASSPTR GetDefault() const
Function GetDefault.
wxPoint m_GridOrigin
origin for grid offsets
int m_SolderPasteMargin
Solder paste margin absolute value.
int m_ModuleTextWidth
Default footprint texts thickness.
std::vector< int > m_TrackWidthList
Track width list.
int m_ModuleSegmentWidth
Default width for all graphic lines.
int GetSmallestClearanceValue()
Function GetSmallestClearanceValue.
int GetBiggestClearanceValue()
Function GetBiggestClearanceValue.
int GetCurrentMicroViaDrill()
Function GetCurrentMicroViaDrill.
int m_PcbTextWidth
current Pcb (not module) Text width
void SetCustomViaDrill(int aDrill)
Function SetCustomViaDrill Sets custom size for via drill (i.e.
void SetLayerVisibility(PCB_LAYER_ID aLayerId, bool aNewState)
Function SetLayerVisibility changes the visibility of a given layer.
bool IsLayerEnabled(PCB_LAYER_ID aLayerId) const
Function IsLayerEnabled tests whether a given layer is enabled.
bool m_useCustomTrackVia
Use custom values for track/via sizes (not specified in net class nor in the size lists)...
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
bool operator==(const VIA_DIMENSION &aOther) const
The common library.
Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a conve...
Definition: richio.h:327
int m_ValueDefaultlayer
Default value text layer on fp creation.
void SetVisibleAlls()
Function SetVisibleAlls Set the bit-mask of all visible elements categories, including enabled layers...
bool IsLayerVisible(PCB_LAYER_ID aLayerId) const
Function IsLayerVisible tests whether a given layer is visible.
wxSize m_ModuleTextSize
Default footprint texts size.
VIATYPE_T
Definition: class_track.h:51
void SetBoardThickness(int aThickness)
int GetCurrentViaSize() const
Function GetCurrentViaSize.
bool m_UseConnectedTrackWidth
if true, when creating a new track starting on an existing track, use this track width ...
void SetCustomViaSize(int aSize)
Function SetCustomViaSize Sets custom size for via diameter (i.e.
Functions relatives to tracks, vias and segments used to fill zones.
unsigned GetViaSizeIndex() const
Function GetViaSizeIndex.
void SetVisibleLayers(LSET aMask)
Function SetVisibleLayers changes the bit-mask of visible layers.
void formatNetClass(NETCLASS *aNetClass, OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
void SetViaSizeIndex(unsigned aIndex)
Function SetViaSizeIndex sets the current via size list index to aIndex.
PCB_LAYER_ID
A quick note on layer IDs:
Class LSET is a set of PCB_LAYER_IDs.
int GetCopperLayerCount() const
Function GetCopperLayerCount.
Class NETCLASSES is a container for NETCLASS instances.
const wxString & GetCurrentNetClassName() const
Function GetCurrentNetClassName.
#define GAL_LAYER_INDEX(x)
Use this macro to convert a GAL layer to a 0-indexed offset from LAYER_VIAS.
int GetCustomViaSize() const
Function GetCustomViaSize.
wxSize m_PcbTextSize
current Pcb (not module) Text size
int m_TrackMinWidth
track min value for width ((min copper size value
bool UseNetClassTrack() const
Function UseNetClassTrack returns true if netclass values should be used to obtain appropriate track ...
int m_ViasMinSize
vias (not micro vias) min diameter
Class NETCLASS handles a collection of nets and the parameters used to route or test these nets...
int m_DrawSegmentWidth
current graphic line width (not EDGE layer)
int m_ViasMinDrill
vias (not micro vias) min drill diameter
bool m_BlindBuriedViaAllowed
true to allow blind/buried vias
int GetCustomViaDrill() const
Function GetCustomViaDrill.
wxString m_ValueDefaultText
Default value text on fp creation.
int m_MicroViasMinSize
micro vias (not vias) min diameter
bool IsElementVisible(GAL_LAYER_ID aElementCategory) const
Function IsElementVisible tests whether a given element category is visible.
int GetCustomTrackWidth() const
Function GetCustomTrackWidth.
void SetCustomTrackWidth(int aWidth)
Function SetCustomTrackWidth Sets custom width for track (i.e.
Pad object description.
LSET m_visibleLayers
Bit-mask for layer visibility.
int m_visibleElements
Bit-mask for element category visibility.
bool SetCurrentNetClass(const wxString &aNetClassName)
Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter ...
unsigned m_viaSizeIndex
Index for m_ViasDimensionsList to select the current via size.
NETCLASSPTR GetDefault() const
Function GetDefault.
bool UseNetClassVia() const
Function UseNetClassVia returns true if netclass values should be used to obtain appropriate via size...
D_PAD m_Pad_Master
A dummy pad to store all default parameters.
void SetVisibleElements(int aMask)
Function SetVisibleElements changes the bit-mask of visible element categories.
int m_RefDefaultlayer
Default ref text layer on fp creation.
void SetElementVisibility(GAL_LAYER_ID aElementCategory, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
std::vector< VIA_DIMENSION > m_ViasDimensionsList
Vias size and drill list.
unsigned GetTrackWidthIndex() const
Function GetTrackWidthIndex.
VIA_DIMENSION(int aDiameter, int aDrill)
void AppendConfigs(PARAM_CFG_ARRAY *aResult)
Function AppendConfigs appends to aResult the configuration setting accessors which will later allow ...
int m_copperLayerCount
Number of copper layers for this design.
bool m_MicroViasAllowed
true to allow micro vias
LSET GetEnabledLayers() const
Function GetEnabledLayers returns a bit-mask of all the layers that are enabled.
bool UseCustomTrackViaSize() const
Function UseCustomTrackViaSize.
int m_MicroViasMinDrill
micro vias (not vias) min drill diameter
int m_EdgeSegmentWidth
current graphic line width (EDGE layer only)
double m_SolderPasteMarginRatio
Solder pask margin ratio value of pad size The final margin is the sum of these 2 values...
int GetCurrentTrackWidth() const
Function GetCurrentTrackWidth.
LSET GetVisibleLayers() const
Function GetVisibleLayers returns a bit-mask of all the layers that are visible.
LSET m_enabledLayers
Bit-mask for layer enabling.
bool m_RefDefaultVisibility
Default ref text visibility on fp creation.
wxPoint m_AuxOrigin
origin for plot exports
int m_boardThickness
Board thickness for 3D viewer.
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
NETCLASSES m_NetClasses
List of current netclasses. There is always the default netclass.
int m_SolderMaskMinWidth
Solder mask min width.
int m_customTrackWidth
Custom track width (used after UseCustomTrackViaSize( true ) was called).
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.