- Modified the Distance Tool such that the Measure button can't be clicked while measuring is in progress
- optimized selection of drills in the Excellon Editor - fixed bugs in multiple selection in Excellon Editor - fixed selection problems in Gerber Editor - in Distance Tool, when run in the Excellon or Gerber Editor, added a new option to snap to center of the geometry (drill for Excellon, pad for Gerber)
This commit is contained in:
@@ -1334,8 +1334,8 @@ class FCDrillCopy(FCDrillMove):
|
||||
|
||||
|
||||
class FCDrillSelect(DrawTool):
|
||||
def __init__(self, exc_editor_app):
|
||||
DrawTool.__init__(self, exc_editor_app)
|
||||
def __init__(self, draw_app):
|
||||
DrawTool.__init__(self, draw_app)
|
||||
self.name = 'drill_select'
|
||||
|
||||
try:
|
||||
@@ -1343,7 +1343,7 @@ class FCDrillSelect(DrawTool):
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
self.exc_editor_app = exc_editor_app
|
||||
self.exc_editor_app = draw_app
|
||||
self.storage = self.exc_editor_app.storage_dict
|
||||
# self.selected = self.exc_editor_app.selected
|
||||
|
||||
@@ -1368,10 +1368,10 @@ class FCDrillSelect(DrawTool):
|
||||
else:
|
||||
mod_key = None
|
||||
|
||||
if mod_key == self.draw_app.app.defaults["global_mselect_key"]:
|
||||
if mod_key == self.exc_editor_app.app.defaults["global_mselect_key"]:
|
||||
pass
|
||||
else:
|
||||
self.exc_editor_app.selected = []
|
||||
self.exc_editor_app.selected = list()
|
||||
|
||||
def click_release(self, pos):
|
||||
self.exc_editor_app.tools_table_exc.clearSelection()
|
||||
@@ -1379,8 +1379,10 @@ class FCDrillSelect(DrawTool):
|
||||
|
||||
try:
|
||||
for storage in self.exc_editor_app.storage_dict:
|
||||
for sh in self.exc_editor_app.storage_dict[storage].get_objects():
|
||||
self.sel_storage.insert(sh)
|
||||
# for sh in self.exc_editor_app.storage_dict[storage].get_objects():
|
||||
# self.sel_storage.insert(sh)
|
||||
_, st_closest_shape = self.exc_editor_app.storage_dict[storage].nearest(pos)
|
||||
self.sel_storage.insert(st_closest_shape)
|
||||
|
||||
_, closest_shape = self.sel_storage.nearest(pos)
|
||||
|
||||
@@ -1417,37 +1419,41 @@ class FCDrillSelect(DrawTool):
|
||||
else:
|
||||
mod_key = None
|
||||
|
||||
if mod_key == self.draw_app.app.defaults["global_mselect_key"]:
|
||||
if mod_key == self.exc_editor_app.app.defaults["global_mselect_key"]:
|
||||
if closest_shape in self.exc_editor_app.selected:
|
||||
self.exc_editor_app.selected.remove(closest_shape)
|
||||
else:
|
||||
self.exc_editor_app.selected.append(closest_shape)
|
||||
else:
|
||||
self.draw_app.selected = []
|
||||
self.draw_app.selected.append(closest_shape)
|
||||
self.exc_editor_app.selected = list()
|
||||
self.exc_editor_app.selected.append(closest_shape)
|
||||
|
||||
# select the diameter of the selected shape in the tool table
|
||||
try:
|
||||
self.draw_app.tools_table_exc.cellPressed.disconnect()
|
||||
self.exc_editor_app.tools_table_exc.cellPressed.disconnect()
|
||||
except (TypeError, AttributeError):
|
||||
pass
|
||||
|
||||
self.exc_editor_app.tools_table_exc.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
|
||||
# if mod_key == self.exc_editor_app.app.defaults["global_mselect_key"]:
|
||||
# self.exc_editor_app.tools_table_exc.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
|
||||
self.sel_tools.clear()
|
||||
|
||||
for shape_s in self.exc_editor_app.selected:
|
||||
for storage in self.exc_editor_app.storage_dict:
|
||||
if shape_s in self.exc_editor_app.storage_dict[storage].get_objects():
|
||||
self.sel_tools.add(storage)
|
||||
|
||||
self.exc_editor_app.tools_table_exc.clearSelection()
|
||||
for storage in self.sel_tools:
|
||||
for k, v in self.draw_app.tool2tooldia.items():
|
||||
for k, v in self.exc_editor_app.tool2tooldia.items():
|
||||
if v == storage:
|
||||
self.exc_editor_app.tools_table_exc.selectRow(int(k) - 1)
|
||||
self.draw_app.last_tool_selected = int(k)
|
||||
self.exc_editor_app.last_tool_selected = int(k)
|
||||
break
|
||||
|
||||
self.exc_editor_app.tools_table_exc.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
||||
# self.exc_editor_app.tools_table_exc.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
||||
|
||||
self.draw_app.tools_table_exc.cellPressed.connect(self.draw_app.on_row_selected)
|
||||
self.exc_editor_app.tools_table_exc.cellPressed.connect(self.exc_editor_app.on_row_selected)
|
||||
|
||||
# delete whatever is in selection storage, there is no longer need for those shapes
|
||||
self.sel_storage = FlatCAMExcEditor.make_storage()
|
||||
@@ -2054,32 +2060,32 @@ class FlatCAMExcEditor(QtCore.QObject):
|
||||
|
||||
self.in_action = False
|
||||
|
||||
self.storage_dict = {}
|
||||
self.storage_dict = dict()
|
||||
|
||||
self.current_storage = []
|
||||
self.current_storage = list()
|
||||
|
||||
# build the data from the Excellon point into a dictionary
|
||||
# {tool_dia: [geometry_in_points]}
|
||||
self.points_edit = {}
|
||||
self.slot_points_edit = {}
|
||||
self.points_edit = dict()
|
||||
self.slot_points_edit = dict()
|
||||
|
||||
self.sorted_diameters = []
|
||||
self.sorted_diameters = list()
|
||||
|
||||
self.new_drills = []
|
||||
self.new_tools = {}
|
||||
self.new_slots = []
|
||||
self.new_tool_offset = {}
|
||||
self.new_drills = list()
|
||||
self.new_tools = dict()
|
||||
self.new_slots = list()
|
||||
self.new_tool_offset = dict()
|
||||
|
||||
# dictionary to store the tool_row and diameters in Tool_table
|
||||
# it will be updated everytime self.build_ui() is called
|
||||
self.olddia_newdia = {}
|
||||
self.olddia_newdia = dict()
|
||||
|
||||
self.tool2tooldia = {}
|
||||
self.tool2tooldia = dict()
|
||||
|
||||
# this will store the value for the last selected tool, for use after clicking on canvas when the selection
|
||||
# is cleared but as a side effect also the selected tool is cleared
|
||||
self.last_tool_selected = None
|
||||
self.utility = []
|
||||
self.utility = list()
|
||||
|
||||
# this will flag if the Editor "tools" are launched from key shortcuts (True) or from menu toolbar (False)
|
||||
self.launched_from_shortcuts = False
|
||||
|
||||
@@ -2300,10 +2300,10 @@ class FCApertureSelect(DrawTool):
|
||||
|
||||
# since FCApertureSelect tool is activated whenever a tool is exited I place here the reinitialization of the
|
||||
# bending modes using in FCRegion and FCTrack
|
||||
self.draw_app.bend_mode = 1
|
||||
self.grb_editor_app.bend_mode = 1
|
||||
|
||||
# here store the selected apertures
|
||||
self.sel_aperture = set()
|
||||
self.sel_aperture = list()
|
||||
|
||||
try:
|
||||
self.grb_editor_app.apertures_table.clearSelection()
|
||||
@@ -2332,7 +2332,7 @@ class FCApertureSelect(DrawTool):
|
||||
else:
|
||||
mod_key = None
|
||||
|
||||
if mod_key == self.draw_app.app.defaults["global_mselect_key"]:
|
||||
if mod_key == self.grb_editor_app.app.defaults["global_mselect_key"]:
|
||||
pass
|
||||
else:
|
||||
self.grb_editor_app.selected = []
|
||||
@@ -2348,46 +2348,53 @@ class FCApertureSelect(DrawTool):
|
||||
else:
|
||||
mod_key = None
|
||||
|
||||
if mod_key != self.grb_editor_app.app.defaults["global_mselect_key"]:
|
||||
self.grb_editor_app.selected.clear()
|
||||
self.sel_aperture.clear()
|
||||
|
||||
for storage in self.grb_editor_app.storage_dict:
|
||||
try:
|
||||
for geo_el in self.grb_editor_app.storage_dict[storage]['geometry']:
|
||||
if 'solid' in geo_el.geo:
|
||||
geometric_data = geo_el.geo['solid']
|
||||
for shape_stored in self.grb_editor_app.storage_dict[storage]['geometry']:
|
||||
if 'solid' in shape_stored.geo:
|
||||
geometric_data = shape_stored.geo['solid']
|
||||
if Point(point).within(geometric_data):
|
||||
if mod_key == self.grb_editor_app.app.defaults["global_mselect_key"]:
|
||||
if geo_el in self.draw_app.selected:
|
||||
self.draw_app.selected.remove(geo_el)
|
||||
self.sel_aperture.remove(storage)
|
||||
else:
|
||||
# add the object to the selected shapes
|
||||
self.draw_app.selected.append(geo_el)
|
||||
self.sel_aperture.add(storage)
|
||||
if shape_stored in self.grb_editor_app.selected:
|
||||
self.grb_editor_app.selected.remove(shape_stored)
|
||||
else:
|
||||
self.draw_app.selected.append(geo_el)
|
||||
self.sel_aperture.add(storage)
|
||||
# add the object to the selected shapes
|
||||
self.grb_editor_app.selected.append(shape_stored)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
# select the aperture in the Apertures Table that is associated with the selected shape
|
||||
self.sel_aperture.clear()
|
||||
|
||||
self.grb_editor_app.apertures_table.clearSelection()
|
||||
try:
|
||||
self.draw_app.apertures_table.cellPressed.disconnect()
|
||||
self.grb_editor_app.apertures_table.cellPressed.disconnect()
|
||||
except Exception as e:
|
||||
log.debug("FlatCAMGrbEditor.FCApertureSelect.click_release() --> %s" % str(e))
|
||||
|
||||
self.grb_editor_app.apertures_table.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
|
||||
for shape_s in self.grb_editor_app.selected:
|
||||
for storage in self.grb_editor_app.storage_dict:
|
||||
if shape_s in self.grb_editor_app.storage_dict[storage]['geometry']:
|
||||
self.sel_aperture.append(storage)
|
||||
|
||||
# self.grb_editor_app.apertures_table.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
|
||||
for aper in self.sel_aperture:
|
||||
for row in range(self.grb_editor_app.apertures_table.rowCount()):
|
||||
if str(aper) == self.grb_editor_app.apertures_table.item(row, 1).text():
|
||||
self.grb_editor_app.apertures_table.selectRow(row)
|
||||
self.draw_app.last_aperture_selected = aper
|
||||
self.grb_editor_app.apertures_table.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
||||
if not self.grb_editor_app.apertures_table.item(row, 0).isSelected():
|
||||
self.grb_editor_app.apertures_table.selectRow(row)
|
||||
self.grb_editor_app.last_aperture_selected = aper
|
||||
# self.grb_editor_app.apertures_table.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
||||
|
||||
self.draw_app.apertures_table.cellPressed.connect(self.draw_app.on_row_selected)
|
||||
self.grb_editor_app.apertures_table.cellPressed.connect(self.grb_editor_app.on_row_selected)
|
||||
|
||||
return ""
|
||||
|
||||
def clean_up(self):
|
||||
self.draw_app.plot_all()
|
||||
self.grb_editor_app.plot_all()
|
||||
|
||||
|
||||
class FCTransform(FCShapeTool):
|
||||
|
||||
Reference in New Issue
Block a user