PlotMSPlotTab.qo.h

Go to the documentation of this file.
00001 //# PlotMSPlotTab.qo.h: Subclass of PlotMSTab for controlling plot parameters.
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 PLOTMSPLOTTAB_QO_H_
00028 #define PLOTMSPLOTTAB_QO_H_
00029 
00030 #include <plotms/GuiTabs/PlotMSPlotTab.ui.h>
00031 #include <plotms/GuiTabs/PlotMSTab.qo.h>
00032 #include <plotms/PlotMS/PlotMSConstants.h>
00033 #include <plotms/Plots/PlotMSPlotManager.h>
00034 
00035 namespace casa {
00036 
00037 //# Forward declarations.
00038 class PlotMSAxesTab;
00039 class PlotMSCacheTab;
00040 class PlotMSCalibrationTab;
00041 class PlotMSCanvasTab;
00042 class PlotMSDataTab;
00043 class PlotMSDisplayTab;
00044 class PlotMSIterateTab;
00045 class PlotMSExportTab;
00046 class PlotMSTransformationsTab;
00047 class PlotMSPlotTab;
00048 
00049 
00050 // Subclass of PlotMSTab for tabs that are meant to be used as subtabs in a
00051 // PlotMSPlotTab.
00052 class PlotMSPlotSubtab : public PlotMSTab {
00053     Q_OBJECT
00054     
00055 public:
00056     // Constructor which takes the parent tab and plotter.
00057     PlotMSPlotSubtab(PlotMSPlotTab* plotTab, PlotMSPlotter* parent);
00058     
00059     // Destructor.
00060     virtual ~PlotMSPlotSubtab();
00061     
00062     
00063     // Gets/Sets the MS filename, selection, and averaging using a
00064     // PlotMSPlotParameters.
00065     // <group>
00066     virtual void getValue(PlotMSPlotParameters& params) const = 0;
00067     virtual void setValue(const PlotMSPlotParameters& params) = 0;
00068     // </group>
00069     
00070     // Updates the labels and other widgets in the subtab using the given
00071     // plot to check changes against.
00072     virtual void update(const PlotMSPlot& plot) = 0;
00073     
00074     
00075     // Implements PlotMSParametersWatcher::parametersHaveChanged() to do
00076     // nothing unless overridden in the child class.
00077     virtual void parametersHaveChanged(const PlotMSWatchedParameters& params,
00078             int updateFlag)   {  (void)params,(void)updateFlag; }
00079     
00080 
00081 
00082 signals:
00083     // This signal should be emitted whenever the value of the widget changes
00084     // because of user interaction.
00085     void changed();
00086     
00087 protected:
00088     // Plot tab.
00089     PlotMSPlotTab* itsPlotTab_;
00090     
00091     
00092     // See PlotMSPlotTab::currentlySetParameters().
00093     PlotMSPlotParameters currentlySetParameters() const;
00094 };
00095 
00096 
00097 // Subclass of PlotMSTab that manages PlotMSPlots in the GUI.  Watches the
00098 // current PlotMSPlot's parameters for changes to update the GUI as needed and
00099 // watches the PlotMSPlotManager for changes to the plots.
00100 class PlotMSPlotTab : public PlotMSTab, Ui::PlotTab /*,
00101                       public PlotMSPlotManagerWatcher*/{
00102     Q_OBJECT
00103     
00104     //# Friend class declarations.
00105     friend class PlotMSPlot;
00106     friend class PlotMSPlotter;
00107     
00108 public:
00109     // Constructor which takes the parent plotter.
00110     PlotMSPlotTab(PlotMSPlotter* parent, int plotIndex = -1);
00111     
00112     // Destructor.
00113     ~PlotMSPlotTab();
00114     
00115     
00116     // Implements PlotMSTab::tabName().
00117     QString tabName() const { return "Plot"; }
00118     
00119     // Overrides PlotMSTab::toolButtons().  Should be called AFTER any tabs
00120     // are added using addTab().
00121     QList<QToolButton*> toolButtons() const;
00122     
00123     // Implements PlotMSParametersWatcher::parametersHaveChanged().  Updates
00124     // the GUI as needed if the given parameters are the current PlotMSPlot's
00125     // parameters.
00126     void parametersHaveChanged(const PlotMSWatchedParameters& params,
00127             int updateFlag);
00128     
00129     // Implements PlotMSPlotManagerWatcher::plotsChanged().
00130     void plotsChanged(const PlotMSPlotManager& manager, int index=-1, bool show = true);
00131     
00132     //Return the data to support overplots.
00133     PlotMSDataTab* getData();
00134     String getFileName() const;
00135 
00136     String getAveragingSummary() const;
00137 
00138     // Returns the currently selected plot.
00139     PlotMSPlot* currentPlot() const;
00140     
00141     // Returns the parameters currently set by the user on the GUI (but NOT
00142     // necessarily set on the underlying plot parameters).
00143     PlotMSPlotParameters currentlySetParameters() const;
00144     
00145     
00146     // Returns the axes that the user has selected to load into the cache.
00147     vector<PMS::Axis> selectedLoadAxes() const {
00148         return selectedLoadOrReleaseAxes(true);
00149     }
00150     
00151     // Returns the axes that the user has selected to release from the cache.
00152     vector<PMS::Axis> selectedReleaseAxes() const {
00153         return selectedLoadOrReleaseAxes(false);
00154     }
00155 
00156     // Returns true if the location of this plot is still valid after the grid
00157     // size has changed; false otherwise.
00158     bool setGridSize( int rowCount, int colCount );
00159 
00160     //Return the location on the grid for this plot.
00161     void getLocation( Int& rowIndex, Int& colIndex );
00162 
00163     // Remove this plot.
00164     void removePlot();
00165 
00166     //Returns whether this plot has a valid location on the page where
00167     //it can be displayed.
00168     bool isPlottable() const;
00169 
00170     //This was put in to support overplotting.  When two plots are sharing the
00171     //same canvas, we don't want to trigger a redraw until all the plots sharing
00172     //the same canvas are done updating their data in background threads.
00173     void completePlotting( bool success );
00174 
00175     //Remove old data from the plot.
00176     void clearData();
00177 
00178     bool managesPlot( PlotMSPlot* plot ) const;
00179 
00180 public slots:
00181     // Slot for doing the plot, using the parameters set on the GUI for the
00182     // current plot.
00183     bool plot( bool forceReload);
00184     
00185     
00186 protected:
00187     // Clears set subtabs.
00188     void clearSubtabs();
00189     
00190     // Clears set subtabs after (and including) the given index.
00191     void clearAfter(int index);
00192     
00193     // Adds the given subtab to the end of the tab widget.
00194     void addSubtab(PlotMSPlotSubtab* tab);
00195     
00196     // Inserts the given subtab in the tab widget.
00197     void insertSubtab(int index, PlotMSPlotSubtab* tab);
00198     
00199     // Inserts one of the known subtab types if it is not already present,
00200     // and returns a pointer to it.
00201     // <group>
00202     PlotMSAxesTab* addAxesSubtab();
00203     PlotMSAxesTab* insertAxesSubtab(int index);
00204 
00205     void insertAxes(int index);
00206     PlotMSCacheTab* addCacheSubtab();
00207     PlotMSCacheTab* insertCacheSubtab(int index);
00208     void insertCache(int index);
00209     PlotMSCalibrationTab* addCalibrationSubtab();
00210     PlotMSCalibrationTab* insertCalibrationSubtab(int index);
00211     void insertCalibration(int index);
00212     PlotMSCanvasTab* addCanvasSubtab();
00213     PlotMSCanvasTab* insertCanvasSubtab(int index);
00214     void insertCanvas(int index);
00215     PlotMSDataTab* addDataSubtab();
00216     PlotMSDataTab* insertDataSubtab(int index);
00217     void insertData(int index);
00218     PlotMSDisplayTab* addDisplaySubtab();
00219     PlotMSDisplayTab* insertDisplaySubtab(int index);
00220     void insertDisplay(int index);
00221     PlotMSIterateTab* addIterateSubtab();
00222     PlotMSIterateTab* insertIterateSubtab(int index);
00223     void insertIterate(int index);
00224 
00225     PlotMSTransformationsTab* addTransformationsSubtab();
00226     PlotMSTransformationsTab* insertTransformationsSubtab(int index);
00227     void insertTransformations(int index);
00228     // </group>
00229     
00230     // Returns the first subtab with the given type, or NULL if there are none
00231     // of that type.
00232     template <class T>
00233     T* subtab() {
00234         T* t;
00235         foreach(PlotMSPlotSubtab* tab, itsSubtabs_)
00236             if((t = dynamic_cast<T*>(tab)) != NULL) return t;
00237         return NULL;
00238     }
00239     
00240 private:    
00241 
00242     PlotMSDataTab* findOrCreateDataTab();
00243     PlotMSIterateTab* findIterateTab() const;
00244     PlotMSDisplayTab* findDisplayTab();
00245     PlotMSAxesTab* findAxesTab();
00246 
00247     // PlotMSPlotSubtab objects in tab widget.
00248     QList<PlotMSPlotSubtab*> itsSubtabs_;
00249     
00250 
00251     // Reference to plot manager.
00252     PlotMSPlotManager& itsPlotManager_;
00253     
00254     // Currently selected plot.
00255     PlotMSPlot* itsCurrentPlot_;
00256     
00257     // Parameters for the currently selected plot.
00258     PlotMSPlotParameters* itsCurrentParameters_;
00259     
00260     // Whether or not to check for changed parameters and update the GUI
00261     // accordingly.
00262     bool itsUpdateFlag_;
00263     bool closing;
00264     int plotIndex;
00265 
00266     int forceReloadCounter_;
00267     
00268     // Sets up the GUI to display the parameters for the given plot.
00269     void setupForPlot();
00270     
00271     // Returns the axes the user has selected to load or release, depending on
00272     // the load flag. 
00273     vector<PMS::Axis> selectedLoadOrReleaseAxes(bool load) const;
00274     
00275 private slots:
00276 
00277     // Slot for when the user changes the value for any parameters.  Updates
00278     // the GUI to show which parameters have been changed (if any).
00279     void tabChanged();
00280 
00281     //A y-axis has changed its internal data.
00282     void changeAxisIdentifier( int index, QString id );
00283 
00284     //y-axis data has been removed.
00285     void removeAxisIdentifier( int index );
00286 
00287     //void plottableChanged();
00288 
00289 };
00290 
00291 }
00292 
00293 #endif /* PLOTMSPLOTTAB_QO_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1