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.

627 lines
18 KiB

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