casa
$Rev:20696$
|
00001 //# ParamPanel.qo.h: Panel for a single parameter. 00002 //# Copyright (C) 2005 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 #ifndef PARAMPANEL_QO_H_ 00028 #define PARAMPANEL_QO_H_ 00029 00030 #include <casaqt/QtParamGui/QtParamGUI.qo.h> 00031 #include <casaqt/QtParamGui/ParamPanel.ui.h> 00032 #include <casaqt/QtParamGui/ValuePanel.qo.h> 00033 00034 #include <utility> 00035 00036 #include <casa/namespace.h> 00037 using namespace std; 00038 00039 namespace casa { 00040 00041 // A ParamPanel holds information for a single parameter. It displays the 00042 // parameter information (name, type, description, etc.) and provides a 00043 // widget(s) for the user to input a value for that parameter. These widget(s) 00044 // are held in a ValuePanel. 00045 class ParamPanel : public QWidget, Ui::ParamPanel { 00046 Q_OBJECT 00047 00048 public: 00049 // Constructor that takes the parameter name and a record describing its 00050 // attributes. Allowed attributes include: 00051 // * allowed: a list of possible values to choose from 00052 // * description: a description of the parameter 00053 // * example: example(s) for the parameter 00054 // * kind: indicates whether the parameter has a special type (such as 00055 // a file) 00056 // * limittypes: if the parameter is type "any", the potential types can 00057 // be limited 00058 // * mustexist: if the parameter requires a non-empty value 00059 // * range: range of values for numeric types 00060 // * type (required): the type for the parameter 00061 // * units: what conceptual units the parameter is in 00062 // * value: a default value 00063 ParamPanel(const QtParamGUI& parent, String name, 00064 const RecordInterface& record, const Record& globals, 00065 const Record& last, const QtParamGUI::ResetMode& resetMode, 00066 int labelWidth = -1, const String& constraints = "", 00067 bool subparam = false); 00068 00069 // Destructor. 00070 ~ParamPanel(); 00071 00072 // Returns the parameter's name. 00073 String name(); 00074 00075 // Returns the ValuePanel. 00076 ValuePanel* value(); 00077 00078 // Returns whether the current value given to the parameter is valid or 00079 // not. If not valid, the second pair value is the reason why. 00080 pair<bool, String> isValid(); 00081 00082 // Put the current value into the record with the parameter name as the 00083 // key. 00084 void getValue(Record& record); 00085 00086 public slots: 00087 // Reset the value to the default (if any). 00088 void reset(); 00089 00090 signals: 00091 // Emitted when the user changes the value in this panel. 00092 void valueChanged(String name); 00093 00094 private: 00095 // Parameter name. 00096 String m_name; 00097 00098 // Parameter attributes. 00099 const RecordInterface& m_record; 00100 00101 // Global settings. 00102 const Record& m_globals; 00103 00104 // Last settings. 00105 const Record& m_last; 00106 00107 // Reset to globals or defaults. 00108 const QtParamGUI::ResetMode& m_resetMode; 00109 00110 // (Optional) label to display units. 00111 QLabel* m_units; 00112 00113 // Value panel. 00114 ValuePanel* m_value; 00115 00116 // Constraints dialog. 00117 QDialog* m_constDialog; 00118 00119 00120 // Sets the value to the default defined in the attributes. 00121 void setValue(); 00122 00123 private slots: 00124 // Show or hide the panel with the description and extra info. 00125 void showHideDesc(); 00126 00127 // Show/hide the constraints dialog. 00128 void showHideConstraints(bool checked); 00129 00130 // When the constraints dialog is closed. 00131 void constraintsClosed(); 00132 00133 // Catch the value panel's valueChanged signal and re-emit it. 00134 void changedValue() { emit valueChanged(m_name); } 00135 }; 00136 00137 } 00138 00139 #endif /*PARAMPANEL_QO_H_*/