QtViewerBase.qo.h

Go to the documentation of this file.
00001 //# QtViewerBase.qo.h: Qt implementation of main viewer supervisory object.
00002 //#                 -- Functional level.
00003 //# Copyright (C) 2005
00004 //# Associated Universities, Inc. Washington DC, USA.
00005 //#
00006 //# This library is free software; you can redistribute it and/or modify it
00007 //# under the terms of the GNU Library General Public License as published by
00008 //# the Free Software Foundation; either version 2 of the License, or (at your
00009 //# option) any later version.
00010 //#
00011 //# This library is distributed in the hope that it will be useful, but WITHOUT
00012 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014 //# License for more details.
00015 //#
00016 //# You should have received a copy of the GNU Library General Public License
00017 //# along with this library; if not, write to the Free Software Foundation,
00018 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00019 //#
00020 //# Correspondence concerning AIPS++ should be addressed as follows:
00021 //#        Internet email: aips2-request@nrao.edu.
00022 //#        Postal address: AIPS++ Project Office
00023 //#                        National Radio Astronomy Observatory
00024 //#                        520 Edgemont Road
00025 //#                        Charlottesville, VA 22903-2475 USA
00026 //#
00027 //# $Id$
00028 
00029 #ifndef QTVIEWERBASE_H
00030 #define QTVIEWERBASE_H
00031 
00032 #include <casa/aips.h>
00033 #include <casa/Containers/List.h>
00034 #include <display/QtViewer/QtMouseToolState.qo.h>
00035 #include <casa/Arrays/Vector.h>
00036 
00037 #include <graphics/X11/X_enter.h>
00038 #  include <QObject>
00039 #  include <QtXml/QDomDocument>
00040 #include <graphics/X11/X_exit.h>
00041 
00042 
00043 // <summary>
00044 // Qt implementation of main viewer supervisory object -- Functional level.
00045 // </summary>
00046 
00047 // <synopsis>
00048 // The viewer is structured with a functional layer and a gui layer.
00049 // In principle the former can operate without the latter.  This class
00050 // manages functional objects associated with the viewer, in particular
00051 // the list of user-created DDs.
00052 // </synopsis>
00053 
00054 namespace casa { //# NAMESPACE CASA - BEGIN
00055 
00056         class String;
00057         class QtDisplayData;
00058         class QtDisplayPanel;
00059         class QtDisplayPanelGui;
00060 
00061         class QtViewerBase : public QObject {
00062 
00063                 Q_OBJECT        //# Allows slot/signal definition.  Must only occur in
00064                 //# implement/.../*.h files; also, makefile must include
00065                 //# name of this file in 'mocs' section.
00066 
00067         public:
00068 
00069                 QtViewerBase( bool is_server=false );
00070                 ~QtViewerBase();
00071 
00072                 bool server( ) const {
00073                         return server_;
00074                 }
00075 
00076                 // Return the common QtMouseToolState that all mouse tool users
00077                 // should share.
00078                 virtual QtMouseToolState* mouseBtns() {
00079                         return &msbtns_;
00080                 }
00081                 virtual const QtMouseToolState* mouseBtns() const {
00082                         return &msbtns_;
00083                 }
00084 
00085                 // The list of QtDisplayPanels that are not closed.
00086                 virtual std::list<QtDisplayPanelGui*> openDPs();
00087 
00088                 // The number of open QtDisplayPanels.  (More efficient than the
00089                 // equivalent openDPs().len(), if the number is all that's needed).
00090                 virtual Int nOpenDPs();
00091 
00092                 // Only to be used by QtDisplayPanels, to inform this class of
00093                 // their creation.  (C++ should allow individual methods to be
00094                 // 'friend'ed to outside classes...).
00095                 virtual void dpCreated( QtDisplayPanelGui *newDP, QtDisplayPanel *panel );
00096 
00097                 // function to aid typing files of interest to the viewer.
00098                 // Moved from QtDataManager to be available for non-gui use.
00099                 // Returns user interface Strings like "Measurement Set".
00100                 static String fileType(const String pathname);
00101 
00102                 // similar to above; returns internal DD datatype names like "ms"
00103                 // (or else 'nonexistent', 'unknown').
00104                 static String filetype(const String pathname);
00105 
00106                 // Does the given file pathname hold a readable file with valid ID and
00107                 // form as a viewer restore xml document?  (If so, contents are set
00108                 // onto restoredoc).
00109                 static Bool isRestoreFile(String filename, QDomDocument& restoredoc);
00110 
00111                 // Does the given String have valid ID and form as viewer restore xml?
00112                 // (If so, contents are set onto restoredoc).
00113                 static Bool isRestoreString(String xmlState, QDomDocument& restoredoc);
00114 
00115                 static const String cvRestoreID;                //# internal identifier,
00116                 static const String cvRestoreFileExt;           //# default file extension,
00117                 //# for save-restore
00118 
00119                 // Utility routines to convert between Vector<Float> and String.
00120                 //<group>
00121                 static String toString(Vector<Float> values);
00122                 static Vector<Float> toVectorF(String values, Bool* ok=0);
00123                 static String toString(Vector<Double> values);
00124                 static Vector<Double> toVectorD(String values, Bool* ok=0);
00125                 //</group>
00126 
00127 
00128                 // Returns True iff datatype is a vaild viewer datatype and
00129                 // displaytype is valid for the datatype.  If the former is true
00130                 // but the latter isn't, displaytype is [re]set to the default
00131                 // displaytype for the datatype.
00132                 Bool dataDisplaysAs(String datatype, String& displaytype);
00133 
00134                 // public (const) data.
00135 
00136                 // viewer datatypess.
00137                 static const Int IMAGE=1, MEASUREMENT_SET=2, SKY_CATALOG=3,
00138                                  RESTORE=4, LEL=5,                           N_DT=5;
00139 
00140                 // viewer displaytypes.
00141                 static const Int RASTER=1, CONTOUR=2, VECTOR=3, MARKER=4,
00142                                  SKY_CAT=5, OLDPANEL=6, NEWPANEL=7,          N_DS=7;
00143 
00144                 // (for invalid datatype or displaytype).
00145                 static const Int INVALID=0;
00146 
00147 
00148                 bool exiting( ) {
00149                         return qtviewer_app_exit;
00150                 }
00151 
00152         public slots:
00153 
00154                 // Hold/release of (canvas-draw) refresh of all QDPs.  (NB: does not
00155                 // concern enabling of Qt Widgets).  Call to hold() must be matched to
00156                 // later call of release(); they can be nested.  It is sometimes
00157                 // efficient to wait until several changes are complete and then
00158                 // redraw everything just once.
00159                 //<group>
00160                 virtual void hold();
00161                 virtual void release();
00162                 //</group>
00163 
00164                 // Closes all open panels, which will exit the Qt loop.  Note that the
00165                 // loop can be restarted (and is, in interactive clean, e.g.), with
00166                 // existing widgets intact.  This does not in itself delete objects
00167                 // or exit the process, although the driver program might do that.
00168                 // Also, some of the panels may have WA_DeleteOnClose set, which
00169                 // would cause their deletion (see, e.g., QtViewer::createDPG()).
00170                 virtual void quit();
00171 
00172         protected slots:
00173 
00174                 // Connected by this class, (only) to QDPs' destroyed() signals
00175                 // (for maintenance of the list of existing QDPs).
00176                 virtual void dpDestroyed_(QObject*);
00177 
00178                 // Connected by this class, (only) to QDPs' dpHidden() signals
00179                 // (for checking on open QDPs -- will quit if none are left open).
00180                 virtual void dpHidden_(QtDisplayPanel*);
00181 
00182 
00183 
00184         protected:
00185 
00186                 bool server_;
00187 
00188                 // Existing QtDisplayPanels (whether 'closed' or not, as long as
00189                 // not deleted).  Unlike QDDs, QtViewerBase does not create or delete
00190                 // QDPs, it just tries to keep track of them.  Note that by default,
00191                 // 'closed' DPs are simply not 'visible' (see QWidget::isVisible()), though
00192                 // they are not deleted unless their owner does it.  An owner can also
00193                 // revive (show) a 'closed' QDP.  The publicly-available list openDPs()
00194                 // shows only those which are not closed.  Minimized or covered
00195                 // DPs are still considered 'open'.
00196                 std::list<QtDisplayPanelGui*> qdps_;
00197 
00198 
00199                 // This should be the only place this object is ever created....
00200                 // Holds mouse button assignment for the mouse tools, which is to
00201                 // be the same on all mouse toolbars / display panels.
00202                 QtMouseToolState msbtns_;
00203 
00204                 // Translates IMAGE, RASTER, etc. into the names used internally
00205                 // (e.g. "image", "raster").
00206                 Vector<String> datatypeNames_, displaytypeNames_;
00207 
00208                 // e.g. dataDisplaysAs_[IMAGE] will be {RASTER, CONTOUR, VECTOR, MARKER}
00209                 // dataDisplaysAs_[datatype][0] will be the default displaytype for
00210                 // that datatype.
00211                 Vector<Vector<Int> > dataDisplaysAs_;
00212 
00213         private:
00214                 static bool qtviewer_app_exit;
00215 
00216         };
00217 
00218 
00219 
00220 } //# NAMESPACE CASA - END
00221 
00222 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1