QtDBusViewerAdaptor.qo.h

Go to the documentation of this file.
00001 //# QtDBusViewerAdaptor.qo.h: provides viewer services via dbus
00002 //# Copyright (C) 2009
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 
00028 #ifndef QTDBUSVIEWERADAPTOR_QO_H_
00029 #define QTDBUSVIEWERADAPTOR_QO_H_
00030 
00031 #include <map>
00032 #include <limits>
00033 #include <casaqt/QtUtilities/QtDBusXmlApp.qo.h>
00034 #include <casa/namespace.h>
00035 #include <QVariantMap>
00036 #include <display/QtViewer/QtViewer.qo.h>
00037 
00038 namespace casa {
00039 
00040         class QtDisplayData;
00041         class QtDisplayPanel;
00042         class QtDisplayPanelGui;
00043 
00044         class QtDBusViewerAdaptor : public QDBusAbstractAdaptor, public QtDBusApp {
00045                 Q_OBJECT
00046                 Q_CLASSINFO("D-Bus Interface", "edu.nrao.casa.viewer")
00047 
00048         public:
00049 
00050                 QString dbusName( ) const {
00051                         return QString(QtViewer::name( ));
00052                 }
00053                 bool connectToDBus( const QString &dbus_name="" ) {
00054                         return QtDBusApp::connectToDBus( parent(), dbus_name );
00055                 }
00056 
00057                 // Constructor which takes the application.
00058                 QtDBusViewerAdaptor( QtViewer * );
00059 
00060                 // Destructor.
00061                 ~QtDBusViewerAdaptor();
00062 
00063         public slots:
00064 
00065                 QDBusVariant start_interact( const QDBusVariant &input, int panel );
00066                 QDBusVariant datarange( const QList<double> &range, int data=0 );
00067                 QDBusVariant contourlevels( const QList<double> &levels,
00068                                             double baselevel=2147483648.0,
00069                                             double unitlevel=2147483648.0, int panel_or_data=0 );
00070                 QDBusVariant contourcolor( const QString &color, int panel_or_data=0 );
00071                 QDBusVariant contourthickness( double thickness, int panel_or_data=0 );
00072                 QDBusVariant axes( const QString &x = "", const QString &y = "", const QString &z = "", int panel=0 );
00073                 QDBusVariant colormap( const QString &map, int panel_or_data=0 );
00074                 QDBusVariant colorwedge( bool show=true, int panel_or_data=0 );
00075 
00076                 QDBusVariant load( const QString &path, const QString &displaytype = "raster", int panel=0, double scaling=0 );
00077                 QDBusVariant reload( int panel_or_data );
00078                 QDBusVariant unload( int data );
00079 
00080                 QDBusVariant restore( const QString &path, int panel=0 );
00081 
00082                 QDBusVariant panel( const QString &type="viewer", bool hidden=false  );
00083                 QDBusVariant hide( int panel=0 );
00084                 QDBusVariant show( int panel=0 );
00085                 QDBusVariant close( int panel=0 );
00086                 QDBusVariant popup( const QString &what, int panel=0 );
00087 
00088                 QDBusVariant cwd( const QString &new_path = "" );
00089 
00090                 QDBusVariant freeze( int panel=0 );
00091                 QDBusVariant unfreeze( int panel=0 );
00092 
00093                 QDBusVariant channel( int num=-1, int panel=0 );
00094                 QDBusVariant zoom( int level, int panel=0 );
00095                 QDBusVariant zoom( const QList<double> &blc, const QList<double> &trc, const QString &coordinates="pixel", int panel=0 );
00096 
00097                 // like "close()", but leaves the closing up to the user if the window is not hidden
00098                 QDBusVariant release( int panel );
00099                 //To change certain things so the panel
00100                 QDBusVariant setoptions( const QDBusVariant &input, int panel);
00101                 // device:      file name or printer name
00102                 // devicetype:  "file", "printer", or "ghostscript"
00103                 // format:      "jpg", "pdf", "eps", "ps", "png", "xbm", "xpm", "ppm"
00104                 //              [only used with devicetype == "file"] [extension on device, e.g. "outfile.pdf" overrides "format"]
00105                 // scale:       size scale factor for raster output (e.g. jpg etc.)
00106                 // dpi:         resolution of PS or EPS images
00107                 // orientation: "portrait", "landscape"
00108                 // media:       "letter" or "a4"
00109                 bool output( const QString &device, const QString &devicetype = "file", int panel = 0,
00110                              double scale = 1.0, int dpi = 300, const QString &format = "jpg",
00111                              const QString &orientation = "portrait", const QString &media = "letter" );
00112 
00113 
00114                 QDBusVariant fileinfo( const QString &path );
00115                 QStringList keyinfo( int );
00116 
00117                 bool done( );
00118 
00119         signals:
00120                 void interact( QDBusVariant );
00121                 void exiting( QDBusVariant );
00122 
00123         protected slots:
00124 
00125                 void handle_interact( QVariant );
00126                 void handle_destroyed_panel(QObject*);
00127 
00128         private:
00129 
00130                 inline QDBusVariant error( const QString &message ) {
00131                         QMap<QString,QVariant> err;
00132                         err["*error*"] = message;
00133                         return QDBusVariant(QVariant(err));
00134                 }
00135 
00136                 class data_desc {
00137                 public:
00138                         data_desc( int idx, const QString &pathx, const QString &typex,
00139                                    QtDisplayData *ddx, QtDisplayPanelGui *dpx ) :
00140                                 id_(idx), path_(pathx), type_(typex), dd_(ddx), dp_(dpx) { }
00141 
00142                         data_desc( int idx ) : id_(idx), dd_(0) { }
00143                         data_desc( ) : id_(0), dd_(0) { }
00144 
00145                         int &id( ) {
00146                                 return id_;
00147                         }
00148                         int id( ) const {
00149                                 return id_;
00150                         }
00151                         QString &path( ) {
00152                                 return path_;
00153                         }
00154                         const QString &path( ) const {
00155                                 return path_;
00156                         }
00157                         QString &type( ) {
00158                                 return type_;
00159                         }
00160                         const QString &type( ) const {
00161                                 return type_;
00162                         }
00163                         QtDisplayData *&data( ) {
00164                                 return dd_;
00165                         }
00166                         const QtDisplayData *data( ) const {
00167                                 return dd_;
00168                         }
00169                         QtDisplayPanelGui *&panel( ) {
00170                                 return dp_;
00171                         }
00172                         const QtDisplayPanelGui *panel( ) const {
00173                                 return dp_;
00174                         }
00175 
00176                 private:
00177                         int id_;
00178                         QString path_;
00179                         QString type_;
00180                         QtDisplayData *dd_;
00181                         QtDisplayPanelGui *dp_;
00182 
00183                         // QtDisplayData does not have a copy constructor...
00184                         // wonder if we'll need to copy our descriptor...
00185                         data_desc( const data_desc &other);
00186                         data_desc &operator=( const data_desc &);
00187                 };
00188 
00189 
00190                 class panel_desc {
00191                 public:
00192 
00193                         panel_desc(QtDisplayPanelGui*p) : panel_(p) { }
00194 
00195                         std::list<int> &data( ) {
00196                                 return data_;
00197                         }
00198                         const std::list<int> &data( ) const {
00199                                 return data_;
00200                         }
00201                         QtDisplayPanelGui *&panel( ) {
00202                                 return panel_;
00203                         }
00204                         const QtDisplayPanelGui *panel( ) const {
00205                                 return panel_;
00206                         }
00207 
00208                 private:
00209                         std::list<int> data_;
00210                         QtDisplayPanelGui *panel_;
00211                 };
00212 
00213 
00214                 QtViewer *viewer_;
00215 
00216                 bool printps( QtDisplayPanel *panel, const QString &type, const QString &file, int dpi,
00217                               const QString &orientation, const QString &media );
00218                 bool printraster( QtDisplayPanel *panel, const QString &type, const QString &file, double scale );
00219                 void  adjusteps( const char *from, const char *to, const QSize &wcmax, const QRect &viewport );
00220 
00221                 typedef std::map<int,panel_desc*> panelmap;
00222                 typedef std::map<int,data_desc*> datamap;
00223                 datamap managed_datas;
00224                 panelmap managed_panels;
00225 
00226                 int get_id( QtDisplayPanelGui *, QtDisplayData *, const QString &path, const QString &type );
00227                 int get_id( QtDisplayPanelGui * );
00228                 QtDisplayPanelGui *findpanel( int key, bool create=true );
00229                 QtDisplayData *finddata( int key );
00230 
00231         protected:
00232                 QtDisplayPanelGui *create_panel( );
00233                 void load_data( QtDisplayPanelGui *panel, int index );
00234                 void unload_data( QtDisplayPanelGui *panel, int index, bool erase=true );
00235                 QtDisplayPanelGui *erase_panel( int panel );
00236                 void erase_data( int );
00237 
00238         };
00239 
00240 }
00241 
00242 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1