00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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& , const bool &) {
00047 casa::DBusSession::instance( ).dispatcher( ).leave( );
00048
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& , const std::string& name) {
00093
00094 returnvalue = name;
00095
00096 casa::DBusSession::instance( ).dispatcher( ).leave( );
00097 }
00098
00099 void check(const int32_t& , const std::string& name, const int32_t& state) {
00100
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