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/PlotMSPages.h>
00032 
00033 namespace casa {
00034 
00035 //# Forward Declararations
00036 class PlotMSApp;
00037 class PlotMSPlot;
00038 class PlotMSPlotManagerWatcher;
00039 class PlotMSPlotParameters;
00040 
00041 
00042 // Class which manages PlotMSPlots for plotms.  Mainly handles adding new plots
00043 // and managing their PlotCanvases and the arrangement of PlotCanvases in the
00044 // Plotter.  Any PlotMSPlots should be owned by the manager, which will handle
00045 // deletion as necessary.
00046 class PlotMSPlotManager {
00047     
00048     //# Friend class declarations.
00049     friend class PlotMSPlot;
00050     
00051 public:
00052     // Constructor.  Parent must be set using setParent() before manager can be
00053     // used.
00054     PlotMSPlotManager();
00055     
00056     // Destructor.
00057     ~PlotMSPlotManager();
00058 
00059     
00060     // Gets/Sets the parent PlotMS.
00061     // <group>
00062     PlotMSApp* parent();
00063     void setParent(PlotMSApp* parent);
00064     // </group>
00065     
00066     // Returns the plotter used by the parent.
00067     PlotterPtr plotter();
00068     
00069     // Adds the given watcher to this manager.
00070     void addWatcher(PlotMSPlotManagerWatcher* watcher);
00071     
00072     // Removes the given watcher from this manager.
00073     void removeWatcher(PlotMSPlotManagerWatcher* watcher);
00074     
00075     
00076     // Returns the number of plots.
00077     unsigned int numPlots() const;
00078     
00079     // Returns all or one of the plots.
00080     // <group>
00081     const vector<PlotMSPlot*>& plots() const;
00082     PlotMSPlot* plot(unsigned int index);
00083     const PlotMSPlot* plot(unsigned int index) const;
00084     QList<PlotMSPlot*> getCanvasPlots( int row, int col ) const;
00085     // </group>
00086     
00087     //Set the new size of a multi-plot display.
00088     bool pageGridChanged( int rows, int cols, bool override );
00089     
00090     //Return the current size of a multi-plot page grid.
00091     void getGridSize( Int& rows, Int& cols );
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 PlotMSPlot, initializes it properly,
00100     // adds it to the plotter, and returns a pointer to it.
00101     // If parameters are given, they are used; otherwise the 
00102     // defaults are used.
00103     PlotMSPlot* addOverPlot(const PlotMSPlotParameters* p = NULL);
00104     
00105     //Remove a plot from the display.
00106     void removePlot( PlotMSPlot* plot );
00107     
00108     // Clears out all plots and canvases.
00109     void clearPlotsAndCanvases( bool clearCanvases = true );
00110     void clearCanvas(int row, int col );
00111     bool findEmptySpot( Int& row, Int& col );
00112 
00113     void unassignPlots();
00114 
00115     vector<String> getFiles() const;
00116 
00117     //Returns the parameters that control the page display (grid rows & cols).
00118     PlotMSParameters getPageParameters();
00119     
00120     //Returns whether or not a canvas has been allocated
00121     //for the plot.
00122     bool isPlottable( PlotMSPlot* plot );
00123 
00124     bool isOwner( int row, int col, PlotMSPlot* plot );
00125 
00126 
00127 
00128 private:
00129     // Parent.
00130     PlotMSApp* itsParent_;
00131     
00132     // Plotter.
00133     PlotterPtr itsPlotter_;
00134     
00135     // Plot factory.
00136     PlotFactoryPtr itsFactory_;
00137     
00138     // Plots.  Will be deleted on destruction.
00139     vector<PlotMSPlot*> itsPlots_;
00140     
00141     // Plot parameters.  Will not be deleted on destruction.
00142     vector<PlotMSPlotParameters*> itsPlotParameters_;
00143     
00144     // Watchers.
00145     vector<PlotMSPlotManagerWatcher*> itsWatchers_;
00146     
00147     // Plot pages.
00148     PlotMSPages itsPages_;
00149     
00150     
00151     // Helper method for add*Plot methods.
00152     void addPlot(PlotMSPlot* plot, const PlotMSPlotParameters* p);
00153     
00154     // Notifies any watchers that the managed plots have changed.
00155     void notifyWatchers() const;
00156 
00157     //Wait for existing draw threads to finish before we proceed so
00158     //we don't get a seg fault from a draw thread hanging onto deleted
00159     //data.
00160     void waitForDrawing();
00161 
00162     //Post a plot message to the logger.
00163     void logMessage( const QString& msg ) const;
00164 };
00165 
00166 
00167 // Interface for any class that wants to be notified when the plots in the
00168 // manager have changed.
00169 class PlotMSPlotManagerWatcher {
00170 public:
00171     // Constructor.
00172     PlotMSPlotManagerWatcher() { }
00173     
00174     // Destructor.
00175     virtual ~PlotMSPlotManagerWatcher() { }
00176     
00177     
00178     // Will be called whenever the plots in the manager change.
00179     virtual void plotsChanged(const PlotMSPlotManager& manager) = 0;
00180 };
00181 
00182 }
00183 
00184 #endif /* PLOTMSPLOTMANAGER_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1