00001 //# WCCSAxisLabeller.h: labelling axes using a DisplayCoordinateSystem 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 <display/Display/DisplayCoordinateSystem.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 DisplayCoordinateSystem. 00039 // </summary> 00040 // 00041 // <synopsis> 00042 // This (base) class adds to the interface of WCAxisLabeller functions 00043 // which support the use/provision of a DisplayCoordinateSystem 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 DisplayCoordinateSystem. 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 DisplayCoordinateSystem& coordsys); 00069 00070 // Get the DisplayCoordinateSystem. 00071 virtual DisplayCoordinateSystem coordinateSystem() const { 00072 return itsCoordinateSystem; 00073 } 00074 00075 // Has a CS been set? 00076 Bool hasCoordinateSystem() const { 00077 return itsHasCoordinateSystem; 00078 }; 00079 00080 // Setting this True allows the labeller to use the WorldCanvas's 00081 // own CS to draw labels (although itsCoordinateSystem is still 00082 // needed for certain things at present). Default: False. 00083 //#dk (See WCCSNLAxisLabeller::draw() and usage in PADD::setupElements()). 00084 //# 00085 //# (Kludge upon kludge, I know... all stemming from the original design 00086 //# flaw: not realizing that WC needs its _own CS_ (related to but _not 00087 //# the same_ as the Images'), and then trying to tack one on later...). 00088 Bool useWCCS; 00089 00090 // install the default options for this labeller. 00091 virtual void setDefaultOptions(); 00092 00093 // apply options stored in rec to the labeller; return value 00094 // True means a refresh is needed. Any fields added to the 00095 // updatedOptions argument are options which have changed in 00096 // some way due to the setting of other options - ie. they 00097 // are context sensitive. 00098 virtual Bool setOptions(const Record &rec, Record &updatedOptions); 00099 00100 // retrieve the current and default options and parameter types. 00101 virtual Record getOptions() const; 00102 00103 // return the X and Y label text - over-ridden from base class 00104 // <group> 00105 //# virtual String xAxisText(WorldCanvas* wc=0) const; 00106 //# virtual String yAxisText(WorldCanvas* wc=0) const; 00107 //# (Compiler whines unless you do it this way instead... grr...). 00108 virtual String xAxisText(WorldCanvas* wc) const; 00109 virtual String yAxisText(WorldCanvas* wc) const; 00110 virtual String xAxisText() const { 00111 return xAxisText(0); 00112 } 00113 virtual String yAxisText() const { 00114 return yAxisText(0); 00115 } 00116 // </group> 00117 00118 virtual String zLabelType() const { 00119 return itsZLabelType; 00120 }; 00121 00122 virtual String zLabelPos() const { 00123 return itsZLabelPos; 00124 }; 00125 00126 virtual void setZIndex(Int zindex) { 00127 itsZIndex = zindex; 00128 }; 00129 00130 // DD 'Absolute Pixel Coordinates', e.g. channel numbers, are internally 00131 // 0-based (they begin numbering at 0), but 'Absolute Pixel coordinates' 00132 // have traditionally been displayed as 1-based in the glish viewer. 00133 // uiBase_, and related methods uiBase() and setUIBase(), allow newer 00134 // (python/Qt-based) code to cause such labelling to be produced with 00135 // 0-based values instead. Unless setUIBase(0) is called, the 00136 // traditional 1-based labelling behavior is retained by default. 00137 // 00138 // If you are using 0-basing for 'Absolute Pixel Coordinate' labelling, 00139 // you should call setUIBase(0), before using draw(). 00140 // <group> 00141 virtual Int uiBase() const { 00142 return uiBase_; 00143 } 00144 00145 virtual void setUIBase(Int uibase) { 00146 if(uibase==0 || uibase==1) uiBase_ = uibase; 00147 } 00148 // </group> 00149 00150 00151 const String &spectralunitStr( ) const { 00152 return itsSpectralUnit; 00153 } 00154 00155 Int spectralprec( ) const { 00156 return itsSpectralPrecision; 00157 } 00158 00159 protected: 00160 Bool itsAbsolute; 00161 Bool itsWorldAxisLabels; 00162 mutable WCCSAxisLabeller::SpecAxisType itsSpecAxisType; 00163 Int itsZIndex; 00164 00165 // Set spectral state onto given CS 00166 void setSpectralState(DisplayCoordinateSystem& cs) const; 00167 00168 // Set direction state onto given CS 00169 void setDirectionState(DisplayCoordinateSystem& cs) const; 00170 00171 private: 00172 00173 DisplayCoordinateSystem itsCoordinateSystem; 00174 Bool itsHasCoordinateSystem; 00175 Int itsSpectralPrecision; 00176 String itsSpectralUnit; 00177 String itsSpectralQuantity; 00178 String itsSpectralTypeUnit; 00179 String itsDirectionUnit; 00180 String itsDirectionSystem; 00181 String itsFrequencySystem; 00182 String itsZLabelType; 00183 String itsZLabelPos; 00184 String itsRestValue; // rest frequency or wavelength (value and unit) 00185 String itsRestUnit; // unit for rest frequency or wavelength 00186 00187 Int uiBase_; // (initialized to 1; see uiBase(), above). 00188 00189 // Generate axis text for specified axis 00190 //# String axisText(Int worldAxis, WorldCanvas* wc=0) const; 00191 //# (Compiler whines unless you do it this way instead... grr...). 00192 String axisText(Int worldAxis, WorldCanvas* wc) const; 00193 String axisText(Int worldAxis) const { 00194 return axisText(worldAxis, 0); 00195 } 00196 00197 // Set new spectral state in itsCoordinateSystem 00198 void setSpectralState() { 00199 setSpectralState(itsCoordinateSystem); 00200 } 00201 00202 // Set new direction state in itsCoordinateSystem 00203 void setDirectionState() { 00204 setDirectionState(itsCoordinateSystem); 00205 } 00206 00207 // Set absolute/relative state in itsCoordinateSystem 00208 void setAbsRelState(); 00209 00210 // "optical velocity [m/s]" --> "optical velocity" and "m/s" 00211 void distributeTypeUnit() ; 00212 00213 static const String FRAME_REST; 00214 }; 00215 00216 00217 } //# NAMESPACE CASA - END 00218 00219 #endif