casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
DParameterRange.h
Go to the documentation of this file.
00001 //# DParameterRange.h: class to store and retrieve range parameters 
00002 //# Copyright (C) 2000,2001
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_DPARAMETERRANGE_H
00029 #define TRIALDISPLAY_DPARAMETERRANGE_H
00030 
00031 #include <casa/aips.h>
00032 #include <display/Display/DisplayParameter.h>
00033 namespace casa { //# NAMESPACE CASA - BEGIN
00034 
00035 // <summary> 
00036 // A helper class to deal with data ranges to support options
00037 // </summary>
00038 //
00039 // <use visibility=export>
00040 // 
00041 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00042 // </reviewed>
00043 // 
00044 // <prerequisite>
00045 //   <li> DisplayParameter
00046 // </prerequisite>
00047 //
00048 // <etymology>
00049 // </etymology>
00050 //
00051 // <synopsis>
00052 //
00053 // </synopsis>
00054 //
00055 // <example>
00056 // </example>
00057 //
00058 // <motivation>
00059 // Making things easier
00060 // </motivation>
00061 //
00062 // <todo> 
00063 // </todo>
00064 //
00065 
00066 template <class T> class DParameterRange : public DisplayParameter {
00067 
00068  public:
00069 
00070   // Constructor taking the name of the parameter, a short
00071   // description, some help text, a minimum value, a maximum value, a
00072   // default value, a current value, and flags indicating whether the
00073   // parameter is editable.
00074   DParameterRange(const String name, const String description,
00075                   const String help, const T minimum, const T maximum, 
00076                   const T resolution, const T defaultvalue, const T value, 
00077                   const String context = "", const Bool editable = True,
00078                   const Bool provideentry = False, const Bool onrelease=False );
00079 
00080   // (Required) default constructor.
00081   DParameterRange();
00082 
00083   // (Required) copy constructor.
00084   DParameterRange(const DParameterRange<T> &other);
00085 
00086   // Destructor.
00087   virtual ~DParameterRange();
00088 
00089   // (Required) copy assignment.
00090   DParameterRange<T> &operator=(const DParameterRange<T> &other);
00091 
00092   // Parse <src>record</src>, and update this parameter if a field
00093   // exists whose name matches that of this parameter.  Return
00094   // <src>True</src> if the parameter is changed, otherwise return
00095   // <src>False</src>.
00096   virtual Bool fromRecord(const RecordInterface &record);
00097 
00098   // Place a record describing this parameter in a sub-field of
00099   // <src>record</src> with name matching that of this parameter.  If
00100   // <src>overwrite</src> is <src>True</src>, then any existing field
00101   // with matching name will be overwritten.  If <src>fullrecord</src>
00102   // is <src>True</src>, then a complete description of the parameter
00103   // is given, otherwise just its current value is stored in
00104   // <src>record</src>.  Presently <src>fullrecord</src> is ignored.
00105   virtual void toRecord(RecordInterface &record, const Bool fullrecord = True,
00106                         const Bool overwrite = False);
00107 
00108   // Return the minimum for this parameter.
00109   T minimum()
00110     { return itsMinimum; }
00111   
00112   // Return the maximum for this parameter.
00113   T maximum()
00114     { return itsMaximum; }
00115 
00116   // Return the resolution of this parameter.
00117   T resolution()
00118     { return itsResolution; }
00119 
00120   // Return the default for this parameter.
00121   T defaultValue() 
00122     { return itsDefault; }
00123 
00124   // Return the current value of this parameter.
00125   T value() 
00126     { return itsValue; }
00127 
00128   // Return whether there should be a text box beside the slider.
00129   // See 'intrange' in the autogui tool documentation for more information.
00130   Bool provideEntry()
00131     { return itsProvideEntry; }
00132 
00133   // Return whether the slider event should occur when the user releases the
00134   // slider, i.e. at the end of setting the value, rather than in real time
00135   // as the user moves the slider (good for operations which take a long time)
00136   Bool onRelease( )
00137     { return itsOnRelease; }
00138 
00139 
00140   // Set or change the minimum for this parameter.
00141   void setMinimum(const T minimum)
00142     { itsMinimum = minimum; }
00143 
00144   // Set or change the maximum for this parameter.
00145   void setMaximum(const T maximum)
00146     { itsMaximum = maximum; }
00147 
00148   // Set or change the resolution for this parameter.
00149   void setResolution(const T resolution)
00150     { itsResolution = resolution; }
00151 
00152   // Set or change the default for this parameter.
00153   void setDefaultValue(const T defaultValue)
00154     { itsDefault = defaultValue; }
00155 
00156   // Set or change the current value for this parameter.
00157   void setValue(const T value)
00158     { itsValue = value; }
00159 
00160   // Convenient syntax to set (only) the value.
00161   const T& operator=(const T &value) {
00162     itsValue = value; return value;  }
00163   
00164   // Set or change the provideentry state for this parameter.
00165   void setProvideEntry(const Bool provideentry)
00166     { itsProvideEntry = provideentry; }
00167 
00168   // Set or change the onrelease state for this parameter.
00169   void setOnRelease(const Bool onrelease)
00170     { itsOnRelease = onrelease; }
00171 
00172  private:
00173 
00174   // Store for the minimum of this parameter.
00175   T itsMinimum;
00176 
00177   // Store for the maximum of this parameter.
00178   T itsMaximum;
00179 
00180   // Store for the resolution of this parameter.
00181   T itsResolution;
00182   
00183   // Store for the default of this parameter.
00184   T itsDefault;
00185 
00186   // Store for the value of this parameter.
00187   T itsValue;
00188 
00189   // Store for the 'provideentry' state of this parameter.
00190   Bool itsProvideEntry;
00191 
00192   // Store for the 'onrelease' state of this parameter
00193   Bool itsOnRelease;
00194   
00195 };
00196 
00197 } //# NAMESPACE CASA - END
00198 
00199 #ifndef AIPS_NO_TEMPLATE_SRC
00200 #include <display/Display/DParameterRange.tcc>
00201 #endif
00202 
00203 #endif