Skip to content

Commit

Permalink
Update the 'stored' selection on any change
Browse files Browse the repository at this point in the history
  • Loading branch information
ales-erjavec committed Oct 23, 2017
1 parent 0f37087 commit 8767e6e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 1 addition & 2 deletions Orange/widgets/visualize/owlinearprojection.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ def select_indices(self, indices, modifiers=Qt.NoModifier):
self._selection_mask[indices] = True

self._on_color_change()
self.selection_indices = numpy.flatnonzero(self._selection_mask).tolist()
self.commit()

def commit(self):
Expand All @@ -956,9 +957,7 @@ def commit(self):
indices = numpy.flatnonzero(self._selection_mask)
if len(indices) > 0:
subset = self.data[indices]
indices = indices.tolist()

self.selection_indices = indices
self.Outputs.selected_data.send(subset)
self.Outputs.annotated_data.send(create_annotated_table(self.data, indices))

Expand Down
19 changes: 13 additions & 6 deletions Orange/widgets/visualize/owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,19 @@ def update_graph(self, reset_view=True, **_):
self.graph.update_data(self.attr_x, self.attr_y, reset_view)

def selection_changed(self):

# Store current selection in a setting that is stored in workflow
if isinstance(self.data, SqlTable):
selection = None
elif self.data is not None:
selection = self.graph.get_selection()
else:
selection = None
if selection is not None and len(selection):
self.selection_group = list(zip(selection, self.graph.selection[selection]))
else:
self.selection_group = None

self.commit()

def send_data(self):
Expand All @@ -417,12 +430,6 @@ def _get_annotated():
self.Outputs.annotated_data.send(_get_annotated())
self.Outputs.selected_data.send(_get_selected())

# Store current selection in a setting that is stored in workflow
if len(selection):
self.selection_group = list(zip(selection, graph.selection[selection]))
else:
self.selection_group = None

def send_features(self):
features = [attr for attr in [self.attr_x, self.attr_y] if attr]
self.Outputs.features.send(features or None)
Expand Down

0 comments on commit 8767e6e

Please sign in to comment.