casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QtWCBox.h
Go to the documentation of this file.
00001 //# QtWCBox.h: Class to define a box shaped WC region
00002 //# Copyright (C) 1998,1999,2001
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 //# $Id: QtWCBox.h 20567 2009-04-09 23:12:39Z gervandiepen $
00026 
00027 
00028 
00029 #ifndef QT_WCBOX_H
00030 #define QT_WCBOX_H
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <coordinates/Coordinates/CoordinateSystem.h>
00035 #include <images/Regions/WCRegion.h>
00036 #include <lattices/Lattices/RegionType.h>
00037 #include <casa/Arrays/Vector.h>
00038 #include <casa/Quanta/Quantum.h>
00039 
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 
00042 //# Forward Declarations
00043 class LCRegion;
00044 class TableRecord;
00045 class IPosition;
00046 
00047 
00048 class QtWCBox : public WCRegion
00049 {
00050 public:
00051    QtWCBox();
00052 
00053    // Construct from vectors of world coordinates 
00054    // defining the box corners.  It is assumed that the
00055    // order of the values is in the order of the pixel axes
00056    // in the given coordinate system.
00057    // <group>
00058    QtWCBox(const Vector<Quantum<Double> >& blc,
00059          const Vector<Quantum<Double> >& trc,
00060          const CoordinateSystem& cSys,
00061          const Vector<Int>& absRel);
00062    // </group>
00063 
00064    // Construct from vectors of world coordinates 
00065    // defining the box corners.   You specify the pixel 
00066    // axis order of the world values. 
00067    // <group>
00068    QtWCBox(const Vector<Quantum<Double> >& blc,
00069          const Vector<Quantum<Double> >& trc,
00070          const IPosition& pixelAxes,
00071          const CoordinateSystem& cSys,
00072          const Vector<Int>& absRel);
00073    // </group>
00074 
00075    // Construct from the bounding box of an  <src>LCRegion</src>.  
00076    QtWCBox(const LCRegion& region,
00077          const CoordinateSystem& cSys);
00078 
00079    // Copy constructor (reference semantics [except for <src>CoordinateSystem</src>])
00080    QtWCBox (const QtWCBox& other);
00081 
00082    // Destructor
00083    virtual ~QtWCBox();
00084 
00085    // Assignment (copy semantics) 
00086    QtWCBox& operator= (const QtWCBox& other);
00087 
00088    // Comparison
00089    virtual Bool operator==(const WCRegion& other) const;
00090 
00091    // Clone a QtWCBox object.
00092    virtual WCRegion* cloneRegion() const;
00093 
00094    // QtWCBox can extend a region.
00095    virtual Bool canExtend() const;
00096 
00097    // Make a new box from the given axesin this box.
00098    QtWCBox splitBox (const IPosition& axes) const;
00099 
00100    // Convert to an LCRegion using the supplied <src>CoordinateSystem</src> 
00101    // and shape.  
00102    virtual LCRegion* doToLCRegion (const CoordinateSystem& cSys,
00103                                    const IPosition& latticeShape,
00104                                    const IPosition& pixelAxesMap,
00105                                    const IPosition& outOrder) const;
00106 
00107    // Convert the QtWCBox object to a record.
00108    // The record can be used to make the object persistent.
00109    // The <src>tableName</src> argument can be used by derived
00110    // classes (e.g. LCPagedMask) to put very large objects.
00111    virtual TableRecord toRecord(const String& tableName) const;
00112 
00113    // Convert to a QtWCBox from a record.
00114    static QtWCBox* fromRecord (const TableRecord& rec,
00115                              const String& tableName);
00116 
00117    // Returns QtWCBox
00118    static String className();
00119 
00120    // Return region type.  Returns the class name 
00121    virtual String type() const;
00122 
00123    // Convert from/to boxit format string
00124    String toBoxString() const;
00125    static QtWCBox* fromBoxString(const String&, 
00126                                const CoordinateSystem& cSys, String& err);
00127 
00128    // FIXME: refactor to someplace more appropriate
00129    // get/set chan extension
00130    void setChanExt(const Double, const Double);
00131    Bool getChanExt(Double&, Double&);
00132 
00133    // FIXME: refactor to someplace more appropriate
00134    // get/set pol extension
00135    void setPolExt(const Double, const Double);
00136    Bool getPolExt(Double&, Double&);
00137 
00138    static void unitInit();
00139 
00140 private:
00141    Vector<Quantum<Double> > itsBlc;
00142    Vector<Quantum<Double> > itsTrc;
00143    IPosition itsPixelAxes;
00144    CoordinateSystem itsCSys;
00145    Vector<Int> itsAbsRel;
00146    Bool itsNull;
00147 
00148 
00149 // Check units of quanta are consistent with CoordinateSystem
00150    void checkUnits (const IPosition& pixelAxes,
00151                     const Vector<Quantum<Double> >& values,
00152                     const CoordinateSystem& cSys);
00153 
00154 // Convert relative pixels to absolute or fill in defaults
00155    void convertPixel(Double& pixel,
00156                      const Quantum<Double>& value,
00157                      const Int absRel,
00158                      const Double refPix,
00159                      const Int shape,
00160                      const Bool isBlc) const;
00161 
00162 };
00163 
00164 
00165 
00166 } //# NAMESPACE CASA - END
00167 
00168 #endif