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