casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtDBusViewerAdaptor.qo.h
Go to the documentation of this file.
1 //# QtDBusViewerAdaptor.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 QTDBUSVIEWERADAPTOR_QO_H_
29 #define QTDBUSVIEWERADAPTOR_QO_H_
30 
31 #include <map>
32 #include <limits>
34 #include <casa/namespace.h>
35 #include <QVariantMap>
37 
38 namespace casa {
39 
40  class QtDisplayData;
41  class QtDisplayPanel;
42  class QtDisplayPanelGui;
43 
44  class QtDBusViewerAdaptor : public QDBusAbstractAdaptor, public QtDBusApp {
45  Q_OBJECT
46  Q_CLASSINFO("D-Bus Interface", "edu.nrao.casa.viewer")
47 
48  public:
49 
50  QString dbusName( ) const {
51  return QString(QtViewer::name( ));
52  }
53  bool connectToDBus( const QString &dbus_name="" ) {
54  return QtDBusApp::connectToDBus( parent(), dbus_name );
55  }
56 
57  // Constructor which takes the application.
59 
60  // Destructor.
62 
63  public slots:
64 
65  QDBusVariant start_interact( const QDBusVariant &input, int panel );
66  QDBusVariant datarange( const QList<double> &range, int data=0 );
67  QDBusVariant contourlevels( const QList<double> &levels,
68  double baselevel=2147483648.0,
69  double unitlevel=2147483648.0, int panel_or_data=0 );
70  QDBusVariant contourcolor( const QString &color, int panel_or_data=0 );
71  QDBusVariant contourthickness( double thickness, int panel_or_data=0 );
72  QDBusVariant axes( const QString &x = "", const QString &y = "", const QString &z = "", int panel=0 );
73  QDBusVariant colormap( const QString &map, int panel_or_data=0 );
74  QDBusVariant colorwedge( bool show=true, int panel_or_data=0 );
75 
76  QDBusVariant load( const QString &path, const QString &displaytype = "raster", int panel=0, double scaling=0 );
77  QDBusVariant reload( int panel_or_data );
78  QDBusVariant unload( int data );
79 
80  QDBusVariant restore( const QString &path, int panel=0 );
81 
82  QDBusVariant panel( const QString &type="viewer", bool hidden=false );
83  QDBusVariant hide( int panel=0 );
84  QDBusVariant show( int panel=0 );
85  QDBusVariant close( int panel=0 );
86  QDBusVariant popup( const QString &what, int panel=0 );
87 
88  QDBusVariant cwd( const QString &new_path = "" );
89 
90  QDBusVariant freeze( int panel=0 );
91  QDBusVariant unfreeze( int panel=0 );
92 
93  QDBusVariant channel( int num=-1, int panel=0 );
94  QDBusVariant zoom( int level, int panel=0 );
95  QDBusVariant zoom( const QList<double> &blc, const QList<double> &trc, const QString &coordinates="pixel", int panel=0 );
96 
97  // like "close()", but leaves the closing up to the user if the window is not hidden
98  QDBusVariant release( int panel );
99  //To change certain things so the panel
100  QDBusVariant setoptions( const QDBusVariant &input, int panel);
101  // device: file name or printer name
102  // devicetype: "file", "printer", or "ghostscript"
103  // format: "jpg", "pdf", "eps", "ps", "png", "xbm", "xpm", "ppm"
104  // [only used with devicetype == "file"] [extension on device, e.g. "outfile.pdf" overrides "format"]
105  // scale: size scale factor for raster output (e.g. jpg etc.)
106  // dpi: resolution of PS or EPS images
107  // orientation: "portrait", "landscape"
108  // media: "letter" or "a4"
109  bool output( const QString &device, const QString &devicetype = "file", int panel = 0,
110  double scale = 1.0, int dpi = 300, const QString &format = "jpg",
111  const QString &orientation = "portrait", const QString &media = "letter" );
112 
113 
114  QDBusVariant fileinfo( const QString &path );
115  QStringList keyinfo( int );
116 
117  bool done( );
118 
119  signals:
120  void interact( QDBusVariant );
121  void exiting( QDBusVariant );
122 
123  protected slots:
124 
125  void handle_interact( QVariant );
126  void handle_destroyed_panel(QObject*);
127 
128  private:
129 
130  inline QDBusVariant error( const QString &message ) {
131  QMap<QString,QVariant> err;
132  err["*error*"] = message;
133  return QDBusVariant(QVariant(err));
134  }
135 
136  class data_desc {
137  public:
138  data_desc( int idx, const QString &pathx, const QString &typex,
139  QtDisplayData *ddx, QtDisplayPanelGui *dpx ) :
140  id_(idx), path_(pathx), type_(typex), dd_(ddx), dp_(dpx) { }
141 
142  data_desc( int idx ) : id_(idx), dd_(0) { }
143  data_desc( ) : id_(0), dd_(0) { }
144 
145  int &id( ) {
146  return id_;
147  }
148  int id( ) const {
149  return id_;
150  }
151  QString &path( ) {
152  return path_;
153  }
154  const QString &path( ) const {
155  return path_;
156  }
157  QString &type( ) {
158  return type_;
159  }
160  const QString &type( ) const {
161  return type_;
162  }
164  return dd_;
165  }
166  const QtDisplayData *data( ) const {
167  return dd_;
168  }
170  return dp_;
171  }
172  const QtDisplayPanelGui *panel( ) const {
173  return dp_;
174  }
175 
176  private:
177  int id_;
178  QString path_;
179  QString type_;
182 
183  // QtDisplayData does not have a copy constructor...
184  // wonder if we'll need to copy our descriptor...
185  data_desc( const data_desc &other);
186  data_desc &operator=( const data_desc &);
187  };
188 
189 
190  class panel_desc {
191  public:
192 
194 
195  std::list<int> &data( ) {
196  return data_;
197  }
198  const std::list<int> &data( ) const {
199  return data_;
200  }
202  return panel_;
203  }
204  const QtDisplayPanelGui *panel( ) const {
205  return panel_;
206  }
207 
208  private:
209  std::list<int> data_;
211  };
212 
213 
215 
216  bool printps( QtDisplayPanel *panel, const QString &type, const QString &file, int dpi,
217  const QString &orientation, const QString &media );
218  bool printraster( QtDisplayPanel *panel, const QString &type, const QString &file, double scale );
219  void adjusteps( const char *from, const char *to, const QSize &wcmax, const QRect &viewport );
220 
221  typedef std::map<int,panel_desc*> panelmap;
222  typedef std::map<int,data_desc*> datamap;
225 
226  int get_id( QtDisplayPanelGui *, QtDisplayData *, const QString &path, const QString &type );
227  int get_id( QtDisplayPanelGui * );
228  QtDisplayPanelGui *findpanel( int key, bool create=true );
229  QtDisplayData *finddata( int key );
230 
231  protected:
233  void load_data( QtDisplayPanelGui *panel, int index );
234  void unload_data( QtDisplayPanelGui *panel, int index, bool erase=true );
236  void erase_data( int );
237 
238  };
239 
240 }
241 
242 #endif
void load_data(QtDisplayPanelGui *panel, int index)
virtual bool connectToDBus(const QString &dbus_name="")=0
Connects to the DBus server using the name provided (if non-null).
data_desc(int idx, const QString &pathx, const QString &typex, QtDisplayData *ddx, QtDisplayPanelGui *dpx)
data_desc & operator=(const data_desc &)
bool printps(QtDisplayPanel *panel, const QString &type, const QString &file, int dpi, const QString &orientation, const QString &media)
QDBusVariant show(int panel=0)
Qt implementation of main viewer supervisory object – Gui level.
Definition: QtViewer.qo.h:79
bool printraster(QtDisplayPanel *panel, const QString &type, const QString &file, double scale)
void handle_destroyed_panel(QObject *)
QDBusVariant start_interact(const QDBusVariant &input, int panel)
QDBusVariant freeze(int panel=0)
virtual Type type()
Return the type enum.
const QtDisplayData * data() const
QDBusVariant contourlevels(const QList< double > &levels, double baselevel=2147483648.0, double unitlevel=2147483648.0, int panel_or_data=0)
std::map< int, data_desc * > datamap
QDBusVariant error(const QString &message)
void unload_data(QtDisplayPanelGui *panel, int index, bool erase=true)
QDBusVariant datarange(const QList< double > &range, int data=0)
QDBusVariant restore(const QString &path, int panel=0)
QDBusVariant load(const QString &path, const QString &displaytype="raster", int panel=0, double scaling=0)
QDBusVariant unload(int data)
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
QStringList keyinfo(int)
QtDisplayPanelGui * create_panel()
QtDBusViewerAdaptor(QtViewer *)
Constructor which takes the application.
bool connectToDBus(const QString &dbus_name="")
Connects to the DBus server using the name provided (if non-null).
QDBusVariant popup(const QString &what, int panel=0)
QDBusVariant reload(int panel_or_data)
QDBusVariant release(int panel)
like &quot;close()&quot;, but leaves the closing up to the user if the window is not hidden ...
QDBusVariant fileinfo(const QString &path)
std::string path(const std::string &name)
QDBusVariant unfreeze(int panel=0)
int get_id(QtDisplayPanelGui *, QtDisplayData *, const QString &path, const QString &type)
void handle_interact(QVariant)
The main display window for the Qt version of the viewer.
QtDisplayPanelGui * findpanel(int key, bool create=true)
QDBusVariant hide(int panel=0)
void adjusteps(const char *from, const char *to, const QSize &wcmax, const QRect &viewport)
QtDisplayData * finddata(int key)
QDBusVariant colormap(const QString &map, int panel_or_data=0)
static const QString & name()
name used to initialize connection to dbus
QDBusVariant axes(const QString &x="", const QString &y="", const QString &z="", int panel=0)
QDBusVariant zoom(int level, int panel=0)
void exiting(QDBusVariant)
std::map< int, panel_desc * > panelmap
const QtDisplayPanelGui * panel() const
QDBusVariant contourthickness(double thickness, int panel_or_data=0)
QDBusVariant channel(int num=-1, int panel=0)
QDBusVariant contourcolor(const QString &color, int panel_or_data=0)
QDBusVariant setoptions(const QDBusVariant &input, int panel)
To change certain things so the panel.
const QtDisplayPanelGui * panel() const
QDBusVariant colorwedge(bool show=true, int panel_or_data=0)
QDBusVariant close(int panel=0)
QtDisplayPanelGui * erase_panel(int panel)
const std::list< int > & data() const
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
QDBusVariant cwd(const QString &new_path="")
void interact(QDBusVariant)
QDBusVariant panel(const QString &type="viewer", bool hidden=false)
~QtDBusViewerAdaptor()
Destructor.
bool output(const QString &device, const QString &devicetype="file", int panel=0, double scale=1.0, int dpi=300, const QString &format="jpg", const QString &orientation="portrait", const QString &media="letter")
device: file name or printer name devicetype: &quot;file&quot;, &quot;printer&quot;, or &quot;ghostscript&quot; format: &quot;jpg&quot;...
Defines nreal time structures used by the VLA table filler.
Definition: nreal.h:100