[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):
|
def filterWaveformData(self):
|
||||||
if self.get_data():
|
if self.get_data():
|
||||||
if self.getFilterOptions() and self.filterAction.isChecked():
|
if self.getFilterOptions() and self.filterAction.isChecked():
|
||||||
kwargs = self.getFilterOptions().parseFilterOptions()
|
kwargs = self.getFilterOptions()['P'].parseFilterOptions()
|
||||||
self.pushFilterWF(kwargs)
|
self.pushFilterWF(kwargs)
|
||||||
elif self.filterAction.isChecked():
|
elif self.filterAction.isChecked():
|
||||||
self.adjustFilterOptions()
|
self.adjustFilterOptions()
|
||||||
@ -2501,6 +2501,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.paraBox._apply.clicked.connect(self.filterOptionsFromParameter)
|
self.paraBox._apply.clicked.connect(self.filterOptionsFromParameter)
|
||||||
self.paraBox._okay.clicked.connect(self.filterOptionsFromParameter)
|
self.paraBox._okay.clicked.connect(self.filterOptionsFromParameter)
|
||||||
if show:
|
if show:
|
||||||
|
self.paraBox.params_to_gui()
|
||||||
self.paraBox.show()
|
self.paraBox.show()
|
||||||
|
|
||||||
def PyLoTprefs(self):
|
def PyLoTprefs(self):
|
||||||
|
@ -341,12 +341,13 @@ class FilterOptions(object):
|
|||||||
def parseFilterOptions(self):
|
def parseFilterOptions(self):
|
||||||
if self:
|
if self:
|
||||||
robject = {'type': self.getFilterType(), 'corners': self.getOrder()}
|
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['freqmin'] = self.getFreq()[0]
|
||||||
robject['freqmax'] = self.getFreq()[1]
|
robject['freqmax'] = self.getFreq()[1]
|
||||||
else:
|
elif self.getFilterType() == 'highpass':
|
||||||
robject['freq'] = self.getFreq() if type(self.getFreq()) is \
|
robject['freq'] = self.getFreq()[0]
|
||||||
float else self.getFreq()[0]
|
elif self.getFilterType() == 'lowpass':
|
||||||
|
robject['freq'] = self.getFreq()[1]
|
||||||
return robject
|
return robject
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -3015,8 +3015,8 @@ class FilterOptionsDialog(QDialog):
|
|||||||
super(FilterOptionsDialog, self).__init__()
|
super(FilterOptionsDialog, self).__init__()
|
||||||
if parent is not None and parent.getFilters():
|
if parent is not None and parent.getFilters():
|
||||||
self.filterOptions = parent.getFilters()
|
self.filterOptions = parent.getFilters()
|
||||||
elif filterOptions is not None:
|
# elif filterOptions is not None:
|
||||||
self.filterOptions = filterOptions
|
# self.filterOptions = filterOptions
|
||||||
else:
|
else:
|
||||||
self.filterOptions = {'P': FilterOptions(),
|
self.filterOptions = {'P': FilterOptions(),
|
||||||
'S': FilterOptions()}
|
'S': FilterOptions()}
|
||||||
@ -3024,10 +3024,11 @@ class FilterOptionsDialog(QDialog):
|
|||||||
self.setWindowTitle(titleString)
|
self.setWindowTitle(titleString)
|
||||||
self.filterOptionWidgets = {'P': FilterOptionsWidget(self.filterOptions['P']),
|
self.filterOptionWidgets = {'P': FilterOptionsWidget(self.filterOptions['P']),
|
||||||
'S': FilterOptionsWidget(self.filterOptions['S'])}
|
'S': FilterOptionsWidget(self.filterOptions['S'])}
|
||||||
self.setupUI()
|
self.setupUi()
|
||||||
|
self.updateUi()
|
||||||
self.connectButtons()
|
self.connectButtons()
|
||||||
|
|
||||||
def setupUI(self):
|
def setupUi(self):
|
||||||
self.main_layout = QtGui.QVBoxLayout()
|
self.main_layout = QtGui.QVBoxLayout()
|
||||||
self.filter_layout = QtGui.QHBoxLayout()
|
self.filter_layout = QtGui.QHBoxLayout()
|
||||||
self.groupBoxes = {'P': QtGui.QGroupBox('P Filter'),
|
self.groupBoxes = {'P': QtGui.QGroupBox('P Filter'),
|
||||||
@ -3053,9 +3054,12 @@ class FilterOptionsDialog(QDialog):
|
|||||||
self.buttonBox.rejected.connect(self.reject)
|
self.buttonBox.rejected.connect(self.reject)
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
|
self.updateUi()
|
||||||
|
QDialog.accept(self)
|
||||||
|
|
||||||
|
def updateUi(self):
|
||||||
for foWidget in self.filterOptionWidgets.values():
|
for foWidget in self.filterOptionWidgets.values():
|
||||||
foWidget.updateUi()
|
foWidget.updateUi()
|
||||||
QDialog.accept(self)
|
|
||||||
|
|
||||||
def getFilterOptions(self):
|
def getFilterOptions(self):
|
||||||
filteroptions = {'P': self.filterOptionWidgets['P'].getFilterOptions(),
|
filteroptions = {'P': self.filterOptionWidgets['P'].getFilterOptions(),
|
||||||
@ -3087,16 +3091,16 @@ class FilterOptionsWidget(QWidget):
|
|||||||
self.freqmaxSpinBox.setDecimals(2)
|
self.freqmaxSpinBox.setDecimals(2)
|
||||||
self.freqmaxSpinBox.setSuffix(' Hz')
|
self.freqmaxSpinBox.setSuffix(' Hz')
|
||||||
|
|
||||||
if _enable:
|
# if _enable:
|
||||||
self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()[0])
|
# self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()[0])
|
||||||
if self.getFilterOptions().getFilterType() in ['bandpass',
|
# if self.getFilterOptions().getFilterType() in ['bandpass',
|
||||||
'bandstop']:
|
# 'bandstop']:
|
||||||
self.freqmaxSpinBox.setValue(
|
# self.freqmaxSpinBox.setValue(
|
||||||
self.getFilterOptions().getFreq()[1])
|
# self.getFilterOptions().getFreq()[1])
|
||||||
else:
|
# else:
|
||||||
try:
|
try:
|
||||||
self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq())
|
self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()[0])
|
||||||
self.freqminSpinBox.setValue(self.getFilterOptions().getFreq())
|
self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq()[1])
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
print(e)
|
print(e)
|
||||||
self.freqmaxSpinBox.setValue(1.)
|
self.freqmaxSpinBox.setValue(1.)
|
||||||
@ -3130,6 +3134,11 @@ class FilterOptionsWidget(QWidget):
|
|||||||
|
|
||||||
self.freqmaxSpinBox.setEnabled(_enable)
|
self.freqmaxSpinBox.setEnabled(_enable)
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.orderSpinBox.setValue(self.getFilterOptions().getOrder())
|
||||||
|
except:
|
||||||
|
self.orderSpinBox.setValue(2)
|
||||||
|
|
||||||
grid = QGridLayout()
|
grid = QGridLayout()
|
||||||
grid.addWidget(self.freqGroupBox, 0, 2, 1, 2)
|
grid.addWidget(self.freqGroupBox, 0, 2, 1, 2)
|
||||||
grid.addLayout(self.selectTypeLayout, 1, 2, 1, 2)
|
grid.addLayout(self.selectTypeLayout, 1, 2, 1, 2)
|
||||||
@ -3145,15 +3154,23 @@ class FilterOptionsWidget(QWidget):
|
|||||||
type = self.selectTypeCombo.currentText()
|
type = self.selectTypeCombo.currentText()
|
||||||
_enable = type in ['bandpass', 'bandstop']
|
_enable = type in ['bandpass', 'bandstop']
|
||||||
freq = [self.freqminSpinBox.value(), self.freqmaxSpinBox.value()]
|
freq = [self.freqminSpinBox.value(), self.freqmaxSpinBox.value()]
|
||||||
self.freqmaxLabel.setEnabled(_enable)
|
self.freqmaxLabel.setEnabled(True)
|
||||||
self.freqmaxSpinBox.setEnabled(_enable)
|
self.freqmaxSpinBox.setEnabled(True)
|
||||||
|
self.freqminLabel.setEnabled(True)
|
||||||
|
self.freqminSpinBox.setEnabled(True)
|
||||||
|
self.freqminLabel.setText("minimum:")
|
||||||
|
self.freqmaxLabel.setText("maximum:")
|
||||||
|
|
||||||
if not _enable:
|
if not _enable:
|
||||||
|
if type == 'highpass':
|
||||||
self.freqminLabel.setText("cutoff:")
|
self.freqminLabel.setText("cutoff:")
|
||||||
self.freqmaxSpinBox.setValue(freq[0])
|
self.freqmaxLabel.setEnabled(False)
|
||||||
freq.remove(freq[1])
|
self.freqmaxSpinBox.setEnabled(False)
|
||||||
|
elif type == 'lowpass':
|
||||||
|
self.freqmaxLabel.setText("cutoff:")
|
||||||
|
self.freqminLabel.setEnabled(False)
|
||||||
|
self.freqminSpinBox.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
self.freqminLabel.setText("minimum:")
|
|
||||||
if not isSorted(freq):
|
if not isSorted(freq):
|
||||||
QMessageBox.warning(self, "Value error",
|
QMessageBox.warning(self, "Value error",
|
||||||
"Maximum frequency must be at least the "
|
"Maximum frequency must be at least the "
|
||||||
|
Loading…
Reference in New Issue
Block a user