casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtDBusPlotSvrAdaptor.qo.h
Go to the documentation of this file.
1 //# QtDBusPlotSvrAdaptor.qo.h: provides viewer services via dbus
2 //# Copyright (C) 2009
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef QTDBUSPLOTSVRADAPTOR_QO_H_
29 #define QTDBUSPLOTSVRADAPTOR_QO_H_
30 
31 #include <map>
33 #include <QVariantMap>
34 #include <QString>
36 #include <qwt_plot_spectrogram.h>
37 
38 class QwtPlotItem;
39 class QDockWidget;
40 
41 namespace casa {
42 
43  class QtPlotSvrPanel;
44 
45  class QtDBusPlotSvrAdaptor : public QDBusAbstractAdaptor, public QtDBusApp {
46  Q_OBJECT
47  Q_CLASSINFO("D-Bus Interface", "edu.nrao.casa.plotserver")
48  public:
49 
50  // name used to initialize connection to dbus
51  QString dbusName( ) const { return QtPlotServer::name( ); }
52  bool connectToDBus( const QString &dbus_name="" )
53  { return QtDBusApp::connectToDBus( parent(), dbus_name ); }
54 
57 
58  public slots:
59 
60  QDBusVariant panel( const QString &title, const QString &xlabel="", const QString &ylabel="", const QString &window_title="",
61  const QList<int> &size=QList<int>( ), const QString &legend="bottom", const QString &zoom="bottom",
62  int with_panel=0, bool new_row=false, bool hidden=false );
63  QStringList colors( );
64  QStringList colormaps( );
65  QStringList symbols( );
66  QDBusVariant line( const QList<double> &x, const QList<double> &y, const QString &color="black",
67  const QString &label="", int panel=0 );
68  QDBusVariant scatter( const QList<double> &x, const QList<double> &y, const QString &color="black",
69  const QString &label="", const QString &symbol="", int symbol_size=-1, int dot_size=-1, int panel=0 );
70  QDBusVariant histogram( const QList<double> &values, int bins=0, const QString &color="blue", const QString &label="", int panel=0 );
71  QDBusVariant raster( const QList<double> &matrix, int sizex, int sizey, const QString &colormap="Rainbow 2", int panel=0 );
72 
73 
74  QDBusVariant setlabel( const QString &xlabel="", const QString &ylabel="", const QString &title="", int panel_id=0 );
75 
76  QDBusVariant erase( int data=0 );
77  QDBusVariant close( int panel=0 );
78  QDBusVariant release( int panel=0 );
79 
80  QDBusVariant hide( int panel );
81  QDBusVariant show( int panel );
82 
83  QDBusVariant loaddock( const QString &file_or_xml, const QString &loc="top", const QStringList &dockable=QStringList( ), int panel=0 );
84 
85  void done( );
86 
87  protected slots:
88 
89  void emit_button( QtPlotSvrPanel*, QString name );
90  void emit_check( QtPlotSvrPanel*, QString name, int );
91  void emit_radio( QtPlotSvrPanel*, QString name, bool );
92  void emit_linetext( QtPlotSvrPanel*, QString name, const QString &value );
93  void emit_slidevalue( QtPlotSvrPanel*, QString name, int );
94  void emit_closing( QtPlotSvrPanel*, bool gone );
95 
96  signals:
97 
98  void button( int panel, QString name );
99  void check( int panel, QString name, int value );
100  void radio( int panel, QString name, bool value );
101  void linetext( int panel, QString name, const QString &value );
102  void slidevalue( int panel, QString name, int value );
103 
104  void closing( int panel, bool gone );
105  void exiting( );
106 
107  private:
108 
109  inline QDBusVariant error( const QString &message ) {
110  QMap<QString,QVariant> err;
111  err["*error*"] = message;
112  return QDBusVariant(QVariant(err));
113  }
114 
115  class panel_desc {
116  public:
117 
119 
120  std::list<int> &data( ) { return data_; }
121  const std::list<int> &data( ) const { return data_; }
122  QtPlotSvrPanel *&panel( ) { return panel_; }
123  const QtPlotSvrPanel *panel( ) const { return panel_; }
124 
125  ~panel_desc( ) { }
126 
127  private:
128  std::list<int> data_;
130  };
131 
132 
133  class data_desc {
134  public:
135 
136  data_desc( int index, QtPlotSvrPanel *panel, QwtPlotItem *data ) : id_(index), data_(data), panel_(panel) { }
137 
138  int &id( ) { return id_; }
139  int id( ) const { return id_; }
140  QwtPlotItem *&data( ) { return data_; }
141  const QwtPlotItem *data( ) const { return data_; }
142  QtPlotSvrPanel *&panel( ) { return panel_; }
143  const QtPlotSvrPanel *panel( ) const { return panel_; }
144  ~data_desc( ) { delete data_; }
145 
146  private:
147  int id_;
148  QwtPlotItem *data_;
150 
151  // QtDisplayData does not have a copy constructor...
152  // wonder if we'll need to copy our descriptor...
153  data_desc( const data_desc &other);
154  data_desc &operator=( const data_desc &);
155  };
156 
157  int get_id( QtPlotSvrPanel *panel );
158  int get_id( QtPlotSvrPanel *panel, QwtPlotItem *data );
159 
160  void close_everything( );
161  void release_everything( );
163 
164  typedef std::map<int,panel_desc*> panelmap;
165  typedef std::map<int,data_desc*> datamap;
166  typedef std::map<int,QDockWidget*> dockmap;
167 
171 
172  void release( panelmap::iterator & );
173  };
174 
175 }
176 #endif
std::map< int, data_desc * > datamap
const std::list< int > & data() const
virtual bool connectToDBus(const QString &dbus_name="")=0
Connects to the DBus server using the name provided (if non-null).
QDBusVariant show(int panel)
QDBusVariant erase(int data=0)
QtDBusPlotSvrAdaptor(QtPlotServer *)
std::map< int, QDockWidget * > dockmap
void radio(int panel, QString name, bool value)
bool connectToDBus(const QString &dbus_name="")
Connects to the DBus server using the name provided (if non-null).
void linetext(int panel, QString name, const QString &value)
QDBusVariant panel(const QString &title, const QString &xlabel="", const QString &ylabel="", const QString &window_title="", const QList< int > &size=QList< int >(), const QString &legend="bottom", const QString &zoom="bottom", int with_panel=0, bool new_row=false, bool hidden=false)
QDBusVariant close(int panel=0)
std::map< int, panel_desc * > panelmap
void check(int panel, QString name, int value)
QDBusVariant release(int panel=0)
QDBusVariant histogram(const QList< double > &values, int bins=0, const QString &color="blue", const QString &label="", int panel=0)
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
QDBusVariant hide(int panel)
size_t size() const
data_desc & operator=(const data_desc &)
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
QDBusVariant loaddock(const QString &file_or_xml, const QString &loc="top", const QStringList &dockable=QStringList(), int panel=0)
static const QString & name()
name used to initialize connection to dbus
QDBusVariant 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, int panel=0)
int get_id(QtPlotSvrPanel *panel)
void slidevalue(int panel, QString name, int value)
void emit_slidevalue(QtPlotSvrPanel *, QString name, int)
data_desc(int index, QtPlotSvrPanel *panel, QwtPlotItem *data)
QString dbusName() const
name used to initialize connection to dbus
QDBusVariant raster(const QList< double > &matrix, int sizex, int sizey, const QString &colormap="Rainbow 2", int panel=0)
QDBusVariant line(const QList< double > &x, const QList< double > &y, const QString &color="black", const QString &label="", int panel=0)
QDBusVariant setlabel(const QString &xlabel="", const QString &ylabel="", const QString &title="", int panel_id=0)
const QtPlotSvrPanel * panel() const
void emit_check(QtPlotSvrPanel *, QString name, int)
void emit_radio(QtPlotSvrPanel *, QString name, bool)
void emit_closing(QtPlotSvrPanel *, bool gone)
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
void closing(int panel, bool gone)
void emit_button(QtPlotSvrPanel *, QString name)
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
void button(int panel, QString name)
QDBusVariant error(const QString &message)
void emit_linetext(QtPlotSvrPanel *, QString name, const QString &value)