[add] reset (to auto settings) button
This commit is contained in:
parent
fa46385a52
commit
69955ff439
@ -1 +1 @@
|
|||||||
144e-dirty
|
fa46-dirty
|
||||||
|
@ -4541,6 +4541,9 @@ class FilterOptionsDialog(QDialog):
|
|||||||
'S': self.filterOptionWidgets['S'].getFilterOptions()}
|
'S': self.filterOptionWidgets['S'].getFilterOptions()}
|
||||||
return filteroptions
|
return filteroptions
|
||||||
|
|
||||||
|
def isComparable(self):
|
||||||
|
return {phase: fltOptWid.comparable for (phase, fltOptWid) in self.filterOptionWidgets.items()}
|
||||||
|
|
||||||
|
|
||||||
class FilterOptionsWidget(QWidget):
|
class FilterOptionsWidget(QWidget):
|
||||||
def __init__(self, filterOptions, filterOptionsAuto):
|
def __init__(self, filterOptions, filterOptionsAuto):
|
||||||
@ -4548,6 +4551,8 @@ class FilterOptionsWidget(QWidget):
|
|||||||
self.filterOptions = filterOptions
|
self.filterOptions = filterOptions
|
||||||
self.filterOptionsAuto = filterOptionsAuto
|
self.filterOptionsAuto = filterOptionsAuto
|
||||||
|
|
||||||
|
self.comparable = None
|
||||||
|
|
||||||
_enable = True
|
_enable = True
|
||||||
if self.getFilterOptions().getFilterType() is None:
|
if self.getFilterOptions().getFilterType() is None:
|
||||||
_enable = False
|
_enable = False
|
||||||
@ -4576,15 +4581,11 @@ class FilterOptionsWidget(QWidget):
|
|||||||
# self.freqmaxSpinBox.setValue(
|
# self.freqmaxSpinBox.setValue(
|
||||||
# self.getFilterOptions().getFreq()[1])
|
# self.getFilterOptions().getFreq()[1])
|
||||||
# else:
|
# else:
|
||||||
try:
|
|
||||||
self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()[0])
|
|
||||||
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"]
|
self.typeOptions = [None, "bandpass", "bandstop", "lowpass", "highpass"]
|
||||||
|
|
||||||
|
self.resetButton = QPushButton('Reset')
|
||||||
|
self.resetButton.setToolTip('Reset filter settings to settings for automatic picking.')
|
||||||
|
|
||||||
self.orderLabel = QLabel()
|
self.orderLabel = QLabel()
|
||||||
self.orderLabel.setText("Order:")
|
self.orderLabel.setText("Order:")
|
||||||
@ -4594,8 +4595,7 @@ class FilterOptionsWidget(QWidget):
|
|||||||
self.selectTypeLabel = QLabel()
|
self.selectTypeLabel = QLabel()
|
||||||
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(self.typeOptions)
|
||||||
self.selectTypeCombo.setCurrentIndex(typeOptions.index(self.getFilterOptions().getFilterType()))
|
|
||||||
|
|
||||||
self.autoOrder = QLabel('{}')
|
self.autoOrder = QLabel('{}')
|
||||||
self.autoType = QLabel('{}')
|
self.autoType = QLabel('{}')
|
||||||
@ -4628,17 +4628,16 @@ 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, 0)
|
||||||
grid.addLayout(self.selectTypeLayout, 1, 2, 1, 2)
|
grid.addLayout(self.selectTypeLayout, 1, 0)
|
||||||
|
grid.addWidget(self.resetButton, 2, 0)
|
||||||
|
|
||||||
self.setLayout(grid)
|
self.setLayout(grid)
|
||||||
|
|
||||||
|
self.setMFtoWidget()
|
||||||
|
|
||||||
|
self.resetButton.clicked.connect(self.setManuToAuto)
|
||||||
self.orderSpinBox.valueChanged.connect(self.updateUi)
|
self.orderSpinBox.valueChanged.connect(self.updateUi)
|
||||||
self.selectTypeCombo.currentIndexChanged.connect(self.updateUi)
|
self.selectTypeCombo.currentIndexChanged.connect(self.updateUi)
|
||||||
self.orderSpinBox.valueChanged.connect(self.checkAutoManu)
|
self.orderSpinBox.valueChanged.connect(self.checkAutoManu)
|
||||||
@ -4648,7 +4647,7 @@ class FilterOptionsWidget(QWidget):
|
|||||||
self.checkAutoManu()
|
self.checkAutoManu()
|
||||||
|
|
||||||
def checkAutoManu(self):
|
def checkAutoManu(self):
|
||||||
self.updateManuOptions()
|
self.updateMFfromWidget()
|
||||||
|
|
||||||
manuFilter = self.filterOptions
|
manuFilter = self.filterOptions
|
||||||
autoFilter = self.filterOptionsAuto
|
autoFilter = self.filterOptionsAuto
|
||||||
@ -4665,21 +4664,47 @@ class FilterOptionsWidget(QWidget):
|
|||||||
'freqmin': manuFilter.getFreq()[0],
|
'freqmin': manuFilter.getFreq()[0],
|
||||||
'freqmax': manuFilter.getFreq()[1]}
|
'freqmax': manuFilter.getFreq()[1]}
|
||||||
|
|
||||||
|
comparable = []
|
||||||
|
|
||||||
for key, label in labels.items():
|
for key, label in labels.items():
|
||||||
text = label.text().format(autoOptions[key])
|
text = label.text().format(autoOptions[key])
|
||||||
label.setText(text)
|
label.setText(text)
|
||||||
if autoOptions[key] == manuOptions[key]:
|
isEqual = autoOptions[key] == manuOptions[key]
|
||||||
|
if isEqual:
|
||||||
label.setStyleSheet('color: green')
|
label.setStyleSheet('color: green')
|
||||||
else:
|
else:
|
||||||
label.setStyleSheet('color: red')
|
label.setStyleSheet('color: red')
|
||||||
|
comparable.append(isEqual)
|
||||||
|
|
||||||
def updateManuOptions(self):
|
self.comparable = all(comparable)
|
||||||
|
|
||||||
|
def setMFtoWidget(self):
|
||||||
|
self.selectTypeCombo.setCurrentIndex(self.typeOptions.index(self.getFilterOptions().getFilterType()))
|
||||||
|
try:
|
||||||
|
freqmin, freqmax = self.filterOptions.getFreq()
|
||||||
|
self.freqminSpinBox.setValue(freqmin)
|
||||||
|
self.freqmaxSpinBox.setValue(freqmax)
|
||||||
|
except TypeError as e:
|
||||||
|
print(e)
|
||||||
|
self.freqmaxSpinBox.setValue(1.)
|
||||||
|
self.freqminSpinBox.setValue(.1)
|
||||||
|
try:
|
||||||
|
self.orderSpinBox.setValue(self.getFilterOptions().getOrder())
|
||||||
|
except:
|
||||||
|
self.orderSpinBox.setValue(2)
|
||||||
|
|
||||||
|
def updateMFfromWidget(self):
|
||||||
type = self.selectTypeCombo.currentText()
|
type = self.selectTypeCombo.currentText()
|
||||||
freq = [self.freqminSpinBox.value(), self.freqmaxSpinBox.value()]
|
freq = [self.freqminSpinBox.value(), self.freqmaxSpinBox.value()]
|
||||||
self.filterOptions.setFilterType(type)
|
self.filterOptions.setFilterType(type)
|
||||||
self.filterOptions.setFreq(freq)
|
self.filterOptions.setFreq(freq)
|
||||||
self.filterOptions.setOrder(self.orderSpinBox.value())
|
self.filterOptions.setOrder(self.orderSpinBox.value())
|
||||||
|
|
||||||
|
def setManuToAuto(self):
|
||||||
|
self.filterOptions = copy.deepcopy(self.filterOptionsAuto)
|
||||||
|
self.setMFtoWidget()
|
||||||
|
self.updateUi()
|
||||||
|
|
||||||
def checkMin(self):
|
def checkMin(self):
|
||||||
if not self.freqminSpinBox.value() <= self.freqmaxSpinBox.value():
|
if not self.freqminSpinBox.value() <= self.freqmaxSpinBox.value():
|
||||||
self.freqmaxSpinBox.setValue(self.freqminSpinBox.value())
|
self.freqmaxSpinBox.setValue(self.freqminSpinBox.value())
|
||||||
@ -4723,7 +4748,7 @@ class FilterOptionsWidget(QWidget):
|
|||||||
self.freqmaxSpinBox.selectAll()
|
self.freqmaxSpinBox.selectAll()
|
||||||
self.freqmaxSpinBox.setFocus()
|
self.freqmaxSpinBox.setFocus()
|
||||||
|
|
||||||
self.updateManuOptions()
|
self.updateMFfromWidget()
|
||||||
|
|
||||||
def getFilterOptions(self):
|
def getFilterOptions(self):
|
||||||
return self.filterOptions
|
return self.filterOptions
|
||||||
|
Loading…
Reference in New Issue
Block a user