casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
PlotMSPlotManager.h
Go to the documentation of this file.
00001 //# PlotMSPlotManager.h: Manages PlotMSPlots for plotms.
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 PLOTMSPLOTMANAGER_H_
00028 #define PLOTMSPLOTMANAGER_H_
00029 
00030 #include <graphics/GenericPlotter/PlotFactory.h>
00031 #include <plotms/Plots/PlotMSPage.h>
00032 
00033 #include <casa/namespace.h>
00034 
00035 namespace casa {
00036 
00037 //# Forward Declararations
00038 class PlotMSApp;
00039   //-class PlotMSMultiPlot;
00040 class PlotMSPlot;
00041 class PlotMSPlotManagerWatcher;
00042 class PlotMSPlotParameters;
00043   //-class PlotMSSinglePlot;
00044 class PlotMSIterPlot;
00045 class PlotMSOverPlot;
00046 
00047 
00048 // Class which manages PlotMSPlots for plotms.  Mainly handles adding new plots
00049 // and managing their PlotCanvases and the arrangement of PlotCanvases in the
00050 // Plotter.  Any PlotMSPlots should be owned by the manager, which will handle
00051 // deletion as necessary.
00052 class PlotMSPlotManager {
00053     
00054     //# Friend class declarations.
00055     friend class PlotMSMultiPlot;
00056     friend class PlotMSOverPlot;
00057     
00058 public:
00059     // Constructor.  Parent must be set using setParent() before manager can be
00060     // used.
00061     PlotMSPlotManager();
00062     
00063     // Destructor.
00064     ~PlotMSPlotManager();
00065 
00066     
00067     // Gets/Sets the parent PlotMS.
00068     // <group>
00069     PlotMSApp* parent();
00070     void setParent(PlotMSApp* parent);
00071     // </group>
00072     
00073     // Returns the plotter used by the parent.
00074     PlotterPtr plotter();
00075     
00076     // Adds the given watcher to this manager.
00077     void addWatcher(PlotMSPlotManagerWatcher* watcher);
00078     
00079     // Removes the given watcher from this manager.
00080     void removeWatcher(PlotMSPlotManagerWatcher* watcher);
00081     
00082     
00083     // Returns the number of plots.
00084     unsigned int numPlots() const;
00085     
00086     // Returns all or one of the plots.
00087     // <group>
00088     const vector<PlotMSPlot*>& plots() const;
00089     PlotMSPlot* plot(unsigned int index);
00090     const PlotMSPlot* plot(unsigned int index) const;
00091     // </group>
00092     
00093     // Returns all or one of the plot parameters.
00094     // <group>
00095     const vector<PlotMSPlotParameters*>& plotParameters() const;
00096     PlotMSPlotParameters* plotParameters(unsigned int index);
00097     // </group>
00098     
00099     // Creates a new PlotMSOverPlot, initializes it properly, adds it to the
00100     // plotter, and returns a pointer to it.  If parameters are given, they are
00101     // used; otherwise the defaults are used.
00102     PlotMSOverPlot* addOverPlot(const PlotMSPlotParameters* p = NULL);
00103     
00104     // These are now deprecated and will throw an exception...
00105     PlotMSPlot* addSinglePlot(const PlotMSPlotParameters* p = NULL);
00106     PlotMSPlot* addMultiPlot(const PlotMSPlotParameters* p = NULL);
00107     PlotMSPlot* addIterPlot(const PlotMSPlotParameters* p = NULL);
00108 
00109     // Clears out all plots and canvases.
00110     void clearPlotsAndCanvases();
00111     
00112 private:
00113     // Parent.
00114     PlotMSApp* itsParent_;
00115     
00116     // Plotter.
00117     PlotterPtr itsPlotter_;
00118     
00119     // Plot factory.
00120     PlotFactoryPtr itsFactory_;
00121     
00122     // Plots.  Will be deleted on destruction.
00123     vector<PlotMSPlot*> itsPlots_;
00124     
00125     // Plot parameters.  Will not be deleted on destruction.
00126     vector<PlotMSPlotParameters*> itsPlotParameters_;
00127     
00128     // Watchers.
00129     vector<PlotMSPlotManagerWatcher*> itsWatchers_;
00130     
00131     // Plot pages.
00132     PlotMSPages itsPages_;
00133     
00134     
00135     // Helper method for add*Plot methods.
00136     void addPlot(PlotMSPlot* plot, const PlotMSPlotParameters* p);
00137     
00138     // Notifies any watchers that the managed plots have changed.
00139     void notifyWatchers() const;
00140 };
00141 
00142 
00143 // Interface for any class that wants to be notified when the plots in the
00144 // manager have changed.
00145 class PlotMSPlotManagerWatcher {
00146 public:
00147     // Constructor.
00148     PlotMSPlotManagerWatcher() { }
00149     
00150     // Destructor.
00151     virtual ~PlotMSPlotManagerWatcher() { }
00152     
00153     
00154     // Will be called whenever the plots in the manager change.
00155     virtual void plotsChanged(const PlotMSPlotManager& manager) = 0;
00156 };
00157 
00158 }
00159 
00160 #endif /* PLOTMSPLOTMANAGER_H_ */