casa
$Rev:20696$
|
00001 //# PanelParams.h: this defines all of the optional plotting parameters. 00002 //# Copyright (C) 2007-2008 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 //# 00027 //# 00028 //# ------------------------------------------------------------------------- 00029 //# Change Log 00030 //# Date Name Description 00031 //# 10/29/2007 S.Jaeger Added new messaging 00032 //# 11/14/2007 S.Jaeger Added PlotRangesSet option 00033 #ifndef PANELPARAMS_H 00034 #define PANELPARAMS_H 00035 00036 #include <casa/aips.h> 00037 #include <casa/iostream.h> 00038 #include <casa/BasicSL/String.h> 00039 #include <casa/Arrays/Vector.h> 00040 #include <casa/Arrays/Matrix.h> 00041 #include <casa/Containers/Record.h> 00042 #include <casa/OS/Time.h> 00043 #include <casa/IO/AipsIO.h> 00044 #include <casa/Quanta/MVTime.h> 00045 #include <casa/Quanta/QC.h> 00046 00047 #include <tableplot/TablePlot/TPCallBackHooks.h> 00048 #include <tables/Tables/Table.h> 00049 00050 namespace casa { //# NAMESPACE CASA - BEGIN 00051 // <summary> 00052 // Classes to hold Plot Options. 00053 // </summary> 00054 00055 // <reviewed reviewer="" date="" tests=""> 00056 // </reviewed> 00057 00058 // <prerequisite> 00059 // <li> 00060 // <li> 00061 // </prerequisite> 00062 00063 00064 // <etymology> 00065 // Plot Options ! 00066 // </etymology> 00067 00068 // <synopsis> 00069 // User applications need to create instances of PlotOptions, fill them in, 00070 // and send one in per TablePlot::plotData call. These options are then stored 00071 // in the PanelParams class, and TablePlot holds a bunch of PanelParams, 00072 // corresponding to its BasePlots. 00073 // </synopsis> 00074 00075 // <motivation> 00076 // The need to have all plot options originate from one single place, and to 00077 // have their defaults also set in one single place. 00078 // </motivation> 00079 00080 // <thrown> 00081 // <li> 00082 // <li> 00083 // </thrown> 00084 00085 00086 // <todo asof="$DATE:$"> 00087 // <li> 00088 // </todo> 00089 00090 00091 class PlotOptions 00092 { 00093 public: 00094 //Constructor 00095 PlotOptions(); 00096 00097 //Destructor 00098 ~PlotOptions(); 00099 00100 // Reset to defaults 00101 Bool reset(); 00102 00103 // Return a string of current values to print (for debugging) 00104 String print(); 00105 00106 // Validate Current entries 00107 // Returns 2 Strings, Errors and Warnings. 00108 Vector<String> validateParams(); 00109 00110 // Fill entries from a record 00111 String fillFromRecord(Record &rpop); 00112 00113 // operator= : copy semantics 00114 PlotOptions& operator= (PlotOptions &inplop); 00115 00116 00117 // Layer Independant Plot Parameters 00118 00119 // default : [1,1,1]. 00120 // [nrows, ncols, panel_index] from matplotlib 00121 Vector<Int> PanelMap; 00122 00123 // default : []. 00124 // [xmin,xmax,ymin,ymax] 00125 // If min=max, default data range is used. 00126 Vector<Double> PlotRange; 00127 00128 // default : []. 00129 // [xminSet,xmaxSet,yminSet,ymaxSet] 00130 // Bitmap to indicate which range values have been set 00131 // in the PotRange option. 00132 Vector<Bool> PlotRangesSet; 00133 00134 // default : 'o' 00135 // 'o' : off -> no time formatting 00136 // 'x' : time formatting for x axis 00137 // 'y' : time formatting for y axis 00138 // 'b' : time formatting for x and y axes 00139 String TimePlotChar; 00140 00141 // default : True : 00142 // To use with CrossPlot. 00143 // True : Columns of the Array are the x axis. 00144 // False : Rows of the Array are the x axis. 00145 // (example : for a MeasurementSet and "DATA" 00146 // True : channels on x-axis 00147 // False : correlations on x-axis ) 00148 Bool ColumnsXaxis; 00149 00150 // Default : False 00151 // True : This plot must sit on top of existing plots 00152 // False : This plot will be a fresh plot 00153 // clearing away all existing layers 00154 Bool OverPlot; 00155 00156 // Default : False 00157 // True : OverPlot=False will replace only the 00158 // top layer, and will not clear away 00159 // all existing layers. 00160 // (example : after making an overplot, 00161 // the plotsymbol for the top-most layer 00162 // is to be changed without having to 00163 // replot all existing layers) 00164 // False : OverPlot=False will clear up all 00165 // existing layers, before plotting. 00166 Bool ReplaceTopPlot; 00167 00168 // Default : True 00169 // True : Make TablePlot mimic the matplotlib 00170 // behaviour of automatically clearing panels 00171 // when a new panel overlaps on it. 00172 // False : Do not do the above. The user will 00173 // have to explicitly clear a panel. 00174 // (example : To make a tiny plot 00175 // that sits in a corner, inside an 00176 // existing larger plot.) 00177 // 00178 // 00179 Bool RemoveOldPanels; 00180 00181 // Default : 12 . matplotlib font size 00182 // This is the title size. The x,ylabels are 00183 // 80% of this size. 00184 Double FontSize; 00185 00186 // X axis label 00187 String XLabel; 00188 00189 // Y axis label 00190 String YLabel; 00191 00192 // Title 00193 // For multiline labels, 00194 // beware of newline characters. These strings 00195 // must contain "\\n" in them for newlines. 00196 String Title; 00197 00198 // Default : 8.0 ( in cm ). matplotlib convention 00199 // Must be same for all panels ! 00200 Double WindowSize; 00201 00202 // Default : 1.0 . -> height/width 00203 // Must be same for all panels ! 00204 Double AspectRatio; 00205 00206 // Default : NULL 00207 // If left as NULL, it gets replaced by a 00208 // pointer to TPConvertVase. This is the base 00209 // class that does not modify values read 00210 // from the table. Modifications to TaQL 00211 // expressions, that cannot be written as 00212 // TaQL strings, can go 00213 // in here, and will get applied to every 00214 // value being read from the TaQL result. 00215 TPConvertBase *Convert; 00216 00217 // Default : TPGuiCallBackHooks instance. 00218 // Applications can supply their own custom 00219 // function for application specific formatting. 00220 // (example : chan numbers to frequency vals.) 00221 TPGuiCallBackHooks *CallBackHooks; 00222 00223 // Default : False 00224 // True : If a Scalar or Vector reduction has been 00225 // done using MEAN(), the values are rescaled to account for 00226 // the number of flagged values being averaged 00227 // by TaQL. Note : Try not to use this. 00228 // False : Don't do any scaling correction. This is if 00229 // averaging is via SUM(...)/SUM() 00230 Bool DoScalingCorrection; 00231 00232 // Default : 'none' 00233 // 'row' : iteration plots from multiple 00234 // TaQLs can be run parallely. The 00235 // panels are separated into rows. 00236 // 'col' : iteration plots from multiple 00237 // TaQLs can be run parallely. The 00238 // panels are separated into cols. 00239 String SeparateIter; 00240 00241 // Default : False ( only for CrossPlot ) 00242 // False : Compute the average x axis value 00243 // as the middle of the range being avgd 00244 // True : Compute the average x axis value 00245 // accounting for flagged cell rows/cols. 00246 Bool HonourXFlags; 00247 00248 // Default : [] 00249 // This is the list of Table columns that 00250 // will get sent into the "locate" function 00251 // when triggered by the GUI. 00252 // It will be overridden by anything specified in 00253 // a DumpLocateInfoBase class. 00254 Vector<String> LocateColumns; 00255 00256 00257 // Layer Dependant Plot Parameters 00258 00259 // Default : ',' . matplotlib plotsymbols 00260 String PlotSymbol; 00261 00262 // Default : '' . matplotlib colour string 00263 // Can be a predefined pylab colour 'brown', or 00264 // an html hex string '#7FFF4e', or '(r,g,b)'. 00265 // If specified (length>0), this takes 00266 // precedence over the colour specified via 00267 // PlotSymbol. If a non-predefined colour is 00268 // specified, MultiColour is always False. 00269 String ColourString; 00270 00271 // Default [] : If specified, it will apply to 00272 // the first N plotted points. 00273 Vector<String> PointLabels; 00274 00275 // Default : 10.0 . matplotlib markersize 00276 Double MarkerSize; 00277 00278 // Default : 2.0 . matplotlib linewidth 00279 Double LineWidth; 00280 00281 // Default : 'none' 00282 // 'cellrow' : Cell rows get different colours 00283 // 'cellcol' : Cell cols get different colours 00284 // 'both': rows and cols get different colours 00285 // 'none': rows and cols get the same colour 00286 String MultiColour; 00287 00288 // Default : True 00289 // True : When multiple Tables are sent in simultaneously 00290 // into TablePlot, they go to different Layers and 00291 // automatically increment colours. 00292 // False : All layers begin with the same colour 00293 Bool TableMultiColour; 00294 00295 // Default : False 00296 // True : Plot flagged points in purple 00297 // False : Plot unflagged points in specified colour 00298 // (example : Do an overplot with False and then 00299 // True, to see flagged and unflagged points in 00300 // different colours.) 00301 Bool ShowFlags; 00302 00303 // Default : "main" 00304 // Name of the flag version to use while plotting 00305 // If it doesn't find this name, it uses "main". 00306 String FlagVersion; 00307 00308 // Default : 1 00309 // Start with the first point, and then 00310 // plot only if npoints % SkipNRows == 0 00311 Int SkipNRows; 00312 00313 // Default : 1 00314 // No averaging. 00315 // If >1, averages every N points. 00316 // Users of plotoptions, need to order/sort/select 00317 // the input Table, so that such averaging is 00318 // accurate. 00319 Int AverageNRows; 00320 00321 String FlagExt; 00322 // Default : 'none' : no points are connected by lines. 00323 // If 'tablerow' : number of plots = nchans x ncorrs 00324 // number of points per plot = nrows 00325 // -> points along table rows are connected. 00326 // If 'cellcol' : number of plots = nrows x ncorrs 00327 // number of points per plot = nchans 00328 // -> points along cell cols are connected 00329 // If 'cellrow' : number of plots = nrows x nchans 00330 // number of points per plot = ncorrs 00331 // -> points along cell rows are connected. 00332 // Currently, 'cellcol' and 'cellrow' do the same 00333 // thing. Nplots = nrow, points per plot = nchanxncorr. 00334 String Connect; 00335 00336 // To allow PanelPArams to get access to some private variables 00337 inline Int getParsedParams(Int &timeplot, Int &plotcolour, 00338 String &pyplotsym) { 00339 timeplot=TimePlot_p; 00340 plotcolour=PlotColour_p; 00341 pyplotsym=PyPlotSymbol_p; 00342 return 0; 00343 }; 00344 00345 // Allowed, predefined colours 00346 Int NColours; 00347 Bool useLayerColor; 00348 00349 // A long list of supported colour names. 00350 Vector<String> ColourList; 00351 String pylabcolourstring; 00352 00353 //for chan/time averaging 00354 Bool doAverage; 00355 Matrix<Int> ChanMap; 00356 Matrix<Int> RowMap; 00357 String MSName; 00358 String spwExpr; 00359 00360 private: 00361 00362 // 0:1:2:3 -> 'o','x','y','b' 00363 Int TimePlot_p; 00364 // an Int for the colour part of plotsymbol 00365 Int PlotColour_p; 00366 // just the plotsymbol (without colour) 00367 String PyPlotSymbol_p; 00368 00369 // Has the 'Convert' TPConvertXXX been 00370 // created inside PlotOptions, or by the user ? 00371 // True : created inside here => needs to be 00372 // deleted inside here too, during cleanup. 00373 // False : created outside and supplied in 00374 // => don't try to delete it ! 00375 Bool ConvertIsLocal_p; 00376 00377 }; 00378 00379 // <summary> 00380 // Classes to hold Plot Options plus other parameters for a panel. 00381 // </summary> 00382 00383 // <reviewed reviewer="" date="" tests=""> 00384 // </reviewed> 00385 00386 // <prerequisite> 00387 // <li> 00388 // <li> 00389 // </prerequisite> 00390 00391 00392 // <etymology> 00393 // Panel Parameters. 00394 // </etymology> 00395 00396 // <synopsis> 00397 // Holds PlotOptions for each BasePlot on one panel. Layers are created via 00398 // overplots, as well as by making one plot using multiple Tables. 00399 // There are layer independant and layer dependant parameters. 00400 // Replots after flag editing, need to remember plot options for all 00401 // layers, so this class does it. TablePlot holds a PanelParams object for each panel. 00402 // </synopsis> 00403 00404 // <motivation> 00405 // The need to remember plot options for multiple plot layers, per panel. 00406 // </motivation> 00407 00408 // <thrown> 00409 // <li> 00410 // <li> 00411 // </thrown> 00412 00413 00414 // <todo asof="$DATE:$"> 00415 // <li> 00416 // </todo> 00417 00418 00419 class PanelParams 00420 { 00421 public: 00422 // Constructor 00423 PanelParams(); 00424 00425 // Destructor 00426 ~PanelParams(); 00427 00428 // Change the number of layers 00429 // Usually called only to increase the layer count, 00430 // when overplots are done one-by-one. 00431 Int changeNlayers(Int nlayers); 00432 00433 // Fill in parameters from the most current PlotOptions. 00434 Int updateLayerParams(); 00435 00436 // Reset all parameters. 00437 Bool reset(); 00438 00439 // A PlotOptions instance to read inputs 00440 // and to hold layer-independant parameters. 00441 PlotOptions Plop; 00442 00443 // Layer INDEPENDANT parameters 00444 // The current plot-range for this panel. 00445 Vector<Double> PanelZrange; 00446 00447 // A list of marked regions for this panel. 00448 // FlagList(panelId, regionCount); 00449 Vector<Vector<Double> > FlagList; 00450 00451 // The layer number for the topmost layer. 00452 // NOTE : A layer is a plot from one BasePlot object. 00453 // Sometimes, a single TablePlot::plotData call, 00454 // generates plots from multiple BasePlots. 00455 // All layers from one single TablePlot::plotData 00456 // call, get the same "layerNumber". 00457 Int MaxLayer; 00458 00459 // Integer form of the TimePlot parameter. 00460 Int TimePlot; 00461 00462 // Ingeter form of the plot colour. 00463 // Needed to allow automatic colour incrementing ! 00464 Int PlotColour; 00465 00466 // Python plot symbol. 00467 String PyPlotSymbol; 00468 00469 // LAYER DEPENDANT parameters 00470 // Number of BasePlot-layers. 00471 Int nBP; 00472 00473 // The "layerNumber" for each BasePlot-Plot 00474 Vector<Int> LayerNumbers; 00475 00476 // Other parameters. 00477 Vector<Int> LayerColours; 00478 Vector<String> LayerSymbols; 00479 Vector<Vector<String> > LayerPointLabels; 00480 Vector<Vector<String> > LayerLocateColumns; 00481 Vector<Double> LayerMarkerSizes; 00482 Vector<Double> LayerLineWidths; 00483 Vector<Bool> LayerShowFlags; 00484 Vector<String> LayerMultiColours; 00485 Vector<String> LayerFlagVersions; 00486 Vector<Int> LayerSkipNRows; 00487 Vector<Int> LayerAverageNRows; 00488 Vector<String> LayerFlagExt; 00489 Vector<String> LayerConnects; 00490 Vector<Vector<String> > LayerXYTaqls; 00491 00492 00493 }; 00494 00495 00496 } //# NAMESPACE CASA - END 00497 00498 00499 #endif 00500