casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
PlotMS.h
Go to the documentation of this file.
00001 //# PlotMS.h: Main controller for plotms.
00002 //# Copyright (C) 2008
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 PLOTMS_H_
00028 #define PLOTMS_H_
00029 
00030 #include <plotms/PlotMS/PlotMSParameters.h>
00031 #include <plotms/Plots/PlotMSPlotManager.h>
00032 
00033 namespace casa {
00034 
00035 // Version definitions.
00036 // <group>
00037 #define PLOTMS_VERSION 0x002250;
00038 #define PLOTMS_VERSION_STR "2.25";
00039 // </group>
00040 
00041 
00042 //# Forward declarations.
00043 class PlotMSDBusApp;
00044 class PlotMSPlotter;
00045 
00046 
00047 // Controller class for plotms.  Handles interactions between the UI and plots.
00048 class PlotMSApp : public PlotMSParametersWatcher {
00049 public:    
00050     // Default constructor that uses default options.  If connectToDBus is
00051     // true, then the application registers itself with CASA's DBus server
00052     // using the PlotMSDBusApp::dbusName() with the current process ID.
00053     PlotMSApp(bool connectToDBus = false);
00054     
00055     // Constructor which takes the given parameters.  If connectToDBus is true,
00056     // then the application registers itself with CASA's DBus server using the
00057     // PlotMSDBusApp::dbusName() with the current process ID.
00058     PlotMSApp(const PlotMSParameters& params, bool connectToDBus = false);
00059     
00060     // Destructor
00061     ~PlotMSApp();
00062   
00063     
00064     // Plotter Methods //
00065     
00066     // Returns the PlotMSPlotter associated with this PlotMS. 
00067     PlotMSPlotter* getPlotter();
00068     
00069     // See PlotMSPlotter::showGUI().
00070     void showGUI(bool show = true);
00071     
00072     // See PlotMSPlotter::guiShown().
00073     bool guiShown() const;
00074     
00075     // See PlotMSPlotter::execLoop().
00076     int execLoop();
00077     
00078     // See PlotMSPlotter::showAndExec().
00079     int showAndExec(bool show= true);
00080     
00081     // See PlotMSPlotter::close().
00082     void close();
00083     
00084     // See PlotMSPlotter::showError().
00085     // <group>
00086     void showError(const String& message, const String& title = "PlotMS Error",
00087             bool isWarning = false);
00088     void showWarning(const String& message,
00089             const String& title = "PlotMS Warning");
00090     // </group>
00091     
00092     // See PlotMSPlotter::showMessage().
00093     void showMessage(const String& message,
00094             const String& title = "PlotMS Message");
00095     
00096     
00097     // Parameter Methods //
00098     
00099     // Gets/Sets the parameters for this PlotMS.
00100     // <group>
00101     PlotMSParameters& getParameters();
00102     void setParameters(const PlotMSParameters& params);
00103     // </group>
00104     
00105     // Implements PlotMSParametersWatcher::parametersHaveChanged().
00106     void parametersHaveChanged(const PlotMSWatchedParameters& params,
00107                 int updateFlag);
00108     
00109     
00110     // Logger Methods //
00111     
00112     // Gets the logger associated with this PlotMS.
00113     PlotLoggerPtr getLogger();
00114     
00115     
00116     // Plot Management Methods //
00117     
00118     // Returns the PlotMSPlotManager associated with this PlotMS.
00119     PlotMSPlotManager& getPlotManager();
00120     
00121     // See PlotMSPlotManager::addSinglePlot().
00122     PlotMSPlot* addSinglePlot(const PlotMSPlotParameters* p = NULL);
00123     
00124     // See PlotMSPlotManager::addMultiPlot();
00125     PlotMSPlot* addMultiPlot(const PlotMSPlotParameters* p = NULL);
00126 
00127     // See PlotMSPlotManager::addIterPlot();
00128     PlotMSPlot* addIterPlot(const PlotMSPlotParameters* p = NULL);
00129 
00130     // See PlotMSPlotManager::addOverPlot();
00131     PlotMSOverPlot* addOverPlot(const PlotMSPlotParameters* p = NULL);
00132     
00133     bool isDrawing() const;
00134     bool isClosed() const;
00135 
00136     // save plot  to file using specified format. If interactive, pop up confirm window, if not, no confirm windowl
00137     bool save(const PlotExportFormat& format, const bool interactive);
00138 
00139 public:
00140     // To allow normal error/warning/info popups, which block execution,
00141     // or, if not, prevent blocking by writing to the Logger and posting 
00142     // text to a status bar (or other visible gui element TBD)
00143     // (public for now, while it's experimental)
00144         bool its_want_avoid_popups;
00145 
00146 private:
00147     // Plotter GUI.
00148     PlotMSPlotter* itsPlotter_;
00149     
00150     // Current parameters.
00151     PlotMSParameters itsParameters_;
00152     
00153     // Logger.
00154     PlotLoggerPtr itsLogger_;
00155     
00156     // Plot manager.
00157     PlotMSPlotManager itsPlotManager_;
00158     
00159     // DBus application, or NULL if one is not needed.
00160     PlotMSDBusApp* itsDBus_;
00161 
00162     
00163     // Initializes a new PlotMS object, to be called from constructor.
00164     void initialize(bool connectToDBus);    
00165     
00166     // Disable copy constructor and operator for now.
00167     // <group>
00168     PlotMSApp(const PlotMSApp& copy);
00169     PlotMSApp& operator=(const PlotMSApp& copy);
00170     // </group>
00171     
00172 };
00173 
00174 /*
00175 // Temporary class for polarization selection, until I understand it better.
00176 // (Not currently used.)
00177 class PlotMSPolSelection {
00178 public:
00179     PlotMSPolSelection(const String& polselstr = DEFAULT_POLSELSTR);
00180     
00181     ~PlotMSPolSelection();
00182     
00183     void setPolSelection(const String& polselstr);
00184     
00185     const String& polselstr() const;    
00186     unsigned int npols() const;    
00187     int pol_selection(unsigned int index) const;
00188     
00189     int operator()(unsigned int index) const { return pol_selection(index); }
00190     
00191 private:
00192     String itsPolSelStr_;
00193     vector<int> itsPolSel_;
00194     
00195     static const String DEFAULT_POLSELSTR;
00196 };
00197  */
00198 
00199 // Rob's AxisUnit stuff, not currently used.
00200 /*
00201 enum AxisUnitEnum {Angle,         // Not Dimensionless because it can
00202                               // include degrees, mas, radians, etc.
00203            Dimensionless,     // Things that you'd have to stretch to
00204                               // tack a unit onto.
00205            FluxDensity,       // (m, u)Jy
00206            Freq,          // VisSet.h typedefs Frequency to Double.
00207            Intensity,         // Jy/beam, Jy/sq. arcsec, etc.
00208            Time,
00209            Velocity,
00210                    Wavelengths};      // (u, v, w) distances.
00211 
00212 class AxisUnit
00213 {
00214 public:
00215   AxisUnitEnum operator[](const String& quant);
00216 
00217   // You want the AxisUnit, you go through this.  Call like AxisUnit::lookup().['time'].
00218   static AxisUnit& lookup();
00219   
00220 private:
00221   // Default constructor.  Because it is private, instantiation of AxisUnits is suppressed.
00222   AxisUnit();
00223 
00224   // There can only be one AxisUnit, so there is no copy constructor or
00225   // assignment operator.
00226 
00227   // Destructor
00228   ~AxisUnit() {}
00229 
00230   typedef std::map<String, AxisUnitEnum> S2UMap;
00231   S2UMap quant2u;
00232 };
00233   
00234 class AxisUnitException: public AipsError {
00235 public:
00236   //
00237   // Creates an AxisUnitException and initializes the error message from
00238   // the parameter
00239   // <group>
00240   AxisUnitException(const Char *str) : AipsError(str, AipsError::INVALID_ARGUMENT) {}
00241   AxisUnitException(const String &str) : AipsError(str,
00242                            AipsError::INVALID_ARGUMENT) {}
00243   
00244   // </group>
00245 
00246   // Destructor which does nothing.
00247   ~AxisUnitException() throw() {}
00248 };
00249  */
00250 
00251 }
00252 
00253 #endif /* PLOTMS_H_ */