Added a workaround to use kpc as a valid unit and make sure non-ICRS frames work properly in 3D mode. In addition, set the far_side_visible option appropriately depending on the viewing mode.

This commit is contained in:
Thomas Robitaille 2019-01-16 09:52:04 +00:00
Родитель 8bcb7154fd
Коммит 415a805361
2 изменённых файлов: 26 добавлений и 7 удалений

Просмотреть файл

@ -66,7 +66,12 @@ class WWTLayer(LayerArtist):
self._coords = [], [] self._coords = [], []
force = True force = True
if force or 'mode' in kwargs or 'frame' in kwargs or 'lon_att' in kwargs or 'lat_att' in kwargs or 'alt_att' in kwargs: # FIXME: kpc isn't yet a valid unit in WWT/PyWWT:
# https://github.com/WorldWideTelescope/wwt-web-client/pull/197
# for now we set unit to pc and scale values accordingly, so if the
# unit changes we need to refresh the data just in case
if force or 'mode' in kwargs or 'frame' in kwargs or 'lon_att' in kwargs or 'lat_att' in kwargs or 'alt_att' in kwargs or 'alt_unit' in kwargs:
try: try:
lon = self.layer[self._viewer_state.lon_att] lon = self.layer[self._viewer_state.lon_att]
@ -94,16 +99,20 @@ class WWTLayer(LayerArtist):
if len(lon) > 0: if len(lon) > 0:
if self._viewer_state.mode == 'Sky': if self._viewer_state.mode in MODES_3D:
ref_frame = 'Sky'
coord = SkyCoord(lon, lat, unit=u.deg, frame=self._viewer_state.frame.lower()).icrs coord = SkyCoord(lon, lat, unit=u.deg, frame=self._viewer_state.frame.lower()).icrs
lon = coord.spherical.lon.degree lon = coord.spherical.lon.degree
lat = coord.spherical.lat.degree lat = coord.spherical.lat.degree
if self._viewer_state.mode in MODES_3D:
ref_frame = 'Sky'
else: else:
ref_frame = self._viewer_state.mode ref_frame = self._viewer_state.mode
# FIXME: kpc isn't yet a valid unit in WWT/PyWWT:
# https://github.com/WorldWideTelescope/wwt-web-client/pull/197
# for now we set unit to pc and scale values accordingly
if self._viewer_state.alt_unit == 'kpc':
alt = alt * 1000
tab = Table() tab = Table()
tab['lon'] = lon * u.degree tab['lon'] = lon * u.degree
tab['lat'] = lat * u.degree tab['lat'] = lat * u.degree
@ -117,13 +126,23 @@ class WWTLayer(LayerArtist):
self.wwt_layer = self.wwt_client.layers.add_data_layer(tab, frame=ref_frame, self.wwt_layer = self.wwt_client.layers.add_data_layer(tab, frame=ref_frame,
lon_att='lon', lat_att='lat', **alt_att) lon_att='lon', lat_att='lat', **alt_att)
self.wwt_layer.far_side_visible = self._viewer_state.mode in MODES_3D
self._coords = lon, lat self._coords = lon, lat
force = True
else: else:
return return
if force or 'alt_unit' in kwargs: if force or 'alt_unit' in kwargs:
self.wwt_layer.alt_unit = self._viewer_state.alt_unit # FIXME: kpc isn't yet a valid unit in WWT/PyWWT:
# https://github.com/WorldWideTelescope/wwt-web-client/pull/197
# for now we set unit to pc and scale values accordingly
if self._viewer_state.alt_unit == 'kpc':
self.wwt_layer.alt_unit = u.pc
else:
self.wwt_layer.alt_unit = self._viewer_state.alt_unit
if force or 'alt_type' in kwargs: if force or 'alt_type' in kwargs:
self.wwt_layer.alt_type = self._viewer_state.alt_type.lower() self.wwt_layer.alt_type = self._viewer_state.alt_type.lower()

Просмотреть файл

@ -17,7 +17,7 @@ MODES_BODIES = ['Sun', 'Mercury', 'Venus', 'Earth', 'Moon', 'Mars',
MODES_3D = ['Solar System', 'Milky Way', 'Universe'] MODES_3D = ['Solar System', 'Milky Way', 'Universe']
ALT_UNITS = [u.m, u.km, u.AU, u.lyr, u.pc, u.Mpc, ALT_UNITS = [u.m, u.km, u.AU, u.lyr, u.pc, u.kpc, u.Mpc,
u.imperial.ft, u.imperial.inch, u.imperial.mi] u.imperial.ft, u.imperial.inch, u.imperial.mi]
ALT_TYPES = ['Altitude', 'Depth', 'Distance'] ALT_TYPES = ['Altitude', 'Depth', 'Distance']