- fixed bug: when deleting a FlatCAMCNCJob with annotations enabled, the annotations are not deleted from canvas;
- fixed bug: creating a new project while a project is open and it contain CNCJob annotations and/or Gerber mark shapes, did not delete them from canvas
This commit is contained in:
parent
8665d4c90d
commit
e936e0e116
|
@ -7149,8 +7149,7 @@ class App(QtCore.QObject):
|
||||||
if self.collection.get_active():
|
if self.collection.get_active():
|
||||||
self.log.debug("App.on_delete()")
|
self.log.debug("App.on_delete()")
|
||||||
|
|
||||||
while self.collection.get_active():
|
for obj_active in self.collection.get_selected():
|
||||||
obj_active = self.collection.get_active()
|
|
||||||
# if the deleted object is FlatCAMGerber then make sure to delete the possible mark shapes
|
# if the deleted object is FlatCAMGerber then make sure to delete the possible mark shapes
|
||||||
if isinstance(obj_active, FlatCAMGerber):
|
if isinstance(obj_active, FlatCAMGerber):
|
||||||
for el in obj_active.mark_shapes:
|
for el in obj_active.mark_shapes:
|
||||||
|
@ -7160,12 +7159,16 @@ class App(QtCore.QObject):
|
||||||
del el
|
del el
|
||||||
elif isinstance(obj_active, FlatCAMCNCjob):
|
elif isinstance(obj_active, FlatCAMCNCjob):
|
||||||
try:
|
try:
|
||||||
|
obj_active.text_col.enabled = False
|
||||||
|
del obj_active.text_col
|
||||||
obj_active.annotation.clear(update=True)
|
obj_active.annotation.clear(update=True)
|
||||||
obj_active.annotation.enabled = False
|
del obj_active.annotation
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
log.debug(
|
log.debug(
|
||||||
"App.on_delete() --> delete annotations on a FlatCAMCNCJob object. %s" % str(e)
|
"App.on_delete() --> delete annotations on a FlatCAMCNCJob object. %s" % str(e)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
while self.collection.get_selected():
|
||||||
self.delete_first_selected()
|
self.delete_first_selected()
|
||||||
|
|
||||||
self.inform.emit('%s...' % _("Object(s) deleted"))
|
self.inform.emit('%s...' % _("Object(s) deleted"))
|
||||||
|
@ -9280,8 +9283,7 @@ class App(QtCore.QObject):
|
||||||
self.on_file_new()
|
self.on_file_new()
|
||||||
else:
|
else:
|
||||||
self.on_file_new()
|
self.on_file_new()
|
||||||
self.inform.emit('[success] %s...' %
|
self.inform.emit('[success] %s...' % _("New Project created"))
|
||||||
_("New Project created"))
|
|
||||||
|
|
||||||
def on_file_new(self, cli=None):
|
def on_file_new(self, cli=None):
|
||||||
"""
|
"""
|
||||||
|
@ -9310,16 +9312,20 @@ class App(QtCore.QObject):
|
||||||
# delete shapes left drawn from mark shape_collections, if any
|
# delete shapes left drawn from mark shape_collections, if any
|
||||||
if isinstance(obj, FlatCAMGerber):
|
if isinstance(obj, FlatCAMGerber):
|
||||||
try:
|
try:
|
||||||
obj.mark_shapes.enabled = False
|
for el in obj.mark_shapes:
|
||||||
obj.mark_shapes.clear(update=True)
|
obj.mark_shapes[el].clear(update=True)
|
||||||
|
obj.mark_shapes[el].enabled = False
|
||||||
|
del el
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# also delete annotation shapes, if any
|
# also delete annotation shapes, if any
|
||||||
elif isinstance(obj, FlatCAMCNCjob):
|
elif isinstance(obj, FlatCAMCNCjob):
|
||||||
try:
|
try:
|
||||||
obj.annotation.enabled = False
|
obj.text_col.enabled = False
|
||||||
|
del obj.text_col
|
||||||
obj.annotation.clear(update=True)
|
obj.annotation.clear(update=True)
|
||||||
|
del obj.annotation
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -6283,7 +6283,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
||||||
for option in geo_obj.options:
|
for option in geo_obj.options:
|
||||||
if option is not 'name':
|
if option is not 'name':
|
||||||
try:
|
try:
|
||||||
new_options[option] = geo_obj.options[option]
|
new_options[option] = deepcopy(geo_obj.options[option])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.warning("Failed to copy option %s. Error: %s" % (str(option), str(e)))
|
log.warning("Failed to copy option %s. Error: %s" % (str(option), str(e)))
|
||||||
|
|
||||||
|
@ -6298,7 +6298,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
||||||
geo_final.multigeo = True
|
geo_final.multigeo = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
new_solid_geometry.append(geo_obj.solid_geometry)
|
new_solid_geometry += deepcopy(geo_obj.solid_geometry)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.debug("FlatCAMGeometry.merge() --> %s" % str(e))
|
log.debug("FlatCAMGeometry.merge() --> %s" % str(e))
|
||||||
|
|
||||||
|
@ -6313,11 +6313,11 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
||||||
if not isinstance(geo_obj, FlatCAMGerber) and not isinstance(geo_obj, FlatCAMExcellon):
|
if not isinstance(geo_obj, FlatCAMGerber) and not isinstance(geo_obj, FlatCAMExcellon):
|
||||||
for tool_uid in geo_obj.tools:
|
for tool_uid in geo_obj.tools:
|
||||||
max_uid += 1
|
max_uid += 1
|
||||||
new_tools[max_uid] = geo_obj.tools[tool_uid]
|
new_tools[max_uid] = deepcopy(geo_obj.tools[tool_uid])
|
||||||
|
|
||||||
geo_final.options.update(deepcopy(new_options))
|
geo_final.options.update(new_options)
|
||||||
geo_final.solid_geometry = deepcopy(list(geo_final.flatten_list(new_solid_geometry)))
|
geo_final.solid_geometry = new_solid_geometry
|
||||||
geo_final.tools = deepcopy(new_tools)
|
geo_final.tools = new_tools
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_pts(o):
|
def get_pts(o):
|
||||||
|
|
|
@ -13,6 +13,8 @@ CAD program, and create G-Code for Isolation routing.
|
||||||
|
|
||||||
|
|
||||||
- working on fixing a bug in FlatCAMGeometry.merge() - FIXED
|
- working on fixing a bug in FlatCAMGeometry.merge() - FIXED
|
||||||
|
- fixed bug: when deleting a FlatCAMCNCJob with annotations enabled, the annotations are not deleted from canvas;
|
||||||
|
- fixed bug: creating a new project while a project is open and it contain CNCJob annotations and/or Gerber mark shapes, did not delete them from canvas
|
||||||
|
|
||||||
|
|
||||||
11.02.2020
|
11.02.2020
|
||||||
|
|
29
camlib.py
29
camlib.py
|
@ -979,8 +979,8 @@ class Geometry(object):
|
||||||
log.debug("Geometry.isolation_geometry() --> Type of isolation not supported")
|
log.debug("Geometry.isolation_geometry() --> Type of isolation not supported")
|
||||||
return "fail"
|
return "fail"
|
||||||
|
|
||||||
def flatten_list(self, list):
|
def flatten_list(self, obj_list):
|
||||||
for item in list:
|
for item in obj_list:
|
||||||
if isinstance(item, Iterable) and not isinstance(item, (str, bytes)):
|
if isinstance(item, Iterable) and not isinstance(item, (str, bytes)):
|
||||||
yield from self.flatten_list(item)
|
yield from self.flatten_list(item)
|
||||||
else:
|
else:
|
||||||
|
@ -1188,7 +1188,6 @@ class Geometry(object):
|
||||||
boundary = self.solid_geometry.envelope
|
boundary = self.solid_geometry.envelope
|
||||||
return boundary.difference(self.solid_geometry)
|
return boundary.difference(self.solid_geometry)
|
||||||
|
|
||||||
|
|
||||||
def clear_polygon(self, polygon, tooldia, steps_per_circle, overlap=0.15, connect=True, contour=True,
|
def clear_polygon(self, polygon, tooldia, steps_per_circle, overlap=0.15, connect=True, contour=True,
|
||||||
prog_plot=False):
|
prog_plot=False):
|
||||||
"""
|
"""
|
||||||
|
@ -1441,7 +1440,7 @@ class Geometry(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
margin_poly = polygon.buffer(-tooldia / 1.99999999, (int(steps_per_circle)))
|
margin_poly = polygon.buffer(-tooldia / 1.99999999, (int(steps_per_circle)))
|
||||||
except Exception as e:
|
except Exception:
|
||||||
log.debug("camlib.Geometry.clear_polygon3() --> Could not buffer the Polygon")
|
log.debug("camlib.Geometry.clear_polygon3() --> Could not buffer the Polygon")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -1571,6 +1570,7 @@ class Geometry(object):
|
||||||
This algorithm draws parallel lines inside the polygon.
|
This algorithm draws parallel lines inside the polygon.
|
||||||
|
|
||||||
:param line: The target line that create painted polygon.
|
:param line: The target line that create painted polygon.
|
||||||
|
:param aperture_size: the size of the aperture that is used to draw the 'line' as a polygon
|
||||||
:type line: shapely.geometry.LineString or shapely.geometry.MultiLineString
|
:type line: shapely.geometry.LineString or shapely.geometry.MultiLineString
|
||||||
:param tooldia: Tool diameter.
|
:param tooldia: Tool diameter.
|
||||||
:param steps_per_circle: how many linear segments to use to approximate a circle
|
:param steps_per_circle: how many linear segments to use to approximate a circle
|
||||||
|
@ -1758,7 +1758,7 @@ class Geometry(object):
|
||||||
# storage.get_points = get_pts
|
# storage.get_points = get_pts
|
||||||
#
|
#
|
||||||
# for shape in geolist:
|
# for shape in geolist:
|
||||||
# if shape is not None: # TODO: This shouldn't have happened.
|
# if shape is not None:
|
||||||
# # Make LlinearRings into linestrings otherwise
|
# # Make LlinearRings into linestrings otherwise
|
||||||
# # When chaining the coordinates path is messed up.
|
# # When chaining the coordinates path is messed up.
|
||||||
# storage.insert(LineString(shape))
|
# storage.insert(LineString(shape))
|
||||||
|
@ -2268,8 +2268,7 @@ class Geometry(object):
|
||||||
# variables to display the percentage of work done
|
# variables to display the percentage of work done
|
||||||
self.geo_len = 0
|
self.geo_len = 0
|
||||||
try:
|
try:
|
||||||
for g in self.solid_geometry:
|
self.geo_len = len(self.solid_geometry)
|
||||||
self.geo_len += 1
|
|
||||||
except TypeError:
|
except TypeError:
|
||||||
self.geo_len = 1
|
self.geo_len = 1
|
||||||
self.old_disp_number = 0
|
self.old_disp_number = 0
|
||||||
|
@ -2783,7 +2782,7 @@ class CNCjob(Geometry):
|
||||||
"""Initialize distance array."""
|
"""Initialize distance array."""
|
||||||
locations = create_data_array()
|
locations = create_data_array()
|
||||||
size = len(locations)
|
size = len(locations)
|
||||||
self.matrix = {}
|
self.matrix = dict()
|
||||||
|
|
||||||
for from_node in range(size):
|
for from_node in range(size):
|
||||||
self.matrix[from_node] = {}
|
self.matrix[from_node] = {}
|
||||||
|
@ -3105,7 +3104,6 @@ class CNCjob(Geometry):
|
||||||
# Drillling! for Absolute coordinates type G90
|
# Drillling! for Absolute coordinates type G90
|
||||||
# variables to display the percentage of work done
|
# variables to display the percentage of work done
|
||||||
geo_len = len(node_list)
|
geo_len = len(node_list)
|
||||||
disp_number = 0
|
|
||||||
old_disp_number = 0
|
old_disp_number = 0
|
||||||
log.warning("Number of drills for which to generate GCode: %s" % str(geo_len))
|
log.warning("Number of drills for which to generate GCode: %s" % str(geo_len))
|
||||||
|
|
||||||
|
@ -3237,7 +3235,6 @@ class CNCjob(Geometry):
|
||||||
node_list = self.optimized_travelling_salesman(altPoints)
|
node_list = self.optimized_travelling_salesman(altPoints)
|
||||||
# variables to display the percentage of work done
|
# variables to display the percentage of work done
|
||||||
geo_len = len(node_list)
|
geo_len = len(node_list)
|
||||||
disp_number = 0
|
|
||||||
old_disp_number = 0
|
old_disp_number = 0
|
||||||
log.warning("Number of drills for which to generate GCode: %s" % str(geo_len))
|
log.warning("Number of drills for which to generate GCode: %s" % str(geo_len))
|
||||||
|
|
||||||
|
@ -4077,7 +4074,6 @@ class CNCjob(Geometry):
|
||||||
|
|
||||||
# variables to display the percentage of work done
|
# variables to display the percentage of work done
|
||||||
geo_len = len(flat_geometry)
|
geo_len = len(flat_geometry)
|
||||||
disp_number = 0
|
|
||||||
old_disp_number = 0
|
old_disp_number = 0
|
||||||
|
|
||||||
pt, geo = storage.nearest(current_pt)
|
pt, geo = storage.nearest(current_pt)
|
||||||
|
@ -4191,7 +4187,6 @@ class CNCjob(Geometry):
|
||||||
|
|
||||||
def create_gcode_single_pass(self, geometry, extracut, extracut_length, tolerance, old_point=(0, 0)):
|
def create_gcode_single_pass(self, geometry, extracut, extracut_length, tolerance, old_point=(0, 0)):
|
||||||
# G-code. Note: self.linear2gcode() and self.point2gcode() will lower and raise the tool every time.
|
# G-code. Note: self.linear2gcode() and self.point2gcode() will lower and raise the tool every time.
|
||||||
gcode_single_pass = ''
|
|
||||||
|
|
||||||
if type(geometry) == LineString or type(geometry) == LinearRing:
|
if type(geometry) == LineString or type(geometry) == LinearRing:
|
||||||
if extracut is False:
|
if extracut is False:
|
||||||
|
@ -4574,8 +4569,8 @@ class CNCjob(Geometry):
|
||||||
if geo['kind'][0] == 'C':
|
if geo['kind'][0] == 'C':
|
||||||
obj.add_shape(shape=geo['geom'], color=color['C'][1], visible=visible)
|
obj.add_shape(shape=geo['geom'], color=color['C'][1], visible=visible)
|
||||||
else:
|
else:
|
||||||
text = []
|
text = list()
|
||||||
pos = []
|
pos = list()
|
||||||
self.coordinates_type = self.app.defaults["cncjob_coords_type"]
|
self.coordinates_type = self.app.defaults["cncjob_coords_type"]
|
||||||
if self.coordinates_type == "G90":
|
if self.coordinates_type == "G90":
|
||||||
# For Absolute coordinates type G90
|
# For Absolute coordinates type G90
|
||||||
|
@ -5122,8 +5117,10 @@ class CNCjob(Geometry):
|
||||||
# graceful abort requested by the user
|
# graceful abort requested by the user
|
||||||
raise FlatCAMApp.GracefulException
|
raise FlatCAMApp.GracefulException
|
||||||
|
|
||||||
if g['kind'][0] == 'C': cuts.append(g)
|
if g['kind'][0] == 'C':
|
||||||
if g['kind'][0] == 'T': travels.append(g)
|
cuts.append(g)
|
||||||
|
if g['kind'][0] == 'T':
|
||||||
|
travels.append(g)
|
||||||
|
|
||||||
# Used to determine the overall board size
|
# Used to determine the overall board size
|
||||||
self.solid_geometry = cascaded_union([geo['geom'] for geo in self.gcode_parsed])
|
self.solid_geometry = cascaded_union([geo['geom'] for geo in self.gcode_parsed])
|
||||||
|
|
Loading…
Reference in New Issue