Skip to content

Commit

Permalink
rename args and update docstring for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Nov 19, 2024
1 parent e22aa08 commit cd851e4
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions jdaviz/configs/imviz/plugins/orientation/orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,61 +535,65 @@ def _on_viewer_change(self, msg={}):
if ref_data.label in self.orientation.choices:
self.orientation.selected = ref_data.label

def _create_north_up_east_left(self, label="North-up, East-left", set_on_create=False,
def _create_north_up_east_left(self, label="North-up, East-left", set_as_orientation=False,
from_ui=False):
if label not in self.orientation.choices:
degn = self._get_wcs_angles()[-3]
self._add_orientation(rotation_angle=degn, east_left=True,
label=label, set_on_create=set_on_create,
label=label, set_on_create=set_as_orientation,
from_ui=from_ui)
elif set_on_create:
elif set_as_orientation:
self.orientation.selected = label

def create_north_up_east_left(self, label="North-up, East-left",
set_on_create=True):
set_as_orientation=True):
"""
Set the rotation angle and flip to achieve North up and East left
according to the reference image WCS.
Parameters
----------
label : str
Data label for this new orientation layer.
set_on_create : bool
Whether to set the created option as the current orientation.
Data label for the orientation layer. If already exists, will be set as the
current orientation layer according to ``set_as_orientation``. Otherwise,
a new layer will be created with this label.
set_as_orientation : bool
Whether to set as the current orientation.
"""
self._create_north_up_east_left(label=label, set_on_create=set_on_create)
self._create_north_up_east_left(label=label, set_as_orientation=set_as_orientation)

def _create_north_up_east_right(self, label="North-up, East-right", set_on_create=False,
def _create_north_up_east_right(self, label="North-up, East-right", set_as_orientation=False,
from_ui=False):
if label not in self.orientation.choices:
degn = self._get_wcs_angles()[-3]
self._add_orientation(rotation_angle=180 - degn, east_left=False,
label=label, set_on_create=set_on_create,
label=label, set_on_create=set_as_orientation,
from_ui=from_ui)
elif set_on_create:
elif set_as_orientation:
self.orientation.selected = label

def create_north_up_east_right(self, label="North-up, East-right",
set_on_create=True):
set_as_orientation=True):
"""
Set the rotation angle and flip to achieve North up and East right
according to the reference image WCS.
Parameters
----------
label : str
Data label for this new orientation layer.
set_on_create : bool
Whether to set the created option as the current orientation.
Data label for the orientation layer. If already exists, will be set as the
current orientation layer according to ``set_as_orientation``. Otherwise,
a new layer will be created with this label.
set_as_orientation : bool
Whether to set as the current orientation.
"""
self._create_north_up_east_right(label=label, set_on_create=set_on_create)
self._create_north_up_east_right(label=label, set_as_orientation=set_as_orientation)

def vue_select_north_up_east_left(self, *args, **kwargs):
self._create_north_up_east_left(set_on_create=True, from_ui=True)
self._create_north_up_east_left(set_as_orientation=True, from_ui=True)

def vue_select_north_up_east_right(self, *args, **kwargs):
self._create_north_up_east_right(set_on_create=True, from_ui=True)
self._create_north_up_east_right(set_as_orientation=True, from_ui=True)

def vue_select_default_orientation(self, *args, **kwargs):
self.orientation.selected = base_wcs_layer_label
Expand Down

0 comments on commit cd851e4

Please sign in to comment.