00001 //# AxesDisplayData.h: axis labelling for registering on WorldCanvasHolders 00002 //# Copyright (C) 1999,2000,2001,2002,2004 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_AXESDISPLAYDATA_H 00029 #define TRIALDISPLAY_AXESDISPLAYDATA_H 00030 00031 #include <casa/aips.h> 00032 #include <display/Display/DParameterRange.h> 00033 #include <display/Display/DParameterString.h> 00034 #include <display/Display/DParameterChoice.h> 00035 #include <display/Display/DParameterColorChoice.h> 00036 #include <display/DisplayDatas/PassiveCachingDD.h> 00037 00038 #include <iostream> 00039 using namespace std; 00040 00041 namespace casa { //# NAMESPACE CASA - BEGIN 00042 00043 class WorldCanvas; 00044 class WorldCanvasHolder; 00045 template <class T> class Vector; 00046 class String; 00047 class AttributeBuffer; 00048 00049 // <summary> 00050 // Interface and simple implementation of axis labelling. 00051 // </summary> 00052 // 00053 // <synopsis> 00054 // This class adds to the interface defined by CachingDisplayData to 00055 // provide the necessary infrastructure for drawing axis labels on 00056 // WorldCanvases. This class serves as a basic implementation which 00057 // can (and probably should) be over-written in derived classes. 00058 // </synopsis> 00059 00060 class AxesDisplayData : public PassiveCachingDD { 00061 00062 public: 00063 00064 // Constructor. 00065 AxesDisplayData(); 00066 00067 // Destructor. 00068 virtual ~AxesDisplayData(); 00069 00070 // Install the default options for this DisplayData. 00071 virtual void setDefaultOptions(); 00072 00073 // Apply options stored in <src>rec</src> to the DisplayData. A 00074 // return value of <src>True</src> means a refresh is needed. 00075 // <src>recOut</src> contains any fields which were implicitly 00076 // changed as a result of the call to this function. 00077 virtual Bool setOptions(Record &rec, Record &recOut); 00078 00079 // Retrieve the current and default options and parameter types. 00080 virtual Record getOptions( bool scrub=false ) const; 00081 00082 // Return the type of this DisplayData. 00083 virtual Display::DisplayDataType classType() { 00084 return Display::CanvasAnnotation; 00085 } 00086 00087 // Create a new AxesDisplayMethod for drawing on the given 00088 // WorldCanvas when the AttributeBuffers are suitably matched to the 00089 // current state of this DisplayData and of the WorldCanvas/Holder. 00090 // The tag is a unique number used to identify the age of the newly 00091 // constructed CachingDisplayMethod. 00092 virtual CachingDisplayMethod *newDisplayMethod(WorldCanvas *worldCanvas, 00093 AttributeBuffer *wchAttributes, 00094 AttributeBuffer *ddAttributes, 00095 CachingDisplayData *dd); 00096 00097 // Return the current options of this DisplayData as an 00098 // AttributeBuffer. 00099 virtual AttributeBuffer optionsAsAttributes(); 00100 00101 // Get the title text for labelling. 00102 virtual String titleText() const { 00103 return itsParamTitleText->value(); 00104 } 00105 00106 // Get the X and Y axis text Strings for labelling. 00107 // a WC can be supplied in order to retrieve default titles 00108 // from the WC CS. 00109 // <group> 00110 virtual String xAxisText(const WorldCanvas* wc=0) const; 00111 virtual String yAxisText(const WorldCanvas* wc=0) const; 00112 // </group> 00113 00114 // Get what type of grid should be marked in each direction. 00115 // <group> 00116 virtual String xGridType() const { 00117 return itsParamXGridType->value(); 00118 } 00119 virtual String yGridType() const { 00120 return itsParamYGridType->value(); 00121 } 00122 // </group> 00123 00124 // Get the color to use for the title text, the X axis text, and the 00125 // Y axis text labels. 00126 // <group> 00127 virtual String titleTextColor() const { 00128 return itsParamTitleColor->value(); 00129 } 00130 virtual String xAxisColor() const { 00131 return itsParamXAxisColor->value(); 00132 } 00133 virtual String yAxisColor() const { 00134 return itsParamYAxisColor->value(); 00135 } 00136 // </group> 00137 00138 // Get the line width for labelling. 00139 virtual Float lineWidth() const { 00140 return itsParamLineWidth->value(); 00141 } 00142 00143 // Get the character font for labelling. 00144 virtual String charFont() const { 00145 return itsParamCharacterFont->value(); 00146 } 00147 00148 // Get the character size for labelling. 00149 virtual Float charSize() const { 00150 return itsParamCharacterSize->value(); 00151 } 00152 00153 // Get the color of the plot outline. 00154 virtual String outlineColor() const { 00155 return itsParamOutlineColor->value(); 00156 } 00157 static const float AXIS_LABEL_DEFAULT_CHAR_SIZE; 00158 protected: 00159 00160 // (Required) copy constructor. 00161 AxesDisplayData(const AxesDisplayData &other); 00162 00163 // (Required) copy assignment. 00164 void operator=(const AxesDisplayData &other); 00165 00166 private: 00167 00168 // display title text 00169 DParameterString *itsParamTitleText; 00170 00171 // Store for X axis label text String. 00172 DParameterString *itsParamXAxisText; 00173 00174 // Store for Y axis label text String. 00175 DParameterString *itsParamYAxisText; 00176 00177 // coordinate grid? 00178 DParameterChoice *itsParamXGridType, *itsParamYGridType; 00179 00180 // title color 00181 DParameterColorChoice *itsParamTitleColor; 00182 //String itsOptionsTitleTextColor; 00183 00184 // label text color 00185 DParameterColorChoice *itsParamXAxisColor, *itsParamYAxisColor; 00186 //String itsOptionsXAxisColor, itsOptionsYAxisColor; 00187 00188 // plot line width 00189 DParameterRange<Float> *itsParamLineWidth; 00190 00191 // plot character font 00192 DParameterChoice *itsParamCharacterFont; 00193 00194 // plot character size 00195 DParameterRange<Float> *itsParamCharacterSize; 00196 00197 // plot outline color 00198 DParameterColorChoice *itsParamOutlineColor; 00199 00200 00201 }; 00202 00203 00204 } //# NAMESPACE CASA - END 00205 00206 #endif 00207