Merged in davidrobertson/flatcam/extract-prefs-code-from-app-class (pull request #306)

Extract prefs code from app class
This commit is contained in:
David Robertson 2020-04-29 06:05:44 +00:00 committed by Marius Stanciu
commit ce9c80c004
47 changed files with 2200 additions and 2323 deletions

File diff suppressed because it is too large Load Diff

View File

@ -270,7 +270,7 @@ class BookmarkManager(QtWidgets.QWidget):
self.build_bm_ui() self.build_bm_ui()
def on_export_bookmarks(self): def on_export_bookmarks(self):
self.app.report_usage("on_export_bookmarks") self.app.defaults.report_usage("on_export_bookmarks")
self.app.log.debug("on_export_bookmarks()") self.app.log.debug("on_export_bookmarks()")
date = str(datetime.today()).rpartition('.')[0] date = str(datetime.today()).rpartition('.')[0]

View File

@ -31,8 +31,7 @@ class GracefulException(Exception):
class LoudDict(dict): class LoudDict(dict):
""" """
A Dictionary with a callback for A Dictionary with a callback for item changes.
item changes.
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -41,8 +40,7 @@ class LoudDict(dict):
def __setitem__(self, key, value): def __setitem__(self, key, value):
""" """
Overridden __setitem__ method. Will emit 'changed(QString)' Overridden __setitem__ method. Will emit 'changed(QString)' if the item was changed, with key as parameter.
if the item was changed, with key as parameter.
""" """
if key in self and self.__getitem__(key) == value: if key in self and self.__getitem__(key) == value:
return return

View File

@ -642,7 +642,7 @@ class ToolsDB(QtWidgets.QWidget):
self.app.inform.emit('[success] %s' % _("Tool removed from Tools DB.")) self.app.inform.emit('[success] %s' % _("Tool removed from Tools DB."))
def on_export_tools_db_file(self): def on_export_tools_db_file(self):
self.app.report_usage("on_export_tools_db_file") self.app.defaults.report_usage("on_export_tools_db_file")
self.app.log.debug("on_export_tools_db_file()") self.app.log.debug("on_export_tools_db_file()")
date = str(datetime.today()).rpartition('.')[0] date = str(datetime.today()).rpartition('.')[0]
@ -699,7 +699,7 @@ class ToolsDB(QtWidgets.QWidget):
self.app.inform.emit('[success] %s: %s' % (_("Exported Tools DB to"), filename)) self.app.inform.emit('[success] %s: %s' % (_("Exported Tools DB to"), filename))
def on_import_tools_db_file(self): def on_import_tools_db_file(self):
self.app.report_usage("on_import_tools_db_file") self.app.defaults.report_usage("on_import_tools_db_file")
self.app.log.debug("on_import_tools_db_file()") self.app.log.debug("on_import_tools_db_file()")
filter__ = "Text File (*.TXT);;All Files (*.*)" filter__ = "Text File (*.TXT);;All Files (*.*)"
@ -2072,7 +2072,7 @@ class ToolsDB2(QtWidgets.QWidget):
self.app.inform.emit('[success] %s' % _("Tool removed from Tools DB.")) self.app.inform.emit('[success] %s' % _("Tool removed from Tools DB."))
def on_export_tools_db_file(self): def on_export_tools_db_file(self):
self.app.report_usage("on_export_tools_db_file") self.app.defaults.report_usage("on_export_tools_db_file")
self.app.log.debug("on_export_tools_db_file()") self.app.log.debug("on_export_tools_db_file()")
date = str(datetime.today()).rpartition('.')[0] date = str(datetime.today()).rpartition('.')[0]
@ -2129,7 +2129,7 @@ class ToolsDB2(QtWidgets.QWidget):
self.app.inform.emit('[success] %s: %s' % (_("Exported Tools DB to"), filename)) self.app.inform.emit('[success] %s: %s' % (_("Exported Tools DB to"), filename))
def on_import_tools_db_file(self): def on_import_tools_db_file(self):
self.app.report_usage("on_import_tools_db_file") self.app.defaults.report_usage("on_import_tools_db_file")
self.app.log.debug("on_import_tools_db_file()") self.app.log.debug("on_import_tools_db_file()")
filter__ = "Text File (*.TXT);;All Files (*.*)" filter__ = "Text File (*.TXT);;All Files (*.*)"

View File

@ -207,6 +207,6 @@ def restart_program(app, ask=None):
if response == bt_yes: if response == bt_yes:
app.on_file_saveprojectas(use_thread=True, quit_action=True) app.on_file_saveprojectas(use_thread=True, quit_action=True)
app.save_defaults() app.preferencesUiManager.save_defaults()
python = sys.executable python = sys.executable
os.execl(python, python, *sys.argv) os.execl(python, python, *sys.argv)

846
defaults.py Normal file
View File

@ -0,0 +1,846 @@
import os
import stat
import sys
from copy import deepcopy
from FlatCAMCommon import LoudDict
from camlib import to_dict, CNCjob, Geometry
import simplejson
import logging
import gettext
import FlatCAMTranslation as fcTranslate
import builtins
from flatcamParsers.ParseExcellon import Excellon
from flatcamParsers.ParseGerber import Gerber
fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__:
_ = gettext.gettext
log = logging.getLogger('FlatCAMDefaults')
class FlatCAMDefaults:
factory_defaults = {
# Global APP Preferences
"decimals_inch": 4,
"decimals_metric": 4,
"version": 8.992, # defaults format version, not necessarily equal to app version
"first_run": True,
"units": "MM",
"global_serial": 0,
"global_stats": dict(),
"global_tabs_detachable": True,
"global_jump_ref": 'abs',
"global_locate_pt": 'bl',
"global_tpdf_tmargin": 15.0,
"global_tpdf_bmargin": 10.0,
"global_tpdf_lmargin": 20.0,
"global_tpdf_rmargin": 20.0,
"global_autosave": False,
"global_autosave_timeout": 300000,
# General
"global_graphic_engine": '3D',
"global_app_level": 'b',
"global_portable": False,
"global_language": 'English',
"global_version_check": True,
"global_send_stats": True,
"global_pan_button": '2',
"global_mselect_key": 'Control',
"global_project_at_startup": False,
"global_systray_icon": True,
"global_project_autohide": True,
"global_toggle_tooltips": True,
"global_worker_number": 2,
"global_tolerance": 0.005,
"global_open_style": True,
"global_delete_confirmation": True,
"global_compression_level": 3,
"global_save_compressed": True,
"global_machinist_setting": False,
# Global GUI Preferences
"global_gridx": 1.0,
"global_gridy": 1.0,
"global_snap_max": 0.05,
"global_workspace": False,
"global_workspaceT": "A4",
"global_workspace_orientation": 'p',
"global_grid_context_menu": {
'in': [0.01, 0.02, 0.025, 0.05, 0.1],
'mm': [0.1, 0.2, 0.5, 1, 2.54]
},
"global_sel_fill": '#a5a5ffbf',
"global_sel_line": '#0000ffbf',
"global_alt_sel_fill": '#BBF268BF',
"global_alt_sel_line": '#006E20BF',
"global_draw_color": '#FF0000',
"global_sel_draw_color": '#0000FF',
"global_proj_item_color": '#000000',
"global_proj_item_dis_color": '#b7b7cb',
"global_activity_icon": 'Ball green',
"global_toolbar_view": 511,
"global_background_timeout": 300000, # Default value is 5 minutes
"global_verbose_error_level": 0, # Shell verbosity 0 = default
# (python trace only for unknown errors),
# 1 = show trace(show trace always),
# 2 = (For the future).
# Persistence
"global_last_folder": None,
"global_last_save_folder": None,
# Default window geometry
"global_def_win_x": 100,
"global_def_win_y": 100,
"global_def_win_w": 1024,
"global_def_win_h": 650,
"global_def_notebook_width": 1,
# Constants...
"global_defaults_save_period_ms": 20000, # Time between default saves.
"global_shell_shape": [500, 300], # Shape of the shell in pixels.
"global_shell_at_startup": False, # Show the shell at startup.
"global_recent_limit": 10, # Max. items in recent list.
"global_bookmarks": dict(),
"global_bookmarks_limit": 10,
"fit_key": 'V',
"zoom_out_key": '-',
"zoom_in_key": '=',
"grid_toggle_key": 'G',
"global_zoom_ratio": 1.5,
"global_point_clipboard_format": "(%.*f, %.*f)",
"global_zdownrate": None,
"global_tcl_path": '',
# General GUI Settings
"global_theme": 'white',
"global_gray_icons": False,
"global_hover": False,
"global_selection_shape": True,
"global_layout": "compact",
"global_cursor_type": "small",
"global_cursor_size": 20,
"global_cursor_width": 2,
"global_cursor_color": '#FF0000',
"global_cursor_color_enabled": True,
# Gerber General
"gerber_plot": True,
"gerber_solid": True,
"gerber_multicolored": False,
"gerber_circle_steps": 64,
"gerber_use_buffer_for_union": True,
"gerber_clean_apertures": True,
"gerber_extra_buffering": True,
"gerber_plot_fill": '#BBF268BF',
"gerber_plot_line": '#006E20BF',
"gerber_def_units": 'IN',
"gerber_def_zeros": 'L',
"gerber_save_filters": "Gerber File .gbr (*.gbr);;Gerber File .bot (*.bot);;Gerber File .bsm (*.bsm);;"
"Gerber File .cmp (*.cmp);;Gerber File .crc (*.crc);;Gerber File .crs (*.crs);;"
"Gerber File .gb0 (*.gb0);;Gerber File .gb1 (*.gb1);;Gerber File .gb2 (*.gb2);;"
"Gerber File .gb3 (*.gb3);;Gerber File .gb4 (*.gb4);;Gerber File .gb5 (*.gb5);;"
"Gerber File .gb6 (*.gb6);;Gerber File .gb7 (*.gb7);;Gerber File .gb8 (*.gb8);;"
"Gerber File .gb9 (*.gb9);;Gerber File .gbd (*.gbd);;Gerber File .gbl (*.gbl);;"
"Gerber File .gbo (*.gbo);;Gerber File .gbp (*.gbp);;Gerber File .gbs (*.gbs);;"
"Gerber File .gdo (*.gdo);;Gerber File .ger (*.ger);;Gerber File .gko (*.gko);;"
"Gerber File .gm1 (*.gm1);;Gerber File .gm2 (*.gm2);;Gerber File .gm3 (*.gm3);;"
"Gerber File .grb (*.grb);;Gerber File .gtl (*.gtl);;Gerber File .gto (*.gto);;"
"Gerber File .gtp (*.gtp);;Gerber File .gts (*.gts);;Gerber File .ly15 (*.ly15);;"
"Gerber File .ly2 (*.ly2);;Gerber File .mil (*.mil);;"
"Gerber File .outline (*.outline);;Gerber File .pho (*.pho);;"
"Gerber File .plc (*.plc);;Gerber File .pls (*.pls);;Gerber File .smb (*.smb);;"
"Gerber File .smt (*.smt);;Gerber File .sol (*.sol);;Gerber File .spb (*.spb);;"
"Gerber File .spt (*.spt);;Gerber File .ssb (*.ssb);;Gerber File .sst (*.sst);;"
"Gerber File .stc (*.stc);;Gerber File .sts (*.sts);;Gerber File .top (*.top);;"
"Gerber File .tsm (*.tsm);;Gerber File .art (*.art)"
"All Files (*.*)",
# Gerber Options
"gerber_isotooldia": 0.1,
"gerber_isopasses": 1,
"gerber_isooverlap": 10,
"gerber_milling_type": "cl",
"gerber_combine_passes": False,
"gerber_iso_scope": 'all',
"gerber_noncoppermargin": 0.1,
"gerber_noncopperrounded": False,
"gerber_bboxmargin": 0.1,
"gerber_bboxrounded": False,
# Gerber Advanced Options
"gerber_aperture_display": False,
"gerber_aperture_scale_factor": 1.0,
"gerber_aperture_buffer_factor": 0.0,
"gerber_follow": False,
"gerber_tool_type": 'circular',
"gerber_vtipdia": 0.1,
"gerber_vtipangle": 30,
"gerber_vcutz": -0.05,
"gerber_iso_type": "full",
"gerber_buffering": "full",
"gerber_simplification": False,
"gerber_simp_tolerance": 0.0005,
# Gerber Export
"gerber_exp_units": 'IN',
"gerber_exp_integer": 2,
"gerber_exp_decimals": 4,
"gerber_exp_zeros": 'L',
# Gerber Editor
"gerber_editor_sel_limit": 30,
"gerber_editor_newcode": 10,
"gerber_editor_newsize": 0.8,
"gerber_editor_newtype": 'C',
"gerber_editor_newdim": "0.5, 0.5",
"gerber_editor_array_size": 5,
"gerber_editor_lin_axis": 'X',
"gerber_editor_lin_pitch": 0.1,
"gerber_editor_lin_angle": 0.0,
"gerber_editor_circ_dir": 'CW',
"gerber_editor_circ_angle": 0.0,
"gerber_editor_scale_f": 1.0,
"gerber_editor_buff_f": 0.1,
"gerber_editor_ma_low": 0.0,
"gerber_editor_ma_high": 1.0,
# Excellon General
"excellon_plot": True,
"excellon_solid": True,
"excellon_format_upper_in": 2,
"excellon_format_lower_in": 4,
"excellon_format_upper_mm": 3,
"excellon_format_lower_mm": 3,
"excellon_zeros": "L",
"excellon_units": "INCH",
"excellon_update": True,
"excellon_optimization_type": 'B',
"excellon_search_time": 3,
"excellon_save_filters": "Excellon File .txt (*.txt);;Excellon File .drd (*.drd);;"
"Excellon File .drill (*.drill);;"
"Excellon File .drl (*.drl);;Excellon File .exc (*.exc);;"
"Excellon File .ncd (*.ncd);;Excellon File .tap (*.tap);;"
"Excellon File .xln (*.xln);;All Files (*.*)",
"excellon_plot_fill": '#C40000BF',
"excellon_plot_line": '#750000BF',
# Excellon Options
"excellon_operation": "drill",
"excellon_milling_type": "drills",
"excellon_milling_dia": 0.8,
"excellon_cutz": -1.7,
"excellon_multidepth": False,
"excellon_depthperpass": 0.7,
"excellon_travelz": 2,
"excellon_endz": 0.5,
"excellon_endxy": None,
"excellon_feedrate_z": 300,
"excellon_spindlespeed": 0,
"excellon_dwell": False,
"excellon_dwelltime": 1,
"excellon_toolchange": False,
"excellon_toolchangez": 15,
"excellon_ppname_e": 'default',
"excellon_tooldia": 0.8,
"excellon_slot_tooldia": 1.8,
"excellon_gcode_type": "drills",
# Excellon Advanced Options
"excellon_offset": 0.0,
"excellon_toolchangexy": "0.0, 0.0",
"excellon_startz": None,
"excellon_feedrate_rapid": 1500,
"excellon_z_pdepth": -0.02,
"excellon_feedrate_probe": 75,
"excellon_spindledir": 'CW',
"excellon_f_plunge": False,
"excellon_f_retract": False,
# Excellon Export
"excellon_exp_units": 'INCH',
"excellon_exp_format": 'ndec',
"excellon_exp_integer": 2,
"excellon_exp_decimals": 4,
"excellon_exp_zeros": 'LZ',
"excellon_exp_slot_type": 'routing',
# Excellon Editor
"excellon_editor_sel_limit": 30,
"excellon_editor_newdia": 1.0,
"excellon_editor_array_size": 5,
"excellon_editor_lin_dir": 'X',
"excellon_editor_lin_pitch": 2.54,
"excellon_editor_lin_angle": 0.0,
"excellon_editor_circ_dir": 'CW',
"excellon_editor_circ_angle": 12,
# Excellon Slots
"excellon_editor_slot_direction": 'X',
"excellon_editor_slot_angle": 0.0,
"excellon_editor_slot_length": 5.0,
# Excellon Slot Array
"excellon_editor_slot_array_size": 5,
"excellon_editor_slot_lin_dir": 'X',
"excellon_editor_slot_lin_pitch": 2.54,
"excellon_editor_slot_lin_angle": 0.0,
"excellon_editor_slot_circ_dir": 'CW',
"excellon_editor_slot_circ_angle": 0.0,
# Geometry General
"geometry_plot": True,
"geometry_circle_steps": 64,
"geometry_cnctooldia": "2.4",
"geometry_plot_line": "#FF0000",
# Geometry Options
"geometry_cutz": -2.4,
"geometry_vtipdia": 0.1,
"geometry_vtipangle": 30,
"geometry_multidepth": False,
"geometry_depthperpass": 0.8,
"geometry_travelz": 2,
"geometry_toolchange": False,
"geometry_toolchangez": 15.0,
"geometry_endz": 15.0,
"geometry_endxy": None,
"geometry_feedrate": 120,
"geometry_feedrate_z": 60,
"geometry_spindlespeed": 0,
"geometry_dwell": False,
"geometry_dwelltime": 1,
"geometry_ppname_g": 'default',
# Geometry Advanced Options
"geometry_toolchangexy": "0.0, 0.0",
"geometry_startz": None,
"geometry_feedrate_rapid": 1500,
"geometry_extracut": False,
"geometry_extracut_length": 0.1,
"geometry_z_pdepth": -0.02,
"geometry_f_plunge": False,
"geometry_spindledir": 'CW',
"geometry_feedrate_probe": 75,
"geometry_segx": 0.0,
"geometry_segy": 0.0,
# Geometry Editor
"geometry_editor_sel_limit": 30,
"geometry_editor_milling_type": "cl",
# CNC Job General
"cncjob_plot": True,
"cncjob_plot_kind": 'all',
"cncjob_annotation": True,
"cncjob_tooldia": 1.0,
"cncjob_coords_type": "G90",
"cncjob_coords_decimals": 4,
"cncjob_fr_decimals": 2,
"cncjob_steps_per_circle": 64,
"cncjob_footer": False,
"cncjob_line_ending": False,
"cncjob_save_filters": "G-Code Files .nc (*.nc);;G-Code Files .din (*.din);;G-Code Files .dnc (*.dnc);;"
"G-Code Files .ecs (*.ecs);;G-Code Files .eia (*.eia);;G-Code Files .fan (*.fan);;"
"G-Code Files .fgc (*.fgc);;G-Code Files .fnc (*.fnc);;G-Code Files . gc (*.gc);;"
"G-Code Files .gcd (*.gcd);;G-Code Files .gcode (*.gcode);;G-Code Files .h (*.h);;"
"G-Code Files .hnc (*.hnc);;G-Code Files .i (*.i);;G-Code Files .min (*.min);;"
"G-Code Files .mpf (*.mpf);;G-Code Files .mpr (*.mpr);;G-Code Files .cnc (*.cnc);;"
"G-Code Files .ncc (*.ncc);;G-Code Files .ncg (*.ncg);;G-Code Files .ncp (*.ncp);;"
"G-Code Files .ngc (*.ngc);;G-Code Files .out (*.out);;G-Code Files .ply (*.ply);;"
"G-Code Files .sbp (*.sbp);;G-Code Files .tap (*.tap);;G-Code Files .xpi (*.xpi);;"
"All Files (*.*)",
"cncjob_plot_line": '#4650BDFF',
"cncjob_plot_fill": '#5E6CFFFF',
"cncjob_travel_line": '#B5AB3A4C',
"cncjob_travel_fill": '#F0E24D4C',
# CNC Job Options
"cncjob_prepend": "",
"cncjob_append": "",
# CNC Job Advanced Options
"cncjob_toolchange_macro": "",
"cncjob_toolchange_macro_enable": False,
"cncjob_annotation_fontsize": 9,
"cncjob_annotation_fontcolor": '#990000',
# NCC Tool
"tools_ncctools": "1.0, 0.5",
"tools_nccorder": 'rev',
"tools_nccoperation": 'clear',
"tools_nccoverlap": 40,
"tools_nccmargin": 1.0,
"tools_nccmethod": _("Seed"),
"tools_nccconnect": True,
"tools_ncccontour": True,
"tools_nccrest": False,
"tools_ncc_offset_choice": False,
"tools_ncc_offset_value": 0.0000,
"tools_nccref": _('Itself'),
"tools_ncc_area_shape": "square",
"tools_ncc_plotting": 'normal',
"tools_nccmilling_type": 'cl',
"tools_ncctool_type": 'C1',
"tools_ncccutz": -0.05,
"tools_ncctipdia": 0.1,
"tools_ncctipangle": 30,
"tools_nccnewdia": 0.1,
# Cutout Tool
"tools_cutouttooldia": 2.4,
"tools_cutoutkind": "single",
"tools_cutoutmargin": 0.1,
"tools_cutout_z": -1.8,
"tools_cutout_depthperpass": 0.6,
"tools_cutout_mdepth": True,
"tools_cutoutgapsize": 4,
"tools_gaps_ff": "4",
"tools_cutout_convexshape": False,
# Paint Tool
"tools_painttooldia": 0.3,
"tools_paintorder": 'rev',
"tools_paintoverlap": 20,
"tools_paintmargin": 0.0,
"tools_paintmethod": _("Seed"),
"tools_selectmethod": _("All Polygons"),
"tools_paint_area_shape": "square",
"tools_pathconnect": True,
"tools_paintcontour": True,
"tools_paint_plotting": 'normal',
"tools_paintrest": False,
"tools_painttool_type": 'C1',
"tools_paintcutz": -0.05,
"tools_painttipdia": 0.1,
"tools_painttipangle": 30,
"tools_paintnewdia": 0.1,
# 2-Sided Tool
"tools_2sided_mirror_axis": "X",
"tools_2sided_axis_loc": "point",
"tools_2sided_drilldia": 3.125,
"tools_2sided_allign_axis": "X",
# Film Tool
"tools_film_type": 'neg',
"tools_film_boundary": 1.0,
"tools_film_scale_stroke": 0,
"tools_film_color": '#000000',
"tools_film_scale_cb": False,
"tools_film_scale_x_entry": 1.0,
"tools_film_scale_y_entry": 1.0,
"tools_film_skew_cb": False,
"tools_film_skew_x_entry": 0.0,
"tools_film_skew_y_entry": 0.0,
"tools_film_skew_ref_radio": 'bottomleft',
"tools_film_mirror_cb": False,
"tools_film_mirror_axis_radio": 'none',
"tools_film_file_type_radio": 'svg',
"tools_film_orientation": 'p',
"tools_film_pagesize": 'A4',
# Panel Tool
"tools_panelize_spacing_columns": 0,
"tools_panelize_spacing_rows": 0,
"tools_panelize_columns": 1,
"tools_panelize_rows": 1,
"tools_panelize_constrain": False,
"tools_panelize_constrainx": 200.0,
"tools_panelize_constrainy": 290.0,
"tools_panelize_panel_type": 'gerber',
# Calculators Tool
"tools_calc_vshape_tip_dia": 0.2,
"tools_calc_vshape_tip_angle": 30,
"tools_calc_vshape_cut_z": 0.05,
"tools_calc_electro_length": 10.0,
"tools_calc_electro_width": 10.0,
"tools_calc_electro_cdensity": 13.0,
"tools_calc_electro_growth": 10.0,
# Transform Tool
"tools_transform_rotate": 90,
"tools_transform_skew_x": 0.0,
"tools_transform_skew_y": 0.0,
"tools_transform_scale_x": 1.0,
"tools_transform_scale_y": 1.0,
"tools_transform_scale_link": True,
"tools_transform_scale_reference": True,
"tools_transform_offset_x": 0.0,
"tools_transform_offset_y": 0.0,
"tools_transform_mirror_reference": False,
"tools_transform_mirror_point": (0, 0),
"tools_transform_buffer_dis": 0.0,
"tools_transform_buffer_factor": 100.0,
"tools_transform_buffer_corner": True,
# SolderPaste Tool
"tools_solderpaste_tools": "1.0, 0.3",
"tools_solderpaste_new": 0.3,
"tools_solderpaste_z_start": 0.05,
"tools_solderpaste_z_dispense": 0.1,
"tools_solderpaste_z_stop": 0.05,
"tools_solderpaste_z_travel": 0.1,
"tools_solderpaste_z_toolchange": 1.0,
"tools_solderpaste_xy_toolchange": "0.0, 0.0",
"tools_solderpaste_frxy": 150,
"tools_solderpaste_frz": 150,
"tools_solderpaste_frz_dispense": 1.0,
"tools_solderpaste_speedfwd": 300,
"tools_solderpaste_dwellfwd": 1,
"tools_solderpaste_speedrev": 200,
"tools_solderpaste_dwellrev": 1,
"tools_solderpaste_pp": 'Paste_1',
# Subtract Tool
"tools_sub_close_paths": True,
# Distance Tool
"tools_dist_snap_center": False,
# ########################################################################################################
# ################################ TOOLS 2 ###############################################################
# ########################################################################################################
# Optimal Tool
"tools_opt_precision": 4,
# Check Rules Tool
"tools_cr_trace_size": True,
"tools_cr_trace_size_val": 0.25,
"tools_cr_c2c": True,
"tools_cr_c2c_val": 0.25,
"tools_cr_c2o": True,
"tools_cr_c2o_val": 1.0,
"tools_cr_s2s": True,
"tools_cr_s2s_val": 0.25,
"tools_cr_s2sm": True,
"tools_cr_s2sm_val": 0.25,
"tools_cr_s2o": True,
"tools_cr_s2o_val": 1.0,
"tools_cr_sm2sm": True,
"tools_cr_sm2sm_val": 0.25,
"tools_cr_ri": True,
"tools_cr_ri_val": 0.3,
"tools_cr_h2h": True,
"tools_cr_h2h_val": 0.3,
"tools_cr_dh": True,
"tools_cr_dh_val": 0.3,
# QRCode Tool
"tools_qrcode_version": 1,
"tools_qrcode_error": 'L',
"tools_qrcode_box_size": 3,
"tools_qrcode_border_size": 4,
"tools_qrcode_qrdata": '',
"tools_qrcode_polarity": 'pos',
"tools_qrcode_rounded": 's',
"tools_qrcode_fill_color": '#000000',
"tools_qrcode_back_color": '#FFFFFF',
"tools_qrcode_sel_limit": 330,
# Copper Thieving Tool
"tools_copper_thieving_clearance": 0.25,
"tools_copper_thieving_margin": 1.0,
"tools_copper_thieving_reference": 'itself',
"tools_copper_thieving_box_type": 'rect',
"tools_copper_thieving_circle_steps": 64,
"tools_copper_thieving_fill_type": 'solid',
"tools_copper_thieving_dots_dia": 1.0,
"tools_copper_thieving_dots_spacing": 2.0,
"tools_copper_thieving_squares_size": 1.0,
"tools_copper_thieving_squares_spacing": 2.0,
"tools_copper_thieving_lines_size": 0.25,
"tools_copper_thieving_lines_spacing": 2.0,
"tools_copper_thieving_rb_margin": 1.0,
"tools_copper_thieving_rb_thickness": 1.0,
"tools_copper_thieving_mask_clearance": 0.0,
# Fiducials Tool
"tools_fiducials_dia": 1.0,
"tools_fiducials_margin": 1.0,
"tools_fiducials_mode": 'auto',
"tools_fiducials_second_pos": 'up',
"tools_fiducials_type": 'circular',
"tools_fiducials_line_thickness": 0.25,
# Calibration Tool
"tools_cal_calsource": 'object',
"tools_cal_travelz": 2.0,
"tools_cal_verz": 0.1,
"tools_cal_zeroz": False,
"tools_cal_toolchangez": 15,
"tools_cal_toolchange_xy": '',
"tools_cal_sec_point": 'tl',
# Drills Extraction Tool
"tools_edrills_hole_type": 'fixed',
"tools_edrills_hole_fixed_dia": 0.5,
"tools_edrills_hole_prop_factor": 80.0,
"tools_edrills_circular_ring": 0.2,
"tools_edrills_oblong_ring": 0.2,
"tools_edrills_square_ring": 0.2,
"tools_edrills_rectangular_ring": 0.2,
"tools_edrills_others_ring": 0.2,
"tools_edrills_circular": True,
"tools_edrills_oblong": False,
"tools_edrills_square": False,
"tools_edrills_rectangular": False,
"tools_edrills_others": False,
# Punch Gerber Tool
"tools_punch_hole_type": 'exc',
"tools_punch_hole_fixed_dia": 0.5,
"tools_punch_hole_prop_factor": 80.0,
"tools_punch_circular_ring": 0.2,
"tools_punch_oblong_ring": 0.2,
"tools_punch_square_ring": 0.2,
"tools_punch_rectangular_ring": 0.2,
"tools_punch_others_ring": 0.2,
"tools_punch_circular": True,
"tools_punch_oblong": False,
"tools_punch_square": True,
"tools_punch_rectangular": False,
"tools_punch_others": False,
# Align Objects Tool
"tools_align_objects_align_type": 'sp',
# Invert Gerber Tool
"tools_invert_margin": 0.1,
"tools_invert_join_style": 's',
# Utilities
# file associations
"fa_excellon": 'drd, drill, drl, exc, ncd, tap, xln',
"fa_gcode": 'cnc, din, dnc, ecs, eia, fan, fgc, fnc, gc, gcd, gcode, h, hnc, i, min, mpf, mpr, nc, ncc, '
'ncg, ncp, ngc, out, ply, rol, sbp, tap, xpi',
"fa_gerber": 'art, bot, bsm, cmp, crc, crs, dim, gb0, gb1, gb2, gb3, gb4, gb5, gb6, gb7, gb8, gb9, gbd, '
'gbl, gbo, gbp, gbr, gbs, gdo, ger, gko, gm1, gm2, gm3, grb, gtl, gto, gtp, gts, ly15, ly2, '
'mil, outline, pho, plc, pls, smb, smt, sol, spb, spt, ssb, sst, stc, sts, top, tsm',
# Keyword list
"util_autocomplete_keywords": 'Desktop, Documents, FlatConfig, FlatPrj, False, '
'Marius, My Documents, Paste_1, '
'Repetier, Roland_MDX_20, True, Users, Toolchange_Custom, '
'Toolchange_Probe_MACH3, '
'Toolchange_manual, Users, all, axis, auto, axisoffset, '
'box, center_x, center_y, columns, combine, connect, contour, default, '
'depthperpass, dia, diatol, dist, drilled_dias, drillz, dpp, dwelltime, '
'endxy, endz, extracut_length, f, feedrate, '
'feedrate_z, grbl_11, GRBL_laser, gridoffsety, gridx, gridy, has_offset, '
'holes, hpgl, iso_type, line_xyz, margin, marlin, method, milled_dias, '
'minoffset, name, offset, opt_type, order, outname, overlap, '
'passes, postamble, pp, ppname_e, ppname_g, preamble, radius, ref, rest, '
'rows, shellvar_, scale_factor, spacing_columns, spacing_rows, spindlespeed, '
'startz, startxy, toolchange_xy, toolchangez, '
'tooldia, travelz, use_threads, value, x, x0, x1, y, y0, y1, z_cut, '
'z_move',
"script_autocompleter": True,
"script_text": "",
"script_plot": True,
"script_source_file": "",
"document_autocompleter": False,
"document_text": "",
"document_plot": True,
"document_source_file": "",
"document_font_color": '#000000',
"document_sel_color": '#0055ff',
"document_font_size": 6,
"document_tab_size": 80,
}
@classmethod
def save_factory_defaults(cls, file_path: str):
"""Writes the factory defaults to a file at the given path, overwriting any existing file."""
# Delete any existing factory defaults file
if os.path.isfile(file_path):
os.chmod(file_path, stat.S_IRWXO | stat.S_IWRITE | stat.S_IWGRP)
os.remove(file_path)
try:
# recreate a new factory defaults file and save the factory defaults data into it
f_f_def_s = open(file_path, "w")
simplejson.dump(cls.factory_defaults, f_f_def_s, default=to_dict, indent=2, sort_keys=True)
f_f_def_s.close()
# and then make the factory_defaults.FlatConfig file read_only
# so it can't be modified after creation.
os.chmod(file_path, stat.S_IREAD | stat.S_IRGRP | stat.S_IROTH)
log.debug("FlatCAM factory defaults written to: %s" % file_path)
except Exception as e:
log.error("save_factory_defaults() -> %s" % str(e))
def __init__(self):
self.defaults = LoudDict()
self.defaults.update(self.factory_defaults)
self.current_defaults = {} # copy used for restoring after cancelled prefs changes
self.current_defaults.update(self.factory_defaults)
self.old_defaults_found = False
##### Pass-through to the defaults LoudDict #####
def __len__(self):
return self.defaults.__len__()
def __getitem__(self, item):
return self.defaults.__getitem__(item)
def __setitem__(self, key, value):
return self.defaults.__setitem__(key, value)
def __delitem__(self, key):
return self.defaults.__delitem__(key)
def __iter__(self):
return self.defaults.__iter__()
def __getattr__(self, item):
# Unfortunately this method alone is not enough to pass through the other magic methods above.
return self.defaults.__getattribute__(item)
##### Additional Methods #####
def write(self, filename: str):
"""Saves the defaults to a file on disk"""
with open(filename, "w") as file:
simplejson.dump(self.defaults, file, default=to_dict, indent=2, sort_keys=True)
def load(self, filename: str):
"""Loads the defaults from a file on disk, performing migration if required."""
# Read in the file
try:
f = open(filename)
options = f.read()
f.close()
except IOError:
log.error("Could not load defaults file.")
self.inform.emit('[ERROR] %s' % _("Could not load defaults file."))
# in case the defaults file can't be loaded, show all toolbars
self.defaults["global_toolbar_view"] = 511
return
# Parse the JSON
try:
defaults = simplejson.loads(options)
except Exception:
# in case the defaults file can't be loaded, show all toolbars
self.defaults["global_toolbar_view"] = 511
e = sys.exc_info()[0]
log.error(str(e))
self.inform.emit('[ERROR] %s' % _("Failed to parse defaults file."))
return
if defaults is None:
return
# Perform migration if necessary
if self.__is_old_defaults(defaults):
self.old_defaults_found = True
defaults = self.__migrate_old_defaults(defaults=defaults)
else:
self.old_defaults_found = False
# Save the resulting defaults
self.defaults.update(defaults)
self.current_defaults.update(self.defaults)
log.debug("FlatCAM defaults loaded from: %s" % filename)
def __is_old_defaults(self, defaults: dict) -> bool:
"""Takes a defaults dict and determines whether or not migration is necessary."""
return 'version' not in defaults or defaults['version'] != self.factory_defaults['version']
def __migrate_old_defaults(self, defaults: dict) -> dict:
"""Performs migration on the passed-in defaults dictionary, and returns the migrated dict"""
migrated = {}
for k, v in defaults.items():
if k in self.factory_defaults and k != 'version':
# check if the types are the same. Because some types (tuple, float, int etc)
# may be stored as strings we check their types.
try:
target = eval(self.defaults[k])
except (NameError, TypeError):
# it's an unknown string leave it as it is
target = deepcopy(self.factory_defaults[k])
try:
source = eval(v)
except NameError:
# it's an unknown string leave it as it is
source = deepcopy(v)
if type(target) == type(source):
migrated[k] = v
return migrated
def reset_to_factory_defaults(self):
self.defaults.update(self.factory_defaults)
self.current_defaults.update(self.factory_defaults)
self.old_defaults_found = False
def propagate_defaults(self):
"""
This method is used to set default values in classes. It's
an alternative to project options but allows the use
of values invisible to the user.
"""
log.debug("propagate_defaults()")
# Which objects to update the given parameters.
routes = {
"global_zdownrate": CNCjob,
"excellon_zeros": Excellon,
"excellon_format_upper_in": Excellon,
"excellon_format_lower_in": Excellon,
"excellon_format_upper_mm": Excellon,
"excellon_format_lower_mm": Excellon,
"excellon_units": Excellon,
"gerber_use_buffer_for_union": Gerber,
"geometry_multidepth": Geometry
}
for param in routes:
if param in routes[param].defaults:
try:
routes[param].defaults[param] = self.defaults[param]
except KeyError:
log.error("FlatCAMApp.propagate_defaults() --> ERROR: " + param + " not in defaults.")
else:
# Try extracting the name:
# classname_param here is param in the object
if param.find(routes[param].__name__.lower() + "_") == 0:
p = param[len(routes[param].__name__) + 1:]
if p in routes[param].defaults:
routes[param].defaults[p] = self.defaults[param]
def report_usage(self, resource):
"""
Increments usage counter for the given resource
in self.defaults['global_stats'].
:param resource: Name of the resource.
:return: None
"""
if resource in self.defaults['global_stats']:
self.defaults['global_stats'][resource] += 1
else:
self.defaults['global_stats'][resource] = 1

View File

@ -122,7 +122,7 @@ class BufferSelectionTool(FlatCAMTool):
self.buffer_distance_entry.set_value(0.01) self.buffer_distance_entry.set_value(0.01)
def run(self): def run(self):
self.app.report_usage("Geo Editor ToolBuffer()") self.app.defaults.report_usage("Geo Editor ToolBuffer()")
FlatCAMTool.run(self) FlatCAMTool.run(self)
# if the splitter us hidden, display it # if the splitter us hidden, display it
@ -339,7 +339,7 @@ class TextInputTool(FlatCAMTool):
self.font_italic_tb.clicked.connect(self.on_italic_button) self.font_italic_tb.clicked.connect(self.on_italic_button)
def run(self): def run(self):
self.app.report_usage("Geo Editor TextInputTool()") self.app.defaults.report_usage("Geo Editor TextInputTool()")
FlatCAMTool.run(self) FlatCAMTool.run(self)
# if the splitter us hidden, display it # if the splitter us hidden, display it
@ -537,7 +537,7 @@ class PaintOptionsTool(FlatCAMTool):
self.set_tool_ui() self.set_tool_ui()
def run(self): def run(self):
self.app.report_usage("Geo Editor ToolPaint()") self.app.defaults.report_usage("Geo Editor ToolPaint()")
FlatCAMTool.run(self) FlatCAMTool.run(self)
# if the splitter us hidden, display it # if the splitter us hidden, display it
@ -980,7 +980,7 @@ class TransformEditorTool(FlatCAMTool):
self.set_tool_ui() self.set_tool_ui()
def run(self): def run(self):
self.app.report_usage("Geo Editor Transform Tool()") self.app.defaults.report_usage("Geo Editor Transform Tool()")
FlatCAMTool.run(self) FlatCAMTool.run(self)
self.set_tool_ui() self.set_tool_ui()

View File

@ -5516,7 +5516,7 @@ class TransformEditorTool(FlatCAMTool):
self.set_tool_ui() self.set_tool_ui()
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("Geo Editor Transform Tool()") self.app.defaults.report_usage("Geo Editor Transform Tool()")
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same
if self.app.ui.splitter.sizes()[0] == 0: if self.app.ui.splitter.sizes()[0] == 0:

View File

@ -152,14 +152,14 @@ class TextEditor(QtWidgets.QWidget):
self.code_edited = '' self.code_edited = ''
def handlePrint(self): def handlePrint(self):
self.app.report_usage("handlePrint()") self.app.defaults.report_usage("handlePrint()")
dialog = QtPrintSupport.QPrintDialog() dialog = QtPrintSupport.QPrintDialog()
if dialog.exec_() == QtWidgets.QDialog.Accepted: if dialog.exec_() == QtWidgets.QDialog.Accepted:
self.code_editor.document().print_(dialog.printer()) self.code_editor.document().print_(dialog.printer())
def handlePreview(self): def handlePreview(self):
self.app.report_usage("handlePreview()") self.app.defaults.report_usage("handlePreview()")
dialog = QtPrintSupport.QPrintPreviewDialog() dialog = QtPrintSupport.QPrintPreviewDialog()
dialog.paintRequested.connect(self.code_editor.print_) dialog.paintRequested.connect(self.code_editor.print_)
@ -172,7 +172,7 @@ class TextEditor(QtWidgets.QWidget):
pass pass
def handleOpen(self, filt=None): def handleOpen(self, filt=None):
self.app.report_usage("handleOpen()") self.app.defaults.report_usage("handleOpen()")
if filt: if filt:
_filter_ = filt _filter_ = filt
@ -192,7 +192,7 @@ class TextEditor(QtWidgets.QWidget):
file.close() file.close()
def handleSaveGCode(self, name=None, filt=None, callback=None): def handleSaveGCode(self, name=None, filt=None, callback=None):
self.app.report_usage("handleSaveGCode()") self.app.defaults.report_usage("handleSaveGCode()")
if filt: if filt:
_filter_ = filt _filter_ = filt
@ -287,7 +287,7 @@ class TextEditor(QtWidgets.QWidget):
callback() callback()
def handleFindGCode(self): def handleFindGCode(self):
self.app.report_usage("handleFindGCode()") self.app.defaults.report_usage("handleFindGCode()")
flags = QtGui.QTextDocument.FindCaseSensitively flags = QtGui.QTextDocument.FindCaseSensitively
text_to_be_found = self.entryFind.get_value() text_to_be_found = self.entryFind.get_value()
@ -298,7 +298,7 @@ class TextEditor(QtWidgets.QWidget):
r = self.code_editor.find(str(text_to_be_found), flags) r = self.code_editor.find(str(text_to_be_found), flags)
def handleReplaceGCode(self): def handleReplaceGCode(self):
self.app.report_usage("handleReplaceGCode()") self.app.defaults.report_usage("handleReplaceGCode()")
old = self.entryFind.get_value() old = self.entryFind.get_value()
new = self.entryReplace.get_value() new = self.entryReplace.get_value()

View File

@ -2913,7 +2913,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
if key == QtCore.Qt.Key_S: if key == QtCore.Qt.Key_S:
widget_name = self.plot_tab_area.currentWidget().objectName() widget_name = self.plot_tab_area.currentWidget().objectName()
if widget_name == 'preferences_tab': if widget_name == 'preferences_tab':
self.app.on_save_button(save_to_file=False) self.app.preferencesUiManager.on_save_button(save_to_file=False)
return return
if widget_name == 'database_tab': if widget_name == 'database_tab':

File diff suppressed because it is too large Load Diff

View File

@ -487,7 +487,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
:param args: :param args:
:return: :return:
""" """
self.app.report_usage("cncjob_on_exportgcode_button") self.app.defaults.report_usage("cncjob_on_exportgcode_button")
self.read_form() self.read_form()
name = self.app.collection.get_active().options['name'] name = self.app.collection.get_active().options['name']

View File

@ -1234,13 +1234,13 @@ class ExcellonObject(FlatCAMObj, Excellon):
return True, "" return True, ""
def on_generate_milling_button_click(self, *args): def on_generate_milling_button_click(self, *args):
self.app.report_usage("excellon_on_create_milling_drills button") self.app.defaults.report_usage("excellon_on_create_milling_drills button")
self.read_form() self.read_form()
self.generate_milling_drills(use_thread=False) self.generate_milling_drills(use_thread=False)
def on_generate_milling_slots_button_click(self, *args): def on_generate_milling_slots_button_click(self, *args):
self.app.report_usage("excellon_on_create_milling_slots_button") self.app.defaults.report_usage("excellon_on_create_milling_slots_button")
self.read_form() self.read_form()
self.generate_milling_slots(use_thread=False) self.generate_milling_slots(use_thread=False)
@ -1338,7 +1338,7 @@ class ExcellonObject(FlatCAMObj, Excellon):
pass pass
def on_create_cncjob_button_click(self, *args): def on_create_cncjob_button_click(self, *args):
self.app.report_usage("excellon_on_create_cncjob_button") self.app.defaults.report_usage("excellon_on_create_cncjob_button")
self.read_form() self.read_form()
# Get the tools from the list # Get the tools from the list

View File

@ -1575,7 +1575,7 @@ class GeometryObject(FlatCAMObj, Geometry):
def on_generatecnc_button_click(self, *args): def on_generatecnc_button_click(self, *args):
log.debug("Generating CNCJob from Geometry ...") log.debug("Generating CNCJob from Geometry ...")
self.app.report_usage("geometry_on_generatecnc_button") self.app.defaults.report_usage("geometry_on_generatecnc_button")
# this reads the values in the UI form to the self.options dictionary # this reads the values in the UI form to the self.options dictionary
self.read_form() self.read_form()

View File

@ -505,7 +505,7 @@ class GerberObject(FlatCAMObj, Gerber):
self.app.worker_task.emit({'fcn': buffer_task, 'params': []}) self.app.worker_task.emit({'fcn': buffer_task, 'params': []})
def on_generatenoncopper_button_click(self, *args): def on_generatenoncopper_button_click(self, *args):
self.app.report_usage("gerber_on_generatenoncopper_button") self.app.defaults.report_usage("gerber_on_generatenoncopper_button")
self.read_form() self.read_form()
name = self.options["name"] + "_noncopper" name = self.options["name"] + "_noncopper"
@ -532,7 +532,7 @@ class GerberObject(FlatCAMObj, Gerber):
self.app.new_object("geometry", name, geo_init) self.app.new_object("geometry", name, geo_init)
def on_generatebb_button_click(self, *args): def on_generatebb_button_click(self, *args):
self.app.report_usage("gerber_on_generatebb_button") self.app.defaults.report_usage("gerber_on_generatebb_button")
self.read_form() self.read_form()
name = self.options["name"] + "_bbox" name = self.options["name"] + "_bbox"
@ -574,7 +574,7 @@ class GerberObject(FlatCAMObj, Gerber):
# in the end toggle the visibility of the origin object so we can see the generated Geometry # in the end toggle the visibility of the origin object so we can see the generated Geometry
iso_obj.ui.plot_cb.toggle() iso_obj.ui.plot_cb.toggle()
else: else:
app_obj.report_usage("gerber_on_iso_button") app_obj.defaults.report_usage("gerber_on_iso_button")
self.read_form() self.read_form()
iso_scope = 'all' if self.ui.iso_scope_radio.get_value() == 'all' else 'single' iso_scope = 'all' if self.ui.iso_scope_radio.get_value() == 'all' else 'single'

View File

@ -236,7 +236,7 @@ class FlatCAMObj(QtCore.QObject):
) )
def on_offset_button_click(self): def on_offset_button_click(self):
self.app.report_usage("obj_on_offset_button") self.app.defaults.report_usage("obj_on_offset_button")
self.read_form() self.read_form()
vector_val = self.ui.offsetvector_entry.get_value() vector_val = self.ui.offsetvector_entry.get_value()
@ -283,7 +283,7 @@ class FlatCAMObj(QtCore.QObject):
self.app.worker_task.emit({'fcn': worker_task, 'params': []}) self.app.worker_task.emit({'fcn': worker_task, 'params': []})
def on_skew_button_click(self): def on_skew_button_click(self):
self.app.report_usage("obj_on_skew_button") self.app.defaults.report_usage("obj_on_skew_button")
self.read_form() self.read_form()
x_angle = self.ui.xangle_entry.get_value() x_angle = self.ui.xangle_entry.get_value()
y_angle = self.ui.yangle_entry.get_value() y_angle = self.ui.yangle_entry.get_value()

View File

@ -28,7 +28,6 @@ import inspect # TODO: Remove
import re import re
import logging import logging
import collections
from copy import deepcopy from copy import deepcopy
from numpy import Inf from numpy import Inf

View File

@ -217,7 +217,7 @@ class AlignObjects(FlatCAMTool):
self.aligned_old_line_color = None self.aligned_old_line_color = None
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolAlignObjects()") self.app.defaults.report_usage("ToolAlignObjects()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -271,7 +271,7 @@ class ToolCalculator(FlatCAMTool):
self.reset_button.clicked.connect(self.set_tool_ui) self.reset_button.clicked.connect(self.set_tool_ui)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolCalculators()") self.app.defaults.report_usage("ToolCalculators()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -731,7 +731,7 @@ class ToolCalibration(FlatCAMTool):
self.reset_button.clicked.connect(self.set_tool_ui) self.reset_button.clicked.connect(self.set_tool_ui)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolCalibration()") self.app.defaults.report_usage("ToolCalibration()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -540,7 +540,7 @@ class ToolCopperThieving(FlatCAMTool):
self.work_finished.connect(self.on_new_pattern_plating_object) self.work_finished.connect(self.on_new_pattern_plating_object)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolCopperThieving()") self.app.defaults.report_usage("ToolCopperThieving()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -419,7 +419,7 @@ class CutOut(FlatCAMTool):
self.obj_combo.obj_type = {"grb": "Gerber", "geo": "Geometry"}[val] self.obj_combo.obj_type = {"grb": "Gerber", "geo": "Geometry"}[val]
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolCutOut()") self.app.defaults.report_usage("ToolCutOut()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -514,7 +514,7 @@ class DblSidedTool(FlatCAMTool):
FlatCAMTool.install(self, icon, separator, shortcut='Alt+D', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='Alt+D', **kwargs)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("Tool2Sided()") self.app.defaults.report_usage("Tool2Sided()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -180,7 +180,7 @@ class Distance(FlatCAMTool):
self.measure_btn.clicked.connect(self.activate_measure_tool) self.measure_btn.clicked.connect(self.activate_measure_tool)
def run(self, toggle=False): def run(self, toggle=False):
self.app.report_usage("ToolDistance()") self.app.defaults.report_usage("ToolDistance()")
self.points[:] = [] self.points[:] = []

View File

@ -136,7 +136,7 @@ class DistanceMin(FlatCAMTool):
self.jump_hp_btn.clicked.connect(self.on_jump_to_half_point) self.jump_hp_btn.clicked.connect(self.on_jump_to_half_point)
def run(self, toggle=False): def run(self, toggle=False):
self.app.report_usage("ToolDistanceMin()") self.app.defaults.report_usage("ToolDistanceMin()")
if self.app.tool_tab_locked is True: if self.app.tool_tab_locked is True:
return return

View File

@ -366,7 +366,7 @@ class ToolExtractDrills(FlatCAMTool):
FlatCAMTool.install(self, icon, separator, shortcut='Alt+I', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='Alt+I', **kwargs)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("Extract Drills()") self.app.defaults.report_usage("Extract Drills()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -367,7 +367,7 @@ class ToolFiducials(FlatCAMTool):
self.reset_button.clicked.connect(self.set_tool_ui) self.reset_button.clicked.connect(self.set_tool_ui)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolFiducials()") self.app.defaults.report_usage("ToolFiducials()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -558,7 +558,7 @@ class Film(FlatCAMTool):
}[self.tf_type_obj_combo.get_value()] }[self.tf_type_obj_combo.get_value()]
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolFilm()") self.app.defaults.report_usage("ToolFilm()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same
@ -933,7 +933,7 @@ class Film(FlatCAMTool):
:param ftype: the type of file for saving the film: 'svg', 'png' or 'pdf' :param ftype: the type of file for saving the film: 'svg', 'png' or 'pdf'
:return: :return:
""" """
self.app.report_usage("export_negative()") self.app.defaults.report_usage("export_negative()")
if filename is None: if filename is None:
filename = self.app.defaults["global_last_save_folder"] filename = self.app.defaults["global_last_save_folder"]
@ -1116,7 +1116,7 @@ class Film(FlatCAMTool):
:return: :return:
""" """
self.app.report_usage("export_positive()") self.app.defaults.report_usage("export_positive()")
if filename is None: if filename is None:
filename = self.app.defaults["global_last_save_folder"] filename = self.app.defaults["global_last_save_folder"]

View File

@ -155,7 +155,7 @@ class ToolImage(FlatCAMTool):
self.image_type.activated_custom.connect(self.on_image_type) self.image_type.activated_custom.connect(self.on_image_type)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolImage()") self.app.defaults.report_usage("ToolImage()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same
@ -263,7 +263,7 @@ class ToolImage(FlatCAMTool):
:return: :return:
""" """
self.app.report_usage("import_image()") self.app.defaults.report_usage("import_image()")
if mask is None: if mask is None:
mask = [250, 250, 250, 250] mask = [250, 250, 250, 250]

View File

@ -156,7 +156,7 @@ class ToolInvertGerber(FlatCAMTool):
FlatCAMTool.install(self, icon, separator, shortcut='', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='', **kwargs)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolInvertGerber()") self.app.defaults.report_usage("ToolInvertGerber()")
log.debug("ToolInvertGerber() is running ...") log.debug("ToolInvertGerber() is running ...")
if toggle: if toggle:

View File

@ -63,7 +63,7 @@ class ToolMove(FlatCAMTool):
FlatCAMTool.install(self, icon, separator, shortcut='M', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='M', **kwargs)
def run(self, toggle): def run(self, toggle):
self.app.report_usage("ToolMove()") self.app.defaults.report_usage("ToolMove()")
if self.app.tool_tab_locked is True: if self.app.tool_tab_locked is True:
return return

View File

@ -939,7 +939,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
FlatCAMTool.install(self, icon, separator, shortcut='Alt+N', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='Alt+N', **kwargs)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolNonCopperClear()") self.app.defaults.report_usage("ToolNonCopperClear()")
log.debug("ToolNCC().run() was launched ...") log.debug("ToolNCC().run() was launched ...")
if toggle: if toggle:
@ -1582,7 +1582,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
# init values for the next usage # init values for the next usage
self.reset_usage() self.reset_usage()
self.app.report_usage("on_paint_button_click") self.app.defaults.report_usage("on_paint_button_click")
self.grb_circle_steps = int(self.app.defaults["gerber_circle_steps"]) self.grb_circle_steps = int(self.app.defaults["gerber_circle_steps"])
self.obj_name = self.object_combo.currentText() self.obj_name = self.object_combo.currentText()

View File

@ -280,7 +280,7 @@ class ToolOptimal(FlatCAMTool):
FlatCAMTool.install(self, icon, separator, shortcut='Alt+O', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='Alt+O', **kwargs)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolOptimal()") self.app.defaults.report_usage("ToolOptimal()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -129,7 +129,7 @@ class ToolPDF(FlatCAMTool):
self.point_to_unit_factor = 0.01388888888 self.point_to_unit_factor = 0.01388888888
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolPDF()") self.app.defaults.report_usage("ToolPDF()")
self.set_tool_ui() self.set_tool_ui()
self.on_open_pdf_click() self.on_open_pdf_click()
@ -147,7 +147,7 @@ class ToolPDF(FlatCAMTool):
:return: None :return: None
""" """
self.app.report_usage("ToolPDF.on_open_pdf_click()") self.app.defaults.report_usage("ToolPDF.on_open_pdf_click()")
self.app.log.debug("ToolPDF.on_open_pdf_click()") self.app.log.debug("ToolPDF.on_open_pdf_click()")
_filter_ = "Adobe PDF Files (*.pdf);;" \ _filter_ = "Adobe PDF Files (*.pdf);;" \

View File

@ -710,7 +710,7 @@ class ToolPaint(FlatCAMTool, Gerber):
FlatCAMTool.install(self, icon, separator, shortcut='Alt+P', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='Alt+P', **kwargs)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolPaint()") self.app.defaults.report_usage("ToolPaint()")
log.debug("ToolPaint().run() was launched ...") log.debug("ToolPaint().run() was launched ...")
if toggle: if toggle:
@ -1374,7 +1374,7 @@ class ToolPaint(FlatCAMTool, Gerber):
# init values for the next usage # init values for the next usage
self.reset_usage() self.reset_usage()
self.app.report_usage("on_paint_button_click") self.app.defaults.report_usage("on_paint_button_click")
# self.app.call_source = 'paint' # self.app.call_source = 'paint'
self.select_method = self.selectmethod_combo.get_value() self.select_method = self.selectmethod_combo.get_value()

View File

@ -293,7 +293,7 @@ class Panelize(FlatCAMTool):
self.constrain_flag = False self.constrain_flag = False
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolPanelize()") self.app.defaults.report_usage("ToolPanelize()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -170,7 +170,7 @@ class PcbWizard(FlatCAMTool):
self.tools_from_inf = {} self.tools_from_inf = {}
def run(self, toggle=False): def run(self, toggle=False):
self.app.report_usage("PcbWizard Tool()") self.app.defaults.report_usage("PcbWizard Tool()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -73,7 +73,7 @@ class Properties(FlatCAMTool):
self.calculations_finished.connect(self.show_area_chull) self.calculations_finished.connect(self.show_area_chull)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolProperties()") self.app.defaults.report_usage("ToolProperties()")
if self.app.tool_tab_locked is True: if self.app.tool_tab_locked is True:
return return

View File

@ -397,7 +397,7 @@ class ToolPunchGerber(FlatCAMTool):
) )
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolPunchGerber()") self.app.defaults.report_usage("ToolPunchGerber()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -354,7 +354,7 @@ class QRCode(FlatCAMTool):
self.reset_button.clicked.connect(self.set_tool_ui) self.reset_button.clicked.connect(self.set_tool_ui)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("QRCode()") self.app.defaults.report_usage("QRCode()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -589,7 +589,7 @@ class RulesCheck(FlatCAMTool):
cb.setChecked(False) cb.setChecked(False)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolRulesCheck()") self.app.defaults.report_usage("ToolRulesCheck()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -377,7 +377,7 @@ class FCShell(TermWidget):
:return: output if there was any :return: output if there was any
""" """
self.app.report_usage('exec_command') self.app.defaults.report_usage('exec_command')
return self.exec_command_test(text, False, no_echo=no_echo) return self.exec_command_test(text, False, no_echo=no_echo)

View File

@ -525,7 +525,7 @@ class SolderPaste(FlatCAMTool):
self.reset_button.clicked.connect(self.set_tool_ui) self.reset_button.clicked.connect(self.set_tool_ui)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolSolderPaste()") self.app.defaults.report_usage("ToolSolderPaste()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -236,7 +236,7 @@ class ToolSub(FlatCAMTool):
FlatCAMTool.install(self, icon, separator, shortcut='Alt+W', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='Alt+W', **kwargs)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolSub()") self.app.defaults.report_usage("ToolSub()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -433,7 +433,7 @@ class ToolTransform(FlatCAMTool):
# self.buffer_entry.returnPressed.connect(self.on_buffer_by_distance) # self.buffer_entry.returnPressed.connect(self.on_buffer_by_distance)
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolTransform()") self.app.defaults.report_usage("ToolTransform()")
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same

View File

@ -50,4 +50,4 @@ class TclCommandSaveSys(TclCommandSignaled):
:return: None or exception :return: None or exception
""" """
self.app.save_defaults(args) self.app.preferencesUiManager.save_defaults(args)

View File

@ -83,8 +83,7 @@ class TclCommandSetSys(TclCommand):
pass pass
self.app.defaults[param] = value self.app.defaults[param] = value
self.app.defaults.propagate_defaults()
self.app.propagate_defaults(silent=True)
else: else:
self.raise_tcl_error("No such system parameter \"{}\".".format(param)) self.raise_tcl_error("No such system parameter \"{}\".".format(param))