@@ -143,6 +143,7 @@ class Aladin(anywidget.AnyWidget):
143143 # Options for the view initialization
144144 _init_options = traitlets .Dict ().tag (sync = True )
145145 _height = Int (400 ).tag (sync = True , init_option = True )
146+ _rotation = Float (0 ).tag (sync = True , init_option = True )
146147 _target = Unicode (
147148 "0 0" ,
148149 help = "A private trait that stores the current target of the widget in a string."
@@ -220,8 +221,12 @@ def __init__(self, *args: any, **init_options: any) -> None:
220221 # https://github.com/jupyter-widgets/ipywidgets/blob/main/python/ipywidgets/ipywidgets/widgets/domwidget.py
221222 for key in ["layout" , "tabbable" , "tooltip" ]:
222223 init_options .pop (key , None )
224+ init_options ["north_pole_orientation" ] = init_options .get (
225+ "north_pole_orientation" , init_options .get ("rotation" , 0 )
226+ )
223227 # some init options are properties here
224228 self .height = init_options .get ("height" , self ._height )
229+ self .rotation = init_options .get ("north_pole_orientation" , self ._rotation )
225230 self .target = init_options .get ("target" , self ._target )
226231 self .fov = init_options .get ("fov" , self ._fov )
227232 # apply different default options from Aladin-Lite
@@ -294,6 +299,38 @@ def height(self, height: int) -> None:
294299 self ._fov_xy = {}
295300 self ._height = height
296301
302+ @property
303+ def rotation (self ) -> float :
304+ """The center rotation of the widget.
305+
306+ This is the view center to north pole angle in degrees.
307+ This is equivalent to getting the 3rd Euler angle.
308+ Positive angles rotates the view in the counter clockwise
309+ order (or towards the east).
310+
311+ It can be set with either a float number in degrees
312+ or an astropy.coordinates.Angle object.
313+
314+ Returns
315+ -------
316+ astropy.coordinates.Angle
317+ An astropy.coordinates.Angle object representing the center
318+ rotation of the widget in degrees. The default rotation is
319+ 0 degrees.
320+ """
321+ return Angle (self ._rotation , unit = "deg" )
322+
323+ @rotation .setter
324+ def rotation (self , rotation : Union [float , Angle ]) -> None :
325+ if isinstance (rotation , Angle ):
326+ rotation = rotation .deg
327+ if np .isclose (self ._rotation , rotation ):
328+ return
329+ self ._wcs = {}
330+ self ._fov_xy = {}
331+ self ._rotation = rotation
332+ self .send ({"event_name" : "change_rotation" , "rotation" : rotation })
333+
297334 @property
298335 def wcs (self ) -> WCS :
299336 """The world coordinate system corresponding to the current view of ipyaladin.
0 commit comments