PlotMSPages.h

Go to the documentation of this file.
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 
00028 #ifndef PLOTMSPAGES_H_
00029 #define PLOTMSPAGES_H_
00030 
00031 #include <plotms/Plots/PlotMSPage.h>
00032 
00033 namespace casa {
00034 
00035 class PlotMSParameters;
00036 
00037 // Represents (potentially) multiple pages for PlotMS, with one being current
00038 // (visible) at a time.
00039 class PlotMSPages {
00040 
00041     //# Friend class declarations.
00042     friend class PlotMSPage;
00043     friend class PlotMSPlot;
00044     friend class PlotMSPlotManager;
00045 
00046 public:
00047     // Constructor, which the plot manager.
00048     PlotMSPages(PlotMSPlotManager& manager);
00049 
00050     // Copy constructor.
00051     PlotMSPages(const PlotMSPages& copy);
00052 
00053     // Destructor.
00054     ~PlotMSPages();
00055 
00056     // Returns the current page number.
00057     unsigned int currentPageNumber() const;
00058 
00059     // Returns a COPY of the current page.
00060     PlotMSPage currentPage() const;
00061 
00062     PlotMSPage getFirstPage() const;
00063 
00064     void setCurrentPageNum(uInt num);
00065 
00066     // Accessor
00067     PlotMSPage& operator[](uInt index) { return itsPages_[index]; }
00068 
00069     // Iterators
00070     typedef vector<PlotMSPage>::iterator iterator;
00071     iterator begin() { return itsPages_.begin(); }
00072     iterator end() { return itsPages_.end(); }
00073 
00074     typedef vector<PlotMSPage>::const_iterator const_iterator;
00075     const_iterator begin() const { return itsPages_.begin(); }
00076     const_iterator end() const { return itsPages_.end(); }
00077 
00078     // Returns the total pages.
00079     unsigned int totalPages() const;
00080 
00081     // Clear all pages
00082     void clear() { itsPages_.clear(); }
00083 
00084     void resize(size_t pages);
00085 
00086     //Erase all traces of a plot at the specific location including removing axes and title.
00087     void clearCanvas( int row, int col );
00088 
00089     //Erase axes & titles from all the canvases.
00090     void clearCanvases();
00091 
00092         //Resize the page to the current number of rows and columns.
00093     bool gridChanged( int rows, int cols);
00094 
00095     // Copy operator.
00096     PlotMSPages& operator=(const PlotMSPages& copy);
00097 
00098     // Iterators
00099     void firstPage();
00100     void nextPage();
00101     void previousPage();
00102     void lastPage();
00103 
00104     // Inserts a new page at the given index, and returns it.  If the given
00105     // index is invalid, the page is inserted at the end.
00106     PlotMSPage insertPage(int index = -1);
00107 
00108     // Clears all pages.
00109     void clearPages();
00110 
00111     // Sets up the current page (see PlotMSPage::setupPage()).
00112     void setupCurrentPage();
00113 
00114     //Remove the plot from the canvas.
00115     void disown( PlotMSPlot* plot );
00116     void disown( int row, int col, PlotMSPlot* plot );
00117 
00118     bool canvasIsOwnedBy( int row, int col, PlotMSPlot* plot ) const;
00119 
00120     PlotMSParameters getPageParameters();
00121     
00122     //Returns whether the spot at the given location is available for
00123     //the plot (either empty or the plot is already occupying it).
00124     bool isSpot( int rowIndex, int colIndex, PlotMSPlot* plot ) const;
00125     
00126     //Returns the row and column index of the first canvas on the
00127     //page, or <-1,-1> if the page is full.
00128     std::pair<int,int> findEmptySpot() const;
00129 
00130 private:
00131         //Returns whether or not (rows,cols) would represent
00132         //a change in the current page size.
00133     bool isGridChanged( int rows, int cols ) const;
00134 
00135 
00136 
00137     // Plot manager.
00138     PlotMSPlotManager* itsManager_;
00139 
00140     // Pages.
00141     vector<PlotMSPage> itsPages_;
00142 
00143     // Current page number.
00144     unsigned int itsCurrentPageNum_;
00145 };
00146 
00147 
00148 
00149 } /* namespace ff */
00150 #endif /* PLOTMSPAGES_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1