From 48b3f8d65a1380ad844612e85403f5035416bda2 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 2 May 2020 04:54:09 +0300 Subject: [PATCH] - fixed bug in Gerber Editor in which the units conversion wasn't calculated correct - fixed bug in Gerber Editor in which the QThread that is started on object edit was not stopped at clean up stage - fixed bug in Gerber Editor that kept all the apertures (including the geometry) of a previously edited object that was not saved after edit --- CHANGELOG.md | 3 ++ FlatCAMApp.py | 32 ++++--------------- flatcamEditors/FlatCAMExcEditor.py | 2 +- flatcamEditors/FlatCAMGeoEditor.py | 2 +- flatcamEditors/FlatCAMGrbEditor.py | 23 ++++++++++--- .../general/GeneralAppPrefGroupUI.py | 17 +++++++++- .../general/GeneralGUIPrefGroupUI.py | 2 +- flatcamTools/ToolPcbWizard.py | 15 +++------ locale/de/LC_MESSAGES/strings.po | 2 +- locale/en/LC_MESSAGES/strings.po | 4 +-- locale/es/LC_MESSAGES/strings.po | 2 +- locale/fr/LC_MESSAGES/strings.po | 2 +- locale/hu/LC_MESSAGES/strings.po | 4 +-- locale/it/LC_MESSAGES/strings.po | 2 +- locale/pt_BR/LC_MESSAGES/strings.po | 2 +- locale/ro/LC_MESSAGES/strings.po | 2 +- locale/ru/LC_MESSAGES/strings.po | 2 +- locale_template/strings.pot | 2 +- 18 files changed, 64 insertions(+), 56 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6130baae..0b4d0dfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ CHANGELOG for FlatCAM beta - changed the icons for the grid snap in the status bar - moved some of the methods from FlatCAMApp.App to flatcamGUI.FlatCAMGUI class +- fixed bug in Gerber Editor in which the units conversion wasn't calculated correct +- fixed bug in Gerber Editor in which the QThread that is started on object edit was not stopped at clean up stage +- fixed bug in Gerber Editor that kept all the apertures (including the geometry) of a previously edited object that was not saved after edit 01.05.2020 diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 6ba19076..49cc7d0f 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -6940,7 +6940,6 @@ class App(QtCore.QObject): else: key_modifier = QtWidgets.QApplication.keyboardModifiers() - if key_modifier == QtCore.Qt.ShiftModifier: mod_key = 'Shift' elif key_modifier == QtCore.Qt.ControlModifier: @@ -6949,20 +6948,19 @@ class App(QtCore.QObject): mod_key = None try: - if mod_key == self.defaults["global_mselect_key"]: + if self.command_active is None: # If the CTRL key is pressed when the LMB is clicked then if the object is selected it will # deselect, and if it's not selected then it will be selected # If there is no active command (self.command_active is None) then we check if we clicked # on a object by checking the bounding limits against mouse click position - if self.command_active is None: + if mod_key == self.defaults["global_mselect_key"]: self.select_objects(key='multisel') - self.delete_hover_shape() - else: - # If there is no active command (self.command_active is None) then we check if we clicked - # on a object by checking the bounding limits against mouse click position - if self.command_active is None: + else: + # If there is no active command (self.command_active is None) then we check if + # we clicked on a object by checking the bounding limits against mouse click position self.select_objects() - self.delete_hover_shape() + + self.delete_hover_shape() except Exception as e: log.warning("FlatCAMApp.on_mouse_click_release_over_plot() select click --> Error: %s" % str(e)) return @@ -8158,7 +8156,6 @@ class App(QtCore.QObject): # ############################################################################################################### # ### The following section has the functions that are displayed and call the Editor tab CNCJob Tab ############# # ############################################################################################################### - def init_code_editor(self, name): self.text_editor_tab = TextEditor(app=self, plain_text=True) @@ -10820,21 +10817,6 @@ class App(QtCore.QObject): # no_km) # QtWidgets.qApp.sendEvent(self.shell._edit, f) - def on_toggle_shell_from_settings(self, state): - """ - Toggle shell: if is visible close it, if it is closed then open it - :return: None - """ - - self.defaults.report_usage("on_toggle_shell_from_settings()") - - if state is True: - if not self.ui.shell_dock.isVisible(): - self.ui.shell_dock.show() - else: - if self.ui.shell_dock.isVisible(): - self.ui.shell_dock.hide() - def shell_message(self, msg, show=False, error=False, warning=False, success=False, selected=False): """ Shows a message on the FlatCAM Shell diff --git a/flatcamEditors/FlatCAMExcEditor.py b/flatcamEditors/FlatCAMExcEditor.py index 9220aba5..2f2e274c 100644 --- a/flatcamEditors/FlatCAMExcEditor.py +++ b/flatcamEditors/FlatCAMExcEditor.py @@ -2837,7 +2837,7 @@ class FlatCAMExcEditor(QtCore.QObject): # start with GRID toolbar activated if self.app.ui.grid_snap_btn.isChecked() is False: self.app.ui.grid_snap_btn.trigger() - self.app.on_grid_snap_triggered(state=True) + self.app.ui.on_grid_snap_triggered(state=True) self.app.ui.popmenu_disable.setVisible(False) self.app.ui.cmenu_newmenu.menuAction().setVisible(False) diff --git a/flatcamEditors/FlatCAMGeoEditor.py b/flatcamEditors/FlatCAMGeoEditor.py index 4716f831..1f10c01f 100644 --- a/flatcamEditors/FlatCAMGeoEditor.py +++ b/flatcamEditors/FlatCAMGeoEditor.py @@ -4100,7 +4100,7 @@ class FlatCAMGeoEditor(QtCore.QObject): # start with GRID toolbar activated if self.app.ui.grid_snap_btn.isChecked() is False: self.app.ui.grid_snap_btn.trigger() - self.app.on_grid_snap_triggered(state=True) + self.app.ui.on_grid_snap_triggered(state=True) def on_buffer_tool(self): buff_tool = BufferSelectionTool(self.app, self) diff --git a/flatcamEditors/FlatCAMGrbEditor.py b/flatcamEditors/FlatCAMGrbEditor.py index 1183f1be..9aa85c78 100644 --- a/flatcamEditors/FlatCAMGrbEditor.py +++ b/flatcamEditors/FlatCAMGrbEditor.py @@ -3703,7 +3703,7 @@ class FlatCAMGrbEditor(QtCore.QObject): # start with GRID toolbar activated if self.app.ui.grid_snap_btn.isChecked() is False: self.app.ui.grid_snap_btn.trigger() - self.app.on_grid_snap_triggered(state=True) + self.app.ui.on_grid_snap_triggered(state=True) # adjust the visibility of some of the canvas context menu self.app.ui.popmenu_edit.setVisible(False) @@ -3723,6 +3723,8 @@ class FlatCAMGrbEditor(QtCore.QObject): except Exception as e: log.debug("FlatCAMGrbEditor.deactivate_grb_editor() --> %s" % str(e)) + self.clear() + # adjust the status of the menu entries related to the editor self.app.ui.menueditedit.setDisabled(False) self.app.ui.menueditok.setDisabled(True) @@ -3731,7 +3733,6 @@ class FlatCAMGrbEditor(QtCore.QObject): self.app.ui.popmenu_save.setVisible(False) self.disconnect_canvas_event_handlers() - self.clear() self.app.ui.grb_edit_toolbar.setDisabled(True) settings = QSettings("Open Source", "FlatCAM") @@ -3939,8 +3940,12 @@ class FlatCAMGrbEditor(QtCore.QObject): pass def clear(self): + self.thread.quit() + self.active_tool = None self.selected = [] + self.storage_dict.clear() + self.results.clear() self.shapes.clear(update=True) self.tool_shape.clear(update=True) @@ -3970,7 +3975,16 @@ class FlatCAMGrbEditor(QtCore.QObject): file_units = self.gerber_obj.units if self.gerber_obj.units else 'IN' app_units = self.app.defaults['units'] - self.conversion_factor = 25.4 if file_units == 'IN' else (1 / 25.4) if file_units != app_units else 1 + # self.conversion_factor = 25.4 if file_units == 'IN' else (1 / 25.4) if file_units != app_units else 1 + + if file_units == app_units: + self.conversion_factor = 1 + else: + if file_units == 'IN': + self.conversion_factor = 25.4 + else: + self.conversion_factor = 0.0393700787401575 + # Hide original geometry orig_grb_obj.visible = False @@ -4230,8 +4244,7 @@ class FlatCAMGrbEditor(QtCore.QObject): else: new_grb_name = self.edited_obj_name + "_edit" - self.app.worker_task.emit({'fcn': self.new_edited_gerber, - 'params': [new_grb_name, self.storage_dict]}) + self.app.worker_task.emit({'fcn': self.new_edited_gerber, 'params': [new_grb_name, self.storage_dict]}) @staticmethod def update_options(obj): diff --git a/flatcamGUI/preferences/general/GeneralAppPrefGroupUI.py b/flatcamGUI/preferences/general/GeneralAppPrefGroupUI.py index ab563f67..7f238b5f 100644 --- a/flatcamGUI/preferences/general/GeneralAppPrefGroupUI.py +++ b/flatcamGUI/preferences/general/GeneralAppPrefGroupUI.py @@ -374,10 +374,25 @@ class GeneralAppPrefGroupUI(OptionsGroupUI): self.splash_cb.stateChanged.connect(self.on_splash_changed) # Monitor the checkbox from the Application Defaults Tab and show the TCL shell or not depending on it's value - self.shell_startup_cb.clicked.connect(self.app.on_toggle_shell_from_settings) + self.shell_startup_cb.clicked.connect(self.on_toggle_shell_from_settings) self.language_apply_btn.clicked.connect(lambda: fcTranslate.on_language_apply_click(app=self.app, restart=True)) + def on_toggle_shell_from_settings(self, state): + """ + Toggle shell: if is visible close it, if it is closed then open it + :return: None + """ + + self.app.defaults.report_usage("on_toggle_shell_from_settings()") + + if state is True: + if not self.app.ui.shell_dock.isVisible(): + self.app.ui.shell_dock.show() + else: + if self.app.ui.shell_dock.isVisible(): + self.app.ui.shell_dock.hide() + @staticmethod def on_splash_changed(state): qsettings = QSettings("Open Source", "FlatCAM") diff --git a/flatcamGUI/preferences/general/GeneralGUIPrefGroupUI.py b/flatcamGUI/preferences/general/GeneralGUIPrefGroupUI.py index a074c75b..94044c27 100644 --- a/flatcamGUI/preferences/general/GeneralGUIPrefGroupUI.py +++ b/flatcamGUI/preferences/general/GeneralGUIPrefGroupUI.py @@ -779,7 +779,7 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI): self.app.connect_toolbar_signals() self.app.ui.grid_snap_btn.setChecked(True) - self.app.on_grid_snap_triggered(state=True) + self.app.ui.on_grid_snap_triggered(state=True) self.app.ui.grid_gap_x_entry.setText(str(self.app.defaults["global_gridx"])) self.app.ui.grid_gap_y_entry.setText(str(self.app.defaults["global_gridy"])) diff --git a/flatcamTools/ToolPcbWizard.py b/flatcamTools/ToolPcbWizard.py index 832cf191..47d3a196 100644 --- a/flatcamTools/ToolPcbWizard.py +++ b/flatcamTools/ToolPcbWizard.py @@ -421,8 +421,7 @@ class PcbWizard(FlatCAMTool): ret = excellon_obj.parse_file(file_obj=excellon_fileobj) if ret == "fail": app_obj.log.debug("Excellon parsing failed.") - app_obj.inform.emit('[ERROR_NOTCL] %s' % - _("This is not Excellon file.")) + app_obj.inform.emit('[ERROR_NOTCL] %s' % _("This is not Excellon file.")) return "fail" except IOError: app_obj.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Cannot parse file"), self.outname)) @@ -443,8 +442,7 @@ class PcbWizard(FlatCAMTool): for tool in excellon_obj.tools: if excellon_obj.tools[tool]['solid_geometry']: return - app_obj.inform.emit('[ERROR_NOTCL] %s: %s' % - (_("No geometry found in file"), name)) + app_obj.inform.emit('[ERROR_NOTCL] %s: %s' % (_("No geometry found in file"), name)) return "fail" if excellon_fileobj is not None and excellon_fileobj != '': @@ -463,12 +461,9 @@ class PcbWizard(FlatCAMTool): self.app.file_opened.emit("excellon", name) # GUI feedback - self.app.inform.emit('[success] %s: %s' % - (_("Imported"), name)) + self.app.inform.emit('[success] %s: %s' % (_("Imported"), name)) self.app.ui.notebook.setCurrentWidget(self.app.ui.project_tab) else: - self.app.inform.emit('[WARNING_NOTCL] %s' % - _('Excellon merging is in progress. Please wait...')) + self.app.inform.emit('[WARNING_NOTCL] %s' % _('Excellon merging is in progress. Please wait...')) else: - self.app.inform.emit('[ERROR_NOTCL] %s' % - _('The imported Excellon file is None.')) + self.app.inform.emit('[ERROR_NOTCL] %s' % _('The imported Excellon file is empty.')) diff --git a/locale/de/LC_MESSAGES/strings.po b/locale/de/LC_MESSAGES/strings.po index 9de38225..326937b3 100644 --- a/locale/de/LC_MESSAGES/strings.po +++ b/locale/de/LC_MESSAGES/strings.po @@ -16793,7 +16793,7 @@ msgid "Excellon merging is in progress. Please wait..." msgstr "Das Zusammenführen von Excellons ist im Gange. Warten Sie mal..." #: flatcamTools/ToolPcbWizard.py:474 -msgid "The imported Excellon file is None." +msgid "The imported Excellon file is empty." msgstr "Die importierte Excellon-Datei ist Keine." #: flatcamTools/ToolProperties.py:131 diff --git a/locale/en/LC_MESSAGES/strings.po b/locale/en/LC_MESSAGES/strings.po index 969d5b6b..161975b5 100644 --- a/locale/en/LC_MESSAGES/strings.po +++ b/locale/en/LC_MESSAGES/strings.po @@ -16456,8 +16456,8 @@ msgid "Excellon merging is in progress. Please wait..." msgstr "Excellon merging is in progress. Please wait..." #: flatcamTools/ToolPcbWizard.py:474 -msgid "The imported Excellon file is None." -msgstr "The imported Excellon file is None." +msgid "The imported Excellon file is empty." +msgstr "The imported Excellon file is empty." #: flatcamTools/ToolProperties.py:131 msgid "Object Properties are displayed." diff --git a/locale/es/LC_MESSAGES/strings.po b/locale/es/LC_MESSAGES/strings.po index 90b63696..1f495e05 100644 --- a/locale/es/LC_MESSAGES/strings.po +++ b/locale/es/LC_MESSAGES/strings.po @@ -16717,7 +16717,7 @@ msgid "Excellon merging is in progress. Please wait..." msgstr "La fusión de Excellon está en progreso. Por favor espera..." #: flatcamTools/ToolPcbWizard.py:474 -msgid "The imported Excellon file is None." +msgid "The imported Excellon file is empty." msgstr "El archivo Excellon importado es Ninguno." #: flatcamTools/ToolProperties.py:131 diff --git a/locale/fr/LC_MESSAGES/strings.po b/locale/fr/LC_MESSAGES/strings.po index 33d122f0..2b9beb3c 100644 --- a/locale/fr/LC_MESSAGES/strings.po +++ b/locale/fr/LC_MESSAGES/strings.po @@ -16716,7 +16716,7 @@ msgid "Excellon merging is in progress. Please wait..." msgstr "Excellon fusion est en cours. S'il vous plaît, attendez..." #: flatcamTools/ToolPcbWizard.py:474 -msgid "The imported Excellon file is None." +msgid "The imported Excellon file is empty." msgstr "Le fichier Excellon importé est Aucun." #: flatcamTools/ToolProperties.py:131 diff --git a/locale/hu/LC_MESSAGES/strings.po b/locale/hu/LC_MESSAGES/strings.po index e17c55c2..bd24dcc7 100644 --- a/locale/hu/LC_MESSAGES/strings.po +++ b/locale/hu/LC_MESSAGES/strings.po @@ -16458,8 +16458,8 @@ msgid "Excellon merging is in progress. Please wait..." msgstr "Excellon merging is in progress. Please wait..." #: flatcamTools/ToolPcbWizard.py:474 -msgid "The imported Excellon file is None." -msgstr "The imported Excellon file is None." +msgid "The imported Excellon file is empty." +msgstr "The imported Excellon file is empty." #: flatcamTools/ToolProperties.py:131 msgid "Object Properties are displayed." diff --git a/locale/it/LC_MESSAGES/strings.po b/locale/it/LC_MESSAGES/strings.po index 21bc2e5b..bac53820 100644 --- a/locale/it/LC_MESSAGES/strings.po +++ b/locale/it/LC_MESSAGES/strings.po @@ -13789,7 +13789,7 @@ msgid "Excellon merging is in progress. Please wait..." msgstr "" #: flatcamTools/ToolPcbWizard.py:478 -msgid "The imported Excellon file is None." +msgid "The imported Excellon file is empty." msgstr "" #: flatcamTools/ToolProperties.py:119 diff --git a/locale/pt_BR/LC_MESSAGES/strings.po b/locale/pt_BR/LC_MESSAGES/strings.po index 5f4d383e..b90a1858 100644 --- a/locale/pt_BR/LC_MESSAGES/strings.po +++ b/locale/pt_BR/LC_MESSAGES/strings.po @@ -16521,7 +16521,7 @@ msgid "Excellon merging is in progress. Please wait..." msgstr "A união Excellon está em andamento. Por favor, espere..." #: flatcamTools/ToolPcbWizard.py:474 -msgid "The imported Excellon file is None." +msgid "The imported Excellon file is empty." msgstr "O arquivo Excellon importado está Vazio." #: flatcamTools/ToolProperties.py:131 diff --git a/locale/ro/LC_MESSAGES/strings.po b/locale/ro/LC_MESSAGES/strings.po index 1bbfb27b..a2abeb59 100644 --- a/locale/ro/LC_MESSAGES/strings.po +++ b/locale/ro/LC_MESSAGES/strings.po @@ -16728,7 +16728,7 @@ msgid "Excellon merging is in progress. Please wait..." msgstr "Fuziunea fisiere Excellon este in curs. Vă rugăm aşteptați ..." #: flatcamTools/ToolPcbWizard.py:474 -msgid "The imported Excellon file is None." +msgid "The imported Excellon file is empty." msgstr "Fişierul Excellon importat este gol." #: flatcamTools/ToolProperties.py:131 diff --git a/locale/ru/LC_MESSAGES/strings.po b/locale/ru/LC_MESSAGES/strings.po index c44ae68d..4056ae5f 100644 --- a/locale/ru/LC_MESSAGES/strings.po +++ b/locale/ru/LC_MESSAGES/strings.po @@ -16579,7 +16579,7 @@ msgid "Excellon merging is in progress. Please wait..." msgstr "Слияние Excellon продолжается. Пожалуйста, подождите..." #: flatcamTools/ToolPcbWizard.py:474 -msgid "The imported Excellon file is None." +msgid "The imported Excellon file is empty." msgstr "Импортированный файл Excellon есть None." #: flatcamTools/ToolProperties.py:131 diff --git a/locale_template/strings.pot b/locale_template/strings.pot index e6e772fa..f195910d 100644 --- a/locale_template/strings.pot +++ b/locale_template/strings.pot @@ -14116,7 +14116,7 @@ msgid "Excellon merging is in progress. Please wait..." msgstr "" #: flatcamTools/ToolPcbWizard.py:474 -msgid "The imported Excellon file is None." +msgid "The imported Excellon file is empty." msgstr "" #: flatcamTools/ToolProperties.py:131