#!/usr/bin/env python
+import sys, os
+from optparse import OptionParser
+from gnuradio import gr, blks2, eng_notation
+
try:
import scipy
from scipy import fftpack
print "Please install SciPy to run this script (http://www.scipy.org/)"
raise SystemExit, 1
-import sys, os
-from PyQt4 import Qt, QtCore, QtGui
-import PyQt4.Qwt5 as Qwt
-from optparse import OptionParser
-from gnuradio import gr, blks2, eng_notation
-from scipy import fftpack
+try:
+ from PyQt4 import Qt, QtCore, QtGui
+except ImportError:
+ print "Please install PyQt4 to run this script (http://www.riverbankcomputing.co.uk/software/pyqt/download)"
+ raise SystemExit, 1
+
+try:
+ import PyQt4.Qwt5 as Qwt
+except ImportError:
+ print "Please install PyQwt5 to run this script (http://pyqwt.sourceforge.net/)"
+ raise SystemExit, 1
+
+try:
+ from pyqt_filter import Ui_MainWindow
+except ImportError:
+ print "Could not import from pyqt_filter. Please build with \"pyuic4 pyqt_filter.ui -o pyqt_filter.py\""
+ raise SystemExit, 1
-from pyqt_filter import Ui_MainWindow
class gr_plot_filter(QtGui.QMainWindow):
def __init__(self, qapp, options):
self.nfftpts = int(10000)
self.gui.nfftEdit.setText(Qt.QString("%1").arg(self.nfftpts))
- self.gui.lpfPassBandRippleLabel.setVisible(False)
- self.gui.lpfPassBandRippleEdit.setVisible(False)
- self.gui.bpfPassBandRippleLabel.setVisible(False)
- self.gui.bpfPassBandRippleEdit.setVisible(False)
- self.gui.bnfPassBandRippleLabel.setVisible(False)
- self.gui.bnfPassBandRippleEdit.setVisible(False)
- self.gui.hpfPassBandRippleLabel.setVisible(False)
- self.gui.hpfPassBandRippleEdit.setVisible(False)
+ self.firFilters = ("Low Pass", "Band Pass", "Complex Band Pass", "Band Notch",
+ "High Pass", "Root Raised Cosine", "Gaussian")
+ self.optFilters = ("Low Pass", "Band Pass", "Complex Band Pass",
+ "Band Notch", "High Pass")
+
+ self.set_windowed()
# Initialize to LPF
self.gui.filterTypeWidget.setCurrentWidget(self.gui.firlpfPage)
# Set up pen for colors and line width
blue = QtGui.qRgb(0x00, 0x00, 0xFF)
blueBrush = Qt.QBrush(Qt.QColor(blue))
+ red = QtGui.qRgb(0xFF, 0x00, 0x00)
+ redBrush = Qt.QBrush(Qt.QColor(red))
self.freqcurve.setPen(Qt.QPen(blueBrush, 2))
self.rcurve.setPen(Qt.QPen(blueBrush, 2))
+ self.icurve.setPen(Qt.QPen(redBrush, 2))
self.phasecurve.setPen(Qt.QPen(blueBrush, 2))
self.groupcurve.setPen(Qt.QPen(blueBrush, 2))
-
+
+ # Set up validators for edit boxes
+ self.intVal = Qt.QIntValidator(None)
+ self.dblVal = Qt.QDoubleValidator(None)
+ self.gui.nfftEdit.setValidator(self.intVal)
+ self.gui.sampleRateEdit.setValidator(self.dblVal)
+ self.gui.filterGainEdit.setValidator(self.dblVal)
+ self.gui.endofLpfPassBandEdit.setValidator(self.dblVal)
+ self.gui.startofLpfStopBandEdit.setValidator(self.dblVal)
+ self.gui.lpfStopBandAttenEdit.setValidator(self.dblVal)
+ self.gui.lpfPassBandRippleEdit.setValidator(self.dblVal)
+ self.gui.startofBpfPassBandEdit.setValidator(self.dblVal)
+ self.gui.endofBpfPassBandEdit.setValidator(self.dblVal)
+ self.gui.bpfTransitionEdit.setValidator(self.dblVal)
+ self.gui.bpfStopBandAttenEdit.setValidator(self.dblVal)
+ self.gui.bpfPassBandRippleEdit.setValidator(self.dblVal)
+ self.gui.startofBnfStopBandEdit.setValidator(self.dblVal)
+ self.gui.endofBnfStopBandEdit.setValidator(self.dblVal)
+ self.gui.bnfTransitionEdit.setValidator(self.dblVal)
+ self.gui.bnfStopBandAttenEdit.setValidator(self.dblVal)
+ self.gui.bnfPassBandRippleEdit.setValidator(self.dblVal)
+ self.gui.endofHpfStopBandEdit.setValidator(self.dblVal)
+ self.gui.startofHpfPassBandEdit.setValidator(self.dblVal)
+ self.gui.hpfStopBandAttenEdit.setValidator(self.dblVal)
+ self.gui.hpfPassBandRippleEdit.setValidator(self.dblVal)
+ self.gui.rrcSymbolRateEdit.setValidator(self.dblVal)
+ self.gui.rrcAlphaEdit.setValidator(self.dblVal)
+ self.gui.rrcNumTapsEdit.setValidator(self.dblVal)
+ self.gui.gausSymbolRateEdit.setValidator(self.dblVal)
+ self.gui.gausBTEdit.setValidator(self.dblVal)
+ self.gui.gausNumTapsEdit.setValidator(self.dblVal)
self.gui.nTapsEdit.setText("0")
self.design()
def set_equiripple(self):
+ # Stop sending the signal for this function
+ self.gui.filterTypeComboBox.blockSignals(True)
+
self.equiripple = True
self.gui.lpfPassBandRippleLabel.setVisible(True)
self.gui.lpfPassBandRippleEdit.setVisible(True)
self.gui.bnfPassBandRippleEdit.setVisible(True)
self.gui.hpfPassBandRippleLabel.setVisible(True)
self.gui.hpfPassBandRippleEdit.setVisible(True)
+
+ # Save current type and repopulate the combo box for
+ # filters this window type can handle
+ currenttype = self.gui.filterTypeComboBox.currentText()
+ items = self.gui.filterTypeComboBox.count()
+ for i in xrange(items):
+ self.gui.filterTypeComboBox.removeItem(0)
+ self.gui.filterTypeComboBox.addItems(self.optFilters)
+
+ # If the last filter type was valid for this window type,
+ # go back to it; otherwise, reset
+ try:
+ index = self.optFilters.index(currenttype)
+ self.gui.filterTypeComboBox.setCurrentIndex(index)
+ except ValueError:
+ pass
+
+ # Tell gui its ok to start sending this signal again
+ self.gui.filterTypeComboBox.blockSignals(False)
def set_windowed(self):
+ # Stop sending the signal for this function
+ self.gui.filterTypeComboBox.blockSignals(True)
+
self.equiripple = False
self.gui.lpfPassBandRippleLabel.setVisible(False)
self.gui.lpfPassBandRippleEdit.setVisible(False)
self.gui.bnfPassBandRippleEdit.setVisible(False)
self.gui.hpfPassBandRippleLabel.setVisible(False)
self.gui.hpfPassBandRippleEdit.setVisible(False)
-
+
+ # Save current type and repopulate the combo box for
+ # filters this window type can handle
+ currenttype = self.gui.filterTypeComboBox.currentText()
+ items = self.gui.filterTypeComboBox.count()
+ for i in xrange(items):
+ self.gui.filterTypeComboBox.removeItem(0)
+ self.gui.filterTypeComboBox.addItems(self.firFilters)
+
+ # If the last filter type was valid for this window type,
+ # go back to it; otherwise, reset
+ try:
+ index = self.optFilters.index(currenttype)
+ self.gui.filterTypeComboBox.setCurrentIndex(index)
+ except ValueError:
+ pass
+
+ # Tell gui its ok to start sending this signal again
+ self.gui.filterTypeComboBox.blockSignals(False)
+
def design(self):
ret = True
fs,r = self.gui.sampleRateEdit.text().toDouble()