casa
$Rev:20696$
|
00001 //# WCAxisLabeller.h: base class for labelling axes on the WorldCanvas 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_WCAXISLABELLER_H 00029 #define TRIALDISPLAY_WCAXISLABELLER_H 00030 00031 //# aips includes: 00032 #include <casa/aips.h> 00033 #include <casa/Containers/Record.h> 00034 00035 //# trial includes: 00036 00037 //# display library includes: 00038 #include <display/Utilities/DisplayOptions.h> 00039 #include <display/DisplayEvents/WCRefreshEvent.h> 00040 00041 namespace casa { //# NAMESPACE CASA - BEGIN 00042 00043 //# forwards: 00044 00045 // <summary> 00046 // Abstract class for drawing grids, axes, ticks and tick labels 00047 // on a WorldCanvas 00048 // </summary> 00049 // 00050 // <use visibility=local> 00051 // 00052 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00053 // </reviewed> 00054 // 00055 // <prerequisite> 00056 // <li> WorldCanvas 00057 // </prerequisite> 00058 // 00059 // <etymology> 00060 // WCAxisLabeller stands for WorldCanvas Axis Labeller 00061 // </etymology> 00062 // 00063 // <synopsis> 00064 // This class forms the base for classes which draw axis grids, 00065 // axes, ticks and tick labels on WorldCanvases. In its 00066 // present form, it is really a heavily pruned form of the 00067 // DisplayData. 00068 // </synopsis> 00069 // 00070 // <example> 00071 // </example> 00072 // 00073 // <motivation> 00074 // Axis labels are a necessary annotation for meaningful displays 00075 // of data. This class is motivated by the desire to provide 00076 // (eventually) many different types of axis labelling. 00077 // </motivation> 00078 // 00079 // <todo asof="1999/02/16"> 00080 // <li> add to interface: getOptions, setOptions 00081 // <li> perhaps convert to a DisplayData? 00082 // </todo> 00083 00084 class WCAxisLabeller : public DisplayOptions { 00085 00086 public: 00087 00088 // Constructor 00089 WCAxisLabeller(); 00090 00091 // Destructor 00092 virtual ~WCAxisLabeller(); 00093 00094 // Draw axis labels for the provided WorldCanvas refresh event 00095 virtual Bool draw(const WCRefreshEvent &ev) = 0; 00096 00097 // Invalidate any cached drawings 00098 virtual void invalidate() { }; 00099 00100 // install the default options for this DisplayData 00101 virtual void setDefaultOptions(); 00102 00103 // apply options stored in rec to the DisplayData; return value 00104 // True means a refresh is needed. Any fields added to the 00105 // updatedOptions argument are options which have changed in 00106 // some way due to the setting of other options - ie. they 00107 // are context sensitive. 00108 virtual Bool setOptions(const Record &rec, Record &updatedOptions); 00109 00110 // retrieve the current and default options and parameter types. 00111 virtual Record getOptions() const; 00112 00113 // set/return whether labelling is on or off. This is a global 00114 // switch. If True is returned from the set function, then a 00115 // refresh is required. 00116 // <group> 00117 virtual Bool setAxisLabelSwitch(const Bool labelswitch = False); 00118 virtual Bool axisLabelSwitch() const 00119 { return itsOptionsAxisLabelSwitch; } 00120 // </group> 00121 00122 // set/return the title text. If True is returned from the set 00123 // function then a refresh is required. 00124 // <group> 00125 virtual Bool setTitleText(const String text = String("")); 00126 virtual String titleText() const 00127 { return itsOptionsTitleText; } 00128 // </group> 00129 00130 // set/return the color of the title text. If True is returned from 00131 // the set function, then a refresh should be called. 00132 // <group> 00133 virtual Bool setTitleTextColor(const String color = String("foreground")); 00134 virtual String titleTextColor() const 00135 { return itsOptionsTitleTextColor; } 00136 // </group> 00137 00138 // set/return the X and Y label text. If True is returned from 00139 // the set functions, then a refresh is needed. 00140 // <group> 00141 virtual Bool setXAxisText(const String text = String("")); 00142 virtual Bool setYAxisText(const String text = String("")); 00143 virtual Bool unsetXAxisText(); 00144 virtual Bool unsetYAxisText(); 00145 virtual String xAxisText() const; 00146 virtual String yAxisText() const; 00147 virtual Bool isXAxisTextUnset() const 00148 { return itsOptionsXAxisTextUnset; } 00149 virtual Bool isYAxisTextUnset() const 00150 { return itsOptionsYAxisTextUnset; } 00151 // </group> 00152 00153 // set/return the color of the label text. If True is returned 00154 // from the set function, then a refresh is needed. 00155 // <group> 00156 virtual Bool setXAxisTextColor(const String color = String("foreground")); 00157 virtual Bool setYAxisTextColor(const String color = String("foreground")); 00158 virtual String xAxisTextColor() const 00159 { return itsOptionsXAxisTextColor; } 00160 virtual String yAxisTextColor() const 00161 { return itsOptionsYAxisTextColor; } 00162 // </group> 00163 00164 // set/return what type of grid is marked in each direction. 00165 // If True is returned from the set functions, a refresh is needed. 00166 // <group> 00167 virtual Bool setXGridType(const String type = String("None")); 00168 virtual Bool setYGridType(const String type = String("None")); 00169 virtual String xGridType() const 00170 { return itsOptionsXGridType; } 00171 virtual String yGridType() const 00172 { return itsOptionsYGridType; } 00173 // </group> 00174 00175 // set/return the color of the grid lines per direction. If True 00176 // is returned from the set functions, a refresh is needed. 00177 // <group> 00178 virtual Bool setXGridColor(const String color = String("foreground")); 00179 virtual Bool setYGridColor(const String color = String("foreground")); 00180 virtual String xGridColor() const 00181 { return itsOptionsXGridColor; } 00182 virtual String yGridColor() const 00183 { return itsOptionsYGridColor; } 00184 // </group> 00185 00186 // set/return the tick length in millimetres. If True is returned 00187 // from the set function, then a refresh is probably needed. 00188 // <group> 00189 virtual Bool setTickLength(const Float length = 4.0); 00190 virtual Float tickLength() const 00191 { return itsOptionsTickLength; } 00192 // </group> 00193 00194 // set/return the position of World label strings 00195 // <group> 00196 virtual Bool setLabelPosition(const String position = String("Auto")); 00197 virtual String labelPosition() const 00198 { return itsOptionsLabelPos; } 00199 // </group> 00200 00201 00202 // set/return whether there is a plot outline or not. If True is 00203 // returned from the set function, then a refresh is probably needed. 00204 // <group> 00205 virtual Bool setPlotOutline(const Bool outline = True); 00206 virtual Bool plotOutline() const 00207 { return itsOptionsPlotOutline; } 00208 // </group> 00209 00210 // set/return the color used for the plot outline. If True is 00211 // returned from the set function, then a refresh should be 00212 // enacted. 00213 // <group> 00214 virtual Bool setPlotOutlineColor(const String color = String("foreground")); 00215 virtual String plotOutlineColor() const 00216 { return itsOptionsPlotOutlineColor; } 00217 // </group> 00218 00219 // set/return the char size for the plot graphics 00220 // <group> 00221 virtual Bool setCharSize(const Float size = 1.2); 00222 virtual Float charSize() const 00223 { return itsOptionsCharSize; } 00224 // </group> 00225 00226 // set/return the char font for the plot graphics 00227 // <group> 00228 virtual Bool setCharFont(const String font = "normal"); 00229 virtual String charFont() const 00230 { return itsOptionsCharFont; } 00231 // </group> 00232 00233 // set/return the line width for the plot graphics. 00234 // <group> 00235 /* 00236 virtual Bool setLineWidth(const Int width = 0); 00237 virtual Int lineWidth() const 00238 { return itsOptionsLineWidth; } 00239 */ 00240 virtual Bool setLineWidth(const Float width = 0.0); 00241 virtual Float lineWidth() const 00242 { return itsOptionsLineWidth; } 00243 // </group> 00244 00245 static const String LABEL_CHAR_SIZE; 00246 static const String PLOT_TITLE; 00247 private: 00248 00249 // global switch on or off 00250 Bool itsOptionsAxisLabelSwitch; 00251 00252 // display title text 00253 String itsOptionsTitleText; 00254 00255 // title color 00256 String itsOptionsTitleTextColor; 00257 00258 // display axes label text 00259 String itsOptionsXAxisText, itsOptionsYAxisText; 00260 00261 // are the above unset 00262 Bool itsOptionsXAxisTextUnset, itsOptionsYAxisTextUnset; 00263 00264 // label text color 00265 String itsOptionsXAxisTextColor, itsOptionsYAxisTextColor; 00266 00267 // coordinate grid? 00268 String itsOptionsXGridType, itsOptionsYGridType; 00269 00270 // coordinate grid colors 00271 String itsOptionsXGridColor, itsOptionsYGridColor; 00272 00273 // tick mark length in mm 00274 Float itsOptionsTickLength; 00275 00276 // Label position 00277 String itsOptionsLabelPos; 00278 00279 // plot outline? 00280 Bool itsOptionsPlotOutline; 00281 00282 // plot outline color 00283 String itsOptionsPlotOutlineColor; 00284 00285 // plot character size 00286 Float itsOptionsCharSize; 00287 00288 // plot character font 00289 String itsOptionsCharFont; 00290 00291 // plot line width 00292 //Int itsOptionsLineWidth; 00293 Float itsOptionsLineWidth; 00294 00295 // defaults for on/off switch and character size 00296 // (from .aipsrc, if they exist there). 00297 Bool itsDefaultSwitch; 00298 Float itsDefaultCharSize; 00299 00300 }; 00301 00302 00303 } //# NAMESPACE CASA - END 00304 00305 #endif