casa
$Rev:20696$
|
00001 //# WCCSAxisLabeller.h: labelling axes using a CoordinateSystem on a WC 00002 //# Copyright (C) 1999,2000,2001,2002 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 TRIALDISPLAY_WCCSAXISLABELLER_H 00029 #define TRIALDISPLAY_WCCSAXISLABELLER_H 00030 00031 #include <casa/aips.h> 00032 #include <coordinates/Coordinates/CoordinateSystem.h> 00033 #include <display/DisplayCanvas/WCAxisLabeller.h> 00034 00035 namespace casa { //# NAMESPACE CASA - BEGIN 00036 00037 // <summary> 00038 // Base class for WorldCanvas axis labelling using a CoordinateSystem. 00039 // </summary> 00040 // 00041 // <synopsis> 00042 // This (base) class adds to the interface of WCAxisLabeller functions 00043 // which support the use/provision of a CoordinateSystem to assist with 00044 // axis labelling. 00045 // </synopsis> 00046 00047 class WCCSAxisLabeller : public WCAxisLabeller { 00048 00049 public: 00050 enum SpecAxisType { // taken from the FITS spectral coordinate type codes 00051 FREQ, 00052 VELO, 00053 WAVE, 00054 AWAV, 00055 }; 00056 00057 // Constructor 00058 WCCSAxisLabeller(); 00059 00060 // Destructor 00061 virtual ~WCCSAxisLabeller(); 00062 00063 // Install a CoordinateSystem. 00064 //#dk note: See Bool useWCCS, below; in some cases the WorldCanvas's 00065 //# own CS is now used to draw labels, although the CS set here is 00066 //# still needed for certain things (default user interface, e.g.) 00067 //# when the WC is unknown. (10/07) 00068 virtual void setCoordinateSystem(const CoordinateSystem& coordsys); 00069 00070 // Get the CoordinateSystem. 00071 virtual CoordinateSystem coordinateSystem() const { 00072 return itsCoordinateSystem; } 00073 00074 // Has a CS been set? 00075 Bool hasCoordinateSystem() const { return itsHasCoordinateSystem; }; 00076 00077 // Setting this True allows the labeller to use the WorldCanvas's 00078 // own CS to draw labels (although itsCoordinateSystem is still 00079 // needed for certain things at present). Default: False. 00080 //#dk (See WCCSNLAxisLabeller::draw() and usage in PADD::setupElements()). 00081 //# 00082 //# (Kludge upon kludge, I know... all stemming from the original design 00083 //# flaw: not realizing that WC needs its _own CS_ (related to but _not 00084 //# the same_ as the Images'), and then trying to tack one on later...). 00085 Bool useWCCS; 00086 00087 // install the default options for this labeller. 00088 virtual void setDefaultOptions(); 00089 00090 // apply options stored in rec to the labeller; return value 00091 // True means a refresh is needed. Any fields added to the 00092 // updatedOptions argument are options which have changed in 00093 // some way due to the setting of other options - ie. they 00094 // are context sensitive. 00095 virtual Bool setOptions(const Record &rec, Record &updatedOptions); 00096 00097 // retrieve the current and default options and parameter types. 00098 virtual Record getOptions() const; 00099 00100 // return the X and Y label text - over-ridden from base class 00101 // <group> 00102 //# virtual String xAxisText(WorldCanvas* wc=0) const; 00103 //# virtual String yAxisText(WorldCanvas* wc=0) const; 00104 //# (Compiler whines unless you do it this way instead... grr...). 00105 virtual String xAxisText(WorldCanvas* wc) const; 00106 virtual String yAxisText(WorldCanvas* wc) const; 00107 virtual String xAxisText() const { return xAxisText(0); } 00108 virtual String yAxisText() const { return yAxisText(0); } 00109 // </group> 00110 00111 virtual String zLabelType() const { return itsZLabelType; }; 00112 00113 virtual String zLabelPos() const { return itsZLabelPos; }; 00114 00115 virtual void setZIndex(Int zindex) { itsZIndex = zindex; }; 00116 00117 // DD 'Absolute Pixel Coordinates', e.g. channel numbers, are internally 00118 // 0-based (they begin numbering at 0), but 'Absolute Pixel coordinates' 00119 // have traditionally been displayed as 1-based in the glish viewer. 00120 // uiBase_, and related methods uiBase() and setUIBase(), allow newer 00121 // (python/Qt-based) code to cause such labelling to be produced with 00122 // 0-based values instead. Unless setUIBase(0) is called, the 00123 // traditional 1-based labelling behavior is retained by default. 00124 // 00125 // If you are using 0-basing for 'Absolute Pixel Coordinate' labelling, 00126 // you should call setUIBase(0), before using draw(). 00127 // <group> 00128 virtual Int uiBase() { return uiBase_; } 00129 00130 virtual void setUIBase(Int uibase) { 00131 if(uibase==0 || uibase==1) uiBase_ = uibase; } 00132 // </group> 00133 00134 00135 const String &spectralunitStr( ) const { return itsSpectralUnit; } 00136 00137 00138 protected: 00139 Bool itsAbsolute; 00140 Bool itsWorldAxisLabels; 00141 mutable WCCSAxisLabeller::SpecAxisType itsSpecAxisType; 00142 Int itsZIndex; 00143 00144 // Set spectral state onto given CS 00145 void setSpectralState(CoordinateSystem& cs) const; 00146 00147 // Set direction state onto given CS 00148 void setDirectionState(CoordinateSystem& cs) const; 00149 00150 private: 00151 00152 CoordinateSystem itsCoordinateSystem; 00153 Bool itsHasCoordinateSystem; 00154 String itsSpectralUnit; 00155 String itsSpectralQuantity; 00156 String itsSpectralTypeUnit; 00157 String itsDirectionUnit; 00158 String itsDirectionSystem; 00159 String itsFrequencySystem; 00160 String itsZLabelType; 00161 String itsZLabelPos; 00162 String itsRestValue; // rest frequency or wavelength (value and unit) 00163 String itsRestUnit; // unit for rest frequency or wavelength 00164 00165 Int uiBase_; // (initialized to 1; see uiBase(), above). 00166 00167 // Generate axis text for specified axis 00168 //# String axisText(Int worldAxis, WorldCanvas* wc=0) const; 00169 //# (Compiler whines unless you do it this way instead... grr...). 00170 String axisText(Int worldAxis, WorldCanvas* wc) const; 00171 String axisText(Int worldAxis) const { return axisText(worldAxis, 0); } 00172 00173 // Set new spectral state in itsCoordinateSystem 00174 void setSpectralState() { setSpectralState(itsCoordinateSystem); } 00175 00176 // Set new direction state in itsCoordinateSystem 00177 void setDirectionState() { setDirectionState(itsCoordinateSystem); } 00178 00179 // Set absolute/relative state in itsCoordinateSystem 00180 void setAbsRelState(); 00181 00182 // "optical velocity [m/s]" --> "optical velocity" and "m/s" 00183 void distributeTypeUnit() ; 00184 }; 00185 00186 00187 } //# NAMESPACE CASA - END 00188 00189 #endif