Skip to content

Commit

Permalink
Revert ":sparkles: Add option compatibility between Region visual and…
Browse files Browse the repository at this point in the history
… Aladin Lite overlay options"

This reverts commit 3876ce3.
  • Loading branch information
Xen0Xys authored and ManonMarchand committed May 27, 2024
1 parent 4f5086c commit 70800b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 31 deletions.
23 changes: 6 additions & 17 deletions js/models/message_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,25 @@ export default class MessageHandler {
handleAddOverlay(msg) {
const infos = msg["infos"];
const options = convertOptionNamesToCamelCase(msg["options"] || {});
// Define default color for graphic overlay
const overlay_color = options["color"] || options["fillColor"] || "red";
const overlay = A.graphicOverlay({ color: overlay_color });
const overlay = A.graphicOverlay(options);
this.aladin.addOverlay(overlay);
switch (msg["region_type"]) {
case "stcs":
overlay.add(A.footprintsFromSTCS(infos.stcs, options));
overlay.addFootprints(A.footprintsFromSTCS(infos.stcs));
break;
case "circle":
overlay.add(A.circle(infos.ra, infos.dec, infos.radius, options));
overlay.add(A.circle(infos.ra, infos.dec, infos.radius));
break;
case "ellipse":
overlay.add(
A.ellipse(
infos.ra,
infos.dec,
infos.a,
infos.b,
infos.theta,
options,
),
A.ellipse(infos.ra, infos.dec, infos.a, infos.b, infos.theta),
);
break;
case "line":
overlay.add(
A.line(infos.ra1, infos.dec1, infos.ra2, infos.dec2, options),
);
overlay.add(A.line(infos.ra1, infos.dec1, infos.ra2, infos.dec2));
break;
case "polygon":
overlay.add(A.polygon(infos.vertices, options));
overlay.add(A.polygon(infos.vertices));
break;
}
}
Expand Down
22 changes: 8 additions & 14 deletions src/ipyaladin/aladin.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,20 +395,14 @@ def add_overlay(

# Visual mapping to Aladin Lite overlay options
if isinstance(region, Region):
# Check if overlay options are empty
if overlay_options and region.visual:
warnings.warn(
"region visuals will be used instead of provided overlay_options",
stacklevel=2,
)
if region.visual:
overlay_options = dict(region.visual)
if "linewidth" in overlay_options:
overlay_options["line_width"] = overlay_options.pop("linewidth")
if "color" in overlay_options:
overlay_options["fill_color"] = overlay_options.pop("color")
if "edgecolor" in overlay_options:
overlay_options["color"] = overlay_options.pop("edgecolor")
visual = dict(region.visual)
if "linewidth" in visual:
visual["line_width"] = visual.pop("linewidth")
if "facecolor" in visual:
visual["fill_color"] = visual.pop("facecolor")
if "edgecolor" in visual:
visual["color"] = visual.pop("edgecolor")
overlay_options = {**overlay_options, **region.visual}

# Define behavior for each region type
region_infos = RegionInfos(region)
Expand Down

0 comments on commit 70800b5

Please sign in to comment.