GNU Radio 3.7.1 C++ API
displayform.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef DISPLAY_FORM_H
24 #define DISPLAY_FORM_H
25 
27 #include <gnuradio/qtgui/api.h>
28 #include <QtGui/QtGui>
29 #include <vector>
30 
31 #include <qwt_plot_grid.h>
32 #include <qwt_plot_layout.h>
33 
36 
37 /*!
38  * \brief Base class for setting up and managing QTGUI plot forms.
39  * \ingroup qtgui_blk
40  */
41 class QTGUI_API DisplayForm : public QWidget
42 {
43  Q_OBJECT
44 
45  public:
46  DisplayForm(int nplots=1, QWidget* parent = 0);
47  ~DisplayForm();
48 
49  virtual DisplayPlot* getPlot() = 0;
50  void Reset();
51  bool isClosed() const;
52 
53  void enableMenu(bool en=true);
54 
55 public slots:
56  void resizeEvent( QResizeEvent * e );
57  void mousePressEvent( QMouseEvent * e);
58  virtual void customEvent( QEvent * e ) = 0;
59 
60  void closeEvent( QCloseEvent * e );
61 
62  void setUpdateTime(double t);
63 
64  void setTitle(const QString &title);
65  void setLineLabel(int which, const QString &label);
66  void setLineColor(int which, const QString &color);
67  void setLineWidth(int which, int width);
68  void setLineStyle(int which, Qt::PenStyle style);
69  void setLineMarker(int which, QwtSymbol::Style style);
70  void setMarkerAlpha(int which, int alpha);
71 
72  QString title();
73  QString lineLabel(int which);
74  QString lineColor(int which);
75  int lineWidth(int which);
76  Qt::PenStyle lineStyle(int which);
77  QwtSymbol::Style lineMarker(int which);
78  int markerAlpha(int which);
79 
80  virtual void setSampleRate(const QString &rate);
81 
82  void setStop(bool on);
83  void setStop();
84 
85  void setGrid(bool on);
86 
87  void saveFigure();
88 
89 private slots:
90  virtual void newData(const QEvent*) = 0;
91  virtual void autoScale(bool) = 0;
92  void updateGuiTimer();
93 
94  void onPlotPointSelected(const QPointF p);
95 
96 signals:
97  void plotPointSelected(const QPointF p, int type);
98 
99 protected:
100  bool _isclosed;
101 
102  int _nplots;
103 
104  QGridLayout *_layout;
107 
108  QwtPlotGrid *_grid;
109 
110  bool _menu_on;
111  QMenu *_menu;
112 
113  QAction *_stop_act;
115  QAction *_grid_act;
117 
118  QAction *_autoscale_act;
120 
121  QList<QMenu*> _lines_menu;
122  QList<LineTitleAction*> _line_title_act;
123  QList<LineColorMenu*> _line_color_menu;
124  QList<LineWidthMenu*> _line_width_menu;
125  QList<LineStyleMenu*> _line_style_menu;
126  QList<LineMarkerMenu*> _line_marker_menu;
127  QList<MarkerAlphaMenu*> _marker_alpha_menu;
128 
130  QAction *_save_act;
131 
132  QTimer *d_displayTimer;
134 };
135 
136 #endif /* DISPLAY_FORM_H */