- 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():
|
||||
self.log.debug("App.on_delete()")
|
||||
|
||||
while self.collection.get_active():
|
||||
obj_active = self.collection.get_active()
|
||||
for obj_active in self.collection.get_selected():
|
||||
# if the deleted object is FlatCAMGerber then make sure to delete the possible mark shapes
|
||||
if isinstance(obj_active, FlatCAMGerber):
|
||||
for el in obj_active.mark_shapes:
|
||||
|
@ -7160,12 +7159,16 @@ class App(QtCore.QObject):
|
|||
del el
|
||||
elif isinstance(obj_active, FlatCAMCNCjob):
|
||||
try:
|
||||
obj_active.text_col.enabled = False
|
||||
del obj_active.text_col
|
||||
obj_active.annotation.clear(update=True)
|
||||
obj_active.annotation.enabled = False
|
||||
del obj_active.annotation
|
||||
except AttributeError as e:
|
||||
log.debug(
|
||||
"App.on_delete() --> delete annotations on a FlatCAMCNCJob object. %s" % str(e)
|
||||
)
|
||||
|
||||
while self.collection.get_selected():
|
||||
self.delete_first_selected()
|
||||
|
||||
self.inform.emit('%s...' % _("Object(s) deleted"))
|
||||
|
@ -9280,8 +9283,7 @@ class App(QtCore.QObject):
|
|||
self.on_file_new()
|
||||
else:
|
||||
self.on_file_new()
|
||||
self.inform.emit('[success] %s...' %
|
||||
_("New Project created"))
|
||||
self.inform.emit('[success] %s...' % _("New Project created"))
|
||||
|
||||
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
|
||||
if isinstance(obj, FlatCAMGerber):
|
||||
try:
|
||||
obj.mark_shapes.enabled = False
|
||||
obj.mark_shapes.clear(update=True)
|
||||
for el in obj.mark_shapes:
|
||||
obj.mark_shapes[el].clear(update=True)
|
||||
obj.mark_shapes[el].enabled = False
|
||||
del el
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
# also delete annotation shapes, if any
|
||||
elif isinstance(obj, FlatCAMCNCjob):
|
||||
try:
|
||||
obj.annotation.enabled = False
|
||||
obj.text_col.enabled = False
|
||||
del obj.text_col
|
||||
obj.annotation.clear(update=True)
|
||||
del obj.annotation
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
|
|
@ -6283,7 +6283,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
|||
for option in geo_obj.options:
|
||||
if option is not 'name':
|
||||
try:
|
||||
new_options[option] = geo_obj.options[option]
|
||||
new_options[option] = deepcopy(geo_obj.options[option])
|
||||
except Exception as 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
|
||||
|
||||
try:
|
||||
new_solid_geometry.append(geo_obj.solid_geometry)
|
||||
new_solid_geometry += deepcopy(geo_obj.solid_geometry)
|
||||
except Exception as 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):
|
||||
for tool_uid in geo_obj.tools:
|
||||
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.solid_geometry = deepcopy(list(geo_final.flatten_list(new_solid_geometry)))
|
||||
geo_final.tools = deepcopy(new_tools)
|
||||
geo_final.options.update(new_options)
|
||||
geo_final.solid_geometry = new_solid_geometry
|
||||
geo_final.tools = new_tools
|
||||
|
||||
@staticmethod
|
||||
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
|
||||
- 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
|
||||
|
|
29
camlib.py
29
camlib.py
|
@ -979,8 +979,8 @@ class Geometry(object):
|
|||
log.debug("Geometry.isolation_geometry() --> Type of isolation not supported")
|
||||
return "fail"
|
||||
|
||||
def flatten_list(self, list):
|
||||
for item in list:
|
||||
def flatten_list(self, obj_list):
|
||||
for item in obj_list:
|
||||
if isinstance(item, Iterable) and not isinstance(item, (str, bytes)):
|
||||
yield from self.flatten_list(item)
|
||||
else:
|
||||
|
@ -1188,7 +1188,6 @@ class Geometry(object):
|
|||
boundary = self.solid_geometry.envelope
|
||||
return boundary.difference(self.solid_geometry)
|
||||
|
||||
|
||||
def clear_polygon(self, polygon, tooldia, steps_per_circle, overlap=0.15, connect=True, contour=True,
|
||||
prog_plot=False):
|
||||
"""
|
||||
|
@ -1441,7 +1440,7 @@ class Geometry(object):
|
|||
|
||||
try:
|
||||
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")
|
||||
return None
|
||||
|
||||
|
@ -1571,6 +1570,7 @@ class Geometry(object):
|
|||
This algorithm draws parallel lines inside the 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
|
||||
:param tooldia: Tool diameter.
|
||||
: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
|
||||
#
|
||||
# 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
|
||||
# # When chaining the coordinates path is messed up.
|
||||
# storage.insert(LineString(shape))
|
||||
|
@ -2268,8 +2268,7 @@ class Geometry(object):
|
|||
# variables to display the percentage of work done
|
||||
self.geo_len = 0
|
||||
try:
|
||||
for g in self.solid_geometry:
|
||||
self.geo_len += 1
|
||||
self.geo_len = len(self.solid_geometry)
|
||||
except TypeError:
|
||||
self.geo_len = 1
|
||||
self.old_disp_number = 0
|
||||
|
@ -2783,7 +2782,7 @@ class CNCjob(Geometry):
|
|||
"""Initialize distance array."""
|
||||
locations = create_data_array()
|
||||
size = len(locations)
|
||||
self.matrix = {}
|
||||
self.matrix = dict()
|
||||
|
||||
for from_node in range(size):
|
||||
self.matrix[from_node] = {}
|
||||
|
@ -3105,7 +3104,6 @@ class CNCjob(Geometry):
|
|||
# Drillling! for Absolute coordinates type G90
|
||||
# variables to display the percentage of work done
|
||||
geo_len = len(node_list)
|
||||
disp_number = 0
|
||||
old_disp_number = 0
|
||||
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)
|
||||
# variables to display the percentage of work done
|
||||
geo_len = len(node_list)
|
||||
disp_number = 0
|
||||
old_disp_number = 0
|
||||
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
|
||||
geo_len = len(flat_geometry)
|
||||
disp_number = 0
|
||||
old_disp_number = 0
|
||||
|
||||
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)):
|
||||
# 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 extracut is False:
|
||||
|
@ -4574,8 +4569,8 @@ class CNCjob(Geometry):
|
|||
if geo['kind'][0] == 'C':
|
||||
obj.add_shape(shape=geo['geom'], color=color['C'][1], visible=visible)
|
||||
else:
|
||||
text = []
|
||||
pos = []
|
||||
text = list()
|
||||
pos = list()
|
||||
self.coordinates_type = self.app.defaults["cncjob_coords_type"]
|
||||
if self.coordinates_type == "G90":
|
||||
# For Absolute coordinates type G90
|
||||
|
@ -5122,8 +5117,10 @@ class CNCjob(Geometry):
|
|||
# graceful abort requested by the user
|
||||
raise FlatCAMApp.GracefulException
|
||||
|
||||
if g['kind'][0] == 'C': cuts.append(g)
|
||||
if g['kind'][0] == 'T': travels.append(g)
|
||||
if g['kind'][0] == 'C':
|
||||
cuts.append(g)
|
||||
if g['kind'][0] == 'T':
|
||||
travels.append(g)
|
||||
|
||||
# Used to determine the overall board size
|
||||
self.solid_geometry = cascaded_union([geo['geom'] for geo in self.gcode_parsed])
|
||||
|
|
Loading…
Reference in New Issue