Skip to content

Commit 7c914e5

Browse files
committed
upstream changes from dev merges
1 parent c06b93e commit 7c914e5

2 files changed

Lines changed: 23 additions & 14 deletions

File tree

js/models/event_handler.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export default class EventHandler {
4949
/**
5050
* Updates the view center rotation in the model.
5151
* WARNING: This method doesn't call model.save_changes()!
52+
*
53+
* The python rotation traitlet is updated when:
54+
* - the user drag the view (positionChanged occuring).
55+
* - the user dbl click inside the view which resets the rotation to 0.
5256
*/
5357
updateRotation() {
5458
if (!this.isLastDiv()) return;
@@ -96,6 +100,9 @@ export default class EventHandler {
96100
jsTargetLock.lock();
97101
const raDec = [position.ra, position.dec];
98102
this.updateWCS();
103+
// When dragging the view, north to east position angle might changes because
104+
// the spherical rotation does not keep the north pole up.
105+
this.updateRotation();
99106
this.model.set("_target", `${raDec[0]} ${raDec[1]}`);
100107
this.model.save_changes();
101108
});
@@ -128,6 +135,12 @@ export default class EventHandler {
128135
this.model.save_changes();
129136
});
130137

138+
// A better way would be to listen to a "dblclick" event through aladin.on
139+
this.aladin.view.catalogCanvas.addEventListener("dblclick", (e) => {
140+
this.updateRotation();
141+
this.model.save_changes();
142+
});
143+
131144
this.model.on("change:_fov", () => {
132145
if (jsFovLock.locked) {
133146
jsFovLock.unlock();
@@ -144,12 +157,17 @@ export default class EventHandler {
144157
// Update WCS and FoV only if this is the last div
145158
this.updateWCS();
146159
this.update2AxisFoV();
160+
if (!this.isLastDiv()) return;
147161
this.model.save_changes();
148162
});
149163

150164
/* Rotation control */
151165
this.model.on("change:_rotation", () => {
152-
this.updateRotation(this.model.get("_rotation"), this.aladinDiv);
166+
// Get the rotation value from the python
167+
let rotation = this.model.get("_rotation");
168+
// And propagate it to Aladin Lite
169+
this.aladin.setRotation(rotation);
170+
153171
// Update WCS and FoV only if this is the last div
154172
this.updateWCS();
155173
this.update2AxisFoV();
@@ -202,15 +220,10 @@ export default class EventHandler {
202220
}
203221
});
204222

205-
this.aladin.on("rotationChanged", (object) => {
206-
if (object["data"] !== undefined) {
207-
this.model.send({
208-
event_type: "rotation_changed",
209-
content: {
210-
rotation: object["rotation"],
211-
},
212-
});
213-
}
223+
this.aladin.on("rotationChanged", (_) => {
224+
this.updateRotation();
225+
if (!this.isLastDiv()) return;
226+
this.model.save_changes();
214227
});
215228

216229
this.aladin.on("objectClicked", (clicked) => {
@@ -302,7 +315,6 @@ export default class EventHandler {
302315
this.eventHandlers = {
303316
add_marker: this.messageHandler.handleAddMarker,
304317
change_fov: this.messageHandler.handleChangeFoV,
305-
change_rotation: this.messageHandler.handleChangeRotation,
306318
goto_ra_dec: this.messageHandler.handleGotoRaDec,
307319
save_view_as_image: this.messageHandler.handleSaveViewAsImage,
308320
add_fits: this.messageHandler.handleAddFits,

src/ipyaladin/widget.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,7 @@ def rotation(self, rotation: Union[float, Angle]) -> None:
345345
rotation = rotation.deg
346346
if np.isclose(self._rotation, rotation):
347347
return
348-
self._wcs = {}
349-
self._fov_xy = {}
350348
self._rotation = rotation
351-
self.send({"event_name": "change_rotation", "rotation": rotation})
352349

353350
@property
354351
def wcs(self) -> WCS:

0 commit comments

Comments
 (0)