GNU Radio 3.7.1 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 <gnuradio/qtgui/api.h>
00028 #include <QtGui/QtGui>
00029 #include <vector>
00030 
00031 #include <qwt_plot_grid.h>
00032 #include <qwt_plot_layout.h>
00033 
00034 #include <gnuradio/qtgui/DisplayPlot.h>
00035 #include <gnuradio/qtgui/form_menus.h>
00036 
00037 /*!
00038  * \brief Base class for setting up and  managing QTGUI plot forms.
00039  * \ingroup qtgui_blk
00040  */
00041 class QTGUI_API DisplayForm : public QWidget
00042 {
00043   Q_OBJECT
00044 
00045   public:
00046   DisplayForm(int nplots=1, QWidget* parent = 0);
00047   ~DisplayForm();
00048 
00049   virtual DisplayPlot* getPlot() = 0;
00050   void Reset();
00051   bool isClosed() const;
00052 
00053   void enableMenu(bool en=true);
00054 
00055 public slots:
00056   void resizeEvent( QResizeEvent * e );
00057   void mousePressEvent( QMouseEvent * e);
00058   virtual void customEvent( QEvent * e ) = 0;
00059 
00060   void closeEvent( QCloseEvent * e );
00061 
00062   void setUpdateTime(double t);
00063 
00064   void setTitle(const QString &title);
00065   void setLineLabel(int which, const QString &label);
00066   void setLineColor(int which, const QString &color);
00067   void setLineWidth(int which, int width);
00068   void setLineStyle(int which, Qt::PenStyle style);
00069   void setLineMarker(int which, QwtSymbol::Style style);
00070   void setMarkerAlpha(int which, int alpha);
00071 
00072   QString title();
00073   QString lineLabel(int which);
00074   QString lineColor(int which);
00075   int lineWidth(int which);
00076   Qt::PenStyle lineStyle(int which);
00077   QwtSymbol::Style lineMarker(int which);
00078   int markerAlpha(int which);
00079 
00080   virtual void setSampleRate(const QString &rate);
00081 
00082   void setStop(bool on);
00083   void setStop();
00084 
00085   void setGrid(bool on);
00086 
00087   void saveFigure();
00088 
00089 private slots:
00090   virtual void newData(const QEvent*) = 0;
00091   virtual void autoScale(bool) = 0;
00092   void updateGuiTimer();
00093 
00094   void onPlotPointSelected(const QPointF p);
00095 
00096 signals:
00097   void plotPointSelected(const QPointF p, int type);
00098 
00099 protected:
00100   bool _isclosed;
00101 
00102   int _nplots;
00103 
00104   QGridLayout *_layout;
00105   DisplayPlot* _displayPlot;
00106   bool _systemSpecifiedFlag;
00107 
00108   QwtPlotGrid *_grid;
00109 
00110   bool   _menu_on;
00111   QMenu *_menu;
00112 
00113   QAction *_stop_act;
00114   bool _stop_state;
00115   QAction *_grid_act;
00116   bool _grid_state;
00117 
00118   QAction *_autoscale_act;
00119   bool _autoscale_state;
00120 
00121   QList<QMenu*> _lines_menu;
00122   QList<LineTitleAction*> _line_title_act;
00123   QList<LineColorMenu*> _line_color_menu;
00124   QList<LineWidthMenu*> _line_width_menu;
00125   QList<LineStyleMenu*> _line_style_menu;
00126   QList<LineMarkerMenu*> _line_marker_menu;
00127   QList<MarkerAlphaMenu*> _marker_alpha_menu;
00128 
00129   PopupMenu *_samp_rate_act;
00130   QAction *_save_act;
00131 
00132   QTimer *d_displayTimer;
00133   double d_update_time;
00134 };
00135 
00136 #endif /* DISPLAY_FORM_H */