Skip to content

Commit

Permalink
ImagePlot: Do not require axes to be settings
Browse files Browse the repository at this point in the history
  • Loading branch information
markotoplak committed Sep 24, 2024
1 parent 2997066 commit be77297
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions orangecontrib/spectroscopy/widgets/owhyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,31 @@ def color_palette_model(palettes, iconsize=QSize(64, 16)):
return model


class AxesSettingsMixin:

def __init__(self):
self.xy_model = DomainModel(DomainModel.METAS | DomainModel.CLASSES,
valid_types=DomainModel.PRIMITIVE)

def setup_axes_settings_box(self):
box = gui.vBox(self)

common_options = {
"labelWidth": 50,
"orientation": Qt.Horizontal,
"sendSelectedValue": True
}

cb_attr_x = gui.comboBox(
box, self, "attr_x", label="Axis x:", callback=self.update_attr,
model=self.xy_model, **common_options)
gui.comboBox(
box, self, "attr_y", label="Axis y:", callback=self.update_attr,
model=self.xy_model, **common_options)
box.setFocusProxy(cb_attr_x)
return box


class ImageColorSettingMixin:
threshold_low = Setting(0.0, schema_only=True)
threshold_high = Setting(1.0, schema_only=True)
Expand Down Expand Up @@ -622,12 +647,10 @@ def legend_items(self):
return []


class ImagePlot(QWidget, OWComponent, SelectionGroupMixin,
class BasicImagePlot(QWidget, OWComponent, SelectionGroupMixin, AxesSettingsMixin,
ImageColorSettingMixin, ImageRGBSettingMixin,
ImageZoomMixin, ConcurrentMixin):

attr_x = ContextSetting(None, exclude_attributes=True)
attr_y = ContextSetting(None, exclude_attributes=True)
gamma = Setting(0)

selection_changed = Signal()
Expand All @@ -637,6 +660,7 @@ def __init__(self, parent):
QWidget.__init__(self)
OWComponent.__init__(self, parent)
SelectionGroupMixin.__init__(self)
AxesSettingsMixin.__init__(self)
ImageColorSettingMixin.__init__(self)
ImageZoomMixin.__init__(self)
ConcurrentMixin.__init__(self)
Expand Down Expand Up @@ -724,26 +748,16 @@ def __init__(self, parent):
for a in actions:
a.setShortcutVisibleInContextMenu(True)

common_options = dict(
labelWidth=50, orientation=Qt.Horizontal, sendSelectedValue=True)

choose_xy = QWidgetAction(self)
box = gui.vBox(self)
box.setContentsMargins(10, 0, 10, 0)
box.setFocusPolicy(Qt.TabFocus)
self.xy_model = DomainModel(DomainModel.METAS | DomainModel.CLASSES,
valid_types=DomainModel.PRIMITIVE)
self.cb_attr_x = gui.comboBox(
box, self, "attr_x", label="Axis x:", callback=self.update_attr,
model=self.xy_model, **common_options)
self.cb_attr_y = gui.comboBox(
box, self, "attr_y", label="Axis y:", callback=self.update_attr,
model=self.xy_model, **common_options)
box.setFocusProxy(self.cb_attr_x)

self.axes_settings_box = self.setup_axes_settings_box()
self.color_settings_box = self.setup_color_settings_box()
self.rgb_settings_box = self.setup_rgb_settings_box()

box.layout().addWidget(self.axes_settings_box)
box.layout().addWidget(self.color_settings_box)
box.layout().addWidget(self.rgb_settings_box)

Expand Down Expand Up @@ -1020,6 +1034,11 @@ def on_exception(self, ex: Exception):
raise ex


class ImagePlot(BasicImagePlot):
attr_x = ContextSetting(None, exclude_attributes=True)
attr_y = ContextSetting(None, exclude_attributes=True)


class CurvePlotHyper(CurvePlot):
viewtype = Setting(AVERAGE) # average view by default

Expand Down

0 comments on commit be77297

Please sign in to comment.