[modified] updateUi method for the FilterOptionsDlg has been restructured and simplified
This commit is contained in:
parent
9b1f7541fd
commit
0cd427486c
@ -27,7 +27,7 @@ from pylot.core.pick.utils import getSNR, earllatepicker, getnoisewin,\
|
|||||||
getResolutionWindow
|
getResolutionWindow
|
||||||
from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS
|
from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS
|
||||||
from pylot.core.util.utils import prepTimeAxis, getGlobalTimes, scaleWFData, \
|
from pylot.core.util.utils import prepTimeAxis, getGlobalTimes, scaleWFData, \
|
||||||
demeanTrace
|
demeanTrace, isSorted
|
||||||
|
|
||||||
|
|
||||||
def createAction(parent, text, slot=None, shortcut=None, icon=None,
|
def createAction(parent, text, slot=None, shortcut=None, icon=None,
|
||||||
@ -985,7 +985,7 @@ class FilterOptionsDialog(QDialog):
|
|||||||
"""
|
"""
|
||||||
super(FilterOptionsDialog, self).__init__()
|
super(FilterOptionsDialog, self).__init__()
|
||||||
|
|
||||||
if parent is not None:
|
if parent is not None and parent.getFilterOptions():
|
||||||
self.filterOptions = parent.getFilterOptions()
|
self.filterOptions = parent.getFilterOptions()
|
||||||
elif filterOptions is not None:
|
elif filterOptions is not None:
|
||||||
self.filterOptions = FilterOptions(filterOptions)
|
self.filterOptions = FilterOptions(filterOptions)
|
||||||
@ -1021,8 +1021,8 @@ class FilterOptionsDialog(QDialog):
|
|||||||
try:
|
try:
|
||||||
self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq())
|
self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq())
|
||||||
self.freqminSpinBox.setValue(self.getFilterOptions().getFreq())
|
self.freqminSpinBox.setValue(self.getFilterOptions().getFreq())
|
||||||
except TypeError, e:
|
except TypeError as e:
|
||||||
print e
|
print(e)
|
||||||
self.freqmaxSpinBox.setValue(1.)
|
self.freqmaxSpinBox.setValue(1.)
|
||||||
self.freqminSpinBox.setValue(.1)
|
self.freqminSpinBox.setValue(.1)
|
||||||
|
|
||||||
@ -1037,6 +1037,7 @@ class FilterOptionsDialog(QDialog):
|
|||||||
self.selectTypeLabel.setText("Select filter type:")
|
self.selectTypeLabel.setText("Select filter type:")
|
||||||
self.selectTypeCombo = QComboBox()
|
self.selectTypeCombo = QComboBox()
|
||||||
self.selectTypeCombo.addItems(typeOptions)
|
self.selectTypeCombo.addItems(typeOptions)
|
||||||
|
self.selectTypeCombo.setCurrentIndex(typeOptions.index(self.getFilterOptions().getFilterType()))
|
||||||
self.selectTypeLayout = QVBoxLayout()
|
self.selectTypeLayout = QVBoxLayout()
|
||||||
self.selectTypeLayout.addWidget(self.orderLabel)
|
self.selectTypeLayout.addWidget(self.orderLabel)
|
||||||
self.selectTypeLayout.addWidget(self.orderSpinBox)
|
self.selectTypeLayout.addWidget(self.orderSpinBox)
|
||||||
@ -1071,30 +1072,28 @@ class FilterOptionsDialog(QDialog):
|
|||||||
self.buttonBox.rejected.connect(self.reject)
|
self.buttonBox.rejected.connect(self.reject)
|
||||||
|
|
||||||
def updateUi(self):
|
def updateUi(self):
|
||||||
_enable = False
|
type = self.selectTypeCombo.currentText()
|
||||||
if self.selectTypeCombo.currentText() not in ['bandpass', 'bandstop']:
|
_enable = type in ['bandpass', 'bandstop']
|
||||||
self.freqminLabel.setText("cutoff:")
|
freq = [self.freqminSpinBox.value(), self.freqmaxSpinBox.value()]
|
||||||
self.freqmaxSpinBox.setValue(self.freqminSpinBox.value())
|
|
||||||
else:
|
|
||||||
_enable = True
|
|
||||||
self.freqminLabel.setText("minimum:")
|
|
||||||
|
|
||||||
self.freqmaxLabel.setEnabled(_enable)
|
self.freqmaxLabel.setEnabled(_enable)
|
||||||
self.freqmaxSpinBox.setEnabled(_enable)
|
self.freqmaxSpinBox.setEnabled(_enable)
|
||||||
|
|
||||||
self.getFilterOptions().setFilterType(
|
if not _enable:
|
||||||
self.selectTypeCombo.currentText())
|
self.freqminLabel.setText("cutoff:")
|
||||||
freq = [self.freqminSpinBox.value()]
|
self.freqmaxSpinBox.setValue(freq[0])
|
||||||
if _enable:
|
freq.remove(freq[1])
|
||||||
if self.freqminSpinBox.value() > self.freqmaxSpinBox.value():
|
else:
|
||||||
|
self.freqminLabel.setText("minimum:")
|
||||||
|
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 "
|
||||||
"same value as minimum frequency (notch)!")
|
"same value as minimum frequency (notch)!")
|
||||||
self.freqmaxSpinBox.setValue(self.freqminSpinBox.value())
|
self.freqmaxSpinBox.setValue(freq[0])
|
||||||
self.freqmaxSpinBox.selectAll()
|
self.freqmaxSpinBox.selectAll()
|
||||||
self.freqmaxSpinBox.setFocus()
|
self.freqmaxSpinBox.setFocus()
|
||||||
return
|
return
|
||||||
freq.append(self.freqmaxSpinBox.value())
|
|
||||||
|
self.getFilterOptions().setFilterType(type)
|
||||||
self.getFilterOptions().setFreq(freq)
|
self.getFilterOptions().setFreq(freq)
|
||||||
self.getFilterOptions().setOrder(self.orderSpinBox.value())
|
self.getFilterOptions().setOrder(self.orderSpinBox.value())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user