Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

FIX do not show labels for invisible shapes #429

Merged
merged 2 commits into from
Feb 18, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions cortex/svgoverlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,23 +249,23 @@ def get_texture(self, layer_name, height, name=None, background=None, labels=Tru
# separate kwargs starting with "label-"
label_kwargs = {k[6:]:v for k, v in kwargs.items() if k[:6] == "label-"}
kwargs = {k:v for k, v in kwargs.items() if k[:6] != "label-"}

for layer in self:
if layer.name==layer_name:
if layer.name == layer_name:
layer.visible = True
layer.labels.visible = labels
if shape_list is not None:
for name_, shape_ in layer.shapes.items():
for name_, shape_ in layer.shapes.items():
# honor visibility set in the svg
if shape_list is not None:
shape_.visible = name_ in shape_list
# Set visibility of labels (by setting text alpha to 0)
# This could be less baroque, but text elements currently
# do not have individually settable visibility / style params
tmp_style = copy.deepcopy(layer.labels.text_style)
tmp_style['fill-opacity'] = '1' if shape_.visible else '0'
tmp_style.update(label_kwargs)
tmp_style_str = ';'.join(['%s:%s'%(k,v) for k, v in tmp_style.items() if v != 'None'])
for i in range(len(layer.labels.elements[name_])):
layer.labels.elements[name_][i].set('style', tmp_style_str)
# Set visibility of labels (by setting text alpha to 0)
# This could be less baroque, but text elements currently
# do not have individually settable visibility / style params
tmp_style = copy.deepcopy(layer.labels.text_style)
tmp_style['fill-opacity'] = '1' if shape_.visible else '0'
tmp_style.update(label_kwargs)
tmp_style_str = ';'.join(['%s:%s'%(k,v) for k, v in tmp_style.items() if v != 'None'])
for i in range(len(layer.labels.elements[name_])):
layer.labels.elements[name_][i].set('style', tmp_style_str)
layer.set(**kwargs)
else:
layer.visible = False
Expand Down