- now, Excellon and Gerber edited objects will have the source_code updated and ready to be saved
- the edited Gerber (or Excellon) object now is kept in the app after editing and the edited object is a new object - added a message to the splash screen
This commit is contained in:
parent
295cba8539
commit
1a8784f5ab
19
FlatCAM.py
19
FlatCAM.py
|
@ -1,7 +1,7 @@
|
|||
import sys
|
||||
import os
|
||||
|
||||
from PyQt5 import QtWidgets
|
||||
from PyQt5 import QtWidgets, QtGui
|
||||
from PyQt5.QtCore import QSettings, Qt
|
||||
from FlatCAMApp import App
|
||||
from flatcamGUI import VisPyPatches
|
||||
|
@ -60,18 +60,17 @@ if __name__ == '__main__':
|
|||
|
||||
# Create and display the splash screen
|
||||
# from here: https://eli.thegreenplace.net/2009/05/09/creating-splash-screens-in-pyqt
|
||||
# splash_pix = QtWidgets.QPixmap('splash_loading.png')
|
||||
# splash = QtWidgets.QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
|
||||
splash_pix = QtGui.QPixmap('share/flatcam_icon256.png')
|
||||
splash = QtWidgets.QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
|
||||
# splash.setMask(splash_pix.mask())
|
||||
# splash.show()
|
||||
# app.processEvents()
|
||||
#
|
||||
# # Simulate something that takes time
|
||||
# while True:
|
||||
# pass
|
||||
splash.show()
|
||||
app.processEvents()
|
||||
splash.showMessage("FlatCAM is initializing ...",
|
||||
alignment=Qt.AlignBottom | Qt.AlignLeft,
|
||||
color=QtGui.QColor("gray"))
|
||||
|
||||
fc = App()
|
||||
splash.finish(fc.ui)
|
||||
fc.ui.show()
|
||||
# splash.finish(fc)
|
||||
|
||||
sys.exit(app.exec_())
|
||||
|
|
|
@ -8530,7 +8530,7 @@ class App(QtCore.QObject):
|
|||
"Most likely another app is holding the file open and not accessible."))
|
||||
return 'fail'
|
||||
|
||||
def export_excellon(self, obj_name, filename, use_thread=True):
|
||||
def export_excellon(self, obj_name, filename, local_use=None, use_thread=True):
|
||||
"""
|
||||
Exports a Excellon Object to an Excellon file.
|
||||
|
||||
|
@ -8551,11 +8551,14 @@ class App(QtCore.QObject):
|
|||
)
|
||||
units = ''
|
||||
|
||||
try:
|
||||
obj = self.collection.get_by_name(str(obj_name))
|
||||
except:
|
||||
# TODO: The return behavior has not been established... should raise exception?
|
||||
return "Could not retrieve object: %s" % obj_name
|
||||
if local_use is None:
|
||||
try:
|
||||
obj = self.collection.get_by_name(str(obj_name))
|
||||
except:
|
||||
# TODO: The return behavior has not been established... should raise exception?
|
||||
return "Could not retrieve object: %s" % obj_name
|
||||
else:
|
||||
obj = local_use
|
||||
|
||||
# updated units
|
||||
eunits = self.defaults["excellon_exp_units"]
|
||||
|
@ -8635,20 +8638,23 @@ class App(QtCore.QObject):
|
|||
exported_excellon += excellon_code
|
||||
exported_excellon += footer
|
||||
|
||||
try:
|
||||
with open(filename, 'w') as fp:
|
||||
fp.write(exported_excellon)
|
||||
except PermissionError:
|
||||
self.inform.emit('[WARNING] %s' %
|
||||
_("Permission denied, saving not possible.\n"
|
||||
"Most likely another app is holding the file open and not accessible."))
|
||||
return 'fail'
|
||||
if local_use is None:
|
||||
try:
|
||||
with open(filename, 'w') as fp:
|
||||
fp.write(exported_excellon)
|
||||
except PermissionError:
|
||||
self.inform.emit('[WARNING] %s' %
|
||||
_("Permission denied, saving not possible.\n"
|
||||
"Most likely another app is holding the file open and not accessible."))
|
||||
return 'fail'
|
||||
|
||||
if self.defaults["global_open_style"] is False:
|
||||
self.file_opened.emit("Excellon", filename)
|
||||
self.file_saved.emit("Excellon", filename)
|
||||
self.inform.emit('[success] %s: %s' %
|
||||
(_("Excellon file exported to"), filename))
|
||||
if self.defaults["global_open_style"] is False:
|
||||
self.file_opened.emit("Excellon", filename)
|
||||
self.file_saved.emit("Excellon", filename)
|
||||
self.inform.emit('[success] %s: %s' %
|
||||
(_("Excellon file exported to"), filename))
|
||||
else:
|
||||
return exported_excellon
|
||||
except Exception as e:
|
||||
log.debug("App.export_excellon.make_excellon() --> %s" % str(e))
|
||||
return 'fail'
|
||||
|
@ -8670,7 +8676,9 @@ class App(QtCore.QObject):
|
|||
if ret == 'fail':
|
||||
self.inform.emit('[ERROR_NOTCL] %s' %
|
||||
_('Could not export Excellon file.'))
|
||||
return
|
||||
return 'fail'
|
||||
if local_use is not None:
|
||||
return ret
|
||||
|
||||
def export_gerber(self, obj_name, filename, local_use=None, use_thread=True):
|
||||
"""
|
||||
|
|
|
@ -14,6 +14,9 @@ CAD program, and create G-Code for Isolation routing.
|
|||
- small changes in the TclCommands: MillDrills, MillSlots, DrillCNCJob: the new parameter for tolerance is now named: tooldia
|
||||
- cleaned up the 'About FlatCAM' window, started to give credits for the translation team
|
||||
- started to add an application splash screen
|
||||
- now, Excellon and Gerber edited objects will have the source_code updated and ready to be saved
|
||||
- the edited Gerber (or Excellon) object now is kept in the app after editing and the edited object is a new object
|
||||
- added a message to the splash screen
|
||||
|
||||
11.09.2019
|
||||
|
||||
|
|
|
@ -3125,7 +3125,6 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|||
self.app.worker_task.emit({'fcn': self.new_edited_excellon,
|
||||
'params': [self.edited_obj_name]})
|
||||
|
||||
|
||||
self.new_tool_offset = self.exc_obj.tool_offset
|
||||
|
||||
# reset the tool table
|
||||
|
@ -3134,8 +3133,8 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|||
self.last_tool_selected = None
|
||||
|
||||
# delete the edited Excellon object which will be replaced by a new one having the edited content of the first
|
||||
self.app.collection.set_active(self.exc_obj.options['name'])
|
||||
self.app.collection.delete_active()
|
||||
# self.app.collection.set_active(self.exc_obj.options['name'])
|
||||
# self.app.collection.delete_active()
|
||||
|
||||
# restore GUI to the Selected TAB
|
||||
# Remove anything else in the GUI
|
||||
|
@ -3193,6 +3192,8 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|||
app_obj.inform.emit(msg)
|
||||
raise
|
||||
# raise
|
||||
excellon_obj.source_file = self.app.export_excellon(obj_name=outname, filename=None,
|
||||
local_use=excellon_obj, use_thread=False)
|
||||
|
||||
with self.app.proc_container.new(_("Creating Excellon.")):
|
||||
|
||||
|
|
|
@ -3713,7 +3713,36 @@ class FlatCAMGrbEditor(QtCore.QObject):
|
|||
for apid in self.gerber_obj.apertures:
|
||||
temp_elem = []
|
||||
if 'geometry' in self.gerber_obj.apertures[apid]:
|
||||
# for elem in self.gerber_obj.apertures[apid]['geometry']:
|
||||
# if 'solid' in elem:
|
||||
# solid_geo = elem['solid']
|
||||
# for clear_geo in global_clear_geo:
|
||||
# # Make sure that the clear_geo is within the solid_geo otherwise we loose
|
||||
# # the solid_geometry. We want for clear_geometry just to cut into solid_geometry not to
|
||||
# # delete it
|
||||
# if clear_geo.within(solid_geo):
|
||||
# solid_geo = solid_geo.difference(clear_geo)
|
||||
# try:
|
||||
# for poly in solid_geo:
|
||||
# new_elem = dict()
|
||||
#
|
||||
# new_elem['solid'] = poly
|
||||
# if 'clear' in elem:
|
||||
# new_elem['clear'] = poly
|
||||
# if 'follow' in elem:
|
||||
# new_elem['follow'] = poly
|
||||
# temp_elem.append(deepcopy(new_elem))
|
||||
# except TypeError:
|
||||
# new_elem = dict()
|
||||
# new_elem['solid'] = solid_geo
|
||||
# if 'clear' in elem:
|
||||
# new_elem['clear'] = solid_geo
|
||||
# if 'follow' in elem:
|
||||
# new_elem['follow'] = solid_geo
|
||||
# temp_elem.append(deepcopy(new_elem))
|
||||
for elem in self.gerber_obj.apertures[apid]['geometry']:
|
||||
new_elem = dict()
|
||||
|
||||
if 'solid' in elem:
|
||||
solid_geo = elem['solid']
|
||||
for clear_geo in global_clear_geo:
|
||||
|
@ -3722,24 +3751,14 @@ class FlatCAMGrbEditor(QtCore.QObject):
|
|||
# delete it
|
||||
if clear_geo.within(solid_geo):
|
||||
solid_geo = solid_geo.difference(clear_geo)
|
||||
try:
|
||||
for poly in solid_geo:
|
||||
new_elem = dict()
|
||||
|
||||
new_elem['solid'] = poly
|
||||
if 'clear' in elem:
|
||||
new_elem['clear'] = poly
|
||||
if 'follow' in elem:
|
||||
new_elem['follow'] = poly
|
||||
temp_elem.append(deepcopy(new_elem))
|
||||
except TypeError:
|
||||
new_elem = dict()
|
||||
new_elem['solid'] = solid_geo
|
||||
if 'clear' in elem:
|
||||
new_elem['clear'] = solid_geo
|
||||
if 'follow' in elem:
|
||||
new_elem['follow'] = solid_geo
|
||||
temp_elem.append(deepcopy(new_elem))
|
||||
new_elem['solid'] = solid_geo
|
||||
if 'clear' in elem:
|
||||
new_elem['clear'] = elem['clear']
|
||||
if 'follow' in elem:
|
||||
new_elem['follow'] = elem['follow']
|
||||
temp_elem.append(deepcopy(new_elem))
|
||||
|
||||
self.gerber_obj.apertures[apid]['geometry'] = deepcopy(temp_elem)
|
||||
log.warning("Polygon difference done for %d apertures." % len(self.gerber_obj.apertures))
|
||||
|
||||
|
@ -3876,19 +3895,19 @@ class FlatCAMGrbEditor(QtCore.QObject):
|
|||
grb_obj.apertures[storage_apid][k] = []
|
||||
for geo_el in val:
|
||||
geometric_data = geo_el.geo
|
||||
|
||||
new_geo_el = dict()
|
||||
if 'solid' in geometric_data:
|
||||
new_geo_el['solid'] = geometric_data['solid']
|
||||
poly_buffer.append(deepcopy(new_geo_el['solid']))
|
||||
|
||||
if 'follow' in geometric_data:
|
||||
if isinstance(geometric_data['follow'], Polygon):
|
||||
buff_val = -(int(storage_apid) / 2)
|
||||
geo_f = (geometric_data['follow'].buffer(buff_val)).exterior
|
||||
new_geo_el['follow'] = geo_f
|
||||
else:
|
||||
new_geo_el['follow'] = geometric_data['follow']
|
||||
# if isinstance(geometric_data['follow'], Polygon):
|
||||
# buff_val = -(int(storage_val['size']) / 2)
|
||||
# geo_f = (geometric_data['follow'].buffer(buff_val)).exterior
|
||||
# new_geo_el['follow'] = geo_f
|
||||
# else:
|
||||
# new_geo_el['follow'] = geometric_data['follow']
|
||||
new_geo_el['follow'] = geometric_data['follow']
|
||||
follow_buffer.append(deepcopy(new_geo_el['follow']))
|
||||
else:
|
||||
if 'solid' in geometric_data:
|
||||
|
@ -3910,6 +3929,9 @@ class FlatCAMGrbEditor(QtCore.QObject):
|
|||
new_poly = new_poly.buffer(0.00000001)
|
||||
new_poly = new_poly.buffer(-0.00000001)
|
||||
|
||||
# for ad in grb_obj.apertures:
|
||||
# print(ad, grb_obj.apertures[ad])
|
||||
|
||||
try:
|
||||
__ = iter(new_poly)
|
||||
except TypeError:
|
||||
|
@ -3924,7 +3946,6 @@ class FlatCAMGrbEditor(QtCore.QObject):
|
|||
else:
|
||||
grb_obj.options[k] = deepcopy(v)
|
||||
|
||||
grb_obj.source_file = []
|
||||
grb_obj.multigeo = False
|
||||
grb_obj.follow = False
|
||||
grb_obj.gerber_units = app_obj.defaults['units']
|
||||
|
@ -3940,6 +3961,8 @@ class FlatCAMGrbEditor(QtCore.QObject):
|
|||
msg += traceback.format_exc()
|
||||
app_obj.inform.emit(msg)
|
||||
raise
|
||||
grb_obj.source_file = self.app.export_gerber(obj_name=out_name, filename=None,
|
||||
local_use=grb_obj, use_thread=False)
|
||||
|
||||
with self.app.proc_container.new(_("Creating Gerber.")):
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue