- some cleanup and bug fixes for the Paint Tool
This commit is contained in:
parent
82ab0d83d6
commit
cf9f15152a
|
@ -15,6 +15,8 @@ CAD program, and create G-Code for Isolation routing.
|
||||||
- solved bug that made drilling with Marlin preprocessor very slow
|
- solved bug that made drilling with Marlin preprocessor very slow
|
||||||
- applied the fix for above bug to the TclCommand Drillcncjob too
|
- applied the fix for above bug to the TclCommand Drillcncjob too
|
||||||
- started a new way to clear the Gerber polygons based on the 'follow' lines
|
- started a new way to clear the Gerber polygons based on the 'follow' lines
|
||||||
|
- some cleanup and bug fixes for the Paint Tool
|
||||||
|
|
||||||
|
|
||||||
8.02.2020
|
8.02.2020
|
||||||
|
|
||||||
|
|
|
@ -542,7 +542,9 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||||
self.bound_obj_name = ""
|
self.bound_obj_name = ""
|
||||||
self.bound_obj = None
|
self.bound_obj = None
|
||||||
|
|
||||||
self.tooldia_list = []
|
self.tooldia_list = list()
|
||||||
|
self.tooldia = None
|
||||||
|
|
||||||
self.sel_rect = None
|
self.sel_rect = None
|
||||||
self.o_name = None
|
self.o_name = None
|
||||||
self.overlap = None
|
self.overlap = None
|
||||||
|
@ -1122,7 +1124,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||||
|
|
||||||
if float('%.*f' % (self.decimals, tool_dia)) in tool_dias:
|
if float('%.*f' % (self.decimals, tool_dia)) in tool_dias:
|
||||||
if muted is None:
|
if muted is None:
|
||||||
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Adding tool cancelled. Tool already in Tool Table."))
|
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Adding tool cancelled. Tool already in Tool Table."))
|
||||||
self.tools_table.itemChanged.connect(self.on_tool_edit)
|
self.tools_table.itemChanged.connect(self.on_tool_edit)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
@ -1242,12 +1244,12 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||||
#
|
#
|
||||||
# self.app.inform.emit("[success] Tool was copied in the Tool Table.")
|
# self.app.inform.emit("[success] Tool was copied in the Tool Table.")
|
||||||
|
|
||||||
def on_tool_delete(self, rows_to_delete=None, all=None):
|
def on_tool_delete(self, rows_to_delete=None, all_tools=None):
|
||||||
self.blockSignals(True)
|
self.blockSignals(True)
|
||||||
|
|
||||||
deleted_tools_list = []
|
deleted_tools_list = []
|
||||||
|
|
||||||
if all:
|
if all_tools:
|
||||||
self.paint_tools.clear()
|
self.paint_tools.clear()
|
||||||
self.blockSignals(False)
|
self.blockSignals(False)
|
||||||
self.build_ui()
|
self.build_ui()
|
||||||
|
@ -1316,25 +1318,20 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||||
self.paint_obj = self.app.collection.get_by_name(str(self.obj_name))
|
self.paint_obj = self.app.collection.get_by_name(str(self.obj_name))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.debug("ToolPaint.on_paint_button_click() --> %s" % str(e))
|
log.debug("ToolPaint.on_paint_button_click() --> %s" % str(e))
|
||||||
self.app.inform.emit('[ERROR_NOTCL] %s: %s' %
|
self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object: %s"), self.obj_name))
|
||||||
(_("Could not retrieve object: %s"),
|
|
||||||
self.obj_name))
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.paint_obj is None:
|
if self.paint_obj is None:
|
||||||
self.app.inform.emit('[ERROR_NOTCL] %s: %s' %
|
self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Object not found"), self.paint_obj))
|
||||||
(_("Object not found"),
|
|
||||||
self.paint_obj))
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# test if the Geometry Object is multigeo and return Fail if True because
|
# test if the Geometry Object is multigeo and return Fail if True because
|
||||||
# for now Paint don't work on MultiGeo
|
# for now Paint don't work on MultiGeo
|
||||||
if self.paint_obj.multigeo is True:
|
if self.paint_obj.multigeo is True:
|
||||||
self.app.inform.emit('[ERROR_NOTCL] %s...' %
|
self.app.inform.emit('[ERROR_NOTCL] %s...' % _("Can't do Paint on MultiGeo geometries"))
|
||||||
_("Can't do Paint on MultiGeo geometries"))
|
|
||||||
return 'Fail'
|
return 'Fail'
|
||||||
|
|
||||||
o_name = '%s_multitool_paint' % self.obj_name
|
self.o_name = '%s_mt_paint' % self.obj_name
|
||||||
|
|
||||||
# use the selected tools in the tool table; get diameters
|
# use the selected tools in the tool table; get diameters
|
||||||
self.tooldia_list = list()
|
self.tooldia_list = list()
|
||||||
|
@ -1347,8 +1344,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||||
try:
|
try:
|
||||||
self.tooldia = float(self.tools_table.item(x.row(), 1).text().replace(',', '.'))
|
self.tooldia = float(self.tools_table.item(x.row(), 1).text().replace(',', '.'))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.app.inform.emit('[ERROR_NOTCL] %s' %
|
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Wrong value format entered, use a number."))
|
||||||
_("Wrong value format entered, use a number."))
|
|
||||||
continue
|
continue
|
||||||
self.tooldia_list.append(self.tooldia)
|
self.tooldia_list.append(self.tooldia)
|
||||||
else:
|
else:
|
||||||
|
@ -1401,7 +1397,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||||
# Get source object.
|
# Get source object.
|
||||||
try:
|
try:
|
||||||
self.bound_obj = self.app.collection.get_by_name(self.bound_obj_name)
|
self.bound_obj = self.app.collection.get_by_name(self.bound_obj_name)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), self.obj_name))
|
self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), self.obj_name))
|
||||||
return "Could not retrieve object: %s" % self.obj_name
|
return "Could not retrieve object: %s" % self.obj_name
|
||||||
|
|
||||||
|
@ -1525,14 +1521,14 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||||
_("Click the end point of the paint area."))
|
_("Click the end point of the paint area."))
|
||||||
|
|
||||||
self.cursor_pos = self.app.plotcanvas.translate_coords(event_pos)
|
self.cursor_pos = self.app.plotcanvas.translate_coords(event_pos)
|
||||||
if self.app.grid_status() == True:
|
if self.app.grid_status():
|
||||||
self.cursor_pos = self.app.geo_editor.snap(self.cursor_pos[0], self.cursor_pos[1])
|
self.cursor_pos = self.app.geo_editor.snap(self.cursor_pos[0], self.cursor_pos[1])
|
||||||
else:
|
else:
|
||||||
self.app.inform.emit(_("Zone added. Click to start adding next zone or right click to finish."))
|
self.app.inform.emit(_("Zone added. Click to start adding next zone or right click to finish."))
|
||||||
self.app.delete_selection_shape()
|
self.app.delete_selection_shape()
|
||||||
|
|
||||||
curr_pos = self.app.plotcanvas.translate_coords(event_pos)
|
curr_pos = self.app.plotcanvas.translate_coords(event_pos)
|
||||||
if self.app.grid_status() == True:
|
if self.app.grid_status():
|
||||||
curr_pos = self.app.geo_editor.snap(curr_pos[0], curr_pos[1])
|
curr_pos = self.app.geo_editor.snap(curr_pos[0], curr_pos[1])
|
||||||
|
|
||||||
x0, y0 = self.cursor_pos[0], self.cursor_pos[1]
|
x0, y0 = self.cursor_pos[0], self.cursor_pos[1]
|
||||||
|
@ -1608,7 +1604,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||||
self.mouse_is_dragging = False
|
self.mouse_is_dragging = False
|
||||||
|
|
||||||
# update the cursor position
|
# update the cursor position
|
||||||
if self.app.grid_status() == True:
|
if self.app.grid_status():
|
||||||
# Update cursor
|
# Update cursor
|
||||||
curr_pos = self.app.geo_editor.snap(curr_pos[0], curr_pos[1])
|
curr_pos = self.app.geo_editor.snap(curr_pos[0], curr_pos[1])
|
||||||
|
|
||||||
|
@ -1768,14 +1764,14 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||||
prog_plot=prog_plot)
|
prog_plot=prog_plot)
|
||||||
except FlatCAMApp.GracefulException:
|
except FlatCAMApp.GracefulException:
|
||||||
return "fail"
|
return "fail"
|
||||||
except Exception as e:
|
except Exception as ee:
|
||||||
log.debug("ToolPaint.paint_poly().gen_paintarea().paint_p() --> %s" % str(e))
|
log.debug("ToolPaint.paint_poly().gen_paintarea().paint_p() --> %s" % str(ee))
|
||||||
|
|
||||||
if cpoly is not None:
|
if cpoly is not None:
|
||||||
geo_obj.solid_geometry += list(cpoly.get_objects())
|
geo_obj.solid_geometry += list(cpoly.get_objects())
|
||||||
return cpoly
|
return cpoly
|
||||||
else:
|
else:
|
||||||
app_obj.inform.emit('[ERROR_NOTCL] %s' % _('Geometry could not be painted completely'))
|
app_obj.inform.emit('[ERROR_NOTCL] %s' % _('Geometry could not be painted completely'))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
current_uid = int(1)
|
current_uid = int(1)
|
||||||
|
@ -1843,7 +1839,11 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||||
geo_obj.solid_geometry = cascaded_union(tools_storage[current_uid]['solid_geometry'])
|
geo_obj.solid_geometry = cascaded_union(tools_storage[current_uid]['solid_geometry'])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
a, b, c, d = geo_obj.solid_geometry.bounds
|
if isinstance(geo_obj.solid_geometry, list):
|
||||||
|
a, b, c, d = MultiPolygon(geo_obj.solid_geometry).bounds
|
||||||
|
else:
|
||||||
|
a, b, c, d = geo_obj.solid_geometry.bounds
|
||||||
|
|
||||||
geo_obj.options['xmin'] = a
|
geo_obj.options['xmin'] = a
|
||||||
geo_obj.options['ymin'] = b
|
geo_obj.options['ymin'] = b
|
||||||
geo_obj.options['xmax'] = c
|
geo_obj.options['xmax'] = c
|
||||||
|
@ -2194,7 +2194,8 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# try:
|
# try:
|
||||||
# # Polygons are the only really paintable geometries, lines in theory have no area to be painted
|
# # Polygons are the only really paintable geometries,
|
||||||
|
# # lines in theory have no area to be painted
|
||||||
# if not isinstance(geo, Polygon):
|
# if not isinstance(geo, Polygon):
|
||||||
# continue
|
# continue
|
||||||
# poly_buf = geo.buffer(-paint_margin)
|
# poly_buf = geo.buffer(-paint_margin)
|
||||||
|
@ -3114,7 +3115,6 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||||
|
|
||||||
self.sel_rect = []
|
self.sel_rect = []
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def paint_bounds(geometry):
|
def paint_bounds(geometry):
|
||||||
def bounds_rec(o):
|
def bounds_rec(o):
|
||||||
|
|
Loading…
Reference in New Issue