casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotMSPage.h
Go to the documentation of this file.
1 //# PlotMSPage.h: Layout of PlotCanvases on a single "page".
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 PLOTMSPAGE_H_
28 #define PLOTMSPAGE_H_
29 
31 
32 #include <QList>
33 
34 namespace casa {
35 
36 //# Forward Declarations.
37 class PlotMSPages;
38 class PlotMSPlot;
39 class PlotMSPlotManager;
40 
41 
42 // Represents a single page of PlotCanvases, arranged in a grid.
43 class PlotMSPage {
44 
45  //# Friend class declarations.
46  friend class PlotMSPlot;
47  friend class PlotMSPages;
48 
49 public:
50  // Copy constructor.
51  PlotMSPage(const PlotMSPage& copy);
52 
53  // Destructor.
54  ~PlotMSPage();
55 
56  // Returns the number of rows/columns of the canvas grid on this page.
57  // <group>
58  unsigned int canvasRows() const;
59  unsigned int canvasCols() const;
60  // </group>
61 
62  //Erase all trace of this plot
63  void disown( PlotMSPlot* plot );
64 
65  //Erase all traces of a plot at the specific location including removing axes and title.
66  void clearCanvas( int row, int col );
67 
68  //Remove axes and titles from all the canvases.
69  void clearCanvases();
70 
71  // Copy operator.
73 
74  // Returns true if the canvas at (rowIndex, colIndex) does not yet have
75  // a plot or if it already has the plot passed in; return false otherwise.
76  bool isSpot( int rowIndex, int colIndex, PlotMSPlot* plot ) const;
77 
78  // Returns the <rowIndex,colIndex> of the first available canvas that does
79  // not yet have a plot. Returns <-1,-1> if there are no canvases without
80  // plots.
81  std::pair<int,int> findEmptySpot() const;
82 
83  //Returns whether or not the plot is the owner of a canvas located at the given
84  //rowIndex and colIndex.
85  bool isOwner( int rowIndex, int colIndex, PlotMSPlot* plot ) const;
86 
87 
88 private:
89  // Resizes the grid to the given number of rows and columns.
90  void resize(unsigned int nrows, unsigned int ncols);
91 
92  // Parent.
94 
95  // Canvases grid.
96  std::vector<std::vector<PlotCanvasPtr > > itsCanvases_;
97 
98  // Owner grid.
99  std::vector<std::vector<QList<PlotMSPlot*> > > itsCanvasOwners_;
100 
101 
102  // Constructor.
103  PlotMSPage(PlotMSPages& parent);
104 
105  //Returns true if the canvas at the given row and col was disowned; false otherwise.
106  bool disown( int row, int col );
107 
108  // Returns the canvas at the given row and column, or NULL if invalid.
109  PlotCanvasPtr canvas(unsigned int row, unsigned int col);
110 
111  // Returns the owner plot(s) at the given row and column, or an empty list if invalid
112  // or there is no owner for that canvas. For overplotting, there could be multiple owners
113  // of the canvas at the given location.
114  QList<PlotMSPlot*> owner(unsigned int row, unsigned int col) const;
115 
116  // Sets the owner for the canvas at the given row and column to the given
117  // plot; returns true for success, false otherwise. If the given canvas is
118  // already owned, it must first be disowned by its old owner.
119  bool setOwner(unsigned int row, unsigned int col, PlotMSPlot* plot);
120 
121  // Returns true if the canvas at the given row and column exists and is
122  // owned, false otherwise.
123  bool isOwned(unsigned int row, unsigned int col);
124 
125 
126  // Sets the canvas at the given row and column to be owned by no one. All
127  // items are removed from the canvas. Returns true for success, false for
128  // failure.
129  bool disown(unsigned int row, unsigned int col, PlotMSPlot* plot);
130 
131  // Sets up this page on the plotter.
132  void setupPage();
133 };
134 
135 
136 
137 
138 }
139 
140 #endif /* PLOTMSPAGE_H_ */
std::vector< std::vector< PlotCanvasPtr > > itsCanvases_
Canvases grid.
Definition: PlotMSPage.h:96
Represents a single page of PlotCanvases, arranged in a grid.
Definition: PlotMSPage.h:43
StatsData< AccumType > copy(const StatsData< AccumType > &stats)
bool isOwned(unsigned int row, unsigned int col)
Returns true if the canvas at the given row and column exists and is owned, false otherwise...
bool setOwner(unsigned int row, unsigned int col, PlotMSPlot *plot)
Sets the owner for the canvas at the given row and column to the given plot; returns true for success...
QList< PlotMSPlot * > owner(unsigned int row, unsigned int col) const
Returns the owner plot(s) at the given row and column, or an empty list if invalid or there is no own...
bool isSpot(int rowIndex, int colIndex, PlotMSPlot *plot) const
Returns true if the canvas at (rowIndex, colIndex) does not yet have a plot or if it already has the ...
unsigned int canvasCols() const
std::pair< int, int > findEmptySpot() const
Returns the &lt;rowIndex,colIndex&gt; of the first available canvas that does not yet have a plot...
Class for a single &quot;plot&quot; concept.
Definition: PlotMSPlot.h:57
bool isOwner(int rowIndex, int colIndex, PlotMSPlot *plot) const
Returns whether or not the plot is the owner of a canvas located at the given rowIndex and colIndex...
PlotMSPage & operator=(const PlotMSPage &copy)
Copy operator.
void resize(unsigned int nrows, unsigned int ncols)
Resizes the grid to the given number of rows and columns.
unsigned int canvasRows() const
Returns the number of rows/columns of the canvas grid on this page.
PlotMSPage(const PlotMSPage &copy)
Copy constructor.
void setupPage()
Sets up this page on the plotter.
std::vector< std::vector< QList< PlotMSPlot * > > > itsCanvasOwners_
Owner grid.
Definition: PlotMSPage.h:99
void clearCanvases()
Remove axes and titles from all the canvases.
void disown(PlotMSPlot *plot)
Erase all trace of this plot.
~PlotMSPage()
Destructor.
void clearCanvas(int row, int col)
Erase all traces of a plot at the specific location including removing axes and title.
Represents (potentially) multiple pages for PlotMS, with one being current (visible) at a time...
Definition: PlotMSPages.h:39
PlotMSPages * itsParent_
Parent.
Definition: PlotMSPage.h:93
PlotCanvasPtr canvas(unsigned int row, unsigned int col)
Returns the canvas at the given row and column, or NULL if invalid.