def create_context_menu(self): menu = QMenu() menu.setToolTipsVisible(True) self._add_zoom_actions_to_menu(menu) if self.something_is_selected: filter_bw = Filter.read_configured_filter_bw() text = self.tr("Apply bandpass filter (filter bw={0:n})".format(filter_bw)) create_from_frequency_selection = menu.addAction(text) create_from_frequency_selection.triggered.connect(self.on_create_from_frequency_selection_triggered) create_from_frequency_selection.setIcon(QIcon.fromTheme("view-filter")) try: cancel_button = " or ".join(k.toString() for k in QKeySequence.keyBindings(QKeySequence.Cancel)) except Exception as e: logger.debug("Error reading cancel button: " + str(e)) cancel_button = "Esc" create_from_frequency_selection.setToolTip("You can abort filtering with <b>{}</b>.".format(cancel_button)) configure_filter_bw = menu.addAction(self.tr("Configure filter bandwidth...")) configure_filter_bw.triggered.connect(self.on_configure_filter_bw_triggered) configure_filter_bw.setIcon(QIcon.fromTheme("configure")) menu.addSeparator() export_fta_action = menu.addAction("Export spectrogram...") export_fta_action.triggered.connect(self.on_export_fta_action_triggered) return menu
def create_context_menu(self): menu = QMenu() menu.setToolTipsVisible(True) self._add_zoom_actions_to_menu(menu) if self.something_is_selected: filter_bw = Filter.read_configured_filter_bw() text = self.tr( "Apply bandpass filter (filter bw={0:n})".format(filter_bw)) create_from_frequency_selection = menu.addAction(text) create_from_frequency_selection.triggered.connect( self.on_create_from_frequency_selection_triggered) create_from_frequency_selection.setIcon( QIcon.fromTheme("view-filter")) try: cancel_button = " or ".join( k.toString() for k in QKeySequence.keyBindings(QKeySequence.Cancel)) except Exception as e: logger.debug("Error reading cancel button: " + str(e)) cancel_button = "Esc" create_from_frequency_selection.setToolTip( "You can abort filtering with <b>{}</b>.".format( cancel_button)) configure_filter_bw = menu.addAction( self.tr("Configure filter bandwidth...")) configure_filter_bw.triggered.connect( self.on_configure_filter_bw_triggered) configure_filter_bw.setIcon(QIcon.fromTheme("configure")) return menu
def on_bandpass_filter_triggered(self, f_low: float, f_high: float): self.setCursor(Qt.WaitCursor) filter_bw = Filter.read_configured_filter_bw() filtered = Filter.apply_bandpass_filter(self.signal.data, f_low, f_high, filter_bw=filter_bw) signal = self.signal.create_new(new_data=filtered.astype(np.complex64)) signal.name = self.signal.name + " filtered with f_low={0:.4n} f_high={1:.4n} bw={2:.4n}".format(f_low, f_high, filter_bw) self.signal_created.emit(signal) self.unsetCursor()
def create_context_menu(self): menu = QMenu() self._add_zoom_actions_to_menu(menu) if self.something_is_selected: filter_bw = Filter.read_configured_filter_bw() text = self.tr( "Create signal from frequency selection (filter bw={0:n})". format(filter_bw)) create_from_frequency_selection = menu.addAction(text) create_from_frequency_selection.triggered.connect( self.on_create_from_frequency_selection_triggered) create_from_frequency_selection.setIcon( QIcon.fromTheme("view-filter")) configure_filter_bw = menu.addAction( self.tr("Configure filter bandwidth...")) configure_filter_bw.triggered.connect( self.on_configure_filter_bw_triggered) configure_filter_bw.setIcon(QIcon.fromTheme("configure")) return menu