diff --git a/QtPyLoT.py b/QtPyLoT.py index 566dda13..e14333fa 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -1531,7 +1531,7 @@ class MainWindow(QMainWindow): def filterWaveformData(self): if self.get_data(): if self.getFilterOptions() and self.filterAction.isChecked(): - kwargs = self.getFilterOptions().parseFilterOptions() + kwargs = self.getFilterOptions()['P'].parseFilterOptions() self.pushFilterWF(kwargs) elif self.filterAction.isChecked(): self.adjustFilterOptions() @@ -2501,6 +2501,7 @@ class MainWindow(QMainWindow): self.paraBox._apply.clicked.connect(self.filterOptionsFromParameter) self.paraBox._okay.clicked.connect(self.filterOptionsFromParameter) if show: + self.paraBox.params_to_gui() self.paraBox.show() def PyLoTprefs(self): diff --git a/pylot/core/io/inputs.py b/pylot/core/io/inputs.py index 95317e05..56e26e99 100644 --- a/pylot/core/io/inputs.py +++ b/pylot/core/io/inputs.py @@ -341,12 +341,13 @@ class FilterOptions(object): def parseFilterOptions(self): if self: robject = {'type': self.getFilterType(), 'corners': self.getOrder()} - if len(self.getFreq()) > 1: + if not self.getFilterType() in ['highpass', 'lowpass']: robject['freqmin'] = self.getFreq()[0] robject['freqmax'] = self.getFreq()[1] - else: - robject['freq'] = self.getFreq() if type(self.getFreq()) is \ - float else self.getFreq()[0] + elif self.getFilterType() == 'highpass': + robject['freq'] = self.getFreq()[0] + elif self.getFilterType() == 'lowpass': + robject['freq'] = self.getFreq()[1] return robject return None diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 0be38ce2..00f595d4 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -3015,8 +3015,8 @@ class FilterOptionsDialog(QDialog): super(FilterOptionsDialog, self).__init__() if parent is not None and parent.getFilters(): self.filterOptions = parent.getFilters() - elif filterOptions is not None: - self.filterOptions = filterOptions + # elif filterOptions is not None: + # self.filterOptions = filterOptions else: self.filterOptions = {'P': FilterOptions(), 'S': FilterOptions()} @@ -3024,10 +3024,11 @@ class FilterOptionsDialog(QDialog): self.setWindowTitle(titleString) self.filterOptionWidgets = {'P': FilterOptionsWidget(self.filterOptions['P']), 'S': FilterOptionsWidget(self.filterOptions['S'])} - self.setupUI() + self.setupUi() + self.updateUi() self.connectButtons() - def setupUI(self): + def setupUi(self): self.main_layout = QtGui.QVBoxLayout() self.filter_layout = QtGui.QHBoxLayout() self.groupBoxes = {'P': QtGui.QGroupBox('P Filter'), @@ -3053,10 +3054,13 @@ class FilterOptionsDialog(QDialog): self.buttonBox.rejected.connect(self.reject) def accept(self): - for foWidget in self.filterOptionWidgets.values(): - foWidget.updateUi() + self.updateUi() QDialog.accept(self) + def updateUi(self): + for foWidget in self.filterOptionWidgets.values(): + foWidget.updateUi() + def getFilterOptions(self): filteroptions = {'P': self.filterOptionWidgets['P'].getFilterOptions(), 'S': self.filterOptionWidgets['S'].getFilterOptions()} @@ -3087,20 +3091,20 @@ class FilterOptionsWidget(QWidget): self.freqmaxSpinBox.setDecimals(2) self.freqmaxSpinBox.setSuffix(' Hz') - if _enable: + # if _enable: + # self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()[0]) + # if self.getFilterOptions().getFilterType() in ['bandpass', + # 'bandstop']: + # self.freqmaxSpinBox.setValue( + # self.getFilterOptions().getFreq()[1]) + # else: + try: self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()[0]) - if self.getFilterOptions().getFilterType() in ['bandpass', - 'bandstop']: - self.freqmaxSpinBox.setValue( - self.getFilterOptions().getFreq()[1]) - else: - try: - self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq()) - self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()) - except TypeError as e: - print(e) - self.freqmaxSpinBox.setValue(1.) - self.freqminSpinBox.setValue(.1) + self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq()[1]) + except TypeError as e: + print(e) + self.freqmaxSpinBox.setValue(1.) + self.freqminSpinBox.setValue(.1) typeOptions = [None, "bandpass", "bandstop", "lowpass", "highpass"] @@ -3130,6 +3134,11 @@ class FilterOptionsWidget(QWidget): self.freqmaxSpinBox.setEnabled(_enable) + try: + self.orderSpinBox.setValue(self.getFilterOptions().getOrder()) + except: + self.orderSpinBox.setValue(2) + grid = QGridLayout() grid.addWidget(self.freqGroupBox, 0, 2, 1, 2) grid.addLayout(self.selectTypeLayout, 1, 2, 1, 2) @@ -3145,15 +3154,23 @@ class FilterOptionsWidget(QWidget): type = self.selectTypeCombo.currentText() _enable = type in ['bandpass', 'bandstop'] freq = [self.freqminSpinBox.value(), self.freqmaxSpinBox.value()] - self.freqmaxLabel.setEnabled(_enable) - self.freqmaxSpinBox.setEnabled(_enable) - + self.freqmaxLabel.setEnabled(True) + self.freqmaxSpinBox.setEnabled(True) + self.freqminLabel.setEnabled(True) + self.freqminSpinBox.setEnabled(True) + self.freqminLabel.setText("minimum:") + self.freqmaxLabel.setText("maximum:") + if not _enable: - self.freqminLabel.setText("cutoff:") - self.freqmaxSpinBox.setValue(freq[0]) - freq.remove(freq[1]) + if type == 'highpass': + self.freqminLabel.setText("cutoff:") + self.freqmaxLabel.setEnabled(False) + self.freqmaxSpinBox.setEnabled(False) + elif type == 'lowpass': + self.freqmaxLabel.setText("cutoff:") + self.freqminLabel.setEnabled(False) + self.freqminSpinBox.setEnabled(False) else: - self.freqminLabel.setText("minimum:") if not isSorted(freq): QMessageBox.warning(self, "Value error", "Maximum frequency must be at least the "