Skip to content

Commit

Permalink
MDS: Add option to show labels only for selected points
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Jun 24, 2016
1 parent 47cebc2 commit 3ef668b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Orange/widgets/unsupervised/owmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class OWMDS(widget.OWWidget):
shape_value = settings.ContextSetting("")
size_value = settings.ContextSetting("")
label_value = settings.ContextSetting("")
label_only_selected = settings.Setting(False)

symbol_size = settings.Setting(8)
symbol_opacity = settings.Setting(230)
Expand Down Expand Up @@ -232,6 +233,9 @@ def __init__(self):
box, self, "label_value", label="Label:",
callback=self._on_label_index_changed, **common_options)
self.cb_label_value.setModel(self.labelvar_model)
gui.checkBox(
gui.indentedBox(box), self, 'label_only_selected',
'Label only selected points', callback=self._on_label_index_changed)

form = QtGui.QFormLayout(
labelAlignment=Qt.AlignLeft,
Expand Down Expand Up @@ -930,9 +934,18 @@ def jitter(x, factor=1, rstate=None):
self.plot.addItem(item)

if self._label_data is not None:
for (x, y), text_item in zip(self.embedding, self._label_data):
self.plot.addItem(text_item)
text_item.setPos(x, y)
if self.label_only_selected:
if self._selection_mask is not None:
for (x, y), text_item, selected \
in zip(self.embedding, self._label_data,
self._selection_mask):
if selected:
self.plot.addItem(text_item)
text_item.setPos(x, y)
else:
for (x, y), text_item in zip(self.embedding, self._label_data):
self.plot.addItem(text_item)
text_item.setPos(x, y)

self._legend_item = LegendItem()
viewbox = self.plot.getViewBox()
Expand Down

0 comments on commit 3ef668b

Please sign in to comment.