def __init__(self, parent=None, vispy_widget=None, data_viewer=None): super(VispyOptionsWidget, self).__init__(parent=parent) self.ui = load_ui('viewer_options.ui', self, directory=os.path.dirname(__file__)) self._vispy_widget = vispy_widget vispy_widget.options = self self._data_viewer = data_viewer self.stretch_sliders = [self.ui.slider_x_stretch, self.ui.slider_y_stretch, self.ui.slider_z_stretch] self.stretch_values = [self.ui.value_x_stretch, self.ui.value_y_stretch, self.ui.value_z_stretch] self._event_lock = False for slider, label in zip(self.stretch_sliders, self.stretch_values): slider.valueChanged.connect(partial(self._update_labels_from_sliders, label, slider)) label.editingFinished.connect(partial(self._update_sliders_from_labels, slider, label)) label.setText('1.0') label.editingFinished.emit() slider.valueChanged.connect(self._update_stretch) connect_bool_button(self._vispy_widget, 'visible_axes', self.ui.checkbox_axes) connect_bool_button(self._vispy_widget, 'perspective_view', self.ui.checkbox_perspective) if self._data_viewer is not None: self.ui.combo_x_attribute.currentIndexChanged.connect(self._data_viewer._update_attributes) self.ui.combo_y_attribute.currentIndexChanged.connect(self._data_viewer._update_attributes) self.ui.combo_z_attribute.currentIndexChanged.connect(self._data_viewer._update_attributes) self.ui.combo_x_attribute.currentIndexChanged.connect(self._update_attribute_limits) self.ui.combo_y_attribute.currentIndexChanged.connect(self._update_attribute_limits) self.ui.combo_z_attribute.currentIndexChanged.connect(self._update_attribute_limits) self.ui.value_x_min.editingFinished.connect(self._update_limits) self.ui.value_y_min.editingFinished.connect(self._update_limits) self.ui.value_z_min.editingFinished.connect(self._update_limits) self.ui.value_x_max.editingFinished.connect(self._update_limits) self.ui.value_y_max.editingFinished.connect(self._update_limits) self.ui.value_z_max.editingFinished.connect(self._update_limits) self.ui.button_flip_x.clicked.connect(self._flip_x) self.ui.button_flip_y.clicked.connect(self._flip_y) self.ui.button_flip_z.clicked.connect(self._flip_z) self.ui.reset_button.clicked.connect(self._vispy_widget._reset_view) self._components = {} self._set_attributes_enabled(False) self._set_limits_enabled(False) self._first_attributes = True
def _connect(self): ui = self.ui cl = self.client connect_bool_button(cl, 'ylog', ui.ylog) connect_current_combo(cl, 'parent_attr', ui.parentCombo) connect_current_combo(cl, 'height_attr', ui.heightCombo) connect_current_combo(cl, 'order_attr', ui.orderCombo)
def _connect(self): ui = self.ui cl = self.client ui.attributeCombo.currentIndexChanged.connect(self._set_attribute_from_combo) ui.normalized_box.toggled.connect(partial(setattr, cl, 'normed')) ui.autoscale_box.toggled.connect(partial(setattr, cl, 'autoscale')) ui.cumulative_box.toggled.connect(partial(setattr, cl, 'cumulative')) connect_int_spin(cl, 'nbins', ui.binSpinBox) connect_float_edit(cl, 'xmin', ui.xmin) connect_float_edit(cl, 'xmax', ui.xmax) connect_bool_button(cl, 'xlog', ui.xlog_box) connect_bool_button(cl, 'ylog', ui.ylog_box)
def autoconnect_qt(state, widget): for child in widget.children(): full_name = child.objectName() if '_' in full_name: wtype, wname = full_name.split('_', 1) if hasattr(state, wname): item = getattr(widget, full_name) if wtype == 'value': connect_value(state, wname, item) elif wtype == 'text': connect_text(state, wname, item) elif wtype == 'bool': connect_bool_button(state, wname, item) elif wtype == 'combo': connect_current_combo(state, wname, item) elif wtype == 'color': connect_color(state, wname, item)
def _connect(self): ui = self.ui cl = self.client connect_bool_button(cl, 'xlog', ui.xLogCheckBox) connect_bool_button(cl, 'ylog', ui.yLogCheckBox) connect_bool_button(cl, 'xflip', ui.xFlipCheckBox) connect_bool_button(cl, 'yflip', ui.yFlipCheckBox) ui.xAxisComboBox.currentIndexChanged.connect(self.update_xatt) ui.yAxisComboBox.currentIndexChanged.connect(self.update_yatt) ui.hidden_attributes.toggled.connect(lambda x: self._update_combos()) ui.swapAxes.clicked.connect(nonpartial(self.swap_axes)) ui.snapLimits.clicked.connect(cl.snap) connect_float_edit(cl, 'xmin', ui.xmin) connect_float_edit(cl, 'xmax', ui.xmax) connect_float_edit(cl, 'ymin', ui.ymin) connect_float_edit(cl, 'ymax', ui.ymax)