- fixed the MultiColor plot option Gerber selected tab to work in legacy graphic engine

- documented some methods in the ShapeCollectionLegacy class
This commit is contained in:
Marius Stanciu 2019-09-22 14:03:20 +03:00 committed by Marius
parent f00559bf6a
commit 961c4bca2f
4 changed files with 62 additions and 7 deletions

View File

@ -124,7 +124,7 @@ class App(QtCore.QObject):
# ################## Version and VERSION DATE ##############################
# ##########################################################################
version = 8.97
version_date = "2019/09/20"
version_date = "2019/09/22"
beta = True
engine = '3D'
@ -2760,7 +2760,7 @@ class App(QtCore.QObject):
:param name: String that store the project path and project name
:return: None
"""
self.ui.setWindowTitle('FlatCAM %s %s - %s - (%s) %s' %
self.ui.setWindowTitle('FlatCAM %s %s - %s - [%s] %s' %
(self.version,
('BETA' if self.beta else ''),
platform.architecture()[0],

View File

@ -1356,11 +1356,26 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
except TypeError:
geometry = [geometry]
# if self.app.is_legacy is False:
def random_color():
color = np.random.rand(4)
color[3] = 1
return color
if self.app.is_legacy is False:
def random_color():
color = np.random.rand(4)
color[3] = 1
return color
else:
def random_color():
while True:
color = np.random.rand(4)
color[3] = 1
new_color = '#'
for idx in range(len(color)):
new_color += '%x' % int(color[idx] * 255)
# do it until a valid color is generated
# a valid color has the # symbol, another 6 chars for the color and the last 2 chars for alpha
# for a total of 9 chars
if len(new_color) == 9:
break
return new_color
try:
if self.options["solid"]:
@ -1395,6 +1410,8 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
self.shapes.redraw()
except (ObjectDeleted, AttributeError):
self.shapes.clear(update=True)
except Exception as e:
log.debug("FlatCAMGerber.plot() --> %s" % str(e))
# experimental plot() when the solid_geometry is stored in the self.apertures
def plot_aperture(self, run_thread=True, **kwargs):

View File

@ -21,6 +21,8 @@ CAD program, and create G-Code for Isolation routing.
- made hover shapes work in legacy graphic engine
- fixed bug in display of the apertures marked in the Aperture table found in the Gerber Selected tab and through this made it to also work with the legacy graphic engine
- fixed annotation in Mark Area Tool in Gerber Editor to work in legacy graphic engine
- fixed the MultiColor plot option Gerber selected tab to work in legacy graphic engine
- documented some methods in the ShapeCollectionLegacy class
21.09.2019

View File

@ -753,7 +753,23 @@ class ShapeCollectionLegacy:
def add(self, shape=None, color=None, face_color=None, alpha=None, visible=True,
update=False, layer=1, tolerance=0.01, obj=None, gcode_parsed=None, tool_tolerance=None, tooldia=None):
"""
This function will add shapes to the shape collection
:param shape: the Shapely shape to be added to the shape collection
:param color: edge color of the shape, hex value
:param face_color: the body color of the shape, hex value
:param alpha: level of transparency of the shape [0.0 ... 1.0]; Float
:param visible: if True will allow the shapes to be added
:param update: not used; just for compatibility with VIsPy canvas
:param layer: just for compatibility with VIsPy canvas
:param tolerance: just for compatibility with VIsPy canvas
:param obj: not used
:param gcode_parsed: not used; just for compatibility with VIsPy canvas
:param tool_tolerance: just for compatibility with VIsPy canvas
:param tooldia:
:return:
"""
self._color = color[:-2] if color is not None else None
self._face_color = face_color[:-2] if face_color is not None else None
self._alpha = int(face_color[-2:], 16) / 255 if face_color is not None else 0.75
@ -802,6 +818,12 @@ class ShapeCollectionLegacy:
return self.shape_id
def clear(self, update=None):
"""
Clear the canvas of the shapes.
:param update:
:return: None
"""
self._shapes.clear()
self.shape_id = 0
@ -812,6 +834,11 @@ class ShapeCollectionLegacy:
self.redraw()
def redraw(self):
"""
This draw the shapes in the shapes collection, on canvas
:return: None
"""
path_num = 0
local_shapes = deepcopy(self._shapes)
@ -922,7 +949,16 @@ class ShapeCollectionLegacy:
self.app.plotcanvas.auto_adjust_axes()
def set(self, text, pos, visible=True, font_size=16, color=None):
"""
This will set annotations on the canvas.
:param text: a list of text elements to be used as annotations
:param pos: a list of positions for showing the text elements above
:param visible: if True will display annotations, if False will clear them on canvas
:param font_size: the font size or the annotations
:param color: color of the annotations
:return: None
"""
if color is None:
color = "#000000FF"