casacore
Loading...
Searching...
No Matches
RegionHandler.h
Go to the documentation of this file.
1// # RegionHandler.h: Abstract base class for handling regions in images
2// # Copyright (C) 2000,2001
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: casa-feedback@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#ifndef IMAGES_REGIONHANDLER_H
27#define IMAGES_REGIONHANDLER_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/BasicSL/String.h>
32#include <casacore/casa/Arrays/ArrayFwd.h>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// # Forward Declarations
37class Table;
38class ImageRegion;
39class LatticeBase;
40class LCPagedMask;
41class String;
42
43// <summary>
44// Base class for handling regions in images
45// </summary>
46
47// <use visibility=local>
48
49// <reviewed reviewer="" date="" tests="tPagedImage2.cc" demos="">
50// </reviewed>
51
52// <prerequisite>
53// <li> <linkto class=PagedImage>PagedImage</linkto>
54// <li> <linkto class=ImageRegion>ImageRegion</linkto>
55// </prerequisite>
56
57// <synopsis>
58// Persistent regions are stored as subrecords of the table keywords
59// "regions" and "masks". The user can choose one of both keywords.
60// Keyword "masks" is meant for true image masks, i.e. telling for
61// each pixel if it is good or bad. Keyword "regions" is meant for
62// true regions in an image.
63// <p>
64// This class handles defining, getting and removing such regions.
65// It is used by class <linkto class=PagedImage>PagedImage</linkto>, but it can also
66// be used by other code to handle regions in other tables.
67// <p>
68// Another function performed by this class for PagedImage is the
69// definition of the default region to be used with an image.
70// </synopsis>
71
72// <example>
73// </example>
74
75// <motivation>
76// This class has 2 purposes:
77// <ol>
78// <li> This untemplated code can be factored out from the templated
79// Image classes.
80// <li> The functions can easily be used by other code.
81// </ol>
82// </motivation>
83
84// # <todo asof="1999/02/16">
85// # <li>
86// # </todo>
87
89 public:
90 virtual ~RegionHandler();
91
92 // Define the possible group types (regions or masks).
94
95 // Make a copy of the object.
96 virtual RegionHandler* clone() const;
97
98 // Set the object pointer (for RegionHandlerTable's callback).
99 // Default implementation does nothing.
100 virtual void setObjectPtr(void* objectPtr);
101
102 // Can the class indeed define and handle regions?
103 // The default implementation returns False.
104 virtual Bool canDefineRegion() const;
105
106 // Set the default mask to the mask with the given name.
107 // It constructs a ImageRegion object for the new default mask.
108 // If the table is writable, the setting is persistent by writing
109 // the name as a keyword.
110 // If the given maskName is the empty string, the default mask is unset.
111 virtual void setDefaultMask(const String& maskName);
112
113 // Get the name of the default mask.
114 // An empty string is returned if no default mask.
115 virtual String getDefaultMask() const;
116
117 // Define a region belonging to the table.
118 // The group type determines if it stored as a region or mask.
119 // If overwrite=False, an exception will be thrown if the region
120 // already exists in the "regions" or "masks" keyword.
121 // Otherwise the region will be removed first.
122 // <br>A False status is returned if the table is not writable
124 Bool overwrite = False);
125
126 // Does the table have a region with the given name?
128
129 // Get a region belonging to the table.
130 // A zero pointer is returned if the region does not exist.
131 // The caller has to delete the <src>ImageRegion</src> object created.
132 // <br>No exception is thrown if the region does not exist.
134 Bool throwIfUnknown = True) const;
135
136 // Rename a region.
137 // If a region with the new name already exists, it is deleted or
138 // an exception is thrown (depending on <src>overwrite</src>).
139 // The region name is looked up in the given group(s).
140 // <br>An exception is thrown if the old region name does not exist.
141 virtual Bool renameRegion(const String& newName, const String& oldName,
142 RegionHandler::GroupType = Any, Bool overwrite = False);
143
144 // Remove a region belonging to the table.
145 // <br>Optionally an exception is thrown if the region does not exist.
146 // <br>A False status is returned if the table is not writable
148 Bool throwIfUnknown = True);
149
150 // Get the names of all regions/masks.
152
153 // Make a unique region name from the given root name, thus make it such
154 // that the name is not already in use for a region or mask.
155 // The root name is returned if it is already unique.
156 // Otherwise a number is appended to the root name to make it unique.
157 // The number starts at the given number and is incremented until the name
158 // is unique.
159 String makeUniqueRegionName(const std::string& rootName, uInt startNumber = 1) const;
160
161 // Make a mask for a lattice (e.g. a PagedImage or TempImage).
162 // It creates it with the shape and tile shape of the lattice.
163 virtual ImageRegion makeMask(const LatticeBase& lattice, const String& name);
164};
165
166} // namespace casacore
167
168#endif
virtual String getDefaultMask() const
Get the name of the default mask.
virtual ImageRegion * getRegion(const String &name, RegionHandler::GroupType=Any, Bool throwIfUnknown=True) const
Get a region belonging to the table.
GroupType
Define the possible group types (regions or masks).
virtual Bool defineRegion(const String &name, const ImageRegion &region, RegionHandler::GroupType, Bool overwrite=False)
Define a region belonging to the table.
virtual Bool hasRegion(const String &name, RegionHandler::GroupType=RegionHandler::Any) const
Does the table have a region with the given name?
virtual Bool renameRegion(const String &newName, const String &oldName, RegionHandler::GroupType=Any, Bool overwrite=False)
Rename a region.
virtual void setDefaultMask(const String &maskName)
Set the default mask to the mask with the given name.
virtual Bool removeRegion(const String &name, RegionHandler::GroupType=Any, Bool throwIfUnknown=True)
Remove a region belonging to the table.
virtual RegionHandler * clone() const
Make a copy of the object.
virtual ImageRegion makeMask(const LatticeBase &lattice, const String &name)
Make a mask for a lattice (e.g.
virtual void setObjectPtr(void *objectPtr)
Set the object pointer (for RegionHandlerTable's callback).
String makeUniqueRegionName(const std::string &rootName, uInt startNumber=1) const
Make a unique region name from the given root name, thus make it such that the name is not already in...
virtual Bool canDefineRegion() const
Can the class indeed define and handle regions?
virtual Vector< String > regionNames(RegionHandler::GroupType=Any) const
Get the names of all regions/masks.
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
String name() const
Return the name of the field.
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41