casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtViewerBase.qo.h
Go to the documentation of this file.
1 //# QtViewerBase.qo.h: Qt implementation of main viewer supervisory object.
2 //# -- casacore::Functional level.
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 QTVIEWERBASE_H
30 #define QTVIEWERBASE_H
31 
32 #include <casa/aips.h>
33 #include <list>
35 #include <casa/Arrays/Vector.h>
36 
37 #include <graphics/X11/X_enter.h>
38 # include <QObject>
39 # include <QtXml/QDomDocument>
40 #include <graphics/X11/X_exit.h>
41 
42 
43 // <summary>
44 // Qt implementation of main viewer supervisory object -- casacore::Functional level.
45 // </summary>
46 
47 // <synopsis>
48 // The viewer is structured with a functional layer and a gui layer.
49 // In principle the former can operate without the latter. This class
50 // manages functional objects associated with the viewer, in particular
51 // the list of user-created DDs.
52 // </synopsis>
53 
54 namespace casacore{
55 
56  class String;
57 }
58 
59 namespace casa { //# NAMESPACE CASA - BEGIN
60 
61  class QtDisplayData;
62  class QtDisplayPanel;
63  class QtDisplayPanelGui;
64 
65  class QtViewerBase : public QObject {
66 
67  Q_OBJECT //# Allows slot/signal definition. Must only occur in
68  //# implement/.../*.h files; also, makefile must include
69  //# name of this file in 'mocs' section.
70 
71  public:
72 
73  QtViewerBase( bool is_server=false );
74  ~QtViewerBase();
75 
76  bool server( ) const {
77  return server_;
78  }
79 
80  // Return the common QtMouseToolState that all mouse tool users
81  // should share.
83  return &msbtns_;
84  }
85  virtual const QtMouseToolState* mouseBtns() const {
86  return &msbtns_;
87  }
88 
89  // The list of QtDisplayPanels that are not closed.
90  virtual std::list<QtDisplayPanelGui*> openDPs();
91 
92  // The number of open QtDisplayPanels. (More efficient than the
93  // equivalent openDPs().len(), if the number is all that's needed).
94  virtual int nOpenDPs();
95 
96  // Only to be used by QtDisplayPanels, to inform this class of
97  // their creation. (C++ should allow individual methods to be
98  // 'friend'ed to outside classes...).
99  virtual void dpCreated( QtDisplayPanelGui *newDP, QtDisplayPanel *panel );
100 
101  // function to aid typing files of interest to the viewer.
102  // Moved from QtDataManager to be available for non-gui use.
103  // Returns user interface Strings like "Measurement Set".
104  static casacore::String fileType(const casacore::String pathname);
105 
106  // similar to above; returns internal DD datatype names like "ms"
107  // (or else 'nonexistent', 'unknown').
108  static casacore::String filetype(const casacore::String pathname);
109 
110  // Does the given file pathname hold a readable file with valid ID and
111  // form as a viewer restore xml document? (If so, contents are set
112  // onto restoredoc).
113  static bool isRestoreFile(casacore::String filename, QDomDocument& restoredoc);
114 
115  // Does the given casacore::String have valid ID and form as viewer restore xml?
116  // (If so, contents are set onto restoredoc).
117  static bool isRestoreString(casacore::String xmlState, QDomDocument& restoredoc);
118 
119  static const casacore::String cvRestoreID; //# internal identifier,
120  static const casacore::String cvRestoreFileExt; //# default file extension,
121  //# for save-restore
122 
123  // Utility routines to convert between casacore::Vector<float> and String.
124  //<group>
126  static casacore::Vector<float> toVectorF(casacore::String values, bool* ok=0);
128  static casacore::Vector<double> toVectorD(casacore::String values, bool* ok=0);
129  //</group>
130 
131 
132  // Returns true iff datatype is a vaild viewer datatype and
133  // displaytype is valid for the datatype. If the former is true
134  // but the latter isn't, displaytype is [re]set to the default
135  // displaytype for the datatype.
136  bool dataDisplaysAs(casacore::String datatype, casacore::String& displaytype);
137 
138  // public (const) data.
139 
140  // viewer datatypess.
141  static const int IMAGE=1, MEASUREMENT_SET=2, SKY_CATALOG=3,
142  RESTORE=4, LEL=5, N_DT=5;
143 
144  // viewer displaytypes.
145  static const int RASTER=1, CONTOUR=2, VECTOR=3, MARKER=4,
147 
148  // (for invalid datatype or displaytype).
149  static const int INVALID=0;
150 
151 
152  bool exiting( ) {
153  return qtviewer_app_exit;
154  }
155 
156  public slots:
157 
158  // Hold/release of (canvas-draw) refresh of all QDPs. (NB: does not
159  // concern enabling of Qt Widgets). Call to hold() must be matched to
160  // later call of release(); they can be nested. It is sometimes
161  // efficient to wait until several changes are complete and then
162  // redraw everything just once.
163  //<group>
164  virtual void hold();
165  virtual void release();
166  //</group>
167 
168  // Closes all open panels, which will exit the Qt loop. Note that the
169  // loop can be restarted (and is, in interactive clean, e.g.), with
170  // existing widgets intact. This does not in itself delete objects
171  // or exit the process, although the driver program might do that.
172  // Also, some of the panels may have WA_DeleteOnClose set, which
173  // would cause their deletion (see, e.g., QtViewer::createDPG()).
174  virtual void quit();
175 
176  protected slots:
177 
178  // Connected by this class, (only) to QDPs' destroyed() signals
179  // (for maintenance of the list of existing QDPs).
180  virtual void dpDestroyed_(QObject*);
181 
182  // Connected by this class, (only) to QDPs' dpHidden() signals
183  // (for checking on open QDPs -- will quit if none are left open).
184  virtual void dpHidden_(QtDisplayPanel*);
185 
186 
187 
188  protected:
189 
190  bool server_;
191 
192  // Existing QtDisplayPanels (whether 'closed' or not, as long as
193  // not deleted). Unlike QDDs, QtViewerBase does not create or delete
194  // QDPs, it just tries to keep track of them. Note that by default,
195  // 'closed' DPs are simply not 'visible' (see QWidget::isVisible()), though
196  // they are not deleted unless their owner does it. An owner can also
197  // revive (show) a 'closed' QDP. The publicly-available list openDPs()
198  // shows only those which are not closed. Minimized or covered
199  // DPs are still considered 'open'.
200  std::list<QtDisplayPanelGui*> qdps_;
201 
202 
203  // This should be the only place this object is ever created....
204  // Holds mouse button assignment for the mouse tools, which is to
205  // be the same on all mouse toolbars / display panels.
207 
208  // Translates IMAGE, RASTER, etc. into the names used internally
209  // (e.g. "image", "raster").
211 
212  // e.g. dataDisplaysAs_[IMAGE] will be {RASTER, CONTOUR, VECTOR, MARKER}
213  // dataDisplaysAs_[datatype][0] will be the default displaytype for
214  // that datatype.
216 
217  private:
218  static bool qtviewer_app_exit;
219 
220  };
221 
222 
223 
224 } //# NAMESPACE CASA - END
225 
226 #endif
static const int SKY_CAT
static const int LEL
virtual const QtMouseToolState * mouseBtns() const
static const int RASTER
viewer displaytypes.
static const int N_DS
std::list< QtDisplayPanelGui * > qdps_
Existing QtDisplayPanels (whether &#39;closed&#39; or not, as long as not deleted).
static const casacore::String cvRestoreID
QtMouseToolState msbtns_
This should be the only place this object is ever created....
virtual void hold()
Hold/release of (canvas-draw) refresh of all QDPs.
static bool isRestoreString(casacore::String xmlState, QDomDocument &restoredoc)
Does the given casacore::String have valid ID and form as viewer restore xml? (If so...
static casacore::Vector< float > toVectorF(casacore::String values, bool *ok=0)
static const int SKY_CATALOG
casacore::Vector< casacore::String > datatypeNames_
Translates IMAGE, RASTER, etc.
static casacore::String toString(casacore::Vector< float > values)
Utility routines to convert between casacore::Vector&lt;float&gt; and String.
virtual QtMouseToolState * mouseBtns()
Return the common QtMouseToolState that all mouse tool users should share.
static const int MEASUREMENT_SET
static casacore::String fileType(const casacore::String pathname)
function to aid typing files of interest to the viewer.
bool dataDisplaysAs(casacore::String datatype, casacore::String &displaytype)
Returns true iff datatype is a vaild viewer datatype and displaytype is valid for the datatype...
static bool isRestoreFile(casacore::String filename, QDomDocument &restoredoc)
Does the given file pathname hold a readable file with valid ID and form as a viewer restore xml docu...
static const int INVALID
(for invalid datatype or displaytype).
casacore::Vector< casacore::Vector< int > > dataDisplaysAs_
e.g.
static const int MARKER
static const int IMAGE
public (const) data.
virtual int nOpenDPs()
The number of open QtDisplayPanels.
virtual void quit()
Closes all open panels, which will exit the Qt loop.
QtViewerBase(bool is_server=false)
virtual void dpDestroyed_(QObject *)
Connected by this class, (only) to QDPs&#39; destroyed() signals (for maintenance of the list of existing...
virtual void dpCreated(QtDisplayPanelGui *newDP, QtDisplayPanel *panel)
Only to be used by QtDisplayPanels, to inform this class of their creation.
The main display window for the Qt version of the viewer.
static casacore::Vector< double > toVectorD(casacore::String values, bool *ok=0)
static const int NEWPANEL
virtual std::list< QtDisplayPanelGui * > openDPs()
The list of QtDisplayPanels that are not closed.
bool server() const
static const int N_DT
static const int VECTOR
static casacore::String filetype(const casacore::String pathname)
similar to above; returns internal DD datatype names like &quot;ms&quot; (or else &#39;nonexistent&#39;, &#39;unknown&#39;).
virtual void release()
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual void dpHidden_(QtDisplayPanel *)
Connected by this class, (only) to QDPs&#39; dpHidden() signals (for checking on open QDPs – will quit if...
static bool qtviewer_app_exit
static const int RESTORE
casacore::Vector< casacore::String > displaytypeNames_
static const casacore::String cvRestoreFileExt
static const int OLDPANEL
static const int CONTOUR
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42