From 338f12707d823972fd804d7a3a06eef846f2ce0d Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 28 Jul 2019 23:11:35 +0300 Subject: [PATCH] - fixed issue with not using the current units in the tool tables after unit conversion - after unit conversion from Preferences, the default values are automatically saved by the app --- FlatCAMApp.py | 12 +++++++++++- FlatCAMObj.py | 13 ++++++++++++- README.md | 5 +++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index d8a05d53..8ca78b51 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -3873,6 +3873,9 @@ class App(QtCore.QObject): scale_defaults(factor) self.defaults_write_form(fl_units=new_units) + # save the defaults to file, some may assume that the conversion is enough and it's not + self.on_save_button() + self.should_we_save = True # change this only if the workspace is active @@ -3918,12 +3921,17 @@ class App(QtCore.QObject): self.defaults_read_form() def on_toggle_units_click(self): - self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.disconnect() + try: + self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.disconnect() + except TypeError: + pass + if self.defaults["units"] == 'MM': self.ui.general_defaults_form.general_app_group.units_radio.set_value("IN") else: self.ui.general_defaults_form.general_app_group.units_radio.set_value("MM") self.on_toggle_units(no_pref=True) + self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.connect( lambda: self.on_toggle_units(no_pref=False)) @@ -4528,6 +4536,8 @@ class App(QtCore.QObject): self.ui.cncjob_defaults_form.cncjob_adv_opt_group.toolchange_text.insertPlainText('%%%s%%' % signal_text) def on_save_button(self): + log.debug("App.on_save_button() --> Saving preferences to file.") + self.save_defaults(silent=False) # load the defaults so they are updated into the app self.load_defaults(filename='current_defaults') diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 7e50685c..b6b3ce9f 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -93,7 +93,8 @@ class FlatCAMObj(QtCore.QObject): self.isHovering = False self.notHovering = True - self.units = 'IN' + # self.units = 'IN' + self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper() # assert isinstance(self.ui, ObjectUI) # self.ui.name_entry.returnPressed.connect(self.on_name_activate) @@ -1787,6 +1788,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): def build_ui(self): FlatCAMObj.build_ui(self) + self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper() + try: # if connected, disconnect the signal from the slot on item_changed as it creates issues self.ui.tools_table.itemChanged.disconnect() @@ -1993,6 +1996,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): FlatCAMApp.App.log.debug("FlatCAMExcellon.set_ui()") + self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper() + self.form_fields.update({ "plot": self.ui.plot_cb, "solid": self.ui.solid_cb, @@ -2089,6 +2094,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): self.ui.tools_table.itemChanged.disconnect() # self.tools_table_exc.selectionModel().currentChanged.disconnect() + self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper() + self.is_modified = True row_of_item_changed = self.ui.tools_table.currentRow() @@ -3027,6 +3034,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.ui_disconnect() FlatCAMObj.build_ui(self) + self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper() + offset = 0 tool_idx = 0 @@ -3518,6 +3527,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): def on_tool_add(self, dia=None): self.ui_disconnect() + self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper() + # if a Tool diameter entered is a char instead a number the final message of Tool adding is changed # because the Default value for Tool is used. change_message = False diff --git a/README.md b/README.md index 05d67aee..821fa1d4 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,11 @@ CAD program, and create G-Code for Isolation routing. ================================================= +28.07.2019 + +- fixed issue with not using the current units in the tool tables after unit conversion +- after unit conversion from Preferences, the default values are automatically saved by the app + 20.07.2019 - updated the CutOut tool so it will work on single PCB Gerbers or on PCB panel Gerbers