diff --git a/cryoet_data_portal_neuroglancer/models/json_generator.py b/cryoet_data_portal_neuroglancer/models/json_generator.py index 883c682..54eeaea 100644 --- a/cryoet_data_portal_neuroglancer/models/json_generator.py +++ b/cryoet_data_portal_neuroglancer/models/json_generator.py @@ -118,6 +118,7 @@ class ImageJSONGenerator(RenderingJSONGenerator): can_hide_high_values_in_neuroglancer: bool = False blend: str = "additive" opacity: float = 1.0 + is_code_editor_visible: bool = False def __post_init__(self): self._type = RenderingTypes.IMAGE @@ -168,6 +169,7 @@ def generate_json(self) -> dict: "visible": self.is_visible, "volumeRendering": "on" if self.volume_rendering_is_visible else "off", "volumeRenderingGain": self.volume_rendering_gain, + "codeVisible": self.is_code_editor_visible, } if self.has_volume_rendering_shader: config["volumeRenderingDepthSamples"] = self.volume_rendering_depth_samples @@ -182,6 +184,7 @@ class AnnotationJSONGenerator(RenderingJSONGenerator): point_size_multiplier: float = 1.0 is_instance_segmentation: bool = False is_visible: bool = True + is_code_editor_visible: bool = False def __post_init__(self): self._type = RenderingTypes.ANNOTATION @@ -201,6 +204,7 @@ def generate_json(self) -> dict: "source": create_source(f"precomputed://{self.source}", self.scale, self.scale), "tab": "rendering", "visible": self.is_visible, + "codeVisible": self.is_code_editor_visible, **self._get_shader(), } diff --git a/cryoet_data_portal_neuroglancer/state_generator.py b/cryoet_data_portal_neuroglancer/state_generator.py index a1d0e6d..21e85c3 100644 --- a/cryoet_data_portal_neuroglancer/state_generator.py +++ b/cryoet_data_portal_neuroglancer/state_generator.py @@ -68,6 +68,7 @@ def generate_oriented_point_layer( scale: float | tuple[float, float, float] = (1.0, 1.0, 1.0), is_visible: bool = True, is_instance_segmentation: bool = False, + is_code_editor_visible: bool = False, ) -> dict[str, Any]: source, name, url, _, scale = _setup_creation(source, name, url, scale=scale) _validate_color(color) @@ -80,6 +81,7 @@ def generate_oriented_point_layer( scale=scale, is_visible=is_visible, is_instance_segmentation=is_instance_segmentation, + is_code_editor_visible=is_code_editor_visible, ).to_json() @@ -189,6 +191,7 @@ def generate_image_layer( can_hide_high_values_in_neuroglancer: bool | None = None, blend: str = "additive", opacity: float = 1.0, + is_code_editor_visible: bool = False, ) -> dict[str, Any]: """Generates JSON for an image layer with optional contrast limits. @@ -217,6 +220,7 @@ def generate_image_layer( can_hide_high_values_in_neuroglancer=can_hide_high_values_in_neuroglancer, blend=blend, opacity=opacity, + is_code_editor_visible=is_code_editor_visible, ).to_json() diff --git a/tests/test_state_generators.py b/tests/test_state_generators.py index cd61be6..4695ce1 100644 --- a/tests/test_state_generators.py +++ b/tests/test_state_generators.py @@ -1,4 +1,9 @@ -from cryoet_data_portal_neuroglancer.state_generator import generate_image_layer, generate_segmentation_mask_layer +from cryoet_data_portal_neuroglancer.state_generator import ( + generate_image_layer, + generate_oriented_point_layer, + generate_point_layer, + generate_segmentation_mask_layer, +) def test__generate_image_layer_default_values(): @@ -7,6 +12,8 @@ def test__generate_image_layer_default_values(): assert "blend" in state assert state["blend"] == "additive" assert state["opacity"] == 1.0 + assert "codeVisible" in state + assert state["codeVisible"] is False def test__generate_segmentation_layer_default_values(): @@ -14,3 +21,17 @@ def test__generate_segmentation_layer_default_values(): assert "pick" in state assert state["pick"] is False + + +def test__generate_oriented_point_layer_default_values(): + state = generate_oriented_point_layer(source="mysource") + + assert "codeVisible" in state + assert state["codeVisible"] is False + + +def test__generate_point_layer_default_values(): + state = generate_point_layer(source="mysource") + + assert "codeVisible" in state + assert state["codeVisible"] is False