casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtAutoGui.qo.h
Go to the documentation of this file.
1 //# QtAutoGui.qo.h: General-purpose Qt options panel widget created from
2 //# an options Record.
3 //# Copyright (C) 2005
4 //# Associated Universities, Inc. Washington DC, USA.
5 //#
6 //# This library is free software; you can redistribute it and/or modify it
7 //# under the terms of the GNU Library General Public License as published by
8 //# the Free Software Foundation; either version 2 of the License, or (at your
9 //# option) any later version.
10 //#
11 //# This library is distributed in the hope that it will be useful, but WITHOUT
12 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 //# License for more details.
15 //#
16 //# You should have received a copy of the GNU Library General Public License
17 //# along with this library; if not, write to the Free Software Foundation,
18 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19 //#
20 //# Correspondence concerning AIPS++ should be addressed as follows:
21 //# Internet email: aips2-request@nrao.edu.
22 //# Postal address: AIPS++ Project Office
23 //# National Radio Astronomy Observatory
24 //# 520 Edgemont Road
25 //# Charlottesville, VA 22903-2475 USA
26 //#
27 //# $Id$
28 
29 #ifndef QTAUTOGUI_H
30 #define QTAUTOGUI_H
31 
32 #include <casa/aips.h>
33 
34 #include <graphics/X11/X_enter.h>
35 # include <QtCore>
36 # include <QtGui>
37 # include <QtXml/QDomDocument>
38 #include <graphics/X11/X_exit.h>
39 
40 #include "QtGuiEntry.qo.h"
41 #include "QtXmlRecord.h"
42 
43 namespace casa { //# NAMESPACE CASA - BEGIN
44 
45 
46 // <summary>
47 // General-purpose Qt options widget created from Record
48 // </summary>
49 
50 // <synopsis>
51 // This class serves the same general purpose as the old glish
52 // autogui.g: it creates a gui from a record whose fields describe
53 // 'parameters' (or 'options') to be controlled by the gui. The record
54 // used to construct the gui is passed in construction, or soon after,
55 // via loadRecord(). Each option passed contains an initial value as
56 // well as meta-data describing the type of input widget to be used
57 // ('popt' field), labels, limits, choices, help texts, etc., as applicable.
58 //
59 // When the user operates the control for a gui option, a setOptions
60 // signal is emitted with a similar casacore::Record indicating which option was
61 // changed, and new value. If the 'Apply' button of the gui is pressed,
62 // the setOptions signal contains the current value of every option.
63 // </synopsis>
64 
66  class QtAutoGui : public QWidget {
67  Q_OBJECT
68 
69  public:
70 
71  QtAutoGui(QWidget *parent = 0);
72  QtAutoGui(casacore::Record rec, casacore::String dataName = "",
73  casacore::String dataType = "Unknown", QWidget *parent = 0);
74  ~QtAutoGui();
75 
76  void setFileName(const QString &file_name);
77  QString fileName() const;
78  void setDataType(const QString &dType);
79  QString dataType() const;
80  bool load(QDomDocument &doc);
81  bool load(); //from file
82  bool save(); //to file
83  void apply(); //to the canvas
84  void restore();
85  void setMemory(); //take a snapshot
86  void setOriginal(); //restore to the saved
87  void setDefault(); //use the preset values
88  void dismiss();
90  // call once only during initialization, to populate the gui,
91  // if you used the QtAutoGui(QWidget=0) constructor.
92  void loadRecord(casacore::Record rec);
93  static const QString HISTOGRAM_SHOW_KEY;
94  static const QString HISTOGRAM_RANGE_KEY;
95 
96  signals:
97 
99  //# dk note to hye:
100  //#
101  //# This is the signal that needs to be sent whenever a value
102  //# is changed on the gui, or when 'apply' is pressed. When
103  //# a gui value change occurs, send only that option; when
104  //# 'apply' is pressed, send the current value of all options.
105  //# The record format should be as for getOptions, although not
106  //# all fields are always sent. You need only send the 'value'
107  //# field of the option[s], although you can send the other fields
108  //# too if you want.
109  //#
110  //# Look at the format of setoptions events sent in the current
111  //# viewer; this is the format the C++ display library expects.
112  //# An easy way to do this is to copy this diagnostic-version
113  //# glish file to the directory where you run aips++:
114  //#
115  //# /users/dking/testcode/g/viewerdisplaydata.g
116  //#
117  //# Then run the aips++ viewer normally there. Each time you
118  //# change an 'adjust' panel option or press its 'apply', it will
119  //# print the record emitted by the setoptions event.
120 
121  protected:
122  void contextMenuEvent(QContextMenuEvent *e);
123  private slots:
124 
125  public slots:
126  void itemValueChanged(QString name, QString value, int action, bool apply);
127  //#dk virtual void paintEvent ( QPaintEvent * event );
128  void adjustHeight();
129 
130  virtual void changeOptions(casacore::Record changedOptions);
131  //# dk note to hye:
132  //#
133  //# This slot needs to be implemented to handle changes
134  //# requested by the C++ library to current values, allowed data
135  //# range('pmin, pmax') and display
136  //# label ('listname'), as appropriate, for any existing options.
137  //#
138  //# It would be useful to allow changes to slider increment
139  //# ('presolution'), available choices ('popt') and the default
140  //# value as well. Also, it would be useful to support
141  //# (new) boolean subfields 'enabled' and 'visible'. These
142  //# features can be postponed, if necessary, though, and we will not
143  //# need to support changes to some of the fields sent in these
144  //# records from the library (such as help, editable, dlformat...).
145  //#
146  //# If you're really ambitious, you could try supporting addition of
147  //# new option entries, too.
148  //#
149  //# the 'modifygui' method in autogui.g is the glish equivalent
150  //# of what we're trying to do here, although modifygui itself is
151  //# rather incomplete.
152 
153 
154  // (called only once, during or soon after construction. Sets up contents of
155  // the gui from rec).
156 
157  void autoApplyState( bool auto_apply ) {
158  auto_apply_ = auto_apply;
159  }
160 
161  protected:
163 
164  private:
165  QDomDocument m_doc;
166  QString m_file_name;
167  QString m_data_type;
168  QWidget *contents_;
169  QVBoxLayout *contentsLayout_;
170  QVBoxLayout *vboxLayout;
171  //#dk QFrame *line;
172  QSpacerItem *spacerItem;
173  //QScrollArea *scrollArea;
174 
176  QString m_lockItem;
177  QMutex mutex;
178  void initialize();
179 
180  };
181 
182 } //# NAMESPACE CASA - END
183 
184 #endif
QDomDocument m_doc
Definition: QtAutoGui.qo.h:165
void loadRecord(casacore::Record rec)
call once only during initialization, to populate the gui, if you used the QtAutoGui(QWidget=0) const...
void contextMenuEvent(QContextMenuEvent *e)
QWidget * contents_
Definition: QtAutoGui.qo.h:168
static const QString HISTOGRAM_RANGE_KEY
Definition: QtAutoGui.qo.h:94
void itemValueChanged(QString name, QString value, int action, bool apply)
QString m_file_name
Definition: QtAutoGui.qo.h:166
void setOptions(casacore::Record options)
QtAutoGui(QWidget *parent=0)
QString m_data_type
Definition: QtAutoGui.qo.h:167
bool recordLoaded_
QScrollArea *scrollArea;.
Definition: QtAutoGui.qo.h:175
void autoApplyState(bool auto_apply)
(called only once, during or soon after construction.
Definition: QtAutoGui.qo.h:157
General-purpose Qt options widget created from Record.
Definition: QtAutoGui.qo.h:66
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
QString m_lockItem
Definition: QtAutoGui.qo.h:176
virtual void changeOptions(casacore::Record changedOptions)
void setDataType(const QString &dType)
Options options
QSpacerItem * spacerItem
Definition: QtAutoGui.qo.h:172
QVBoxLayout * contentsLayout_
Definition: QtAutoGui.qo.h:169
QVBoxLayout * vboxLayout
Definition: QtAutoGui.qo.h:170
A hierarchical collection of named fields of various types.
Definition: Record.h:180
QString fileName() const
QString dataType() const
const Double e
e and functions thereof:
String: the storage and methods of handling collections of characters.
Definition: String.h:223
static const QString HISTOGRAM_SHOW_KEY
Definition: QtAutoGui.qo.h:93
void setFileName(const QString &file_name)
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.