[change] structural changes to filteroptions WIP
This commit is contained in:
parent
dbc38385b5
commit
f7e54275c3
@ -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):
|
||||
|
@ -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
|
||||
|
||||
|
@ -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,9 +3054,12 @@ class FilterOptionsDialog(QDialog):
|
||||
self.buttonBox.rejected.connect(self.reject)
|
||||
|
||||
def accept(self):
|
||||
self.updateUi()
|
||||
QDialog.accept(self)
|
||||
|
||||
def updateUi(self):
|
||||
for foWidget in self.filterOptionWidgets.values():
|
||||
foWidget.updateUi()
|
||||
QDialog.accept(self)
|
||||
|
||||
def getFilterOptions(self):
|
||||
filteroptions = {'P': self.filterOptionWidgets['P'].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 "
|
||||
|
Loading…
Reference in New Issue
Block a user