- fixed MultiColor checkbox in Excellon Object to work in Legacy Mode (2D)
- modified the visibility change in Excellon UI to no longer do plot() when doing visibility toggle for one of the tools but only a visibility change in the shapes properties
This commit is contained in:
@@ -1272,6 +1272,7 @@ class ShapeCollectionLegacy:
|
||||
'face_color': self._face_color,
|
||||
'linewidth': line_width,
|
||||
'alpha': self._alpha,
|
||||
'visible': self._visible,
|
||||
'shape': sh
|
||||
})
|
||||
|
||||
@@ -1285,6 +1286,7 @@ class ShapeCollectionLegacy:
|
||||
'face_color': self._face_color,
|
||||
'linewidth': line_width,
|
||||
'alpha': self._alpha,
|
||||
'visible': self._visible,
|
||||
'shape': shape
|
||||
})
|
||||
|
||||
@@ -1336,19 +1338,20 @@ class ShapeCollectionLegacy:
|
||||
except AttributeError:
|
||||
obj_type = 'utility'
|
||||
|
||||
if self._visible:
|
||||
# if we don't use this then when adding each new shape, the old ones will be added again, too
|
||||
if obj_type == 'utility':
|
||||
self.axes.patches.clear()
|
||||
# if we don't use this then when adding each new shape, the old ones will be added again, too
|
||||
# if obj_type == 'utility':
|
||||
# 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 obj_type == 'excellon':
|
||||
# Plot excellon (All polygons?)
|
||||
if self.obj.options["solid"] and isinstance(local_shapes[element]['shape'], Polygon):
|
||||
try:
|
||||
patch = PolygonPatch(local_shapes[element]['shape'],
|
||||
facecolor="#C40000",
|
||||
edgecolor="#750000",
|
||||
facecolor=local_shapes[element]['face_color'],
|
||||
edgecolor=local_shapes[element]['color'],
|
||||
alpha=local_shapes[element]['alpha'],
|
||||
zorder=3,
|
||||
linewidth=local_shapes[element]['linewidth']
|
||||
@@ -1546,6 +1549,17 @@ class ShapeCollectionLegacy:
|
||||
self.redraw()
|
||||
self._visible = value
|
||||
|
||||
def update_visibility(self, state, indexes=None):
|
||||
if indexes:
|
||||
for i in indexes:
|
||||
if i in self._shapes:
|
||||
self._shapes[i]['visible'] = state
|
||||
else:
|
||||
for i in self._shapes:
|
||||
self._shapes[i]['visible'] = state
|
||||
|
||||
self.redraw()
|
||||
|
||||
@property
|
||||
def enabled(self):
|
||||
return self._visible
|
||||
|
||||
@@ -145,7 +145,9 @@ class ShapeGroup(object):
|
||||
:param kwargs: keyword arguments
|
||||
Arguments for ShapeCollection.add function
|
||||
"""
|
||||
self._indexes.append(self._collection.add(**kwargs))
|
||||
key = self._collection.add(**kwargs)
|
||||
self._indexes.append(key)
|
||||
return key
|
||||
|
||||
def remove(self, idx, update=False):
|
||||
self._indexes.remove(idx)
|
||||
@@ -196,6 +198,17 @@ class ShapeGroup(object):
|
||||
|
||||
self._collection.redraw([])
|
||||
|
||||
def update_visibility(self, state, indexes=None):
|
||||
if indexes:
|
||||
for i in indexes:
|
||||
if i in self._indexes:
|
||||
self._collection.data[i]['visible'] = state
|
||||
else:
|
||||
for i in self._indexes:
|
||||
self._collection.data[i]['visible'] = state
|
||||
|
||||
self._collection.redraw([])
|
||||
|
||||
|
||||
class ShapeCollectionVisual(CompoundVisual):
|
||||
|
||||
@@ -326,6 +339,19 @@ class ShapeCollectionVisual(CompoundVisual):
|
||||
if update:
|
||||
self.__update()
|
||||
|
||||
def update_visibility(self, state:bool, indexes=None) -> None:
|
||||
# Lock sub-visuals updates
|
||||
self.update_lock.acquire(True)
|
||||
if indexes is None:
|
||||
for k, data in list(self.data.items()):
|
||||
self.data[k]['visible'] = state
|
||||
else:
|
||||
for k, data in list(self.data.items()):
|
||||
if k in indexes:
|
||||
self.data[k]['visible'] = state
|
||||
|
||||
self.update_lock.release()
|
||||
|
||||
def update_color(self, new_mesh_color=None, new_line_color=None, indexes=None):
|
||||
if new_mesh_color is None and new_line_color is None:
|
||||
return
|
||||
@@ -533,7 +559,7 @@ class ShapeCollectionVisual(CompoundVisual):
|
||||
|
||||
self.results_lock.release()
|
||||
|
||||
if update_colors is None:
|
||||
if update_colors is None or update_colors is False:
|
||||
self.__update()
|
||||
else:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user