- minor work in GCode Editor

This commit is contained in:
Marius Stanciu 2020-07-31 14:08:53 +03:00
parent 593e6a80e5
commit 1fc70fd3cf
3 changed files with 38 additions and 11 deletions

View File

@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta
=================================================
31.07.2020
- minor work in GCode Editor
29.07.2020
- fixed an exception that was raised in Geometry object when using an Offset

View File

@ -36,6 +36,8 @@ class AppGCodeEditor(QtCore.QObject):
self.ui = AppGCodeEditorUI(app=self.app)
self.edited_obj_name = ""
self.gcode_obj = None
self.code_edited = ''
@ -81,8 +83,9 @@ class AppGCodeEditor(QtCore.QObject):
# #################################################################################
# ################### SIGNALS #####################################################
# #################################################################################
self.ui.name_entry.returnPressed.connect(self.on_name_activate)
self.ui.update_gcode_button.clicked.connect(self.insert_gcode)
self.ui.exit_editor_button.clicked.connect(self.update_fcgcode)
self.ui.exit_editor_button.clicked.connect(lambda: self.app.editor2object())
def build_ui(self):
"""
@ -97,6 +100,10 @@ class AppGCodeEditor(QtCore.QObject):
# Switch notebook to Selected page
self.app.ui.notebook.setCurrentWidget(self.app.ui.selected_tab)
# make a new name for the new Excellon object (the one with edited content)
self.edited_obj_name = self.gcode_obj.options['name']
self.ui.name_entry.set_value(self.edited_obj_name)
def ui_connect(self):
"""
@ -154,7 +161,7 @@ class AppGCodeEditor(QtCore.QObject):
self.ui.gcode_editor_tab.load_text(gcode_text, move_to_start=True, clear_text=True)
self.app.inform.emit('[success] %s...' % _('Loaded Machine Code into Code Editor'))
def update_fcgcode(self):
def update_fcgcode(self, edited_obj):
"""
:return:
@ -166,7 +173,7 @@ class AppGCodeEditor(QtCore.QObject):
self.gcode_obj.source_file = my_gcode
self.ui.gcode_editor_tab.buttonSave.setStyleSheet("")
self.ui.gcode_editor_tab.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png'))
self.ui.gcode_editor_tab.buttonSave.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png'))
def on_open_gcode(self):
"""
@ -188,6 +195,8 @@ class AppGCodeEditor(QtCore.QObject):
self.ui.gcode_editor_tab.load_text(self.code_edited, move_to_start=True, clear_text=True)
file.close()
def on_name_activate(self):
self.edited_obj_name = self.ui.name_entry.get_value()
class AppGCodeEditorUI:
def __init__(self, app):

View File

@ -2298,7 +2298,7 @@ class App(QtCore.QObject):
self.ui.tool_scroll_area.setWidget(QtWidgets.QWidget())
self.ui.notebook.setTabText(2, "Tool")
if isinstance(edited_obj, GeometryObject):
if edited_obj.kind == 'geometry':
obj_type = "Geometry"
self.geo_editor.update_fcgeometry(edited_obj)
# self.geo_editor.update_options(edited_obj)
@ -2322,7 +2322,7 @@ class App(QtCore.QObject):
edited_obj.plot()
self.inform.emit('[success] %s' % _("Editor exited. Editor content saved."))
elif isinstance(edited_obj, GerberObject):
elif edited_obj.kind == 'gerber':
obj_type = "Gerber"
self.grb_editor.update_fcgerber()
# self.grb_editor.update_options(edited_obj)
@ -2344,7 +2344,7 @@ class App(QtCore.QObject):
# Remove anything else in the GUI
self.ui.selected_scroll_area.takeWidget()
elif isinstance(edited_obj, ExcellonObject):
elif edited_obj.kind == 'excellon':
obj_type = "Excellon"
self.exc_editor.update_fcexcellon(edited_obj)
# self.exc_editor.update_options(edited_obj)
@ -2371,12 +2371,24 @@ class App(QtCore.QObject):
self.collection.delete_by_name(name=old_name)
self.inform.emit('[success] %s' % _("Editor exited. Editor content saved."))
elif edited_obj.kind == 'cncjob':
obj_type = "CNCJob"
self.gcode_editor.update_fcgcode(edited_obj)
# self.exc_editor.update_options(edited_obj)
# restore GUI to the Selected TAB
# Remove anything else in the GUI
self.ui.tool_scroll_area.takeWidget()
self.inform.emit('[success] %s' % _("Editor exited. Editor content saved."))
else:
self.inform.emit('[WARNING_NOTCL] %s' %
_("Select a Gerber, Geometry or Excellon Object to update."))
_("Select a Gerber, Geometry, Excellon or CNCJobObject to update."))
return
self.inform.emit('[selected] %s %s' % (obj_type, _("is updated, returning to App...")))
elif response == bt_no:
# show the Tools Toolbar
tools_tb = self.ui.toolbartools
@ -2389,19 +2401,21 @@ class App(QtCore.QObject):
self.inform.emit('[WARNING_NOTCL] %s' % _("Editor exited. Editor content was not saved."))
if isinstance(edited_obj, GeometryObject):
if edited_obj.kind == 'geometry':
self.geo_editor.deactivate()
edited_obj.build_ui()
edited_obj.plot()
elif isinstance(edited_obj, GerberObject):
elif edited_obj.kind == 'gerber':
self.grb_editor.deactivate_grb_editor()
edited_obj.build_ui()
elif isinstance(edited_obj, ExcellonObject):
elif edited_obj.kind == 'excellon':
self.exc_editor.deactivate()
edited_obj.build_ui()
elif edited_obj.kind == 'cncjob':
edited_obj.build_ui()
else:
self.inform.emit('[WARNING_NOTCL] %s' %
_("Select a Gerber, Geometry or Excellon Object to update."))
_("Select a Gerber, Geometry, Excellon or CNCJobObject to update."))
return
elif response == bt_cancel:
return