Skip to content

Commit 2158bb9

Browse files
committed
Beat head on wall of catalog style stuff
1 parent c9d9905 commit 2158bb9

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

src/astro_image_display_api/dummy_viewer.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class ImageViewer:
3939
_cursor: str = ImageViewerInterface.ALLOWED_CURSOR_LOCATIONS[0]
4040
# marker style will be stored in catalog table metadata
4141
_catalogs: dict[str, CatalogInfo] = field(default_factory=dict)
42-
_default_marker_style: dict[str, Any] = field(default_factory=dict)
4342
_cuts: str | tuple[float, float] = (0, 1)
4443
_stretch: str = "linear"
4544
# viewer: Any
@@ -54,10 +53,9 @@ class ImageViewer:
5453
def __post_init__(self):
5554
# This is a dictionary of marker sets. The keys are the names of the
5655
# marker sets, and the values are the tables containing the markers.
57-
self._default_marker_style = dict(shape="circle", color="yellow", size=10)
5856
self._catalogs = defaultdict(CatalogInfo)
5957
self._catalogs[None].data = None
60-
self._catalogs[None].style = self._default_marker_style.copy()
58+
self._catalogs[None].style = self._default_catalog_style.copy()
6159

6260
def _user_catalog_labels(self) -> list[str]:
6361
"""
@@ -89,6 +87,17 @@ def _resolve_catalog_label(self, catalog_label: str | None) -> str:
8987

9088
return catalog_label
9189

90+
@property
91+
def _default_catalog_style(self) -> dict[str, Any]:
92+
"""
93+
The default style for the catalog markers.
94+
"""
95+
return {
96+
"shape": "circle",
97+
"color": "red",
98+
"size": 5,
99+
}
100+
92101
@property
93102
def stretch(self) -> str:
94103
return self._stretch
@@ -128,7 +137,7 @@ def cursor(self, value: str) -> None:
128137

129138
# The methods, grouped loosely by purpose
130139

131-
def get_catalog_style(self, catalog_label=None) -> dict[str, dict[str, Any]]:
140+
def get_catalog_style(self, catalog_label=None) -> dict[str, Any]:
132141
"""
133142
Get the style for the catalog.
134143
@@ -151,9 +160,9 @@ def get_catalog_style(self, catalog_label=None) -> dict[str, dict[str, Any]]:
151160
def set_catalog_style(
152161
self,
153162
catalog_label: str | None = None,
154-
shape: str = "",
155-
color: str = "",
156-
size: float = 0,
163+
shape: str = "circle",
164+
color: str = "red",
165+
size: float = 5,
157166
**kwargs
158167
) -> None:
159168
"""
@@ -172,9 +181,9 @@ def set_catalog_style(
172181
**kwargs
173182
Additional keyword arguments to pass to the marker style.
174183
"""
175-
shape = shape if shape else self._default_marker_style["shape"]
176-
color = color if color else self._default_marker_style["color"]
177-
size = size if size else self._default_marker_style["size"]
184+
shape = shape
185+
color = color
186+
size = size
178187

179188
catalog_label = self._resolve_catalog_label(catalog_label)
180189

@@ -305,11 +314,12 @@ def load_catalog(self, table: Table, x_colname: str = 'x', y_colname: str = 'y',
305314
self._catalogs[catalog_label].data = vstack([old_table, to_add])
306315
else:
307316
self._catalogs[catalog_label].data = to_add
308-
317+
breakpoint()
309318
if catalog_style is None:
310-
catalog_style = self._default_marker_style.copy()
311-
312-
self._catalogs[catalog_label].style = catalog_style
319+
if self._catalogs[catalog_label].style is None:
320+
catalog_style = self._default_catalog_style.copy()
321+
else:
322+
self._catalogs[catalog_label].style = catalog_style
313323

314324
load_catalog.__doc__ = ImageViewerInterface.load_catalog.__doc__
315325

0 commit comments

Comments
 (0)