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.

733 lines
21 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #pragma once
  24. #include <kicommon.h>
  25. class wxConfigBase;
  26. /**
  27. * @defgroup advanced_config Advanced Configuration Variables
  28. *
  29. * Class containing "advanced" configuration options.
  30. *
  31. * Options set here are for developer or advanced users only. If a general user
  32. * needs to set one of these for normal KiCad use, either:
  33. * * They are working around some bug that should be fixed, or
  34. * * The parameter they are setting is of general interest and should be in the
  35. * main application config, with UI provided.
  36. *
  37. * Options in this class are, in general, preferable to #defines, as they
  38. * allow more flexible configuration by developers, and don't hide code from
  39. * the compiler on other configurations, which can result in broken builds.
  40. *
  41. * Never use advanced configs in an untestable way. If a function depends on
  42. * advanced config such that you cannot test it without changing the config,
  43. * "lift" the config to a higher level and make pass it as parameter of the code
  44. * under test. The tests can pass their own values as needed.
  45. *
  46. * This also applies to code that does not depend on "common" - it cannot
  47. * use this class, so you must pass configuration in as proper parameters.
  48. *
  49. * Sometimes you can just use values directly, and sometimes helper functions
  50. * might be provided to allow extra logic (for example when a advanced config
  51. * applies only on certain platforms).
  52. *
  53. * For more information on what config keys set these parameters in the
  54. * config files, and why you might want to set them, see #AC_KEYS
  55. *
  56. */
  57. class KICOMMON_API ADVANCED_CFG
  58. {
  59. public:
  60. /**
  61. * Get the singleton instance's config, which is shared by all consumers.
  62. *
  63. * This configuration is read-only - to set options, users should add the parameters to
  64. * their config files at ~/.config/kicad/advanced, or the platform equivalent.
  65. */
  66. static const ADVANCED_CFG& GetCfg();
  67. ///@{
  68. /// \ingroup advanced_config
  69. /**
  70. * Distance from an arc end point and the estimated end point, when rotating from the
  71. * start point to the end point.
  72. *
  73. * Setting name: "DrawArcAccuracy"
  74. * Valid values: 0 to 100000
  75. * Default value: 10
  76. */
  77. double m_DrawArcAccuracy;
  78. /**
  79. * When drawing an arc, the angle ( center - start ) - ( start - end ) can be limited to
  80. * avoid extremely high radii.
  81. *
  82. * Setting name: "DrawArcCenterStartEndMaxAngle"
  83. * Valid values: 0 to 100000
  84. * Default value: 50
  85. */
  86. double m_DrawArcCenterMaxAngle;
  87. /**
  88. * Maximum angle between the tangent line of an arc track and a connected straight track
  89. * in order to commence arc dragging. Units are degrees.
  90. *
  91. * Setting name: "MaxTangentTrackAngleDeviation"
  92. * Valid values: 0 to 90
  93. * Default value: 1
  94. */
  95. double m_MaxTangentAngleDeviation;
  96. /**
  97. * Maximum track length to keep after doing an arc track resizing operation. Units are mm.
  98. *
  99. * Setting name: "MaxTrackLengthToKeep"
  100. * Valid values: 0 to 1
  101. * Default value: 0.0005
  102. */
  103. double m_MaxTrackLengthToKeep;
  104. /**
  105. * When filling zones, we add an extra amount of clearance to each zone to ensure that
  106. * rounding errors do not overrun minimum clearance distances.
  107. *
  108. * This is the extra clearance in mm.
  109. *
  110. * Setting name: "ExtraFillMargin"
  111. * Valid values: 0 to 1
  112. * Default value: 0.0005
  113. */
  114. double m_ExtraClearance;
  115. /**
  116. * Enable the minimum slot width check for creepage
  117. *
  118. * Setting name: "EnableCreepageSlot"
  119. * Default value: false
  120. */
  121. bool m_EnableCreepageSlot;
  122. /**
  123. * Epsilon for DRC tests.
  124. *
  125. * @note Fo zone tests this is essentially additive with #m_ExtraClearance. Units are mm.
  126. *
  127. * Setting name: "DRCEpsilon"
  128. * Valid values: 0 to 1
  129. * Default value: 0.0005
  130. */
  131. double m_DRCEpsilon;
  132. /**
  133. * Sliver width tolerance for DRC.
  134. *
  135. * Units are mm.
  136. *
  137. * Setting name: "DRCSliverWidthTolerance"
  138. * Valid values: 0.01 to 0.25
  139. * Default value: 0.08
  140. */
  141. double m_SliverWidthTolerance;
  142. /**
  143. * Sliver length tolerance for DRC.
  144. *
  145. * Units are mm.
  146. *
  147. * Setting name: "DRCSliverMinimumLength"
  148. * Valid values: 1e-9 to 10
  149. * Default value: 0.0008
  150. */
  151. double m_SliverMinimumLength;
  152. /**
  153. * Sliver angle to tolerance for DRC.
  154. *
  155. * Units are mm.
  156. *
  157. * Setting name: "DRCSliverAngleTolerance"
  158. * Valid values: 1 to 90
  159. * Default value: 20
  160. */
  161. double m_SliverAngleTolerance;
  162. /**
  163. * Dimension used to calculate the actual hole size from the finish hole size.
  164. *
  165. * @note IPC-6012 says 0.015-0.018mm; Cadence says at least 0.020mm for a Class 2 board and
  166. * at least 0.025mm for Class 3. Units are mm.
  167. *
  168. * Setting name: "HoleWallPlatingThickness"
  169. * Valid values: 1 to 90
  170. * Default value: 0.02
  171. */
  172. double m_HoleWallThickness;
  173. /**
  174. * Configure the coroutine stack size in bytes.
  175. *
  176. * @note This should be allocated in multiples of the system page size (n*4096 is generally
  177. * safe)
  178. *
  179. * Setting name: "CoroutineStackSize"
  180. * Valid values: 32 * 4096 to 4096 * 4096
  181. * Default value: 256 * 4096
  182. */
  183. int m_CoroutineStackSize;
  184. /**
  185. * The update interval the wxWidgets sends wxUpdateUIEvents to windows.
  186. *
  187. * Setting this to -1 will disable all automatic UI events. Any other
  188. * value is the number of milliseconds between events.
  189. *
  190. * @see https://docs.wxwidgets.org/3.0/classwx_update_u_i_event.html#a24daac56f682b866baac592e761ccede.
  191. *
  192. * Setting name: "UpdateUIEventInterval"
  193. * Valid values: -1 to 100000
  194. * Default value: 0
  195. */
  196. int m_UpdateUIEventInterval;
  197. /**
  198. * Show PNS router debug graphics while routing
  199. *
  200. * Setting name: "ShowRouterDebugGraphics"
  201. * Valid values: 0 or 1
  202. * Default value: 0
  203. */
  204. bool m_ShowRouterDebugGraphics;
  205. /**
  206. * Enable PNS router to dump state information for debug purpose (press `0` while routing)
  207. *
  208. * Setting name: "EnableRouterDump"
  209. * Valid values: 0 or 1
  210. * Default value: 0
  211. */
  212. bool m_EnableRouterDump;
  213. /**
  214. * Slide the zoom steps over for debugging things "up close".
  215. *
  216. * Setting name: "HyperZoom"
  217. * Valid values: 0 or 1
  218. * Default value: 0
  219. */
  220. bool m_HyperZoom;
  221. /**
  222. * Save files in compact display mode
  223. *
  224. * When set to true, this will wrap polygon point sets at 4 points per line rather
  225. * than a single point per line. Single point per line helps with version control systems.
  226. *
  227. * Setting name: "CompactSave"
  228. * Valid values: 0 or 1
  229. * Default value: 0
  230. */
  231. bool m_CompactSave;
  232. /**
  233. * Enable drawing the triangulation outlines with a visible color.
  234. *
  235. * @note This only affects the OpenGL GAL.
  236. *
  237. * Setting name: "StrokeTriangulation"
  238. * Valid values: 0 or 1
  239. * Default value: 0
  240. */
  241. bool m_DrawTriangulationOutlines;
  242. /**
  243. * When true, adds zone-display-modes for stroking the zone fracture boundaries and the zone
  244. * triangulation.
  245. *
  246. * Setting name: "ExtraZoneDisplayModes"
  247. * Valid values: 0 or 1
  248. * Default value: 0
  249. */
  250. bool m_ExtraZoneDisplayModes;
  251. /**
  252. * Absolute minimum pen width for plotting.
  253. *
  254. * @note Some formats (PDF, for example) don't like ultra-thin lines. PDF seems happy
  255. * enough with 0.0212mm which equates to 1px @ 1200dpi. Units are mm.
  256. *
  257. * Setting name: "MinPlotPenWidth"
  258. * Valid values: 0 to 1
  259. * Default value: 0.0212
  260. */
  261. double m_MinPlotPenWidth;
  262. /**
  263. * A mode that dumps the various stages of a F_Cu fill into In1_Cu through In9_Cu.
  264. *
  265. * Setting name: "DebugZoneFiller"
  266. * Valid values: 0 or 1
  267. * Default value: 0
  268. */
  269. bool m_DebugZoneFiller;
  270. /**
  271. * A mode that writes PDFs without compression.
  272. *
  273. * Setting name: "DebugPDFWriter"
  274. * Valid values: 0 or 1
  275. * Default value: 0
  276. */
  277. bool m_DebugPDFWriter;
  278. /**
  279. * The diameter of the drill marks on print and plot outputs (in mm) when the "Drill marks"
  280. * option is set to "Small mark".
  281. *
  282. * Setting name: "SmallDrillMarkSize"
  283. * Valid values: 0 to 3
  284. * Default value: 0.35
  285. */
  286. double m_SmallDrillMarkSize;
  287. /**
  288. * Enable the hotkeys dumper feature for generating documentation.
  289. *
  290. * Setting name: "HotkeysDumper"
  291. * Valid values: 0 or 1
  292. * Default value: 0
  293. */
  294. bool m_HotkeysDumper;
  295. /**
  296. * Draw GAL bounding boxes in painters.
  297. *
  298. * Setting name: "DrawBoundingBoxes"
  299. * Valid values: 0 or 1
  300. * Default value: 0
  301. */
  302. bool m_DrawBoundingBoxes;
  303. /**
  304. * Enable exporting board editor netlist to a file for troubleshooting purposes.
  305. *
  306. * Setting name: "ShowPcbnewExportNetlist"
  307. * Valid values: 0 or 1
  308. * Default value: 0
  309. */
  310. bool m_ShowPcbnewExportNetlist;
  311. /**
  312. * Skip reading/writing 3D model file caches.
  313. *
  314. * This does not prevent the models from being cached in memory meaning reopening the 3D
  315. * viewer in the same project session will not reload model data from disk again.
  316. *
  317. * Setting name: "Skip3DModelFileCache"
  318. * Valid values: 0 or 1
  319. * Default value: 0
  320. */
  321. bool m_Skip3DModelFileCache;
  322. /**
  323. * Skip reading/writing 3D model memory caches.
  324. &
  325. * This ensures 3D models are always reloaded from disk even if we previously opened the 3D
  326. * viewer.
  327. *
  328. * Setting name: "Skip3DModelMemoryCache"
  329. * Valid values: 0 or 1
  330. * Default value: 0
  331. */
  332. bool m_Skip3DModelMemoryCache;
  333. /**
  334. * Hide the build version from the KiCad manager frame title.
  335. *
  336. * Useful for making screenshots/videos of KiCad without pinning to a specific version.
  337. *
  338. * Setting name: "HideVersionFromTitle"
  339. * Valid values: 0 or 1
  340. * Default value: 0
  341. */
  342. bool m_HideVersionFromTitle;
  343. /**
  344. * Enable showing schematic repair output.
  345. *
  346. * Setting name: "ShowRepairSchematic"
  347. * Valid values: 0 or 1
  348. * Default value: 0
  349. */
  350. bool m_ShowRepairSchematic;
  351. /**
  352. * Shows debugging event counters in various places.
  353. *
  354. * Setting name: "ShowEventCounters"
  355. * Valid values: 0 or 1
  356. * Default value: 0
  357. */
  358. bool m_ShowEventCounters;
  359. /**
  360. * Allow manual scaling of canvas.
  361. *
  362. * Setting name: "AllowManualCanvasScale"
  363. * Valid values: 0 or 1
  364. * Default value: 0
  365. */
  366. bool m_AllowManualCanvasScale;
  367. /**
  368. * Set the bevel height of layer items in 3D viewer when ray tracing.
  369. *
  370. * Controls the start of curvature normal on the edge. The value is in micrometer. Good
  371. * values should be around or less than the copper thickness.
  372. *
  373. * Setting name: "V3DRT_BevelHeight_um"
  374. * Valid values: 0 to std::numeric_limits<int>::max()
  375. * Default value: 30
  376. */
  377. int m_3DRT_BevelHeight_um;
  378. /**
  379. * 3D-Viewer raytracing factor applied to Extent.z of the item layer.
  380. *
  381. * This is used for calculating the bevel's height.
  382. *
  383. * Setting name: "V3DRT_BevelExtentFactor"
  384. * Valid values: 0 to 100
  385. * Default value: 1/16
  386. */
  387. double m_3DRT_BevelExtentFactor;
  388. /**
  389. * Use the 3DConnexion Driver.
  390. *
  391. * Setting name: "3DConnexionDriver"
  392. * Valid values: 0 or 1
  393. * Default value: 1
  394. */
  395. bool m_Use3DConnexionDriver;
  396. /**
  397. * Use the new incremental netlister for realtime jobs.
  398. *
  399. * Setting name: "IncrementalConnectivity"
  400. * Valid values: 0 or 1
  401. * Default value: 1
  402. */
  403. bool m_IncrementalConnectivity;
  404. /**
  405. * The number of milliseconds to wait in a click before showing a disambiguation menu.
  406. *
  407. * Setting name: "DisambiguationTime"
  408. * Valid values: 50 or 10000
  409. * Default value: 300
  410. */
  411. int m_DisambiguationMenuDelay;
  412. /**
  413. * Enable the new Design Blocks feature
  414. *
  415. * Setting name: "EnableDesignBlocks"
  416. * Valid values: true or false
  417. * Default value: false
  418. */
  419. bool m_EnableDesignBlocks;
  420. /**
  421. * Enable support for generators.
  422. *
  423. * Setting name: "EnableGenerators"
  424. * Valid values: 0 or 1
  425. * Default value: 0
  426. */
  427. bool m_EnableGenerators;
  428. /**
  429. * Enable git integration.
  430. *
  431. * Setting name: "EnableGit"
  432. * Valid values: 0 or 1
  433. * Default value: 0
  434. */
  435. bool m_EnableGit;
  436. /**
  437. * Enable option to load lib files with text editor.
  438. *
  439. * Setting name: "EnableLibWithText"
  440. * Valid values: 0 or 1
  441. * Default value: 0
  442. */
  443. bool m_EnableLibWithText;
  444. /**
  445. * Enable option to open lib file directory.
  446. * Reveals one additional field under common preferences to set
  447. * system's file manager command in order for the context menu options to work.
  448. * On windows common settings preselect the default explorer with a hardcoded value.
  449. *
  450. * Examples,
  451. * Linux: "nemo -n %F"
  452. * "nautilus --browser %F"
  453. * "dolphin --select %F" etc
  454. * Win11: "explorer.exe /n,/select,%F"
  455. *
  456. * Setting name: "EnableLibDir"
  457. * Valid values: 0 or 1
  458. * Default value: 0
  459. */
  460. bool m_EnableLibDir;
  461. /**
  462. * Enable Eeschema printing using Cairo.
  463. *
  464. * Setting name: "EnableEeschemaPrintCairo"
  465. * Valid values: 0 or 1
  466. * Default value: 1
  467. */
  468. bool m_EnableEeschemaPrintCairo;
  469. /**
  470. * Enable Eeschema Export to clipboard using Cairo.
  471. *
  472. * Setting name: "EnableEeschemaExportClipboardCairo"
  473. * Valid values: 0 or 1
  474. * Default value: 0
  475. */
  476. bool m_EnableEeschemaExportClipboardCairo;
  477. /**
  478. * Board object selection visibility limit.
  479. *
  480. * This ratio is used to determine if an object in a selected object layer stack is
  481. * visible. All alpha ratios less or equal to this value are considered invisible
  482. * to the user and will be pruned from the list of selections. Valid values are
  483. * between 0 and less than 1. A value of 1 disables this feature. Reasonable values
  484. * are between 0.01 and 0.03 depending on the layer colors.
  485. *
  486. * Setting name: "PcbSelectionVisibilityRatio"
  487. * Valid values: 0.0 to 1.0
  488. * Default value: 1
  489. */
  490. double m_PcbSelectionVisibilityRatio;
  491. /**
  492. * Deviation between font's bezier curve ideal and the poligonized curve. This
  493. * is 1/16 of the font's internal units.
  494. *
  495. * Setting name: "FontErrorSize"
  496. * Valid values: 0.01 to 100
  497. * Default value: 2
  498. */
  499. double m_FontErrorSize;
  500. /**
  501. * OCE (STEP/IGES) 3D Plugin Tesselation Linear Deflection
  502. *
  503. * Linear deflection determines the maximum distance between the original geometry
  504. * and the tessellated representation, measured in millimeters (mm), influencing
  505. * the precision of flat surfaces.
  506. *
  507. * Setting name: "OcePluginLinearDeflection"
  508. * Valid values: 0.01 to 1.0
  509. * Default value: 0.14
  510. */
  511. double m_OcePluginLinearDeflection;
  512. /**
  513. * OCE (STEP/IGES) 3D Plugin Tesselation Angular Deflection
  514. *
  515. * Angular deflection specifies the maximum deviation angle (in degrees) between
  516. * the normals of adjacent facets in the tessellated model. Lower values result
  517. * in smoother curved surfaces by creating more facets to closely approximate
  518. * the curve.
  519. *
  520. * Setting name: "OcePluginAngularDeflection"
  521. * Valid values: 0.1 to 180
  522. * Default value: 30
  523. */
  524. double m_OcePluginAngularDeflection;
  525. /**
  526. * The number of internal units that will be allowed to deflect from the base
  527. * segment when creating a new segment.
  528. *
  529. * Setting name: "TriangulateSimplificationLevel"
  530. * Valid values: 0 to 1000
  531. * Default value: 50
  532. */
  533. int m_TriangulateSimplificationLevel;
  534. /**
  535. * The minimum area of a polygon that can be left over after triangulation and
  536. * still consider the triangulation successful. This is internal units, so
  537. * it is square nm in pcbnew.
  538. *
  539. * Setting name: "TriangulateMinimumArea"
  540. * Valid values: 0 to 100000
  541. * Default value: 1000
  542. */
  543. int m_TriangulateMinimumArea;
  544. /**
  545. * Enable the use of a cache-friendlier and therefore faster version of the
  546. * polygon fracture algorithm.
  547. *
  548. * Setting name: "EnableCacheFriendlyFracture"
  549. * Valid values: 0 or 1
  550. * Default value: 1
  551. */
  552. bool m_EnableCacheFriendlyFracture;
  553. /**
  554. * Log IPC API requests and responses
  555. *
  556. * Setting name: "EnableAPILogging"
  557. * Default value: false
  558. */
  559. bool m_EnableAPILogging;
  560. /**
  561. * Maximum number of filesystem watchers to use.
  562. *
  563. * Setting name: "MaxFilesystemWatchers"
  564. * Valid values: 0 to 2147483647
  565. * Default value: 16384
  566. */
  567. int m_MaxFilesystemWatchers;
  568. /**
  569. * Set the number of items in a schematic graph for it to be considered "minor"
  570. *
  571. * Setting name: "MinorSchematicGraphSize"
  572. * Valid values: 0 to 2147483647
  573. * Default value: 10000
  574. */
  575. int m_MinorSchematicGraphSize;
  576. /**
  577. * The number of recursions to resolve text variables.
  578. *
  579. * Setting name: "ResolveTextRecursionDepth"
  580. * Valid values: 0 to 10
  581. * Default value: 3
  582. */
  583. int m_ResolveTextRecursionDepth;
  584. /**
  585. * Enable snap anchors based on item line extensions.
  586. *
  587. * This should be removed when extension snaps are tuned up.
  588. *
  589. * Setting name: "EnableExtensionSnaps"
  590. * Default value: true
  591. */
  592. bool m_EnableExtensionSnaps;
  593. /**
  594. * If extension snaps are enabled, this is the timeout in milliseconds
  595. * before a hovered item gets extensions shown.
  596. *
  597. * This should be removed if a good value is agreed, or made configurable
  598. * if there's no universal good value.
  599. *
  600. * Setting name: "EnableExtensionSnapsMs"
  601. * Default value: 500
  602. * Valid values: >0
  603. */
  604. int m_ExtensionSnapTimeoutMs;
  605. /**
  606. * If extension snaps are enabled, 'activate' items on
  607. * hover, even if not near a snap point.
  608. *
  609. * This just to experiment with tuning. It should either
  610. * be removed or made configurable when we know what feels best.
  611. *
  612. * Setting name: "ExtensionSnapActivateOnHover"
  613. * Default value: true
  614. */
  615. bool m_ExtensionSnapActivateOnHover;
  616. /**
  617. * Enable snap anchors debug visualization.
  618. *
  619. * Setting name: "EnableSnapAnchorsDebug"
  620. * Default value: false
  621. */
  622. bool m_EnableSnapAnchorsDebug;
  623. /**
  624. * Minimum overlapping angle for which an arc is considered to be parallel
  625. * to its paired arc.
  626. *
  627. * Setting name: "MinParallelAngle"
  628. * Default value: 0.001
  629. */
  630. double m_MinParallelAngle;
  631. /**
  632. * What factor to use when painting via and PTH pad hole walls, so that
  633. * the painted hole wall can be overemphasized compared to physical reality
  634. * to make the wall easier to see on-screen.
  635. *
  636. * Setting name: "HoleWallPaintingMultiplier"
  637. * Default value: 1.5
  638. */
  639. double m_HoleWallPaintingMultiplier;
  640. /**
  641. * Default value for the maximum number of threads to use for parallel processing.
  642. * Setting this value to 0 or less will mean that we use the number of cores available
  643. *
  644. * Setting name: "MaximumThreads"
  645. * Default value: 0
  646. */
  647. int m_MaximumThreads;
  648. ///@}
  649. private:
  650. ADVANCED_CFG();
  651. /**
  652. * Load the config from the normal config file
  653. */
  654. void loadFromConfigFile();
  655. /*
  656. * Load config from the given config base
  657. */
  658. void loadSettings( wxConfigBase& aCfg );
  659. };