casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
PlotMSIterPlot.h
Go to the documentation of this file.
00001 //# PlotMSIterPlot.h: Subclass of PlotMSPlot for a single plot/canvas.
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 PLOTMSITERPLOT_H_
00028 #define PLOTMSITERPLOT_H_
00029 
00030 #include <plotms/Plots/PlotMSPlot.h>
00031 
00032 #include <casa/namespace.h>
00033 #include <plotms/Data/PlotMSIndexer.h>
00034 #include <plotms/Data/MSCache.h>
00035 
00036 namespace casa {
00037 
00038 // Implementation of PlotMSPlot for a single plot on a single canvas.  Uses
00039 // PlotMSSinglePlotParameters in addition to PlotMSPlotParameters.
00040 class PlotMSIterPlot : public PlotMSPlot {
00041 public:
00042     // Static //    
00043     
00044     // See PlotMSPlot::makeParameters().
00045     // <group>
00046     static PlotMSPlotParameters makeParameters(PlotMSApp* plotms);
00047     static void makeParameters(PlotMSPlotParameters& params, PlotMSApp* plotms);
00048     // </group>
00049     
00050     
00051     // Simple class to hold parameter to resume updating after a threaded
00052     // cache loading.
00053     class TCLParams {
00054     public:
00055         // Constructor.
00056         TCLParams() : releaseWhenDone(false), updateCanvas(false),
00057                 updateDisplay(false), endCacheLog(false) { }
00058         
00059         // Destructor.
00060         ~TCLParams() { }
00061         
00062         // Parameters.
00063         // <group>
00064         bool releaseWhenDone;
00065         bool updateCanvas;
00066         bool updateDisplay;
00067         bool endCacheLog;
00068         // </group>
00069     };
00070     
00071     
00072     // Non-Static //
00073     
00074     // Constructor which takes the PlotMS parent.  Starts out with default
00075     // parameters.
00076     PlotMSIterPlot(PlotMSApp* parent);
00077     
00078     // Destructor.
00079     ~PlotMSIterPlot();
00080     
00081     
00082     // Include overloaded methods.
00083     using PlotMSPlot::initializePlot;
00084     
00085     
00086     // Implements PlotMSPlot::name().
00087     String name() const;
00088     
00089     // implement PlotMSPlot::spectype().
00090     String spectype() const { return "Iter";};
00091 
00092     // Implements PlotMSPlot::plots().
00093     vector<MaskedScatterPlotPtr> plots() const;
00094     
00095     // Implements PlotMSPlot::canvases().
00096     vector<PlotCanvasPtr> canvases() const;
00097     
00098     // Implements PlotMSPlot::setupPlotSubtabs().
00099     void setupPlotSubtabs(PlotMSPlotTab& tab) const;
00100     
00101     // Implements PlotMSPlot::attachToCanvases().
00102     void attachToCanvases();
00103     
00104     // Implements PlotMSPlot::detachFromCanvases().
00105     void detachFromCanvases();
00106     
00107     // Implements PlotMSPlot::plotTabHasChanged().
00108     void plotTabHasChanged(PlotMSPlotTab& tab) { (void)tab; }
00109 
00110     // Step the iteration
00111     bool firstIter();
00112     bool prevIter();
00113     bool nextIter();
00114     bool lastIter();
00115 
00116     virtual Int iter() { return iter_; };
00117 
00118 protected:
00119     // Implements PlotMSPlot::assignCanvases().
00120     bool assignCanvases(PlotMSPages& pages);
00121     
00122     // Implements PlotMSPlot::initializePlot().
00123     bool initializePlot();
00124     
00125     // Implements PlotMSPlot::parametersHaveChanged_().
00126     bool parametersHaveChanged_(const PlotMSWatchedParameters& params,
00127                 int updateFlag, bool releaseWhenDone);
00128     
00129     // Implements PlotMSPlot::selectedRegions().
00130     PlotMSRegions selectedRegions(
00131                 const vector<PlotCanvasPtr>& canvases) const;
00132     
00133     // Overrides PlotMSPlot::constructorSetup().
00134     void constructorSetup();
00135 
00136     // Clear the underlying data cache
00137     virtual bool updateData() { itsCache_->clear();  return True; };   
00138 
00139 
00140 private:    
00141     // Convenient access to single plot.
00142     MaskedScatterPlotPtr itsPlot_;
00143     
00144     // Convenient access to single plot as a colored plot.
00145     ColoredPlotPtr itsColoredPlot_;
00146     
00147     // Convenient access to single canvas.
00148     PlotCanvasPtr itsCanvas_;
00149     
00150     // See TCLParams class documentation
00151     TCLParams itsTCLParams_;
00152     
00153   // The indexer
00154   PlotMSIndexerPtr itsIndexer_;
00155 
00156 
00157   // Iteration counter
00158   Int iter_;
00159 
00160     // Disable copy constructor and operator for now.
00161     // <group>
00162     PlotMSIterPlot(const PlotMSIterPlot& copy);
00163     PlotMSIterPlot& operator=(const PlotMSIterPlot& copy);
00164     // </group>
00165     
00166     // Updates helper methods.
00167     // <group>
00168     bool updateCache();
00169     bool updateIndexing();
00170     bool resetIter();
00171     bool updateCanvas();
00172     bool updateDisplay();
00173     // </group>
00174     
00175     // Set default colors
00176     void setColors();
00177 
00178     // Log the number of points plotted; 
00179     void logPoints();
00180     
00181     // Log iteration info
00182     void logIter(Int iter,Int nIter);
00183 
00184     // Post-thread methods for loading the cache.
00185     public:
00186         static void cacheLoaded (void *obj, bool wasCanceled)
00187         {
00188              PlotMSIterPlot *cobj = static_cast < PlotMSIterPlot * >(obj);
00189              if (cobj != NULL)
00190                   cobj->cacheLoaded_ (wasCanceled);
00191         }
00192         
00193         private:
00194         void cacheLoaded_ (bool wasCanceled);
00195         
00196     static const uInt pixelThreshold;
00197     static const uInt mediumThreshold;
00198     static const uInt largeThreshold;
00199 };
00200 
00201 }
00202 
00203 #endif /* PLOTMSSINGLEPLOT_H_ */