Skip to content

Commit

Permalink
feat: Disable "pick" for default value in segmentation layer
Browse files Browse the repository at this point in the history
  • Loading branch information
aranega committed Nov 27, 2024
1 parent cb32980 commit 3af57f4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cryoet_data_portal_neuroglancer/models/json_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ class SegmentationJSONGenerator(RenderingJSONGenerator):
highlight_on_hover: bool = False
mesh_render_scale: float = 1.0
visible_segments: tuple[int, ...] = (1,)
enable_pick: bool = False

def __post_init__(self):
self._type = RenderingTypes.SEGMENTATION
Expand All @@ -254,6 +255,7 @@ def generate_json(self) -> dict:
"segments": sorted((self.visible_segments)),
"visible": self.is_visible,
"meshRenderScale": self.mesh_render_scale,
"pick": self.enable_pick,
}
# self.color === None means that the color will be random
# This is useful for multiple segmentations
Expand Down
2 changes: 2 additions & 0 deletions cryoet_data_portal_neuroglancer/state_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def generate_segmentation_mask_layer(
highlight_on_hover: bool = False,
mesh_render_scale: float = 2.0,
visible_segments: tuple[int, ...] = (1,),
enable_pick: bool = False,
) -> dict[str, Any]:
source, name, url, _, scale = _setup_creation(source, name, url, scale=scale)
_validate_color(color)
Expand All @@ -109,6 +110,7 @@ def generate_segmentation_mask_layer(
highlight_on_hover=highlight_on_hover,
mesh_render_scale=mesh_render_scale,
visible_segments=visible_segments,
enable_pick=enable_pick,
).to_json()


Expand Down
9 changes: 8 additions & 1 deletion tests/test_state_generators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from cryoet_data_portal_neuroglancer.state_generator import generate_image_layer
from cryoet_data_portal_neuroglancer.state_generator import generate_image_layer, generate_segmentation_mask_layer


def test__generate_image_layer_default_values():
Expand All @@ -7,3 +7,10 @@ def test__generate_image_layer_default_values():
assert "blend" in state
assert state["blend"] == "additive"
assert state["opacity"] == 1.0


def test__generate_segmentation_layer_default_values():
state = generate_segmentation_mask_layer(source="mysource")

assert "pick" in state
assert state["pick"] is False

0 comments on commit 3af57f4

Please sign in to comment.