- in Legacy2D graphic engine fixed setting the Opacity functionality

- fixed a recent issue where Gerber files made out of single polygons were not processed
This commit is contained in:
Marius Stanciu
2021-09-21 19:21:05 +03:00
committed by Marius
parent dd029d6ded
commit 734398d460
4 changed files with 35 additions and 32 deletions

View File

@@ -12,6 +12,8 @@ CHANGELOG for FlatCAM beta
- fixed an error due of missing attribute of PlotCanvasLegacy when using Legacy2D graphic engine - fixed an error due of missing attribute of PlotCanvasLegacy when using Legacy2D graphic engine
- solving deprecation warnings issued by Shapely - solving deprecation warnings issued by Shapely
- made sure that the Gerber Object geometry is always flattened - made sure that the Gerber Object geometry is always flattened
- in Legacy2D graphic engine fixed setting the Opacity functionality
- fixed a recent issue where Gerber files made out of single polygons were not processed
19.09.2021 19.09.2021

View File

@@ -29,6 +29,7 @@ MATPLOTLIB_AVAILABLE = True
try: try:
# Prevent conflict with Qt5 and above. # Prevent conflict with Qt5 and above.
from matplotlib import use as mpl_use from matplotlib import use as mpl_use
mpl_use("Qt5Agg") mpl_use("Qt5Agg")
from matplotlib.figure import Figure from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
@@ -37,6 +38,7 @@ except ImportError:
from matplotlib.lines import Line2D from matplotlib.lines import Line2D
from matplotlib.offsetbox import AnchoredText from matplotlib.offsetbox import AnchoredText
# from matplotlib.widgets import Cursor # from matplotlib.widgets import Cursor
fcTranslate.apply_language('strings') fcTranslate.apply_language('strings')
@@ -211,16 +213,16 @@ class PlotCanvasLegacy(QtCore.QObject):
'C10': (28, 40), 'C10': (28, 40),
# American paper sizes # American paper sizes
'LETTER': (8.5*25.4, 11*25.4), 'LETTER': (8.5 * 25.4, 11 * 25.4),
'LEGAL': (8.5*25.4, 14*25.4), 'LEGAL': (8.5 * 25.4, 14 * 25.4),
'ELEVENSEVENTEEN': (11*25.4, 17*25.4), 'ELEVENSEVENTEEN': (11 * 25.4, 17 * 25.4),
# From https://en.wikipedia.org/wiki/Paper_size # From https://en.wikipedia.org/wiki/Paper_size
'JUNIOR_LEGAL': (5*25.4, 8*25.4), 'JUNIOR_LEGAL': (5 * 25.4, 8 * 25.4),
'HALF_LETTER': (5.5*25.4, 8*25.4), 'HALF_LETTER': (5.5 * 25.4, 8 * 25.4),
'GOV_LETTER': (8*25.4, 10.5*25.4), 'GOV_LETTER': (8 * 25.4, 10.5 * 25.4),
'GOV_LEGAL': (8.5*25.4, 13*25.4), 'GOV_LEGAL': (8.5 * 25.4, 13 * 25.4),
'LEDGER': (17*25.4, 11*25.4), 'LEDGER': (17 * 25.4, 11 * 25.4),
} }
) )
@@ -554,7 +556,7 @@ class PlotCanvasLegacy(QtCore.QObject):
if self.app.defaults['units'].upper() == 'MM': if self.app.defaults['units'].upper() == 'MM':
dims = self.pagesize_dict[workspace_size] dims = self.pagesize_dict[workspace_size]
else: else:
dims = (self.pagesize_dict[workspace_size][0]/25.4, self.pagesize_dict[workspace_size][1]/25.4) dims = (self.pagesize_dict[workspace_size][0] / 25.4, self.pagesize_dict[workspace_size][1] / 25.4)
except Exception as e: except Exception as e:
log.error("PlotCanvasLegacy.draw_workspace() --> %s" % str(e)) log.error("PlotCanvasLegacy.draw_workspace() --> %s" % str(e))
return return
@@ -1123,7 +1125,8 @@ class PlotCanvasLegacy(QtCore.QObject):
self.draw_cursor(x_pos=x, y_pos=y) self.draw_cursor(x_pos=x, y_pos=y)
# self.canvas.blit(self.axes.bbox) # self.canvas.blit(self.axes.bbox)
def translate_coords(self, position): @staticmethod
def translate_coords(position):
""" """
This does not do much. It's just for code compatibility This does not do much. It's just for code compatibility
@@ -1254,6 +1257,7 @@ class ShapeCollectionLegacy:
hold the collection of shapes into a dict self._shapes. hold the collection of shapes into a dict self._shapes.
This handles the shapes redraw on canvas. This handles the shapes redraw on canvas.
""" """
def __init__(self, obj, app, name=None, annotation_job=None, linewidth=1): def __init__(self, obj, app, name=None, annotation_job=None, linewidth=1):
""" """
@@ -1312,7 +1316,7 @@ class ShapeCollectionLegacy:
:param obj: not used :param obj: not used
:param gcode_parsed: not used; just for compatibility with VIsPy canvas :param gcode_parsed: not used; just for compatibility with VIsPy canvas
:param tool_tolerance: just for compatibility with VIsPy canvas :param tool_tolerance: just for compatibility with VIsPy canvas
:param tooldia: :param tooldia: tool diameter
:param linewidth: the width of the line :param linewidth: the width of the line
:return: :return:
""" """
@@ -1428,7 +1432,6 @@ class ShapeCollectionLegacy:
# if obj_type == 'utility': # if obj_type == 'utility':
# self.axes.patches.clear() # self.axes.patches.clear()
self.axes.patches.clear() self.axes.patches.clear()
for element in local_shapes: for element in local_shapes:
if local_shapes[element]['visible'] is True: if local_shapes[element]['visible'] is True:
if obj_type == 'excellon': if obj_type == 'excellon':
@@ -1492,15 +1495,17 @@ class ShapeCollectionLegacy:
if update_colors: if update_colors:
gerber_fill_color = update_colors[0] gerber_fill_color = update_colors[0]
gerber_outline_color = update_colors[1] gerber_outline_color = update_colors[1]
gerber_alpha = int(gerber_fill_color[-2:], 16) / 255
else: else:
gerber_fill_color = local_shapes[element]['face_color'] gerber_fill_color = local_shapes[element]['face_color']
gerber_outline_color = local_shapes[element]['color'] gerber_outline_color = local_shapes[element]['color']
gerber_alpha = local_shapes[element]['alpha']
try: try:
patch = PolygonPatch(local_shapes[element]['shape'], patch = PolygonPatch(local_shapes[element]['shape'],
facecolor=gerber_fill_color, facecolor=gerber_fill_color,
edgecolor=gerber_outline_color, edgecolor=gerber_outline_color,
alpha=local_shapes[element]['alpha'], alpha=gerber_alpha,
zorder=2, zorder=2,
linewidth=local_shapes[element]['linewidth']) linewidth=local_shapes[element]['linewidth'])
self.axes.add_patch(patch) self.axes.add_patch(patch)

View File

@@ -80,9 +80,6 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
{'label': _('OpenGL(3D)'), 'value': '3D'}], {'label': _('OpenGL(3D)'), 'value': '3D'}],
orientation='vertical') orientation='vertical')
# TODO disabled until matplotlib will support PyQt6
self.ge_radio.setDisabled(True)
grid0.addWidget(self.ge_label, 6, 0) grid0.addWidget(self.ge_label, 6, 0)
grid0.addWidget(self.ge_radio, 6, 1) grid0.addWidget(self.ge_radio, 6, 1)

View File

@@ -8104,7 +8104,6 @@ def flatten_shapely_geometry(geometry):
if isinstance(geometry, (MultiLineString, MultiPolygon, MultiPoint)): if isinstance(geometry, (MultiLineString, MultiPolygon, MultiPoint)):
for geo in geometry.geoms: for geo in geometry.geoms:
flat_list.append(geo) flat_list.append(geo)
elif isinstance(geometry, list):
for geo_el in geometry: for geo_el in geometry:
flat_list += flatten_shapely_geometry(geo_el) flat_list += flatten_shapely_geometry(geo_el)
except TypeError: except TypeError: