Skip to content

Commit 2af2f3d

Browse files
author
jonathan.bouyer
committed
SQUASHME: fix(actor): fix actor serialization condition
Serialize actors on condition of having a mapper and a property instance, or on visibility turn off
1 parent b116bc9 commit 2af2f3d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/trame_vtk/modules/vtk/serializers/actors.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .registry import class_name
44
from .serialize import serialize
55
from .utils import reference_id, rgb_float_to_hex, wrap_id
6-
from .cache import cache_properties
6+
from .cache import cache_properties, get_cached_property
77

88
logger = logging.getLogger(__name__)
99

@@ -69,7 +69,11 @@ def generic_actor_serializer(parent, actor, actor_id, context, depth):
6969
user_matrix[idx] = matrix.GetElement(i, j)
7070
add_on["userMatrix"] = user_matrix
7171

72-
if mapper_instance and property_instance:
72+
should_serialize = mapper_instance and property_instance
73+
if get_cached_property(actor_id, "visibility") and not actor_visibility:
74+
should_serialize = True
75+
76+
if should_serialize:
7377
return {
7478
"parent": reference_id(parent),
7579
"id": actor_id,

src/trame_vtk/modules/vtk/serializers/cache.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
PROP_CACHE = {}
22

33

4+
def get_cached_property(obj_id, prop):
5+
return PROP_CACHE.get(obj_id, {}).get(prop, None)
6+
7+
48
def cache_properties(obj_id, ctx, props):
59
if not ctx.ignore_last_dependencies:
610
prev = PROP_CACHE.get(obj_id)

0 commit comments

Comments
 (0)