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/PlotMS/PlotMSExportParam.h>
00032 #include <plotms/Plots/PlotMSPlotManager.h>
00033 #include <plotms/PlotMS/PlotMSFlagging.h>
00034 #include <plotms/PlotMS/PlotEngine.h>
00035 #include <plotms/Actions/PlotMSAction.h>
00036 
00037 namespace casa {
00038 
00039 // Version definitions.
00040 // <group>
00041 #define PLOTMS_VERSION 0x002250;
00042 #define PLOTMS_VERSION_STR "2.25";
00043 // </group>
00044 
00045 
00046 //# Forward declarations.
00047 class PlotMSDBusApp;
00048 class Client;
00049 
00050 
00051 // Controller class for plotms.  Handles interactions between the UI and plots.
00052 class PlotMSApp : public PlotMSParametersWatcher, public PlotEngine {
00053 public:    
00054     // Default constructor that uses default options.  If connectToDBus is
00055     // true, then the application registers itself with CASA's DBus server
00056     // using the PlotMSDBusApp::dbusName() with the current process ID.
00057     PlotMSApp(bool connectToDBus = false, bool userGui = true);
00058     
00059     // Constructor which takes the given parameters.  If connectToDBus is true,
00060     // then the application registers itself with CASA's DBus server using the
00061     // PlotMSDBusApp::dbusName() with the current process ID.
00062     PlotMSApp(const PlotMSParameters& params, bool connectToDBus = false, bool userGui = true);
00063     
00064     // Destructor
00065     ~PlotMSApp();
00066   
00067     
00068     // Plotter Methods //
00069 
00070     // See PlotMSPlotter::showGUI().
00071     virtual void showGUI(bool show = true);
00072     
00073     // See PlotMSPlotter::guiShown().
00074     virtual bool guiShown() const;
00075     
00076     // See PlotMSPlotter::execLoop().
00077     int execLoop();
00078     
00079     // See PlotMSPlotter::showAndExec().
00080     int showAndExec(bool show= true);
00081     
00082     // See PlotMSPlotter::close().
00083     void close();
00084     
00085     //Remove existing plots.
00086     virtual void clearPlots();
00087 
00088     // See PlotMSPlotter::showError().
00089     // <group>
00090     void showError(const String& message, const String& title = "PlotMS Error",
00091             bool isWarning = false);
00092     void showWarning(const String& message,
00093             const String& title = "PlotMS Warning");
00094     void clearMessage();
00095     // </group>
00096     
00097     // See PlotMSPlotter::showMessage().
00098     void showMessage(const String& message,
00099             const String& title = "PlotMS Message");
00100     
00101     // Enable/disable annotations in the client
00102     void setAnnotationModeActive( PlotMSAction::Type type, bool active );
00103 
00104     //Enables/disables tool settings on the canvases based
00105     //on GUI settings.
00106     void resetTools();
00107     
00108     // Parameter Methods //
00109     
00110     // Gets/Sets the parameters for this PlotMS.
00111     // <group>
00112     virtual PlotMSParameters& getParameters();
00113     void setParameters(const PlotMSParameters& params);
00114     // </group>
00115     
00116     // Gets/Sets the export parameters for this PlotMS.
00117     // <group>
00118     virtual PlotMSExportParam& getExportParameters();
00119     void setExportParameters(const PlotMSExportParam& params);
00120     PlotExportFormat getExportFormat();
00121     void setExportFormat( const PlotExportFormat format );
00122     // </group>
00123 
00124     // Implements PlotMSParametersWatcher::parametersHaveChanged().
00125     void parametersHaveChanged(const PlotMSWatchedParameters& params,
00126                 int updateFlag);
00127     virtual PlotSymbolPtr createSymbol (const String& descriptor,
00128                 Int size, const String& color,
00129                 const String& fillPattern, bool outline );
00130     PlotSymbolPtr createSymbol( const PlotSymbolPtr& copy );
00131     // Logger Methods //
00132     
00133     // Gets the logger associated with this PlotMS.
00134     virtual PlotLoggerPtr getLogger();
00135     
00136     
00137     // Plot Management Methods //
00138     
00139     // Returns the PlotMSPlotManager associated with this PlotMS.
00140     virtual PlotMSPlotManager& getPlotManager();
00141     
00142 
00143     // See PlotMSPlotManager::addOverPlot();
00144     PlotMSPlot* addOverPlot(const PlotMSPlotParameters* p = NULL);
00145     
00146     virtual bool isDrawing() const;
00147     bool isClosed() const;
00148     // Set whether the latest plot update was successful completed.  This
00149     // may not be the case if an invalid selection was made.
00150     void setOperationCompleted( bool completed );
00151 
00152 
00153     // save plot  to file using specified format.
00154     bool save(const PlotExportFormat& format);
00155 
00159     virtual PlotFactoryPtr getPlotFactory();
00160     virtual void quitApplication();
00161     virtual PlotMSFlagging getFlagging() const;
00162     virtual void setFlagging(PlotMSFlagging flag);
00163     void canvasAdded( PlotCanvasPtr canvas );
00164     bool isVisible(PlotCanvasPtr& canvas );
00165     bool exportToFormat(const PlotExportFormat& format);
00166     virtual Record locateInfo( Bool& success, String& errorMessage );
00167     //Returns whether or not the latest plot update completed successfully.
00168     //For example, if an invalid selection was made, the return value may be false.
00169     bool isOperationCompleted() const;
00170     PlotterPtr getPlotter();
00171 public:
00172     // To allow normal error/warning/info popups, which block execution,
00173     // or, if not, prevent blocking by writing to the Logger and posting 
00174     // text to a status bar (or other visible gui element TBD)
00175     // (public for now, while it's experimental)
00176         bool its_want_avoid_popups;
00177         bool updateCachePlot( PlotMSPlot* plot, void (*f)(void*, bool), bool setupPlot);
00178         void setCommonAxes(bool commonX, bool commonY );
00179         bool isCommonAxisX() const;
00180         bool isCommonAxisY() const;
00181         void setAxisLocation( PlotAxis locationX, PlotAxis locationY );
00182         PlotAxis getAxisLocationX() const;
00183         PlotAxis getAxisLocationY() const;
00184         vector<String> getFiles() const;
00185 
00186 
00187 private:
00188     // Plotter, Script or GUI
00189     Client* itsPlotter_;
00190     Client* itsLastPlotter_;
00191     bool isGUI_;
00192 
00193     // Current parameters.
00194     PlotMSParameters itsParameters_;
00195     PlotMSExportParam itsExportParameters_;
00196     PlotExportFormat itsExportFormat;
00197     
00198     // Logger.
00199     PlotLoggerPtr itsLogger_;
00200     
00201     // Plot manager.
00202     PlotMSPlotManager itsPlotManager_;
00203     
00204     // DBus application, or NULL if one is not needed.
00205     PlotMSDBusApp* itsDBus_;
00206 
00207         //Whether the most recent plot updated was successfully
00208         //completed.  A null selection, for example, could result
00209         //in an unsuccessful update.
00210     bool operationCompleted;
00211 
00212     // Initializes a new PlotMS object, to be called from constructor.
00213     void initialize(bool connectToDBus, bool userGui );
00214     
00215     // Disable copy constructor and operator for now.
00216     // <group>
00217     PlotMSApp(const PlotMSApp& copy);
00218     PlotMSApp& operator=(const PlotMSApp& copy);
00219     // </group>
00220     
00221 };
00222 
00223 /*
00224 // Temporary class for polarization selection, until I understand it better.
00225 // (Not currently used.)
00226 class PlotMSPolSelection {
00227 public:
00228     PlotMSPolSelection(const String& polselstr = DEFAULT_POLSELSTR);
00229     
00230     ~PlotMSPolSelection();
00231     
00232     void setPolSelection(const String& polselstr);
00233     
00234     const String& polselstr() const;    
00235     unsigned int npols() const;    
00236     int pol_selection(unsigned int index) const;
00237     
00238     int operator()(unsigned int index) const { return pol_selection(index); }
00239     
00240 private:
00241     String itsPolSelStr_;
00242     vector<int> itsPolSel_;
00243     
00244     static const String DEFAULT_POLSELSTR;
00245 };
00246  */
00247 
00248 }
00249 
00250 #endif /* PLOTMS_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1