casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
LFPlotServerProxy.h
Go to the documentation of this file.
00001 //# FlagPlotServerProxy.h: Flagger's version of PlotServerProxy
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 DBUS_LFPLOTSERVERPROXY_H
00029 #define DBUS_LFPLOTSERVERPROXY_H
00030 
00031 #include <stdio.h>
00032 #include <math.h>
00033 #include <casadbus/plotserver/PlotServerProxy.h>
00034 #include <casadbus/utilities/BusAccess.h>
00035 #include <casadbus/session/DBusSession.h>
00036 
00037 namespace casa {
00038 
00039 class FlagPlotServerProxy : public PlotServerProxy {
00040     public:
00041         FlagPlotServerProxy( char *&dbusname ) : PlotServerProxy(dbusname ) { }
00042         void exiting( ) {
00043             casa::DBusSession::instance( ).dispatcher( ).leave( );
00044             returnvalue = "Quit";
00045         }
00046         void closing(const int32_t& /*panel*/, const bool &/*gone*/) {
00047             casa::DBusSession::instance( ).dispatcher( ).leave( );
00048             //std::cout << "closing panel: " << panel << " (" << gone << ")..." << std::endl;
00049             returnvalue = "Quit";
00050         }
00051 
00052         dbus::variant panel( const std::string& title, const std::string &xlabel="", const std::string &ylabel="",
00053                              const std::string &window_title="", const std::vector<int> &size=std::vector<int>( ),
00054                              const std::string& legend="bottom", const std::string &zoom="bottom",
00055                              const int32_t& with_panel=0, const bool& new_row=false, const bool& hidden=false )
00056          {
00057             dbus::variant v = PlotServerProxy::panel( title,xlabel,ylabel,window_title,size,
00058                                                                              legend,zoom,with_panel,new_row,hidden );
00059             if ( v.type( ) == dbus::variant::INT ) {
00060                 p = v.getInt( );
00061             }
00062             return v;
00063         }
00064  
00065         dbus::variant line( const std::vector< double >& x, const std::vector< double >& y, const std::string& color="black",
00066                             const std::string& label="", const int32_t& panel=0 ) {
00067             dbus::variant v = PlotServerProxy::line( x, y, color, label, panel );
00068             if ( v.type( ) == dbus::variant::INT ) {
00069                 l = v.getInt( );
00070             }
00071             return v;
00072         }
00073 
00074   dbus::variant raster(  const std::vector<double> &matrix, int sizex, int sizey, const std::string& colormap="Greyscale 1", int panel=0 )
00075 {
00076   dbus::variant v = PlotServerProxy::raster( matrix, sizex, sizey, colormap, panel );
00077             if ( v.type( ) == dbus::variant::INT ) {
00078                 l = v.getInt( );
00079             }
00080             return v;
00081         }
00082 
00083         void draw( std::vector<double> x, std::vector<double> y, std::string color="blue" ) {
00084             xvals = x;
00085             yvals = y;
00086             dbus::variant v = line(x,y,color,"",p);
00087             if ( v.type( ) == dbus::variant::INT ) {
00088                 l = v.getInt( );
00089             }
00090         }
00091 
00092         void button(const int32_t& /*panel*/, const std::string& name) {
00093           //std::cout << "button: " << name << "/" << panel << std::endl;
00094               returnvalue = name;
00095               //              std::cout << returnvalue << std::endl;
00096               casa::DBusSession::instance( ).dispatcher( ).leave( );
00097         }
00098 
00099         void check(const int32_t& /*panel*/, const std::string& name, const int32_t& state) {
00100           //std::cout << "check: " << name << "/" << panel << " <" << state << ">" << std::endl;
00101           stringstream rval;
00102           rval << name << ":"<< state;
00103           returnvalue = rval.str();
00104           casa::DBusSession::instance().dispatcher().leave();
00105         }
00106 
00107         void radio(const int32_t& panel, const std::string& name, const bool& state) {
00108             std::cout << "radio: " << name << "/" << panel << " <" << state << ">" << std::endl;
00109         }
00110 
00111         void linetext(const int32_t& panel, const std::string& name, const std::string& text) {
00112             std::cout << "line: " << name << "/" << panel << " <" << text << ">" << std::endl;
00113         }
00114 
00115         void slidevalue(const int32_t& panel, const std::string& name, const int32_t& value) {
00116             std::cout << "slider: " << name << "/" << panel << " <" << value << ">" << std::endl;
00117         }
00118 
00119     
00120   std::string eventloop()
00121   {
00122       casa::DBusSession::instance( ).dispatcher( ).enter( );
00123       return returnvalue;
00124   }
00125 
00126 
00127     private:
00128         int p;
00129         int l;
00130         std::vector<double> xvals;
00131         std::vector<double> yvals;
00132  
00133   std::string  returnvalue;
00134 
00135 };
00136 
00137 }
00138 #endif