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.

864 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
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. * 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 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. int m_DimensionUnits;
  191. int m_DimensionPrecision;
  192. // Variables used in footprint editing (default value in item/footprint creation)
  193. wxString m_RefDefaultText; ///< Default ref text on fp creation
  194. // if empty, use footprint name as default
  195. bool m_RefDefaultVisibility; ///< Default ref text visibility on fp creation
  196. int m_RefDefaultlayer; ///< Default ref text layer on fp creation
  197. // should be a PCB_LAYER_ID, but use an int
  198. // to save this param in config
  199. wxString m_ValueDefaultText; ///< Default value text on fp creation
  200. // if empty, use footprint name as default
  201. bool m_ValueDefaultVisibility; ///< Default value text visibility on fp creation
  202. int m_ValueDefaultlayer; ///< Default value text layer on fp creation
  203. // should be a PCB_LAYER_ID, but use an int
  204. // to save this param in config
  205. // Miscellaneous
  206. wxPoint m_AuxOrigin; ///< origin for plot exports
  207. wxPoint m_GridOrigin; ///< origin for grid offsets
  208. D_PAD m_Pad_Master; ///< A dummy pad to store all default parameters
  209. // when importing values or create a new pad
  210. /** Set to true if the board has a stackup management.
  211. * if m_hasStackup is false, a default basic stackup witll be used to
  212. * generate the ;gbrjob file.
  213. * if m_hasStackup is true, the stackup defined for the board is used.
  214. * if not up to date, a error message will be set
  215. * Could be removed later, or at least always set to true
  216. */
  217. bool m_HasStackup;
  218. private:
  219. // Indicies into the trackWidth, viaSizes and diffPairDimensions lists.
  220. // The 0 index is always the current netclass value(s)
  221. unsigned m_trackWidthIndex;
  222. unsigned m_viaSizeIndex;
  223. unsigned m_diffPairIndex;
  224. // Custom values for track/via sizes (specified via dialog instead of netclass or lists)
  225. bool m_useCustomTrackVia;
  226. int m_customTrackWidth;
  227. VIA_DIMENSION m_customViaSize;
  228. // Custom values for differential pairs (specified via dialog instead of netclass/lists)
  229. bool m_useCustomDiffPair;
  230. DIFF_PAIR_DIMENSION m_customDiffPair;
  231. int m_copperLayerCount; ///< Number of copper layers for this design
  232. LSET m_enabledLayers; ///< Bit-mask for layer enabling
  233. LSET m_visibleLayers; ///< Bit-mask for layer visibility
  234. int m_visibleElements; ///< Bit-mask for element category visibility
  235. int m_boardThickness; ///< Board thickness for 3D viewer
  236. /// Current net class name used to display netclass info.
  237. /// This is also the last used netclass after starting a track.
  238. wxString m_currentNetClassName;
  239. /** the description of layers stackup, for board fabrication
  240. * only physical layers are in layers stackup.
  241. * It includes not only layers enabled for the board edition, but also dielectic layers
  242. */
  243. BOARD_STACKUP m_stackup;
  244. public:
  245. BOARD_DESIGN_SETTINGS();
  246. BOARD_STACKUP& GetStackupDescriptor() { return m_stackup; }
  247. /**
  248. * Function GetDefault
  249. * @return the default netclass.
  250. */
  251. inline NETCLASSPTR GetDefault() const
  252. {
  253. return m_NetClasses.GetDefault();
  254. }
  255. /**
  256. * Function GetCurrentNetClassName
  257. * @return the current net class name.
  258. */
  259. inline const wxString& GetCurrentNetClassName() const
  260. {
  261. return m_currentNetClassName;
  262. }
  263. /**
  264. * Function UseNetClassTrack
  265. * returns true if netclass values should be used to obtain appropriate track width.
  266. */
  267. inline bool UseNetClassTrack() const
  268. {
  269. return ( m_trackWidthIndex == 0 && !m_useCustomTrackVia );
  270. }
  271. /**
  272. * Function UseNetClassVia
  273. * returns true if netclass values should be used to obtain appropriate via size.
  274. */
  275. inline bool UseNetClassVia() const
  276. {
  277. return ( m_viaSizeIndex == 0 && !m_useCustomTrackVia );
  278. }
  279. /**
  280. * Function UseNetClassDiffPair
  281. * returns true if netclass values should be used to obtain appropriate diff pair dimensions.
  282. */
  283. inline bool UseNetClassDiffPair() const
  284. {
  285. return ( m_diffPairIndex == 0 && !m_useCustomDiffPair );
  286. }
  287. /**
  288. * Function SetCurrentNetClass
  289. * Must be called after a netclass selection (or after a netclass parameter change
  290. * Initialize vias and tracks values displayed in comb boxes of the auxiliary toolbar
  291. * and some others parameters (netclass name ....)
  292. * @param aNetClassName = the new netclass name
  293. * @return true if lists of tracks and vias sizes are modified
  294. */
  295. bool SetCurrentNetClass( const wxString& aNetClassName );
  296. /**
  297. * Function GetBiggestClearanceValue
  298. * @return the biggest clearance value found in NetClasses list
  299. */
  300. int GetBiggestClearanceValue();
  301. /**
  302. * Function GetSmallestClearanceValue
  303. * @return the smallest clearance value found in NetClasses list
  304. */
  305. int GetSmallestClearanceValue();
  306. /**
  307. * Function GetCurrentMicroViaSize
  308. * @return the current micro via size,
  309. * that is the current netclass value
  310. */
  311. int GetCurrentMicroViaSize();
  312. /**
  313. * Function GetCurrentMicroViaDrill
  314. * @return the current micro via drill,
  315. * that is the current netclass value
  316. */
  317. int GetCurrentMicroViaDrill();
  318. /**
  319. * Function GetTrackWidthIndex
  320. * @return the current track width list index.
  321. */
  322. inline unsigned GetTrackWidthIndex() const { return m_trackWidthIndex; }
  323. /**
  324. * Function SetTrackWidthIndex
  325. * sets the current track width list index to \a aIndex.
  326. *
  327. * @param aIndex is the track width list index.
  328. */
  329. void SetTrackWidthIndex( unsigned aIndex );
  330. /**
  331. * Function GetCurrentTrackWidth
  332. * @return the current track width, according to the selected options
  333. * ( using the default netclass value or a preset/custom value )
  334. * the default netclass is always in m_TrackWidthList[0]
  335. */
  336. inline int GetCurrentTrackWidth() const
  337. {
  338. return m_useCustomTrackVia ? m_customTrackWidth : m_TrackWidthList[m_trackWidthIndex];
  339. }
  340. /**
  341. * Function SetCustomTrackWidth
  342. * Sets custom width for track (i.e. not available in netclasses or preset list). To have
  343. * it returned with GetCurrentTrackWidth() you need to enable custom track & via sizes
  344. * (UseCustomTrackViaSize()).
  345. * @param aWidth is the new track width.
  346. */
  347. inline void SetCustomTrackWidth( int aWidth )
  348. {
  349. m_customTrackWidth = aWidth;
  350. }
  351. /**
  352. * Function GetCustomTrackWidth
  353. * @return Current custom width for a track.
  354. */
  355. inline int GetCustomTrackWidth() const
  356. {
  357. return m_customTrackWidth;
  358. }
  359. /**
  360. * Function GetViaSizeIndex
  361. * @return the current via size list index.
  362. */
  363. inline unsigned GetViaSizeIndex() const
  364. {
  365. return m_viaSizeIndex;
  366. }
  367. /**
  368. * Function SetViaSizeIndex
  369. * sets the current via size list index to \a aIndex.
  370. *
  371. * @param aIndex is the via size list index.
  372. */
  373. void SetViaSizeIndex( unsigned aIndex );
  374. /**
  375. * Function GetCurrentViaSize
  376. * @return the current via size, according to the selected options
  377. * ( using the default netclass value or a preset/custom value )
  378. * the default netclass is always in m_TrackWidthList[0]
  379. */
  380. inline int GetCurrentViaSize() const
  381. {
  382. if( m_useCustomTrackVia )
  383. return m_customViaSize.m_Diameter;
  384. else
  385. return m_ViasDimensionsList[m_viaSizeIndex].m_Diameter;
  386. }
  387. /**
  388. * Function SetCustomViaSize
  389. * Sets custom size for via diameter (i.e. not available in netclasses or preset list). To have
  390. * it returned with GetCurrentViaSize() you need to enable custom track & via sizes
  391. * (UseCustomTrackViaSize()).
  392. * @param aSize is the new drill diameter.
  393. */
  394. inline void SetCustomViaSize( int aSize )
  395. {
  396. m_customViaSize.m_Diameter = aSize;
  397. }
  398. /**
  399. * Function GetCustomViaSize
  400. * @return Current custom size for the via diameter.
  401. */
  402. inline int GetCustomViaSize() const
  403. {
  404. return m_customViaSize.m_Diameter;
  405. }
  406. /**
  407. * Function GetCurrentViaDrill
  408. * @return the current via size, according to the selected options
  409. * ( using the default netclass value or a preset/custom value )
  410. * the default netclass is always in m_TrackWidthList[0]
  411. */
  412. int GetCurrentViaDrill() const;
  413. /**
  414. * Function SetCustomViaDrill
  415. * Sets custom size for via drill (i.e. not available in netclasses or preset list). To have
  416. * it returned with GetCurrentViaDrill() you need to enable custom track & via sizes
  417. * (UseCustomTrackViaSize()).
  418. * @param aDrill is the new drill size.
  419. */
  420. inline void SetCustomViaDrill( int aDrill )
  421. {
  422. m_customViaSize.m_Drill = aDrill;
  423. }
  424. /**
  425. * Function GetCustomViaDrill
  426. * @return Current custom size for the via drill.
  427. */
  428. inline int GetCustomViaDrill() const
  429. {
  430. return m_customViaSize.m_Drill;
  431. }
  432. /**
  433. * Function UseCustomTrackViaSize
  434. * Enables/disables custom track/via size settings. If enabled, values set with
  435. * SetCustomTrackWidth()/SetCustomViaSize()/SetCustomViaDrill() are used for newly created
  436. * tracks and vias.
  437. * @param aEnabled decides if custom settings should be used for new tracks/vias.
  438. */
  439. inline void UseCustomTrackViaSize( bool aEnabled )
  440. {
  441. m_useCustomTrackVia = aEnabled;
  442. }
  443. /**
  444. * Function UseCustomTrackViaSize
  445. * @return True if custom sizes of tracks & vias are enabled, false otherwise.
  446. */
  447. inline bool UseCustomTrackViaSize() const
  448. {
  449. return m_useCustomTrackVia;
  450. }
  451. /**
  452. * Function GetDiffPairIndex
  453. * @return the current diff pair dimension list index.
  454. */
  455. inline unsigned GetDiffPairIndex() const { return m_diffPairIndex; }
  456. /**
  457. * Function SetDiffPairIndex
  458. * @param aIndex is the diff pair dimensions list index to set.
  459. */
  460. void SetDiffPairIndex( unsigned aIndex );
  461. /**
  462. * Function SetCustomDiffPairWidth
  463. * Sets custom track width for differential pairs (i.e. not available in netclasses or
  464. * preset list).
  465. * @param aDrill is the new track wdith.
  466. */
  467. inline void SetCustomDiffPairWidth( int aWidth )
  468. {
  469. m_customDiffPair.m_Width = aWidth;
  470. }
  471. /**
  472. * Function GetCustomDiffPairWidth
  473. * @return Current custom track width for differential pairs.
  474. */
  475. inline int GetCustomDiffPairWidth()
  476. {
  477. return m_customDiffPair.m_Width;
  478. }
  479. /**
  480. * Function SetCustomDiffPairGap
  481. * Sets custom gap for differential pairs (i.e. not available in netclasses or preset
  482. * list).
  483. * @param aGap is the new gap.
  484. */
  485. inline void SetCustomDiffPairGap( int aGap )
  486. {
  487. m_customDiffPair.m_Gap = aGap;
  488. }
  489. /**
  490. * Function GetCustomDiffPairGap
  491. * @return Current custom gap width for differential pairs.
  492. */
  493. inline int GetCustomDiffPairGap()
  494. {
  495. return m_customDiffPair.m_Gap;
  496. }
  497. /**
  498. * Function SetCustomDiffPairViaGap
  499. * Sets custom via gap for differential pairs (i.e. not available in netclasses or
  500. * preset list).
  501. * @param aGap is the new gap. Specify 0 to use the DiffPairGap for vias as well.
  502. */
  503. inline void SetCustomDiffPairViaGap( int aGap )
  504. {
  505. m_customDiffPair.m_ViaGap = aGap;
  506. }
  507. /**
  508. * Function GetCustomDiffPairViaGap
  509. * @return Current custom via gap width for differential pairs.
  510. */
  511. inline int GetCustomDiffPairViaGap()
  512. {
  513. return m_customDiffPair.m_ViaGap > 0 ? m_customDiffPair.m_ViaGap : m_customDiffPair.m_Gap;
  514. }
  515. /**
  516. * Function UseCustomDiffPairDimensions
  517. * Enables/disables custom differential pair dimensions.
  518. * @param aEnabled decides if custom settings should be used for new differential pairs.
  519. */
  520. inline void UseCustomDiffPairDimensions( bool aEnabled )
  521. {
  522. m_useCustomDiffPair = aEnabled;
  523. }
  524. /**
  525. * Function UseCustomDiffPairDimensions
  526. * @return True if custom sizes of diff pairs are enabled, false otherwise.
  527. */
  528. inline bool UseCustomDiffPairDimensions() const
  529. {
  530. return m_useCustomDiffPair;
  531. }
  532. /**
  533. * Function GetCurrentDiffPairWidth
  534. * @return the current diff pair track width, according to the selected options
  535. * ( using the default netclass value or a preset/custom value )
  536. * the default netclass is always in m_DiffPairDimensionsList[0]
  537. */
  538. inline int GetCurrentDiffPairWidth() const
  539. {
  540. if( m_useCustomDiffPair )
  541. return m_customDiffPair.m_Width;
  542. else
  543. return m_DiffPairDimensionsList[m_diffPairIndex].m_Width;
  544. }
  545. /**
  546. * Function GetCurrentDiffPairGap
  547. * @return the current diff pair gap, according to the selected options
  548. * ( using the default netclass value or a preset/custom value )
  549. * the default netclass is always in m_DiffPairDimensionsList[0]
  550. */
  551. inline int GetCurrentDiffPairGap() const
  552. {
  553. if( m_useCustomDiffPair )
  554. return m_customDiffPair.m_Gap;
  555. else
  556. return m_DiffPairDimensionsList[m_diffPairIndex].m_Gap;
  557. }
  558. /**
  559. * Function GetCurrentDiffPairViaGap
  560. * @return the current diff pair via gap, according to the selected options
  561. * ( using the default netclass value or a preset/custom value )
  562. * the default netclass is always in m_DiffPairDimensionsList[0]
  563. */
  564. inline int GetCurrentDiffPairViaGap() const
  565. {
  566. if( m_useCustomDiffPair )
  567. return m_customDiffPair.m_ViaGap;
  568. else
  569. return m_DiffPairDimensionsList[m_diffPairIndex].m_ViaGap;
  570. }
  571. /**
  572. * Function SetMinHoleSeparation
  573. * @param aValue The minimum distance between the edges of two holes or 0 to disable
  574. * hole-to-hole separation checking.
  575. */
  576. void SetMinHoleSeparation( int aDistance );
  577. /**
  578. * Function SetCopperEdgeClearance
  579. * @param aValue The minimum distance between copper items and board edges.
  580. */
  581. void SetCopperEdgeClearance( int aDistance );
  582. /**
  583. * Function SetRequireCourtyardDefinitions
  584. * @param aRequire Set to true to generate DRC violations from missing courtyards.
  585. */
  586. void SetRequireCourtyardDefinitions( bool aRequire );
  587. /**
  588. * Function SetProhibitOverlappingCourtyards
  589. * @param aProhibit Set to true to generate DRC violations from overlapping courtyards.
  590. */
  591. void SetProhibitOverlappingCourtyards( bool aProhibit );
  592. /**
  593. * Function GetVisibleLayers
  594. * returns a bit-mask of all the layers that are visible
  595. * @return int - the visible layers in bit-mapped form.
  596. */
  597. inline LSET GetVisibleLayers() const
  598. {
  599. return m_visibleLayers;
  600. }
  601. /**
  602. * Function SetVisibleAlls
  603. * Set the bit-mask of all visible elements categories,
  604. * including enabled layers
  605. */
  606. void SetVisibleAlls();
  607. /**
  608. * Function SetVisibleLayers
  609. * changes the bit-mask of visible layers
  610. * @param aMask = The new bit-mask of visible layers
  611. */
  612. inline void SetVisibleLayers( LSET aMask )
  613. {
  614. m_visibleLayers = aMask & m_enabledLayers;
  615. }
  616. /**
  617. * Function IsLayerVisible
  618. * tests whether a given layer is visible
  619. * @param aLayerId = The layer to be tested
  620. * @return bool - true if the layer is visible.
  621. */
  622. inline bool IsLayerVisible( PCB_LAYER_ID aLayerId ) const
  623. {
  624. // If a layer is disabled, it is automatically invisible
  625. return (m_visibleLayers & m_enabledLayers)[aLayerId];
  626. }
  627. /**
  628. * Function SetLayerVisibility
  629. * changes the visibility of a given layer
  630. * @param aLayerId = The layer to be changed
  631. * @param aNewState = The new visibility state of the layer
  632. */
  633. void SetLayerVisibility( PCB_LAYER_ID aLayerId, bool aNewState );
  634. /**
  635. * Function GetVisibleElements
  636. * returns a bit-mask of all the element categories that are visible
  637. * @return int - the visible element categories in bit-mapped form.
  638. */
  639. inline int GetVisibleElements() const
  640. {
  641. return m_visibleElements;
  642. }
  643. /**
  644. * Function SetVisibleElements
  645. * changes the bit-mask of visible element categories
  646. * @param aMask = The new bit-mask of visible element categories
  647. */
  648. inline void SetVisibleElements( int aMask )
  649. {
  650. m_visibleElements = aMask;
  651. }
  652. /**
  653. * Function IsElementVisible
  654. * tests whether a given element category is visible. Keep this as an
  655. * inline function.
  656. * @param aElementCategory is from the enum by the same name
  657. * @return bool - true if the element is visible.
  658. * @see enum GAL_LAYER_ID
  659. */
  660. inline bool IsElementVisible( GAL_LAYER_ID aElementCategory ) const
  661. {
  662. return ( m_visibleElements & ( 1 << GAL_LAYER_INDEX( aElementCategory ) ) );
  663. }
  664. /**
  665. * Function SetElementVisibility
  666. * changes the visibility of an element category
  667. * @param aElementCategory is from the enum by the same name
  668. * @param aNewState = The new visibility state of the element category
  669. * @see enum GAL_LAYER_ID
  670. */
  671. void SetElementVisibility( GAL_LAYER_ID aElementCategory, bool aNewState );
  672. /**
  673. * Function GetEnabledLayers
  674. * returns a bit-mask of all the layers that are enabled
  675. * @return int - the enabled layers in bit-mapped form.
  676. */
  677. inline LSET GetEnabledLayers() const
  678. {
  679. return m_enabledLayers;
  680. }
  681. /**
  682. * Function SetEnabledLayers
  683. * changes the bit-mask of enabled layers
  684. * @param aMask = The new bit-mask of enabled layers
  685. */
  686. void SetEnabledLayers( LSET aMask );
  687. /**
  688. * Function IsLayerEnabled
  689. * tests whether a given layer is enabled
  690. * @param aLayerId = The layer to be tested
  691. * @return bool - true if the layer is enabled
  692. */
  693. inline bool IsLayerEnabled( PCB_LAYER_ID aLayerId ) const
  694. {
  695. return m_enabledLayers[aLayerId];
  696. }
  697. /**
  698. * Function GetCopperLayerCount
  699. * @return int - the number of neabled copper layers
  700. */
  701. inline int GetCopperLayerCount() const
  702. {
  703. return m_copperLayerCount;
  704. }
  705. /**
  706. * Function SetCopperLayerCount
  707. * do what its name says...
  708. * @param aNewLayerCount = The new number of enabled copper layers
  709. */
  710. void SetCopperLayerCount( int aNewLayerCount );
  711. /**
  712. * Function AppendConfigs
  713. * appends to @a aResult the configuration setting accessors which will later
  714. * allow reading or writing of configuration file information directly into
  715. * this object.
  716. */
  717. void AppendConfigs( BOARD* aBoard, std::vector<PARAM_CFG*>* aResult );
  718. inline int GetBoardThickness() const { return m_boardThickness; }
  719. inline void SetBoardThickness( int aThickness ) { m_boardThickness = aThickness; }
  720. /**
  721. * Function GetLineThickness
  722. * Returns the default graphic segment thickness from the layer class for the given layer.
  723. */
  724. int GetLineThickness( PCB_LAYER_ID aLayer ) const;
  725. /**
  726. * Function GetTextSize
  727. * Returns the default text size from the layer class for the given layer.
  728. */
  729. wxSize GetTextSize( PCB_LAYER_ID aLayer ) const;
  730. /**
  731. * Function GetTextThickness
  732. * Returns the default text thickness from the layer class for the given layer.
  733. */
  734. int GetTextThickness( PCB_LAYER_ID aLayer ) const;
  735. bool GetTextItalic( PCB_LAYER_ID aLayer ) const;
  736. bool GetTextUpright( PCB_LAYER_ID aLayer ) const;
  737. int GetLayerClass( PCB_LAYER_ID aLayer ) const;
  738. private:
  739. void formatNetClass( NETCLASS* aNetClass, OUTPUTFORMATTER* aFormatter, int aNestLevel,
  740. int aControlBits ) const;
  741. };
  742. #endif // BOARD_DESIGN_SETTINGS_H_