def _populate_function_combo(self): """ Add name of functions to function combo box """ f = [f for f in link_function.members if len(f.output_labels) == 1] functions = [l for l in f + link_helper.members if l.category == self.category] LinkEquation.function.set_choices(self, functions) LinkEquation.function.set_display_func(self, lambda l: get_function_name(l[0])) connect_combo_selection(self, 'function', self._ui.function)
def _populate_function_combo(self): """ Add name of functions to function combo box """ f = [f for f in link_function.members if len(f.output_labels) == 1] functions = [l for l in f + link_helper.members if l.category == self.category] LinkEquation.function.set_choices(self, functions) LinkEquation.function.set_display_func(self, lambda l: get_function_name(l[0])) connect_combo_selection(self, 'function', self._ui.function)
def _enable_viewer_combo(self, viewer, data, index, selection_label): connect_combo_selection(self, selection_label, viewer.combo) helper = ComponentIDComboHelper(self, selection_label) helper.set_multiple_data([data]) viewer.combo.setEnabled(True) viewer.combo.currentIndexChanged.connect( self._get_change_viewer_combo_func(viewer.combo, index)) self._viewer_combo_helpers.append(helper)
def __init__(self, data_collection=None, initial_data=None, parent=None): super(ComponentManagerWidget, self).__init__(parent=parent) self.ui = load_ui('component_manager.ui', self, directory=os.path.dirname(__file__)) self.list = {} self.list = self.ui.list_main_components self.data_collection = data_collection self._components_main = defaultdict(list) self._components_other = defaultdict(list) self._state = defaultdict(dict) for data in data_collection: for cid in data.main_components: comp_state = {} comp_state['cid'] = cid comp_state['label'] = cid.label self._state[data][cid] = comp_state self._components_main[data].append(cid) # Keep track of all other components self._components_other[data] = [] for cid in data.components: if cid not in self._components_main[data]: self._components_other[data].append(cid) # Populate data combo ComponentManagerWidget.data.set_choices(self, list(self.data_collection)) ComponentManagerWidget.data.set_display_func(self, lambda x: x.label) connect_combo_selection(self, 'data', self.ui.combosel_data) if initial_data is None: self.ui.combosel_data.setCurrentIndex(0) else: self.data = initial_data self.ui.combosel_data.currentIndexChanged.connect(self._update_component_lists) self._update_component_lists() self.ui.button_remove_main.clicked.connect(self._remove_main_component) self.ui.list_main_components.itemSelectionChanged.connect(self._update_selection_main) self._update_selection_main() self.ui.list_main_components.itemChanged.connect(self._update_state) self.ui.list_main_components.order_changed.connect(self._update_state) self.ui.button_ok.clicked.connect(self.accept) self.ui.button_cancel.clicked.connect(self.reject)
def __init__(self, data_collection=None, parent=None): super(ComponentManagerWidget, self).__init__(parent=parent) self.ui = load_ui('component_manager.ui', self, directory=os.path.dirname(__file__)) self.list = {} self.list = self.ui.list_main_components self.data_collection = data_collection self._components_main = defaultdict(list) self._components_other = defaultdict(list) self._state = defaultdict(dict) for data in data_collection: for cid in data.main_components: comp_state = {} comp_state['cid'] = cid comp_state['label'] = cid.label self._state[data][cid] = comp_state self._components_main[data].append(cid) # Keep track of all other components self._components_other[data] = [] for cid in data.components: if cid not in self._components_main[data]: self._components_other[data].append(cid) # Populate data combo ComponentManagerWidget.data.set_choices(self, list(self.data_collection)) ComponentManagerWidget.data.set_display_func(self, lambda x: x.label) connect_combo_selection(self, 'data', self.ui.combosel_data) self.ui.combosel_data.setCurrentIndex(0) self.ui.combosel_data.currentIndexChanged.connect( self._update_component_lists) self._update_component_lists() self.ui.button_remove_main.clicked.connect(self._remove_main_component) self.ui.list_main_components.itemSelectionChanged.connect( self._update_selection_main) self._update_selection_main() self.ui.list_main_components.itemChanged.connect(self._update_state) self.ui.list_main_components.order_changed.connect(self._update_state) self.ui.button_ok.clicked.connect(self.accept) self.ui.button_cancel.clicked.connect(self.reject)
def __init__(self, parent=None, data_viewer=None): super(OptionsWidget, self).__init__(parent=parent) self.ui = load_ui('viewer_options.ui', self, directory=os.path.dirname(__file__)) self.file_helper = ComponentIDComboHelper( self, 'file_att', data_collection=data_viewer._data) connect_combo_selection(self, 'file_att', self.ui.combo_file_attribute)
def __init__(self, label=None, data=None, equation=None, references=None, parent=None): super(EquationEditorDialog, self).__init__(parent=parent) self.ui = load_ui('equation_editor.ui', self, directory=os.path.dirname(__file__)) # Get mapping from label to component ID if references is not None: self.references = references elif data is not None: self.references = OrderedDict() for cid in data.coordinate_components + data.main_components: self.references[cid.label] = cid example = sorted(self.references, key=len)[0] self.ui.text_label.setPlaceholderText("New attribute name") self.ui.expression.setPlaceholderText( self.placeholder_text.format(example=example)) self.ui.label.setText(self.tip_text.format(example=example)) if label is not None: self.ui.text_label.setText(label) self.ui.text_label.textChanged.connect(self._update_status) # Populate component combo EquationEditorDialog.attribute.set_choices(self, list(self.references)) connect_combo_selection(self, 'attribute', self.ui.combosel_component) # Set up labels for auto-completion labels = ['{' + l + '}' for l in self.references] self.ui.expression.set_word_list(labels) if equation is not None: self.ui.expression.insertPlainText(equation) self.ui.button_ok.clicked.connect(self.accept) self.ui.button_cancel.clicked.connect(self.reject) self.ui.button_insert.clicked.connect(self._insert_component) self.ui.expression.updated.connect(self._update_status) self._update_status()
def __init__(self, label=None, data=None, equation=None, references=None, parent=None): super(EquationEditorDialog, self).__init__(parent=parent) self.ui = load_ui('equation_editor.ui', self, directory=os.path.dirname(__file__)) # Get mapping from label to component ID if references is not None: self.references = references elif data is not None: self.references = OrderedDict() for cid in data.coordinate_components + data.main_components: self.references[cid.label] = cid example = sorted(self.references, key=len)[0] self.ui.text_label.setPlaceholderText("New attribute name") self.ui.expression.setPlaceholderText(self.placeholder_text.format(example=example)) self.ui.label.setText(self.tip_text.format(example=example)) if label is not None: self.ui.text_label.setText(label) self.ui.text_label.textChanged.connect(self._update_status) # Populate component combo EquationEditorDialog.attribute.set_choices(self, list(self.references)) connect_combo_selection(self, 'attribute', self.ui.combosel_component) # Set up labels for auto-completion labels = ['{' + l + '}' for l in self.references] self.ui.expression.set_word_list(labels) if equation is not None: self.ui.expression.insertPlainText(equation) self.ui.button_ok.clicked.connect(self.accept) self.ui.button_cancel.clicked.connect(self.reject) self.ui.button_insert.clicked.connect(self._insert_component) self.ui.expression.updated.connect(self._update_status) self._update_status()
def enable(self): self.nav_mode = NavigateMouseMode(self.viewer, press_callback=self._on_nav_activate) self.rng_mode = RangeMouseMode(self.viewer) self.nav_mode.state.add_callback('x', self._on_slider_change) self.ui.tabs.setCurrentIndex(0) self.ui.tabs.currentChanged.connect(self._on_tab_change) self.ui.button_settings.clicked.connect(self._on_settings) self.ui.button_fit.clicked.connect(self._on_fit) self.ui.button_clear.clicked.connect(self._on_clear) self.ui.button_collapse.clicked.connect(self._on_collapse) font = QtGui.QFont("Courier") font.setStyleHint(font.Monospace) self.ui.text_log.document().setDefaultFont(font) self.ui.text_log.setLineWrapMode(self.ui.text_log.NoWrap) self.axes = self.viewer.axes self.canvas = self.axes.figure.canvas self._fit_artists = [] ProfileTools.fit_function.set_choices(self, list(fit_plugin)) ProfileTools.fit_function.set_display_func(self, lambda fitter: fitter.label) connect_combo_selection(self, 'fit_function', self.ui.combosel_fit_function) ProfileTools.collapse_function.set_choices(self, list(COLLAPSE_FUNCS)) ProfileTools.collapse_function.set_display_func( self, COLLAPSE_FUNCS.get) connect_combo_selection(self, 'collapse_function', self.ui.combosel_collapse_function) self._toolbar_connected = False self.viewer.toolbar_added.connect(self._on_toolbar_added) self.viewer.state.add_callback('x_att', self._on_x_att_change)
def enable(self): self.nav_mode = NavigateMouseMode(self.viewer, press_callback=self._on_nav_activate) self.rng_mode = RangeMouseMode(self.viewer) self.nav_mode.state.add_callback('x', self._on_slider_change) self.ui.tabs.setCurrentIndex(0) self.ui.tabs.currentChanged.connect(self._on_tab_change) self.ui.button_settings.clicked.connect(self._on_settings) self.ui.button_fit.clicked.connect(self._on_fit) self.ui.button_clear.clicked.connect(self._on_clear) self.ui.button_collapse.clicked.connect(self._on_collapse) font = QtGui.QFont("Courier") font.setStyleHint(font.Monospace) self.ui.text_log.document().setDefaultFont(font) self.ui.text_log.setLineWrapMode(self.ui.text_log.NoWrap) self.axes = self.viewer.axes self.canvas = self.axes.figure.canvas self._fit_artists = [] ProfileTools.fit_function.set_choices(self, list(fit_plugin)) ProfileTools.fit_function.set_display_func(self, lambda fitter: fitter.label) connect_combo_selection(self, 'fit_function', self.ui.combosel_fit_function) ProfileTools.collapse_function.set_choices(self, list(COLLAPSE_FUNCS)) ProfileTools.collapse_function.set_display_func(self, COLLAPSE_FUNCS.get) connect_combo_selection(self, 'collapse_function', self.ui.combosel_collapse_function) self._toolbar_connected = False self.viewer.toolbar_added.connect(self._on_toolbar_added) self.viewer.state.add_callback('x_att', self._on_x_att_change)
def __init__(self, data_collection=None, parent=None): super(ArithmeticEditorWidget, self).__init__(parent=parent) self.ui = load_ui('component_arithmetic.ui', self, directory=os.path.dirname(__file__)) self.list = self.ui.list_derived_components self.data_collection = data_collection self._components_derived = defaultdict(list) self._components_other = defaultdict(list) self._state = defaultdict(dict) for data in data_collection: # First find all derived components (only ones based on arithmetic # expressions) self._components_derived[data] = [] for cid in data.derived_components: comp = data.get_component(cid) if isinstance(comp.link, ParsedComponentLink): comp_state = {} comp_state['cid'] = cid comp_state['label'] = cid.label comp_state['equation'] = comp.link._parsed self._state[data][cid] = comp_state self._components_derived[data].append(cid) # Keep track of all other components self._components_other[data] = [] for cid in data.components: if cid not in self._components_derived[data]: self._components_other[data].append(cid) # Populate data combo ArithmeticEditorWidget.data.set_choices(self, list(self.data_collection)) ArithmeticEditorWidget.data.set_display_func(self, lambda x: x.label) connect_combo_selection(self, 'data', self.ui.combosel_data) self.ui.combosel_data.setCurrentIndex(0) self.ui.combosel_data.currentIndexChanged.connect(self._update_component_lists) self._update_component_lists() self.ui.button_add_derived.clicked.connect(self._add_derived_component) self.ui.button_edit_derived.clicked.connect(self._edit_derived_component) self.ui.button_remove_derived.clicked.connect(self._remove_derived_component) self.ui.list_derived_components.itemSelectionChanged.connect(self._update_selection_derived) self._update_selection_derived() self.ui.list_derived_components.itemChanged.connect(self._update_state) self.ui.list_derived_components.order_changed.connect(self._update_state) self.ui.list_derived_components.itemDoubleClicked.connect(self._edit_derived_component) self.ui.button_ok.clicked.connect(self.accept) self.ui.button_cancel.clicked.connect(self.reject)
def _populate_category_combo(self): f = [f for f in link_function.members if len(f.output_labels) == 1] categories = sorted(set(l.category for l in f + link_helper.members)) LinkEquation.category.set_choices(self, categories) connect_combo_selection(self, 'category', self._ui.category)
def _populate_category_combo(self): f = [f for f in link_function.members if len(f.output_labels) == 1] categories = sorted(set(l.category for l in f + link_helper.members)) LinkEquation.category.set_choices(self, categories) connect_combo_selection(self, 'category', self._ui.category)