PlotMSDBusApp.h

Go to the documentation of this file.
00001 //# PlotMSDBusApp.h: Controller for plotms using 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 #ifndef PLOTMSDBUSAPP_H_
00028 #define PLOTMSDBUSAPP_H_
00029 
00030 #include <casaqt/QtUtilities/QtDBusXmlApp.qo.h>
00031 #include <plotms/PlotMS/PlotMSParameters.h>
00032 #include <plotms/Plots/PlotMSPlotManager.h>
00033 #include <plotms/PlotMS/PlotEngine.h>
00034 
00035 namespace casa {
00036 
00037 //# Forward declarations.
00038 //class PlotEngine;
00039 
00040 
00041 // Subclass of QtDBusXmlApp to control plotms using DBus communication.
00042 class PlotMSDBusApp: public QtDBusXmlApp, public PlotMSParametersWatcher,
00043                      public PlotMSPlotManagerWatcher {
00044     
00045     //# Friend class declarations.
00046     friend class PlotMSDBusAppWatcher;
00047     
00048 public:
00049 
00050     static const QString &name( );
00051     QString dbusName( ) const { return QString(name( )); }
00052 
00053     // Static //
00054     
00055     // Constants for the casaplotms standalone executable.
00056     // <group>
00057     static const String APP_NAME;
00058     static const String APP_CASAPY_SWITCH;
00059     static const String APP_LOGFILENAME_SWITCH;
00060     static const String APP_LOGFILTER_SWITCH;
00061     // </group>
00062     
00063     
00064     // PARAMETERS //
00065     
00066     // Parameter names.
00067     // <group>
00068     static const String PARAM_AVERAGING; // Record (see PlotMSAveraging)
00069     static const String PARAM_AXIS_X; // String
00070     static const String PARAM_AXIS_Y; // String
00071     static const String PARAM_AXIS_Y_LOCATION;
00072     static const String PARAM_GRIDROWS; //int
00073     static const String PARAM_GRIDCOLS; //int
00074     static const String PARAM_CLEARSELECTIONS; // bool
00075     static const String PARAM_DATACOLUMN_X; // String
00076     static const String PARAM_DATACOLUMN_Y; // String
00077     static const String PARAM_FILENAME; // String
00078     static const String PARAM_FLAGGING; // Record
00079     static const String PARAM_HEIGHT; // int or uInt
00080     static const String PARAM_ITERATE; // Record (see PlotMSIterParam)
00081     static const String PARAM_PLOTINDEX; // int or uInt
00082     static const String PARAM_PRIORITY; // String
00083     static const String PARAM_SELECTION; // Record (see PlotMSSelection)
00084     static const String PARAM_TRANSFORMATIONS; // Record (see PlotMSTransformations)
00085     static const String PARAM_CALIBRATION; // Record (see PlotMSCalibration)
00086     static const String PARAM_UPDATEIMMEDIATELY; // bool
00087     static const String PARAM_WIDTH; // int or uInt
00088     static const String PARAM_EXPORT_FILENAME; // String
00089     static const String PARAM_EXPORT_FORMAT; //String
00090     static const String PARAM_EXPORT_RANGE; //String
00091     static const String PARAM_EXPORT_HIGHRES; // bool
00092     static const String PARAM_EXPORT_DPI; // int
00093     static const String PARAM_EXPORT_WIDTH; // int
00094     static const String PARAM_EXPORT_HEIGHT; // int
00095     static const String PARAM_EXPORT_INTERACTIVE; // bool
00096     static const String PARAM_EXPORT_ASYNC;  // bool
00097     static const String PARAM_COLORIZE;      // bool
00098     static const String PARAM_COLORAXIS;     // string
00099     static const String PARAM_CANVASTITLE;    // string
00100     static const String PARAM_CANVASTITLEFONT;  // int
00101     static const String PARAM_DATA_INDEX;    //int
00102     static const String PARAM_XAXISLABEL;    // string
00103     static const String PARAM_YAXISLABEL;    // string
00104     static const String PARAM_XAXISFONT;    // int
00105     static const String PARAM_YAXISFONT;    // int
00106     static const String PARAM_SHOWMAJORGRID;  // bool
00107     static const String PARAM_SHOWMINORGRID;  // bool
00108     static const String PARAM_MAJORCOLOR;    // string
00109     static const String PARAM_MINORCOLOR;    // string
00110     static const String PARAM_MAJORSTYLE;    // string 
00111     static const String PARAM_MINORSTYLE;    // string
00112     static const String PARAM_MAJORWIDTH;    // int 
00113     static const String PARAM_MINORWIDTH;    // int 
00114     static const String PARAM_SHOWLEGEND;    //bool
00115     static const String PARAM_LEGENDPOSITION; //string
00116     static const String PARAM_XAUTORANGE;    // bool
00117     static const String PARAM_XMIN;          // double
00118     static const String PARAM_XMAX;          // double
00119     static const String PARAM_YAUTORANGE;    // bool
00120     static const String PARAM_YMIN;          // double
00121     static const String PARAM_YMAX;          // double
00122     static const String PARAM_SYMBOL;        // bool
00123     static const String PARAM_SYMBOLSHAPE;   // string
00124     static const String PARAM_SYMBOLSIZE;    // int
00125     static const String PARAM_SYMBOLCOLOR;   // string
00126     static const String PARAM_SYMBOLFILL;    // string
00127     static const String PARAM_SYMBOLOUTLINE; // bool
00128     static const String PARAM_FLAGGEDSYMBOL;        // bool
00129     static const String PARAM_FLAGGEDSYMBOLSHAPE;   // string
00130     static const String PARAM_FLAGGEDSYMBOLSIZE;    // int
00131     static const String PARAM_FLAGGEDSYMBOLCOLOR;   // string
00132     static const String PARAM_FLAGGEDSYMBOLFILL;    // string
00133     static const String PARAM_FLAGGEDSYMBOLOUTLINE; // bool
00134     
00135     
00136     // </group>
00137 
00138     // DBus method name for getting the log parameters, including: the sink
00139     // filename (PARAM_FILENAME) and the filter priority (PARAM_PRIORITY).
00140     // PARAMETERS: none.
00141     // RETURNS: value (Record), unless invalid or run asynchronously.
00142     static const String METHOD_GETLOGPARAMS;
00143     
00144     // DBus method name for setting the log parameters, using a Record with
00145     // zero or more of the parameters set (see METHOD_GETLOGPARAMS).
00146     // PARAMETERS: value (Record).
00147     // RETURNS: none.
00148     static const String METHOD_SETLOGPARAMS;
00149     
00150     // DBus method name for getting the plotms parameters, including: the
00151     // "clear selections on axes change" flag (PARAM_CLEARSELECTIONS), and the
00152     // cached image width (PARAM_WIDTH) and height (PARAM_HEIGHT).
00153     // PARAMETERS: none.
00154     // RETURNS: value (Record), unless invalid or run asynchronously.
00155     static const String METHOD_GETPLOTMSPARAMS;
00156     
00157     // DBus method name for setting the plotms parameters, using a Record with
00158     // zero or more of the parameters set (see METHOD_GETPLOTMSPARAMS).
00159     // PARAMETERS: value (Record).
00160     // RETURNS: none.
00161     static const String METHOD_SETPLOTMSPARAMS;
00162     
00163     // DBus method name for setting the cached image size to the current screen
00164     // resolution.
00165     // PARAMETERS: none.
00166     // RETURNS: none.
00167     static const String METHOD_SETCACHEDIMAGESIZETOSCREENRES;
00168     
00169     // DBus method name for getting the plot parameters at the given index
00170     // (PARAM_PLOTINDEX), including: the MS filename (PARAM_FILENAME), the x
00171     // axis (PARAM_AXIS_X) and data column (PARAM_DATACOLUMN_X), the y axis
00172     // (PARAM_AXIS_Y) and data column (PARAM_DATACOLUMN_Y), averaging
00173     // (PARAM_AVERAGING), selection (PARAM_SELECTION), transformations
00174     // (PARAM_TRANSFORMATIONS), and calibration (PARAM_CALIBRATION)
00175     // PARAMETERS: plot index.
00176     // RETURNS: value (Record), unless invalid or run asynchronously.
00177     static const String METHOD_GETPLOTPARAMS;
00178     
00179     // DBus method name for setting the plot parameters at the given index
00180     // (PARAM_PLOTINDEX), using a Record with zero or more of the parameters
00181     // set (see METHOD_GETPLOTPARAMS).
00182     // PARAMETERS: value (Record).
00183     // RETURNS: none.
00184     static const String METHOD_SETPLOTPARAMS;
00185     
00186     //Sets the export parameters.
00187     // PARAMETERS: value (Record).
00188     // RETURNS: none.
00189     static const String METHOD_SETEXPORTPARAMS;
00190 
00191     // DBus method name for getting the flag extension parameters
00192     // (PARAM_FLAGGING).
00193     // PARAMETERS: none.
00194     // RETURNS: value (Record), unless invalid or run asynchronously.
00195     static const String METHOD_GETFLAGGING;
00196     
00197     // DBus method name for setting the flag extension parameters.
00198     // PARAMETERS: flagging value.
00199     // RETURNS: none.
00200     static const String METHOD_SETFLAGGING;
00201     
00202     // DBus method names for showing/hiding the window.  Does NOT quit the
00203     // entire application.
00204     // PARAMETERS: none.
00205     // RETURNS: none.
00206     // <group>
00207     static const String METHOD_SHOW;
00208     static const String METHOD_HIDE;
00209     // </group>
00210     
00211     // DBus method name for updating the running PlotMS with any attributes
00212     // that were set with updateImmediately = false.
00213     // PARAMETERS: none.
00214     // RETURNS: none.
00215     static const String METHOD_UPDATE;
00216     
00217     //Existing plots should be removed.
00218     //PARAMETERS: none.
00219     //RETURNS: none.
00220     static const String METHOD_CLEARPLOTS;
00221 
00222     // DBus method name for quitting the entire application.
00223     // PARAMETERS: none.
00224     // RETURNS: none.
00225     static const String METHOD_QUIT;
00226     
00227     //DBus method name for exporting plot file.
00228 
00229     static const String METHOD_SAVE;
00230 
00231     //DBus method name for determining if a plot is being drawn
00232     static const String METHOD_ISDRAWING;
00233     
00234     //is the top widget still shown
00235     static const String METHOD_ISCLOSED;
00236 
00237     // DBus method name for locating points in a specified region
00238     // PARAMETERS: upper left and lower right bounding box coordinates
00239     // RETURNS: meta data of located points (Record)
00240     static const String METHOD_LOCATEINFO;
00241 
00242     // Returns the name that the plotms in the process with the given ID is (or
00243     // would be) registered with in the CASA DBus server.
00244     static String dbusName(pid_t pid);
00245     
00246     // Non-Static //
00247     
00248     // Constructor which takes PlotMS parent object.
00249     PlotMSDBusApp(PlotEngine& plotms);
00250     
00251     // Destructor.
00252     ~PlotMSDBusApp();
00253     
00254     // Connects to the DBus server using the dbusName() method with the current
00255     // process ID.  Returns whether the connection succeeded or not.
00256     bool connectToDBus( const QString &dbus_name="" );
00257     
00258     // Implements PlotMSParametersWatcher::parametersHaveChanged().
00259     void parametersHaveChanged(
00260         const PlotMSWatchedParameters& params, int updateFlag
00261     );
00262     
00263     // Implements PlotMSPlotManagerWatcher::plotsChanged().
00264     void plotsChanged(const PlotMSPlotManager& manager);
00265     
00266 protected:
00267     // Implements QtDBusXmlApp::dbusRunXmlMethod().
00268     void dbusRunXmlMethod(
00269         const String& methodName, const Record& parameters,
00270         Record& retValue, const String& callerName, bool isAsync
00271     );
00272     
00273     // Overrides QtDBusXmlApp::dbusXmlReceived() to print the message to the log
00274     // as needed.
00275     void dbusXmlReceived(const QtDBusXML& xml);
00276     
00277 private:
00278     // Parent PlotMS.
00279     //PlotMSApp& itsPlotms_;
00280     PlotEngine& itsPlotms_;
00281     
00282     // Set PlotMS parameters that haven't yet been transferred to the current
00283     // PlotMS.
00284     PlotMSParameters itsParams_;
00285     
00286     // Set PlotMSSinglePlot parameters that haven't yet been transfered to the
00287     // current PlotMS.
00288     vector<PlotMSPlotParameters> itsPlotParams_;
00289     
00290     // Flag for whether to call update() during show() or not.  This will be
00291     // true if the user updates something while the GUI is hidden.
00292     bool itsUpdateFlag_;
00293 
00294     // Helper method for posting log messages.
00295     void log(const String& message);
00296     
00297     // Adjusts the given plot index to be an acceptable, and returns whether
00298     // the parameters were resized or not.
00299     bool plotParameters(int& plotIndex) const;
00300     
00301     // Helper for updating.
00302     bool update();
00303 
00304     // helper for saving
00305     bool _savePlot(const Record& parameters);
00306 
00307     // helper for locate
00308     Record _locateInfo(const Record& parameters);
00309 
00310     //Make sure users don't set the plot index to an invalid value.
00311     bool checkPlotIndex( int index );
00312 
00313 };
00314 
00315 }
00316 
00317 #endif /* PLOTMSDBUSAPP_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1