- fixed Gerber object color set for Legacy(2D) graphic engine; glitch on the OpenGL(3D) graphic engine

This commit is contained in:
Marius Stanciu 2019-12-22 16:24:04 +02:00 committed by Marius
parent 988b9d7dac
commit 9fe3dfbfa9
4 changed files with 31 additions and 13 deletions

View File

@ -12396,13 +12396,22 @@ class App(QtCore.QObject):
new_color = str(plot_fill_color.name()) + \
str(hex(self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.value())[2:])
new_line_color = new_color[:-2]
sel_obj.fill_color = new_color
sel_obj.outline_color = new_line_color
if self.is_legacy is False:
new_line_color = new_color[:-2]
sel_obj.fill_color = new_color
sel_obj.outline_color = new_line_color
sel_obj.shapes.redraw(
update_colors=(new_color, new_line_color)
)
sel_obj.shapes.redraw(
update_colors=(new_color, new_line_color)
)
else:
new_line_color = new_color
sel_obj.fill_color = new_color
sel_obj.outline_color = new_line_color
sel_obj.shapes.redraw(
update_colors=(new_color, new_line_color)
)
def on_grid_snap_triggered(self, state):
if state:

View File

@ -112,9 +112,6 @@ class FlatCAMObj(QtCore.QObject):
else:
self.shapes = ShapeCollectionLegacy(obj=self, app=self.app, name=name)
self.fill_color = self.app.defaults['global_plot_fill']
self.outline_color = self.app.defaults['global_plot_line']
self.mark_shapes = dict()
self.item = None # Link with project view item
@ -657,6 +654,9 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
self.units_found = self.app.defaults['units']
self.fill_color = self.app.defaults['global_plot_fill']
self.outline_color = self.app.defaults['global_plot_line']
# Attributes to be included in serialization
# Always append to it because it carries contents
# from predecessors.

View File

@ -14,6 +14,7 @@ CAD program, and create G-Code for Isolation routing.
- added a new option for the Gerber objects: on the project context menu now can be chosen a color for the selected Gerber object
- fixed issue in Gerber UI where a label was not hidden when in Basic mode
- added the color parameters of the objects to the serializable attributes
- fixed Gerber object color set for Legacy(2D) graphic engine; glitch on the OpenGL(3D) graphic engine
21.12.2019

View File

@ -1033,7 +1033,7 @@ class ShapeCollectionLegacy:
if update is True:
self.redraw()
def redraw(self):
def redraw(self, update_colors=None):
"""
This draw the shapes in the shapes collection, on canvas
@ -1087,7 +1087,6 @@ class ShapeCollectionLegacy:
self.axes.plot(x, y, local_shapes[element]['color'],
linestyle='-',
linewidth=local_shapes[element]['linewidth'])
elif obj_type == 'gerber':
if self.obj.options["multicolored"]:
linespec = '-'
@ -1095,16 +1094,25 @@ class ShapeCollectionLegacy:
linespec = 'k-'
if self.obj.options["solid"]:
if update_colors:
gerber_fill_color = update_colors[0]
gerber_outline_color = update_colors[1]
else:
gerber_fill_color = local_shapes[element]['face_color']
gerber_outline_color = local_shapes[element]['color']
try:
patch = PolygonPatch(local_shapes[element]['shape'],
facecolor=local_shapes[element]['face_color'],
edgecolor=local_shapes[element]['color'],
facecolor=gerber_fill_color,
edgecolor=gerber_outline_color,
alpha=local_shapes[element]['alpha'],
zorder=2)
self.axes.add_patch(patch)
except AssertionError:
FlatCAMApp.App.log.warning("A geometry component was not a polygon:")
FlatCAMApp.App.log.warning(str(element))
except Exception as e:
FlatCAMApp.App.log.debug("PlotCanvasLegacy.ShepeCollectionLegacy.redraw() --> %s" % str(e))
else:
x, y = local_shapes[element]['shape'].exterior.xy
self.axes.plot(x, y, linespec)