cleaned up object type class definition for FilterOptions, programs now only use methods to access attributes

This commit is contained in:
Sebastian Wehling-Benatelli 2014-10-30 13:38:03 +01:00
parent bff84ede81
commit 97344c9f21
2 changed files with 28 additions and 27 deletions

View File

@ -165,39 +165,34 @@ class FilterOptions(object):
'''
def __init__(self, filtertype='bandpass', freq=[2., 5.], order=3,
**kwargs):
self.__filterInformation = {}
self._setFilterType(filtertype)
self._setFreq(freq)
self._setOrder(order)
self.setFilterType(filtertype)
self.setFreq(freq)
self.setOrder(order)
def __str__(self):
hrs = '''\n\tFilter parameter:\n
Type:\t\t{ftype}\n
Frequencies:\t{freq}\n
Order:\t\t{order}\n
'''.format(ftype=self.filterType,
freq=self.freq,
order=self.order)
'''.format(ftype=self.getFilterType(),
freq=self.getFreq(),
order=self.getOrder())
return hrs
def _getFreq(self):
return self.__filterInformation['freq']
def getFreq(self):
return self.freq
def _setFreq(self, freq):
self.__filterInformation['freq'] = freq
def setFreq(self, freq):
self.freq = freq
def _getOrder(self):
return self.__filterInformation['order']
def getOrder(self):
return self.order
def _setOrder(self, order):
self.__filterInformation['order'] = order
def setOrder(self, order):
self.order = order
def _getFilterType(self):
return self.__filterInformation['filtertype']
def getFilterType(self):
return self.filterType
def _setFilterType(self, filtertype):
self.__filterInformation['filtertype'] = filtertype
filterType = property(fget=_getFilterType, fset=_setFilterType)
order = property(fget=_getOrder, fset=_setOrder)
freq = property(fget=_getFreq, fset=_setFreq)
def setFilterType(self, filtertype):
self.filterType = filtertype

View File

@ -158,7 +158,10 @@ class FilterOptionsDialog(QDialog):
"""
super(FilterOptionsDialog, self).__init__()
self.filterOptions = [filterOptions if filterOptions is not None else FilterOptions()][0]
if filterOptions is not None:
self.filterOptions = filterOptions
else:
self.filterOptions = FilterOptions()
self.freqminLabel = QLabel()
self.freqminLabel.setText("minimum:")
@ -166,7 +169,7 @@ class FilterOptionsDialog(QDialog):
self.freqminSpinBox.setRange(5e-7, 1e6)
self.freqminSpinBox.setDecimals(2)
self.freqminSpinBox.setSuffix(' Hz')
self.freqminSpinBox.setValue(filterOptions.freq[0])
self.freqminSpinBox.setValue(self.getFilterOptions().getFreq()[0])
self.freqmaxLabel = QLabel()
self.freqmaxLabel.setText("maximum:")
self.freqmaxSpinBox = QDoubleSpinBox()
@ -174,7 +177,7 @@ class FilterOptionsDialog(QDialog):
self.freqmaxSpinBox.setDecimals(2)
self.freqmaxSpinBox.setSuffix(' Hz')
if self.filterOptions.filterType in ['bandpass', 'bandstop']:
self.freqmaxSpinBox.setValue(self.filterOptions.freq[1])
self.freqmaxSpinBox.setValue(self.getFilterOptions().getFreq()[1])
typeOptions = ["bandpass", "bandstop", "lowpass", "highpass"]
@ -244,6 +247,9 @@ class FilterOptionsDialog(QDialog):
self.filterOptions.order = self.orderSpinBox.value()
return self.filterOptions
def getFilterOptions(self):
return self.filterOptions
class LoadDataDlg(QDialog):