- fixed Edit -> Copy as Geom function handler to work for Excellon objects, too
- made sure that the mouse pointer is restored to default on Editor exit
This commit is contained in:
@@ -4633,9 +4633,14 @@ class App(QtCore.QObject):
|
|||||||
if obj.tools:
|
if obj.tools:
|
||||||
obj_init.tools = obj.tools
|
obj_init.tools = obj.tools
|
||||||
|
|
||||||
def initialize_excellon(obj, app):
|
def initialize_excellon(obj_init, app):
|
||||||
objs = self.collection.get_selected()
|
# objs = self.collection.get_selected()
|
||||||
FlatCAMGeometry.merge(objs, obj)
|
# FlatCAMGeometry.merge(objs, obj)
|
||||||
|
solid_geo = []
|
||||||
|
for tool in obj.tools:
|
||||||
|
for geo in obj.tools[tool]['solid_geometry']:
|
||||||
|
solid_geo.append(geo)
|
||||||
|
obj_init.solid_geometry = deepcopy(solid_geo)
|
||||||
|
|
||||||
for obj in self.collection.get_selected():
|
for obj in self.collection.get_selected():
|
||||||
|
|
||||||
|
|||||||
@@ -397,10 +397,11 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
|||||||
if index.isValid():
|
if index.isValid():
|
||||||
obj = index.internalPointer().obj
|
obj = index.internalPointer().obj
|
||||||
if obj:
|
if obj:
|
||||||
old_name = obj.options['name']
|
old_name = str(obj.options['name'])
|
||||||
|
new_name = str(data)
|
||||||
|
if old_name != new_name:
|
||||||
# rename the object
|
# rename the object
|
||||||
obj.options["name"] = str(data)
|
obj.options["name"] = str(data)
|
||||||
new_name = obj.options['name']
|
|
||||||
|
|
||||||
# update the SHELL auto-completer model data
|
# update the SHELL auto-completer model data
|
||||||
try:
|
try:
|
||||||
@@ -413,7 +414,8 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
|||||||
"setData() --> Could not remove the old object name from auto-completer model list")
|
"setData() --> Could not remove the old object name from auto-completer model list")
|
||||||
|
|
||||||
obj.build_ui()
|
obj.build_ui()
|
||||||
self.app.inform.emit(_("Object renamed from {old} to {new}").format(old=old_name, new=new_name))
|
self.app.inform.emit(_("Object renamed from <b>{old}</b> to <b>{new}</b>").format(old=old_name,
|
||||||
|
new=new_name))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -721,7 +723,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
|||||||
color='red', name=str(obj.options['name'])))
|
color='red', name=str(obj.options['name'])))
|
||||||
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
FlatCAMApp.App.log.debug("on_list_selection_change(): Index Error (Nothing selected?)")
|
# FlatCAMApp.App.log.debug("on_list_selection_change(): Index Error (Nothing selected?)")
|
||||||
self.app.inform.emit('')
|
self.app.inform.emit('')
|
||||||
try:
|
try:
|
||||||
self.app.ui.selected_scroll_area.takeWidget()
|
self.app.ui.selected_scroll_area.takeWidget()
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ CAD program, and create G-Code for Isolation routing.
|
|||||||
- Geometry Editor: modified the intersection (if the selected shapes don't intersects preserve them) and substract functions (delete all shapes that were used in the process)
|
- Geometry Editor: modified the intersection (if the selected shapes don't intersects preserve them) and substract functions (delete all shapes that were used in the process)
|
||||||
- work in the ToolSilk
|
- work in the ToolSilk
|
||||||
- for all objects, if in Selected the object name is changed to the same name, the rename is not done (because there is nothing changed)
|
- for all objects, if in Selected the object name is changed to the same name, the rename is not done (because there is nothing changed)
|
||||||
|
- fixed Edit -> Copy as Geom function handler to work for Excellon objects, too
|
||||||
|
- made sure that the mouse pointer is restored to default on Editor exit
|
||||||
|
-
|
||||||
|
|
||||||
24.04.2019
|
24.04.2019
|
||||||
|
|
||||||
|
|||||||
@@ -1653,6 +1653,11 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|||||||
self.drills_frame.show()
|
self.drills_frame.show()
|
||||||
|
|
||||||
def deactivate(self):
|
def deactivate(self):
|
||||||
|
try:
|
||||||
|
QtGui.QGuiApplication.restoreOverrideCursor()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
# adjust the status of the menu entries related to the editor
|
# adjust the status of the menu entries related to the editor
|
||||||
self.app.ui.menueditedit.setDisabled(False)
|
self.app.ui.menueditedit.setDisabled(False)
|
||||||
self.app.ui.menueditok.setDisabled(True)
|
self.app.ui.menueditok.setDisabled(True)
|
||||||
|
|||||||
@@ -2979,6 +2979,11 @@ class FlatCAMGeoEditor(QtCore.QObject):
|
|||||||
self.editor_active = True
|
self.editor_active = True
|
||||||
|
|
||||||
def deactivate(self):
|
def deactivate(self):
|
||||||
|
try:
|
||||||
|
QtGui.QGuiApplication.restoreOverrideCursor()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
# adjust the status of the menu entries related to the editor
|
# adjust the status of the menu entries related to the editor
|
||||||
self.app.ui.menueditedit.setDisabled(False)
|
self.app.ui.menueditedit.setDisabled(False)
|
||||||
self.app.ui.menueditok.setDisabled(True)
|
self.app.ui.menueditok.setDisabled(True)
|
||||||
|
|||||||
@@ -2690,6 +2690,11 @@ class FlatCAMGrbEditor(QtCore.QObject):
|
|||||||
self.editor_active = True
|
self.editor_active = True
|
||||||
|
|
||||||
def deactivate_grb_editor(self):
|
def deactivate_grb_editor(self):
|
||||||
|
try:
|
||||||
|
QtGui.QGuiApplication.restoreOverrideCursor()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
# adjust the status of the menu entries related to the editor
|
# adjust the status of the menu entries related to the editor
|
||||||
self.app.ui.menueditedit.setDisabled(False)
|
self.app.ui.menueditedit.setDisabled(False)
|
||||||
self.app.ui.menueditok.setDisabled(True)
|
self.app.ui.menueditok.setDisabled(True)
|
||||||
|
|||||||
@@ -105,6 +105,13 @@ class ToolSilk(FlatCAMTool):
|
|||||||
|
|
||||||
self.solder_union = None
|
self.solder_union = None
|
||||||
|
|
||||||
|
# object to hold a flattened geometry
|
||||||
|
self.flat_geometry = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.intersect_btn.clicked.disconnect(self.on_intersection_click)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
self.intersect_btn.clicked.connect(self.on_intersection_click)
|
self.intersect_btn.clicked.connect(self.on_intersection_click)
|
||||||
|
|
||||||
def install(self, icon=None, separator=None, **kwargs):
|
def install(self, icon=None, separator=None, **kwargs):
|
||||||
@@ -162,10 +169,10 @@ class ToolSilk(FlatCAMTool):
|
|||||||
self.new_apertures[apid]['size'] = self.silk_obj.apertures[apid]['size']
|
self.new_apertures[apid]['size'] = self.silk_obj.apertures[apid]['size']
|
||||||
self.new_apertures[apid]['solid_geometry'] = []
|
self.new_apertures[apid]['solid_geometry'] = []
|
||||||
|
|
||||||
geo_union_list = []
|
# geo_union_list = []
|
||||||
for apid1 in self.sm_obj.apertures:
|
# for apid1 in self.sm_obj.apertures:
|
||||||
geo_union_list += self.sm_obj.apertures[apid1]['solid_geometry']
|
# geo_union_list += self.sm_obj.apertures[apid1]['solid_geometry']
|
||||||
self.solder_union = cascaded_union(geo_union_list)
|
# self.solder_union = cascaded_union(geo_union_list)
|
||||||
|
|
||||||
# start the QTimer with 1 second period check
|
# start the QTimer with 1 second period check
|
||||||
self.periodic_check(1000)
|
self.periodic_check(1000)
|
||||||
@@ -178,30 +185,29 @@ class ToolSilk(FlatCAMTool):
|
|||||||
def aperture_intersection(self, apid, geo_list):
|
def aperture_intersection(self, apid, geo_list):
|
||||||
self.promises.append(apid)
|
self.promises.append(apid)
|
||||||
new_solid_geometry = []
|
new_solid_geometry = []
|
||||||
for g in geo_list:
|
|
||||||
print(g.exterior.wkt)
|
|
||||||
|
|
||||||
with self.app.proc_container.new(_("Parsing aperture %s geometry ..." % str(apid))):
|
with self.app.proc_container.new(_("Parsing aperture %s geometry ..." % str(apid))):
|
||||||
for geo_silk in geo_list:
|
for geo_silk in geo_list:
|
||||||
if geo_silk.exterior.intersects(self.solder_union.exterior):
|
for ap in self.sm_obj.apertures:
|
||||||
print("yes")
|
for solder_poly in self.sm_obj.apertures[ap]['solid_geometry']:
|
||||||
new_geo = geo_silk.exterior.difference(self.solder_union.exterior)
|
if geo_silk.exterior.intersects(solder_poly):
|
||||||
|
|
||||||
|
new_geo = self.subtract_polygon(geo_silk, solder_poly)
|
||||||
|
if not new_geo.is_empty:
|
||||||
|
print(new_geo.wkt)
|
||||||
# if the resulting geometry is not empty add it to the new_apertures solid_geometry
|
# if the resulting geometry is not empty add it to the new_apertures solid_geometry
|
||||||
try:
|
try:
|
||||||
for g in new_geo:
|
for g in new_geo:
|
||||||
new_solid_geometry.append(g)
|
new_solid_geometry.append(g)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
new_solid_geometry.append(new_geo)
|
new_solid_geometry.append(new_geo)
|
||||||
|
# else:
|
||||||
else:
|
# new_solid_geometry.append(geo_silk)
|
||||||
print("no")
|
|
||||||
new_solid_geometry.append(geo_silk)
|
|
||||||
|
|
||||||
if new_solid_geometry:
|
if new_solid_geometry:
|
||||||
try:
|
try:
|
||||||
while not self.new_apertures[apid]['solid_geometry']:
|
while not self.new_apertures[apid]['solid_geometry']:
|
||||||
self.new_apertures[apid]['solid_geometry'] = new_solid_geometry
|
self.new_apertures[apid]['solid_geometry'] = new_solid_geometry
|
||||||
time.sleep(0.1)
|
time.sleep(0.5)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -213,11 +219,72 @@ class ToolSilk(FlatCAMTool):
|
|||||||
self.promises.remove(apid)
|
self.promises.remove(apid)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
time.sleep(0.1)
|
time.sleep(0.5)
|
||||||
except:
|
except:
|
||||||
log.debug("Promise fulfilled: %s" % str(apid))
|
log.debug("Promise fulfilled: %s" % str(apid))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def subtract_polygon(self, geometry, polygon):
|
||||||
|
"""
|
||||||
|
Subtract polygon from the given object. This only operates on the paths in the original geometry, i.e. it converts polygons into paths.
|
||||||
|
|
||||||
|
:param points: The vertices of the polygon.
|
||||||
|
:return: none
|
||||||
|
"""
|
||||||
|
|
||||||
|
# pathonly should be always True, otherwise polygons are not subtracted
|
||||||
|
flat_geometry = self.flatten(geometry=geometry, pathonly=True)
|
||||||
|
log.debug("%d paths" % len(flat_geometry))
|
||||||
|
|
||||||
|
toolgeo=cascaded_union(polygon)
|
||||||
|
diffs=[]
|
||||||
|
for target in flat_geometry:
|
||||||
|
if type(target) == LineString or type(target) == LinearRing:
|
||||||
|
diffs.append(target.difference(toolgeo))
|
||||||
|
else:
|
||||||
|
log.warning("Not implemented.")
|
||||||
|
|
||||||
|
return cascaded_union(diffs)
|
||||||
|
|
||||||
|
def flatten(self, geometry=None, reset=True, pathonly=False):
|
||||||
|
"""
|
||||||
|
Creates a list of non-iterable linear geometry objects.
|
||||||
|
Polygons are expanded into its exterior and interiors if specified.
|
||||||
|
|
||||||
|
Results are placed in self.flat_geometry
|
||||||
|
|
||||||
|
:param geometry: Shapely type or list or list of list of such.
|
||||||
|
:param reset: Clears the contents of self.flat_geometry.
|
||||||
|
:param pathonly: Expands polygons into linear elements.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if geometry is None:
|
||||||
|
log.debug("ToolSilk.flatten() --> There is no Geometry to flatten")
|
||||||
|
return
|
||||||
|
|
||||||
|
if reset:
|
||||||
|
self.flat_geometry = []
|
||||||
|
|
||||||
|
## If iterable, expand recursively.
|
||||||
|
try:
|
||||||
|
for geo in geometry:
|
||||||
|
if geo is not None:
|
||||||
|
self.flatten(geometry=geo,
|
||||||
|
reset=False,
|
||||||
|
pathonly=pathonly)
|
||||||
|
|
||||||
|
## Not iterable, do the actual indexing and add.
|
||||||
|
except TypeError:
|
||||||
|
if pathonly and type(geometry) == Polygon:
|
||||||
|
self.flat_geometry.append(geometry.exterior)
|
||||||
|
self.flatten(geometry=geometry.interiors,
|
||||||
|
reset=False,
|
||||||
|
pathonly=True)
|
||||||
|
else:
|
||||||
|
self.flat_geometry.append(geometry)
|
||||||
|
|
||||||
|
return self.flat_geometry
|
||||||
|
|
||||||
def periodic_check(self, check_period, reset=False):
|
def periodic_check(self, check_period, reset=False):
|
||||||
"""
|
"""
|
||||||
This function starts an QTimer and it will periodically check if intersections are done
|
This function starts an QTimer and it will periodically check if intersections are done
|
||||||
@@ -259,7 +326,7 @@ class ToolSilk(FlatCAMTool):
|
|||||||
self.app.worker_task.emit({'fcn': self.new_silkscreen_object,
|
self.app.worker_task.emit({'fcn': self.new_silkscreen_object,
|
||||||
'params': [outname]})
|
'params': [outname]})
|
||||||
|
|
||||||
log.debug("ToolPDF --> Periodic check finished.")
|
log.debug("ToolSilk --> Periodic check finished.")
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user