PlotMSPlot.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 #ifndef PLOTMSPLOT_H_
00028 #define PLOTMSPLOT_H_
00029 
00030 #include <graphics/GenericPlotter/PlotFactory.h>
00031 #include <plotms/Data/PlotMSCacheBase.h>
00032 #include <plotms/PlotMS/PlotMSRegions.h>
00033 #include <plotms/PlotMS/PlotMS.h>
00034 #include <plotms/Plots/PlotMSPlotParameters.h>
00035 #include <plotms/Plots/PlotMSPlot.h>
00036 #include <plotms/Plots/PlotMSPage.h>
00037 #include <plotms/Data/PlotMSIndexer.h>
00038 
00039 namespace casa {
00040 
00041 
00042 class PlotMSPages;
00043 class PMS_PP_Cache;
00044 class PMS_PP_Canvas;
00045 class PMS_PP_Axes;
00046 class PMS_PP_Iteration;
00047 class PMS_PP_Display;
00048 
00049 
00050 
00051 
00052 
00053 
00054 class PlotMSPlot : public PlotMSParametersWatcher {
00055 public:
00056     
00057     
00058     
00059     
00060     static PlotMSPlotParameters makeParameters(PlotMSApp* plotms);
00061     
00062     
00063     
00064     static void makeParameters(PlotMSPlotParameters& params, PlotMSApp* plotms);
00065     
00066     void customizeAutoSymbol( const PlotSymbolPtr& baseSymbol, uInt dataSize  );
00067     
00068     
00069     
00070     
00071     PlotMSPlot(PlotMSApp* parent);
00072     
00073     
00074     ~PlotMSPlot();
00075 
00076     void resize(PlotMSPages&, uInt rows, uInt cols);
00077 
00078     
00079     
00080     class TCLParams {
00081     public:
00082         
00083         
00084         bool releaseWhenDone;
00085         bool updateCanvas;
00086         bool updateDisplay;
00087         bool endCacheLog;
00088         bool updateIteration;
00089 
00090         
00091 
00092         
00093         TCLParams()
00094             :
00095             releaseWhenDone(false),
00096             updateCanvas(false),
00097             updateDisplay(false),
00098             endCacheLog(false)
00099 
00100         {}
00101     };
00102     
00103     
00104     
00105     String name() const;
00106 
00107     
00108     String spectype() const { return "Unknown";};
00109     
00110     
00111     vector<MaskedScatterPlotPtr> plots() const;
00112     
00113     
00114     vector<PlotCanvasPtr> canvases() const;
00115     
00116     
00117     
00118     void attachToCanvases();
00119     void detachFromCanvases();
00120     Int iter() { return iter_; }
00121     
00122     
00123     
00124     void dataMissing();
00125     
00126     
00127     
00128     
00129     
00130     
00131     void waitForDrawing( bool holdDrawing );
00132 
00133     
00134     
00135     const PlotMSPlotParameters& parameters() const;
00136     PlotMSPlotParameters& parameters();
00137     
00138     
00139     
00140     
00141     vector<PlotCanvasPtr> visibleCanvases() const;
00142    
00143     
00144     virtual PlotMSRegions selectedRegions() const;
00145   
00146     
00147     PlotMSRegions visibleSelectedRegions() const;
00148 
00149     
00150     
00151     
00152     
00153     
00154     
00155     bool initializePlot(PlotMSPages& pages);
00156     
00157     
00158     
00159     PlotMSCacheBase& cache() { return *itsCache_; };
00160     const PlotMSCacheBase& cache() const { return *itsCache_; };
00161     
00162     
00163     
00164     PlotMSApp* parent() { return itsParent_; };
00165     
00166     
00167     bool firstIter();
00168     bool prevIter();
00169     bool nextIter(); 
00170     bool lastIter();
00171     bool setIter( int index );
00172     bool resetIter();
00173     void recalculateIteration();
00174     Int nIter();
00175 
00176     
00177     
00178     void parametersHaveChanged(const PlotMSWatchedParameters& params,
00179             int updateFlag);
00180     
00181     
00182     
00183     void plotDataChanged();
00184     
00185     
00186     bool isIteration() const;
00187 
00188     
00189     
00190     bool exportToFormat(const PlotExportFormat& format);
00191     void exportToFormatCancel();
00192     
00193     void cacheLoaded_(bool wasCanceled);
00194 
00195     
00196     
00197     void canvasWasDisowned(PlotCanvasPtr canvas);
00198     vector<PMS::Axis> getCachedAxes();
00199     vector<PMS::DataColumn> getCachedData();
00200 
00201     Record locateInfo(int plotIterIndex, const Vector<PlotRegion>& regions,
00202                 bool showUnflagged, bool showFlagged, bool selectAll ) const ;
00203 
00204     PlotLogMessage* locateRange( int plotIterIndex, const Vector<PlotRegion> & regions,
00205                 bool showUnflagged, bool showFlagged);
00206 
00207     PlotLogMessage* flagRange( int canvasIndex, casa::PlotMSFlagging& flagging,
00208                 const Vector<PlotRegion>& regions, bool showFlagged);
00209 
00210     
00211     
00212     
00213     
00214     
00215     bool assignCanvases(PlotMSPages& pages);
00216     void updateLocation();
00217 
00218     
00219     void clearCanvases();
00220 
00221     
00222     bool isCacheUpdating() const;
00223     void setCacheUpdating( bool updating );
00224 
00225     void updatePlots();
00226     bool updateIndexing();
00227 
00228     void logPoints();
00229     void logIter(Int iter, Int nIter);
00230 
00231     
00232     
00233     void setRelease( bool b );
00234 
00235     static void cacheLoaded(void *obj, bool wasCanceled){
00236         PlotMSPlot *cobj = static_cast<PlotMSPlot*>(obj);
00237         if(cobj != NULL){
00238                 cobj->setCacheUpdating( false );
00239             if ( ! cobj->itsParent_->guiShown() ){
00240                 cobj->cacheLoaded_(wasCanceled);
00241             }
00242         }
00243     }
00244 
00245 protected:
00246     
00247     
00248     
00249     
00250     
00251     
00252     bool initializePlot();
00253     
00254     
00255     
00256     
00257     bool parametersHaveChanged_(const PlotMSWatchedParameters& params,
00258                                 int updateFlag, bool releaseWhenDone );
00259     
00260     
00261     
00262     PlotMSRegions selectedRegions(
00263             const vector<PlotCanvasPtr>& canvases) const;
00264     
00265     void constructorSetup();
00266     void updatePages();
00267     bool updateCache( );
00268     bool updateCanvas();
00269     bool updateDisplay();
00270     void setColors();
00271     
00272     
00273     bool updateData();
00274     
00275     
00276     
00277     bool allDrawingHeld();
00278     
00279     
00280     void holdDrawing();
00281     
00282     
00283     void releaseDrawing();
00284     
00285     int getPageIterationCount( const PlotMSPage& page );
00286 
00287     void waitOnCanvases();
00288 
00289     
00290     
00291     
00292     PlotMSApp* itsParent_;
00293     
00294     
00295     PlotFactoryPtr itsFactory_;
00296     
00297     
00298     PlotMSPlotParameters itsParams_;
00299     
00300     
00301     PlotMSCacheBase* itsCache_;
00302     
00303     
00304     volatile bool cacheUpdating;
00305 
00306 private:
00307     void waitOnCanvas( const PlotCanvasPtr& canvas );
00308 
00309     
00310     
00311     PlotMSPlot(const PlotMSPlot& copy);
00312     PlotMSPlot& operator=(const PlotMSPlot& copy);
00313     
00314 
00315     
00316     void resizePlots( int rows, int cols );
00317 
00318     
00319     void clearPlotData();
00320 
00321     
00322     void getPlotSize( Int& rows, Int& cols );
00323 
00324     
00325     int getIterationIndex( int r, int c, const PlotMSPage& page );
00326 
00327     
00328     void logMessage( const QString& msg ) const;
00329 
00330     void clearCanvasProperties( int row, int col);
00331     void setCanvasProperties (int row, int col, PMS_PP_Cache*,
00332                 PMS_PP_Axes* axes, bool set, PMS_PP_Canvas *canv,
00333                 uInt rows, uInt cols, PMS_PP_Iteration *iter,
00334                 uInt iteration, PlotMSAveraging averaging );
00335     
00336     bool axisIsAveraged(PMS::Axis axis, PlotMSAveraging averaging);
00337     String addFreqFrame(String freqLabel);
00338     PMS::Axis getCalAxis(String calType, PMS::Axis axis);
00339     PMS::Axis getDefaultXAxis(String calType);
00340 
00341     
00342     
00343     vector<vector<MaskedScatterPlotPtr> > itsPlots_;
00344 
00345     
00346     
00347     vector<vector<PlotCanvasPtr> > itsCanvases_;
00348 
00349     vector<vector<ColoredPlotPtr> > itsColoredPlots_;
00350     TCLParams itsTCLParams_;
00351     int gridRow;
00352     int gridCol;
00353 
00354     Int iter_;
00355     Int iterStep_;
00356 
00357     static const uInt PIXEL_THRESHOLD;
00358     static const uInt MEDIUM_THRESHOLD;
00359     static const uInt LARGE_THRESHOLD;
00360 };
00361 
00362 }
00363 
00364 #endif