casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotMSLabelFormat.h
Go to the documentation of this file.
1 //# PlotMSLabelFormat.h: Class for generating labels based on a format.
2 //# Copyright (C) 2009
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef PLOTMSLABELFORMAT_H_
28 #define PLOTMSLABELFORMAT_H_
29 
31 
32 namespace casa {
33 
34 //# Forward declarations.
35 class PlotMSPlotParameters;
36 
37 
38 // Class for generating labels based upon axes, units, etc. A format is a
39 // casacore::String that consists of tags and non-tags. Tags are special substrings
40 // differentiated by being surrounded by a separator; tags are replaced with
41 // given values when the label is built. For example: the %%axis%% tag is
42 // replaced with the name of the Axis that is passed in when generating the
43 // String. Non-tags are copied exactly into the label. An example of a format
44 // is: "%%xaxis%% vs. %%yaxis%%", when passed in the axes TIME and AMP, would
45 // return the label "time vs. amp". Currently, labels can either be single
46 // axis (like for an axis label) or double axes (like for a plot title).
48 public:
49  // Static //
50 
51  // Separator that goes before and after tags.
52  static const casacore::String& TAGSEPARATOR();
53 
54  // Tag for axes, both the single case and the double case. This tag is
55  // replaced with the axis name (see PMS::axis()) during generation.
56  // <group>
57  static const casacore::String& TAG_AXIS();
58  static const casacore::String& TAG_XAXIS();
59  static const casacore::String& TAG_YAXIS();
60  // </group>
61 
62  // Tag for axes units, both the single case and the double case. This tag
63  // is replaced with the axis unit name (see PMS::axisUnit()) during
64  // generation.
65  // <group>
66  static const casacore::String& TAG_UNIT();
67  static const casacore::String& TAG_XUNIT();
68  static const casacore::String& TAG_YUNIT();
69  // </group>
70 
71  // Tags for if/endif for axes units. Parts of the format that are
72  // surrounded with an IF at the beginning and ENDIF at the end are only
73  // copied to the label if the given unit is NOT PMS::UNONE. For example,
74  // "TAG_IF_UNIT(sample text)TAG_ENDIF_UNIT" would copy over "(sample text)"
75  // only if the given unit was NOT PMS::UNONE.
76  // <group>
77  static const casacore::String& TAG_IF_UNIT();
78  static const casacore::String& TAG_IF_XUNIT();
79  static const casacore::String& TAG_IF_YUNIT();
80  static const casacore::String& TAG_ENDIF_UNIT();
81  static const casacore::String& TAG_ENDIF_XUNIT();
82  static const casacore::String& TAG_ENDIF_YUNIT();
83  // </group>
84 
85  // Tags for axis reference values, both the single case and the double
86  // case. This tag is replaced with the reference value for the given axis,
87  // if there is one, during generation. Note: if the associated axis is a
88  // date, the value will be in date format.
89  // <group>
90  static const casacore::String& TAG_REFVALUE();
91  static const casacore::String& TAG_XREFVALUE();
92  static const casacore::String& TAG_YREFVALUE();
93  // </group>
94 
95  // Tags for if/endif for axis reference values. Parts of the format that
96  // are surrounded with an IF at the beginning and ENDIF at the end are only
97  // copied to the label if the given axis has a reference value set. For
98  // example, "TAG_IF_REFVALUE(sample text)TAG_ENDIF_REFVALUE" would copy
99  // over "(sample text)" only if the given axis had a set reference value.
100  // <group>
101  static const casacore::String& TAG_IF_REFVALUE();
102  static const casacore::String& TAG_IF_XREFVALUE();
103  static const casacore::String& TAG_IF_YREFVALUE();
104  static const casacore::String& TAG_ENDIF_REFVALUE();
105  static const casacore::String& TAG_ENDIF_XREFVALUE();
106  static const casacore::String& TAG_ENDIF_YREFVALUE();
107  // </group>
108 
109  // Convenience method to surround the given tag with the separator.
110  static casacore::String TAG(const casacore::String& tag);
111 
112 
113  // Non-Static //
114 
115  // Constructor which takes an optional starting format.
117 
118  // Copy constructor. See operator=().
120 
121  // Destructor.
123 
124 
125  // Format.
127 
128 
129  // Generates a label, using the given single axis and reference value. If
130  // any double axes tags are in the format, the given axis will be used for
131  // them.
132  casacore::String getLabel(PMS::Axis axis, bool refValueSet = false,
133  double refValue = 0, PMS::DataColumn data = PMS::DATA,
134  bool polnRatio = false) const;
135 
136  casacore::String getLabel(std::vector<PMS::Axis> axes, std::vector<bool> refValueSets,
137  std::vector<double> refValues, std::vector<PMS::DataColumn> datas,
138  bool polnRatio = false ) const;
139 
140  // Generates a label, using the given double axes and reference values. If
141  // any single axes tags are in the format, the x axis will be used for it.
142  casacore::String getLabel(PMS::Axis xAxis, std::vector<PMS::Axis> yAxes,
143  bool xRefValueSet = false, double xRefValue = 0,
144  std::vector<bool> yRefValueSets=std::vector<bool>(1,false),
145  std::vector<double> yRefValues =std::vector<double>(1,0.0),
146  PMS::DataColumn xData=PMS::DATA,
147  std::vector<PMS::DataColumn> yData = std::vector<PMS::DataColumn>(1,PMS::DATA),
148  bool polnRatio = false ) const;
149 
150  // Equality operators.
151  // <group>
152  bool operator==(const PlotMSLabelFormat& other) const;
153  bool operator!=(const PlotMSLabelFormat& other) const {
154  return !(operator==(other)); }
155  // </group>
156 
157  // Copy operator.
159 
160 private:
161  // Generates a label using the given format, single axis, and double axes.
162  static casacore::String getLabel(const casacore::String& format, PMS::Axis axis,
163  PMS::Axis xAxis, std::vector<PMS::Axis> yAxes, bool refValueSet,
164  double refValue, bool xRefValueSet, double xRefValue,
165  std::vector<bool> yRefValueSets, std::vector<double> yRefValues,
166  PMS::DataColumn xData, const std::vector<PMS::DataColumn>& ydatas,
167  bool polnRatio);
168 
169  //Adds the data label such as DATA, MODEL, CORRECTED, etc to the tag
170  static void addDataToTag( casacore::String& tag, PMS::Axis axis, PMS::DataColumn column );
171  // Adds "POLN Ratio" to tag for cal table ratio plots
172  static void addPolnRatioToTag( casacore::String& tag, PMS::Axis axis );
173 
174  // Helper method for getLabel() which gets the next token in the format.
175  // Returns true if a token was returned; false if the end of the format was
176  // reached. The given format will be automatically shortened as tokens are
177  // taken out. The next token is put in the token parameter, and the
178  // tokenWasTag parameter is set to true if the token was a tag, false
179  // otherwise.
180  static bool nextToken(casacore::String& format, casacore::String& token, bool& tokenWasTag);
181 
182  // casacore::Format for when reference values are dates.
184 };
185 
186 }
187 
188 #endif /* PLOTMSLABELFORMAT_H_ */
static const casacore::String & TAG_IF_UNIT()
Tags for if/endif for axes units.
StatsData< AccumType > copy(const StatsData< AccumType > &stats)
static const casacore::String & TAG_ENDIF_UNIT()
casacore::String format
Format.
static const casacore::String & TAG_ENDIF_REFVALUE()
static const casacore::String & TAG_AXIS()
Tag for axes, both the single case and the double case.
static const casacore::String & TAG_YREFVALUE()
static const casacore::String & TAG_UNIT()
Tag for axes units, both the single case and the double case.
static const casacore::String & TAG_IF_REFVALUE()
Tags for if/endif for axis reference values.
static const casacore::String & TAG_YAXIS()
PlotMSLabelFormat & operator=(const PlotMSLabelFormat &copy)
Copy operator.
static const casacore::String & TAG_REFVALUE()
Tags for axis reference values, both the single case and the double case.
static const casacore::String & TAG_ENDIF_XREFVALUE()
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
Class for generating labels based upon axes, units, etc.
static casacore::String TAG(const casacore::String &tag)
Convenience method to surround the given tag with the separator.
static const casacore::String & TAG_ENDIF_YUNIT()
static bool nextToken(casacore::String &format, casacore::String &token, bool &tokenWasTag)
Helper method for getLabel() which gets the next token in the format.
static const casacore::String & TAG_XUNIT()
static void addPolnRatioToTag(casacore::String &tag, PMS::Axis axis)
Adds &quot;POLN Ratio&quot; to tag for cal table ratio plots.
static const casacore::String & TAGSEPARATOR()
Static //.
static const casacore::String & TAG_IF_YREFVALUE()
static void addDataToTag(casacore::String &tag, PMS::Axis axis, PMS::DataColumn column)
Adds the data label such as DATA, MODEL, CORRECTED, etc to the tag.
static const casacore::String & TAG_IF_XREFVALUE()
casacore::String getLabel(PMS::Axis axis, bool refValueSet=false, double refValue=0, PMS::DataColumn data=PMS::DATA, bool polnRatio=false) const
Generates a label, using the given single axis and reference value.
bool operator==(const PlotMSLabelFormat &other) const
Equality operators.
static const casacore::String REFERENCE_DATE_FORMAT
casacore::Format for when reference values are dates.
static const casacore::String & TAG_ENDIF_YREFVALUE()
~PlotMSLabelFormat()
Destructor.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
PlotMSLabelFormat(const casacore::String &format="")
Non-Static //.
static const casacore::String & TAG_XAXIS()
static const casacore::String & TAG_IF_XUNIT()
static const casacore::String & TAG_XREFVALUE()
bool operator!=(const PlotMSLabelFormat &other) const
static const casacore::String & TAG_YUNIT()
static const casacore::String & TAG_IF_YUNIT()
static const casacore::String & TAG_ENDIF_XUNIT()