casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtPlotSvrPanel.qo.h
Go to the documentation of this file.
1 //# QtPlotSvrPanel.qo.h: Qt implementation of main 2D plot server display window.
2 //# with surrounding Gui functionality
3 //# Copyright (C) 2005
4 //# Associated Universities, Inc. Washington DC, USA.
5 //#
6 //# This library is free software; you can redistribute it and/or modify it
7 //# under the terms of the GNU Library General Public License as published by
8 //# the Free Software Foundation; either version 2 of the License, or (at your
9 //# option) any later version.
10 //#
11 //# This library is distributed in the hope that it will be useful, but WITHOUT
12 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 //# License for more details.
15 //#
16 //# You should have received a copy of the GNU Library General Public License
17 //# along with this library; if not, write to the Free Software Foundation,
18 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19 //#
20 //# Correspondence concerning AIPS++ should be addressed as follows:
21 //# Internet email: aips2-request@nrao.edu.
22 //# Postal address: AIPS++ Project Office
23 //# National Radio Astronomy Observatory
24 //# 520 Edgemont Road
25 //# Charlottesville, VA 22903-2475 USA
26 //#
27 //# $Id: QtDisplayPanelGui.qo.h,v 1.7 2006/10/10 21:42:05 dking Exp $
28 
29 #ifndef CASAQT_QTPLOTSRVPANEL_H
30 #define CASAQT_QTPLOTSRVPANEL_H
31 
32 #include <QMainWindow>
33 #include <QStringList>
34 #include <QColor>
35 #include <qwt_global.h>
36 #include <qwt_plot_curve.h>
37 #include <qwt_color_map.h>
38 #include <casaqt/QwtConfig.h>
42 #include <casadbus/types/ptr.h>
43 #include <map>
44 #include <vector>
45 
46 class QwtPlotCurve;
47 class QwtPlotSpectrogram;
48 class QVBoxLayout;
49 class QHBoxLayout;
50 class QSlider;
51 class QwtPlotZoomer;
52 
53 namespace casa {
54 
55  class QtPlotFrame;
56 
57  class QtPlotSvrMain : public QtPanelBase {
58  Q_OBJECT
59  public:
60  QtPlotSvrMain( QWidget */*parent*/=0 ) : QtPanelBase( ) { }
61 
62  signals:
63  void closing( bool );
64 
65  protected:
66  // scripted (via dbus) panels should override the closeEvent( ) and hide the gui
67  // instead of deleting it when it was created via a dbus script...
68  void closeEvent(QCloseEvent *event);
69  };
70 
71  class QtPlotSvrPanel : public QObject {
72  Q_OBJECT
73  public:
74 
75  void hide( );
76  void show( );
77  void closeMainPanel( );
78  bool isVisible( );
79  void releaseMainPanel( );
80 
81  QtPlotSvrPanel( QWidget *parent=0 );
82  QtPlotSvrPanel( const QString &title, const QString &xlabel="", const QString &ylabel="", const QString &window_title="",
83  const QList<int> &size=QList<int>( ), const QString &legend="bottom", const QString &zoom="bottom",
84  QtPlotSvrPanel *with_panel=0, bool new_row=false, QWidget *parent=0 );
85 
86  static QStringList colors( );
87  static QStringList colormaps( );
88  static QStringList symbols( );
89 
90  QwtPlotCurve *line( const QList<double> &x, const QList<double> &y, const QString &color="black", const QString &label="" );
91  QwtPlotCurve *scatter( const QList<double> &x, const QList<double> &y, const QString &color="black", const QString &label="",
92  const QString &symbol="", int symbol_size=-1, int dot_size=-1 );
93  QtPlotHistogram *histogram( const QList<double> &y, int bins=0, const QString &color="blue", const QString &label="" );
94  QwtPlotSpectrogram *raster( const QList<double> &matrix, int sizex, int sizey, const QString &colormap="Rainbow 2" );
95 
96  void replot( );
97 
98  void setxlabel( const QString &xlabel );
99  void setylabel( const QString &ylabel );
100  void settitle( const QString &title );
101  QwtLinearColorMap * getnewcolormap(const QString & colormap);
102 
103  std::pair<QDockWidget*,QString> loaddock( const QString &file_or_xml, const QString &loc, const QStringList &dockable );
104 
105  virtual ~QtPlotSvrPanel( ) { }
106 
107  signals:
108 
109  void button( QtPlotSvrPanel *, QString );
110  void check( QtPlotSvrPanel *, QString, int );
111  void radio( QtPlotSvrPanel *, QString, bool );
112  void linetext( QtPlotSvrPanel *, QString, const QString &text );
113  void slidevalue( QtPlotSvrPanel *, QString, int );
114 
115  void closing( QtPlotSvrPanel *, bool );
116 
117  protected slots:
118 
119  void emit_button( );
120  void emit_check( int );
121  void emit_radio( bool );
122  void emit_linetext( const QString &text );
123  void emit_slidevalue( int );
124 
125  void emit_closing( bool );
126 
127  void zoom( int x=-1 );
128 #ifdef QWT6
129  void zoomed( const QRectF & );
130 #else
131  void zoomed( const QwtDoubleRect & );
132 #endif
133 
134  protected:
135 
136  QWidget *loaddock( QString file );
137  QFont defaultfont;
138 
139  typedef std::map<QString,std::vector<QColor> > colormap_map;
140  static void load_colormaps( );
142 
143  private:
144 
145  class row_desc {
146  public:
147 
148  class plot_desc {
149  public:
150  plot_desc( QWidget *c, QLayout *l, QtPlotFrame *p, QSlider *s ) :
151  container_(c), layout_(l), plot_(p), slider_(s) { }
152  QWidget *&container( ) { return container_; }
153  QLayout *&layout( ) { return layout_; }
154  QtPlotFrame *&plot( ) { return plot_; }
155  QSlider *&slider( ) { return slider_; }
156 
157  private:
158  QWidget *container_;
159  QLayout *layout_;
161  QSlider *slider_;
162  };
163 
164  row_desc( QWidget *c, QHBoxLayout *l ) : container_(c), layout_(l), id_(QtId::get_id( )) { }
165  QWidget *container( ) { return container_; }
166  QHBoxLayout *layout( ) { return layout_; }
167  void addplot( QWidget *container, QLayout *layout, QtPlotFrame *plot, QSlider *slider )
168  { plots.push_back( new plot_desc(container, layout, plot, slider ) ); }
169  int id( ) { return id_; }
170  private:
171  typedef std::list<plot_desc*> plotlist;
173  QWidget *container_;
174  QHBoxLayout *layout_;
175  int id_;
176  };
177 
178  class win_desc {
179  public:
180  win_desc( QtPlotSvrMain *b, QWidget *c, QVBoxLayout *l ) : base_(b), container_(c), layout_(l) { }
181  QtPlotSvrMain *& base( ) { return base_; }
182  QWidget *&container( ) { return container_; }
183  QVBoxLayout *&layout( ) { return layout_; }
184  private:
186  QWidget *container_;
187  QVBoxLayout *layout_;
188  };
189 
190  typedef std::map<QtPlotSvrPanel*,memory::cptr<row_desc> > rowmap;
192 
194 
195  QSlider *slider;
197  QwtPlotZoomer *zoomer;
200  };
201 }
202 
203 #endif
std::pair< QDockWidget *, QString > loaddock(const QString &file_or_xml, const QString &loc, const QStringList &dockable)
plot_desc(QWidget *c, QLayout *l, QtPlotFrame *p, QSlider *s)
static QStringList colormaps()
win_desc(QtPlotSvrMain *b, QWidget *c, QVBoxLayout *l)
std::list< plot_desc * > plotlist
void emit_closing(bool)
QtPlotHistogram * histogram(const QList< double > &y, int bins=0, const QString &color="blue", const QString &label="")
void closing(QtPlotSvrPanel *, bool)
static QStringList symbols()
void radio(QtPlotSvrPanel *, QString, bool)
void closeEvent(QCloseEvent *event)
scripted (via dbus) panels should override the closeEvent() and hide the gui instead of deleting it w...
void linetext(QtPlotSvrPanel *, QString, const QString &text)
void zoom(int x=-1)
QtPlotSvrPanel(QWidget *parent=0)
void setxlabel(const QString &xlabel)
std::map< QtPlotSvrPanel *, memory::cptr< row_desc > > rowmap
size_t size() const
void addplot(QWidget *container, QLayout *layout, QtPlotFrame *plot, QSlider *slider)
static QStringList colors()
row_desc(QWidget *c, QHBoxLayout *l)
void slidevalue(QtPlotSvrPanel *, QString, int)
void zoomed(const QwtDoubleRect &)
void emit_linetext(const QString &text)
void emit_slidevalue(int)
std::map< QString, std::vector< QColor > > colormap_map
void button(QtPlotSvrPanel *, QString)
QwtPlotZoomer * zoomer
static void load_colormaps()
static colormap_map * colormaps_
QwtPlotSpectrogram * raster(const QList< double > &matrix, int sizex, int sizey, const QString &colormap="Rainbow 2")
memory::cptr< rowmap > rows_
const Double c
Fundamental physical constants (SI units):
void settitle(const QString &title)
void setylabel(const QString &ylabel)
QwtPlotCurve * line(const QList< double > &x, const QList< double > &y, const QString &color="black", const QString &label="")
QtPlotSvrMain(QWidget *=0)
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the color(i.e.,"000000"for black) and
QwtPlotCurve * scatter(const QList< double > &x, const QList< double > &y, const QString &color="black", const QString &label="", const QString &symbol="", int symbol_size=-1, int dot_size=-1)
void check(QtPlotSvrPanel *, QString, int)
memory::cptr< win_desc > window_
QwtLinearColorMap * getnewcolormap(const QString &colormap)
Defines nreal time structures used by the VLA table filler.
Definition: nreal.h:100