casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RegionTextList.h
Go to the documentation of this file.
1 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
3 //# License for more details.
4 //#
5 //# You should have received a copy of the GNU Library General Public License
6 //# along with this library; if not, write to the Free Software Foundation,
7 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
8 //#
9 //# Correspondence concerning AIPS++ should be addressed as follows:
10 //# Internet email: aips2-request@nrao.edu.
11 //# Postal address: AIPS++ Project Office
12 //# National Radio Astronomy Observatory
13 //# 520 Edgemont Road
14 //# Charlottesville, VA 22903-2475 USA
15 //#
16 
17 #ifndef ANNOTATIONS_REGIONTEXTLIST_H
18 #define ANNOTATIONS_REGIONTEXTLIST_H
19 
20 #include <casa/aips.h>
21 #include <casa/Arrays/Vector.h>
26 #include <images/Regions/WCUnion.h>
27 
28 namespace casacore{
29 
30 class WCDifference;
31 }
32 
33 namespace casa {
34 
35 
36 // <summary>
37 // An ordered list of annotations and comments representing an ascii region file.
38 // </summary>
39 // <author>Dave Mehringer</author>
40 // <use visibility=export>
41 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
42 // </reviewed>
43 // <prerequisite>
44 
45 // </prerequisite>
46 
47 // <etymology>
48 // An order list of annotations and comments representing an ascii region file.
49 // </etymology>
50 
51 // <synopsis>
52 // A list of regions and annotations and comments representing an ascii region file.
53 // See the region file format proposal attached to CAS-2285 (https://bugs.nrao.edu/browse/CAS-2285)
54 // </synopsis>
55 
57 
58 public:
59 
60  // <group>
61  // create an empty list which can be appended to. This constructor
62  // is used for constructing an annotation list on the fly, possibly
63  // to be written to a file when complete. Do not use this constructor
64  // if you want to determine the final composite region.
66 
67  // create an empty list which can be appended to. This constructor
68  // is used for constructing an annotation list on the fly, possibly
69  // to be written to a file when complete. It can be used to determine
70  // the composite region as well but it is the caller's responsibility
71  // to ensure the regions added to this object are constructed
72  // in a consistent manner (eg using the same coordinate system).
73  // <src>shape</src> is the image shape and is only used if
74  // the first region is a difference; in that case, the all pixels in entire
75  // shape are set to good initially.
76  // <src>globalOverrideChans</src> override all spectral selections in the file
77  // or text by using this channel selection<src>
78  // <src>globalOverrideStokes</src> override all correlation selections in the file
79  // or text by using this polarization selection<src>
82  );
83 
84  // create a list by reading it from a file.
85  // An exception is thrown if the file is not in the correct
86  // format or does not exist. The coordinate system is used for
87  // setting defaults and reference frames to be used.
88  // <src>shape</src> is the image shape and is only used if
89  // the first region is a difference; in that case, the all pixels in entire
90  // shape are set to good initially.
91  // <src>requireImageRegion</src> is passed to the parser so that file lines are
92  // added only for regions inside the image.
94  const casacore::String& filename, const casacore::CoordinateSystem& csys,
95  const casacore::IPosition shape, const casacore::String& prependRegion="",
96  const casacore::String& globalOverrideChans="",
97  const casacore::String& globalOverrrideStokes="",
98  const casacore::Int requireAtLeastThisVersion=RegionTextParser::CURRENT_VERSION,
99  casacore::Bool verbose=true, casacore::Bool requireImageRegion=true
100  );
101 
102  // create a list by reading it from a text string.
103  // An exception is thrown if the text is not in the correct
104  // format. The coordinate system is used for
105  // setting defaults and reference frames to be used.
106  // <src>shape</src> is the image shape and is only used if
107  // the first region is a difference; in that case, the all pixels in entire
108  // shape are set to good initially.
109  // <src>requireImageRegion</src> is passed to the parser so that file lines are
110  // added only for regions inside the image.
112  const casacore::CoordinateSystem& csys, const casacore::String& text,
113  const casacore::IPosition shape,
114  const casacore::String& prependRegion="",
115  const casacore::String& globalOverrideChans="",
116  const casacore::String& globalOverrrideStokes="",
117  casacore::Bool verbose=true, casacore::Bool requireImageRegion=true
118  );
119  //</group>
120 
121  ~RegionTextList();
122 
123  // add a line to the end of the list
124  void addLine(const AsciiAnnotationFileLine& line);
125 
126  // number of lines in the list
127  casacore::uInt nLines() const;
128 
129  // get the line at the specified index
131 
132  // get all lines in the list
134  return _lines;
135  }
136 
137  std::ostream& print(std::ostream& os) const;
138 
139  // get the composite region.
141 
142  // get the composite region as a region record.
144 
145 private:
147  std::vector<std::shared_ptr<const casacore::WCRegion> > _regions;
151  // if false, then the corresponding region is complementary to
152  // the result of the previous region operations in the sequence
153  std::vector<casacore::Bool> _union;
154  mutable std::vector<std::shared_ptr<const casacore::WCDifference> > _myDiff;
155  mutable std::shared_ptr<const casacore::WCRegion> _composite;
156 };
157 
158 inline std::ostream &operator<<(std::ostream& os, const RegionTextList& list) {
159  return list.print(os);
160 };
161 
162 }
163 
164 #endif /* IMAGES_ASCIIREGIONFILE_H_ */
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
std::shared_ptr< const casacore::WCRegion > _composite
A 1-D Specialization of the Array class.
int Int
Definition: aipstype.h:50
An ordered list of annotations and comments representing an ascii region file. &lt;author&gt;Dave Mehringer...
ostream & operator<<(ostream &os, const PageHeaderCache &cache)
std::vector< casacore::Bool > _union
if false, then the corresponding region is complementary to the result of the previous region operati...
void addLine(const AsciiAnnotationFileLine &line)
add a line to the end of the list
static const casacore::Int CURRENT_VERSION
casacore::Bool _canGetRegion
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
std::ostream & print(std::ostream &os) const
casacore::Vector< AsciiAnnotationFileLine > _lines
std::vector< std::shared_ptr< const casacore::WCRegion > > _regions
casacore::CountedPtr< const casacore::WCRegion > getRegion() const
get the composite region.
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
const casacore::Vector< AsciiAnnotationFileLine > & getLines() const
get all lines in the list
RegionTextList()
create an empty list which can be appended to.
casacore::Record regionAsRecord() const
get the composite region as a region record.
casacore::uInt nLines() const
number of lines in the list
casacore::IPosition _shape
Represents a line in an ascii region file &lt;author&gt;Dave Mehringer&lt;/author&gt;
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::CoordinateSystem _csys
std::vector< std::shared_ptr< const casacore::WCDifference > > _myDiff
Interconvert pixel and world coordinates.
AsciiAnnotationFileLine lineAt(const casacore::uInt i) const
get the line at the specified index
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42