- some protections in case there are some apertures without solid_geometry

This commit is contained in:
Marius Stanciu
2019-05-01 04:41:12 +03:00
parent 8062af7feb
commit dc64f8174e

View File

@@ -1613,22 +1613,25 @@ class FCApertureSelect(DrawTool):
key_modifier = QtWidgets.QApplication.keyboardModifiers() key_modifier = QtWidgets.QApplication.keyboardModifiers()
for storage in self.grb_editor_app.storage_dict: for storage in self.grb_editor_app.storage_dict:
for shape in self.grb_editor_app.storage_dict[storage]['solid_geometry']: try:
if Point(point).within(shape.geo): for shape in self.grb_editor_app.storage_dict[storage]['solid_geometry']:
if (self.grb_editor_app.app.defaults["global_mselect_key"] == 'Control' and if Point(point).within(shape.geo):
key_modifier == Qt.ControlModifier) or \ if (self.grb_editor_app.app.defaults["global_mselect_key"] == 'Control' and
(self.grb_editor_app.app.defaults["global_mselect_key"] == 'Shift' and key_modifier == Qt.ControlModifier) or \
key_modifier == Qt.ShiftModifier): (self.grb_editor_app.app.defaults["global_mselect_key"] == 'Shift' and
key_modifier == Qt.ShiftModifier):
if shape in self.draw_app.selected: if shape in self.draw_app.selected:
self.draw_app.selected.remove(shape) self.draw_app.selected.remove(shape)
else:
# add the object to the selected shapes
self.draw_app.selected.append(shape)
sel_aperture.add(storage)
else: else:
# add the object to the selected shapes
self.draw_app.selected.append(shape) self.draw_app.selected.append(shape)
sel_aperture.add(storage) sel_aperture.add(storage)
else: except KeyError:
self.draw_app.selected.append(shape) pass
sel_aperture.add(storage)
# select the aperture in the Apertures Table that is associated with the selected shape # select the aperture in the Apertures Table that is associated with the selected shape
try: try:
@@ -3384,20 +3387,22 @@ class FlatCAMGrbEditor(QtCore.QObject):
self.app.delete_selection_shape() self.app.delete_selection_shape()
for storage in self.storage_dict: for storage in self.storage_dict:
for obj in self.storage_dict[storage]['solid_geometry']: try:
if (sel_type is True and poly_selection.contains(obj.geo)) or \ for obj in self.storage_dict[storage]['solid_geometry']:
(sel_type is False and poly_selection.intersects(obj.geo)): if (sel_type is True and poly_selection.contains(obj.geo)) or \
if self.key == self.app.defaults["global_mselect_key"]: (sel_type is False and poly_selection.intersects(obj.geo)):
if obj in self.selected: if self.key == self.app.defaults["global_mselect_key"]:
self.selected.remove(obj) if obj in self.selected:
self.selected.remove(obj)
else:
# add the object to the selected shapes
self.selected.append(obj)
sel_aperture.add(storage)
else: else:
# add the object to the selected shapes
self.selected.append(obj) self.selected.append(obj)
sel_aperture.add(storage) sel_aperture.add(storage)
else: except KeyError:
self.selected.append(obj) pass
sel_aperture.add(storage)
try: try:
self.apertures_table.cellPressed.disconnect() self.apertures_table.cellPressed.disconnect()
except: except:
@@ -3532,15 +3537,18 @@ class FlatCAMGrbEditor(QtCore.QObject):
self.shapes.clear(update=True) self.shapes.clear(update=True)
for storage in self.storage_dict: for storage in self.storage_dict:
for shape in self.storage_dict[storage]['solid_geometry']: try:
if shape.geo is None: for shape in self.storage_dict[storage]['solid_geometry']:
continue if shape.geo is None:
continue
if shape in self.selected: if shape in self.selected:
self.plot_shape(geometry=shape.geo, color=self.app.defaults['global_sel_draw_color'], self.plot_shape(geometry=shape.geo, color=self.app.defaults['global_sel_draw_color'],
linewidth=2) linewidth=2)
continue continue
self.plot_shape(geometry=shape.geo, color=self.app.defaults['global_draw_color']) self.plot_shape(geometry=shape.geo, color=self.app.defaults['global_draw_color'])
except KeyError:
pass
for shape in self.utility: for shape in self.utility:
self.plot_shape(geometry=shape.geo, linewidth=1) self.plot_shape(geometry=shape.geo, linewidth=1)
@@ -3656,13 +3664,11 @@ class FlatCAMGrbEditor(QtCore.QObject):
return return
for storage in self.storage_dict: for storage in self.storage_dict:
# try: try:
# self.storage_dict[storage].remove(shape) if shape in self.storage_dict[storage]['solid_geometry']:
# except: self.storage_dict[storage]['solid_geometry'].remove(shape)
# pass except KeyError:
if shape in self.storage_dict[storage]['solid_geometry']: pass
self.storage_dict[storage]['solid_geometry'].remove(shape)
if shape in self.selected: if shape in self.selected:
self.selected.remove(shape) # TODO: Check performance self.selected.remove(shape) # TODO: Check performance