casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotMSPlotManager.h
Go to the documentation of this file.
1 //# PlotMSPlotManager.h: Manages PlotMSPlots for plotms.
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 PLOTMSPLOTMANAGER_H_
28 #define PLOTMSPLOTMANAGER_H_
29 
32 
33 namespace casa {
34 
35 //# Forward Declararations
36 class PlotMSApp;
37 class PlotMSPlot;
38 class PlotMSPlotManagerWatcher;
39 class PlotMSPlotParameters;
40 
41 
42 // Class which manages PlotMSPlots for plotms. Mainly handles adding new plots
43 // and managing their PlotCanvases and the arrangement of PlotCanvases in the
44 // Plotter. Any PlotMSPlots should be owned by the manager, which will handle
45 // deletion as necessary.
47 
48  //# Friend class declarations.
49  friend class PlotMSPlot;
50 
51 public:
52  // Constructor. Parent must be set using setParent() before manager can be
53  // used.
55 
56  // Destructor.
58 
59 
60  // Gets/Sets the parent PlotMS.
61  // <group>
62  PlotMSApp* parent();
63  void setParent(PlotMSApp* parent);
64  // </group>
65 
66  // Returns the plotter used by the parent.
68 
69  // Adds the given watcher to this manager.
70  void addWatcher(PlotMSPlotManagerWatcher* watcher);
71 
72  // Removes the given watcher from this manager.
74 
75 
76  // Returns the number of plots.
77  unsigned int numPlots() const;
78 
79  // Returns all or one of the plots.
80  // <group>
81  const std::vector<PlotMSPlot*>& plots() const;
82  PlotMSPlot* plot(unsigned int index);
83  const PlotMSPlot* plot(unsigned int index) const;
84  QList<PlotMSPlot*> getCanvasPlots( int row, int col ) const;
85  // </group>
86 
87  //Set the new size of a multi-plot display.
88  bool pageGridChanged( int rows, int cols, bool override );
89 
90  //Return the current size of a multi-plot page grid.
91  void getGridSize( casacore::Int& rows, casacore::Int& cols );
92 
93  // Returns all or one of the plot parameters.
94  // <group>
95  const std::vector<PlotMSPlotParameters*>& plotParameters() const;
96  PlotMSPlotParameters* plotParameters(unsigned int index);
97  // </group>
98 
99  // Creates a new PlotMSPlot, initializes it properly,
100  // adds it to the plotter, and returns a pointer to it.
101  // If parameters are given, they are used; otherwise the
102  // defaults are used.
103  PlotMSPlot* addOverPlot(const PlotMSPlotParameters* p = NULL);
104 
105  //Remove a plot from the display.
106  void removePlot( PlotMSPlot* plot );
107 
108  // Clears out all plots and canvases.
109  void clearPlotsAndCanvases( bool clearCanvases = true );
110  void clearCanvas(int row, int col );
111  bool findEmptySpot( casacore::Int& row, casacore::Int& col );
112 
113  void unassignPlots();
114 
115  std::vector<casacore::String> getFiles() const;
116 
117  //Returns the parameters that control the page display (grid rows & cols).
119 
120  //Returns whether or not a canvas has been allocated
121  //for the plot.
122  bool isPlottable( PlotMSPlot* plot );
123 
124  bool isOwner( int row, int col, PlotMSPlot* plot );
125 
126 
127 
128 private:
129  // Parent.
131 
132  // Plotter.
134 
135  // Plot factory.
137 
138  // Plots. Will be deleted on destruction.
139  std::vector<PlotMSPlot*> itsPlots_;
140 
141  // Plot parameters. Will not be deleted on destruction.
142  std::vector<PlotMSPlotParameters*> itsPlotParameters_;
143 
144  // Watchers.
145  std::vector<PlotMSPlotManagerWatcher*> itsWatchers_;
146 
147  // Plot pages.
149 
150 
151  // Helper method for add*Plot methods.
152  void addPlot(PlotMSPlot* plot, const PlotMSPlotParameters* p);
153 
154  // Notifies any watchers that the managed plots have changed.
155  void notifyWatchers() const;
156 
157  //Wait for existing draw threads to finish before we proceed so
158  //we don't get a seg fault from a draw thread hanging onto deleted
159  //data.
160  void waitForDrawing();
161 
162  //Post a plot message to the logger.
163  void logMessage( const QString& msg ) const;
164 };
165 
166 
167 // Interface for any class that wants to be notified when the plots in the
168 // manager have changed.
170 public:
171  // Constructor.
173 
174  // Destructor.
176 
177 
178  // Will be called whenever the plots in the manager change.
179  virtual void plotsChanged(const PlotMSPlotManager& manager) = 0;
180 };
181 
182 }
183 
184 #endif /* PLOTMSPLOTMANAGER_H_ */
bool findEmptySpot(casacore::Int &row, casacore::Int &col)
bool isOwner(int row, int col, PlotMSPlot *plot)
PlotMSApp * itsParent_
Parent.
int Int
Definition: aipstype.h:50
void notifyWatchers() const
Notifies any watchers that the managed plots have changed.
void clearCanvas(int row, int col)
unsigned int numPlots() const
Returns the number of plots.
QList< PlotMSPlot * > getCanvasPlots(int row, int col) const
void getGridSize(casacore::Int &rows, casacore::Int &cols)
Return the current size of a multi-plot page grid.
PlotMSPlotManager()
Constructor.
PlotMSParameters getPageParameters()
Returns the parameters that control the page display (grid rows &amp; cols).
Parameters for a PlotMSPlot.
Subclass of PlotMSWatchedParameters that hold parameters for the whole plotter.
std::vector< PlotMSPlot * > itsPlots_
Plots.
PlotMSPlot * addOverPlot(const PlotMSPlotParameters *p=NULL)
Creates a new PlotMSPlot, initializes it properly, adds it to the plotter, and returns a pointer to i...
void removeWatcher(PlotMSPlotManagerWatcher *watcher)
Removes the given watcher from this manager.
Controller class for plotms.
Definition: PlotMS.h:55
~PlotMSPlotManager()
Destructor.
PlotMSPages itsPages_
Plot pages.
virtual void plotsChanged(const PlotMSPlotManager &manager)=0
Will be called whenever the plots in the manager change.
void addPlot(PlotMSPlot *plot, const PlotMSPlotParameters *p)
Helper method for add*Plot methods.
void removePlot(PlotMSPlot *plot)
Remove a plot from the display.
PlotMSApp * parent()
Gets/Sets the parent PlotMS.
Class for a single &quot;plot&quot; concept.
Definition: PlotMSPlot.h:57
PlotMSPlot * plot(unsigned int index)
PlotterPtr plotter()
Returns the plotter used by the parent.
Interface for any class that wants to be notified when the plots in the manager have changed...
void addWatcher(PlotMSPlotManagerWatcher *watcher)
Adds the given watcher to this manager.
const std::vector< PlotMSPlotParameters * > & plotParameters() const
Returns all or one of the plot parameters.
void setParent(PlotMSApp *parent)
virtual ~PlotMSPlotManagerWatcher()
Destructor.
void clearPlotsAndCanvases(bool clearCanvases=true)
Clears out all plots and canvases.
PlotFactoryPtr itsFactory_
Plot factory.
std::vector< PlotMSPlotManagerWatcher * > itsWatchers_
Watchers.
bool isPlottable(PlotMSPlot *plot)
Returns whether or not a canvas has been allocated for the plot.
void logMessage(const QString &msg) const
Post a plot message to the logger.
const std::vector< PlotMSPlot * > & plots() const
Returns all or one of the plots.
Class which manages PlotMSPlots for plotms.
void waitForDrawing()
Wait for existing draw threads to finish before we proceed so we don&#39;t get a seg fault from a draw th...
Represents (potentially) multiple pages for PlotMS, with one being current (visible) at a time...
Definition: PlotMSPages.h:39
PlotterPtr itsPlotter_
Plotter.
std::vector< casacore::String > getFiles() const
bool pageGridChanged(int rows, int cols, bool override)
Set the new size of a multi-plot display.
std::vector< PlotMSPlotParameters * > itsPlotParameters_
Plot parameters.