- fixed a minor issue that when saving a project with CNCJob objects, the variable that holds the origin of the CNCJob object was not saved in the project. Added to the serializable objects also the exc_cnc_tools dictionary

- some changes in the File menu
This commit is contained in:
Marius Stanciu 2019-12-29 00:00:15 +02:00 committed by Marius
parent 779e13697f
commit 58054f71b3
4 changed files with 92 additions and 92 deletions

View File

@ -3302,7 +3302,6 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
job_obj.options['type'] = 'Excellon'
job_obj.options['ppname_e'] = pp_excellon_name
app_obj.progress.emit(20)
job_obj.z_cut = float(self.options["drillz"])
job_obj.tool_offset = self.tool_offset
job_obj.z_move = float(self.options["travelz"])
@ -3325,27 +3324,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
job_obj.options['xmax'] = xmax
job_obj.options['ymax'] = ymax
try:
job_obj.z_pdepth = float(self.options["z_pdepth"])
except ValueError:
# try to convert comma to decimal point. if it's still not working error message and return
try:
job_obj.z_pdepth = float(self.options["z_pdepth"].replace(',', '.'))
except ValueError:
self.app.inform.emit('[ERROR_NOTCL] %s' %
_('Wrong value format for self.defaults["z_pdepth"] '
'or self.options["z_pdepth"]'))
try:
job_obj.feedrate_probe = float(self.options["feedrate_probe"])
except ValueError:
# try to convert comma to decimal point. if it's still not working error message and return
try:
job_obj.feedrate_rapid = float(self.options["feedrate_probe"].replace(',', '.'))
except ValueError:
self.app.inform.emit('[ERROR_NOTCL] %s' %
_('Wrong value format for self.defaults["feedrate_probe"] or '
'self.options["feedrate_probe"]'))
job_obj.z_pdepth = float(self.options["z_pdepth"])
job_obj.feedrate_probe = float(self.options["feedrate_probe"])
# There could be more than one drill size...
# job_obj.tooldia = # TODO: duplicate variable!
@ -3364,14 +3344,10 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
if ret_val == 'fail':
return 'fail'
app_obj.progress.emit(50)
job_obj.gcode_parse()
app_obj.progress.emit(60)
job_obj.create_geometry()
app_obj.progress.emit(80)
# To be run in separate thread
def job_thread(app_obj):
with self.app.proc_container.new(_("Generating CNC Code")):
@ -6078,6 +6054,9 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
# (like the one in the TCL Command), False
self.multitool = False
# determine if the GCode was generated out of a Excellon object or a Geometry object
self.origin_kind = None
# used for parsing the GCode lines to adjust the GCode when the GCode is offseted or scaled
gcodex_re_string = r'(?=.*(X[-\+]?\d*\.\d*))'
self.g_x_re = re.compile(gcodex_re_string)
@ -6097,7 +6076,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
# Attributes to be included in serialization
# Always append to it because it carries contents
# from predecessors.
self.ser_attrs += ['options', 'kind', 'cnc_tools', 'multitool']
self.ser_attrs += ['options', 'kind', 'origin_kind', 'cnc_tools', 'exc_cnc_tools', 'multitool']
if self.app.is_legacy is False:
self.text_col = self.app.plotcanvas.new_text_collection()

View File

@ -13,6 +13,8 @@ CAD program, and create G-Code for Isolation routing.
- more updates to the Preferences window and in some other parts of the GUI
- updated the translations (less Russian)
- fixed a minor issue that when saving a project with CNCJob objects, the variable that holds the origin of the CNCJob object was not saved in the project. Added to the serializable objects also the exc_cnc_tools dictionary
- some changes in the File menu
28.12.2019

View File

@ -2239,7 +2239,6 @@ class CNCjob(Geometry):
Geometry.__init__(self, geo_steps_per_circle=self.steps_per_circle)
self.kind = kind
self.origin_kind = None
self.units = units
@ -4155,7 +4154,7 @@ class CNCjob(Geometry):
kind = ['C', 'F']
geometry.append(
{
"geom": Point(current_drill_point_coords).buffer(dia/2).exterior,
"geom": Point(current_drill_point_coords).buffer(dia/2.0).exterior,
"kind": kind
}
)
@ -4465,11 +4464,12 @@ class CNCjob(Geometry):
# if geo['kind'][0] == 'C':
# obj.add_shape(shape=poly, color=color['C'][1], face_color=color['C'][0],
# visible=visible, layer=1)
try:
obj.annotation.set(text=text, pos=pos, visible=obj.options['plot'],
font_size=self.app.defaults["cncjob_annotation_fontsize"],
color=self.app.defaults["cncjob_annotation_fontcolor"])
except Exception as e:
except Exception:
pass
def create_geometry(self):

View File

@ -81,26 +81,31 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menufilenewgeo.setToolTip(
_("Will create a new, empty Geometry Object.")
)
self.menufilenewgrb = self.menufilenew.addAction(QtGui.QIcon(self.app.resource_location + '/new_file_grb16.png'), _('Gerber\tB'))
self.menufilenewgrb = self.menufilenew.addAction(
QtGui.QIcon(self.app.resource_location + '/new_file_grb16.png'), _('Gerber\tB'))
self.menufilenewgrb.setToolTip(
_("Will create a new, empty Gerber Object.")
)
self.menufilenewexc = self.menufilenew.addAction(QtGui.QIcon(self.app.resource_location + '/new_file_exc16.png'), _('Excellon\tL'))
self.menufilenewexc = self.menufilenew.addAction(
QtGui.QIcon(self.app.resource_location + '/new_file_exc16.png'), _('Excellon\tL'))
self.menufilenewexc.setToolTip(
_("Will create a new, empty Excellon Object.")
)
self.menufilenew.addSeparator()
self.menufilenewdoc = self.menufilenew.addAction(QtGui.QIcon(self.app.resource_location + '/notes16_1.png'), _('Document\tD'))
self.menufilenewdoc = self.menufilenew.addAction(
QtGui.QIcon(self.app.resource_location + '/notes16_1.png'), _('Document\tD'))
self.menufilenewdoc.setToolTip(
_("Will create a new, empty Document Object.")
)
self.menufile_open = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/folder32_bis.png'), _('Open'))
self.menufile_open = self.menufile.addMenu(
QtGui.QIcon(self.app.resource_location + '/folder32_bis.png'), _('Open'))
self.menufile_open.setToolTipsVisible(True)
# Open Project ...
self.menufileopenproject = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/folder16.png'), _('Open &Project ...'), self)
self.menufileopenproject = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/folder16.png'), _('Open &Project ...'), self)
self.menufile_open.addAction(self.menufileopenproject)
self.menufile_open.addSeparator()
@ -115,30 +120,37 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menufile_open.addAction(self.menufileopenexcellon)
# Open G-Code ...
self.menufileopengcode = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/code.png'), _('Open G-&Code ...'), self)
self.menufileopengcode = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/code.png'), _('Open G-&Code ...'), self)
self.menufile_open.addAction(self.menufileopengcode)
self.menufile_open.addSeparator()
# Open Config File...
self.menufileopenconfig = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/folder16.png'), _('Open Config ...'), self)
self.menufileopenconfig = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/folder16.png'), _('Open Config ...'), self)
self.menufile_open.addAction(self.menufileopenconfig)
# Recent
self.recent_projects = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/recent_files.png'), _("Recent projects"))
self.recent = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/recent_files.png'), _("Recent files"))
self.recent_projects = self.menufile.addMenu(
QtGui.QIcon(self.app.resource_location + '/recent_files.png'), _("Recent projects"))
self.recent = self.menufile.addMenu(
QtGui.QIcon(self.app.resource_location + '/recent_files.png'), _("Recent files"))
# Separator
self.menufile.addSeparator()
# Scripting
self.menufile_scripting = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/script16.png'), _('Scripting'))
self.menufile_scripting = self.menufile.addMenu(
QtGui.QIcon(self.app.resource_location + '/script16.png'), _('Scripting'))
self.menufile_scripting.setToolTipsVisible(True)
self.menufilenewscript = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/script_new16.png'), _('New Script ...'), self)
self.menufileopenscript = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/open_script32.png'), _('Open Script ...'), self)
self.menufilerunscript = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/script16.png'),
'%s\tSHIFT+S' % _('Run Script ...'), self)
self.menufilenewscript = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/script_new16.png'), _('New Script ...'), self)
self.menufileopenscript = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/open_script32.png'), _('Open Script ...'), self)
self.menufilerunscript = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/script16.png'), '%s\tSHIFT+S' % _('Run Script ...'), self)
self.menufilerunscript.setToolTip(
_("Will run the opened Tcl Script thus\n"
"enabling the automation of certain\n"
@ -153,40 +165,45 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menufile.addSeparator()
# Import ...
self.menufileimport = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/import.png'), _('Import'))
self.menufileimportsvg = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/svg16.png'),
_('&SVG as Geometry Object ...'), self)
self.menufileimport = self.menufile.addMenu(
QtGui.QIcon(self.app.resource_location + '/import.png'), _('Import'))
self.menufileimportsvg = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/svg16.png'), _('&SVG as Geometry Object ...'), self)
self.menufileimport.addAction(self.menufileimportsvg)
self.menufileimportsvg_as_gerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/svg16.png'),
_('&SVG as Gerber Object ...'), self)
self.menufileimportsvg_as_gerber = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/svg16.png'), _('&SVG as Gerber Object ...'), self)
self.menufileimport.addAction(self.menufileimportsvg_as_gerber)
self.menufileimport.addSeparator()
self.menufileimportdxf = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/dxf16.png'),
_('&DXF as Geometry Object ...'), self)
self.menufileimportdxf = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/dxf16.png'), _('&DXF as Geometry Object ...'), self)
self.menufileimport.addAction(self.menufileimportdxf)
self.menufileimportdxf_as_gerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/dxf16.png'),
_('&DXF as Gerber Object ...'), self)
self.menufileimportdxf_as_gerber = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/dxf16.png'), _('&DXF as Gerber Object ...'), self)
self.menufileimport.addAction(self.menufileimportdxf_as_gerber)
self.menufileimport.addSeparator()
self.menufileimport_hpgl2_as_geo = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/dxf16.png'),
_('HPGL2 as Geometry Object ...'), self)
self.menufileimport_hpgl2_as_geo = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/dxf16.png'), _('HPGL2 as Geometry Object ...'), self)
self.menufileimport.addAction(self.menufileimport_hpgl2_as_geo)
self.menufileimport.addSeparator()
# Export ...
self.menufileexport = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export'))
self.menufileexport = self.menufile.addMenu(
QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export'))
self.menufileexport.setToolTipsVisible(True)
self.menufileexportsvg = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export &SVG ...'), self)
self.menufileexportsvg = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export &SVG ...'), self)
self.menufileexport.addAction(self.menufileexportsvg)
self.menufileexportdxf = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export DXF ...'), self)
self.menufileexportdxf = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export DXF ...'), self)
self.menufileexport.addAction(self.menufileexportdxf)
self.menufileexport.addSeparator()
self.menufileexportpng = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/export_png32.png'), _('Export &PNG ...'), self)
self.menufileexportpng = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/export_png32.png'), _('Export &PNG ...'), self)
self.menufileexportpng.setToolTip(
_("Will export an image in PNG format,\n"
"the saved image will contain the visual \n"
@ -196,8 +213,8 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menufileexport.addSeparator()
self.menufileexportexcellon = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/drill32.png'),
_('Export &Excellon ...'), self)
self.menufileexportexcellon = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/drill32.png'), _('Export &Excellon ...'), self)
self.menufileexportexcellon.setToolTip(
_("Will export an Excellon Object as Excellon file,\n"
"the coordinates format, the file units and zeros\n"
@ -205,8 +222,8 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
)
self.menufileexport.addAction(self.menufileexportexcellon)
self.menufileexportgerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'),
_('Export &Gerber ...'), self)
self.menufileexportgerber = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'), _('Export &Gerber ...'), self)
self.menufileexportgerber.setToolTip(
_("Will export an Gerber Object as Gerber file,\n"
"the coordinates format, the file units and zeros\n"
@ -217,27 +234,29 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
# Separator
self.menufile.addSeparator()
# Save Defaults
self.menufilesavedefaults = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/defaults.png'),
_('Save Preferences'), self)
self.menufile.addAction(self.menufilesavedefaults)
# Separator
self.menufile.addSeparator()
self.menufile_backup = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/backup24.png'),
_('Backup'))
self.menufile_backup = self.menufile.addMenu(
QtGui.QIcon(self.app.resource_location + '/backup24.png'), _('Backup'))
# Import Preferences
self.menufileimportpref = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/backup_import24.png'),
_('Import Preferences from file ...'), self)
self.menufileimportpref = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/backup_import24.png'),
_('Import Preferences from file ...'), self
)
self.menufile_backup.addAction(self.menufileimportpref)
# Export Preferences
self.menufileexportpref = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/backup_export24.png'),
_('Export Preferences to file ...'), self)
self.menufileexportpref = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/backup_export24.png'), _('Export Preferences to file ...'), self)
self.menufile_backup.addAction(self.menufileexportpref)
# Separator
self.menufile_backup.addSeparator()
# Save Defaults
self.menufilesavedefaults = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/defaults.png'), _('Save Preferences'), self)
self.menufile_backup.addAction(self.menufilesavedefaults)
# Separator
self.menufile.addSeparator()
self.menufile_print = QtWidgets.QAction(
@ -247,18 +266,18 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menufile_save = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/save_as.png'), _('Save'))
# Save Project
self.menufilesaveproject = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/floppy16.png'),
_('&Save Project ...'), self)
self.menufilesaveproject = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/floppy16.png'), _('&Save Project ...'), self)
self.menufile_save.addAction(self.menufilesaveproject)
# Save Project As ...
self.menufilesaveprojectas = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/save_as.png'),
_('Save Project &As ...\tCTRL+S'), self)
self.menufilesaveprojectas = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/save_as.png'), _('Save Project &As ...\tCTRL+S'), self)
self.menufile_save.addAction(self.menufilesaveprojectas)
# Save Project Copy ...
self.menufilesaveprojectcopy = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/floppy16.png'),
_('Save Project C&opy ...'), self)
self.menufilesaveprojectcopy = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/floppy16.png'), _('Save Project C&opy ...'), self)
self.menufile_save.addAction(self.menufilesaveprojectcopy)
self.menufile_save.addSeparator()
@ -267,8 +286,8 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menufile.addSeparator()
# Quit
self.menufile_exit = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/power16.png'),
_('E&xit'), self)
self.menufile_exit = QtWidgets.QAction(
QtGui.QIcon(self.app.resource_location + '/power16.png'), _('E&xit'), self)
# exitAction.setShortcut('Ctrl+Q')
# exitAction.setStatusTip('Exit application')
self.menufile.addAction(self.menufile_exit)
@ -279,10 +298,10 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menuedit = self.menu.addMenu(_('Edit'))
# Separator
self.menuedit.addSeparator()
self.menueditedit = self.menuedit.addAction(QtGui.QIcon(self.app.resource_location + '/edit16.png'),
_('Edit Object\tE'))
self.menueditok = self.menuedit.addAction(QtGui.QIcon(self.app.resource_location + '/edit_ok16.png'),
_('Close Editor\tCTRL+S'))
self.menueditedit = self.menuedit.addAction(
QtGui.QIcon(self.app.resource_location + '/edit16.png'), _('Edit Object\tE'))
self.menueditok = self.menuedit.addAction(
QtGui.QIcon(self.app.resource_location + '/edit_ok16.png'), _('Close Editor\tCTRL+S'))
# adjust the initial state of the menu entries related to the editor
self.menueditedit.setDisabled(False)
@ -290,8 +309,8 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
# Separator
self.menuedit.addSeparator()
self.menuedit_convert = self.menuedit.addMenu(QtGui.QIcon(self.app.resource_location + '/convert24.png'),
_('Conversion'))
self.menuedit_convert = self.menuedit.addMenu(
QtGui.QIcon(self.app.resource_location + '/convert24.png'), _('Conversion'))
self.menuedit_convertjoin = self.menuedit_convert.addAction(
QtGui.QIcon(self.app.resource_location + '/join16.png'), _('&Join Geo/Gerber/Exc -> Geo'))
self.menuedit_convertjoin.setToolTip(