Merged Beta_8.995 into gerber_editor_upgrade

This commit is contained in:
Marius Stanciu
2022-05-18 21:00:48 +00:00
4 changed files with 43 additions and 39 deletions

View File

@@ -7,6 +7,11 @@ CHANGELOG for FlatCAM Evo beta
=================================================
18.05.2022
- added some safeguards in Cutout Plugin
- fixed the `Toggle Grid Lines` functionality for dark mode
17.05.2020
- in Cutout Plugin added ability to use the margin (full range of values: negative, zero, positive) when applying the cutout over a Geometry source object

View File

@@ -383,7 +383,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
self.rect_hud.radius = [5, 5, 5, 5]
def on_toggle_grid_lines(self, signal=None, silent=None):
state = not self.grid_lines_enabled
state = self.grid_lines_enabled
settings = QtCore.QSettings("Open Source", "FlatCAM")
if settings.contains("theme"):
@@ -399,18 +399,18 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
if (theme == 'default' or theme == 'light') and not dark_canvas:
color = 'dimgray'
else:
color = '#dededeff'
color = '#202124ff'
if state:
self.fcapp.defaults['global_grid_lines'] = True
self.grid_lines_enabled = True
self.fcapp.options['global_grid_lines'] = True
self.grid_lines_enabled = False
# self.grid.parent = self.view.scene
self.grid._grid_color_fn['color'] = Color(color).rgba
if silent is None:
self.fcapp.inform[str, bool].emit(_("Grid enabled."), False)
else:
self.fcapp.defaults['global_grid_lines'] = False
self.grid_lines_enabled = False
self.fcapp.options['global_grid_lines'] = False
self.grid_lines_enabled = True
# self.grid.parent = None
self.grid._grid_color_fn['color'] = Color('#FFFFFFFF').rgba
if silent is None:

View File

@@ -534,11 +534,11 @@ class PlotCanvasLegacy(QtCore.QObject):
self.text = hud_text
def on_toggle_grid_lines(self, signal=None, silent=None):
state = not self.grid_lines_enabled
state = self.grid_lines_enabled
if state:
self.app.options['global_grid_lines'] = True
self.grid_lines_enabled = True
self.grid_lines_enabled = False
self.axes.grid(True)
try:
self.canvas.draw()
@@ -548,7 +548,7 @@ class PlotCanvasLegacy(QtCore.QObject):
self.app.inform[str, bool].emit(_("Grid enabled."), False)
else:
self.app.options['global_grid_lines'] = False
self.grid_lines_enabled = False
self.grid_lines_enabled = True
self.axes.grid(False)
try:
self.canvas.draw()

View File

@@ -651,7 +651,6 @@ class CutOut(AppTool):
if 0 in {cut_dia}:
self.app.inform.emit('[WARNING_NOTCL] %s' %
_("Tool Diameter is zero value. Change it to a positive real number."))
return "Tool Diameter is zero value. Change it to a positive real number."
try:
kind = self.ui.obj_kind_combo.get_value()
@@ -695,7 +694,7 @@ class CutOut(AppTool):
convex_box = self.ui.convex_box_cb.get_value()
gapsize = self.ui.gapsize.get_value()
# real gapsize has to be bigger because it will be made less by the cutting tool diameter
gapsize = gapsize + cut_dia
gapsize = gapsize + abs(cut_dia)
mb_dia = self.ui.mb_dia_entry.get_value()
mb_buff_val = mb_dia / 2.0
@@ -705,7 +704,7 @@ class CutOut(AppTool):
if cutout_obj.kind == 'gerber':
if isinstance(cutout_obj.solid_geometry, list):
cutout_obj.solid_geometry = MultiPolygon(cutout_obj.solid_geometry)
cutout_obj.solid_geometry = unary_union(cutout_obj.solid_geometry)
try:
if convex_box:
object_geo = cutout_obj.solid_geometry.convex_hull
@@ -758,7 +757,7 @@ class CutOut(AppTool):
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Failed."))
return 'fail'
solid_geo, rest_geo = self.any_cutout_handler(geo, cut_dia, gaps, gapsize, margin)
solid_geo, rest_geo = self.any_cutout_handler(geo, abs(cut_dia), gaps, gapsize, margin)
if gap_type == 1 and thin_entry != 0: # "Thin gaps"
gaps_solid_geo = rest_geo
else:
@@ -782,7 +781,7 @@ class CutOut(AppTool):
buff_geo_ext = geo_ext.buffer(-margin)
geom_struct = unary_union(buff_geo_ext.interiors)
c_geo, r_geo = self.any_cutout_handler(geom_struct, cut_dia, gaps, gapsize, margin)
c_geo, r_geo = self.any_cutout_handler(geom_struct, abs(cut_dia), gaps, gapsize, margin)
solid_geo += c_geo
if gap_type == 1 and thin_entry != 0: # "Thin gaps"
gaps_solid_geo += r_geo
@@ -800,7 +799,7 @@ class CutOut(AppTool):
# If it has mouse bytes
if has_mouse_bites is True:
gapsize -= cut_dia / 2
gapsize -= abs(cut_dia) / 2
mb_object_geo = deepcopy(object_geo)
if kind == 'single':
mb_object_geo = unary_union(mb_object_geo)
@@ -822,7 +821,7 @@ class CutOut(AppTool):
geo_buf = mb_object_geo.buffer(0.0000001)
mb_geo = geo_buf.exterior
__, rest_geo = self.any_cutout_handler(mb_geo, cut_dia, gaps, gapsize, margin)
__, rest_geo = self.any_cutout_handler(mb_geo, abs(cut_dia), gaps, gapsize, margin)
mouse_bites_geo = rest_geo
else:
mb_object_geo = flatten_shapely_geometry(mb_object_geo)
@@ -835,7 +834,7 @@ class CutOut(AppTool):
mb_geom_struct = mb_geom_struct.buffer(-margin + mb_buff_val)
mb_geom_struct = mb_geom_struct.interiors
__, mb_r_geo = self.any_cutout_handler(mb_geom_struct, cut_dia, gaps, gapsize, margin)
__, mb_r_geo = self.any_cutout_handler(mb_geom_struct, abs(cut_dia), gaps, gapsize, margin)
mouse_bites_geo += mb_r_geo
# list of Shapely Points to mark the drill points centers
@@ -851,11 +850,11 @@ class CutOut(AppTool):
geo_obj.solid_geometry = deepcopy(solid_geo)
geo_obj.tools[1] = deepcopy(self.cut_tool_dict)
geo_obj.tools[1]['tooldia'] = str(cut_dia)
geo_obj.tools[1]['tooldia'] = str(abs(cut_dia))
geo_obj.tools[1]['solid_geometry'] = geo_obj.solid_geometry
geo_obj.tools[1]['data']['name'] = outname
geo_obj.tools[1]['data']['tools_mill_tooldia'] = str(cut_dia)
geo_obj.tools[1]['data']['tools_mill_tooldia'] = str(abs(cut_dia))
geo_obj.tools[1]['data']['tools_mill_cutz'] = self.ui.cutz_entry.get_value()
geo_obj.tools[1]['data']['tools_mill_multidepth'] = self.ui.mpass_cb.get_value()
@@ -864,11 +863,11 @@ class CutOut(AppTool):
# if there are "thin gaps"
if gaps_solid_geo:
geo_obj.tools[99] = deepcopy(self.cut_tool_dict)
geo_obj.tools[99]['tooldia'] = str(cut_dia)
geo_obj.tools[99]['tooldia'] = str(abs(cut_dia))
geo_obj.tools[99]['solid_geometry'] = gaps_solid_geo
geo_obj.tools[99]['data']['name'] = outname
geo_obj.tools[99]['data']['tools_mill_tooldia'] = str(cut_dia)
geo_obj.tools[99]['data']['tools_mill_tooldia'] = str(abs(cut_dia))
geo_obj.tools[99]['data']['tools_mill_cutz'] = self.ui.thin_depth_entry.get_value()
geo_obj.tools[99]['data']['tools_mill_multidepth'] = self.ui.mpass_cb.get_value()
geo_obj.tools[99]['data']['tools_mill_depthperpass'] = self.ui.maxdepth_entry.get_value()
@@ -881,7 +880,7 @@ class CutOut(AppTool):
geo_obj.obj_options['xmax'] = xmax
geo_obj.obj_options['ymax'] = ymax
geo_obj.obj_options['tools_mill_tooldia'] = str(cut_dia)
geo_obj.obj_options['tools_mill_tooldia'] = str(abs(cut_dia))
geo_obj.obj_options['tools_mill_cutz'] = self.ui.cutz_entry.get_value()
geo_obj.obj_options['tools_mill_multidepth'] = self.ui.mpass_cb.get_value()
geo_obj.obj_options['tools_mill_depthperpass'] = self.ui.maxdepth_entry.get_value()
@@ -1049,7 +1048,6 @@ class CutOut(AppTool):
if 0 in {cut_dia_val}:
self.app.inform.emit('[ERROR_NOTCL] %s' %
_("Tool Diameter is zero value. Change it to a positive real number."))
return "Tool Diameter is zero value. Change it to a positive real number."
try:
kind = self.ui.obj_kind_combo.get_value()
@@ -1096,7 +1094,7 @@ class CutOut(AppTool):
mb_buff_val = mb_dia / 2.0
# real gapsize has to be bigger because it will be made less by the cutting tool diameter
gapsize = gapsize + cut_dia
gapsize = gapsize + abs(cut_dia)
if cutout_obj.multigeo is False:
object_geo = cutout_obj.solid_geometry
@@ -1140,7 +1138,7 @@ class CutOut(AppTool):
geo = unary_union(buff_geo_ext.interiors)
# w_gapsize = gapsize - abs(cut_dia)
solid_geo = self.rect_cutout_handler(geo, cut_dia, gaps, gapsize, margin, xmin, ymin, xmax, ymax)
solid_geo = self.rect_cutout_handler(geo, abs(cut_dia), gaps, gapsize, margin, xmin, ymin, xmax, ymax)
if gap_type == 1 and thin_entry != 0: # "Thin gaps"
gaps_solid_geo = self_c.subtract_geo(geo, deepcopy(solid_geo))
@@ -1162,7 +1160,7 @@ class CutOut(AppTool):
buff_geo_ext = geo_ext.buffer(-margin)
geom_struct = unary_union(buff_geo_ext.interiors)
c_geo = self.rect_cutout_handler(geom_struct, cut_dia, gaps, gapsize, margin,
c_geo = self.rect_cutout_handler(geom_struct, abs(cut_dia), gaps, gapsize, margin,
xmin, ymin, xmax, ymax)
solid_geo += c_geo
if gap_type == 1 and thin_entry != 0: # "Thin gaps"
@@ -1179,7 +1177,7 @@ class CutOut(AppTool):
geom_struct = geom_struct.buffer(margin + abs(cut_dia / 2))
c_geo = self.rect_cutout_handler(geom_struct, cut_dia, gaps, gapsize, margin,
c_geo = self.rect_cutout_handler(geom_struct, abs(cut_dia), gaps, gapsize, margin,
xmin, ymin, xmax, ymax)
solid_geo += c_geo
if gap_type == 1 and thin_entry != 0: # "Thin gaps"
@@ -1188,7 +1186,8 @@ class CutOut(AppTool):
except TypeError:
gaps_solid_geo.append(self_c.subtract_geo(geom_struct, c_geo))
elif cutout_obj.kind == 'gerber' and margin < 0:
mesg = '[WARNING_NOTCL] %s' % _("Rectangular cutout with negative margin is not possible.")
app_obj.log.error("Rectangular cutout with negative margin is not possible.")
mesg = '[ERROR_NOTCL] %s' % _("Failed.")
app_obj.inform.emit(mesg)
return "fail"
@@ -1204,7 +1203,7 @@ class CutOut(AppTool):
pass
if has_mouse_bites is True:
gapsize -= cut_dia / 2
gapsize -= abs(cut_dia) / 2
mb_object_geo = deepcopy(object_geo)
if kind == 'single':
@@ -1224,7 +1223,7 @@ class CutOut(AppTool):
else:
mb_geo = mb_geo.buffer(0.0000001)
mb_solid_geo = self.rect_cutout_handler(mb_geo, cut_dia, gaps, gapsize, margin,
mb_solid_geo = self.rect_cutout_handler(mb_geo, abs(cut_dia), gaps, gapsize, margin,
xmin, ymin, xmax, ymax)
mouse_bites_geo = self_c.subtract_geo(mb_geo, mb_solid_geo)
@@ -1236,7 +1235,7 @@ class CutOut(AppTool):
xmin, ymin, xmax, ymax = mb_geom_struct.bounds
mb_geom_struct = box(xmin, ymin, xmax, ymax)
c_geo = self.rect_cutout_handler(mb_geom_struct, cut_dia, gaps, gapsize, margin,
c_geo = self.rect_cutout_handler(mb_geom_struct, abs(cut_dia), gaps, gapsize, margin,
xmin, ymin, xmax, ymax)
solid_geo += c_geo
@@ -1252,7 +1251,7 @@ class CutOut(AppTool):
mb_geom_struct = box(xmin, ymin, xmax, ymax)
mb_geom_struct = mb_geom_struct.buffer(margin + mb_buff_val)
c_geo = self.rect_cutout_handler(mb_geom_struct, cut_dia, gaps, gapsize, margin,
c_geo = self.rect_cutout_handler(mb_geom_struct, abs(cut_dia), gaps, gapsize, margin,
xmin, ymin, xmax, ymax)
solid_geo += c_geo
@@ -1261,8 +1260,8 @@ class CutOut(AppTool):
except TypeError:
mouse_bites_geo.append(self_c.subtract_geo(mb_geom_struct, c_geo))
elif cutout_obj.kind == 'gerber' and margin < 0:
msg2 = '[WARNING_NOTCL] %s' % \
_("Rectangular cutout with negative margin is not possible.")
app_obj.log.error("Rectangular cutout with negative margin is not possible.")
msg2 = '[ERROR_NOTCL] %s' % _("Failed.")
app_obj.inform.emit(msg2)
return "fail"
@@ -1279,22 +1278,22 @@ class CutOut(AppTool):
geo_obj.solid_geometry = deepcopy(solid_geo)
geo_obj.tools[1] = deepcopy(self_c.cut_tool_dict)
geo_obj.tools[1]['tooldia'] = str(cut_dia)
geo_obj.tools[1]['tooldia'] = str(abs(cut_dia))
geo_obj.tools[1]['solid_geometry'] = geo_obj.solid_geometry
geo_obj.tools[1]['data']['name'] = outname
geo_obj.tools[1]['data']['tools_mill_tooldia'] = str(cut_dia)
geo_obj.tools[1]['data']['tools_mill_tooldia'] = str(abs(cut_dia))
geo_obj.tools[1]['data']['tools_mill_cutz'] = self_c.ui.cutz_entry.get_value()
geo_obj.tools[1]['data']['tools_mill_multidepth'] = self_c.ui.mpass_cb.get_value()
geo_obj.tools[1]['data']['tools_mill_depthperpass'] = self_c.ui.maxdepth_entry.get_value()
if gaps_solid_geo:
geo_obj.tools[99] = deepcopy(self_c.cut_tool_dict)
geo_obj.tools[99]['tooldia'] = str(cut_dia)
geo_obj.tools[99]['tooldia'] = str(abs(cut_dia))
geo_obj.tools[99]['solid_geometry'] = gaps_solid_geo
geo_obj.tools[99]['data']['name'] = outname
geo_obj.tools[99]['data']['tools_mill_tooldia'] = str(cut_dia)
geo_obj.tools[99]['data']['tools_mill_tooldia'] = str(abs(cut_dia))
geo_obj.tools[99]['data']['tools_mill_cutz'] = self_c.ui.thin_depth_entry.get_value()
geo_obj.tools[99]['data']['tools_mill_multidepth'] = self_c.ui.mpass_cb.get_value()
geo_obj.tools[99]['data']['tools_mill_depthperpass'] = self_c.ui.maxdepth_entry.get_value()
@@ -1306,7 +1305,7 @@ class CutOut(AppTool):
geo_obj.obj_options['xmax'] = xmax
geo_obj.obj_options['ymax'] = ymax
geo_obj.obj_options['tools_mill_tooldia'] = str(cut_dia)
geo_obj.obj_options['tools_mill_tooldia'] = str(abs(cut_dia))
geo_obj.obj_options['tools_mill_cutz'] = self_c.ui.cutz_entry.get_value()
geo_obj.obj_options['tools_mill_multidepth'] = self_c.ui.mpass_cb.get_value()
geo_obj.obj_options['tools_mill_depthperpass'] = self_c.ui.maxdepth_entry.get_value()