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.

425 lines
10 KiB

5 years ago
4 years ago
4 years ago
4 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
  5. * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software: you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation, either version 3 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef PCBNEW_SETTINGS_H_
  21. #define PCBNEW_SETTINGS_H_
  22. #include <geometry/eda_angle.h>
  23. #include <settings/app_settings.h>
  24. #include <pcb_display_options.h>
  25. namespace PNS
  26. {
  27. class ROUTING_SETTINGS;
  28. }
  29. // Settings for the CONVERT_TOOL.
  30. enum CONVERT_STRATEGY
  31. {
  32. COPY_LINEWIDTH,
  33. CENTERLINE,
  34. BOUNDING_HULL
  35. };
  36. struct CONVERT_SETTINGS
  37. {
  38. CONVERT_STRATEGY m_Strategy;
  39. int m_Gap;
  40. int m_LineWidth;
  41. bool m_DeleteOriginals;
  42. };
  43. enum class MAGNETIC_OPTIONS
  44. {
  45. NO_EFFECT = 0,
  46. CAPTURE_CURSOR_IN_TRACK_TOOL,
  47. CAPTURE_ALWAYS
  48. };
  49. struct MAGNETIC_SETTINGS
  50. {
  51. MAGNETIC_OPTIONS pads;
  52. MAGNETIC_OPTIONS tracks;
  53. bool graphics;
  54. MAGNETIC_SETTINGS() :
  55. pads( MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL ),
  56. tracks( MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL ),
  57. graphics( false )
  58. { }
  59. };
  60. enum class TRACK_DRAG_ACTION
  61. {
  62. MOVE,
  63. DRAG,
  64. DRAG_FREE_ANGLE
  65. };
  66. enum TRACK_CLEARANCE_MODE
  67. {
  68. DO_NOT_SHOW_CLEARANCE = 0,
  69. SHOW_WHILE_ROUTING,
  70. SHOW_WITH_VIA_WHILE_ROUTING,
  71. SHOW_WITH_VIA_WHILE_ROUTING_OR_DRAGGING,
  72. SHOW_WITH_VIA_ALWAYS
  73. };
  74. enum PCB_DISPLAY_ORIGIN
  75. {
  76. PCB_ORIGIN_PAGE = 0,
  77. PCB_ORIGIN_AUX,
  78. PCB_ORIGIN_GRID,
  79. };
  80. typedef std::vector<std::pair<wxString, bool>> ACTION_PLUGIN_SETTINGS_LIST;
  81. // base class to handle Pcbnew SETTINGS also used in Cvpcb
  82. class PCB_VIEWERS_SETTINGS_BASE : public APP_SETTINGS_BASE
  83. {
  84. public:
  85. struct VIEWERS_DISPLAY_OPTIONS
  86. {
  87. bool m_DisplayGraphicsFill;
  88. bool m_DisplayTextFill;
  89. bool m_DisplayPadNumbers;
  90. bool m_DisplayPadFill;
  91. };
  92. VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay;
  93. PCB_VIEWERS_SETTINGS_BASE( const std::string& aFilename, int aSchemaVersion ):
  94. APP_SETTINGS_BASE( aFilename, aSchemaVersion )
  95. {
  96. m_ViewersDisplay.m_DisplayGraphicsFill = true;
  97. m_ViewersDisplay.m_DisplayTextFill = true;
  98. m_ViewersDisplay.m_DisplayPadNumbers = true;
  99. m_ViewersDisplay.m_DisplayPadFill = true;
  100. }
  101. virtual ~PCB_VIEWERS_SETTINGS_BASE() {};
  102. };
  103. class PCBNEW_SETTINGS : public PCB_VIEWERS_SETTINGS_BASE
  104. {
  105. public:
  106. struct AUI_PANELS
  107. {
  108. int appearance_panel_tab;
  109. bool appearance_expand_layer_display;
  110. bool appearance_expand_net_display;
  111. int right_panel_width;
  112. int properties_panel_width;
  113. float properties_splitter_proportion;
  114. int search_panel_height;
  115. bool show_layer_manager;
  116. bool show_properties;
  117. bool show_search;
  118. };
  119. struct DIALOG_CLEANUP
  120. {
  121. bool cleanup_vias;
  122. bool delete_dangling_vias;
  123. bool cleanup_tracks_in_pad;
  124. bool cleanup_unconnected;
  125. bool cleanup_short_circuits;
  126. bool merge_segments;
  127. };
  128. struct DIALOG_DRC
  129. {
  130. bool refill_zones;
  131. bool test_all_track_errors;
  132. bool test_footprints;
  133. int severities;
  134. };
  135. struct DIALOG_EXPORT_IDF
  136. {
  137. bool auto_adjust;
  138. int ref_units;
  139. double ref_x;
  140. double ref_y;
  141. bool units_mils;
  142. };
  143. struct DIALOG_EXPORT_STEP
  144. {
  145. int origin_mode;
  146. int origin_units;
  147. double origin_x;
  148. double origin_y;
  149. bool no_virtual;
  150. bool replace_models;
  151. bool overwrite_file;
  152. };
  153. struct DIALOG_EXPORT_SVG
  154. {
  155. bool black_and_white;
  156. bool mirror;
  157. bool one_file;
  158. bool plot_board_edges;
  159. int page_size;
  160. wxString output_dir;
  161. std::vector<int> layers;
  162. };
  163. struct DIALOG_EXPORT_VRML
  164. {
  165. int units;
  166. bool copy_3d_models;
  167. bool use_relative_paths;
  168. int ref_units;
  169. double ref_x;
  170. double ref_y;
  171. int origin_mode;
  172. };
  173. struct DIALOG_FOOTPRINT_WIZARD_LIST
  174. {
  175. int width;
  176. int height;
  177. };
  178. struct DIALOG_GENERATE_DRILL
  179. {
  180. bool merge_pth_npth;
  181. bool minimal_header;
  182. bool mirror;
  183. bool unit_drill_is_inch;
  184. bool use_route_for_oval_holes;
  185. int drill_file_type;
  186. int map_file_type;
  187. int zeros_format;
  188. };
  189. struct DIALOG_IMPORT_GRAPHICS
  190. {
  191. int layer;
  192. bool interactive_placement;
  193. wxString last_file;
  194. double dxf_line_width;
  195. int dxf_line_width_units;
  196. int origin_units;
  197. double origin_x;
  198. double origin_y;
  199. int dxf_units;
  200. };
  201. struct DIALOG_NETLIST
  202. {
  203. int report_filter;
  204. bool update_footprints;
  205. bool delete_shorting_tracks;
  206. bool delete_extra_footprints;
  207. bool associate_by_ref_sch;
  208. };
  209. struct DIALOG_PLACE_FILE
  210. {
  211. wxString output_directory;
  212. int units;
  213. int file_options;
  214. int file_format;
  215. bool include_board_edge;
  216. bool exclude_TH;
  217. bool only_SMD;
  218. bool use_aux_origin;
  219. bool negate_xcoord;
  220. };
  221. struct DIALOG_PLOT
  222. {
  223. int all_layers_on_one_page;
  224. bool edgecut_on_all_layers;
  225. int pads_drill_mode;
  226. double fine_scale_x;
  227. double fine_scale_y;
  228. double ps_fine_width_adjust;
  229. bool check_zones_before_plotting;
  230. bool mirror;
  231. };
  232. struct DIALOG_REANNOTATE
  233. {
  234. bool sort_on_fp_location;
  235. bool remove_front_prefix;
  236. bool remove_back_prefix;
  237. bool exclude_locked;
  238. int grid_index;
  239. int sort_code;
  240. int annotation_choice;
  241. int report_severity;
  242. wxString front_refdes_start;
  243. wxString back_refdes_start;
  244. wxString front_prefix;
  245. wxString back_prefix;
  246. wxString exclude_list;
  247. wxString report_file_name;
  248. };
  249. struct FOOTPRINT_CHOOSER
  250. {
  251. int width;
  252. int height;
  253. int sash_h;
  254. int sash_v;
  255. };
  256. struct ZONES
  257. {
  258. int net_sort_mode;
  259. };
  260. struct DISPLAY_OPTIONS
  261. {
  262. // Note: Display options common to Cvpcb and Pcbnew are stored in
  263. // VIEWERS_DISPLAY_OPTIONS m_ViewersDisplay, because the section DISPLAY_OPTIONS
  264. // exists only for Pcbnew
  265. bool m_DisplayViaFill;
  266. bool m_DisplayPcbTrackFill;
  267. TRACK_CLEARANCE_MODE m_TrackClearance;
  268. bool m_PadClearance;
  269. int m_NetNames;
  270. RATSNEST_MODE m_RatsnestMode;
  271. int m_MaxLinksShowed;
  272. bool m_ShowModuleRatsnest;
  273. bool m_ShowGlobalRatsnest;
  274. bool m_DisplayRatsnestLinesCurved;
  275. PCB_DISPLAY_ORIGIN m_DisplayOrigin;
  276. bool m_DisplayInvertXAxis;
  277. bool m_DisplayInvertYAxis;
  278. bool m_Live3DRefresh;
  279. };
  280. PCBNEW_SETTINGS();
  281. virtual ~PCBNEW_SETTINGS();
  282. virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
  283. AUI_PANELS m_AuiPanels;
  284. DIALOG_CLEANUP m_Cleanup;
  285. DIALOG_DRC m_DrcDialog;
  286. DIALOG_EXPORT_IDF m_ExportIdf;
  287. DIALOG_EXPORT_STEP m_ExportStep;
  288. DIALOG_EXPORT_SVG m_ExportSvg;
  289. DIALOG_EXPORT_VRML m_ExportVrml;
  290. DIALOG_FOOTPRINT_WIZARD_LIST m_FootprintWizardList;
  291. DIALOG_GENERATE_DRILL m_GenDrill;
  292. DIALOG_IMPORT_GRAPHICS m_ImportGraphics;
  293. DIALOG_NETLIST m_NetlistDialog;
  294. DIALOG_PLACE_FILE m_PlaceFile;
  295. DIALOG_PLOT m_Plot;
  296. DIALOG_REANNOTATE m_Reannotate;
  297. FOOTPRINT_CHOOSER m_FootprintChooser;
  298. ZONES m_Zones;
  299. WINDOW_SETTINGS m_FootprintViewer;
  300. WINDOW_SETTINGS m_FootprintWizard;
  301. DISPLAY_OPTIONS m_Display;
  302. MAGNETIC_SETTINGS m_MagneticItems;
  303. TRACK_DRAG_ACTION m_TrackDragAction;
  304. ARC_EDIT_MODE m_ArcEditMode;
  305. bool m_CtrlClickHighlight;
  306. bool m_Use45DegreeLimit; // True to constrain tool actions to horizontal,
  307. // vertical and 45deg
  308. bool m_FlipLeftRight; // True: Flip footprints across Y axis
  309. bool m_ESCClearsNetHighlight;
  310. bool m_PolarCoords;
  311. EDA_ANGLE m_RotationAngle;
  312. bool m_ShowPageLimits;
  313. bool m_ShowCourtyardCollisions;
  314. ///<@todo Implement real auto zone filling (not just after zone properties are edited)
  315. bool m_AutoRefillZones; // Fill zones after editing the zone using the Zone Properties dialog
  316. bool m_AllowFreePads; // True: unlocked pads can be moved freely with respect to the footprint.
  317. // False (default): all pads are treated as locked for the purposes of
  318. // movement and any attempt to move them will move the footprint instead.
  319. wxString m_FootprintTextShownColumns;
  320. std::unique_ptr<PNS::ROUTING_SETTINGS> m_PnsSettings;
  321. double m_FootprintViewerZoom; ///< The last zoom level used (0 for auto)
  322. bool m_FootprintViewerAutoZoomOnSelect; ///< true to use automatic zoom on fp selection
  323. int m_FootprintViewerLibListWidth;
  324. int m_FootprintViewerFPListWidth;
  325. wxString m_lastFootprintLibDir;
  326. wxString m_lastFootprint3dDir;
  327. ACTION_PLUGIN_SETTINGS_LIST m_VisibleActionPlugins;
  328. protected:
  329. virtual std::string getLegacyFrameName() const override { return "PcbFrame"; }
  330. };
  331. #endif