casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
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 
00032 #include <plotms/GuiTabs/PlotMSTab.qo.h>
00033 #include <plotms/PlotMS/PlotMSConstants.h>
00034 #include <plotms/Plots/PlotMSPlotManager.h>
00035 
00036 #include <casa/namespace.h>
00037 
00038 namespace casa {
00039 
00040 //# Forward declarations.
00041 class PlotMSAxesTab;
00042 class PlotMSCacheTab;
00043 class PlotMSCanvasTab;
00044 class PlotMSDataTab;
00045 class PlotMSDisplayTab;
00046 class PlotMSIterateTab;
00047 class PlotMSExportTab;
00048 class PlotMSTransformationsTab;
00049 class PlotMSPlotTab;
00050 
00051 
00052 // Subclass of PlotMSTab for tabs that are meant to be used as subtabs in a
00053 // PlotMSPlotTab.
00054 class PlotMSPlotSubtab : public PlotMSTab {
00055     Q_OBJECT
00056     
00057 public:
00058     // Constructor which takes the parent tab and plotter.
00059     PlotMSPlotSubtab(PlotMSPlotTab* plotTab, PlotMSPlotter* parent);
00060     
00061     // Destructor.
00062     virtual ~PlotMSPlotSubtab();
00063     
00064     
00065     // Gets/Sets the MS filename, selection, and averaging using a
00066     // PlotMSPlotParameters.
00067     // <group>
00068     virtual void getValue(PlotMSPlotParameters& params) const = 0;
00069     virtual void setValue(const PlotMSPlotParameters& params) = 0;
00070     // </group>
00071     
00072     // Updates the labels and other widgets in the subtab using the given
00073     // plot to check changes against.
00074     virtual void update(const PlotMSPlot& plot) = 0;
00075     
00076     
00077     // Implements PlotMSParametersWatcher::parametersHaveChanged() to do
00078     // nothing unless overridden in the child class.
00079     virtual void parametersHaveChanged(const PlotMSWatchedParameters& params,
00080             int updateFlag)   {  (void)params,(void)updateFlag; }
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 PlotMSOverPlot;
00106     friend class PlotMSPlot;
00107     friend class PlotMSPlotter;
00108     friend class PlotMSIterPlot;
00109     
00110 public:
00111     // Constructor which takes the parent plotter.
00112     PlotMSPlotTab(PlotMSPlotter* parent);
00113     
00114     // Destructor.
00115     ~PlotMSPlotTab();
00116     
00117     
00118     // Implements PlotMSTab::tabName().
00119     QString tabName() const { return "Plots"; }
00120     
00121     // Overrides PlotMSTab::toolButtons().  Should be called AFTER any tabs
00122     // are added using addTab().
00123     QList<QToolButton*> toolButtons() const;
00124     
00125     // Implements PlotMSParametersWatcher::parametersHaveChanged().  Updates
00126     // the GUI as needed if the given parameters are the current PlotMSPlot's
00127     // parameters.
00128     void parametersHaveChanged(const PlotMSWatchedParameters& params,
00129             int updateFlag);
00130     
00131     // Implements PlotMSPlotManagerWatcher::plotsChanged().
00132     void plotsChanged(const PlotMSPlotManager& manager);
00133     
00134     
00135     // Returns the currently selected plot.
00136     PlotMSPlot* currentPlot() const;
00137     
00138     // Returns the parameters currently set by the user on the GUI (but NOT
00139     // necessarily set on the underlying plot parameters).
00140     PlotMSPlotParameters currentlySetParameters() const;
00141     
00142     // Returns the PlotExportFormat currently set by the user on the GUI.
00143     PlotExportFormat currentlySetExportFormat() const;
00144     
00145     // Returns the axes that the user has selected to load into the cache.
00146     vector<PMS::Axis> selectedLoadAxes() const {
00147         return selectedLoadOrReleaseAxes(true); }
00148     
00149     // Returns the axes that the user has selected to release from the cache.
00150     vector<PMS::Axis> selectedReleaseAxes() const {
00151         return selectedLoadOrReleaseAxes(false); }
00152     
00153     // Returns the MS summary type the user has selected.
00154     // <group>
00155     bool msSummaryVerbose() const;
00156     PMS::SummaryType msSummaryType() const;
00157     // </group>
00158     
00159 public slots:
00160     // Slot for doing the plot, using the parameters set on the GUI for the
00161     // current plot.
00162     void plot();
00163         void observeModKeys();
00164     
00165     
00166 protected:
00167     // Clears set subtabs.
00168     void clearSubtabs();
00169     
00170     // Clears set subtabs after (and including) the given index.
00171     void clearSubtabsAfter(int index);
00172     
00173     // Adds the given subtab to the end of the tab widget.
00174     void addSubtab(PlotMSPlotSubtab* tab);
00175     
00176     // Inserts the given subtab in the tab widget.
00177     void insertSubtab(int index, PlotMSPlotSubtab* tab);
00178     
00179     // Inserts one of the known subtab types if it is not already present,
00180     // and returns a pointer to it.
00181     // <group>
00182     PlotMSAxesTab* addAxesSubtab();
00183     PlotMSAxesTab* insertAxesSubtab(int index);
00184     PlotMSCacheTab* addCacheSubtab();
00185     PlotMSCacheTab* insertCacheSubtab(int index);
00186     PlotMSCanvasTab* addCanvasSubtab();
00187     PlotMSCanvasTab* insertCanvasSubtab(int index);
00188     PlotMSDataTab* addDataSubtab();
00189     PlotMSDataTab* insertDataSubtab(int index);
00190     PlotMSDisplayTab* addDisplaySubtab();
00191     PlotMSDisplayTab* insertDisplaySubtab(int index);
00192     PlotMSIterateTab* addIterateSubtab();
00193     PlotMSIterateTab* insertIterateSubtab(int index);
00194     PlotMSExportTab* addExportSubtab();
00195     PlotMSExportTab* insertExportSubtab(int index);
00196     PlotMSTransformationsTab* addTransformationsSubtab();
00197     PlotMSTransformationsTab* insertTransformationsSubtab(int index);
00198 
00199     // </group>
00200     
00201     // Returns the first subtab with the given type, or NULL if there are none
00202     // of that type.
00203     template <class T>
00204     T* subtab() {
00205         T* t;
00206         foreach(PlotMSPlotSubtab* tab, itsSubtabs_)
00207             if((t = dynamic_cast<T*>(tab)) != NULL) return t;
00208         return NULL;
00209     }
00210     
00211 private:    
00212     // PlotMSPlotSubtab objects in tab widget.
00213     QList<PlotMSPlotSubtab*> itsSubtabs_;
00214     
00215     // Reference to plot manager.
00216     PlotMSPlotManager& itsPlotManager_;
00217     
00218     // Currently selected plot.
00219     PlotMSPlot* itsCurrentPlot_;
00220     
00221     // Parameters for the currently selected plot.
00222     PlotMSPlotParameters* itsCurrentParameters_;
00223     
00224     // Whether or not to check for changed parameters and update the GUI
00225     // accordingly.
00226     bool itsUpdateFlag_;
00227     
00228     // Bitflags report if shift, etc were down during click of Plot button
00229     Qt::KeyboardModifiers itsModKeys;  
00230     
00231     // Flag set if user uses shift+plot or otherwise requests reload&replot
00232     bool its_force_reload;
00233     int forceReloadCounter_;
00234     
00235     // Sets up the GUI to display the parameters for the given plot.
00236     void setupForPlot(PlotMSPlot* plot);
00237     
00238     // Returns the axes the user has selected to load or release, depending on
00239     // the load flag. 
00240     vector<PMS::Axis> selectedLoadOrReleaseAxes(bool load) const;
00241     
00242 private slots:
00243     // Slot for when the user changes the "go" chooser on the top.
00244     void goChanged(int index);
00245 
00246     // Slot for when the user clicks "go" on the top of the tab.
00247     void goClicked();
00248 
00249     // Slot for when the user changes the value for any parameters.  Updates
00250     // the GUI to show which parameters have been changed (if any).
00251     void tabChanged();
00252 
00253     
00254 };
00255 
00256 }
00257 
00258 #endif /* PLOTMSPLOTTAB_QO_H_ */