Adding a phase and group delay plot to the GUI.
authorTom <trondeau@vt.edu>
Mon, 24 Aug 2009 01:19:12 +0000 (21:19 -0400)
committerTom <trondeau@vt.edu>
Mon, 24 Aug 2009 01:19:12 +0000 (21:19 -0400)
gr-utils/src/python/gr_filter_design.py
gr-utils/src/python/pyqt_filter.py
gr-utils/src/python/pyqt_filter.ui

index cce04c881dfb1d09fa8a82cf615aa039a8d88ca5..cc24afbba7268e48089a27757977651ae0c99568 100755 (executable)
@@ -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)
         
index c848dbd1b90d3255a54a259f4e6a788cd0e361d4..01523264307096c435536fc088c7f1ed76003301 100644 (file)
@@ -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))
index 69d57077581a58b2bc62c11f6c9f158a3ac42415..773b4cca92fb38f6a3558762682b3eb9d256833c 100644 (file)
          </widget>
          <widget class="QWidget" name="firhpfPage">
           <layout class="QFormLayout" name="formLayout_3">
+           <property name="fieldGrowthPolicy">
+            <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+           </property>
            <item row="0" column="0">
             <widget class="QLabel" name="endofHpfStopBandLabel">
              <property name="text">
          </widget>
         </widget>
        </item>
+       <item>
+        <widget class="QGroupBox" name="sysParamsBox">
+         <property name="title">
+          <string>System Parameters</string>
+         </property>
+         <layout class="QFormLayout" name="formLayout_4">
+          <item row="1" column="1">
+           <widget class="QLineEdit" name="nfftEdit"/>
+          </item>
+          <item row="1" column="0">
+           <widget class="QLabel" name="nfftLabel">
+            <property name="text">
+             <string>Num FFT points</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
        <item>
         <widget class="QPushButton" name="designButton">
          <property name="minimumSize">
         </item>
        </layout>
       </widget>
+      <widget class="QWidget" name="phaseTab">
+       <attribute name="title">
+        <string>Phase</string>
+       </attribute>
+       <layout class="QHBoxLayout" name="horizontalLayout_3">
+        <item>
+         <widget class="QwtPlot" name="phasePlot"/>
+        </item>
+       </layout>
+      </widget>
+      <widget class="QWidget" name="groupTab">
+       <attribute name="title">
+        <string>Group Delay</string>
+       </attribute>
+       <layout class="QHBoxLayout" name="horizontalLayout_4">
+        <item>
+         <widget class="QwtPlot" name="groupPlot"/>
+        </item>
+       </layout>
+      </widget>
      </widget>
     </item>
    </layout>