- added possibility to see the GCode when right clicking on the Project tab on a CNCJob object and then clicking View Source

This commit is contained in:
Marius Stanciu 2019-09-15 22:46:51 +03:00 committed by Marius
parent b0d545eb03
commit c06317374e
4 changed files with 27 additions and 11 deletions

View File

@ -8217,20 +8217,34 @@ class App(QtCore.QObject):
if obj.kind == 'gerber': if obj.kind == 'gerber':
flt = "Gerber Files (*.GBR);;All Files (*.*)" flt = "Gerber Files (*.GBR);;All Files (*.*)"
else: elif obj.kind == 'excellon':
flt = "Excellon Files (*.DRL);;All Files (*.*)" flt = "Excellon Files (*.DRL);;All Files (*.*)"
elif obj.kind == 'cncjob':
"GCode Files (*.NC);;All Files (*.*)"
else:
flt = "All Files (*.*)"
self.init_code_editor(name=_("Source Editor")) self.init_code_editor(name=_("Source Editor"))
self.ui.buttonOpen.clicked.connect(lambda: self.handleOpen(filt=flt)) self.ui.buttonOpen.clicked.connect(lambda: self.handleOpen(filt=flt))
self.ui.buttonSave.clicked.connect(lambda: self.handleSaveGCode(filt=flt)) self.ui.buttonSave.clicked.connect(lambda: self.handleSaveGCode(filt=flt))
# then append the text from GCode to the text editor # then append the text from GCode to the text editor
try: if obj.kind == 'cncjob':
file = StringIO(obj.source_file) try:
except AttributeError: file = obj.export_gcode(preamble='', postamble='', to_file=True)
self.inform.emit('[WARNING_NOTCL] %s' % if file == 'fail':
_("There is no selected object for which to see it's source file code.")) return 'fail'
return 'fail' except AttributeError:
self.inform.emit('[WARNING_NOTCL] %s' %
_("There is no selected object for which to see it's source file code."))
return 'fail'
else:
try:
file = StringIO(obj.source_file)
except AttributeError:
self.inform.emit('[WARNING_NOTCL] %s' %
_("There is no selected object for which to see it's source file code."))
return 'fail'
self.ui.cncjob_frame.hide() self.ui.cncjob_frame.hide()
try: try:

View File

@ -5842,11 +5842,12 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
preamble = str(self.ui.prepend_text.get_value()) preamble = str(self.ui.prepend_text.get_value())
postamble = str(self.ui.append_text.get_value()) postamble = str(self.ui.append_text.get_value())
gc = self.export_gcode(preamble=preamble, postamble=postamble, to_file=True)
if gc == 'fail': gco = self.export_gcode(preamble=preamble, postamble=postamble, to_file=True)
if gco == 'fail':
return return
else: else:
self.app.gcode_edited = gc self.app.gcode_edited = gco
self.app.init_code_editor(name=_("Code Editor")) self.app.init_code_editor(name=_("Code Editor"))
self.app.ui.buttonOpen.clicked.connect(self.app.handleOpen) self.app.ui.buttonOpen.clicked.connect(self.app.handleOpen)

View File

@ -320,7 +320,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
self.app.ui.menuprojectgeneratecnc.setVisible(False) self.app.ui.menuprojectgeneratecnc.setVisible(False)
if type(obj) != FlatCAMGeometry and type(obj) != FlatCAMExcellon and type(obj) != FlatCAMGerber: if type(obj) != FlatCAMGeometry and type(obj) != FlatCAMExcellon and type(obj) != FlatCAMGerber:
self.app.ui.menuprojectedit.setVisible(False) self.app.ui.menuprojectedit.setVisible(False)
if type(obj) != FlatCAMGerber and type(obj) != FlatCAMExcellon: if type(obj) != FlatCAMGerber and type(obj) != FlatCAMExcellon and type(obj) != FlatCAMCNCjob:
self.app.ui.menuprojectviewsource.setVisible(False) self.app.ui.menuprojectviewsource.setVisible(False)
else: else:
self.app.ui.menuprojectgeneratecnc.setVisible(False) self.app.ui.menuprojectgeneratecnc.setVisible(False)

View File

@ -20,6 +20,7 @@ CAD program, and create G-Code for Isolation routing.
- fixed the TclCommand cncjob to use the -outname parameter - fixed the TclCommand cncjob to use the -outname parameter
- added some more keywords in the data_model for auto-completer - added some more keywords in the data_model for auto-completer
- fixed isolate TclCommand to use correctly the -outname parameter - fixed isolate TclCommand to use correctly the -outname parameter
- added possibility to see the GCode when right clicking on the Project tab on a CNCJob object and then clicking View Source
14.09.2019 14.09.2019