Skip to content

Commit

Permalink
🎨 Define custom SupportedRegion type for add_overlay function
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys authored and ManonMarchand committed May 27, 2024
1 parent f0a854b commit 44b0acd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
2 changes: 0 additions & 2 deletions js/models/message_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ export default class MessageHandler {
msg["graphic_options"] || {},
);
if (!graphic_options["color"]) graphic_options["color"] = "red";
console.log(graphic_options);
const overlay = A.graphicOverlay(graphic_options);
this.aladin.addOverlay(overlay);
console.log(regions);
for (const region of regions) {
const infos = region["infos"];
switch (region["region_type"]) {
Expand Down
40 changes: 21 additions & 19 deletions src/ipyaladin/aladin.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@

from .coordinate_parser import parse_coordinate_string

SupportedRegion = Union[
typing.List[
Union[
str,
CircleSkyRegion,
EllipseSkyRegion,
LineSkyRegion,
PolygonSkyRegion,
RectangleSkyRegion,
]
],
str,
CircleSkyRegion,
EllipseSkyRegion,
LineSkyRegion,
PolygonSkyRegion,
RectangleSkyRegion,
Regions,
]


class Aladin(anywidget.AnyWidget):
"""Aladin Lite widget.
Expand Down Expand Up @@ -357,25 +377,7 @@ def add_table(self, table: Union[QTable, Table], **table_options: any) -> None:

def add_overlay(
self,
region: Union[
typing.List[
Union[
str,
CircleSkyRegion,
EllipseSkyRegion,
LineSkyRegion,
PolygonSkyRegion,
RectangleSkyRegion,
]
],
str,
CircleSkyRegion,
EllipseSkyRegion,
LineSkyRegion,
PolygonSkyRegion,
RectangleSkyRegion,
Regions,
],
region: SupportedRegion,
**graphic_options: any,
) -> None:
"""Add an overlay layer to the Aladin Lite widget.
Expand Down

0 comments on commit 44b0acd

Please sign in to comment.