casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Util.h
Go to the documentation of this file.
1 //# Copyright (C) 2005
2 //# Associated Universities, Inc. Washington DC, USA.
3 //#
4 //# This library is free software; you can redistribute it and/or modify it
5 //# under the terms of the GNU Library General Public License as published by
6 //# the Free Software Foundation; either version 2 of the License, or (at your
7 //# option) any later version.
8 //#
9 //# This library is distributed in the hope that it will be useful, but WITHOUT
10 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 //# License for more details.
13 //#
14 //# You should have received a copy of the GNU Library General Public License
15 //# along with this library; if not, write to the Free Software Foundation,
16 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
17 //#
18 //# Correspondence concerning AIPS++ should be addressed as follows:
19 //# Internet email: aips2-request@nrao.edu.
20 //# Postal address: AIPS++ Project Office
21 //# National Radio Astronomy Observatory
22 //# 520 Edgemont Road
23 //# Charlottesville, VA 22903-2475 USA
24 //#
25 #ifndef UTIL_H_
26 #define UTIL_H_
27 
28 #include <QString>
29 #include <casa/Arrays/Vector.h>
33 
34 class QWidget;
35 
36 namespace casacore{
37 
38  template <class T> class ImageInterface;
39  class ImageRegion;
40 }
41 
42 namespace casa { //# NAMESPACE CASA - BEGIN
43 
44 
45  class Util {
46 
47 
48  public:
49  static const QString &ORGANIZATION( ) {
50  static QString result("NRAO/CASA");
51  return result;
52  }
53  static const QString &APPLICATION( ) {
54  static QString result("Spectral Profiler");
55  return result;
56  }
57  static void showUserMessage( QString& msg, QWidget* parent);
58  static double degMinSecToRadians( int degrees, int mins, float secs );
59  static double hrMinSecToRadians( int hours, int mins, float secs );
60  static QString toHTML( const QString& baseStr );
62  static void getRa(double radians, int& raHour, int& raMin, double& raSec);
63  static void getDec(double radians, int& decDeg, int& decMin, double& decSec);
64  static void minMax( double& min, double& max, const casacore::Vector<casacore::Double>& values );
65  static QString toDegreeString( int hrs, int mins, double secs );
66  static QString toDecString( int hrs, int mins, double secs );
67  static void appendSign( double rad, QString& degreeString );
68  static QList<QString> getTitleCaseVariations( QString source );
69  static QString toTitleCase( QString word );
71 
75  static QString stripBrackets( QString unitStr );
76 
81  static QString stripFont( QString unitStr );
82 
83  //Support for tabular axes that are frequency. Returns -1 if there
84  //is no tabular index in the image in frequency units.
85  static int getTabularFrequencyAxisIndex(std::shared_ptr<const casacore::ImageInterface<casacore::Float> > img);
86 
89 
90  static std::pair<casacore::Vector<casacore::Float>,casacore::Vector<casacore::Float> > getProfile(std::shared_ptr<const casacore::ImageInterface<casacore::Float> >& imagePtr,
93  const casacore::String& coordinateType,
94  const casacore::Quantity *const restFreq=0, const casacore::String& frame="");
105  int channelMin, int channelMax, int spectralAxisNumber);
106 
118  int channelMin, int channelMax, int spectralAxisNumber);
119 
138 
144  private:
145  Util();
146  virtual ~Util();
147  static double toRadians( double degrees );
148  static double toDecimalDegrees( int hrs, int mins, float seconds );
150  int channelMin, int channelMax, int spectralAxisNumber );
151 
152  static const double PI;
153  static const double TIME_CONV;
154  static const double RAD_DEGREE_CONVERSION;
155 
156  };
157 }
158 #endif /* UTIL_H_ */
static casacore::Record getEllipticalRegion3D(const DisplayCoordinateSystem &cSys, const casacore::Vector< casacore::Double > &x, const casacore::Vector< casacore::Double > &y, int channelMin, int channelMax, int spectralAxisNumber)
Returns the record of a 3-dimension region with the base in the shape of an ellipse and height given ...
static void minMax(double &min, double &max, const casacore::Vector< casacore::Double > &values)
static const double TIME_CONV
Definition: Util.h:153
static double toDecimalDegrees(int hrs, int mins, float seconds)
static const double RAD_DEGREE_CONVERSION
Definition: Util.h:154
#define max(a, b)
Definition: hio.h:44
static casacore::ImageRegion * getEllipsoid(const DisplayCoordinateSystem &cSys, const casacore::Vector< casacore::Double > &x, const casacore::Vector< casacore::Double > &y)
Return a 2D region in the shape of an ellipse.
AggregateType
Non-templated data related bits for ImageCollapser.
#define min(a, b)
Definition: hio.h:45
static void getDec(double radians, int &decDeg, int &decMin, double &decSec)
static casacore::Record getPolygonalRegion3D(const DisplayCoordinateSystem &cSys, const casacore::Vector< casacore::Double > &x, const casacore::Vector< casacore::Double > &y, int channelMin, int channelMax, int spectralAxisNumber)
Returns the record of a 3-dimension region with the base in the shape of a polygon and height given b...
static QString toTitleCase(QString word)
static const double PI
Definition: Util.h:152
static QString toDegreeString(int hrs, int mins, double secs)
TableExprNode mins(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1687
static const QString & ORGANIZATION()
Definition: Util.h:49
static casacore::ImageRegion * getPolygon(const DisplayCoordinateSystem &cSys, const casacore::Vector< casacore::Double > &x, const casacore::Vector< casacore::Double > &y)
Return a 2D region in the shape of a polygon.
static std::pair< casacore::Vector< casacore::Float >, casacore::Vector< casacore::Float > > getProfile(std::shared_ptr< const casacore::ImageInterface< casacore::Float > > &imagePtr, const casacore::Vector< casacore::Double > &x, const casacore::Vector< casacore::Double > &y, const casacore::String &shape, int tabularAxis, ImageCollapserData::AggregateType, casacore::String unit, const casacore::String &coordinateType, const casacore::Quantity *const restFreq=0, const casacore::String &frame="")
static double hrMinSecToRadians(int hours, int mins, float secs)
static casacore::String mainImageName(casacore::String path)
static void getRa(double radians, int &raHour, int &raMin, double &raSec)
static casacore::Record make3DRegion(const DisplayCoordinateSystem &cSys, casacore::ImageRegion *shape3D, int channelMin, int channelMax, int spectralAxisNumber)
static int getTabularFrequencyAxisIndex(std::shared_ptr< const casacore::ImageInterface< casacore::Float > > img)
Support for tabular axes that are frequency.
double Double
Definition: aipstype.h:55
static int getCenter(const casacore::Vector< casacore::Double > &values, casacore::Double &mean)
std::string path(const std::string &name)
static void showUserMessage(QString &msg, QWidget *parent)
static QString stripFont(QString unitStr)
Designed to take an input string of the format &lt;font color=&quot;black&quot;&gt;km/s&lt;/font&gt;&#39; and return &#39;km/s&#39;...
A hierarchical collection of named fields of various types.
Definition: Record.h:180
static casacore::Record getRegionRecord(casacore::String shape, const DisplayCoordinateSystem &cSys, const casacore::Vector< casacore::Double > &x, const casacore::Vector< casacore::Double > &y)
static QString toHTML(const QString &baseStr)
static double toRadians(double degrees)
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
static bool arrayEquals(const casacore::Vector< casacore::Double > &a, const casacore::Vector< casacore::Double > &b)
Tests whether the contents of the two arrays are the same.
static const QString & APPLICATION()
Definition: Util.h:53
static QString stripBrackets(QString unitStr)
Designed to take an input string of the format &#39;[km/s]&#39; and return &#39;km/s&#39;.
Class to hold a region of interest in an image.
Definition: ImageRegion.h:86
virtual ~Util()
static QList< QString > getTitleCaseVariations(QString source)
LatticeExprNode mean(const LatticeExprNode &expr)
static QString toDecString(int hrs, int mins, double secs)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
static void appendSign(double rad, QString &degreeString)
static double degMinSecToRadians(int degrees, int mins, float secs)
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42