GNU Radio 3.7.0 C++ API
displayform.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2012 Free Software Foundation, Inc.
00004  *
00005  * This file is part of GNU Radio
00006  *
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  *
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef DISPLAY_FORM_H
00024 #define DISPLAY_FORM_H
00025 
00026 #include <gnuradio/qtgui/spectrumUpdateEvents.h>
00027 #include <QtGui/QtGui>
00028 #include <vector>
00029 
00030 #include <qwt_plot_grid.h>
00031 #include <qwt_plot_layout.h>
00032 
00033 #include <gnuradio/qtgui/DisplayPlot.h>
00034 #include <gnuradio/qtgui/form_menus.h>
00035 
00036 /*!
00037  * \brief Base class for setting up and  managing QTGUI plot forms.
00038  * \ingroup qtgui_blk
00039  */
00040 class DisplayForm : public QWidget
00041 {
00042   Q_OBJECT
00043 
00044   public:
00045   DisplayForm(int nplots=1, QWidget* parent = 0);
00046   ~DisplayForm();
00047 
00048   virtual DisplayPlot* getPlot() = 0;
00049   void Reset();
00050   bool isClosed() const;
00051 
00052   void enableMenu(bool en=true);
00053 
00054 public slots:
00055   void resizeEvent( QResizeEvent * e );
00056   void mousePressEvent( QMouseEvent * e);
00057   virtual void customEvent( QEvent * e ) = 0;
00058 
00059   void closeEvent( QCloseEvent * e );
00060 
00061   void setUpdateTime(double t);
00062 
00063   void setTitle(const QString &title);
00064   void setLineLabel(int which, const QString &label);
00065   void setLineColor(int which, const QString &color);
00066   void setLineWidth(int which, int width);
00067   void setLineStyle(int which, Qt::PenStyle style);
00068   void setLineMarker(int which, QwtSymbol::Style style);
00069   void setMarkerAlpha(int which, int alpha);
00070 
00071   QString title();
00072   QString lineLabel(int which);
00073   QString lineColor(int which);
00074   int lineWidth(int which);
00075   Qt::PenStyle lineStyle(int which);
00076   QwtSymbol::Style lineMarker(int which);
00077   int markerAlpha(int which);
00078 
00079   virtual void setSampleRate(const QString &rate) = 0;
00080 
00081   void setStop(bool on);
00082   void setStop();
00083 
00084   void setGrid(bool on);
00085 
00086   void saveFigure();
00087 
00088 private slots:
00089   virtual void newData(const QEvent*) = 0;
00090   virtual void autoScale(bool) = 0;
00091   void updateGuiTimer();
00092 
00093   void onPlotPointSelected(const QPointF p);
00094 
00095 signals:
00096   void plotPointSelected(const QPointF p, int type);
00097 
00098 protected:
00099   bool _isclosed;
00100 
00101   int _nplots;
00102 
00103   QGridLayout *_layout;
00104   DisplayPlot* _displayPlot;
00105   bool _systemSpecifiedFlag;
00106 
00107   QwtPlotGrid *_grid;
00108 
00109   bool   _menu_on;
00110   QMenu *_menu;
00111 
00112   QAction *_stop_act;
00113   bool _stop_state;
00114   QAction *_grid_act;
00115   bool _grid_state;
00116 
00117   QAction *_autoscale_act;
00118   bool _autoscale_state;
00119 
00120   QList<QMenu*> _lines_menu;
00121   QList<LineTitleAction*> _line_title_act;
00122   QList<LineColorMenu*> _line_color_menu;
00123   QList<LineWidthMenu*> _line_width_menu;
00124   QList<LineStyleMenu*> _line_style_menu;
00125   QList<LineMarkerMenu*> _line_marker_menu;
00126   QList<MarkerAlphaMenu*> _marker_alpha_menu;
00127 
00128   PopupMenu *_samp_rate_act;
00129   QAction *_save_act;
00130 
00131   QTimer *d_displayTimer;
00132   double d_update_time;
00133 };
00134 
00135 #endif /* DISPLAY_FORM_H */