Skip to content

Commit

Permalink
simplify stretch_curve_visible switch
Browse files Browse the repository at this point in the history
* to use traitlet directly since it does not interact with any glue state objects
  • Loading branch information
kecnry committed Aug 30, 2023
1 parent 5237237 commit 866eed0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
15 changes: 4 additions & 11 deletions jdaviz/configs/default/plugins/plot_options/plot_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class PlotOptions(PluginTemplateMixin):
limits instead of all data within the layer; not exposed for Specviz.
* ``stretch_hist_nbins`` : number of bins to use in creating the histogram; not exposed
for Specviz.
* ``stretch_curve_visible`` : (:class:`~jdaviz.core.template_mixin.PlotOptionsSyncState`):
* ``stretch_curve_visible`` : bool
whether the stretch histogram's colormap "curve" is visible; not exposed for Specviz.
* ``image_visible`` (:class:`~jdaviz.core.template_mixin.PlotOptionsSyncState`):
whether the image bitmap is visible; not exposed for Specviz.
Expand Down Expand Up @@ -208,8 +208,7 @@ class PlotOptions(PluginTemplateMixin):
stretch_hist_downsampled = List([0, 0]).tag(sync=True)
stretch_histogram_widget = Unicode().tag(sync=True)

stretch_curve_visible_value = Bool().tag(sync=True)
stretch_curve_visible_sync = Dict().tag(sync=True)
stretch_curve_visible = Bool().tag(sync=True)

subset_visible_value = Bool().tag(sync=True)
subset_visible_sync = Dict().tag(sync=True)
Expand Down Expand Up @@ -395,12 +394,6 @@ def state_attr_for_line_visible(state):
'stretch_vmax_value', 'stretch_vmax_sync',
state_filter=is_image)

self.stretch_curve_visible = PlotOptionsSyncState(self, self.viewer, self.layer,
'stretch_curve_visible',
'stretch_curve_visible_value',
'stretch_curve_visible_sync',
state_filter=is_image)

self.stretch_histogram = Plot(self)
self.stretch_histogram.add_bins('histogram', color='gray')
self.stretch_histogram.add_line('vmin', x=[0, 0], y=[0, 1], ynorm=True, color='#c75d2c')
Expand Down Expand Up @@ -670,7 +663,7 @@ def _update_stretch_histogram(self, msg={}):

@observe('stretch_vmin_value', 'stretch_vmax_value', 'layer_selected',
'stretch_hist_nbins', 'image_contrast_value', 'image_bias_value',
'stretch_curve_visible_value')
'stretch_curve_visible')
def _update_stretch_curve(self, msg=None):
mark_label_prefix = "stretch_curve: "

Expand All @@ -679,7 +672,7 @@ def _update_stretch_curve(self, msg=None):
# or the stretch histogram hasn't been initialized:
return

if not self.stretch_curve_visible_value:
if not self.stretch_curve_visible:
# clear marks if curve is not visible:
for existing_mark_label, mark in self.stretch_histogram.marks.items():
if existing_mark_label.startswith(mark_label_prefix):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
</v-row>
<v-row>
<v-switch
v-model="stretch_curve_visible_value"
v-model="stretch_curve_visible"
class="hide-input"
label="Show stretch function curve"
style="z-index: 1"
Expand Down

0 comments on commit 866eed0

Please # to comment.