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 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
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
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
00099
00100
00101
00102 class PMS {
00103 public:
00104
00105
00106
00107
00108
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
00142
00143
00144
00145 static PlotAxisScale axisScale(Axis axis);
00146
00147
00148
00149
00150
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
00156
00157
00158
00159
00160 static bool axisIsData(Axis axis);
00161
00162 static bool axisNeedsCalSlice(Axis axis);
00163
00164 static bool axisIsWeight(Axis axis);
00165
00166
00167
00168
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
00174
00175
00176 static AxisType axisType(Axis axis);
00177
00178
00179
00180
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>λ</html>", "degrees", "ns", "K", "neper", "s");
00188
00189
00190
00191
00192 static AxisUnit axisUnit(Axis axis);
00193
00194
00195
00196
00197
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
00205
00206
00207
00208
00209
00210 static bool strEq(const String& str1, const String& str2,
00211 bool ignoreCase = false);
00212
00213
00214 static bool recEq(const Record& rec1, const Record& rec2);
00215
00216
00217
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
00232
00233
00234
00235
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
00248
00249
00250
00251
00252 PMS_ENUM1(ExportRange, exportRanges, exportRangeStrings, exportRange, PAGE_CURRENT, PAGE_ALL)
00253 PMS_ENUM2(ExportRange, exportRanges, exportRangeStrings, exportRange, "Current Page", "All Pages")
00254
00255
00256
00257
00258
00259
00260 static const vector<String>& COLORS_LIST();
00261
00262
00263
00264
00265
00266
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
00276
00277
00278
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
00285
00286
00287
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
00300
00301
00302 static const ExportRange DEFAULT_EXPORT_RANGE;
00303
00304
00305
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
00310
00311
00312 static std::map<PlotSymbol::Symbol, int> SYMBOL_MINIMUM_SIZES();
00313
00314
00315
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
00321
00322
00323
00324 static PlotLinePtr DEFAULT_ANNOTATION_RECT_LINE(PlotFactoryPtr factory);
00325 static PlotAreaFillPtr DEFAULT_ANNOTATION_RECT_FILL(PlotFactoryPtr f);
00326
00327
00328
00329
00330
00331
00332 static const String LOG_ORIGIN;
00333
00334
00335
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
00346
00347
00348
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
00359 };
00360
00361 }
00362
00363 #endif