From 2ee80990e52db772b89058b9fc4d966da4e23bd7 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 6 Feb 2019 21:37:50 +0200 Subject: [PATCH] - added a new function (and shortcut key Escape) that when triggered it deselects all selected objects and delete the selection box(es) - fixed bug in Excellon Gcode generation that made the toolchange X,Y always none regardless of the value in Preferences --- FlatCAMApp.py | 4 ++++ FlatCAMGUI.py | 25 +++++++++++++++++-------- FlatCAMObj.py | 3 ++- README.md | 2 ++ postprocessors/default.py | 2 +- tclCommands/TclCommandGeoCutout.py | 19 ++++++------------- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index de12606f..9f109c2e 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -3229,6 +3229,10 @@ class App(QtCore.QObject): self.general_defaults_form.general_gui_group.sel_draw_color_entry.set_value(new_val_sel) self.defaults['global_sel_draw_color'] = new_val_sel + def on_deselect_all(self): + self.collection.set_all_inactive() + self.delete_selection_shape() + def on_workspace_modified(self): self.save_defaults(silent=True) self.plotcanvas.draw_workspace() diff --git a/FlatCAMGUI.py b/FlatCAMGUI.py index efdb7cc6..ec7586d1 100644 --- a/FlatCAMGUI.py +++ b/FlatCAMGUI.py @@ -988,6 +988,10 @@ class FlatCAMGUI(QtWidgets.QMainWindow): SPACE  En(Dis)able Obj Plot + + Escape +  Deselects all objects + @@ -1539,7 +1543,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow): self.app.on_file_saveproject() # Toggle Plot Area - if key == QtCore.Qt.Key_F10: + if key == QtCore.Qt.Key_F10 or key == 'F10': self.app.on_toggle_plotarea() return @@ -1647,16 +1651,16 @@ class FlatCAMGUI(QtWidgets.QMainWindow): return # Toggle Fullscreen - if key == QtCore.Qt.Key_F10: + if key == QtCore.Qt.Key_F10 or key == 'F10': self.app.on_fullscreen() return else: # Open Manual - if key == QtCore.Qt.Key_F1: + if key == QtCore.Qt.Key_F1 or key == 'F1': webbrowser.open(self.app.manual_url) # Open Video Help - if key == QtCore.Qt.Key_F2: + if key == QtCore.Qt.Key_F2 or key == 'F2': webbrowser.open(self.app.video_url) # Switch to Project Tab @@ -1672,10 +1676,15 @@ class FlatCAMGUI(QtWidgets.QMainWindow): self.app.on_select_tab('tool') # Delete - if key == QtCore.Qt.Key_Delete and active: - # Delete via the application to - # ensure cleanup of the GUI - active.app.on_delete() + if key == QtCore.Qt.Key_Delete or key == 'Delete': + if active: + # Delete via the application to + # ensure cleanup of the GUI + active.app.on_delete() + + # Escape = Deselect All + if key == QtCore.Qt.Key_Escape or key == 'Escape': + self.app.on_deselect_all() # Space = Toggle Active/Inactive if key == QtCore.Qt.Key_Space: diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 00875ec8..377e7f5b 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -1701,7 +1701,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): job_obj.dwell = self.options["dwell"] job_obj.dwelltime = self.options["dwelltime"] job_obj.pp_excellon_name = pp_excellon_name - job_obj.toolchange_xy = self.app.defaults["excellon_toolchangexy"] + job_obj.toolchange_xy_type = "excellon" job_obj.coords_decimals = int(self.app.defaults["cncjob_coords_decimals"]) job_obj.fr_decimals = int(self.app.defaults["cncjob_fr_decimals"]) @@ -1740,6 +1740,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): ret_val = job_obj.generate_from_excellon_by_tool(self, tools_csv, drillz=self.options['drillz'], toolchange=self.options["toolchange"], + toolchangexy=self.app.defaults["excellon_toolchangexy"], toolchangez=self.options["toolchangez"], startz=self.options["startz"], endz=self.options["endz"], diff --git a/README.md b/README.md index 172ea83a..967ce074 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ CAD program, and create G-Code for Isolation routing. - renamed the theme to layout because it is really a layout change - added plot kind for CNC Job in the App Preferences - combined the geocutout and cutout_any TCL commands - work in progress +- added a new function (and shortcut key Escape) that when triggered it deselects all selected objects and delete the selection box(es) +- fixed bug in Excellon Gcode generation that made the toolchange X,Y always none regardless of the value in Preferences 5.02.3019 diff --git a/postprocessors/default.py b/postprocessors/default.py index e7d1d8e1..7441bc44 100644 --- a/postprocessors/default.py +++ b/postprocessors/default.py @@ -45,7 +45,7 @@ class default(FlatCAMPostProc): gcode += '(Steps per circle: ' + str(p['steps_per_circle']) + ')\n' if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry': - gcode += '(Postprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n' + gcode += '(Postprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n' + '\n' else: gcode += '(Postprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + '\n' diff --git a/tclCommands/TclCommandGeoCutout.py b/tclCommands/TclCommandGeoCutout.py index 7067adc4..84ac3d23 100644 --- a/tclCommands/TclCommandGeoCutout.py +++ b/tclCommands/TclCommandGeoCutout.py @@ -1,6 +1,6 @@ from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled - +from copy import deepcopy class TclCommandGeoCutout(TclCommandSignaled): """ @@ -124,21 +124,14 @@ class TclCommandGeoCutout(TclCommandSignaled): elif isinstance(cutout_obj, FlatCAMGerber): def geo_init(geo_obj, app_obj): - geo_obj.solid_geometry = obj_exteriors + try: + geo_obj.solid_geometry = cutout_obj.isolation_geometry((dia / 2), iso_type=0) + except Exception as e: + log.debug("TclCommandGeoCutout.execute() --> %s" % str(e)) + return 'fail' outname = cutout_obj.options["name"] + "_cutout" - cutout_obj.isolate(dia=dia, passes=1, overlap=1, combine=False, outname="_temp") - ext_obj = self.app.collection.get_by_name("_temp") - - try: - obj_exteriors = ext_obj.get_exteriors() - except: - obj_exteriors = ext_obj.solid_geometry - self.app.new_object('geometry', outname, geo_init) - self.app.collection.set_all_inactive() - self.app.collection.set_active("_temp") - self.app.on_delete() cutout_obj = self.app.collection.get_by_name(outname) else: