casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QtMouseTools.qo.h
Go to the documentation of this file.
00001 //# QtMouseTools.qo.h: Qt versions of display library mouse tools.
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 
00028 
00029 #ifndef QTMOUSETOOLS_H
00030 #define QTMOUSETOOLS_H
00031 
00032 #include <casa/aips.h>
00033 #include <display/DisplayEvents/MultiRectToolImpl.h>
00034 #include <display/DisplayEvents/MultiEllipseToolImpl.h>
00035 #include <display/DisplayEvents/MultiPointToolImpl.h>
00036 #include <display/DisplayEvents/MultiPolyToolImpl.h>
00037 #include <display/DisplayEvents/MultiPolylineToolImpl.h>
00038 #include <display/DisplayEvents/MultiPVToolImpl.h>
00039 #include <display/DisplayEvents/MWCETRegion.h>
00040 #include <display/Display/PanelDisplay.h>
00041 #include <casa/Containers/Record.h>
00042 
00043 #include <graphics/X11/X_enter.h>
00044 #  include <QObject>
00045 #include <graphics/X11/X_exit.h>
00046 
00047 namespace casa {
00048 
00049 
00050 
00051 // <synopsis>
00052 // Nothing yet: it may prove useful for Qt-signal-emitting mouse tools
00053 // (which are MWCTools or possibly PCTools) to have a common base.
00054 // </synopsis>
00055 class QtMouseTool: public QObject {
00056 
00057   Q_OBJECT      //# Allows slot/signal definition.  Must only occur in
00058                 //# implement/.../*.h files; also, makefile must include
00059                 //# name of this file in 'mocs' section.
00060   
00061  public: 
00062  
00063   QtMouseTool() : QObject() {  }
00064   ~QtMouseTool() {  }
00065 
00066 }; 
00067 
00068 
00069 
00070 
00071 // <synopsis>
00072 // QtRTRegion is the Rectangle Region mouse tool that sends a signal
00073 // when a new rectangle is ready.
00074 // </synopsis>
00075 class QtRTRegion: public QtMouseTool, public MultiRectToolImpl {
00076   
00077   Q_OBJECT      //# Allows slot/signal definition.  Must only occur in
00078                 //# implement/.../*.h files; also, makefile must include
00079                 //# name of this file in 'mocs' section.
00080 
00081  public: 
00082  
00083   QtRTRegion(viewer::RegionSourceFactory *rf, PanelDisplay* pd) : QtMouseTool(), MultiRectToolImpl(rf, pd), pd_(pd) {  }
00084   
00085   ~QtRTRegion() {  }
00086   
00087   // Retrieve the current rectangular mouse region record and WCH, if any.
00088   // (If nothing is ready, returns False -- be sure to check before using
00089   // return parameters.  See implementation for mouseRegion Record format).
00090   Bool getMouseRegion(Record& mouseRegion, WorldCanvasHolder*& wch);
00091 
00092  signals:
00093  
00094   // See regionReady() implementation for format of the record.  (For some
00095   // uses, a connecting slot may be able to do without the WCH* parameter).
00096   void mouseRegionReady(Record mouseRegion, WorldCanvasHolder*);
00097   void echoClicked(Record);
00098 
00099  protected:
00100   
00101   // Signals mouseRegionReady with an appropriate Record, when
00102   // called by base class in response to user selection with the mouse.
00103   // See implementation for format of the record.
00104   virtual void regionReady();
00105 
00106   virtual void clicked(Int x, Int y); 
00107   virtual void doubleClicked(Int x, Int y); 
00108   //virtual void rectangleReady(); 
00109   //virtual void handleEvent(DisplayEvent& ev);
00110   //virtual void keyPressed(const WCPositionEvent &ev);
00111   
00112   PanelDisplay* pd_;    // (Kludge... zIndex inaccessible from WC...)
00113 
00114 };
00115 
00116 
00117 // <synopsis>
00118 // QtPTRegion is the Rectangle Region mouse tool that sends a signal
00119 // when a new rectangle is ready.
00120 // </synopsis>
00121 class QtPointRegion: public QtMouseTool, public MultiPointToolImpl {
00122   
00123   Q_OBJECT      //# Allows slot/signal definition.  Must only occur in
00124                 //# implement/.../*.h files; also, makefile must include
00125                 //# name of this file in 'mocs' section.
00126 
00127  public: 
00128  
00129   QtPointRegion(viewer::RegionSourceFactory *rf, PanelDisplay* pd) : QtMouseTool(), MultiPointToolImpl(rf, pd), pd_(pd) {  }
00130   
00131   ~QtPointRegion() {  }
00132   
00133   // Retrieve the current rectangular mouse region record and WCH, if any.
00134   // (If nothing is ready, returns False -- be sure to check before using
00135   // return parameters.  See implementation for mouseRegion Record format).
00136   Bool getMouseRegion(Record& mouseRegion, WorldCanvasHolder*& wch);
00137 
00138  signals:
00139  
00140   // See regionReady() implementation for format of the record.  (For some
00141   // uses, a connecting slot may be able to do without the WCH* parameter).
00142   void mouseRegionReady(Record mouseRegion, WorldCanvasHolder*);
00143   void echoClicked(Record);
00144 
00145  protected:
00146   
00147   // Signals mouseRegionReady with an appropriate Record, when
00148   // called by base class in response to user selection with the mouse.
00149   // See implementation for format of the record.
00150   virtual void regionReady();
00151 
00152   virtual void clicked(Int x, Int y); 
00153   virtual void doubleClicked(Int x, Int y); 
00154   //virtual void rectangleReady(); 
00155   //virtual void handleEvent(DisplayEvent& ev);
00156   //virtual void keyPressed(const WCPositionEvent &ev);
00157   
00158   PanelDisplay* pd_;    // (Kludge... zIndex inaccessible from WC...)
00159 
00160 };
00161 
00162 
00163 // <synopsis>
00164 // QtELRegion is the Ellipse Region mouse tool that sends a signal
00165 // when a new circle is ready.
00166 // </synopsis>
00167 class QtELRegion: public QtMouseTool, public MultiEllipseToolImpl {
00168 
00169   Q_OBJECT      //# Allows slot/signal definition.  Must only occur in
00170                 //# implement/.../*.h files; also, makefile must include
00171                 //# name of this file in 'mocs' section.
00172 
00173  public:
00174 
00175   QtELRegion(viewer::RegionSourceFactory *rf, PanelDisplay* pd) : QtMouseTool(), MultiEllipseToolImpl(rf, pd), pd_(pd) {  }
00176 
00177   ~QtELRegion() {  }
00178 
00179   // Retrieve the current circular mouse region record and WCH, if any.
00180   // (If nothing is ready, returns False -- be sure to check before using
00181   // return parameters.  See implementation for mouseRegion Record format).
00182   Bool getMouseRegion(Record& mouseRegion, WorldCanvasHolder*& wch);
00183 
00184  signals:
00185 
00186   // See regionReady() implementation for format of the record.  (For some
00187   // uses, a connecting slot may be able to do without the WCH* parameter).
00188   void mouseRegionReady(Record mouseRegion, WorldCanvasHolder*);
00189   void echoClicked(Record);
00190 
00191  protected:
00192 
00193   // Signals mouseRegionReady with an appropriate Record, when
00194   // called by base class in response to user selection with the mouse.
00195   // See implementation for format of the record.
00196   virtual void regionReady();
00197 
00198   virtual void clicked(Int x, Int y);
00199   virtual void doubleClicked(Int x, Int y);
00200 
00201   PanelDisplay* pd_;    // (Kludge... zIndex inaccessible from WC...)
00202 
00203 };
00204 
00205 
00206 // <synopsis>
00207 // QtPTRegion is the Polygon Region mouse tool that sends a signal
00208 // when a new polygon is ready.
00209 // </synopsis>
00210 class QtPTRegion: public QtMouseTool, public MultiPolyToolImpl {
00211   
00212   Q_OBJECT      //# Allows slot/signal definition.  Must only occur in
00213                 //# implement/.../*.h files; also, makefile must include
00214                 //# name of this file in 'mocs' section.
00215 
00216  public: 
00217  
00218   QtPTRegion(viewer::RegionSourceFactory *rf, PanelDisplay* pd) : QtMouseTool(), MultiPolyToolImpl(rf, pd), pd_(pd) {  }
00219   
00220   ~QtPTRegion() {  }
00221   
00222   // Retrieve the current polygon mouse region record and WCH, if any.
00223   // (If nothing is ready, returns False -- be sure to check before using
00224   // return parameters.  See implementation for mouseRegion Record format).
00225   Bool getMouseRegion(Record& mouseRegion, WorldCanvasHolder*& wch);
00226 
00227  signals:
00228  
00229   // See regionReady() implementation for format of the record.  (For some
00230   // uses, a connecting slot may be able to do without the WCH* parameter).
00231   void mouseRegionReady(Record mouseRegion, WorldCanvasHolder*);
00232   void echoClicked(Record);
00233 
00234  protected:
00235   
00236   // This callback is invoked by the base when the user double-clicks
00237   // inside a polygon defined previously (but see also polygonReady(),
00238   // below).  This implementation emits the Qt signal mouseRegionReady()
00239   // with an appropriate Record defining the user's polygon mouse selection.
00240   // See implementation for format of the record.
00241   virtual void regionReady();
00242   virtual void clicked(Int x, Int y);
00243   virtual void doubleClicked(Int x, Int y); 
00244 
00245   //virtual void handleEvent(DisplayEvent& ev);
00246   //virtual void keyPressed(const WCPositionEvent &ev);
00247   
00249   //
00250   // This callback is invoked by the base when the polygon is first
00251   // defined (by a double-click at last point) or when the mouse is
00252   // released after a move/resize.  It was unused in glish.  For Qt,
00253   // this will also signal that the polygon region has been fully
00254   // 'selected/made ready' (which will preclude the need for the
00255   // user to double-click [again] inside the polygon to select it). 
00256   //virtual void polygonReady() { regionReady();  }
00257 
00258   // is this fix to 1393?
00259   virtual void polygonReady() { }
00260 
00261   PanelDisplay* pd_;    // (Kludge... zIndex inaccessible from WC...)
00262 
00263 };
00264 
00265 // <synopsis>
00266 // QtPolylineToolRegion is the Polyline Region mouse tool that sends a signal
00267 // when a new polyline is ready.
00268 // </synopsis>
00269 class QtPolylineToolRegion: public QtMouseTool, public MultiPolylineToolImpl {
00270 
00271   Q_OBJECT
00272 
00273  public:
00274 
00275   QtPolylineToolRegion(viewer::RegionSourceFactory *rf, PanelDisplay* pd) :
00276           QtMouseTool(), MultiPolylineToolImpl(rf, pd), pd_(pd) {  }
00277 
00278   ~QtPolylineToolRegion() {  }
00279 
00280   // Retrieve the current polyline mouse region record and WCH, if any.
00281   // (If nothing is ready, returns False -- be sure to check before using
00282   // return parameters.  See implementation for mouseRegion Record format).
00283   Bool getMouseRegion(Record& mouseRegion, WorldCanvasHolder*& wch);
00284 
00285  signals:
00286 
00287   // See regionReady() implementation for format of the record.  (For some
00288   // uses, a connecting slot may be able to do without the WCH* parameter).
00289   void mouseRegionReady(Record mouseRegion, WorldCanvasHolder*);
00290   void echoClicked(Record);
00291 
00292  protected:
00293 
00294   // This callback is invoked by the base when the user double-clicks
00295   // inside a polygon defined previously (but see also polygonReady(),
00296   // below).  This implementation emits the Qt signal mouseRegionReady()
00297   // with an appropriate Record defining the user's polygon mouse selection.
00298   // See implementation for format of the record.
00299   virtual void regionReady();
00300   virtual void clicked(Int x, Int y);
00301   virtual void doubleClicked(Int x, Int y);
00302 
00303 
00304 
00306   //
00307   // This callback is invoked by the base when the polygon is first
00308   // defined (by a double-click at last point) or when the mouse is
00309   // released after a move/resize.  It was unused in glish.  For Qt,
00310   // this will also signal that the polygon region has been fully
00311   // 'selected/made ready' (which will preclude the need for the
00312   // user to double-click [again] inside the polygon to select it).
00313   //virtual void polygonReady() { regionReady();  }
00314 
00315   // is this fix to 1393?
00316   virtual void polylineReady() { }
00317 
00318   PanelDisplay* pd_;    // (Kludge... zIndex inaccessible from WC...)
00319 
00320 };
00321 
00322 // <synopsis>
00323 // QtPVToolRegion is the Polygon Region mouse tool that sends a signal
00324 // when a new polygon is ready.
00325 // </synopsis>
00326 class QtPVToolRegion: public QtMouseTool, public MultiPVToolImpl {
00327   
00328   Q_OBJECT      //# Allows slot/signal definition.  Must only occur in
00329                 //# implement/.../*.h files; also, makefile must include
00330                 //# name of this file in 'mocs' section.
00331 
00332  public: 
00333  
00334   QtPVToolRegion(viewer::RegionSourceFactory *rf, PanelDisplay* pd) : QtMouseTool(), MultiPVToolImpl(rf, pd), pd_(pd) {  }
00335   
00336   ~QtPVToolRegion() {  }
00337   
00338   // Retrieve the current polygon mouse region record and WCH, if any.
00339   // (If nothing is ready, returns False -- be sure to check before using
00340   // return parameters.  See implementation for mouseRegion Record format).
00341   Bool getMouseRegion(Record& mouseRegion, WorldCanvasHolder*& wch);
00342 
00343  signals:
00344  
00345   // See regionReady() implementation for format of the record.  (For some
00346   // uses, a connecting slot may be able to do without the WCH* parameter).
00347   void mouseRegionReady(Record mouseRegion, WorldCanvasHolder*);
00348   void echoClicked(Record);
00349 
00350  protected:
00351   
00352   // This callback is invoked by the base when the user double-clicks
00353   // inside a polygon defined previously (but see also polygonReady(),
00354   // below).  This implementation emits the Qt signal mouseRegionReady()
00355   // with an appropriate Record defining the user's polygon mouse selection.
00356   // See implementation for format of the record.
00357   virtual void regionReady();
00358   virtual void clicked(Int x, Int y);
00359   virtual void doubleClicked(Int x, Int y); 
00360 
00361   //virtual void handleEvent(DisplayEvent& ev);
00362   //virtual void keyPressed(const WCPositionEvent &ev);
00363   
00364   PanelDisplay* pd_;    // (Kludge... zIndex inaccessible from WC...)
00365 
00366 };
00367 
00368 
00369 } //# NAMESPACE CASA - END
00370 
00371 #endif
00372