Merged marius_stanciu/flatcam_beta/Beta into Beta

This commit is contained in:
Marius Stanciu 2020-04-29 11:11:15 +03:00
commit 24a12f0fcb
7 changed files with 25 additions and 49 deletions

View File

@ -17,6 +17,7 @@ CHANGELOG for FlatCAM beta
- promoted some methods to be static - promoted some methods to be static
- set the default layout on first run to the 'minimal' value - set the default layout on first run to the 'minimal' value
- modified the method that detects which tab was closed in the Plot Area so it will no longer depend on it's translated text but on it's objectName set on the QTab creation - modified the method that detects which tab was closed in the Plot Area so it will no longer depend on it's translated text but on it's objectName set on the QTab creation
- fixed the merge methods for all FlatCAM objects
28.04.2020 28.04.2020

View File

@ -663,7 +663,6 @@ class App(QtCore.QObject):
self.preferencesUiManager.show_preferences_gui() self.preferencesUiManager.show_preferences_gui()
# ### End of Data #### # ### End of Data ####
# ########################################################################################################### # ###########################################################################################################
@ -1683,7 +1682,6 @@ class App(QtCore.QObject):
if App.args: if App.args:
self.args_at_startup.emit(App.args) self.args_at_startup.emit(App.args)
if self.defaults.old_defaults_found is True: if self.defaults.old_defaults_found is True:
self.inform.emit('[WARNING_NOTCL] %s' % _("Found old default preferences files. " self.inform.emit('[WARNING_NOTCL] %s' % _("Found old default preferences files. "
"Please reboot the application to update.")) "Please reboot the application to update."))
@ -1695,26 +1693,6 @@ class App(QtCore.QObject):
# ################################################################################################################# # #################################################################################################################
# ################################################################################################################# # #################################################################################################################
# ################################################################################################################# # #################################################################################################################
@staticmethod @staticmethod
def copy_and_overwrite(from_path, to_path): def copy_and_overwrite(from_path, to_path):
@ -1880,8 +1858,6 @@ class App(QtCore.QObject):
fcTranslate.restart_program(app=self) fcTranslate.restart_program(app=self)
def clear_pool(self): def clear_pool(self):
""" """
Clear the multiprocessing pool and calls garbage collector. Clear the multiprocessing pool and calls garbage collector.
@ -2410,7 +2386,6 @@ class App(QtCore.QObject):
loc = os.path.dirname(__file__) loc = os.path.dirname(__file__)
return loc return loc
def info(self, msg): def info(self, msg):
""" """
Informs the user. Normally on the status bar, optionally Informs the user. Normally on the status bar, optionally
@ -2509,7 +2484,6 @@ class App(QtCore.QObject):
else: else:
self.ui.toolbarshell.setVisible(False) self.ui.toolbarshell.setVisible(False)
def on_import_preferences(self): def on_import_preferences(self):
""" """
Loads the application default settings from a saved file into Loads the application default settings from a saved file into
@ -2550,7 +2524,7 @@ class App(QtCore.QObject):
self.defaults.report_usage("on_export_preferences") self.defaults.report_usage("on_export_preferences")
App.log.debug("on_export_preferences()") App.log.debug("on_export_preferences()")
defaults_file_content = None # defaults_file_content = None
# Show file chooser # Show file chooser
date = str(datetime.today()).rpartition('.')[0] date = str(datetime.today()).rpartition('.')[0]
@ -3751,20 +3725,20 @@ class App(QtCore.QObject):
root_path = winreg.HKEY_CURRENT_USER root_path = winreg.HKEY_CURRENT_USER
# create the keys # create the keys
def set_reg(name, root_path, new_reg_path, value): def set_reg(name, root_pth, new_reg_path, value):
try: try:
winreg.CreateKey(root_path, new_reg_path) winreg.CreateKey(root_pth, new_reg_path)
with winreg.OpenKey(root_path, new_reg_path, 0, winreg.KEY_WRITE) as registry_key: with winreg.OpenKey(root_pth, new_reg_path, 0, winreg.KEY_WRITE) as registry_key:
winreg.SetValueEx(registry_key, name, 0, winreg.REG_SZ, value) winreg.SetValueEx(registry_key, name, 0, winreg.REG_SZ, value)
return True return True
except WindowsError: except WindowsError:
return False return False
# delete key in registry # delete key in registry
def delete_reg(root_path, reg_path, key_to_del): def delete_reg(root_pth, reg_path, key_to_del):
key_to_del_path = reg_path + key_to_del key_to_del_path = reg_path + key_to_del
try: try:
winreg.DeleteKey(root_path, key_to_del_path) winreg.DeleteKey(root_pth, key_to_del_path)
return True return True
except WindowsError: except WindowsError:
return False return False
@ -4041,7 +4015,7 @@ class App(QtCore.QObject):
# if at least one True object is in the list then due of the previous check, all list elements are True objects # if at least one True object is in the list then due of the previous check, all list elements are True objects
if True in geo_type_set: if True in geo_type_set:
def initialize(geo_obj, app): def initialize(geo_obj, app):
GeometryObject.merge(self, geo_list=objs, geo_final=geo_obj, multigeo=True) GeometryObject.merge(geo_list=objs, geo_final=geo_obj, multigeo=True)
app.inform.emit('[success] %s.' % _("Geometry merging finished")) app.inform.emit('[success] %s.' % _("Geometry merging finished"))
# rename all the ['name] key in obj.tools[tooluid]['data'] to the obj_name_multi # rename all the ['name] key in obj.tools[tooluid]['data'] to the obj_name_multi
@ -4051,7 +4025,7 @@ class App(QtCore.QObject):
self.new_object("geometry", obj_name_multi, initialize) self.new_object("geometry", obj_name_multi, initialize)
else: else:
def initialize(geo_obj, app): def initialize(geo_obj, app):
GeometryObject.merge(self, geo_list=objs, geo_final=geo_obj, multigeo=False) GeometryObject.merge(geo_list=objs, geo_final=geo_obj, multigeo=False)
app.inform.emit('[success] %s.' % _("Geometry merging finished")) app.inform.emit('[success] %s.' % _("Geometry merging finished"))
# rename all the ['name] key in obj.tools[tooluid]['data'] to the obj_name_multi # rename all the ['name] key in obj.tools[tooluid]['data'] to the obj_name_multi
@ -4084,7 +4058,7 @@ class App(QtCore.QObject):
return 'fail' return 'fail'
def initialize(exc_obj, app): def initialize(exc_obj, app):
ExcellonObject.merge(exc_list=objs, exc_final=exc_obj) ExcellonObject.merge(exc_list=objs, exc_final=exc_obj, decimals=self.decimals)
app.inform.emit('[success] %s.' % _("Excellon merging finished")) app.inform.emit('[success] %s.' % _("Excellon merging finished"))
self.new_object("excellon", 'Combo_Excellon', initialize) self.new_object("excellon", 'Combo_Excellon', initialize)
@ -4112,7 +4086,7 @@ class App(QtCore.QObject):
return 'fail' return 'fail'
def initialize(grb_obj, app): def initialize(grb_obj, app):
GerberObject.merge(self, grb_list=objs, grb_final=grb_obj) GerberObject.merge(grb_list=objs, grb_final=grb_obj)
app.inform.emit('[success] %s.' % _("Gerber merging finished")) app.inform.emit('[success] %s.' % _("Gerber merging finished"))
self.new_object("gerber", 'Combo_Gerber', initialize) self.new_object("gerber", 'Combo_Gerber', initialize)

View File

@ -130,7 +130,8 @@ class ExcellonObject(FlatCAMObj, Excellon):
# from predecessors. # from predecessors.
self.ser_attrs += ['options', 'kind'] self.ser_attrs += ['options', 'kind']
def merge(self, exc_list, exc_final): @staticmethod
def merge(exc_list, exc_final, decimals=None):
""" """
Merge Excellon objects found in exc_list parameter into exc_final object. Merge Excellon objects found in exc_list parameter into exc_final object.
Options are always copied from source . Options are always copied from source .
@ -146,10 +147,9 @@ class ExcellonObject(FlatCAMObj, Excellon):
:return: None :return: None
""" """
try: if decimals is None:
decimals_exc = self.decimals decimals = 4
except AttributeError: decimals_exc = decimals
decimals_exc = 4
# flag to signal that we need to reorder the tools dictionary and drills and slots lists # flag to signal that we need to reorder the tools dictionary and drills and slots lists
flag_order = False flag_order = False

View File

@ -2519,10 +2519,10 @@ class GeometryObject(FlatCAMObj, Geometry):
self.ui.plot_cb.setChecked(True) self.ui.plot_cb.setChecked(True)
self.ui_connect() self.ui_connect()
def merge(self, geo_list, geo_final, multigeo=None): @staticmethod
def merge(geo_list, geo_final, multigeo=None):
""" """
Merges the geometry of objects in grb_list into Merges the geometry of objects in grb_list into the geometry of geo_final.
the geometry of geo_final.
:param geo_list: List of GerberObject Objects to join. :param geo_list: List of GerberObject Objects to join.
:param geo_final: Destination GerberObject object. :param geo_final: Destination GerberObject object.
@ -2552,7 +2552,7 @@ class GeometryObject(FlatCAMObj, Geometry):
# Expand lists # Expand lists
if type(geo_obj) is list: if type(geo_obj) is list:
GeometryObject.merge(self, geo_list=geo_obj, geo_final=geo_final) GeometryObject.merge(geo_list=geo_obj, geo_final=geo_final)
# If not list, just append # If not list, just append
else: else:
if multigeo is None or multigeo is False: if multigeo is None or multigeo is False:

View File

@ -39,7 +39,8 @@ class GerberObject(FlatCAMObj, Gerber):
ui_type = GerberObjectUI ui_type = GerberObjectUI
def merge(self, grb_list, grb_final): @staticmethod
def merge(grb_list, grb_final):
""" """
Merges the geometry of objects in geo_list into Merges the geometry of objects in geo_list into
the geometry of geo_final. the geometry of geo_final.
@ -64,7 +65,7 @@ class GerberObject(FlatCAMObj, Gerber):
# Expand lists # Expand lists
if type(grb) is list: if type(grb) is list:
GerberObject.merge(grb, grb_final) GerberObject.merge(grb_list=grb, grb_final=grb_final)
else: # If not list, just append else: # If not list, just append
for option in grb.options: for option in grb.options:
if option != 'name': if option != 'name':

View File

@ -62,7 +62,7 @@ class TclCommandJoinExcellon(TclCommand):
objs.append(obj) objs.append(obj)
def initialize(obj_, app): def initialize(obj_, app):
ExcellonObject.merge(self, objs, obj_) ExcellonObject.merge(objs, obj_, decimals=self.app.decimals)
if objs and len(objs) >= 2: if objs and len(objs) >= 2:
self.app.new_object("excellon", outname, initialize, plot=False) self.app.new_object("excellon", outname, initialize, plot=False)

View File

@ -62,7 +62,7 @@ class TclCommandJoinGeometry(TclCommand):
objs.append(obj) objs.append(obj)
def initialize(obj_, app): def initialize(obj_, app):
GeometryObject.merge(self, objs, obj_) GeometryObject.merge(objs, obj_)
if objs and len(objs) >= 2: if objs and len(objs) >= 2:
self.app.new_object("geometry", outname, initialize, plot=False) self.app.new_object("geometry", outname, initialize, plot=False)