@@ -28,7 +28,8 @@ class ImageViewer:
2828 stretch_options : tuple = ("linear" , "log" , "sqrt" )
2929 autocut_options : tuple = ("minmax" , "zscale" , "asinh" , "percentile" , "histogram" )
3030 _cursor : str = ImageViewerInterface .ALLOWED_CURSOR_LOCATIONS [0 ]
31- marker : Any = "marker"
31+ _markers : dict [str , dict ] = field (default_factory = dict )
32+ _default_marker_style : dict [str , Any ] = field (default_factory = dict )
3233 _cuts : str | tuple [float , float ] = (0 , 1 )
3334 _stretch : str = "linear"
3435 # viewer: Any
@@ -37,12 +38,15 @@ class ImageViewer:
3738 ALLOWED_CURSOR_LOCATIONS : tuple = ImageViewerInterface .ALLOWED_CURSOR_LOCATIONS
3839
3940 # some internal variable for keeping track of viewer state
40- _interactive_marker_name : str = ""
41- _previous_marker : Any = ""
42- _markers : dict [str , Table ] = field (default_factory = dict )
4341 _wcs : WCS | None = None
4442 _center : tuple [float , float ] = (0.0 , 0.0 )
4543
44+ def __post_init__ (self ):
45+ # This is a dictionary of marker sets. The keys are the names of the
46+ # marker sets, and the values are the tables containing the markers.
47+ self ._default_marker_style = dict (shape = "circle" , color = "yellow" , size = 10 )
48+ self ._markers [None ] = self ._default_marker_style .copy ()
49+
4650 @property
4751 def stretch (self ) -> str :
4852 return self ._stretch
@@ -82,6 +86,74 @@ def cursor(self, value: str) -> None:
8286
8387 # The methods, grouped loosely by purpose
8488
89+ def get_catalog_style (self , catalog_label = None ) -> dict [str , dict [str , Any ]]:
90+ """
91+ Get the style for the catalog.
92+
93+ Parameters
94+ ----------
95+ catalog_label : str, optional
96+ The label of the catalog. Default is ``None``.
97+
98+ Returns
99+ -------
100+ dict
101+ The style for the catalog.
102+ """
103+ user_keys = list (set (self ._markers .keys ()) - {None })
104+ if catalog_label is None :
105+ match len (user_keys ):
106+ case 0 :
107+ # No user-defined styles, so return the default style
108+ catalog_label = None
109+ case 1 :
110+ # The user must have set a style, so return that instead of
111+ # the default style, which live in the key None.
112+ catalog_label = user_keys [0 ]
113+ case _:
114+ raise ValueError (
115+ "Multiple catalog styles defined. Please specify a catalog_label to get the style."
116+ )
117+
118+ style = self ._markers [catalog_label ]
119+ style ["catalog_label" ] = catalog_label
120+ return style
121+
122+ def set_catalog_style (
123+ self ,
124+ catalog_label : str | None = None ,
125+ shape : str = "" ,
126+ color : str = "" ,
127+ size : float = 0 ,
128+ ** kwargs
129+ ) -> None :
130+ """
131+ Set the style for the catalog.
132+
133+ Parameters
134+ ----------
135+ catalog_label : str, optional
136+ The label of the catalog.
137+ shape : str, optional
138+ The shape of the markers.
139+ color : str, optional
140+ The color of the markers.
141+ size : float, optional
142+ The size of the markers.
143+ **kwargs
144+ Additional keyword arguments to pass to the marker style.
145+ """
146+ shape = shape if shape else self ._default_marker_style ["shape" ]
147+ color = color if color else self ._default_marker_style ["color" ]
148+ size = size if size else self ._default_marker_style ["size" ]
149+
150+ self ._markers [catalog_label ] = {
151+ "shape" : shape ,
152+ "color" : color ,
153+ "size" : size ,
154+ ** kwargs ,
155+ }
156+
85157 # Methods for loading data
86158 def load_fits (self , file : str | os .PathLike ) -> None :
87159 """
0 commit comments