From 86359e9c11af047ba3cdb51a63d3bd3c42596d6c Mon Sep 17 00:00:00 2001 From: JulienChampagnol Date: Wed, 2 Dec 2026 15:04:35 +0100 Subject: [PATCH 1/7] feat(highlight): brand orange highlight, like the Import button Co-Authored-By: Claude Opus 5.5 --- .../object/object_methods.py | 41 +++++++++++-------- tests/test_highlight_style.py | 25 +++++++++++ 2 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 tests/test_highlight_style.py diff --git a/src/opengeodeweb_viewer/object/object_methods.py b/src/opengeodeweb_viewer/object/object_methods.py index 98c8a08b..8e0a7303 100644 --- a/src/opengeodeweb_viewer/object/object_methods.py +++ b/src/opengeodeweb_viewer/object/object_methods.py @@ -32,6 +32,29 @@ EDGES_DEPTH_FACTOR_SHARE = 0.2 +# Geode Solutions brand Orange (#F48830): the accent color of the app's Import button +HIGHLIGHT_COLOR = (244 / 255, 136 / 255, 48 / 255) +# Brand Auburn (#47250A), the dark orange of the brand palette, for the highlight outline +HIGHLIGHT_EDGE_COLOR = (71 / 255, 37 / 255, 10 / 255) + + +def apply_highlight_style(actor: vtkActor, mapper: vtkDataSetMapper) -> None: + mapper.ScalarVisibilityOff() + mapper.SetResolveCoincidentTopologyToPolygonOffset() + mapper.SetRelativeCoincidentTopologyPolygonOffsetParameters(-2, -2) + prop = actor.GetProperty() + prop.SetColor(*HIGHLIGHT_COLOR) + prop.SetLineWidth(4) + prop.SetPointSize(15) + prop.RenderPointsAsSpheresOn() + prop.LightingOff() + prop.EdgeVisibilityOn() + prop.SetEdgeColor(*HIGHLIGHT_EDGE_COLOR) + actor.SetMapper(mapper) + actor.VisibilityOff() + actor.UseBoundsOff() + + class VtkObjectView(VtkView): def __init__(self) -> None: super().__init__() @@ -410,25 +433,9 @@ def clear_colors(self, data_id: str) -> None: scalar_bar.actor.VisibilityOff() self.update_scalar_bars_layout() - def _apply_highlight_style(self, actor: vtkActor, mapper: vtkDataSetMapper) -> None: - mapper.ScalarVisibilityOff() - mapper.SetResolveCoincidentTopologyToPolygonOffset() - mapper.SetRelativeCoincidentTopologyPolygonOffsetParameters(-2, -2) - prop = actor.GetProperty() - prop.SetColor(0.235, 0.6, 0.514) - prop.SetLineWidth(4) - prop.SetPointSize(15) - prop.RenderPointsAsSpheresOn() - prop.LightingOff() - prop.EdgeVisibilityOn() - prop.SetEdgeColor(0.12, 0.35, 0.30) - actor.SetMapper(mapper) - actor.VisibilityOff() - actor.UseBoundsOff() - def highlight(self, pipeline: VtkPipeline) -> None: highlight = pipeline.highlight - self._apply_highlight_style(highlight.actor, highlight.mapper) + apply_highlight_style(highlight.actor, highlight.mapper) if pipeline.filter.GetNumberOfInputConnections(0) == 0: pipeline.filter.SetInputConnection(pipeline.reader.GetOutputPort()) input_port = pipeline.filter.GetOutputPort() diff --git a/tests/test_highlight_style.py b/tests/test_highlight_style.py new file mode 100644 index 00000000..ce8ccfc9 --- /dev/null +++ b/tests/test_highlight_style.py @@ -0,0 +1,25 @@ +# Standard library imports + +# Third party imports +import pytest +from vtkmodules.vtkRenderingCore import vtkActor, vtkDataSetMapper + +# Local application imports +from opengeodeweb_viewer.object.object_methods import apply_highlight_style + +RGB_MAX = 255 + + +def test_highlight_has_the_color_of_the_import_button() -> None: + actor = vtkActor() + + apply_highlight_style(actor, vtkDataSetMapper()) + + # Geode Solutions brand Orange (#F48830), the accent color of the app's Import button + assert actor.GetProperty().GetColor() == pytest.approx( + (244 / RGB_MAX, 136 / RGB_MAX, 48 / RGB_MAX) + ) + # Brand Auburn (#47250A), the dark orange of the brand palette, outlines it + assert actor.GetProperty().GetEdgeColor() == pytest.approx( + (71 / RGB_MAX, 37 / RGB_MAX, 10 / RGB_MAX) + ) From e6f10eca905567a10ed12840d4b04c2e28f82bb2 Mon Sep 17 00:00:00 2001 From: JulienChampagnol Date: Wed, 2 Dec 2026 15:14:36 +0100 Subject: [PATCH 2/7] fix(highlight): whole components highlighted without cell edges Outlining every cell of a highlighted surface hid its color under the edges. A picked cell is still outlined. Co-Authored-By: Claude Opus 5.5 --- .../object/object_methods.py | 15 +++++++- .../rpc/model/model_protocols.py | 17 +++++---- src/opengeodeweb_viewer/vtk_protocol.py | 2 ++ tests/test_highlight_style.py | 35 +++++++++++++++++-- 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/src/opengeodeweb_viewer/object/object_methods.py b/src/opengeodeweb_viewer/object/object_methods.py index 8e0a7303..6c713b2b 100644 --- a/src/opengeodeweb_viewer/object/object_methods.py +++ b/src/opengeodeweb_viewer/object/object_methods.py @@ -8,6 +8,7 @@ vtkDataSet, vtkMultiBlockDataSet, ) +from vtkmodules.vtkFiltersCore import vtkAppendDataSets from vtkmodules.vtkRenderingAnnotation import vtkScalarBarActor from vtkmodules.vtkRenderingCore import ( vtkActor, @@ -17,10 +18,12 @@ ) # Local application imports -from opengeodeweb_viewer.vtk_pipeline import VtkPipeline +from opengeodeweb_viewer.vtk_pipeline import HighlightPipeline, VtkPipeline from opengeodeweb_viewer.vtk_protocol import VtkView if TYPE_CHECKING: + from collections.abc import Iterable + from vtkmodules.vtkIOXML import vtkXMLReader from opengeodeweb_viewer.utils_functions import ColorClassProtocol @@ -55,6 +58,16 @@ def apply_highlight_style(actor: vtkActor, mapper: vtkDataSetMapper) -> None: actor.UseBoundsOff() +def highlight_whole_components(highlight: HighlightPipeline, blocks: Iterable[vtkDataSet]) -> None: + """Show whole components in plain color: outlining each of their cells would hide it.""" + append = vtkAppendDataSets() + for block in blocks: + append.AddInputData(block) + append.Update() + highlight.mapper.SetInputDataObject(append.GetOutput()) + highlight.actor.GetProperty().EdgeVisibilityOff() + + class VtkObjectView(VtkView): def __init__(self) -> None: super().__init__() diff --git a/src/opengeodeweb_viewer/rpc/model/model_protocols.py b/src/opengeodeweb_viewer/rpc/model/model_protocols.py index 3e762160..50d29a0b 100644 --- a/src/opengeodeweb_viewer/rpc/model/model_protocols.py +++ b/src/opengeodeweb_viewer/rpc/model/model_protocols.py @@ -12,7 +12,6 @@ vtkDataSet, vtkMultiBlockDataSet, ) -from vtkmodules.vtkFiltersCore import vtkAppendDataSets from vtkmodules.vtkIOXML import vtkXMLMultiBlockDataReader from vtkmodules.vtkRenderingCore import ( vtkActor, @@ -21,7 +20,7 @@ ) # Local application imports -from opengeodeweb_viewer.object.object_methods import VtkObjectView +from opengeodeweb_viewer.object.object_methods import VtkObjectView, highlight_whole_components from opengeodeweb_viewer.typed_rpc import typed_rpc from opengeodeweb_viewer.utils_functions import ( AttributeProtocol, @@ -537,13 +536,13 @@ def set_model_visibility(self, params: schemas.Visibility) -> schemas.Visibility def set_model_highlight(self, params: schemas.Highlight) -> schemas.HighlightResponse: pipeline = self.get_vtk_pipeline(params.id) if params.visibility and params.block_ids: - append = vtkAppendDataSets() - for i in params.block_ids: - block = pipeline.block_data_sets[i] if i < len(pipeline.block_data_sets) else None - if isinstance(block, vtkDataSet): - append.AddInputData(block) - append.Update() - pipeline.highlight.mapper.SetInputDataObject(append.GetOutput()) + blocks = [ + pipeline.block_data_sets[i] if i < len(pipeline.block_data_sets) else None + for i in params.block_ids + ] + highlight_whole_components( + pipeline.highlight, [block for block in blocks if isinstance(block, vtkDataSet)] + ) else: pipeline.highlight.mapper.SetInputConnection( pipeline.highlight.extract_selection.GetOutputPort() diff --git a/src/opengeodeweb_viewer/vtk_protocol.py b/src/opengeodeweb_viewer/vtk_protocol.py index 892dcf22..951f290f 100644 --- a/src/opengeodeweb_viewer/vtk_protocol.py +++ b/src/opengeodeweb_viewer/vtk_protocol.py @@ -244,6 +244,8 @@ def update_highlight( pipeline.highlight.extract_selection.SetInputData(0, target_dataset) pipeline.highlight.extract_selection.Modified() pipeline.highlight.extract_selection.Update() + # The picked cell is outlined, even after whole components were highlighted without edges + pipeline.highlight.actor.GetProperty().EdgeVisibilityOn() pipeline.highlight.actor.VisibilityOn() def clear_highlights(self, data_ids: list[str]) -> None: diff --git a/tests/test_highlight_style.py b/tests/test_highlight_style.py index ce8ccfc9..9e7152b1 100644 --- a/tests/test_highlight_style.py +++ b/tests/test_highlight_style.py @@ -2,10 +2,17 @@ # Third party imports import pytest -from vtkmodules.vtkRenderingCore import vtkActor, vtkDataSetMapper +from vtkmodules.vtkFiltersSources import vtkCubeSource +from vtkmodules.vtkIOXML import vtkXMLMultiBlockDataReader +from vtkmodules.vtkRenderingCore import vtkActor, vtkCompositePolyDataMapper, vtkDataSetMapper # Local application imports -from opengeodeweb_viewer.object.object_methods import apply_highlight_style +from opengeodeweb_viewer.object.object_methods import ( + apply_highlight_style, + highlight_whole_components, +) +from opengeodeweb_viewer.vtk_pipeline import VtkPipeline +from opengeodeweb_viewer.vtk_protocol import VtkView RGB_MAX = 255 @@ -23,3 +30,27 @@ def test_highlight_has_the_color_of_the_import_button() -> None: assert actor.GetProperty().GetEdgeColor() == pytest.approx( (71 / RGB_MAX, 37 / RGB_MAX, 10 / RGB_MAX) ) + + +def test_whole_components_are_highlighted_without_edges() -> None: + pipeline = VtkPipeline(vtkXMLMultiBlockDataReader(), vtkCompositePolyDataMapper()) + apply_highlight_style(pipeline.highlight.actor, pipeline.highlight.mapper) + cube = vtkCubeSource() + cube.Update() + + highlight_whole_components(pipeline.highlight, [cube.GetOutput()]) + + assert not pipeline.highlight.actor.GetProperty().GetEdgeVisibility() + assert pipeline.highlight.mapper.GetInputDataObject(0, 0).GetNumberOfCells() == 6 + + +def test_a_picked_cell_is_outlined_after_a_component_highlight() -> None: + pipeline = VtkPipeline(vtkXMLMultiBlockDataReader(), vtkCompositePolyDataMapper()) + apply_highlight_style(pipeline.highlight.actor, pipeline.highlight.mapper) + cube = vtkCubeSource() + cube.Update() + highlight_whole_components(pipeline.highlight, [cube.GetOutput()]) + + VtkView().update_highlight(pipeline, 0, "CELL", cube.GetOutput()) + + assert pipeline.highlight.actor.GetProperty().GetEdgeVisibility() From 87a762e96f4cd1feac6611e22c4197da3f13606d Mon Sep 17 00:00:00 2001 From: JulienChampagnol Date: Wed, 2 Dec 2026 15:55:48 +0100 Subject: [PATCH 3/7] feat(highlight): whole model highlighted by component type A highlight of every component of a model shows surfaces in brand Orange, lines in Auburn and corners in Anthracite. Some components, or a picked cell, stay in Orange. Co-Authored-By: Claude Opus 5.5 --- .../object/object_methods.py | 68 +++++++++++++++++-- .../rpc/model/model_protocols.py | 20 ++++-- src/opengeodeweb_viewer/vtk_protocol.py | 4 +- tests/helpers/__init__.py | 0 tests/helpers/colors.py | 6 ++ tests/test_highlight_style.py | 67 +++++++++++++++++- 6 files changed, 150 insertions(+), 15 deletions(-) create mode 100644 tests/helpers/__init__.py create mode 100644 tests/helpers/colors.py diff --git a/src/opengeodeweb_viewer/object/object_methods.py b/src/opengeodeweb_viewer/object/object_methods.py index 6c713b2b..8a2771d3 100644 --- a/src/opengeodeweb_viewer/object/object_methods.py +++ b/src/opengeodeweb_viewer/object/object_methods.py @@ -3,7 +3,11 @@ from typing import TYPE_CHECKING, Any # Third party imports -from vtkmodules.vtkCommonCore import VTK_COLOR_MODE_DIRECT_SCALARS, reference +from vtkmodules.vtkCommonCore import ( + VTK_COLOR_MODE_DIRECT_SCALARS, + reference, + vtkUnsignedCharArray, +) from vtkmodules.vtkCommonDataModel import ( vtkDataSet, vtkMultiBlockDataSet, @@ -22,7 +26,7 @@ from opengeodeweb_viewer.vtk_protocol import VtkView if TYPE_CHECKING: - from collections.abc import Iterable + from collections.abc import Iterable, Mapping from vtkmodules.vtkIOXML import vtkXMLReader @@ -39,6 +43,17 @@ HIGHLIGHT_COLOR = (244 / 255, 136 / 255, 48 / 255) # Brand Auburn (#47250A), the dark orange of the brand palette, for the highlight outline HIGHLIGHT_EDGE_COLOR = (71 / 255, 37 / 255, 10 / 255) +# Brand Anthracite (#1E1E1E) +HIGHLIGHT_CORNER_COLOR = (30 / 255, 30 / 255, 30 / 255) +# A whole model highlights each component type in its own color: surfaces in Orange, lines in +# Auburn, corners in Anthracite. Blocks take the surfaces color. +WHOLE_MODEL_HIGHLIGHT_COLORS = { + "surfaces": HIGHLIGHT_COLOR, + "lines": HIGHLIGHT_EDGE_COLOR, + "corners": HIGHLIGHT_CORNER_COLOR, +} +HIGHLIGHT_COLOR_ARRAY = "highlight_color" +RGB_MAX = 255 def apply_highlight_style(actor: vtkActor, mapper: vtkDataSetMapper) -> None: @@ -58,14 +73,55 @@ def apply_highlight_style(actor: vtkActor, mapper: vtkDataSetMapper) -> None: actor.UseBoundsOff() +def is_whole_model(block_ids: Iterable[int], component_types: Mapping[int, str]) -> bool: + """Whether the highlighted blocks are every component of the model.""" + return bool(component_types) and component_types.keys() <= set(block_ids) + + +def _show_whole_components(highlight: HighlightPipeline, append: vtkAppendDataSets) -> None: + """Outlining each cell of whole components would hide their color.""" + append.Update() + highlight.mapper.SetInputDataObject(append.GetOutput()) + highlight.actor.GetProperty().EdgeVisibilityOff() + + def highlight_whole_components(highlight: HighlightPipeline, blocks: Iterable[vtkDataSet]) -> None: - """Show whole components in plain color: outlining each of their cells would hide it.""" + """Show some components of a model in the highlight color.""" append = vtkAppendDataSets() for block in blocks: append.AddInputData(block) - append.Update() - highlight.mapper.SetInputDataObject(append.GetOutput()) - highlight.actor.GetProperty().EdgeVisibilityOff() + highlight.mapper.ScalarVisibilityOff() + _show_whole_components(highlight, append) + + +def _with_cell_color(block: vtkDataSet, color: tuple[float, float, float]) -> vtkDataSet: + """A shallow copy of block whose cells all have color, the block itself left untouched.""" + colored = block.NewInstance() + colored.ShallowCopy(block) + colors = vtkUnsignedCharArray() + colors.SetName(HIGHLIGHT_COLOR_ARRAY) + colors.SetNumberOfComponents(3) + colors.SetNumberOfTuples(colored.GetNumberOfCells()) + for component, value in enumerate(color): + colors.FillComponent(component, round(value * RGB_MAX)) + colored.GetCellData().AddArray(colors) + return colored + + +def highlight_whole_model( + highlight: HighlightPipeline, typed_blocks: Iterable[tuple[vtkDataSet, str]] +) -> None: + """Show every component of a model, each in the color of its component type.""" + append = vtkAppendDataSets() + for block, component_type in typed_blocks: + color = WHOLE_MODEL_HIGHLIGHT_COLORS.get(component_type, HIGHLIGHT_COLOR) + append.AddInputData(_with_cell_color(block, color)) + mapper = highlight.mapper + mapper.ScalarVisibilityOn() + mapper.SetScalarModeToUseCellFieldData() + mapper.SelectColorArray(HIGHLIGHT_COLOR_ARRAY) + mapper.SetColorModeToDirectScalars() + _show_whole_components(highlight, append) class VtkObjectView(VtkView): diff --git a/src/opengeodeweb_viewer/rpc/model/model_protocols.py b/src/opengeodeweb_viewer/rpc/model/model_protocols.py index 50d29a0b..052ac9c6 100644 --- a/src/opengeodeweb_viewer/rpc/model/model_protocols.py +++ b/src/opengeodeweb_viewer/rpc/model/model_protocols.py @@ -20,7 +20,12 @@ ) # Local application imports -from opengeodeweb_viewer.object.object_methods import VtkObjectView, highlight_whole_components +from opengeodeweb_viewer.object.object_methods import ( + VtkObjectView, + highlight_whole_components, + highlight_whole_model, + is_whole_model, +) from opengeodeweb_viewer.typed_rpc import typed_rpc from opengeodeweb_viewer.utils_functions import ( AttributeProtocol, @@ -536,14 +541,19 @@ def set_model_visibility(self, params: schemas.Visibility) -> schemas.Visibility def set_model_highlight(self, params: schemas.Highlight) -> schemas.HighlightResponse: pipeline = self.get_vtk_pipeline(params.id) if params.visibility and params.block_ids: + component_types = pipeline.block_component_types() blocks = [ - pipeline.block_data_sets[i] if i < len(pipeline.block_data_sets) else None + (block, component_types.get(i, "")) for i in params.block_ids + if i < len(pipeline.block_data_sets) + and isinstance(block := pipeline.block_data_sets[i], vtkDataSet) ] - highlight_whole_components( - pipeline.highlight, [block for block in blocks if isinstance(block, vtkDataSet)] - ) + if is_whole_model(params.block_ids, component_types): + highlight_whole_model(pipeline.highlight, blocks) + else: + highlight_whole_components(pipeline.highlight, [block for block, _ in blocks]) else: + pipeline.highlight.mapper.ScalarVisibilityOff() pipeline.highlight.mapper.SetInputConnection( pipeline.highlight.extract_selection.GetOutputPort() ) diff --git a/src/opengeodeweb_viewer/vtk_protocol.py b/src/opengeodeweb_viewer/vtk_protocol.py index 951f290f..fd78b1a3 100644 --- a/src/opengeodeweb_viewer/vtk_protocol.py +++ b/src/opengeodeweb_viewer/vtk_protocol.py @@ -244,7 +244,9 @@ def update_highlight( pipeline.highlight.extract_selection.SetInputData(0, target_dataset) pipeline.highlight.extract_selection.Modified() pipeline.highlight.extract_selection.Update() - # The picked cell is outlined, even after whole components were highlighted without edges + # The picked cell is outlined in the highlight color, even after a whole model or whole + # components were highlighted without edges or in their component type colors + pipeline.highlight.mapper.ScalarVisibilityOff() pipeline.highlight.actor.GetProperty().EdgeVisibilityOn() pipeline.highlight.actor.VisibilityOn() diff --git a/tests/helpers/__init__.py b/tests/helpers/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/helpers/colors.py b/tests/helpers/colors.py new file mode 100644 index 00000000..479eb5b4 --- /dev/null +++ b/tests/helpers/colors.py @@ -0,0 +1,6 @@ +RGB_MAX = 255 + + +def rgb(red: int, green: int, blue: int) -> tuple[float, float, float]: + """A color from its 0-255 channels, as VTK takes it.""" + return (red / RGB_MAX, green / RGB_MAX, blue / RGB_MAX) diff --git a/tests/test_highlight_style.py b/tests/test_highlight_style.py index 9e7152b1..bff4c423 100644 --- a/tests/test_highlight_style.py +++ b/tests/test_highlight_style.py @@ -2,7 +2,7 @@ # Third party imports import pytest -from vtkmodules.vtkFiltersSources import vtkCubeSource +from vtkmodules.vtkFiltersSources import vtkCubeSource, vtkLineSource, vtkPointSource from vtkmodules.vtkIOXML import vtkXMLMultiBlockDataReader from vtkmodules.vtkRenderingCore import vtkActor, vtkCompositePolyDataMapper, vtkDataSetMapper @@ -10,11 +10,12 @@ from opengeodeweb_viewer.object.object_methods import ( apply_highlight_style, highlight_whole_components, + highlight_whole_model, + is_whole_model, ) from opengeodeweb_viewer.vtk_pipeline import VtkPipeline from opengeodeweb_viewer.vtk_protocol import VtkView - -RGB_MAX = 255 +from tests.helpers.colors import RGB_MAX, rgb def test_highlight_has_the_color_of_the_import_button() -> None: @@ -54,3 +55,63 @@ def test_a_picked_cell_is_outlined_after_a_component_highlight() -> None: VtkView().update_highlight(pipeline, 0, "CELL", cube.GetOutput()) assert pipeline.highlight.actor.GetProperty().GetEdgeVisibility() + + +def test_a_highlight_of_every_component_is_the_whole_model() -> None: + types = {1: "corners", 2: "lines", 3: "surfaces"} + + assert is_whole_model([1, 2, 3], types) + assert not is_whole_model([2, 3], types) + assert not is_whole_model([], types) + + +def test_the_whole_model_is_highlighted_with_a_color_per_component_type() -> None: + pipeline = VtkPipeline(vtkXMLMultiBlockDataReader(), vtkCompositePolyDataMapper()) + apply_highlight_style(pipeline.highlight.actor, pipeline.highlight.mapper) + sources = [vtkCubeSource(), vtkLineSource(), vtkPointSource()] + for source in sources: + source.Update() + surface, line, corner = (source.GetOutput() for source in sources) + + highlight_whole_model( + pipeline.highlight, [(surface, "surfaces"), (line, "lines"), (corner, "corners")] + ) + + mapper = pipeline.highlight.mapper + assert mapper.GetScalarVisibility() + assert not pipeline.highlight.actor.GetProperty().GetEdgeVisibility() + colors = mapper.GetInputDataObject(0, 0).GetCellData().GetArray(mapper.GetArrayName()) + first_cells = {"surfaces": 0, "lines": 6, "corners": 7} + assert [ + tuple(component / RGB_MAX for component in colors.GetTuple3(cell)) + for cell in first_cells.values() + ] == [ + pytest.approx(rgb(0xF4, 0x88, 0x30)), + pytest.approx(rgb(0x47, 0x25, 0x0A)), + pytest.approx(rgb(0x1E, 0x1E, 0x1E)), + ] + + +def test_some_components_are_highlighted_in_orange_after_the_whole_model() -> None: + pipeline = VtkPipeline(vtkXMLMultiBlockDataReader(), vtkCompositePolyDataMapper()) + apply_highlight_style(pipeline.highlight.actor, pipeline.highlight.mapper) + cube = vtkCubeSource() + cube.Update() + highlight_whole_model(pipeline.highlight, [(cube.GetOutput(), "surfaces")]) + + highlight_whole_components(pipeline.highlight, [cube.GetOutput()]) + + assert not pipeline.highlight.mapper.GetScalarVisibility() + assert pipeline.highlight.actor.GetProperty().GetColor() == pytest.approx(rgb(0xF4, 0x88, 0x30)) + + +def test_a_picked_cell_is_orange_after_the_whole_model() -> None: + pipeline = VtkPipeline(vtkXMLMultiBlockDataReader(), vtkCompositePolyDataMapper()) + apply_highlight_style(pipeline.highlight.actor, pipeline.highlight.mapper) + cube = vtkCubeSource() + cube.Update() + highlight_whole_model(pipeline.highlight, [(cube.GetOutput(), "surfaces")]) + + VtkView().update_highlight(pipeline, 0, "CELL", cube.GetOutput()) + + assert not pipeline.highlight.mapper.GetScalarVisibility() From 8591b4b78949b02cc8934f86b4b1f00e4b60c6ba Mon Sep 17 00:00:00 2001 From: JulienChampagnol Date: Wed, 2 Dec 2026 16:04:53 +0100 Subject: [PATCH 4/7] feat(highlight): whole model lines in Anthracite, corners in Auburn Co-Authored-By: Claude Opus 5.5 --- src/opengeodeweb_viewer/object/object_methods.py | 8 ++++---- tests/test_highlight_style.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/opengeodeweb_viewer/object/object_methods.py b/src/opengeodeweb_viewer/object/object_methods.py index 8a2771d3..fc21a44c 100644 --- a/src/opengeodeweb_viewer/object/object_methods.py +++ b/src/opengeodeweb_viewer/object/object_methods.py @@ -44,13 +44,13 @@ # Brand Auburn (#47250A), the dark orange of the brand palette, for the highlight outline HIGHLIGHT_EDGE_COLOR = (71 / 255, 37 / 255, 10 / 255) # Brand Anthracite (#1E1E1E) -HIGHLIGHT_CORNER_COLOR = (30 / 255, 30 / 255, 30 / 255) +HIGHLIGHT_LINE_COLOR = (30 / 255, 30 / 255, 30 / 255) # A whole model highlights each component type in its own color: surfaces in Orange, lines in -# Auburn, corners in Anthracite. Blocks take the surfaces color. +# Anthracite, corners in Auburn. Blocks take the surfaces color. WHOLE_MODEL_HIGHLIGHT_COLORS = { "surfaces": HIGHLIGHT_COLOR, - "lines": HIGHLIGHT_EDGE_COLOR, - "corners": HIGHLIGHT_CORNER_COLOR, + "lines": HIGHLIGHT_LINE_COLOR, + "corners": HIGHLIGHT_EDGE_COLOR, } HIGHLIGHT_COLOR_ARRAY = "highlight_color" RGB_MAX = 255 diff --git a/tests/test_highlight_style.py b/tests/test_highlight_style.py index bff4c423..e332cd95 100644 --- a/tests/test_highlight_style.py +++ b/tests/test_highlight_style.py @@ -87,8 +87,8 @@ def test_the_whole_model_is_highlighted_with_a_color_per_component_type() -> Non for cell in first_cells.values() ] == [ pytest.approx(rgb(0xF4, 0x88, 0x30)), - pytest.approx(rgb(0x47, 0x25, 0x0A)), pytest.approx(rgb(0x1E, 0x1E, 0x1E)), + pytest.approx(rgb(0x47, 0x25, 0x0A)), ] From 2cdb90ebd138e8ced0dcdc989e5df704972e798e Mon Sep 17 00:00:00 2001 From: JulienChampagnol <91873154+JulienChampagnol@users.noreply.github.com> Date: Wed, 2 Dec 2026 16:48:45 +0000 Subject: [PATCH 5/7] Apply prepare changes --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 64bd7093..0e8e27eb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -61,4 +61,3 @@ wslink==2.6.0 yarl==1.* # via aiohttp -opengeodeweb-microservice==1.*,>=1.5.0 From 072464ef5823dadc48a935ef0461d9944bcce67a Mon Sep 17 00:00:00 2001 From: JulienChampagnol Date: Thu, 3 Dec 2026 10:42:57 +0100 Subject: [PATCH 6/7] feat(highlight): highlight colours set by the app A new viewer.set_highlight_colors RPC sets the highlight, outline and whole-model component type colours for the session, restyling the highlights already loaded. Without it, and after reset_visualization, the viewer uses brand-neutral teal defaults. Co-Authored-By: Claude Opus 5.5 --- opengeodeweb_viewer_schemas.json | 156 ++++++++++++++++++ opengeodeweb_viewer_typed_schemas.d.ts | 12 ++ .../object/object_methods.py | 87 ++++++++-- .../rpc/viewer/schemas/__init__.py | 1 + .../viewer/schemas/set_highlight_colors.json | 35 ++++ .../viewer/schemas/set_highlight_colors.py | 35 ++++ .../rpc/viewer/viewer_protocols.py | 28 ++++ tests/conftest.py | 8 + tests/test_highlight_style.py | 93 +++++++++-- tests/test_viewer_protocols.py | 22 +++ 10 files changed, 444 insertions(+), 33 deletions(-) create mode 100644 src/opengeodeweb_viewer/rpc/viewer/schemas/set_highlight_colors.json create mode 100644 src/opengeodeweb_viewer/rpc/viewer/schemas/set_highlight_colors.py diff --git a/opengeodeweb_viewer_schemas.json b/opengeodeweb_viewer_schemas.json index ae66e43c..b5b33d3a 100644 --- a/opengeodeweb_viewer_schemas.json +++ b/opengeodeweb_viewer_schemas.json @@ -5487,6 +5487,162 @@ "additionalProperties": false } }, + "set_highlight_colors": { + "$id": "opengeodeweb_viewer.viewer.set_highlight_colors", + "rpc": "set_highlight_colors", + "type": "object", + "properties": { + "color": { + "title": "ColorRGB", + "type": "object", + "properties": { + "red": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "green": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "blue": { + "type": "integer", + "minimum": 0, + "maximum": 255 + } + }, + "required": [ + "red", + "green", + "blue" + ], + "additionalProperties": false + }, + "outline_color": { + "title": "ColorRGB", + "type": "object", + "properties": { + "red": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "green": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "blue": { + "type": "integer", + "minimum": 0, + "maximum": 255 + } + }, + "required": [ + "red", + "green", + "blue" + ], + "additionalProperties": false + }, + "surfaces_color": { + "title": "ColorRGB", + "type": "object", + "properties": { + "red": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "green": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "blue": { + "type": "integer", + "minimum": 0, + "maximum": 255 + } + }, + "required": [ + "red", + "green", + "blue" + ], + "additionalProperties": false + }, + "lines_color": { + "title": "ColorRGB", + "type": "object", + "properties": { + "red": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "green": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "blue": { + "type": "integer", + "minimum": 0, + "maximum": 255 + } + }, + "required": [ + "red", + "green", + "blue" + ], + "additionalProperties": false + }, + "corners_color": { + "title": "ColorRGB", + "type": "object", + "properties": { + "red": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "green": { + "type": "integer", + "minimum": 0, + "maximum": 255 + }, + "blue": { + "type": "integer", + "minimum": 0, + "maximum": 255 + } + }, + "required": [ + "red", + "green", + "blue" + ], + "additionalProperties": false + } + }, + "required": [ + "color", + "outline_color", + "surfaces_color", + "lines_color", + "corners_color" + ], + "additionalProperties": false, + "response": { + "type": "object", + "properties": {}, + "required": [], + "additionalProperties": false + } + }, "set_background_color": { "$id": "opengeodeweb_viewer.viewer.set_background_color", "rpc": "set_background_color", diff --git a/opengeodeweb_viewer_typed_schemas.d.ts b/opengeodeweb_viewer_typed_schemas.d.ts index da71c1b6..0108207a 100644 --- a/opengeodeweb_viewer_typed_schemas.d.ts +++ b/opengeodeweb_viewer_typed_schemas.d.ts @@ -1036,6 +1036,17 @@ export type Marker = "axes" | "compass" | "none"; export interface ViewerSetOrientationWidgetResponse { } +export interface ViewerSetHighlightColorsParams { + color: ColorRGB; + corners_color: ColorRGB; + lines_color: ColorRGB; + outline_color: ColorRGB; + surfaces_color: ColorRGB; +} + +export interface ViewerSetHighlightColorsResponse { +} + export interface ViewerSetBackgroundColorParams { color: ColorRGB; } @@ -1401,6 +1412,7 @@ export interface Schemas { readonly set_z_scaling: (typeof json)["opengeodeweb_viewer"]["viewer"]["set_z_scaling"] & TypedSchema; readonly set_text_style: (typeof json)["opengeodeweb_viewer"]["viewer"]["set_text_style"] & TypedSchema; readonly set_orientation_widget: (typeof json)["opengeodeweb_viewer"]["viewer"]["set_orientation_widget"] & TypedSchema; + readonly set_highlight_colors: (typeof json)["opengeodeweb_viewer"]["viewer"]["set_highlight_colors"] & TypedSchema; readonly set_background_color: (typeof json)["opengeodeweb_viewer"]["viewer"]["set_background_color"] & TypedSchema; readonly ruler: (typeof json)["opengeodeweb_viewer"]["viewer"]["ruler"] & TypedSchema; readonly reset_visualization: (typeof json)["opengeodeweb_viewer"]["viewer"]["reset_visualization"] & TypedSchema; diff --git a/src/opengeodeweb_viewer/object/object_methods.py b/src/opengeodeweb_viewer/object/object_methods.py index fc21a44c..b45c07b8 100644 --- a/src/opengeodeweb_viewer/object/object_methods.py +++ b/src/opengeodeweb_viewer/object/object_methods.py @@ -1,4 +1,5 @@ import logging +from dataclasses import dataclass from pathlib import Path from typing import TYPE_CHECKING, Any @@ -30,6 +31,7 @@ from vtkmodules.vtkIOXML import vtkXMLReader + from opengeodeweb_viewer.schema_types import ColorRGB from opengeodeweb_viewer.utils_functions import ColorClassProtocol from opengeodeweb_viewer.vtk_pipeline import ColorMapKey @@ -39,35 +41,85 @@ EDGES_DEPTH_FACTOR_SHARE = 0.2 -# Geode Solutions brand Orange (#F48830): the accent color of the app's Import button -HIGHLIGHT_COLOR = (244 / 255, 136 / 255, 48 / 255) -# Brand Auburn (#47250A), the dark orange of the brand palette, for the highlight outline -HIGHLIGHT_EDGE_COLOR = (71 / 255, 37 / 255, 10 / 255) -# Brand Anthracite (#1E1E1E) -HIGHLIGHT_LINE_COLOR = (30 / 255, 30 / 255, 30 / 255) -# A whole model highlights each component type in its own color: surfaces in Orange, lines in -# Anthracite, corners in Auburn. Blocks take the surfaces color. -WHOLE_MODEL_HIGHLIGHT_COLORS = { - "surfaces": HIGHLIGHT_COLOR, - "lines": HIGHLIGHT_LINE_COLOR, - "corners": HIGHLIGHT_EDGE_COLOR, -} -HIGHLIGHT_COLOR_ARRAY = "highlight_color" RGB_MAX = 255 +Rgb = tuple[float, float, float] + + +@dataclass +class HighlightColors: + """The highlight colors of a session, VTK RGB (0-1).""" + + # Some components, a picked cell or point + color: Rgb + # The outline of a picked cell + outline_color: Rgb + # A whole model highlighted shows each component type in its own color; blocks take surfaces' + surfaces_color: Rgb + lines_color: Rgb + corners_color: Rgb + + +def vtk_rgb(color: ColorRGB) -> Rgb: + return (color.red / RGB_MAX, color.green / RGB_MAX, color.blue / RGB_MAX) + + +_TEAL = (60 / RGB_MAX, 153 / RGB_MAX, 131 / RGB_MAX) +_DARK_TEAL = (31 / RGB_MAX, 89 / RGB_MAX, 77 / RGB_MAX) +# Without colors set by the app, the viewer stays brand-neutral +DEFAULT_HIGHLIGHT_COLORS = HighlightColors( + color=_TEAL, + outline_color=_DARK_TEAL, + surfaces_color=_TEAL, + lines_color=_DARK_TEAL, + corners_color=_DARK_TEAL, +) + + +class _SessionHighlight: + """The highlight colors set by the app for this viewer, else the defaults.""" + + colors = DEFAULT_HIGHLIGHT_COLORS + + +def set_highlight_colors(colors: HighlightColors) -> None: + _SessionHighlight.colors = colors + + +def reset_highlight_colors() -> None: + _SessionHighlight.colors = DEFAULT_HIGHLIGHT_COLORS + + +def apply_highlight_colors(actor: vtkActor) -> None: + """Give actor the session highlight colors.""" + prop = actor.GetProperty() + prop.SetColor(*_SessionHighlight.colors.color) + prop.SetEdgeColor(*_SessionHighlight.colors.outline_color) + + +def _component_type_color(component_type: str) -> Rgb: + colors = _SessionHighlight.colors + return { + "surfaces": colors.surfaces_color, + "lines": colors.lines_color, + "corners": colors.corners_color, + }.get(component_type, colors.surfaces_color) + + +HIGHLIGHT_COLOR_ARRAY = "highlight_color" + def apply_highlight_style(actor: vtkActor, mapper: vtkDataSetMapper) -> None: mapper.ScalarVisibilityOff() mapper.SetResolveCoincidentTopologyToPolygonOffset() mapper.SetRelativeCoincidentTopologyPolygonOffsetParameters(-2, -2) prop = actor.GetProperty() - prop.SetColor(*HIGHLIGHT_COLOR) prop.SetLineWidth(4) prop.SetPointSize(15) prop.RenderPointsAsSpheresOn() prop.LightingOff() prop.EdgeVisibilityOn() - prop.SetEdgeColor(*HIGHLIGHT_EDGE_COLOR) + apply_highlight_colors(actor) actor.SetMapper(mapper) actor.VisibilityOff() actor.UseBoundsOff() @@ -114,8 +166,7 @@ def highlight_whole_model( """Show every component of a model, each in the color of its component type.""" append = vtkAppendDataSets() for block, component_type in typed_blocks: - color = WHOLE_MODEL_HIGHLIGHT_COLORS.get(component_type, HIGHLIGHT_COLOR) - append.AddInputData(_with_cell_color(block, color)) + append.AddInputData(_with_cell_color(block, _component_type_color(component_type))) mapper = highlight.mapper mapper.ScalarVisibilityOn() mapper.SetScalarModeToUseCellFieldData() diff --git a/src/opengeodeweb_viewer/rpc/viewer/schemas/__init__.py b/src/opengeodeweb_viewer/rpc/viewer/schemas/__init__.py index e16c1379..28334dd3 100644 --- a/src/opengeodeweb_viewer/rpc/viewer/schemas/__init__.py +++ b/src/opengeodeweb_viewer/rpc/viewer/schemas/__init__.py @@ -7,6 +7,7 @@ from .set_z_scaling import * from .set_text_style import * from .set_orientation_widget import * +from .set_highlight_colors import * from .set_background_color import * from .ruler import * from .reset_visualization import * diff --git a/src/opengeodeweb_viewer/rpc/viewer/schemas/set_highlight_colors.json b/src/opengeodeweb_viewer/rpc/viewer/schemas/set_highlight_colors.json new file mode 100644 index 00000000..0acda2f6 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/viewer/schemas/set_highlight_colors.json @@ -0,0 +1,35 @@ +{ + "rpc": "set_highlight_colors", + "type": "object", + "properties": { + "color": { + "title": "ColorRGB" + }, + "outline_color": { + "title": "ColorRGB" + }, + "surfaces_color": { + "title": "ColorRGB" + }, + "lines_color": { + "title": "ColorRGB" + }, + "corners_color": { + "title": "ColorRGB" + } + }, + "required": [ + "color", + "outline_color", + "surfaces_color", + "lines_color", + "corners_color" + ], + "additionalProperties": false, + "response": { + "type": "object", + "properties": {}, + "required": [], + "additionalProperties": false + } +} diff --git a/src/opengeodeweb_viewer/rpc/viewer/schemas/set_highlight_colors.py b/src/opengeodeweb_viewer/rpc/viewer/schemas/set_highlight_colors.py new file mode 100644 index 00000000..c8aed972 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/viewer/schemas/set_highlight_colors.py @@ -0,0 +1,35 @@ +from opengeodeweb_viewer.schema_types import ColorRGB +from pathlib import Path +from opengeodeweb_microservice.schemas import Route, load_schema +from dataclasses_json import DataClassJsonMixin +from opengeodeweb_microservice.schemas import print_dataclass +from dataclasses import dataclass + + +@dataclass +class SetHighlightColors(DataClassJsonMixin): + def __post_init__(self) -> None: + print_dataclass(self) + + color: ColorRGB + corners_color: ColorRGB + lines_color: ColorRGB + outline_color: ColorRGB + surfaces_color: ColorRGB + + +@dataclass +class SetHighlightColorsResponse(DataClassJsonMixin): + def __post_init__(self) -> None: + print_dataclass(self) + + pass + + +set_highlight_colors_route = Route( + schema=load_schema(Path(__file__)), + params=SetHighlightColors, + response=SetHighlightColorsResponse, +) + +__all__ = ["ColorRGB", "ColorRGB", "ColorRGB", "ColorRGB", "ColorRGB", "SetHighlightColors", "SetHighlightColorsResponse", "set_highlight_colors_route"] diff --git a/src/opengeodeweb_viewer/rpc/viewer/viewer_protocols.py b/src/opengeodeweb_viewer/rpc/viewer/viewer_protocols.py index bf200f16..3e17f8bf 100644 --- a/src/opengeodeweb_viewer/rpc/viewer/viewer_protocols.py +++ b/src/opengeodeweb_viewer/rpc/viewer/viewer_protocols.py @@ -36,6 +36,13 @@ ) from vtkmodules.vtkRenderingUI import vtkGenericRenderWindowInteractor +from opengeodeweb_viewer.object.object_methods import ( + HighlightColors, + apply_highlight_colors, + reset_highlight_colors, + set_highlight_colors, + vtk_rgb, +) from opengeodeweb_viewer.orientation_marker import NO_MARKER, build_marker, style_marker from opengeodeweb_viewer.rpc.viewer import schemas from opengeodeweb_viewer.rpc.viewer.schemas.explode import ExplodedBound @@ -67,6 +74,8 @@ def reset_visualization( renderer = render_window.GetRenderers().GetFirstRenderer() renderer.RemoveAllViewProps() self._clipping_plane_previews = [] + # A reset viewer draws its own highlight colors, until the app sets its own again + reset_highlight_colors() grid_scale = vtkCubeAxesActor() grid_scale.SetCamera(renderer.GetActiveCamera()) @@ -122,6 +131,25 @@ def set_background_color( renderer.SetBackground([color.red / 255, color.green / 255, color.blue / 255]) return schemas.SetBackgroundColorResponse() + @typed_rpc(viewer_prefix, schemas.set_highlight_colors_route) + def update_highlight_colors( + self, params: schemas.SetHighlightColors + ) -> schemas.SetHighlightColorsResponse: + set_highlight_colors( + HighlightColors( + color=vtk_rgb(params.color), + outline_color=vtk_rgb(params.outline_color), + surfaces_color=vtk_rgb(params.surfaces_color), + lines_color=vtk_rgb(params.lines_color), + corners_color=vtk_rgb(params.corners_color), + ) + ) + # Highlights of the data already loaded take the new colors too + for pipeline in self.get_data_base().values(): + apply_highlight_colors(pipeline.highlight.actor) + self.render(-1) + return schemas.SetHighlightColorsResponse() + @typed_rpc(viewer_prefix, schemas.set_text_style_route) def update_text_style(self, params: schemas.SetTextStyle) -> schemas.SetTextStyleResponse: color = params.color diff --git a/tests/conftest.py b/tests/conftest.py index 5ec82428..4cdc23c3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -18,6 +18,7 @@ from xprocess import ProcessStarter, XProcess # type: ignore[import-untyped] from opengeodeweb_viewer.config import TestConfig +from opengeodeweb_viewer.object.object_methods import reset_highlight_colors from opengeodeweb_viewer.rpc.viewer.viewer_protocols import VtkViewerView if TYPE_CHECKING: @@ -183,6 +184,13 @@ class Starter(ProcessStarter): # type: ignore[misc] TEST_PROJECT_FOLDER_PATH = tempfile.mkdtemp(prefix="ogw_test_data_") +@pytest.fixture(autouse=True) +def default_highlight_colors() -> Generator[None]: + """Highlight colors set by a test are the session's: each test starts from the defaults.""" + yield + reset_highlight_colors() + + @pytest.fixture def server(xprocess: XProcess) -> Generator[ServerMonitor]: name, starter, monitor_class = HELPER.get_xprocess_args(TEST_PROJECT_FOLDER_PATH) diff --git a/tests/test_highlight_style.py b/tests/test_highlight_style.py index e332cd95..4d18d26f 100644 --- a/tests/test_highlight_style.py +++ b/tests/test_highlight_style.py @@ -8,29 +8,71 @@ # Local application imports from opengeodeweb_viewer.object.object_methods import ( + HighlightColors, + apply_highlight_colors, apply_highlight_style, highlight_whole_components, highlight_whole_model, is_whole_model, + reset_highlight_colors, + set_highlight_colors, ) from opengeodeweb_viewer.vtk_pipeline import VtkPipeline from opengeodeweb_viewer.vtk_protocol import VtkView from tests.helpers.colors import RGB_MAX, rgb +TEAL = rgb(60, 153, 131) +DARK_TEAL = rgb(31, 89, 77) +ORANGE = rgb(0xF4, 0x88, 0x30) +AUBURN = rgb(0x47, 0x25, 0x0A) +ANTHRACITE = rgb(0x1E, 0x1E, 0x1E) +BRAND_COLORS = HighlightColors( + color=ORANGE, + outline_color=AUBURN, + surfaces_color=ORANGE, + lines_color=ANTHRACITE, + corners_color=AUBURN, +) + -def test_highlight_has_the_color_of_the_import_button() -> None: +def test_highlight_has_neutral_colors_by_default() -> None: actor = vtkActor() apply_highlight_style(actor, vtkDataSetMapper()) - # Geode Solutions brand Orange (#F48830), the accent color of the app's Import button - assert actor.GetProperty().GetColor() == pytest.approx( - (244 / RGB_MAX, 136 / RGB_MAX, 48 / RGB_MAX) - ) - # Brand Auburn (#47250A), the dark orange of the brand palette, outlines it - assert actor.GetProperty().GetEdgeColor() == pytest.approx( - (71 / RGB_MAX, 37 / RGB_MAX, 10 / RGB_MAX) - ) + assert actor.GetProperty().GetColor() == pytest.approx(TEAL) + assert actor.GetProperty().GetEdgeColor() == pytest.approx(DARK_TEAL) + + +def test_highlight_takes_the_colors_set_by_the_app() -> None: + actor = vtkActor() + + set_highlight_colors(BRAND_COLORS) + apply_highlight_style(actor, vtkDataSetMapper()) + + assert actor.GetProperty().GetColor() == pytest.approx(ORANGE) + assert actor.GetProperty().GetEdgeColor() == pytest.approx(AUBURN) + + +def test_an_existing_highlight_takes_the_new_colors() -> None: + actor = vtkActor() + apply_highlight_style(actor, vtkDataSetMapper()) + + set_highlight_colors(BRAND_COLORS) + apply_highlight_colors(actor) + + assert actor.GetProperty().GetColor() == pytest.approx(ORANGE) + assert actor.GetProperty().GetEdgeColor() == pytest.approx(AUBURN) + + +def test_resetting_highlight_colors_brings_back_the_defaults() -> None: + actor = vtkActor() + set_highlight_colors(BRAND_COLORS) + + reset_highlight_colors() + apply_highlight_style(actor, vtkDataSetMapper()) + + assert actor.GetProperty().GetColor() == pytest.approx(TEAL) def test_whole_components_are_highlighted_without_edges() -> None: @@ -73,6 +115,7 @@ def test_the_whole_model_is_highlighted_with_a_color_per_component_type() -> Non source.Update() surface, line, corner = (source.GetOutput() for source in sources) + set_highlight_colors(BRAND_COLORS) highlight_whole_model( pipeline.highlight, [(surface, "surfaces"), (line, "lines"), (corner, "corners")] ) @@ -86,13 +129,33 @@ def test_the_whole_model_is_highlighted_with_a_color_per_component_type() -> Non tuple(component / RGB_MAX for component in colors.GetTuple3(cell)) for cell in first_cells.values() ] == [ - pytest.approx(rgb(0xF4, 0x88, 0x30)), - pytest.approx(rgb(0x1E, 0x1E, 0x1E)), - pytest.approx(rgb(0x47, 0x25, 0x0A)), + pytest.approx(ORANGE, abs=0.5 / RGB_MAX), + pytest.approx(ANTHRACITE, abs=0.5 / RGB_MAX), + pytest.approx(AUBURN, abs=0.5 / RGB_MAX), + ] + + +def test_the_whole_model_has_neutral_colors_by_default() -> None: + pipeline = VtkPipeline(vtkXMLMultiBlockDataReader(), vtkCompositePolyDataMapper()) + apply_highlight_style(pipeline.highlight.actor, pipeline.highlight.mapper) + sources = [vtkCubeSource(), vtkLineSource()] + for source in sources: + source.Update() + surface, line = (source.GetOutput() for source in sources) + + highlight_whole_model(pipeline.highlight, [(surface, "surfaces"), (line, "lines")]) + + mapper = pipeline.highlight.mapper + colors = mapper.GetInputDataObject(0, 0).GetCellData().GetArray(mapper.GetArrayName()) + assert [ + tuple(component / RGB_MAX for component in colors.GetTuple3(cell)) for cell in (0, 6) + ] == [ + pytest.approx(TEAL, abs=0.5 / RGB_MAX), + pytest.approx(DARK_TEAL, abs=0.5 / RGB_MAX), ] -def test_some_components_are_highlighted_in_orange_after_the_whole_model() -> None: +def test_some_components_take_the_highlight_color_after_the_whole_model() -> None: pipeline = VtkPipeline(vtkXMLMultiBlockDataReader(), vtkCompositePolyDataMapper()) apply_highlight_style(pipeline.highlight.actor, pipeline.highlight.mapper) cube = vtkCubeSource() @@ -102,10 +165,10 @@ def test_some_components_are_highlighted_in_orange_after_the_whole_model() -> No highlight_whole_components(pipeline.highlight, [cube.GetOutput()]) assert not pipeline.highlight.mapper.GetScalarVisibility() - assert pipeline.highlight.actor.GetProperty().GetColor() == pytest.approx(rgb(0xF4, 0x88, 0x30)) + assert pipeline.highlight.actor.GetProperty().GetColor() == pytest.approx(TEAL) -def test_a_picked_cell_is_orange_after_the_whole_model() -> None: +def test_a_picked_cell_takes_the_highlight_color_after_the_whole_model() -> None: pipeline = VtkPipeline(vtkXMLMultiBlockDataReader(), vtkCompositePolyDataMapper()) apply_highlight_style(pipeline.highlight.actor, pipeline.highlight.mapper) cube = vtkCubeSource() diff --git a/tests/test_viewer_protocols.py b/tests/test_viewer_protocols.py index 1198f82e..8c9916e8 100644 --- a/tests/test_viewer_protocols.py +++ b/tests/test_viewer_protocols.py @@ -58,6 +58,28 @@ def test_set_viewer_background_color(server: ServerMonitor) -> None: assert server.compare_image("viewer/set_background_color.jpeg") +def test_set_highlight_colors(server: ServerMonitor) -> None: + rpc = ( + VtkViewerView.viewer_prefix + + VtkViewerView.viewer_schemas_dict["set_highlight_colors"]["rpc"] + ) + orange = {"red": 244, "green": 136, "blue": 48} + auburn = {"red": 71, "green": 37, "blue": 10} + server.call( + rpc, + [ + { + "color": orange, + "outline_color": auburn, + "surfaces_color": orange, + "lines_color": {"red": 30, "green": 30, "blue": 30}, + "corners_color": auburn, + } + ], + ) + assert server.get_result(rpc) == {} + + def test_set_text_style(server: ServerMonitor, dataset_factory: Callable[..., str]) -> None: test_grid_scale(server, dataset_factory) server.call( From 7dff40a4c50b8d95edf948ef47eb4e324c661ba7 Mon Sep 17 00:00:00 2001 From: JulienChampagnol Date: Thu, 3 Dec 2026 11:00:06 +0100 Subject: [PATCH 7/7] fix(highlight): test that loaded highlights take the app colours Co-Authored-By: Claude Opus 5.5 --- .../images/viewer/set_highlight_colors.jpeg | Bin 0 -> 16846 bytes tests/test_viewer_protocols.py | 42 +++++++++--------- 2 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 tests/data/images/viewer/set_highlight_colors.jpeg diff --git a/tests/data/images/viewer/set_highlight_colors.jpeg b/tests/data/images/viewer/set_highlight_colors.jpeg new file mode 100644 index 0000000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Ijg6m7g&|ko%iS*y6iUn6LgV9=lsK~6k{ol9 zAMvOnqDVw!@pxgU_&j6auf0Cf1R*C?1rZm#Vc-DDnJ7(cua4H<`P*#!x#ur{7xjm6 zXlF{xOX|%{Mp0$GCC)_ zN!8tw7Vk8VdonC=gNpzU@=wq>Z{g08cUR+m>OrpoyODg>$RW4 zK&-k!XfnoHW%-4*n&0A*Ym>86-j=N|K9Y0XqjGS^?Is zAiG!Z#X!&iDu630jXxbMN(jtnt~gFeq*q1gej_%Zm5k0f~4j1@D6c zK!V83JIRlzKW}gCB7&)ksndw}V?(E6`(nm9s~FzYN4-67^84a42v;qYfaayX_A~blwwB|nBhmA*EJ3#)F`jE82KZW93+@Esl zKc`2=X31xhesuW*$|DU>NW-4!01nu~xp1kr23DnFK>h(pb}0S;untKHRSVJ_8MZ&5 zeu(|>=-=;uFH)FOUDSa_V5m$2tkI&*4jfny13O)c$fJL^e1=?#YnCJqlw{U7jfFWS zX9^Ka!DElvQY!T$Z7PQ;Y_6$5-yTwrHv7a$xkL`EV-^~Fa4Sy*H%q`HU?EZhBDKnY zOwpAFQyWc&JbiGAx?_Y=K_L9*y;2}+G#Pe`{qd3JIqFVibr{TMi!?Xl_1gur1%Cfz|KOr!jo`(9V45iqUtjxHx;wSe#2xH748RAkM9GV6@*M(MU%a1Q9)i2ed(s|X7J3SLjIq{Be0vfZ);1BQb`0jaHHBMXv* zLT$e-$k9@p0)|%yRO=I{sx7uH+7LBmn1E0)&-D4r0fManU~Z376y-%ENvEv%8T(+N c>)>7L4MW>CL}iW<2GGs=5Hq None: assert server.compare_image("viewer/set_background_color.jpeg") -def test_set_highlight_colors(server: ServerMonitor) -> None: - rpc = ( - VtkViewerView.viewer_prefix - + VtkViewerView.viewer_schemas_dict["set_highlight_colors"]["rpc"] - ) - orange = {"red": 244, "green": 136, "blue": 48} - auburn = {"red": 71, "green": 37, "blue": 10} - server.call( - rpc, - [ - { - "color": orange, - "outline_color": auburn, - "surfaces_color": orange, - "lines_color": {"red": 30, "green": 30, "blue": 30}, - "corners_color": auburn, - } - ], - ) - assert server.get_result(rpc) == {} +BRAND_HIGHLIGHT_COLORS = { + "color": {"red": 244, "green": 136, "blue": 48}, + "outline_color": {"red": 71, "green": 37, "blue": 10}, + "surfaces_color": {"red": 244, "green": 136, "blue": 48}, + "lines_color": {"red": 30, "green": 30, "blue": 30}, + "corners_color": {"red": 71, "green": 37, "blue": 10}, +} +SET_HIGHLIGHT_COLORS = ( + VtkViewerView.viewer_prefix + VtkViewerView.viewer_schemas_dict["set_highlight_colors"]["rpc"] +) +MESH_HIGHLIGHT = VtkMeshView.mesh_prefix + VtkMeshView.mesh_schemas_dict["highlight"]["rpc"] + + +def test_set_highlight_colors_restyles_loaded_data( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + test_register_mesh(server, dataset_factory) + server.call(MESH_HIGHLIGHT, [{"id": mesh_id, "visibility": True}]) + + server.call(SET_HIGHLIGHT_COLORS, [BRAND_HIGHLIGHT_COLORS]) + + assert server.compare_image("viewer/set_highlight_colors.jpeg") def test_set_text_style(server: ServerMonitor, dataset_factory: Callable[..., str]) -> None: