You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

861 lines
28 KiB

14 years ago
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2009-2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.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. #ifndef BOARD_DESIGN_SETTINGS_H_
  25. #define BOARD_DESIGN_SETTINGS_H_
  26. #include <class_pad.h>
  27. #include <class_track.h>
  28. #include <netclass.h>
  29. #include <config_params.h>
  30. #include <board_stackup_manager/class_board_stackup.h>
  31. #define DEFAULT_SILK_LINE_WIDTH 0.12
  32. #define DEFAULT_COPPER_LINE_WIDTH 0.20
  33. #define DEFAULT_EDGE_WIDTH 0.05
  34. #define DEFAULT_COURTYARD_WIDTH 0.05
  35. #define DEFAULT_LINE_WIDTH 0.10
  36. #define DEFAULT_SILK_TEXT_SIZE 1.0
  37. #define DEFAULT_COPPER_TEXT_SIZE 1.5
  38. #define DEFAULT_TEXT_SIZE 1.0
  39. #define DEFAULT_SILK_TEXT_WIDTH 0.15
  40. #define DEFAULT_COPPER_TEXT_WIDTH 0.30
  41. #define DEFAULT_TEXT_WIDTH 0.15
  42. // Board thickness, mainly for 3D view:
  43. #define DEFAULT_BOARD_THICKNESS_MM 1.6
  44. #define DEFAULT_PCB_EDGE_THICKNESS 0.15
  45. #define DEFAULT_SOLDERMASK_CLEARANCE 0.051 // soldermask to pad clearance
  46. #define DEFAULT_SOLDERMASK_MIN_WIDTH 0.25 // soldermask minimum dam size
  47. #define DEFAULT_SOLDERPASTE_CLEARANCE 0.0
  48. #define DEFAULT_SOLDERPASTE_RATIO 0.0
  49. #define DEFAULT_CUSTOMTRACKWIDTH 0.2
  50. #define DEFAULT_CUSTOMDPAIRWIDTH 0.125
  51. #define DEFAULT_CUSTOMDPAIRGAP 0.18
  52. #define DEFAULT_CUSTOMDPAIRVIAGAP 0.18
  53. #define DEFAULT_TRACKMINWIDTH 0.2 // track width min value
  54. #define DEFAULT_VIASMINSIZE 0.4 // vias (not micro vias) min diameter
  55. #define DEFAULT_VIASMINDRILL 0.3 // vias (not micro vias) min drill diameter
  56. #define DEFAULT_MICROVIASMINSIZE 0.2 // micro vias (not vias) min diameter
  57. #define DEFAULT_MICROVIASMINDRILL 0.1 // micro vias (not vias) min drill diameter
  58. #define DEFAULT_HOLETOHOLEMIN 0.25 // separation between drilled hole edges
  59. #define DEFAULT_COPPEREDGECLEARANCE 0.01 // clearance between copper items and edge cuts
  60. #define LEGACY_COPPEREDGECLEARANCE -0.01 // A flag to indicate the legacy method (based
  61. // on edge cut line thicknesses) should be used.
  62. #define MINIMUM_ERROR_SIZE_MM 0.001
  63. #define MAXIMUM_ERROR_SIZE_MM 0.1
  64. /**
  65. * Struct VIA_DIMENSION
  66. * is a small helper container to handle a stock of specific vias each with
  67. * unique diameter and drill sizes in the BOARD class.
  68. */
  69. struct VIA_DIMENSION
  70. {
  71. int m_Diameter; // <= 0 means use Netclass via diameter
  72. int m_Drill; // <= 0 means use Netclass via drill
  73. VIA_DIMENSION()
  74. {
  75. m_Diameter = 0;
  76. m_Drill = 0;
  77. }
  78. VIA_DIMENSION( int aDiameter, int aDrill )
  79. {
  80. m_Diameter = aDiameter;
  81. m_Drill = aDrill;
  82. }
  83. bool operator==( const VIA_DIMENSION& aOther ) const
  84. {
  85. return ( m_Diameter == aOther.m_Diameter ) && ( m_Drill == aOther.m_Drill );
  86. }
  87. bool operator<( const VIA_DIMENSION& aOther ) const
  88. {
  89. if( m_Diameter != aOther.m_Diameter )
  90. return m_Diameter < aOther.m_Diameter;
  91. return m_Drill < aOther.m_Drill;
  92. }
  93. };
  94. /**
  95. * Struct DIFF_PAIR_DIMENSION
  96. * is a small helper container to handle a stock of specific differential pairs each with
  97. * unique track width, gap and via gap.
  98. */
  99. struct DIFF_PAIR_DIMENSION
  100. {
  101. int m_Width; // <= 0 means use Netclass differential pair width
  102. int m_Gap; // <= 0 means use Netclass differential pair gap
  103. int m_ViaGap; // <= 0 means use Netclass differential pair via gap
  104. DIFF_PAIR_DIMENSION()
  105. {
  106. m_Width = 0;
  107. m_Gap = 0;
  108. m_ViaGap = 0;
  109. }
  110. DIFF_PAIR_DIMENSION( int aWidth, int aGap, int aViaGap )
  111. {
  112. m_Width = aWidth;
  113. m_Gap = aGap;
  114. m_ViaGap = aViaGap;
  115. }
  116. bool operator==( const DIFF_PAIR_DIMENSION& aOther ) const
  117. {
  118. return ( m_Width == aOther.m_Width )
  119. && ( m_Gap == aOther.m_Gap )
  120. && ( m_ViaGap == aOther.m_ViaGap );
  121. }
  122. bool operator<( const DIFF_PAIR_DIMENSION& aOther ) const
  123. {
  124. if( m_Width != aOther.m_Width )
  125. return m_Width < aOther.m_Width;
  126. if( m_Gap != aOther.m_Gap )
  127. return m_Gap < aOther.m_Gap;
  128. return m_ViaGap < aOther.m_ViaGap;
  129. }
  130. };
  131. enum
  132. {
  133. LAYER_CLASS_SILK = 0,
  134. LAYER_CLASS_COPPER,
  135. LAYER_CLASS_EDGES,
  136. LAYER_CLASS_COURTYARD,
  137. LAYER_CLASS_OTHERS,
  138. LAYER_CLASS_COUNT
  139. };
  140. /**
  141. * Class BOARD_DESIGN_SETTINGS
  142. * contains design settings for a BOARD object.
  143. */
  144. class BOARD_DESIGN_SETTINGS
  145. {
  146. public:
  147. // Note: the first value in each dimensions list is the current netclass value
  148. std::vector<int> m_TrackWidthList;
  149. std::vector<VIA_DIMENSION> m_ViasDimensionsList;
  150. std::vector<DIFF_PAIR_DIMENSION> m_DiffPairDimensionsList;
  151. // List of netclasses. There is always the default netclass.
  152. NETCLASSES m_NetClasses;
  153. bool m_MicroViasAllowed; ///< true to allow micro vias
  154. bool m_BlindBuriedViaAllowed; ///< true to allow blind/buried vias
  155. VIATYPE_T m_CurrentViaType; ///< (VIA_BLIND_BURIED, VIA_THROUGH, VIA_MICROVIA)
  156. bool m_RequireCourtyards; ///< require courtyard definitions in footprints
  157. bool m_ProhibitOverlappingCourtyards; ///< check for overlapping courtyards in DRC
  158. // if true, when creating a new track starting on an existing track, use this track width
  159. bool m_UseConnectedTrackWidth;
  160. int m_TrackMinWidth; ///< track min value for width ((min copper size value
  161. int m_ViasMinSize; ///< vias (not micro vias) min diameter
  162. int m_ViasMinDrill; ///< vias (not micro vias) min drill diameter
  163. int m_MicroViasMinSize; ///< micro vias (not vias) min diameter
  164. int m_MicroViasMinDrill; ///< micro vias (not vias) min drill diameter
  165. int m_CopperEdgeClearance;
  166. /** Option to handle filled polygons in zones:
  167. * the "legacy" option is using thick outlines around filled polygons: give the best shape
  168. * the "new" option is using only filled polygons (no outline: give the faster redraw time
  169. * moreover when exporting zone filled areas, the excatct shape is exported.
  170. * the legacy option can really create redraw time issues for large boards.
  171. */
  172. bool m_ZoneUseNoOutlineInFill; ///< true for new zone filling option
  173. // Maximum error allowed when approximating circles and arcs to segments
  174. int m_MaxError;
  175. // Global mask margins:
  176. int m_SolderMaskMargin; ///< Solder mask margin
  177. int m_SolderMaskMinWidth; ///< Solder mask min width
  178. // 2 areas near than m_SolderMaskMinWidth
  179. // are merged
  180. int m_SolderPasteMargin; ///< Solder paste margin absolute value
  181. double m_SolderPasteMarginRatio; ///< Solder pask margin ratio value of pad size
  182. ///< The final margin is the sum of these 2 values
  183. int m_HoleToHoleMin; ///< Min width of peninsula between two drilled holes
  184. // Arrays of default values for the various layer classes.
  185. int m_LineThickness[ LAYER_CLASS_COUNT ];
  186. wxSize m_TextSize[ LAYER_CLASS_COUNT ];
  187. int m_TextThickness[ LAYER_CLASS_COUNT ];
  188. bool m_TextItalic[ LAYER_CLASS_COUNT ];
  189. bool m_TextUpright[ LAYER_CLASS_COUNT ];
  190. // Variables used in footprint editing (default value in item/footprint creation)
  191. wxString m_RefDefaultText; ///< Default ref text on fp creation
  192. // if empty, use footprint name as default
  193. bool m_RefDefaultVisibility; ///< Default ref text visibility on fp creation
  194. int m_RefDefaultlayer; ///< Default ref text layer on fp creation
  195. // should be a PCB_LAYER_ID, but use an int
  196. // to save this param in config
  197. wxString m_ValueDefaultText; ///< Default value text on fp creation
  198. // if empty, use footprint name as default
  199. bool m_ValueDefaultVisibility; ///< Default value text visibility on fp creation
  200. int m_ValueDefaultlayer; ///< Default value text layer on fp creation
  201. // should be a PCB_LAYER_ID, but use an int
  202. // to save this param in config
  203. // Miscellaneous
  204. wxPoint m_AuxOrigin; ///< origin for plot exports
  205. wxPoint m_GridOrigin; ///< origin for grid offsets
  206. D_PAD m_Pad_Master; ///< A dummy pad to store all default parameters
  207. // when importing values or create a new pad
  208. /** Set to true if the board has a stackup management.
  209. * if m_hasStackup is false, a default basic stackup witll be used to
  210. * generate the ;gbrjob file.
  211. * if m_hasStackup is true, the stackup defined for the board is used.
  212. * if not up to date, a error message will be set
  213. * Could be removed later, or at least always set to true
  214. */
  215. bool m_HasStackup;
  216. private:
  217. // Indicies into the trackWidth, viaSizes and diffPairDimensions lists.
  218. // The 0 index is always the current netclass value(s)
  219. unsigned m_trackWidthIndex;
  220. unsigned m_viaSizeIndex;
  221. unsigned m_diffPairIndex;
  222. // Custom values for track/via sizes (specified via dialog instead of netclass or lists)
  223. bool m_useCustomTrackVia;
  224. int m_customTrackWidth;
  225. VIA_DIMENSION m_customViaSize;
  226. // Custom values for differential pairs (specified via dialog instead of netclass/lists)
  227. bool m_useCustomDiffPair;
  228. DIFF_PAIR_DIMENSION m_customDiffPair;
  229. int m_copperLayerCount; ///< Number of copper layers for this design
  230. LSET m_enabledLayers; ///< Bit-mask for layer enabling
  231. LSET m_visibleLayers; ///< Bit-mask for layer visibility
  232. int m_visibleElements; ///< Bit-mask for element category visibility
  233. int m_boardThickness; ///< Board thickness for 3D viewer
  234. /// Current net class name used to display netclass info.
  235. /// This is also the last used netclass after starting a track.
  236. wxString m_currentNetClassName;
  237. /** the description of layers stackup, for board fabrication
  238. * only physical layers are in layers stackup.
  239. * It includes not only layers enabled for the board edition, but also dielectic layers
  240. */
  241. BOARD_STACKUP m_stackup;
  242. public:
  243. BOARD_DESIGN_SETTINGS();
  244. BOARD_STACKUP& GetStackupDescriptor() { return m_stackup; }
  245. /**
  246. * Function GetDefault
  247. * @return the default netclass.
  248. */
  249. inline NETCLASSPTR GetDefault() const
  250. {
  251. return m_NetClasses.GetDefault();
  252. }
  253. /**
  254. * Function GetCurrentNetClassName
  255. * @return the current net class name.
  256. */
  257. inline const wxString& GetCurrentNetClassName() const
  258. {
  259. return m_currentNetClassName;
  260. }
  261. /**
  262. * Function UseNetClassTrack
  263. * returns true if netclass values should be used to obtain appropriate track width.
  264. */
  265. inline bool UseNetClassTrack() const
  266. {
  267. return ( m_trackWidthIndex == 0 && !m_useCustomTrackVia );
  268. }
  269. /**
  270. * Function UseNetClassVia
  271. * returns true if netclass values should be used to obtain appropriate via size.
  272. */
  273. inline bool UseNetClassVia() const
  274. {
  275. return ( m_viaSizeIndex == 0 && !m_useCustomTrackVia );
  276. }
  277. /**
  278. * Function UseNetClassDiffPair
  279. * returns true if netclass values should be used to obtain appropriate diff pair dimensions.
  280. */
  281. inline bool UseNetClassDiffPair() const
  282. {
  283. return ( m_diffPairIndex == 0 && !m_useCustomDiffPair );
  284. }
  285. /**
  286. * Function SetCurrentNetClass
  287. * Must be called after a netclass selection (or after a netclass parameter change
  288. * Initialize vias and tracks values displayed in comb boxes of the auxiliary toolbar
  289. * and some others parameters (netclass name ....)
  290. * @param aNetClassName = the new netclass name
  291. * @return true if lists of tracks and vias sizes are modified
  292. */
  293. bool SetCurrentNetClass( const wxString& aNetClassName );
  294. /**
  295. * Function GetBiggestClearanceValue
  296. * @return the biggest clearance value found in NetClasses list
  297. */
  298. int GetBiggestClearanceValue();
  299. /**
  300. * Function GetSmallestClearanceValue
  301. * @return the smallest clearance value found in NetClasses list
  302. */
  303. int GetSmallestClearanceValue();
  304. /**
  305. * Function GetCurrentMicroViaSize
  306. * @return the current micro via size,
  307. * that is the current netclass value
  308. */
  309. int GetCurrentMicroViaSize();
  310. /**
  311. * Function GetCurrentMicroViaDrill
  312. * @return the current micro via drill,
  313. * that is the current netclass value
  314. */
  315. int GetCurrentMicroViaDrill();
  316. /**
  317. * Function GetTrackWidthIndex
  318. * @return the current track width list index.
  319. */
  320. inline unsigned GetTrackWidthIndex() const { return m_trackWidthIndex; }
  321. /**
  322. * Function SetTrackWidthIndex
  323. * sets the current track width list index to \a aIndex.
  324. *
  325. * @param aIndex is the track width list index.
  326. */
  327. void SetTrackWidthIndex( unsigned aIndex );
  328. /**
  329. * Function GetCurrentTrackWidth
  330. * @return the current track width, according to the selected options
  331. * ( using the default netclass value or a preset/custom value )
  332. * the default netclass is always in m_TrackWidthList[0]
  333. */
  334. inline int GetCurrentTrackWidth() const
  335. {
  336. return m_useCustomTrackVia ? m_customTrackWidth : m_TrackWidthList[m_trackWidthIndex];
  337. }
  338. /**
  339. * Function SetCustomTrackWidth
  340. * Sets custom width for track (i.e. not available in netclasses or preset list). To have
  341. * it returned with GetCurrentTrackWidth() you need to enable custom track & via sizes
  342. * (UseCustomTrackViaSize()).
  343. * @param aWidth is the new track width.
  344. */
  345. inline void SetCustomTrackWidth( int aWidth )
  346. {
  347. m_customTrackWidth = aWidth;
  348. }
  349. /**
  350. * Function GetCustomTrackWidth
  351. * @return Current custom width for a track.
  352. */
  353. inline int GetCustomTrackWidth() const
  354. {
  355. return m_customTrackWidth;
  356. }
  357. /**
  358. * Function GetViaSizeIndex
  359. * @return the current via size list index.
  360. */
  361. inline unsigned GetViaSizeIndex() const
  362. {
  363. return m_viaSizeIndex;
  364. }
  365. /**
  366. * Function SetViaSizeIndex
  367. * sets the current via size list index to \a aIndex.
  368. *
  369. * @param aIndex is the via size list index.
  370. */
  371. void SetViaSizeIndex( unsigned aIndex );
  372. /**
  373. * Function GetCurrentViaSize
  374. * @return the current via size, according to the selected options
  375. * ( using the default netclass value or a preset/custom value )
  376. * the default netclass is always in m_TrackWidthList[0]
  377. */
  378. inline int GetCurrentViaSize() const
  379. {
  380. if( m_useCustomTrackVia )
  381. return m_customViaSize.m_Diameter;
  382. else
  383. return m_ViasDimensionsList[m_viaSizeIndex].m_Diameter;
  384. }
  385. /**
  386. * Function SetCustomViaSize
  387. * Sets custom size for via diameter (i.e. not available in netclasses or preset list). To have
  388. * it returned with GetCurrentViaSize() you need to enable custom track & via sizes
  389. * (UseCustomTrackViaSize()).
  390. * @param aSize is the new drill diameter.
  391. */
  392. inline void SetCustomViaSize( int aSize )
  393. {
  394. m_customViaSize.m_Diameter = aSize;
  395. }
  396. /**
  397. * Function GetCustomViaSize
  398. * @return Current custom size for the via diameter.
  399. */
  400. inline int GetCustomViaSize() const
  401. {
  402. return m_customViaSize.m_Diameter;
  403. }
  404. /**
  405. * Function GetCurrentViaDrill
  406. * @return the current via size, according to the selected options
  407. * ( using the default netclass value or a preset/custom value )
  408. * the default netclass is always in m_TrackWidthList[0]
  409. */
  410. int GetCurrentViaDrill() const;
  411. /**
  412. * Function SetCustomViaDrill
  413. * Sets custom size for via drill (i.e. not available in netclasses or preset list). To have
  414. * it returned with GetCurrentViaDrill() you need to enable custom track & via sizes
  415. * (UseCustomTrackViaSize()).
  416. * @param aDrill is the new drill size.
  417. */
  418. inline void SetCustomViaDrill( int aDrill )
  419. {
  420. m_customViaSize.m_Drill = aDrill;
  421. }
  422. /**
  423. * Function GetCustomViaDrill
  424. * @return Current custom size for the via drill.
  425. */
  426. inline int GetCustomViaDrill() const
  427. {
  428. return m_customViaSize.m_Drill;
  429. }
  430. /**
  431. * Function UseCustomTrackViaSize
  432. * Enables/disables custom track/via size settings. If enabled, values set with
  433. * SetCustomTrackWidth()/SetCustomViaSize()/SetCustomViaDrill() are used for newly created
  434. * tracks and vias.
  435. * @param aEnabled decides if custom settings should be used for new tracks/vias.
  436. */
  437. inline void UseCustomTrackViaSize( bool aEnabled )
  438. {
  439. m_useCustomTrackVia = aEnabled;
  440. }
  441. /**
  442. * Function UseCustomTrackViaSize
  443. * @return True if custom sizes of tracks & vias are enabled, false otherwise.
  444. */
  445. inline bool UseCustomTrackViaSize() const
  446. {
  447. return m_useCustomTrackVia;
  448. }
  449. /**
  450. * Function GetDiffPairIndex
  451. * @return the current diff pair dimension list index.
  452. */
  453. inline unsigned GetDiffPairIndex() const { return m_diffPairIndex; }
  454. /**
  455. * Function SetDiffPairIndex
  456. * @param aIndex is the diff pair dimensions list index to set.
  457. */
  458. void SetDiffPairIndex( unsigned aIndex );
  459. /**
  460. * Function SetCustomDiffPairWidth
  461. * Sets custom track width for differential pairs (i.e. not available in netclasses or
  462. * preset list).
  463. * @param aDrill is the new track wdith.
  464. */
  465. inline void SetCustomDiffPairWidth( int aWidth )
  466. {
  467. m_customDiffPair.m_Width = aWidth;
  468. }
  469. /**
  470. * Function GetCustomDiffPairWidth
  471. * @return Current custom track width for differential pairs.
  472. */
  473. inline int GetCustomDiffPairWidth()
  474. {
  475. return m_customDiffPair.m_Width;
  476. }
  477. /**
  478. * Function SetCustomDiffPairGap
  479. * Sets custom gap for differential pairs (i.e. not available in netclasses or preset
  480. * list).
  481. * @param aGap is the new gap.
  482. */
  483. inline void SetCustomDiffPairGap( int aGap )
  484. {
  485. m_customDiffPair.m_Gap = aGap;
  486. }
  487. /**
  488. * Function GetCustomDiffPairGap
  489. * @return Current custom gap width for differential pairs.
  490. */
  491. inline int GetCustomDiffPairGap()
  492. {
  493. return m_customDiffPair.m_Gap;
  494. }
  495. /**
  496. * Function SetCustomDiffPairViaGap
  497. * Sets custom via gap for differential pairs (i.e. not available in netclasses or
  498. * preset list).
  499. * @param aGap is the new gap. Specify 0 to use the DiffPairGap for vias as well.
  500. */
  501. inline void SetCustomDiffPairViaGap( int aGap )
  502. {
  503. m_customDiffPair.m_ViaGap = aGap;
  504. }
  505. /**
  506. * Function GetCustomDiffPairViaGap
  507. * @return Current custom via gap width for differential pairs.
  508. */
  509. inline int GetCustomDiffPairViaGap()
  510. {
  511. return m_customDiffPair.m_ViaGap > 0 ? m_customDiffPair.m_ViaGap : m_customDiffPair.m_Gap;
  512. }
  513. /**
  514. * Function UseCustomDiffPairDimensions
  515. * Enables/disables custom differential pair dimensions.
  516. * @param aEnabled decides if custom settings should be used for new differential pairs.
  517. */
  518. inline void UseCustomDiffPairDimensions( bool aEnabled )
  519. {
  520. m_useCustomDiffPair = aEnabled;
  521. }
  522. /**
  523. * Function UseCustomDiffPairDimensions
  524. * @return True if custom sizes of diff pairs are enabled, false otherwise.
  525. */
  526. inline bool UseCustomDiffPairDimensions() const
  527. {
  528. return m_useCustomDiffPair;
  529. }
  530. /**
  531. * Function GetCurrentDiffPairWidth
  532. * @return the current diff pair track width, according to the selected options
  533. * ( using the default netclass value or a preset/custom value )
  534. * the default netclass is always in m_DiffPairDimensionsList[0]
  535. */
  536. inline int GetCurrentDiffPairWidth() const
  537. {
  538. if( m_useCustomDiffPair )
  539. return m_customDiffPair.m_Width;
  540. else
  541. return m_DiffPairDimensionsList[m_diffPairIndex].m_Width;
  542. }
  543. /**
  544. * Function GetCurrentDiffPairGap
  545. * @return the current diff pair gap, according to the selected options
  546. * ( using the default netclass value or a preset/custom value )
  547. * the default netclass is always in m_DiffPairDimensionsList[0]
  548. */
  549. inline int GetCurrentDiffPairGap() const
  550. {
  551. if( m_useCustomDiffPair )
  552. return m_customDiffPair.m_Gap;
  553. else
  554. return m_DiffPairDimensionsList[m_diffPairIndex].m_Gap;
  555. }
  556. /**
  557. * Function GetCurrentDiffPairViaGap
  558. * @return the current diff pair via gap, according to the selected options
  559. * ( using the default netclass value or a preset/custom value )
  560. * the default netclass is always in m_DiffPairDimensionsList[0]
  561. */
  562. inline int GetCurrentDiffPairViaGap() const
  563. {
  564. if( m_useCustomDiffPair )
  565. return m_customDiffPair.m_ViaGap;
  566. else
  567. return m_DiffPairDimensionsList[m_diffPairIndex].m_ViaGap;
  568. }
  569. /**
  570. * Function SetMinHoleSeparation
  571. * @param aValue The minimum distance between the edges of two holes or 0 to disable
  572. * hole-to-hole separation checking.
  573. */
  574. void SetMinHoleSeparation( int aDistance );
  575. /**
  576. * Function SetCopperEdgeClearance
  577. * @param aValue The minimum distance between copper items and board edges.
  578. */
  579. void SetCopperEdgeClearance( int aDistance );
  580. /**
  581. * Function SetRequireCourtyardDefinitions
  582. * @param aRequire Set to true to generate DRC violations from missing courtyards.
  583. */
  584. void SetRequireCourtyardDefinitions( bool aRequire );
  585. /**
  586. * Function SetProhibitOverlappingCourtyards
  587. * @param aProhibit Set to true to generate DRC violations from overlapping courtyards.
  588. */
  589. void SetProhibitOverlappingCourtyards( bool aProhibit );
  590. /**
  591. * Function GetVisibleLayers
  592. * returns a bit-mask of all the layers that are visible
  593. * @return int - the visible layers in bit-mapped form.
  594. */
  595. inline LSET GetVisibleLayers() const
  596. {
  597. return m_visibleLayers;
  598. }
  599. /**
  600. * Function SetVisibleAlls
  601. * Set the bit-mask of all visible elements categories,
  602. * including enabled layers
  603. */
  604. void SetVisibleAlls();
  605. /**
  606. * Function SetVisibleLayers
  607. * changes the bit-mask of visible layers
  608. * @param aMask = The new bit-mask of visible layers
  609. */
  610. inline void SetVisibleLayers( LSET aMask )
  611. {
  612. m_visibleLayers = aMask & m_enabledLayers;
  613. }
  614. /**
  615. * Function IsLayerVisible
  616. * tests whether a given layer is visible
  617. * @param aLayerId = The layer to be tested
  618. * @return bool - true if the layer is visible.
  619. */
  620. inline bool IsLayerVisible( PCB_LAYER_ID aLayerId ) const
  621. {
  622. // If a layer is disabled, it is automatically invisible
  623. return (m_visibleLayers & m_enabledLayers)[aLayerId];
  624. }
  625. /**
  626. * Function SetLayerVisibility
  627. * changes the visibility of a given layer
  628. * @param aLayerId = The layer to be changed
  629. * @param aNewState = The new visibility state of the layer
  630. */
  631. void SetLayerVisibility( PCB_LAYER_ID aLayerId, bool aNewState );
  632. /**
  633. * Function GetVisibleElements
  634. * returns a bit-mask of all the element categories that are visible
  635. * @return int - the visible element categories in bit-mapped form.
  636. */
  637. inline int GetVisibleElements() const
  638. {
  639. return m_visibleElements;
  640. }
  641. /**
  642. * Function SetVisibleElements
  643. * changes the bit-mask of visible element categories
  644. * @param aMask = The new bit-mask of visible element categories
  645. */
  646. inline void SetVisibleElements( int aMask )
  647. {
  648. m_visibleElements = aMask;
  649. }
  650. /**
  651. * Function IsElementVisible
  652. * tests whether a given element category is visible. Keep this as an
  653. * inline function.
  654. * @param aElementCategory is from the enum by the same name
  655. * @return bool - true if the element is visible.
  656. * @see enum GAL_LAYER_ID
  657. */
  658. inline bool IsElementVisible( GAL_LAYER_ID aElementCategory ) const
  659. {
  660. return ( m_visibleElements & ( 1 << GAL_LAYER_INDEX( aElementCategory ) ) );
  661. }
  662. /**
  663. * Function SetElementVisibility
  664. * changes the visibility of an element category
  665. * @param aElementCategory is from the enum by the same name
  666. * @param aNewState = The new visibility state of the element category
  667. * @see enum GAL_LAYER_ID
  668. */
  669. void SetElementVisibility( GAL_LAYER_ID aElementCategory, bool aNewState );
  670. /**
  671. * Function GetEnabledLayers
  672. * returns a bit-mask of all the layers that are enabled
  673. * @return int - the enabled layers in bit-mapped form.
  674. */
  675. inline LSET GetEnabledLayers() const
  676. {
  677. return m_enabledLayers;
  678. }
  679. /**
  680. * Function SetEnabledLayers
  681. * changes the bit-mask of enabled layers
  682. * @param aMask = The new bit-mask of enabled layers
  683. */
  684. void SetEnabledLayers( LSET aMask );
  685. /**
  686. * Function IsLayerEnabled
  687. * tests whether a given layer is enabled
  688. * @param aLayerId = The layer to be tested
  689. * @return bool - true if the layer is enabled
  690. */
  691. inline bool IsLayerEnabled( PCB_LAYER_ID aLayerId ) const
  692. {
  693. return m_enabledLayers[aLayerId];
  694. }
  695. /**
  696. * Function GetCopperLayerCount
  697. * @return int - the number of neabled copper layers
  698. */
  699. inline int GetCopperLayerCount() const
  700. {
  701. return m_copperLayerCount;
  702. }
  703. /**
  704. * Function SetCopperLayerCount
  705. * do what its name says...
  706. * @param aNewLayerCount = The new number of enabled copper layers
  707. */
  708. void SetCopperLayerCount( int aNewLayerCount );
  709. /**
  710. * Function AppendConfigs
  711. * appends to @a aResult the configuration setting accessors which will later
  712. * allow reading or writing of configuration file information directly into
  713. * this object.
  714. */
  715. void AppendConfigs( BOARD* aBoard, PARAM_CFG_ARRAY* aResult );
  716. inline int GetBoardThickness() const { return m_boardThickness; }
  717. inline void SetBoardThickness( int aThickness ) { m_boardThickness = aThickness; }
  718. /**
  719. * Function GetLineThickness
  720. * Returns the default graphic segment thickness from the layer class for the given layer.
  721. */
  722. int GetLineThickness( PCB_LAYER_ID aLayer ) const;
  723. /**
  724. * Function GetTextSize
  725. * Returns the default text size from the layer class for the given layer.
  726. */
  727. wxSize GetTextSize( PCB_LAYER_ID aLayer ) const;
  728. /**
  729. * Function GetTextThickness
  730. * Returns the default text thickness from the layer class for the given layer.
  731. */
  732. int GetTextThickness( PCB_LAYER_ID aLayer ) const;
  733. bool GetTextItalic( PCB_LAYER_ID aLayer ) const;
  734. bool GetTextUpright( PCB_LAYER_ID aLayer ) const;
  735. int GetLayerClass( PCB_LAYER_ID aLayer ) const;
  736. private:
  737. void formatNetClass( NETCLASS* aNetClass, OUTPUTFORMATTER* aFormatter, int aNestLevel,
  738. int aControlBits ) const;
  739. };
  740. #endif // BOARD_DESIGN_SETTINGS_H_