From aafbdf432b547529bea9ebe9ce2ad4c77ab20f03 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 23 Aug 2009 21:19:12 -0400 Subject: [PATCH] Adding a phase and group delay plot to the GUI. --- gr-utils/src/python/gr_filter_design.py | 28 +++++++++++++++-- gr-utils/src/python/pyqt_filter.py | 36 +++++++++++++++++++-- gr-utils/src/python/pyqt_filter.ui | 42 +++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 4 deletions(-) diff --git a/gr-utils/src/python/gr_filter_design.py b/gr-utils/src/python/gr_filter_design.py index cce04c88..cc24afbb 100755 --- a/gr-utils/src/python/gr_filter_design.py +++ b/gr-utils/src/python/gr_filter_design.py @@ -39,9 +39,15 @@ class gr_plot_filter(QtGui.QMainWindow): Qt.SIGNAL("currentChanged(int)"), self.tab_changed) + self.connect(self.gui.nfftEdit, + Qt.SIGNAL("textEdited(QString)"), + self.nfft_edit_changed) + self.gui.designButton.setShortcut("Return") self.taps = [] + self.nfftpts = int(10000) + self.gui.nfftEdit.setText(Qt.QString("%1").arg(self.nfftpts)) self.gui.lpfPassBandRippleLabel.setVisible(False) self.gui.lpfPassBandRippleEdit.setVisible(False) @@ -73,6 +79,18 @@ class gr_plot_filter(QtGui.QMainWindow): Qwt.QwtPicker.AlwaysOn, self.gui.freqPlot.canvas()) + self.phaseZoomer = Qwt.QwtPlotZoomer(self.gui.phasePlot.xBottom, + self.gui.phasePlot.yLeft, + Qwt.QwtPicker.PointSelection, + Qwt.QwtPicker.AlwaysOn, + self.gui.phasePlot.canvas()) + + self.groupZoomer = Qwt.QwtPlotZoomer(self.gui.groupPlot.xBottom, + self.gui.groupPlot.yLeft, + Qwt.QwtPicker.PointSelection, + Qwt.QwtPicker.AlwaysOn, + self.gui.groupPlot.canvas()) + # Set up pen for colors and line width blue = QtGui.qRgb(0x00, 0x00, 0xFF) blueBrush = Qt.QBrush(Qt.QColor(blue)) @@ -151,7 +169,7 @@ class gr_plot_filter(QtGui.QMainWindow): if(r): self.update_time_curves(taps) - self.update_freq_curves(taps) + self.update_freq_curves(taps, self.nfftpts) # Filter design functions using a window @@ -269,9 +287,15 @@ class gr_plot_filter(QtGui.QMainWindow): else: return ([],r) + def nfft_edit_changed(self, nfft): + infft,r = nfft.toInt() + if(r and (infft != self.nfftpts)): + self.nfftpts = infft + self.update_freq_curves(self.taps, self.nfftpts) + def tab_changed(self, tab): if(tab == 0): - self.update_freq_curves(self.taps) + self.update_freq_curves(self.taps, self.nfftpts) if(tab == 1): self.update_time_curves(self.taps) diff --git a/gr-utils/src/python/pyqt_filter.py b/gr-utils/src/python/pyqt_filter.py index c848dbd1..01523264 100644 --- a/gr-utils/src/python/pyqt_filter.py +++ b/gr-utils/src/python/pyqt_filter.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'pyqt_filter.ui' # -# Created: Sun Aug 23 18:03:28 2009 +# Created: Sun Aug 23 21:18:30 2009 # by: PyQt4 UI code generator 4.4.4 # # WARNING! All changes made in this file will be lost! @@ -132,6 +132,7 @@ class Ui_MainWindow(object): self.firhpfPage = QtGui.QWidget() self.firhpfPage.setObjectName("firhpfPage") self.formLayout_3 = QtGui.QFormLayout(self.firhpfPage) + self.formLayout_3.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) self.formLayout_3.setObjectName("formLayout_3") self.endofHpfStopBandLabel = QtGui.QLabel(self.firhpfPage) self.endofHpfStopBandLabel.setObjectName("endofHpfStopBandLabel") @@ -159,6 +160,17 @@ class Ui_MainWindow(object): self.formLayout_3.setWidget(3, QtGui.QFormLayout.FieldRole, self.hpfPassBandRippleEdit) self.filterTypeWidget.addWidget(self.firhpfPage) self.verticalLayout.addWidget(self.filterTypeWidget) + self.sysParamsBox = QtGui.QGroupBox(self.filterFrame) + self.sysParamsBox.setObjectName("sysParamsBox") + self.formLayout_4 = QtGui.QFormLayout(self.sysParamsBox) + self.formLayout_4.setObjectName("formLayout_4") + self.nfftEdit = QtGui.QLineEdit(self.sysParamsBox) + self.nfftEdit.setObjectName("nfftEdit") + self.formLayout_4.setWidget(1, QtGui.QFormLayout.FieldRole, self.nfftEdit) + self.nfftLabel = QtGui.QLabel(self.sysParamsBox) + self.nfftLabel.setObjectName("nfftLabel") + self.formLayout_4.setWidget(1, QtGui.QFormLayout.LabelRole, self.nfftLabel) + self.verticalLayout.addWidget(self.sysParamsBox) self.designButton = QtGui.QPushButton(self.filterFrame) self.designButton.setMinimumSize(QtCore.QSize(0, 0)) self.designButton.setMaximumSize(QtCore.QSize(200, 16777215)) @@ -186,6 +198,22 @@ class Ui_MainWindow(object): self.timePlot.setObjectName("timePlot") self.horizontalLayout.addWidget(self.timePlot) self.tabGroup.addTab(self.timeTab, "") + self.phaseTab = QtGui.QWidget() + self.phaseTab.setObjectName("phaseTab") + self.horizontalLayout_3 = QtGui.QHBoxLayout(self.phaseTab) + self.horizontalLayout_3.setObjectName("horizontalLayout_3") + self.phasePlot = Qwt5.QwtPlot(self.phaseTab) + self.phasePlot.setObjectName("phasePlot") + self.horizontalLayout_3.addWidget(self.phasePlot) + self.tabGroup.addTab(self.phaseTab, "") + self.groupTab = QtGui.QWidget() + self.groupTab.setObjectName("groupTab") + self.horizontalLayout_4 = QtGui.QHBoxLayout(self.groupTab) + self.horizontalLayout_4.setObjectName("horizontalLayout_4") + self.groupPlot = Qwt5.QwtPlot(self.groupTab) + self.groupPlot.setObjectName("groupPlot") + self.horizontalLayout_4.addWidget(self.groupPlot) + self.tabGroup.addTab(self.groupTab, "") self.gridLayout.addWidget(self.tabGroup, 1, 1, 1, 1) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) @@ -206,7 +234,7 @@ class Ui_MainWindow(object): self.retranslateUi(MainWindow) self.filterTypeWidget.setCurrentIndex(2) - self.tabGroup.setCurrentIndex(0) + self.tabGroup.setCurrentIndex(3) QtCore.QObject.connect(self.action_exit, QtCore.SIGNAL("activated()"), MainWindow.close) QtCore.QMetaObject.connectSlotsByName(MainWindow) MainWindow.setTabOrder(self.filterTypeComboBox, self.filterDesignTypeComboBox) @@ -259,9 +287,13 @@ class Ui_MainWindow(object): self.startofHpfPassBandLabel.setText(QtGui.QApplication.translate("MainWindow", "Start of Pass Band (Hz)", None, QtGui.QApplication.UnicodeUTF8)) self.hpfStopBandAttenLabel.setText(QtGui.QApplication.translate("MainWindow", "Stop Band Attenuation (dB)", None, QtGui.QApplication.UnicodeUTF8)) self.hpfPassBandRippleLabel.setText(QtGui.QApplication.translate("MainWindow", "Pass Band Ripple (dB)", None, QtGui.QApplication.UnicodeUTF8)) + self.sysParamsBox.setTitle(QtGui.QApplication.translate("MainWindow", "System Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.nfftLabel.setText(QtGui.QApplication.translate("MainWindow", "Num FFT points", None, QtGui.QApplication.UnicodeUTF8)) self.designButton.setText(QtGui.QApplication.translate("MainWindow", "Design", None, QtGui.QApplication.UnicodeUTF8)) self.tabGroup.setTabText(self.tabGroup.indexOf(self.freqTab), QtGui.QApplication.translate("MainWindow", "Frequency Domain", None, QtGui.QApplication.UnicodeUTF8)) self.tabGroup.setTabText(self.tabGroup.indexOf(self.timeTab), QtGui.QApplication.translate("MainWindow", "Time Domain", None, QtGui.QApplication.UnicodeUTF8)) + self.tabGroup.setTabText(self.tabGroup.indexOf(self.phaseTab), QtGui.QApplication.translate("MainWindow", "Phase", None, QtGui.QApplication.UnicodeUTF8)) + self.tabGroup.setTabText(self.tabGroup.indexOf(self.groupTab), QtGui.QApplication.translate("MainWindow", "Group Delay", None, QtGui.QApplication.UnicodeUTF8)) self.menu_File.setTitle(QtGui.QApplication.translate("MainWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) self.action_open.setText(QtGui.QApplication.translate("MainWindow", "&Open", None, QtGui.QApplication.UnicodeUTF8)) self.action_open.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+O", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/gr-utils/src/python/pyqt_filter.ui b/gr-utils/src/python/pyqt_filter.ui index 69d57077..773b4cca 100644 --- a/gr-utils/src/python/pyqt_filter.ui +++ b/gr-utils/src/python/pyqt_filter.ui @@ -259,6 +259,9 @@ + + QFormLayout::AllNonFixedFieldsGrow + @@ -303,6 +306,25 @@ + + + + System Parameters + + + + + + + + + Num FFT points + + + + + + @@ -362,6 +384,26 @@ + + + Phase + + + + + + + + + + Group Delay + + + + + + + -- 2.30.2