casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotMSPlotTab.qo.h
Go to the documentation of this file.
1 //# PlotMSPlotTab.qo.h: Subclass of PlotMSTab for controlling plot parameters.
2 //# Copyright (C) 2009
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef PLOTMSPLOTTAB_QO_H_
28 #define PLOTMSPLOTTAB_QO_H_
29 
30 #include <plotms/GuiTabs/PlotMSPlotTab.ui.h>
34 
35 namespace casa {
36 
37 //# Forward declarations.
38 class PlotMSAxesTab;
39 class PlotMSCacheTab;
40 class PlotMSCalibrationTab;
41 class PlotMSCanvasTab;
42 class PlotMSDataTab;
43 class PlotMSDisplayTab;
44 class PlotMSIterateTab;
45 class PlotMSExportTab;
46 class PlotMSTransformationsTab;
47 class PlotMSPlotTab;
48 
49 
50 // Subclass of PlotMSTab for tabs that are meant to be used as subtabs in a
51 // PlotMSPlotTab.
52 class PlotMSPlotSubtab : public PlotMSTab {
53  Q_OBJECT
54 
55 public:
56  // Constructor which takes the parent tab and plotter.
57  PlotMSPlotSubtab(PlotMSPlotTab* plotTab, PlotMSPlotter* parent);
58 
59  // Destructor.
60  virtual ~PlotMSPlotSubtab();
61 
62 
63  // Gets/Sets the casacore::MS filename, selection, and averaging using a
64  // PlotMSPlotParameters.
65  // <group>
66  virtual void getValue(PlotMSPlotParameters& params) const = 0;
67  virtual void setValue(const PlotMSPlotParameters& params) = 0;
68  // </group>
69 
70  // Updates the labels and other widgets in the subtab using the given
71  // plot to check changes against.
72  virtual void update(const PlotMSPlot& plot) = 0;
73 
74 
75  // Implements PlotMSParametersWatcher::parametersHaveChanged() to do
76  // nothing unless overridden in the child class.
77  virtual void parametersHaveChanged(const PlotMSWatchedParameters& params,
78  int updateFlag) { (void)params,(void)updateFlag; }
79 
80 
81 
82 signals:
83  // This signal should be emitted whenever the value of the widget changes
84  // because of user interaction.
85  void changed();
86 
87 protected:
88  // Plot tab.
90 
91 
92  // See PlotMSPlotTab::currentlySetParameters().
94 };
95 
96 
97 // Subclass of PlotMSTab that manages PlotMSPlots in the GUI. Watches the
98 // current PlotMSPlot's parameters for changes to update the GUI as needed and
99 // watches the PlotMSPlotManager for changes to the plots.
100 class PlotMSPlotTab : public PlotMSTab, Ui::PlotTab //,
101  // public PlotMSPlotManagerWatcher
102  {
103  Q_OBJECT
104 
105  //# Friend class declarations.
106  friend class PlotMSPlot;
107  friend class PlotMSPlotter;
108 
109 public:
110  // Constructor which takes the parent plotter.
111  PlotMSPlotTab(PlotMSPlotter* parent, int plotIndex = -1);
112 
113  // Destructor.
114  ~PlotMSPlotTab();
115 
116 
117  // Implements PlotMSTab::tabName().
118  QString tabName() const { return "Plot"; }
119 
120  // Overrides PlotMSTab::toolButtons(). Should be called AFTER any tabs
121  // are added using addTab().
122  QList<QToolButton*> toolButtons() const;
123 
124  // Implements PlotMSParametersWatcher::parametersHaveChanged(). Updates
125  // the GUI as needed if the given parameters are the current PlotMSPlot's
126  // parameters.
128  int updateFlag);
129 
130  // Implements PlotMSPlotManagerWatcher::plotsChanged().
131  void plotsChanged(const PlotMSPlotManager& manager, int index=-1, bool show = true);
132 
133  //Return the data to support overplots.
136 
138 
139  // Returns the currently selected plot.
140  PlotMSPlot* currentPlot() const;
141 
142  // Returns the parameters currently set by the user on the GUI (but NOT
143  // necessarily set on the underlying plot parameters).
145 
146 
147  // Returns the axes that the user has selected to load into the cache.
148  std::vector<PMS::Axis> selectedLoadAxes() const {
149  return selectedLoadOrReleaseAxes(true);
150  }
151 
152  // Returns the axes that the user has selected to release from the cache.
153  std::vector<PMS::Axis> selectedReleaseAxes() const {
154  return selectedLoadOrReleaseAxes(false);
155  }
156 
157  // Returns true if the location of this plot is still valid after the grid
158  // size has changed; false otherwise.
159  bool setGridSize( int rowCount, int colCount );
160 
161  //Return the location on the grid for this plot.
162  void getLocation( int& rowIndex, int& colIndex );
163 
164  // Remove this plot.
165  void removePlot();
166 
167  //Returns whether this plot has a valid location on the page where
168  //it can be displayed.
169  bool isPlottable() const;
170 
171  //This was put in to support overplotting. When two plots are sharing the
172  //same canvas, we don't want to trigger a redraw until all the plots sharing
173  //the same canvas are done updating their data in background threads.
174  void completePlotting( bool success );
175 
176  //Remove old data from the plot.
177  void clearData();
178 
179  bool managesPlot( PlotMSPlot* plot ) const;
180 
181 public slots:
182  // Slot for doing the plot, using the parameters set on the GUI for the
183  // current plot.
184  bool plot( bool forceReload);
185 
186 
187 protected:
188  // Clears set subtabs.
189  void clearSubtabs();
190 
191  // Clears set subtabs after (and including) the given index.
192  void clearAfter(int index);
193 
194  // Adds the given subtab to the end of the tab widget.
195  void addSubtab(PlotMSPlotSubtab* tab);
196 
197  // Inserts the given subtab in the tab widget.
198  void insertSubtab(int index, PlotMSPlotSubtab* tab);
199 
200  // Inserts one of the known subtab types if it is not already present,
201  // and returns a pointer to it.
202  // <group>
204  PlotMSAxesTab* insertAxesSubtab(int index);
205 
206  void insertAxes(int index);
208  PlotMSCacheTab* insertCacheSubtab(int index);
209  void insertCache(int index);
212  void insertCalibration(int index);
215  void insertCanvas(int index);
217  PlotMSDataTab* insertDataSubtab(int index);
218  void insertData(int index);
221  void insertDisplay(int index);
224  void insertIterate(int index);
225 
228  void insertTransformations(int index);
229  // </group>
230 
231  // Returns the first subtab with the given type, or NULL if there are none
232  // of that type.
233  template <class T>
234  T* subtab() {
235  T* t;
236  foreach(PlotMSPlotSubtab* tab, itsSubtabs_)
237  if((t = dynamic_cast<T*>(tab)) != NULL) return t;
238  return NULL;
239  }
240 
241 private:
242 
247 
248  // PlotMSPlotSubtab objects in tab widget.
249  QList<PlotMSPlotSubtab*> itsSubtabs_;
250 
251 
252  // Reference to plot manager.
254 
255  // Currently selected plot.
257 
258  // Parameters for the currently selected plot.
260 
261  // Whether or not to check for changed parameters and update the GUI
262  // accordingly.
264  bool closing;
266 
268 
269  // Sets up the GUI to display the parameters for the given plot.
270  void setupForPlot();
271 
272  // Returns the axes the user has selected to load or release, depending on
273  // the load flag.
274  std::vector<PMS::Axis> selectedLoadOrReleaseAxes(bool load) const;
275 
276 private slots:
277 
278  // Slot for when the user changes the value for any parameters.
279  // Updates the GUI to show which parameters have been changed (if any).
280  void tabChanged();
281 
282  //A y-axis has changed its internal data.
283  void changeAxisIdentifier( int index, QString id );
284 
285  //y-axis data has been removed.
286  void removeAxisIdentifier( int index );
287 
288  //void plottableChanged();
289 
290 };
291 
292 }
293 
294 #endif /* PLOTMSPLOTTAB_QO_H_ */
void changeAxisIdentifier(int index, QString id)
A y-axis has changed its internal data.
PlotMSTransformationsTab * insertTransformationsSubtab(int index)
void getLocation(int &rowIndex, int &colIndex)
Return the location on the grid for this plot.
QList< QToolButton * > toolButtons() const
Overrides PlotMSTab::toolButtons().
PlotMSCacheTab * addCacheSubtab()
PlotMSCanvasTab * addCanvasSubtab()
PlotMSPlotParameters * itsCurrentParameters_
Parameters for the currently selected plot.
void addSubtab(PlotMSPlotSubtab *tab)
Adds the given subtab to the end of the tab widget.
PlotMSAxesTab * insertAxesSubtab(int index)
bool itsUpdateFlag_
Whether or not to check for changed parameters and update the GUI accordingly.
void completePlotting(bool success)
This was put in to support overplotting.
PlotMSCacheTab * insertCacheSubtab(int index)
std::vector< PMS::Axis > selectedLoadAxes() const
Returns the axes that the user has selected to load into the cache.
PlotMSAxesTab * addAxesSubtab()
Inserts one of the known subtab types if it is not already present, and returns a pointer to it...
void tabChanged()
Slot for when the user changes the value for any parameters.
virtual void setValue(const PlotMSPlotParameters &params)=0
casacore::String getFileName() const
Subclass of PlotMSTab that handles picking casacore::MS filename, selection, and averaging parameters...
PlotMSPlotTab * itsPlotTab_
Plot tab.
Parameters for a PlotMSPlot.
PlotMSDisplayTab * findDisplayTab()
PlotMSDataTab * insertDataSubtab(int index)
virtual void parametersHaveChanged(const PlotMSWatchedParameters &params, int updateFlag)
Implements PlotMSParametersWatcher::parametersHaveChanged() to do nothing unless overridden in the ch...
casacore::String getAveragingSummary() const
bool plot(bool forceReload)
Slot for doing the plot, using the parameters set on the GUI for the current plot.
void clearAfter(int index)
Clears set subtabs after (and including) the given index.
void changed()
This signal should be emitted whenever the value of the widget changes because of user interaction...
PlotMSAxesTab * findAxesTab()
PlotMSPlotParameters currentlySetParameters() const
Returns the parameters currently set by the user on the GUI (but NOT necessarily set on the underlyin...
PlotMSDataTab * addDataSubtab()
void plotsChanged(const PlotMSPlotManager &manager, int index=-1, bool show=true)
Implements PlotMSPlotManagerWatcher::plotsChanged().
bool managesPlot(PlotMSPlot *plot) const
void insertCanvas(int index)
PlotMSPlot * itsCurrentPlot_
Currently selected plot.
void clearData()
Remove old data from the plot.
void show(const variant &v)
Abstract class for parameters that may be watched by one or more interested classes.
PlotMSPlot * currentPlot() const
Returns the currently selected plot.
void insertDisplay(int index)
virtual void getValue(PlotMSPlotParameters &params) const =0
Gets/Sets the casacore::MS filename, selection, and averaging using a PlotMSPlotParameters.
virtual void update(const PlotMSPlot &plot)=0
Updates the labels and other widgets in the subtab using the given plot to check changes against...
PlotMSTransformationsTab * addTransformationsSubtab()
void parametersHaveChanged(const PlotMSWatchedParameters &params, int updateFlag)
Implements PlotMSParametersWatcher::parametersHaveChanged().
PlotMSCanvasTab * insertCanvasSubtab(int index)
void insertCache(int index)
Subclass of PlotMSPlotSubtab to manage canvas parameters.
void removePlot()
Remove this plot.
Subclass of PlotMSTab that handles picking casacore::MS filename, selection, and averaging parameters...
std::vector< PMS::Axis > selectedReleaseAxes() const
Returns the axes that the user has selected to release from the cache.
Subclass of PlotMSTab for tabs that are meant to be used as subtabs in a PlotMSPlotTab.
PlotMSCalibrationTab * addCalibrationSubtab()
PlotMSPlotSubtab(PlotMSPlotTab *plotTab, PlotMSPlotter *parent)
Constructor which takes the parent tab and plotter.
PlotMSDataTab * findOrCreateDataTab()
PlotMSIterateTab * findIterateTab() const
PlotMSCalibrationTab * insertCalibrationSubtab(int index)
PlotMSPlotParameters currentlySetParameters() const
See PlotMSPlotTab::currentlySetParameters().
void removeAxisIdentifier(int index)
y-axis data has been removed.
PlotMSIterateTab * addIterateSubtab()
void insertCalibration(int index)
Class for a single &quot;plot&quot; concept.
Definition: PlotMSPlot.h:57
QString tabName() const
Implements PlotMSTab::tabName().
virtual ~PlotMSPlotSubtab()
Destructor.
Subclass of PlotMSPlotSubtab to manage plot display parameters.
void clearSubtabs()
Clears set subtabs.
void insertData(int index)
void insertAxes(int index)
PlotMSDisplayTab * addDisplaySubtab()
void setupForPlot()
Sets up the GUI to display the parameters for the given plot.
PlotMSDisplayTab * insertDisplaySubtab(int index)
void insertIterate(int index)
void insertSubtab(int index, PlotMSPlotSubtab *tab)
Inserts the given subtab in the tab widget.
bool setGridSize(int rowCount, int colCount)
Returns true if the location of this plot is still valid after the grid size has changed; false other...
PlotMSPlotTab(PlotMSPlotter *parent, int plotIndex=-1)
Constructor which takes the parent plotter.
Subclass of PlotMSPlotSubtab that manages plot axes parameters.
T * subtab()
Returns the first subtab with the given type, or NULL if there are none of that type.
Abstract parent for any widget that goes in the tabbed side panel of the PlotMSPlotter.
Definition: PlotMSTab.qo.h:48
QList< PlotMSPlotSubtab * > itsSubtabs_
PlotMSPlotSubtab objects in tab widget.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
PlotMSIterateTab * insertIterateSubtab(int index)
High(ish)-level plotter class that manages the GUI (semi-) transparently to the rest of PlotMS...
Subclass of PlotMSTab that handles using a calibration library (initially settable only from casapy s...
bool isPlottable() const
Returns whether this plot has a valid location on the page where it can be displayed.
Class which manages PlotMSPlots for plotms.
PlotMSDataTab * getData()
Return the data to support overplots.
Subclass of PlotMSPlotSubtab to manage plot display parameters.
Subclass of PlotMSTab that manages PlotMSPlots in the GUI.
PlotMSPlotManager & itsPlotManager_
Reference to plot manager.
std::vector< PMS::Axis > selectedLoadOrReleaseAxes(bool load) const
Returns the axes the user has selected to load or release, depending on the load flag.
void insertTransformations(int index)
~PlotMSPlotTab()
Destructor.