casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WCCSAxisLabeller.h
Go to the documentation of this file.
1 //# WCCSAxisLabeller.h: labelling axes using a DisplayCoordinateSystem on a WC
2 //# Copyright (C) 1999,2000,2001,2002
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef TRIALDISPLAY_WCCSAXISLABELLER_H
29 #define TRIALDISPLAY_WCCSAXISLABELLER_H
30 
31 #include <casa/aips.h>
34 
35 namespace casa { //# NAMESPACE CASA - BEGIN
36 
37 // <summary>
38 // Base class for WorldCanvas axis labelling using a DisplayCoordinateSystem.
39 // </summary>
40 //
41 // <synopsis>
42 // This (base) class adds to the interface of WCAxisLabeller functions
43 // which support the use/provision of a DisplayCoordinateSystem to assist with
44 // axis labelling.
45 // </synopsis>
46 
48 
49  public:
50  enum SpecAxisType { // taken from the casacore::FITS spectral coordinate type codes
55  };
56 
57  // Constructor
59 
60  // Destructor
61  virtual ~WCCSAxisLabeller();
62 
63  // Install a DisplayCoordinateSystem.
64  //#dk note: See casacore::Bool useWCCS, below; in some cases the WorldCanvas's
65  //# own CS is now used to draw labels, although the CS set here is
66  //# still needed for certain things (default user interface, e.g.)
67  //# when the WC is unknown. (10/07)
68  virtual void setCoordinateSystem(const DisplayCoordinateSystem& coordsys);
69 
70  // Get the DisplayCoordinateSystem.
72  return itsCoordinateSystem;
73  }
74 
75  // Has a CS been set?
78  };
79 
80  // Setting this true allows the labeller to use the WorldCanvas's
81  // own CS to draw labels (although itsCoordinateSystem is still
82  // needed for certain things at present). Default: false.
83  //#dk (See WCCSNLAxisLabeller::draw() and usage in PADD::setupElements()).
84  //#
85  //# (Kludge upon kludge, I know... all stemming from the original design
86  //# flaw: not realizing that WC needs its _own CS_ (related to but _not
87  //# the same_ as the Images'), and then trying to tack one on later...).
89 
90  // install the default options for this labeller.
91  virtual void setDefaultOptions();
92 
93  // apply options stored in rec to the labeller; return value
94  // true means a refresh is needed. Any fields added to the
95  // updatedOptions argument are options which have changed in
96  // some way due to the setting of other options - ie. they
97  // are context sensitive.
98  virtual casacore::Bool setOptions(const casacore::Record &rec, casacore::Record &updatedOptions);
99 
100  // retrieve the current and default options and parameter types.
101  virtual casacore::Record getOptions() const;
102 
103  // return the X and Y label text - over-ridden from base class
104  // <group>
105  //# virtual casacore::String xAxisText(WorldCanvas* wc=0) const;
106  //# virtual casacore::String yAxisText(WorldCanvas* wc=0) const;
107  //# (Compiler whines unless you do it this way instead... grr...).
108  virtual casacore::String xAxisText(WorldCanvas* wc) const;
109  virtual casacore::String yAxisText(WorldCanvas* wc) const;
110  virtual casacore::String xAxisText() const {
111  return xAxisText(0);
112  }
113  virtual casacore::String yAxisText() const {
114  return yAxisText(0);
115  }
116  // </group>
117 
118  virtual casacore::String zLabelType() const {
119  return itsZLabelType;
120  };
121 
122  virtual casacore::String zLabelPos() const {
123  return itsZLabelPos;
124  };
125 
126  virtual void setZIndex(casacore::Int zindex) {
127  itsZIndex = zindex;
128  };
129 
130  // DD 'Absolute Pixel Coordinates', e.g. channel numbers, are internally
131  // 0-based (they begin numbering at 0), but 'Absolute Pixel coordinates'
132  // have traditionally been displayed as 1-based in the glish viewer.
133  // uiBase_, and related methods uiBase() and setUIBase(), allow newer
134  // (python/Qt-based) code to cause such labelling to be produced with
135  // 0-based values instead. Unless setUIBase(0) is called, the
136  // traditional 1-based labelling behavior is retained by default.
137  //
138  // If you are using 0-basing for 'Absolute Pixel casacore::Coordinate' labelling,
139  // you should call setUIBase(0), before using draw().
140  // <group>
141  virtual casacore::Int uiBase() const {
142  return uiBase_;
143  }
144 
145  virtual void setUIBase(casacore::Int uibase) {
146  if(uibase==0 || uibase==1) uiBase_ = uibase;
147  }
148  // </group>
149 
150 
152  return itsSpectralUnit;
153  }
154 
156  return itsSpectralPrecision;
157  }
158 
159  protected:
164 
165  // Set spectral state onto given CS
167 
168  // Set direction state onto given CS
170 
171  private:
172 
184  casacore::String itsRestValue; // rest frequency or wavelength (value and unit)
185  casacore::String itsRestUnit; // unit for rest frequency or wavelength
186 
187  casacore::Int uiBase_; // (initialized to 1; see uiBase(), above).
188 
189  // Generate axis text for specified axis
190  //# casacore::String axisText(casacore::Int worldAxis, WorldCanvas* wc=0) const;
191  //# (Compiler whines unless you do it this way instead... grr...).
192  casacore::String axisText(casacore::Int worldAxis, WorldCanvas* wc) const;
194  return axisText(worldAxis, 0);
195  }
196 
197  // Set new spectral state in itsCoordinateSystem
200  }
201 
202  // Set new direction state in itsCoordinateSystem
205  }
206 
207  // Set absolute/relative state in itsCoordinateSystem
208  void setAbsRelState();
209 
210  // "optical velocity [m/s]" --> "optical velocity" and "m/s"
211  void distributeTypeUnit() ;
212 
214  };
215 
216 
217 } //# NAMESPACE CASA - END
218 
219 #endif
Base class for WorldCanvas axis labelling using a DisplayCoordinateSystem.
WCCSAxisLabeller::SpecAxisType itsSpecAxisType
int Int
Definition: aipstype.h:50
void setDirectionState()
Set new direction state in itsCoordinateSystem.
casacore::String itsRestValue
casacore::String axisText(casacore::Int worldAxis, WorldCanvas *wc) const
Generate axis text for specified axis.
casacore::String itsRestUnit
casacore::Int spectralprec() const
virtual DisplayCoordinateSystem coordinateSystem() const
Get the DisplayCoordinateSystem.
void setAbsRelState()
Set absolute/relative state in itsCoordinateSystem.
casacore::String axisText(casacore::Int worldAxis) const
casacore::Bool hasCoordinateSystem() const
Has a CS been set?
virtual void setDefaultOptions()
install the default options for this labeller.
casacore::Int itsSpectralPrecision
casacore::Bool itsWorldAxisLabels
Abstract class for drawing grids, axes, ticks and tick labels on a WorldCanvas.
casacore::String itsSpectralUnit
DisplayCoordinateSystem itsCoordinateSystem
casacore::String itsSpectralQuantity
virtual void setUIBase(casacore::Int uibase)
static const casacore::String FRAME_REST
casacore::String itsZLabelPos
virtual casacore::Record getOptions() const
retrieve the current and default options and parameter types.
casacore::Bool itsAbsolute
WCCSAxisLabeller()
Constructor.
virtual casacore::Bool setOptions(const casacore::Record &rec, casacore::Record &updatedOptions)
apply options stored in rec to the labeller; return value true means a refresh is needed...
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Bool itsHasCoordinateSystem
casacore::String itsZLabelType
void distributeTypeUnit()
&quot;optical velocity [m/s]&quot; –&gt; &quot;optical velocity&quot; and &quot;m/s&quot;
casacore::String itsSpectralTypeUnit
virtual void setZIndex(casacore::Int zindex)
const casacore::String & spectralunitStr() const
virtual void setCoordinateSystem(const DisplayCoordinateSystem &coordsys)
Install a DisplayCoordinateSystem.
virtual casacore::String zLabelPos() const
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
casacore::String itsDirectionSystem
virtual casacore::String zLabelType() const
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Bool useWCCS
Setting this true allows the labeller to use the WorldCanvas&#39;s own CS to draw labels (although itsCoo...
virtual casacore::String xAxisText() const
casacore::String itsDirectionUnit
void setSpectralState()
Set new spectral state in itsCoordinateSystem.
virtual ~WCCSAxisLabeller()
Destructor.
virtual casacore::String yAxisText() const
virtual casacore::Int uiBase() const
DD &#39;Absolute Pixel Coordinates&#39;, e.g.
casacore::String itsFrequencySystem