00001 //# WCCompound.h: Base class for compound WCRegion objects 00002 //# Copyright (C) 1998,1999,2003 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id$ 00027 00028 #ifndef IMAGES_WCCOMPOUND_H 00029 #define IMAGES_WCCOMPOUND_H 00030 00031 //# Includes 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/images/Regions/WCRegion.h> 00034 #include <casacore/casa/Containers/Block.h> 00035 #include <casacore/casa/Arrays/IPosition.h> 00036 00037 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00038 00039 //# Forward Declarations 00040 class ImageRegion; 00041 class LCRegion; 00042 class CoordinateSystem; 00043 class RecordInterface; 00044 class TableRecord; 00045 class String; 00046 00047 00048 // <summary> 00049 // Base class for compound WCRegion objects. 00050 // </summary> 00051 00052 // <use visibility=local> 00053 00054 // <reviewed reviewer="" date="" tests=""> 00055 // </reviewed> 00056 00057 // <prerequisite> 00058 // <li> <linkto class=WCRegion>WCRegion</linkto> 00059 // </prerequisite> 00060 00061 // <synopsis> 00062 // WCCompound is the base class for world coordinate regions. 00063 // It defines the functionality simply as conversion to an LCRegion. 00064 // This is because you need an LCRegion to be able to access the 00065 // pixels in a Lattice. 00066 00067 // The conversion functions should be flexible in that the 00068 // supplied CoordinateSystem does not have to be the same 00069 // as that with which the derived class was constructed. 00070 // This means that you can apply a WCCompound from one image 00071 // to another, provided that operation has some meaning. 00072 // </synopsis> 00073 00074 // <example> 00075 // <srcblock> 00076 // </srcblock> 00077 // </example> 00078 00079 //# <todo asof="1997/11/11"> 00080 //# <li> 00081 //# </todo> 00082 00083 00084 class WCCompound : public WCRegion 00085 { 00086 public: 00087 // Construct from one or more image regions. 00088 // The image regions have to contain WCRegion objects, otherwise an 00089 // exception is thrown. 00090 // <group> 00091 WCCompound (const ImageRegion& region1, const ImageRegion& region2); 00092 WCCompound (const ImageRegion* region1, 00093 const ImageRegion* region2 = 0, 00094 const ImageRegion* region3 = 0, 00095 const ImageRegion* region4 = 0, 00096 const ImageRegion* region5 = 0, 00097 const ImageRegion* region6 = 0, 00098 const ImageRegion* region7 = 0, 00099 const ImageRegion* region8 = 0, 00100 const ImageRegion* region9 = 0, 00101 const ImageRegion* region10 = 0); 00102 WCCompound (const PtrBlock<const ImageRegion*>& regions); 00103 // </group> 00104 00105 // Construct from multiple regions given as a Block. 00106 // When <src>takeOver</src> is True, the destructor will delete the 00107 // given regions. Otherwise a copy of the regions is made. 00108 WCCompound (Bool takeOver, const PtrBlock<const WCRegion*>& regions); 00109 00110 // Copy constructor (copy semantics). 00111 WCCompound (const WCCompound& other); 00112 00113 virtual ~WCCompound(); 00114 00115 // Comparison 00116 virtual Bool operator==(const WCRegion& other) const; 00117 00118 // Get the contributing regions. 00119 const PtrBlock<const WCRegion*>& regions() const; 00120 00121 protected: 00122 // Assignment (copy semantics) makes only sense for a derived class. 00123 WCCompound& operator= (const WCCompound& other); 00124 00125 // Convert each WCRegion to an LCRegion. 00126 // The axes argument tells which axes to use from the coordinate 00127 // system and shape. 00128 void multiToLCRegion (PtrBlock<const LCRegion*>& regions, 00129 const CoordinateSystem& cSys, 00130 const IPosition& shape, 00131 const IPosition& pixelAxesMap, 00132 const IPosition& extendAxes) const; 00133 00134 // Store the contributing regions in a record. 00135 TableRecord makeRecord (const String& tableName) const; 00136 00137 // Retrieve the contributing objects from the record. 00138 static void unmakeRecord (PtrBlock<const WCRegion*>&, 00139 const TableRecord&, 00140 const String& tableName); 00141 00142 private: 00143 // Check if the ImageRegion's contain WCRegion's and extract them. 00144 void makeWCRegion (const PtrBlock<const ImageRegion*>&); 00145 00146 // Check if the regions are correct. 00147 // If needed, make a copy of the region objects. 00148 void init (Bool takeOver); 00149 00150 //# Member variables. 00151 PtrBlock<const WCRegion*> itsRegions; 00152 Block<IPosition> itsAxesUsed; 00153 }; 00154 00155 00156 inline const PtrBlock<const WCRegion*>& WCCompound::regions() const 00157 { 00158 return itsRegions; 00159 } 00160 00161 00162 00163 } //# NAMESPACE CASACORE - END 00164 00165 #endif