Skip to content

Commit

Permalink
Merge pull request #741 from markotoplak/preprocess-gen
Browse files Browse the repository at this point in the history
[MNT] Support for Preprocess images from the SNOM addon
  • Loading branch information
markotoplak authored Sep 19, 2024
2 parents 08be0e1 + ad9e327 commit 2997066
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
2 changes: 1 addition & 1 deletion orangecontrib/spectroscopy/widgets/owhyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def update_color_schema(self):
return

if self.parent.value_type == 1:
dat = self.data.domain[self.parent.attr_value]
dat = self.parent.data.domain[self.parent.attr_value]
if isinstance(dat, DiscreteVariable):
# use a defined discrete palette
self.img.setLookupTable(dat.colors)
Expand Down
53 changes: 36 additions & 17 deletions orangecontrib/spectroscopy/widgets/owpreprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,29 @@ def progress_interrupt(i: float):
return orig_data, data


class SpectralPreprocess(OWWidget, ConcurrentWidgetMixin, openclass=True):
class SpectraPreviews:

curveplot = settings.SettingProvider(CurvePlot)
curveplot_after = settings.SettingProvider(CurvePlot)

def __init__(self):
self.curveplot = CurvePlot(self)
self.curveplot_after = CurvePlot(self)
self.curveplot.plot.vb.x_padding = 0.005 # pad view so that lines are not hidden
self.curveplot_after.plot.vb.x_padding = 0.005 # pad view so that lines are not hidden

self.curveplot.highlight_changed.connect(
lambda: transfer_highlight(self.curveplot, self.curveplot_after))
self.curveplot_after.highlight_changed.connect(
lambda: transfer_highlight(self.curveplot_after, self.curveplot))

def shutdown(self):
self.curveplot.shutdown()
self.curveplot_after.shutdown()


class GeneralPreprocess(OWWidget, ConcurrentWidgetMixin,
openclass=True):

class Inputs:
data = Input("Data", Orange.data.Table, default=True)
Expand All @@ -437,9 +459,6 @@ class Outputs:
# compatibility for old workflows when reference was not processed
process_reference = settings.Setting(True, schema_only=True)

curveplot = settings.SettingProvider(CurvePlot)
curveplot_after = settings.SettingProvider(CurvePlot)

# draw preview on top of current image
preview_on_image = False

Expand Down Expand Up @@ -534,11 +553,6 @@ def mimeData(indexlist):

splitter = QSplitter(self)
splitter.setOrientation(Qt.Vertical)
self.curveplot = CurvePlot(self)
self.curveplot_after = CurvePlot(self)
self.curveplot.plot.vb.x_padding = 0.005 # pad view so that lines are not hidden
self.curveplot_after.plot.vb.x_padding = 0.005 # pad view so that lines are not hidden

splitter.addWidget(self.curveplot)
splitter.addWidget(self.curveplot_after)
self.mainArea.layout().addWidget(splitter)
Expand All @@ -560,11 +574,6 @@ def overlay(widget):
self.curveplot_info = overlay(self.curveplot)
self.curveplot_after_info = overlay(self.curveplot_after)

self.curveplot.highlight_changed.connect(
lambda: transfer_highlight(self.curveplot, self.curveplot_after))
self.curveplot_after.highlight_changed.connect(
lambda: transfer_highlight(self.curveplot_after, self.curveplot))

if not self.preview_on_image:
self.curveplot_after.show()
else:
Expand All @@ -575,7 +584,7 @@ def overlay(widget):

self.flow_view.installEventFilter(self)

box = gui.widgetBox(self.controlArea, "Preview")
self.preview_settings_box = box = gui.widgetBox(self.controlArea, "Preview")
self.final_preview_toggle = False
if not self.preview_on_image:
self.final_preview = gui.button(
Expand Down Expand Up @@ -815,8 +824,6 @@ def storeSpecificSettings(self):
def onDeleteWidget(self):
self.shutdown()
self.preview_runner.shutdown()
self.curveplot.shutdown()
self.curveplot_after.shutdown()
self.data = None
self.set_model(None)
super().onDeleteWidget()
Expand Down Expand Up @@ -871,6 +878,18 @@ def migrate_settings(cls, settings_, version):
cls.migrate_preprocessors(settings_["storedsettings"]["preprocessors"], version)


class SpectralPreprocess(GeneralPreprocess,
SpectraPreviews, openclass=True):

def __init__(self):
SpectraPreviews.__init__(self)
super().__init__()

def onDeleteWidget(self):
super().onDeleteWidget()
SpectraPreviews.shutdown(self)


class SpectralPreprocessReference(SpectralPreprocess, openclass=True):

class Inputs(SpectralPreprocess.Inputs):
Expand Down

0 comments on commit 2997066

Please sign in to comment.