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 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 
21 #ifndef PCBNEW_SETTINGS_H_
22 #define PCBNEW_SETTINGS_H_
23 
24 #include <settings/app_settings.h>
25 #include <pcb_display_options.h>
26 
27 namespace PNS
28 {
29     class ROUTING_SETTINGS;
30 }
31 
32 enum class MAGNETIC_OPTIONS
33 {
34     NO_EFFECT = 0,
35     CAPTURE_CURSOR_IN_TRACK_TOOL,
36     CAPTURE_ALWAYS
37 };
38 
39 struct MAGNETIC_SETTINGS
40 {
41     MAGNETIC_OPTIONS pads;
42     MAGNETIC_OPTIONS tracks;
43     bool             graphics;
44 
MAGNETIC_SETTINGSMAGNETIC_SETTINGS45     MAGNETIC_SETTINGS()
46             : pads( MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL ),
47               tracks( MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL ),
48               graphics( false )
49     {
50     }
51 };
52 
53 enum class TRACK_DRAG_ACTION
54 {
55     MOVE,
56     DRAG,
57     DRAG_FREE_ANGLE
58 };
59 
60 typedef std::vector<std::pair<wxString, bool>> ACTION_PLUGIN_SETTINGS_LIST;
61 
62 
63 class PCBNEW_SETTINGS : public APP_SETTINGS_BASE
64 {
65 public:
66     struct AUI_PANELS
67     {
68         int  appearance_panel_tab;
69         int  right_panel_width;
70         bool show_layer_manager;
71     };
72 
73     struct DIALOG_CLEANUP
74     {
75         bool cleanup_vias;
76         bool delete_dangling_vias;
77         bool cleanup_tracks_in_pad;
78         bool cleanup_unconnected;
79         bool cleanup_short_circuits;
80         bool merge_segments;
81     };
82 
83     struct DIALOG_DRC
84     {
85         bool refill_zones;
86         bool test_all_track_errors;
87         bool test_footprints;
88         int  severities;
89     };
90 
91     struct DIALOG_EXPORT_IDF
92     {
93         bool   auto_adjust;
94         int    ref_units;
95         double ref_x;
96         double ref_y;
97         bool   units_mils;
98     };
99 
100     struct DIALOG_EXPORT_STEP
101     {
102         int    origin_mode;
103         int    origin_units;
104         double origin_x;
105         double origin_y;
106         bool   no_virtual;
107         bool   replace_models;
108         bool   overwrite_file;
109     };
110 
111     struct DIALOG_EXPORT_SVG
112     {
113         bool             black_and_white;
114         bool             mirror;
115         bool             one_file;
116         bool             plot_board_edges;
117         int              page_size;
118         wxString         output_dir;
119         std::vector<int> layers;
120     };
121 
122     struct DIALOG_EXPORT_VRML
123     {
124         int    units;
125         bool   copy_3d_models;
126         bool   use_relative_paths;
127         int    ref_units;
128         double ref_x;
129         double ref_y;
130         int    origin_mode;
131     };
132 
133     struct DIALOG_FOOTPRINT_WIZARD_LIST
134     {
135         int width;
136         int height;
137     };
138 
139     struct DIALOG_GENERATE_DRILL
140     {
141         bool merge_pth_npth;
142         bool minimal_header;
143         bool mirror;
144         bool unit_drill_is_inch;
145         bool use_route_for_oval_holes;
146         int  drill_file_type;
147         int  map_file_type;
148         int  zeros_format;
149     };
150 
151     struct DIALOG_IMPORT_GRAPHICS
152     {
153         int         layer;
154         bool        interactive_placement;
155         wxString    last_file;
156         double      line_width;
157         int         line_width_units;
158         int         origin_units;
159         double      origin_x;
160         double      origin_y;
161         int         dxf_units;
162     };
163 
164     struct DIALOG_NETLIST
165     {
166         int  report_filter;
167         bool update_footprints;
168         bool delete_shorting_tracks;
169         bool delete_extra_footprints;
170         bool associate_by_ref_sch;
171     };
172 
173     struct DIALOG_PLACE_FILE
174     {
175         int  units;
176         int  file_options;
177         int  file_format;
178         bool include_board_edge;
179         bool use_aux_origin;
180     };
181 
182     struct DIALOG_PLOT
183     {
184         int    all_layers_on_one_page;
185         int    pads_drill_mode;
186         double fine_scale_x;
187         double fine_scale_y;
188         double ps_fine_width_adjust;
189         bool   check_zones_before_plotting;
190         bool   mirror;
191     };
192 
193     struct DIALOG_REANNOTATE
194     {
195         bool     sort_on_fp_location;
196         bool     remove_front_prefix;
197         bool     remove_back_prefix;
198         bool     exclude_locked;
199         int      grid_index;
200         int      sort_code;
201         int      annotation_choice;
202         int      report_severity;
203         wxString front_refdes_start;
204         wxString back_refdes_start;
205         wxString front_prefix;
206         wxString back_prefix;
207         wxString exclude_list;
208         wxString report_file_name;
209     };
210 
211     struct FOOTPRINT_CHOOSER
212     {
213         int width;
214         int height;
215         int sash_h;
216         int sash_v;
217     };
218 
219     struct ZONES
220     {
221         int         hatching_style;
222         int         net_sort_mode;
223         double      clearance;
224         double      min_thickness;
225         double      thermal_relief_gap;
226         double      thermal_relief_copper_width;
227     };
228 
229     PCBNEW_SETTINGS();
230 
231     virtual ~PCBNEW_SETTINGS();
232 
233     virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
234 
235     AUI_PANELS m_AuiPanels;
236 
237     DIALOG_CLEANUP m_Cleanup;
238 
239     DIALOG_DRC m_DrcDialog;
240 
241     DIALOG_EXPORT_IDF m_ExportIdf;
242 
243     DIALOG_EXPORT_STEP m_ExportStep;
244 
245     DIALOG_EXPORT_SVG m_ExportSvg;
246 
247     DIALOG_EXPORT_VRML m_ExportVrml;
248 
249     DIALOG_FOOTPRINT_WIZARD_LIST m_FootprintWizardList;
250 
251     DIALOG_GENERATE_DRILL m_GenDrill;
252 
253     DIALOG_IMPORT_GRAPHICS m_ImportGraphics;
254 
255     DIALOG_NETLIST m_NetlistDialog;
256 
257     DIALOG_PLACE_FILE m_PlaceFile;
258 
259     DIALOG_PLOT m_Plot;
260 
261     DIALOG_REANNOTATE m_Reannotate;
262 
263     FOOTPRINT_CHOOSER m_FootprintChooser;
264 
265     ZONES m_Zones;
266 
267     WINDOW_SETTINGS m_FootprintViewer;
268 
269     WINDOW_SETTINGS m_FootprintWizard;
270 
271     PCB_DISPLAY_OPTIONS m_Display;
272 
273     MAGNETIC_SETTINGS m_MagneticItems;
274 
275     TRACK_DRAG_ACTION m_TrackDragAction;
276 
277     bool m_PcbUse45DegreeLimit;         // True to constrain tool actions to horizontal,
278                                         // vertical and 45deg in board editor
279     bool m_FpeditUse45DegreeLimit;      // True to constrain tool actions to horizontal,
280                                         // vertical and 45deg in footprint editor
281     bool m_FlipLeftRight;               // True: Flip footprints across Y axis
282     // False: Flip footprints across X axis
283 
284     bool m_PolarCoords;
285 
286     int m_RotationAngle;
287 
288     bool m_ShowPageLimits;
289 
290     ///<@todo Implement real auto zone filling (not just after zone properties are edited)
291     bool m_AutoRefillZones; // Fill zones after editing the zone using the Zone Properties dialog
292 
293     bool m_AllowFreePads; // True: unlocked pads can be moved freely with respect to the footprint.
294                           // False (default): all pads are treated as locked for the purposes of
295                           // movement and any attempt to move them will move the footprint instead.
296 
297     wxString m_FootprintTextShownColumns;
298 
299     std::unique_ptr<PNS::ROUTING_SETTINGS> m_PnsSettings;
300 
301     double m_FootprintViewerZoom;       ///< The last zoom level used (0 for auto)
302 
303     wxString m_lastFootprintLibDir;
304 
305     wxString m_lastFootprint3dDir;
306 
307     ACTION_PLUGIN_SETTINGS_LIST m_VisibleActionPlugins;
308 
309 protected:
310 
getLegacyFrameName()311     virtual std::string getLegacyFrameName() const override { return "PcbFrame"; }
312 
313 };
314 
315 #endif
316