diff --git a/pywwt/layers.py b/pywwt/layers.py index 5fec8aae..7a43926f 100644 --- a/pywwt/layers.py +++ b/pywwt/layers.py @@ -1371,11 +1371,20 @@ def _serialize_state(self): state["settings"][wwt_name] = value if self._uniform_color(): - state["settings"]["_colorMap"] = 0 + state["settings"]["colorMap"] = 0 state["settings"]["colorMapColumn"] = -1 + elif self.cmap.name.lower() in VALID_COLORMAPS: + state["settings"]["colorMap"] = 3 + state["settings"]["colorMapperName"] = self.cmap.name + state["settings"]["dynamicColor"] = True + state["settings"]["normalizeColorMap"] = True + state["settings"]["normalizeColorMapMin"] = self.cmap_vmin + state["settings"]["normalizeColorMapMax"] = self.cmap_vmax + state["settings"]["colorMapColumn"] = self.cmap_att else: - state["settings"]["_colorMap"] = 3 + state["settings"]["colorMap"] = 3 state["settings"]["colorMapColumn"] = CMAP_COLUMN_NAME + state["settings"]["dynamicColor"] = False if self._uniform_size(): state["settings"]["sizeColumn"] = -1 diff --git a/pywwt/tests/test_serialization.py b/pywwt/tests/test_serialization.py index d3dfb185..13a81c23 100644 --- a/pywwt/tests/test_serialization.py +++ b/pywwt/tests/test_serialization.py @@ -1,7 +1,7 @@ import pytest from ..core import BaseWWTWidget -from ..layers import SIZE_COLUMN_NAME, CMAP_COLUMN_NAME +from ..layers import SIZE_COLUMN_NAME import numpy as np import os @@ -456,7 +456,7 @@ def test_table_setting_serialization(): 'markerScale': 'world', 'showFarSide': True, 'sizeColumn': -1, - '_colorMap': 0, + 'colorMap': 0, 'colorMapColumn': -1, 'xAxisColumn': '', 'yAxisColumn': '', @@ -472,9 +472,14 @@ def test_table_setting_serialization(): expected_settings['sizeColumn'] = SIZE_COLUMN_NAME expected_settings['pointScaleType'] = 0 - expected_settings['colorMapColumn'] = CMAP_COLUMN_NAME - expected_settings['_colorMap'] = 3 + expected_settings['colorMapColumn'] = layer.cmap_att + expected_settings['colorMap'] = 3 expected_settings['altUnit'] = 'megaParsecs' + expected_settings['dynamicColor'] = True + expected_settings['colorMapperName'] = 'viridis' + expected_settings["normalizeColorMap"] = True + expected_settings["normalizeColorMapMin"] = layer.cmap_vmin + expected_settings["normalizeColorMapMax"] = layer.cmap_vmax assert widget.quick_serialize()['layers'][0]['settings'] == expected_settings