PlotMSConstants.h

Go to the documentation of this file.
00001 //# PlotMSConstants.h: Constants and useful classes/methods for plotms.
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 PLOTMSCONSTANTS_H_
00028 #define PLOTMSCONSTANTS_H_
00029 
00030 #include <casa/Containers/Record.h>
00031 #include <graphics/GenericPlotter/PlotFactory.h>
00032 
00033 #include <map>
00034 #include <vector>
00035 
00036 namespace casa {
00037 
00038 // Useful macros for defining enums.  Although the two macros can be used
00039 // separately, their intended use is for them to be used sequentially.
00040 // Parameters:
00041 // * NAME: name of the enum,
00042 // * ALLMETHOD: name of the method that returns a vector of all defined members
00043 //              of the enum (also nALLMETHOD which returns the number of
00044 //              defined members in the enum),
00045 // * ALLSTRMETHOD: name of the method that returns a vector of the string
00046 //                 representation of all defined members of the enum,
00047 // * CONVMETHOD: name of the method that converts between the enum and its
00048 //               String representation,
00049 // * ... (__VA_ARGS__): list of enum methods for PMS_ENUM1 and list of
00050 //                      their string representations for PMS_ENUM2.  IMPORTANT:
00051 //                      if both macros are used then the lists must be the same
00052 //                      size and in the same order.
00053 // <group>
00054 #define PMS_ENUM1(NAME,ALLMETHOD,ALLSTRMETHOD,CONVMETHOD,...)                 \
00055     enum NAME {                                                               \
00056         __VA_ARGS__                                                           \
00057     };                                                                        \
00058                                                                               \
00059     static const vector< NAME >& ALLMETHOD () {                               \
00060         static const NAME arr[] = {                                           \
00061             __VA_ARGS__                                                       \
00062         };                                                                    \
00063         static const int count = sizeof(arr) / sizeof(arr[0]);                \
00064         static const vector< NAME > v(arr, &arr[count]);                      \
00065         return v;                                                             \
00066     }                                                                         \
00067                                                                               \
00068     static unsigned int n##ALLMETHOD () {                                     \
00069         static unsigned int n = ALLMETHOD ().size();                          \
00070         return n;                                                             \
00071     }
00072 
00073 #define PMS_ENUM2(NAME,ALLMETHOD,ALLSTRMETHOD,CONVMETHOD,...)                 \
00074     static const vector<String>& ALLSTRMETHOD () {                            \
00075         static const String arr[] = {                                         \
00076             __VA_ARGS__                                                       \
00077         };                                                                    \
00078         static const int count = sizeof(arr) / sizeof(arr[0]);                \
00079         static const vector<String> v(arr, &arr[count]);                      \
00080         return v;                                                             \
00081     }                                                                         \
00082                                                                               \
00083     static const String& CONVMETHOD ( NAME v) {                               \
00084         return ALLSTRMETHOD ()[v]; }                                          \
00085                                                                               \
00086     static const NAME & CONVMETHOD (const String& v, bool* ok = NULL) {       \
00087         const vector<String>& strs = ALLSTRMETHOD ();                         \
00088         const vector< NAME >& enms = ALLMETHOD ();                            \
00089         for(unsigned int i = 0; i < strs.size(); i++) {                       \
00090             if(PMS::strEq(v, strs[i], true)) {                                \
00091                 if(ok != NULL) *ok = true;                                    \
00092                 return enms[i];                                               \
00093             }                                                                 \
00094         }                                                                     \
00095         if(ok != NULL) *ok = false;                                           \
00096         return enms[0];                                                       \
00097     }
00098 // </group>
00099 
00100 
00101 // Container class for useful constants/methods.
00102 class PMS {
00103 public:
00104     // Enum for the axis choices that are available to be plotted.  Used both
00105     // by the user to select what to plot and by the cache loading system.
00106     // **If these are changed, also update: xmlcasa/tasks/plotms.xml,
00107     // xmlcasa/scripts/task_plotms.py.**
00108     // <group>
00109     PMS_ENUM1(Axis, axes, axesStrings, axis,
00110               SCAN,FIELD,TIME,TIME_INTERVAL,
00111               SPW,CHANNEL,FREQUENCY,VELOCITY,CORR,
00112               ANTENNA1,ANTENNA2,BASELINE,ROW,
00113           OBSERVATION,INTENT,FEED1,FEED2,
00114               AMP,PHASE,REAL,IMAG,WT,WTxAMP,WTSP,
00115               SIGMA, SIGMASP,
00116               FLAG,FLAG_ROW,
00117               UVDIST,UVDIST_L,U,V,W,UWAVE,VWAVE,WWAVE,
00118               AZ0,EL0,HA0,PA0,
00119               ANTENNA,AZIMUTH,ELEVATION,
00120               PARANG,
00121               GAMP,GPHASE,GREAL,GIMAG,
00122               DELAY,SWP,TSYS,OPAC, SNR, TEC,
00123               RADIAL_VELOCITY, RHO, 
00124               NONE)
00125 
00126     PMS_ENUM2(Axis, axes, axesStrings, axis,
00127               "Scan","Field","Time","Interval",
00128               "Spw","Channel","Frequency","Velocity","Corr",
00129               "Antenna1","Antenna2","Baseline","Row",
00130               "Observation", "Intent", "Feed1", "Feed2",
00131               "Amp","Phase","Real","Imag","Wt","Wt*Amp","WtSp",
00132               "Sigma", "SigmaSp", "Flag","FlagRow",
00133               "UVdist","UVwave","U","V","W","Uwave","Vwave","Wwave",
00134               "Azimuth","Elevation","HourAngle","ParAngle",
00135               "Antenna","Ant-Azimuth","Ant-Elevation","Ant-ParAngle",
00136               "Gain Amplitude","Gain Phase","Gain Real","Gain Imag",
00137               "Delay","SwPower","Tsys","Opac", "SNR", "TEC",
00138               "Radial Velocity [km/s]", "Distance (rho) [km]", 
00139               "None")
00140 
00141     // </group>
00142               
00143     // Returns the axes scale for the given axis.  Currently NORMAL unless the
00144     // axis is TIME, in which case the scale is DATE_MJ_SEC.
00145     static PlotAxisScale axisScale(Axis axis);
00146     
00147     
00148     // Enum for the different data columns for data axes.
00149     // **If these are changed, also update: xmlcasa/tasks/plotms.xml.**
00150     // <group>
00151     PMS_ENUM1(DataColumn, dataColumns, dataColumnStrings, dataColumn,
00152               DATA, CORRECTED, MODEL, CORRMODEL, DATAMODEL, DATA_DIVIDE_MODEL, CORRECTED_DIVIDE_MODEL, FLOAT_DATA)
00153     PMS_ENUM2(DataColumn, dataColumns, dataColumnStrings, dataColumn,
00154               "data", "corrected", "model", "corrected-model", "data-model", "data/model", "corrected/model", "float")
00155     // </group>
00156               
00157     // Returns whether or not the given axis needs the second data parameter to
00158     // indicate which data column to use or not.  Currently false except for
00159     // AMP, PHASE, REAL, and IMAG.
00160     static bool axisIsData(Axis axis);
00161     // Cal table axes which need validation/slicing for poln selection
00162     static bool axisNeedsCalSlice(Axis axis);
00163     // Need datacolumn for averaging weight axes          
00164     static bool axisIsWeight(Axis axis);
00165               
00166     // Enum for different axes types.  Currently only used to display this
00167     // information to the user in the GUI's cache tab.
00168     // <group>
00169     PMS_ENUM1(AxisType, axesTypes, axesTypeStrings, axisType,
00170               TBOOL, TINT, TFLOAT, TDOUBLE, TTIME)
00171     PMS_ENUM2(AxisType, axesTypes, axesTypeStrings, axisType,
00172               "boolean", "integer", "float", "double", "time")
00173     //</group>
00174              
00175     // Returns the type for the given axis.
00176     static AxisType axisType(Axis axis);
00177     
00178     
00179     // Enum for different axes units.  Currently only used in labels.
00180     // <group>
00181     PMS_ENUM1(AxisUnit, axesUnits, axesUnitStrings, axisUnit,
00182               UNONE, UDATETIME, GHERTZ, METERS_PER_SECOND, KILOMETERS_PER_SECOND,
00183               KILOMETERS, METERS, HOURS, WAVELENGTHS, DEGREES, NANOSECONDS, KELVIN,
00184               NEPERS, SECONDS);
00185     PMS_ENUM2(AxisUnit, axesUnits, axesUnitStrings, axisUnit,
00186               "", "hh:mm:ss", "GHz", "m/s", "km/s", "km", "m", "hours",
00187               "<html>&lambda;</html>", "degrees", "ns", "K", "neper", "s");
00188 
00189     // </group>
00190               
00191     // Returns the unit for the given axis.
00192     static AxisUnit axisUnit(Axis axis);
00193     
00194     
00195     // Convert to/from dates and doubles, using the given scale (must be either
00196     // DATE_MJ_SEC or DATE_MJ_DAY).
00197     // <group>
00198     static double dateDouble(unsigned int year, unsigned int mon,
00199             unsigned int day, unsigned int hour, unsigned int min,
00200             double sec, PlotAxisScale scale = DATE_MJ_SEC);
00201     static void dateDouble(double value, unsigned int& year, unsigned int& mon,
00202             unsigned int& day, unsigned int& hour, unsigned int& min,
00203             double& sec, PlotAxisScale scale = DATE_MJ_SEC);
00204     // </group>    
00205               
00206     // Returns true if the given Strings are equals, false otherwise.  If
00207     // ignoreCase is false then it is a direct String comparison using ==;
00208     // otherwise the String characters are compared while ignoring case for
00209     // letters.
00210     static bool strEq(const String& str1, const String& str2,
00211                       bool ignoreCase = false);
00212     
00213     // Returns true if the given Records are equals, false otherwise.
00214     static bool recEq(const Record& rec1, const Record& rec2);
00215     
00216     // Converts the given templated vector to/from an int Vector.
00217     // <group>
00218     template <class T>
00219     static Vector<int> toIntVector(const vector<T>& v) {
00220         Vector<int> v2(v.size());
00221         for(unsigned int i = 0; i < v.size(); i++) v2[i] = (int)v[i];
00222         return v2;
00223     }
00224     
00225     template <class T>
00226     static vector<T> fromIntVector(const Vector<int>& v) {
00227         vector<T> v2(v.size());
00228         for(unsigned int i = 0; i < v.size(); i++) v2[i] = (T)v[i];
00229         return v2;
00230     }
00231     // </group>
00232     
00233     
00234     // Enum for the different MS summary types.
00235     // <group>
00236     PMS_ENUM1(SummaryType, summaryTypes, summaryTypeStrings, summaryType,
00237               S_ALL, S_WHERE, S_WHAT, S_HOW, S_MAIN, S_TABLES, S_ANTENNA,
00238               S_FEED, S_FIELD, S_OBSERVATION, S_HISTORY, S_POLARIZATION,
00239               S_SOURCE, S_SPW, S_SPW_POL,
00240               S_SYSCAL, S_WEATHER)
00241 
00242     PMS_ENUM2(SummaryType, summaryTypes, summaryTypeStrings, summaryType,
00243               "All", "Where", "What", "How", "Main", "Tables", "Antenna",
00244               "Feed", "Field", "Observation", "History", "Polarization",
00245               "Source", "Spectral Window", "Spectral Window and Polarization",
00246               "SysCal", "Weather")
00247     // </group>
00248               
00249 
00250    // Enum for export range.
00251    // <group>
00252    PMS_ENUM1(ExportRange, exportRanges, exportRangeStrings, exportRange, PAGE_CURRENT, PAGE_ALL)
00253    PMS_ENUM2(ExportRange, exportRanges, exportRangeStrings, exportRange, "Current Page", "All Pages")
00254    // </group>
00255               
00256 
00257     // Colorizing Values //
00258               
00259     // Returns the list of unique colors used to colorize plots.
00260     static const vector<String>& COLORS_LIST();
00261     
00262     
00263     // Default Parameter Values //
00264     
00265     // Default values for PlotMSParameters.
00266     // <group>
00267     static const String DEFAULT_LOG_FILENAME;
00268     static const int DEFAULT_LOG_EVENTS;
00269     static const LogMessage::Priority DEFAULT_LOG_PRIORITY;
00270     static const bool DEFAULT_CLEAR_SELECTIONS;
00271     static const int DEFAULT_CACHED_IMAGE_WIDTH;
00272     static const int DEFAULT_CACHED_IMAGE_HEIGHT;
00273     static const int DEFAULT_GRID_ROWS;
00274     static const int DEFAULT_GRID_COLS;
00275     // </group>
00276     
00277     // Default values for PMS_PP_Cache.
00278     // <group>
00279     static const Axis DEFAULT_XAXIS;
00280     static const Axis DEFAULT_YAXIS;
00281     static const DataColumn DEFAULT_DATACOLUMN;
00282     static const DataColumn DEFAULT_DATACOLUMN_WT;
00283     static const Axis DEFAULT_COLOR_AXIS;
00284     // </group>
00285     
00286     // Default values for PMS_PP_Canvas.
00287     // <group>
00288     static const PlotAxis DEFAULT_CANVAS_XAXIS;
00289     static const PlotAxis DEFAULT_CANVAS_YAXIS;
00290     static const String DEFAULT_CANVAS_AXIS_LABEL_FORMAT;
00291     static const bool DEFAULT_FONTSET;
00292     static const int DEFAULT_FONT;
00293     static const bool DEFAULT_SHOWAXIS;
00294     static const bool DEFAULT_SHOWLEGEND;
00295     static const PlotCanvas::LegendPosition DEFAULT_LEGENDPOSITION;
00296     static const bool DEFAULT_SHOW_GRID;
00297     static PlotLinePtr DEFAULT_GRID_LINE(PlotFactoryPtr factory);
00298     static const String DEFAULT_TITLE_FORMAT;
00299     // </group>
00300     
00301     // Default values for export range;
00302     static const ExportRange DEFAULT_EXPORT_RANGE;
00303 
00304     // Default values for PMS_PP_Display.
00305     // <group>
00306     static PlotSymbolPtr DEFAULT_UNFLAGGED_SYMBOL(PlotFactoryPtr factory);
00307     static PlotSymbolPtr DEFAULT_FLAGGED_SYMBOL(PlotFactoryPtr factory);
00308     static PlotSymbolPtr NO_FLAGGED_SYMBOL(PlotFactoryPtr factory);
00309     // </group>
00310     
00311     // Returns the minimum visible sizes for plot symbol types.
00312     static std::map<PlotSymbol::Symbol, int> SYMBOL_MINIMUM_SIZES();
00313     
00314     // Default text annotation properties.
00315     // <group>
00316     static PlotFontPtr DEFAULT_ANNOTATION_TEXT_FONT(PlotFactoryPtr factory);
00317     static PlotLinePtr DEFAULT_ANNOTATION_TEXT_OUTLINE(PlotFactoryPtr factory);
00318     static PlotAreaFillPtr DEFAULT_ANNOTATION_TEXT_BACKGROUND(
00319             PlotFactoryPtr factory);
00320     // </group>
00321     
00322     // Default rectangle annotation properties.
00323     // <group>
00324     static PlotLinePtr DEFAULT_ANNOTATION_RECT_LINE(PlotFactoryPtr factory);
00325     static PlotAreaFillPtr DEFAULT_ANNOTATION_RECT_FILL(PlotFactoryPtr f);
00326     // </group>
00327     
00328     
00329     // Logging Constants //
00330     
00331     // Log class origin.
00332     static const String LOG_ORIGIN;
00333     
00334     // Log event origin names.
00335     // <group>
00336     static const String LOG_ORIGIN_DBUS;
00337     static const String LOG_ORIGIN_FLAG;
00338     static const String LOG_ORIGIN_LOAD_CACHE;
00339     static const String LOG_ORIGIN_LOCATE;
00340     static const String LOG_ORIGIN_PARAMS_CHANGED;
00341     static const String LOG_ORIGIN_PLOT;
00342     static const String LOG_ORIGIN_RELEASE_CACHE;
00343     static const String LOG_ORIGIN_UNFLAG;
00344     static const String LOG_ORIGIN_SUMMARY;
00345     // </group>
00346     
00347     // Log event flags.
00348     // <group>
00349     static const int LOG_EVENT_DBUS;
00350     static const int LOG_EVENT_FLAG;
00351     static const int LOG_EVENT_LOAD_CACHE;
00352     static const int LOG_EVENT_LOCATE;
00353     static const int LOG_EVENT_PARAMS_CHANGED;
00354     static const int LOG_EVENT_PLOT;
00355     static const int LOG_EVENT_RELEASE_CACHE;
00356     static const int LOG_EVENT_UNFLAG;
00357     static const int LOG_EVENT_SUMMARY;
00358     // </group>
00359 };
00360 
00361 }
00362 
00363 #endif /* PLOTMSCONSTANTS_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1