- fixed an issue with the moving shape when creating an exclusion area

- added ability to copy the coordinates of the exclusion area with the context menu actions in the Exclusion areas table found in the Milling/Drilling plugins
This commit is contained in:
Marius Stanciu
2022-02-15 03:45:52 +02:00
committed by Marius
parent e0819ab1a6
commit c5b929781e
5 changed files with 63 additions and 7 deletions

View File

@@ -7,6 +7,11 @@ CHANGELOG for FlatCAM beta
=================================================
15.02.2022
- fixed an issue with the moving shape when creating an exclusion area
- added ability to copy the coordinates of the exclusion area with the context menu actions in the Exclusion areas table found in the Milling/Drilling plugins
13.02.2022
- fixed issue when doing a custom origin set

View File

@@ -601,7 +601,7 @@ class ExclusionAreas(QtCore.QObject):
# "<b>Y</b>: %.4f&nbsp;" % (curr_pos[0], curr_pos[1]))
# self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f&nbsp;&nbsp; <b>Dy</b>: "
# "%.4f&nbsp;&nbsp;&nbsp;&nbsp;" % (self.app.dx, self.app.dy))
self.app.ui.update_location_labels(self.dx, self.dy, curr_pos[0], curr_pos[1])
self.app.ui.update_location_labels(self.app.dx, self.app.dy, curr_pos[0], curr_pos[1])
units = self.app.app_units.lower()
# self.app.plotcanvas.text_hud.text = \
@@ -740,7 +740,7 @@ class ExclusionAreas(QtCore.QObject):
origin_point = Point(start_point)
buffered_storage = []
# add a little something to the half diameter, to make sure that we really don't enter in the exclusion zones
# add a little something to the half diameter, to make sure that we really don't enter the exclusion zones
buffered_distance = (tooldia / 2.0) + (0.1 if self.app.app_units == 'MM' else 0.00393701)
for area in self.exclusion_areas_storage:

View File

@@ -2246,13 +2246,14 @@ class Gerber(Geometry):
return
# variables to display the percentage of work done
self.geo_len = 0
try:
self.geo_len = len(self.solid_geometry)
except AttributeError:
if isinstance(self.solid_geometry, (MultiPolygon, MultiLineString)):
self.geo_len = len(self.solid_geometry.geoms)
except TypeError:
elif isinstance(self.solid_geometry, list):
self.geo_len = len(self.solid_geometry)
elif isinstance(self.solid_geometry, Polygon):
self.geo_len = 1
else:
self.geo_len = 0
self.old_disp_number = 0
self.el_count = 0

View File

@@ -305,6 +305,10 @@ class ToolDrilling(AppTool, Excellon):
# ############################## EXCLUSION TABLE context menu #################################################
# #############################################################################################################
self.ui.exclusion_table.setupContextMenu()
self.ui.exclusion_table.addContextMenu(
'%s %s' % (_("Copy"), _("coords")), self.on_copy_exclusion_area_coords,
icon=QtGui.QIcon(self.app.resource_location + "/copy16.png")
)
self.ui.exclusion_table.addContextMenu(
_("Delete"), self.on_delete_sel_areas, icon=QtGui.QIcon(self.app.resource_location + "/trash16.png")
)
@@ -1694,6 +1698,27 @@ class ToolDrilling(AppTool, Excellon):
self.app.exc_areas.delete_sel_shapes(idxs=list(sel_rows))
self.app.exc_areas.e_shape_modified.emit()
def on_copy_exclusion_area_coords(self):
sel_model = self.ui.exclusion_table.selectionModel()
sel_indexes = sel_model.selectedIndexes()
# it will iterate over all indexes which means all items in all columns too but I'm interested only on rows
# so the duplicate rows will not be added
sel_rows = set()
for idx in sel_indexes:
sel_rows.add(idx.row())
if len(sel_rows) != 1:
self.app.inform.emit("[WARNING_NOTCL] %s" % _("Multiple areas selected. Only one area is allowed."))
return
row_idx = list(sel_rows)[0]
poly = self.app.exc_areas.exclusion_areas_storage[row_idx]['shape']
poly_coords = list(poly.exterior.coords)
self.app.clipboard.setText(str(poly_coords))
self.app.inform.emit('[success] %s' % _("Coordinates copied to clipboard."))
def draw_sel_shape(self):
sel_model = self.ui.exclusion_table.selectionModel()
sel_indexes = sel_model.selectedIndexes()

View File

@@ -435,6 +435,10 @@ class ToolMilling(AppTool, Excellon):
# ############################## EXCLUSION TABLE context menu #################################################
# #############################################################################################################
self.ui.exclusion_table.setupContextMenu()
self.ui.exclusion_table.addContextMenu(
'%s %s' % (_("Copy"), _("coords")), self.on_copy_exclusion_area_coords,
icon=QtGui.QIcon(self.app.resource_location + "/copy16.png")
)
self.ui.exclusion_table.addContextMenu(
_("Delete"), self.on_delete_sel_areas, icon=QtGui.QIcon(self.app.resource_location + "/trash16.png")
)
@@ -3787,6 +3791,27 @@ class ToolMilling(AppTool, Excellon):
self.app.exc_areas.delete_sel_shapes(idxs=list(sel_rows))
self.app.exc_areas.e_shape_modified.emit()
def on_copy_exclusion_area_coords(self):
sel_model = self.ui.exclusion_table.selectionModel()
sel_indexes = sel_model.selectedIndexes()
# it will iterate over all indexes which means all items in all columns too but I'm interested only on rows
# so the duplicate rows will not be added
sel_rows = set()
for idx in sel_indexes:
sel_rows.add(idx.row())
if len(sel_rows) != 1:
self.app.inform.emit("[WARNING_NOTCL] %s" % _("Multiple areas selected. Only one area is allowed."))
return
row_idx = list(sel_rows)[0]
poly = self.app.exc_areas.exclusion_areas_storage[row_idx]['shape']
poly_coords = list(poly.exterior.coords)
self.app.clipboard.setText(str(poly_coords))
self.app.inform.emit('[success] %s' % _("Coordinates copied to clipboard."))
def draw_sel_shape(self):
sel_model = self.ui.exclusion_table.selectionModel()
sel_indexes = sel_model.selectedIndexes()