00001 //# PlotMSPage.h: Layout of PlotCanvases on a single "page". 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 PLOTMSPAGE_H_ 00028 #define PLOTMSPAGE_H_ 00029 00030 #include <graphics/GenericPlotter/PlotCanvas.h> 00031 00032 #include <QList> 00033 00034 namespace casa { 00035 00036 //# Forward Declarations. 00037 class PlotMSPages; 00038 class PlotMSPlot; 00039 class PlotMSPlotManager; 00040 00041 00042 // Represents a single page of PlotCanvases, arranged in a grid. 00043 class PlotMSPage { 00044 00045 //# Friend class declarations. 00046 friend class PlotMSPlot; 00047 friend class PlotMSPages; 00048 00049 public: 00050 // Copy constructor. 00051 PlotMSPage(const PlotMSPage& copy); 00052 00053 // Destructor. 00054 ~PlotMSPage(); 00055 00056 // Returns the number of rows/columns of the canvas grid on this page. 00057 // <group> 00058 unsigned int canvasRows() const; 00059 unsigned int canvasCols() const; 00060 // </group> 00061 00062 //Erase all trace of this plot 00063 void disown( PlotMSPlot* plot ); 00064 00065 //Erase all traces of a plot at the specific location including removing axes and title. 00066 void clearCanvas( int row, int col ); 00067 00068 //Remove axes and titles from all the canvases. 00069 void clearCanvases(); 00070 00071 // Copy operator. 00072 PlotMSPage& operator=(const PlotMSPage& copy); 00073 00074 // Returns true if the canvas at (rowIndex, colIndex) does not yet have 00075 // a plot or if it already has the plot passed in; return false otherwise. 00076 bool isSpot( int rowIndex, int colIndex, PlotMSPlot* plot ) const; 00077 00078 // Returns the <rowIndex,colIndex> of the first available canvas that does 00079 // not yet have a plot. Returns <-1,-1> if there are no canvases without 00080 // plots. 00081 std::pair<int,int> findEmptySpot() const; 00082 00083 //Returns whether or not the plot is the owner of a canvas located at the given 00084 //rowIndex and colIndex. 00085 bool isOwner( int rowIndex, int colIndex, PlotMSPlot* plot ) const; 00086 00087 00088 private: 00089 // Resizes the grid to the given number of rows and columns. 00090 void resize(unsigned int nrows, unsigned int ncols); 00091 00092 // Parent. 00093 PlotMSPages* itsParent_; 00094 00095 // Canvases grid. 00096 vector<vector<PlotCanvasPtr > > itsCanvases_; 00097 00098 // Owner grid. 00099 vector<vector<QList<PlotMSPlot*> > > itsCanvasOwners_; 00100 00101 00102 // Constructor. 00103 PlotMSPage(PlotMSPages& parent); 00104 00105 //Returns true if the canvas at the given row and col was disowned; false otherwise. 00106 bool disown( int row, int col ); 00107 00108 // Returns the canvas at the given row and column, or NULL if invalid. 00109 PlotCanvasPtr canvas(unsigned int row, unsigned int col); 00110 00111 // Returns the owner plot(s) at the given row and column, or an empty list if invalid 00112 // or there is no owner for that canvas. For overplotting, there could be multiple owners 00113 // of the canvas at the given location. 00114 QList<PlotMSPlot*> owner(unsigned int row, unsigned int col) const; 00115 00116 // Sets the owner for the canvas at the given row and column to the given 00117 // plot; returns true for success, false otherwise. If the given canvas is 00118 // already owned, it must first be disowned by its old owner. 00119 bool setOwner(unsigned int row, unsigned int col, PlotMSPlot* plot); 00120 00121 // Returns true if the canvas at the given row and column exists and is 00122 // owned, false otherwise. 00123 bool isOwned(unsigned int row, unsigned int col); 00124 00125 00126 // Sets the canvas at the given row and column to be owned by no one. All 00127 // items are removed from the canvas. Returns true for success, false for 00128 // failure. 00129 bool disown(unsigned int row, unsigned int col, PlotMSPlot* plot); 00130 00131 // Sets up this page on the plotter. 00132 void setupPage(); 00133 }; 00134 00135 00136 00137 00138 } 00139 00140 #endif /* PLOTMSPAGE_H_ */