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.

890 lines
29 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-2020 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 <netclass.h>
  28. #include <config_params.h>
  29. #include <board_stackup_manager/class_board_stackup.h>
  30. #include <drc/drc_rule.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. // soldermask to pad clearance. The default is 0 because usually board houses
  46. // create a clearance depending on their fab process:
  47. // mask material, color, price ...
  48. #define DEFAULT_SOLDERMASK_CLEARANCE 0.0
  49. // DEFAULT_SOLDERMASK_MIN_WIDTH is only used in Gerber files: soldermask minimum size.
  50. // Set to 0, because using non 0 value creates an annoying issue in Gerber files:
  51. // pads are no longer identified as pads (Flashed items or regions)
  52. // Therefore solder mask min width must be used only in specific cases
  53. // for instance for home made boards
  54. #define DEFAULT_SOLDERMASK_MIN_WIDTH 0.0
  55. #define DEFAULT_SOLDERPASTE_CLEARANCE 0.0
  56. #define DEFAULT_SOLDERPASTE_RATIO 0.0
  57. #define DEFAULT_CUSTOMTRACKWIDTH 0.2
  58. #define DEFAULT_CUSTOMDPAIRWIDTH 0.125
  59. #define DEFAULT_CUSTOMDPAIRGAP 0.18
  60. #define DEFAULT_CUSTOMDPAIRVIAGAP 0.18
  61. #define DEFAULT_MINCLEARANCE 0.0 // overall min clearance
  62. #define DEFAULT_TRACKMINWIDTH 0.2 // track width min value
  63. #define DEFAULT_VIASMINSIZE 0.4 // vias (not micro vias) min diameter
  64. #define DEFAULT_MINTHROUGHDRILL 0.3 // through holes (not micro vias) min drill diameter
  65. #define DEFAULT_MICROVIASMINSIZE 0.2 // micro vias (not vias) min diameter
  66. #define DEFAULT_MICROVIASMINDRILL 0.1 // micro vias (not vias) min drill diameter
  67. #define DEFAULT_HOLETOHOLEMIN 0.25 // separation between drilled hole edges
  68. #define DEFAULT_COPPEREDGECLEARANCE 0.01 // clearance between copper items and edge cuts
  69. #define LEGACY_COPPEREDGECLEARANCE -0.01 // A flag to indicate the legacy method (based
  70. // on edge cut line thicknesses) should be used.
  71. #define MINIMUM_ERROR_SIZE_MM 0.001
  72. #define MAXIMUM_ERROR_SIZE_MM 0.1
  73. #define DRC_EPSILON 5; // An epsilon to account for rounding errors, etc.
  74. // 5nm is small enough not to materially violate
  75. // any constraints.
  76. /**
  77. * Struct VIA_DIMENSION
  78. * is a small helper container to handle a stock of specific vias each with
  79. * unique diameter and drill sizes in the BOARD class.
  80. */
  81. struct VIA_DIMENSION
  82. {
  83. int m_Diameter; // <= 0 means use Netclass via diameter
  84. int m_Drill; // <= 0 means use Netclass via drill
  85. VIA_DIMENSION()
  86. {
  87. m_Diameter = 0;
  88. m_Drill = 0;
  89. }
  90. VIA_DIMENSION( int aDiameter, int aDrill )
  91. {
  92. m_Diameter = aDiameter;
  93. m_Drill = aDrill;
  94. }
  95. bool operator==( const VIA_DIMENSION& aOther ) const
  96. {
  97. return ( m_Diameter == aOther.m_Diameter ) && ( m_Drill == aOther.m_Drill );
  98. }
  99. bool operator<( const VIA_DIMENSION& aOther ) const
  100. {
  101. if( m_Diameter != aOther.m_Diameter )
  102. return m_Diameter < aOther.m_Diameter;
  103. return m_Drill < aOther.m_Drill;
  104. }
  105. };
  106. /**
  107. * Struct DIFF_PAIR_DIMENSION
  108. * is a small helper container to handle a stock of specific differential pairs each with
  109. * unique track width, gap and via gap.
  110. */
  111. struct DIFF_PAIR_DIMENSION
  112. {
  113. int m_Width; // <= 0 means use Netclass differential pair width
  114. int m_Gap; // <= 0 means use Netclass differential pair gap
  115. int m_ViaGap; // <= 0 means use Netclass differential pair via gap
  116. DIFF_PAIR_DIMENSION()
  117. {
  118. m_Width = 0;
  119. m_Gap = 0;
  120. m_ViaGap = 0;
  121. }
  122. DIFF_PAIR_DIMENSION( int aWidth, int aGap, int aViaGap )
  123. {
  124. m_Width = aWidth;
  125. m_Gap = aGap;
  126. m_ViaGap = aViaGap;
  127. }
  128. bool operator==( const DIFF_PAIR_DIMENSION& aOther ) const
  129. {
  130. return ( m_Width == aOther.m_Width )
  131. && ( m_Gap == aOther.m_Gap )
  132. && ( m_ViaGap == aOther.m_ViaGap );
  133. }
  134. bool operator<( const DIFF_PAIR_DIMENSION& aOther ) const
  135. {
  136. if( m_Width != aOther.m_Width )
  137. return m_Width < aOther.m_Width;
  138. if( m_Gap != aOther.m_Gap )
  139. return m_Gap < aOther.m_Gap;
  140. return m_ViaGap < aOther.m_ViaGap;
  141. }
  142. };
  143. enum
  144. {
  145. LAYER_CLASS_SILK = 0,
  146. LAYER_CLASS_COPPER,
  147. LAYER_CLASS_EDGES,
  148. LAYER_CLASS_COURTYARD,
  149. LAYER_CLASS_FAB,
  150. LAYER_CLASS_OTHERS,
  151. LAYER_CLASS_COUNT
  152. };
  153. struct TEXT_ITEM_INFO
  154. {
  155. wxString m_Text;
  156. bool m_Visible;
  157. int m_Layer;
  158. TEXT_ITEM_INFO( const wxString& aText, bool aVisible, int aLayer )
  159. {
  160. m_Text = aText;
  161. m_Visible = aVisible;
  162. m_Layer = aLayer;
  163. }
  164. };
  165. // forward declaration from class_track.h
  166. enum class VIATYPE : int;
  167. /**
  168. * BOARD_DESIGN_SETTINGS
  169. * contains design settings for a BOARD object.
  170. */
  171. class BOARD_DESIGN_SETTINGS
  172. {
  173. public:
  174. // Note: the first value in each dimensions list is the current netclass value
  175. std::vector<int> m_TrackWidthList;
  176. std::vector<VIA_DIMENSION> m_ViasDimensionsList;
  177. std::vector<DIFF_PAIR_DIMENSION> m_DiffPairDimensionsList;
  178. // List of netclasses. There is always the default netclass.
  179. NETCLASSES m_NetClasses;
  180. std::vector<DRC_SELECTOR*> m_DRCRuleSelectors;
  181. std::vector<DRC_RULE*> m_DRCRules;
  182. // Temporary storage for rule matching.
  183. std::vector<DRC_SELECTOR*> m_matched;
  184. bool m_MicroViasAllowed; ///< true to allow micro vias
  185. bool m_BlindBuriedViaAllowed; ///< true to allow blind/buried vias
  186. VIATYPE m_CurrentViaType; ///< (VIA_BLIND_BURIED, VIA_THROUGH, VIA_MICROVIA)
  187. bool m_UseConnectedTrackWidth; // use width of existing track when creating a new,
  188. // connected track
  189. int m_MinClearance; // overall min clearance
  190. int m_TrackMinWidth; // overall min track width
  191. int m_ViasMinAnnulus; // overall minimum width of the via copper ring
  192. int m_ViasMinSize; // overall vias (not micro vias) min diameter
  193. int m_MinThroughDrill; // through hole (not micro vias) min drill diameter
  194. int m_MicroViasMinSize; // micro vias min diameter
  195. int m_MicroViasMinDrill; // micro vias min drill diameter
  196. int m_CopperEdgeClearance;
  197. int m_HoleToHoleMin; // Min width of peninsula between two drilled holes
  198. std::map< int, int > m_DRCSeverities; // Map from DRCErrorCode to SEVERITY
  199. /** Option to handle filled polygons in zones:
  200. * the "legacy" option is using thick outlines around filled polygons: give the best shape
  201. * the "new" option is using only filled polygons (no outline: give the faster redraw time
  202. * moreover when exporting zone filled areas, the excatct shape is exported.
  203. * the legacy option can really create redraw time issues for large boards.
  204. */
  205. bool m_ZoneUseNoOutlineInFill; ///< true for new zone filling option
  206. // Maximum error allowed when approximating circles and arcs to segments
  207. int m_MaxError;
  208. // Global mask margins:
  209. int m_SolderMaskMargin; ///< Solder mask margin
  210. int m_SolderMaskMinWidth; ///< Solder mask min width
  211. // 2 areas near than m_SolderMaskMinWidth
  212. // are merged
  213. int m_SolderPasteMargin; ///< Solder paste margin absolute value
  214. double m_SolderPasteMarginRatio; ///< Solder pask margin ratio value of pad size
  215. ///< The final margin is the sum of these 2 values
  216. // Variables used in footprint editing (default value in item/footprint creation)
  217. std::vector<TEXT_ITEM_INFO> m_DefaultFPTextItems;
  218. // Arrays of default values for the various layer classes.
  219. int m_LineThickness[ LAYER_CLASS_COUNT ];
  220. wxSize m_TextSize[ LAYER_CLASS_COUNT ];
  221. int m_TextThickness[ LAYER_CLASS_COUNT ];
  222. bool m_TextItalic[ LAYER_CLASS_COUNT ];
  223. bool m_TextUpright[ LAYER_CLASS_COUNT ];
  224. int m_DimensionUnits;
  225. int m_DimensionPrecision;
  226. // Miscellaneous
  227. wxPoint m_AuxOrigin; ///< origin for plot exports
  228. wxPoint m_GridOrigin; ///< origin for grid offsets
  229. D_PAD m_Pad_Master; ///< A dummy pad to store all default parameters
  230. // when importing values or create a new pad
  231. /** Set to true if the board has a stackup management.
  232. * if m_hasStackup is false, a default basic stackup witll be used to
  233. * generate the ;gbrjob file.
  234. * if m_hasStackup is true, the stackup defined for the board is used.
  235. * if not up to date, a error message will be set
  236. * Could be removed later, or at least always set to true
  237. */
  238. bool m_HasStackup;
  239. private:
  240. // Indicies into the trackWidth, viaSizes and diffPairDimensions lists.
  241. // The 0 index is always the current netclass value(s)
  242. unsigned m_trackWidthIndex;
  243. unsigned m_viaSizeIndex;
  244. unsigned m_diffPairIndex;
  245. // Custom values for track/via sizes (specified via dialog instead of netclass or lists)
  246. bool m_useCustomTrackVia;
  247. int m_customTrackWidth;
  248. VIA_DIMENSION m_customViaSize;
  249. // Custom values for differential pairs (specified via dialog instead of netclass/lists)
  250. bool m_useCustomDiffPair;
  251. DIFF_PAIR_DIMENSION m_customDiffPair;
  252. int m_copperLayerCount; ///< Number of copper layers for this design
  253. LSET m_enabledLayers; ///< Bit-mask for layer enabling
  254. LSET m_visibleLayers; ///< Bit-mask for layer visibility
  255. int m_visibleElements; ///< Bit-mask for element category visibility
  256. int m_boardThickness; ///< Board thickness for 3D viewer
  257. /// Current net class name used to display netclass info.
  258. /// This is also the last used netclass after starting a track.
  259. wxString m_currentNetClassName;
  260. /** the description of layers stackup, for board fabrication
  261. * only physical layers are in layers stackup.
  262. * It includes not only layers enabled for the board edition, but also dielectic layers
  263. */
  264. BOARD_STACKUP m_stackup;
  265. public:
  266. BOARD_DESIGN_SETTINGS();
  267. BOARD_STACKUP& GetStackupDescriptor() { return m_stackup; }
  268. int GetSeverity( int aDRCErrorCode );
  269. /**
  270. * returns true if the DRC error code's severity is SEVERITY_IGNORE
  271. */
  272. bool Ignore( int aDRCErrorCode );
  273. /**
  274. * Function GetDefault
  275. * @return the default netclass.
  276. */
  277. inline NETCLASS* GetDefault() const
  278. {
  279. return m_NetClasses.GetDefaultPtr();
  280. }
  281. /**
  282. * Function GetCurrentNetClassName
  283. * @return the current net class name.
  284. */
  285. inline const wxString& GetCurrentNetClassName() const
  286. {
  287. return m_currentNetClassName;
  288. }
  289. /**
  290. * Function UseNetClassTrack
  291. * returns true if netclass values should be used to obtain appropriate track width.
  292. */
  293. inline bool UseNetClassTrack() const
  294. {
  295. return ( m_trackWidthIndex == 0 && !m_useCustomTrackVia );
  296. }
  297. /**
  298. * Function UseNetClassVia
  299. * returns true if netclass values should be used to obtain appropriate via size.
  300. */
  301. inline bool UseNetClassVia() const
  302. {
  303. return ( m_viaSizeIndex == 0 && !m_useCustomTrackVia );
  304. }
  305. /**
  306. * Function UseNetClassDiffPair
  307. * returns true if netclass values should be used to obtain appropriate diff pair dimensions.
  308. */
  309. inline bool UseNetClassDiffPair() const
  310. {
  311. return ( m_diffPairIndex == 0 && !m_useCustomDiffPair );
  312. }
  313. /**
  314. * Function SetCurrentNetClass
  315. * Must be called after a netclass selection (or after a netclass parameter change
  316. * Initialize vias and tracks values displayed in comb boxes of the auxiliary toolbar
  317. * and some others parameters (netclass name ....)
  318. * @param aNetClassName = the new netclass name
  319. * @return true if lists of tracks and vias sizes are modified
  320. */
  321. bool SetCurrentNetClass( const wxString& aNetClassName );
  322. /**
  323. * Function GetBiggestClearanceValue
  324. * @return the biggest clearance value found in NetClasses list
  325. */
  326. int GetBiggestClearanceValue();
  327. /**
  328. * Function GetSmallestClearanceValue
  329. * @return the smallest clearance value found in NetClasses list
  330. */
  331. int GetSmallestClearanceValue();
  332. /**
  333. * Function GetCurrentMicroViaSize
  334. * @return the current micro via size,
  335. * that is the current netclass value
  336. */
  337. int GetCurrentMicroViaSize();
  338. /**
  339. * Function GetCurrentMicroViaDrill
  340. * @return the current micro via drill,
  341. * that is the current netclass value
  342. */
  343. int GetCurrentMicroViaDrill();
  344. /**
  345. * Function GetTrackWidthIndex
  346. * @return the current track width list index.
  347. */
  348. inline unsigned GetTrackWidthIndex() const { return m_trackWidthIndex; }
  349. /**
  350. * Function SetTrackWidthIndex
  351. * sets the current track width list index to \a aIndex.
  352. *
  353. * @param aIndex is the track width list index.
  354. */
  355. void SetTrackWidthIndex( unsigned aIndex );
  356. /**
  357. * Function GetCurrentTrackWidth
  358. * @return the current track width, according to the selected options
  359. * ( using the default netclass value or a preset/custom value )
  360. * the default netclass is always in m_TrackWidthList[0]
  361. */
  362. inline int GetCurrentTrackWidth() const
  363. {
  364. return m_useCustomTrackVia ? m_customTrackWidth : m_TrackWidthList[m_trackWidthIndex];
  365. }
  366. /**
  367. * Function SetCustomTrackWidth
  368. * Sets custom width for track (i.e. not available in netclasses or preset list). To have
  369. * it returned with GetCurrentTrackWidth() you need to enable custom track & via sizes
  370. * (UseCustomTrackViaSize()).
  371. * @param aWidth is the new track width.
  372. */
  373. inline void SetCustomTrackWidth( int aWidth )
  374. {
  375. m_customTrackWidth = aWidth;
  376. }
  377. /**
  378. * Function GetCustomTrackWidth
  379. * @return Current custom width for a track.
  380. */
  381. inline int GetCustomTrackWidth() const
  382. {
  383. return m_customTrackWidth;
  384. }
  385. /**
  386. * Function GetViaSizeIndex
  387. * @return the current via size list index.
  388. */
  389. inline unsigned GetViaSizeIndex() const
  390. {
  391. return m_viaSizeIndex;
  392. }
  393. /**
  394. * Function SetViaSizeIndex
  395. * sets the current via size list index to \a aIndex.
  396. *
  397. * @param aIndex is the via size list index.
  398. */
  399. void SetViaSizeIndex( unsigned aIndex );
  400. /**
  401. * Function GetCurrentViaSize
  402. * @return the current via size, according to the selected options
  403. * ( using the default netclass value or a preset/custom value )
  404. * the default netclass is always in m_TrackWidthList[0]
  405. */
  406. inline int GetCurrentViaSize() const
  407. {
  408. if( m_useCustomTrackVia )
  409. return m_customViaSize.m_Diameter;
  410. else
  411. return m_ViasDimensionsList[m_viaSizeIndex].m_Diameter;
  412. }
  413. /**
  414. * Function SetCustomViaSize
  415. * Sets custom size for via diameter (i.e. not available in netclasses or preset list). To have
  416. * it returned with GetCurrentViaSize() you need to enable custom track & via sizes
  417. * (UseCustomTrackViaSize()).
  418. * @param aSize is the new drill diameter.
  419. */
  420. inline void SetCustomViaSize( int aSize )
  421. {
  422. m_customViaSize.m_Diameter = aSize;
  423. }
  424. /**
  425. * Function GetCustomViaSize
  426. * @return Current custom size for the via diameter.
  427. */
  428. inline int GetCustomViaSize() const
  429. {
  430. return m_customViaSize.m_Diameter;
  431. }
  432. /**
  433. * Function GetCurrentViaDrill
  434. * @return the current via size, according to the selected options
  435. * ( using the default netclass value or a preset/custom value )
  436. * the default netclass is always in m_TrackWidthList[0]
  437. */
  438. int GetCurrentViaDrill() const;
  439. /**
  440. * Function SetCustomViaDrill
  441. * Sets custom size for via drill (i.e. not available in netclasses or preset list). To have
  442. * it returned with GetCurrentViaDrill() you need to enable custom track & via sizes
  443. * (UseCustomTrackViaSize()).
  444. * @param aDrill is the new drill size.
  445. */
  446. inline void SetCustomViaDrill( int aDrill )
  447. {
  448. m_customViaSize.m_Drill = aDrill;
  449. }
  450. /**
  451. * Function GetCustomViaDrill
  452. * @return Current custom size for the via drill.
  453. */
  454. inline int GetCustomViaDrill() const
  455. {
  456. return m_customViaSize.m_Drill;
  457. }
  458. /**
  459. * Function UseCustomTrackViaSize
  460. * Enables/disables custom track/via size settings. If enabled, values set with
  461. * SetCustomTrackWidth()/SetCustomViaSize()/SetCustomViaDrill() are used for newly created
  462. * tracks and vias.
  463. * @param aEnabled decides if custom settings should be used for new tracks/vias.
  464. */
  465. inline void UseCustomTrackViaSize( bool aEnabled )
  466. {
  467. m_useCustomTrackVia = aEnabled;
  468. }
  469. /**
  470. * Function UseCustomTrackViaSize
  471. * @return True if custom sizes of tracks & vias are enabled, false otherwise.
  472. */
  473. inline bool UseCustomTrackViaSize() const
  474. {
  475. return m_useCustomTrackVia;
  476. }
  477. /**
  478. * Function GetDiffPairIndex
  479. * @return the current diff pair dimension list index.
  480. */
  481. inline unsigned GetDiffPairIndex() const { return m_diffPairIndex; }
  482. /**
  483. * Function SetDiffPairIndex
  484. * @param aIndex is the diff pair dimensions list index to set.
  485. */
  486. void SetDiffPairIndex( unsigned aIndex );
  487. /**
  488. * Function SetCustomDiffPairWidth
  489. * Sets custom track width for differential pairs (i.e. not available in netclasses or
  490. * preset list).
  491. * @param aDrill is the new track wdith.
  492. */
  493. inline void SetCustomDiffPairWidth( int aWidth )
  494. {
  495. m_customDiffPair.m_Width = aWidth;
  496. }
  497. /**
  498. * Function GetCustomDiffPairWidth
  499. * @return Current custom track width for differential pairs.
  500. */
  501. inline int GetCustomDiffPairWidth()
  502. {
  503. return m_customDiffPair.m_Width;
  504. }
  505. /**
  506. * Function SetCustomDiffPairGap
  507. * Sets custom gap for differential pairs (i.e. not available in netclasses or preset
  508. * list).
  509. * @param aGap is the new gap.
  510. */
  511. inline void SetCustomDiffPairGap( int aGap )
  512. {
  513. m_customDiffPair.m_Gap = aGap;
  514. }
  515. /**
  516. * Function GetCustomDiffPairGap
  517. * @return Current custom gap width for differential pairs.
  518. */
  519. inline int GetCustomDiffPairGap()
  520. {
  521. return m_customDiffPair.m_Gap;
  522. }
  523. /**
  524. * Function SetCustomDiffPairViaGap
  525. * Sets custom via gap for differential pairs (i.e. not available in netclasses or
  526. * preset list).
  527. * @param aGap is the new gap. Specify 0 to use the DiffPairGap for vias as well.
  528. */
  529. inline void SetCustomDiffPairViaGap( int aGap )
  530. {
  531. m_customDiffPair.m_ViaGap = aGap;
  532. }
  533. /**
  534. * Function GetCustomDiffPairViaGap
  535. * @return Current custom via gap width for differential pairs.
  536. */
  537. inline int GetCustomDiffPairViaGap()
  538. {
  539. return m_customDiffPair.m_ViaGap > 0 ? m_customDiffPair.m_ViaGap : m_customDiffPair.m_Gap;
  540. }
  541. /**
  542. * Function UseCustomDiffPairDimensions
  543. * Enables/disables custom differential pair dimensions.
  544. * @param aEnabled decides if custom settings should be used for new differential pairs.
  545. */
  546. inline void UseCustomDiffPairDimensions( bool aEnabled )
  547. {
  548. m_useCustomDiffPair = aEnabled;
  549. }
  550. /**
  551. * Function UseCustomDiffPairDimensions
  552. * @return True if custom sizes of diff pairs are enabled, false otherwise.
  553. */
  554. inline bool UseCustomDiffPairDimensions() const
  555. {
  556. return m_useCustomDiffPair;
  557. }
  558. /**
  559. * Function GetCurrentDiffPairWidth
  560. * @return the current diff pair track width, 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 GetCurrentDiffPairWidth() const
  565. {
  566. if( m_useCustomDiffPair )
  567. return m_customDiffPair.m_Width;
  568. else
  569. return m_DiffPairDimensionsList[m_diffPairIndex].m_Width;
  570. }
  571. /**
  572. * Function GetCurrentDiffPairGap
  573. * @return the current diff pair gap, according to the selected options
  574. * ( using the default netclass value or a preset/custom value )
  575. * the default netclass is always in m_DiffPairDimensionsList[0]
  576. */
  577. inline int GetCurrentDiffPairGap() const
  578. {
  579. if( m_useCustomDiffPair )
  580. return m_customDiffPair.m_Gap;
  581. else
  582. return m_DiffPairDimensionsList[m_diffPairIndex].m_Gap;
  583. }
  584. /**
  585. * Function GetCurrentDiffPairViaGap
  586. * @return the current diff pair via gap, according to the selected options
  587. * ( using the default netclass value or a preset/custom value )
  588. * the default netclass is always in m_DiffPairDimensionsList[0]
  589. */
  590. inline int GetCurrentDiffPairViaGap() const
  591. {
  592. if( m_useCustomDiffPair )
  593. return m_customDiffPair.m_ViaGap;
  594. else
  595. return m_DiffPairDimensionsList[m_diffPairIndex].m_ViaGap;
  596. }
  597. /**
  598. * Function SetMinHoleSeparation
  599. * @param aValue The minimum distance between the edges of two holes or 0 to disable
  600. * hole-to-hole separation checking.
  601. */
  602. void SetMinHoleSeparation( int aDistance );
  603. /**
  604. * Function SetCopperEdgeClearance
  605. * @param aValue The minimum distance between copper items and board edges.
  606. */
  607. void SetCopperEdgeClearance( int aDistance );
  608. /**
  609. * Function GetVisibleLayers
  610. * returns a bit-mask of all the layers that are visible
  611. * @return int - the visible layers in bit-mapped form.
  612. */
  613. inline LSET GetVisibleLayers() const
  614. {
  615. return m_visibleLayers;
  616. }
  617. /**
  618. * Function SetVisibleAlls
  619. * Set the bit-mask of all visible elements categories,
  620. * including enabled layers
  621. */
  622. void SetVisibleAlls();
  623. /**
  624. * Function SetVisibleLayers
  625. * changes the bit-mask of visible layers
  626. * @param aMask = The new bit-mask of visible layers
  627. */
  628. inline void SetVisibleLayers( LSET aMask )
  629. {
  630. m_visibleLayers = aMask & m_enabledLayers;
  631. }
  632. /**
  633. * Function IsLayerVisible
  634. * tests whether a given layer is visible
  635. * @param aLayerId = The layer to be tested
  636. * @return bool - true if the layer is visible.
  637. */
  638. inline bool IsLayerVisible( PCB_LAYER_ID aLayerId ) const
  639. {
  640. // If a layer is disabled, it is automatically invisible
  641. return (m_visibleLayers & m_enabledLayers)[aLayerId];
  642. }
  643. /**
  644. * Function SetLayerVisibility
  645. * changes the visibility of a given layer
  646. * @param aLayerId = The layer to be changed
  647. * @param aNewState = The new visibility state of the layer
  648. */
  649. void SetLayerVisibility( PCB_LAYER_ID aLayerId, bool aNewState );
  650. /**
  651. * Function GetVisibleElements
  652. * returns a bit-mask of all the element categories that are visible
  653. * @return int - the visible element categories in bit-mapped form.
  654. */
  655. inline int GetVisibleElements() const
  656. {
  657. return m_visibleElements;
  658. }
  659. /**
  660. * Function SetVisibleElements
  661. * changes the bit-mask of visible element categories
  662. * @param aMask = The new bit-mask of visible element categories
  663. */
  664. inline void SetVisibleElements( int aMask )
  665. {
  666. m_visibleElements = aMask;
  667. }
  668. /**
  669. * Function IsElementVisible
  670. * tests whether a given element category is visible. Keep this as an
  671. * inline function.
  672. * @param aElementCategory is from the enum by the same name
  673. * @return bool - true if the element is visible.
  674. * @see enum GAL_LAYER_ID
  675. */
  676. inline bool IsElementVisible( GAL_LAYER_ID aElementCategory ) const
  677. {
  678. return ( m_visibleElements & ( 1 << GAL_LAYER_INDEX( aElementCategory ) ) );
  679. }
  680. /**
  681. * Function SetElementVisibility
  682. * changes the visibility of an element category
  683. * @param aElementCategory is from the enum by the same name
  684. * @param aNewState = The new visibility state of the element category
  685. * @see enum GAL_LAYER_ID
  686. */
  687. void SetElementVisibility( GAL_LAYER_ID aElementCategory, bool aNewState );
  688. /**
  689. * Function GetEnabledLayers
  690. * returns a bit-mask of all the layers that are enabled
  691. * @return int - the enabled layers in bit-mapped form.
  692. */
  693. inline LSET GetEnabledLayers() const
  694. {
  695. return m_enabledLayers;
  696. }
  697. /**
  698. * Function SetEnabledLayers
  699. * changes the bit-mask of enabled layers
  700. * @param aMask = The new bit-mask of enabled layers
  701. */
  702. void SetEnabledLayers( LSET aMask );
  703. /**
  704. * Function IsLayerEnabled
  705. * tests whether a given layer is enabled
  706. * @param aLayerId = The layer to be tested
  707. * @return bool - true if the layer is enabled
  708. */
  709. inline bool IsLayerEnabled( PCB_LAYER_ID aLayerId ) const
  710. {
  711. return m_enabledLayers[aLayerId];
  712. }
  713. /**
  714. * Function GetCopperLayerCount
  715. * @return int - the number of neabled copper layers
  716. */
  717. inline int GetCopperLayerCount() const
  718. {
  719. return m_copperLayerCount;
  720. }
  721. /**
  722. * Function SetCopperLayerCount
  723. * do what its name says...
  724. * @param aNewLayerCount = The new number of enabled copper layers
  725. */
  726. void SetCopperLayerCount( int aNewLayerCount );
  727. /**
  728. * Function AppendConfigs
  729. * appends to @a aResult the configuration setting accessors which will later
  730. * allow reading or writing of configuration file information directly into
  731. * this object.
  732. */
  733. void AppendConfigs( BOARD* aBoard, std::vector<PARAM_CFG*>* aResult );
  734. inline int GetBoardThickness() const { return m_boardThickness; }
  735. inline void SetBoardThickness( int aThickness ) { m_boardThickness = aThickness; }
  736. /*
  737. * Function GetDRCEpsilon
  738. * an epsilon which accounts for rounding errors, etc. While currently a global, going
  739. * through this API allows us to easily change it to board-specific if so desired.
  740. */
  741. int GetDRCEpsilon() const { return DRC_EPSILON; }
  742. /**
  743. * Function GetLineThickness
  744. * Returns the default graphic segment thickness from the layer class for the given layer.
  745. */
  746. int GetLineThickness( PCB_LAYER_ID aLayer ) const;
  747. /**
  748. * Function GetTextSize
  749. * Returns the default text size from the layer class for the given layer.
  750. */
  751. wxSize GetTextSize( PCB_LAYER_ID aLayer ) const;
  752. /**
  753. * Function GetTextThickness
  754. * Returns the default text thickness from the layer class for the given layer.
  755. */
  756. int GetTextThickness( PCB_LAYER_ID aLayer ) const;
  757. bool GetTextItalic( PCB_LAYER_ID aLayer ) const;
  758. bool GetTextUpright( PCB_LAYER_ID aLayer ) const;
  759. int GetLayerClass( PCB_LAYER_ID aLayer ) const;
  760. };
  761. #endif // BOARD_DESIGN_SETTINGS_H_