RegionSource.h

Go to the documentation of this file.
00001 //# regionsource.h: regionsource producing persistent regions used within the casa viewer
00002 //# Copyright (C) 2011
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 REGION_REGIONSOURCE_H_
00030 #define REGION_REGIONSOURCE_H_
00031 #include <list>
00032 #include <casa/Utilities/CountedPtr.h>
00033 #include <display/region/RegionCreator.h>
00034 #include <display/Utilities/dtor.h>
00035 #include <display/Display/MouseToolState.h>
00036 
00037 namespace casa {
00038 
00039         class WorldCanvas;
00040 
00041         namespace viewer {
00042 
00043                 class Rectangle;
00044                 class Polygon;
00045                 class Polyline;
00046                 class Ellipse;
00047                 class PVLine;
00048 
00049                 class QtRegionDock;
00050                 class RegionSource;
00051                 class RegionCreator;
00052 
00053                 class RegionSourceKernel : public dtorNotifiee {
00054                 public:
00055                         typedef SHARED_PTR<RegionSourceKernel> shared_kernel_ptr_type;
00056 
00057                         RegionSourceKernel( ) { }
00058                         virtual ~RegionSourceKernel( );
00059 
00060                         // inherited pure-virtual from dtorNotifiee, removes deleted regions...
00061                         void dtorCalled( const dtorNotifier * );
00062 
00063                         // re-generate regionUpdateResponse( ) signals for existing regions...
00064                         // with *same* arguments as regionCreated( ), for the benefit of a newly created (e.g. QtProfile) tool...
00065                         virtual void generateExistingRegionUpdates( );
00066 
00067                         virtual QtRegionDock *dock( ) {
00068                                 return 0;
00069                         }
00070                         virtual int numFrames( ) const {
00071                                 return -1;
00072                         }
00073 
00074                         virtual void revokeRegion( Region *r ) = 0;
00075 
00076                 protected:
00077                         friend class RegionSource;
00078                         virtual SHARED_PTR<Rectangle> rectangle( RegionCreator *rc, WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ) = 0;
00079                         virtual SHARED_PTR<Polygon> polygon( RegionCreator *rc, WorldCanvas *wc, double x1, double y1 ) = 0;
00080                         virtual SHARED_PTR<Polygon> polygon( RegionCreator *rc, WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts ) = 0;
00081                         virtual SHARED_PTR<Polyline> polyline( RegionCreator *rc, WorldCanvas *wc, double x1, double y1 ) = 0;
00082                         virtual SHARED_PTR<Polyline> polyline( RegionCreator *rc, WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts ) = 0;
00083                         virtual SHARED_PTR<Rectangle> ellipse( RegionCreator *rc, WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ) = 0;
00084                         virtual SHARED_PTR<Rectangle> point( RegionCreator *rc, WorldCanvas *wc, double x, double y, QtMouseToolNames::PointRegionSymbols sym, int size ) = 0;
00085                         virtual SHARED_PTR<PVLine> pvline( RegionCreator *rc, WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ) = 0;
00086 
00087                         virtual QtMouseToolNames::PointRegionSymbols currentPointSymbolType( ) const = 0;
00088 
00089                         // register region for dtor callback, and add to list of created regions...
00090                         void register_new_region( Region * );
00091 
00092                         std::list<Region*> created_regions;
00093                 };
00094 
00095                 class RegionSource {
00096                 public:
00097                         typedef RegionSourceKernel::shared_kernel_ptr_type shared_kernel_ptr_type;
00098 
00099                         SHARED_PTR<Rectangle> rectangle( WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ) {
00100                                 return kernel_->rectangle(region_creator,wc,blc_x,blc_y,trc_x,trc_y);
00101                         }
00102                         virtual SHARED_PTR<Polygon> polygon( WorldCanvas *wc, double x1, double y1 ) {
00103                                 return kernel_->polygon(region_creator,wc,x1,y1);
00104                         }
00105                         virtual SHARED_PTR<Polygon> polygon( WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts ) {
00106                                 return kernel_->polygon(region_creator,wc,pts);
00107                         }
00108                         virtual SHARED_PTR<Polyline> polyline( WorldCanvas *wc, double x1, double y1 ) {
00109                                 return kernel_->polyline(region_creator,wc,x1,y1);
00110                         }
00111                         virtual SHARED_PTR<Polyline> polyline( WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts ) {
00112                                 return kernel_->polyline(region_creator,wc,pts);
00113                         }
00114                         virtual SHARED_PTR<Rectangle> ellipse( WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ) {
00115                                 return kernel_->ellipse(region_creator,wc,blc_x,blc_y,trc_x,trc_y);
00116                         }
00117                         virtual SHARED_PTR<Rectangle> point( WorldCanvas *wc, double x, double y, QtMouseToolNames::PointRegionSymbols sym, int size ) {
00118                                 return kernel_->point(region_creator,wc,x,y,sym,size);
00119                         }
00120                         SHARED_PTR<PVLine> pvline( WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ) {
00121                                 return kernel_->pvline(region_creator,wc,blc_x,blc_y,trc_x,trc_y);
00122                         }
00123 
00124                         RegionSource( RegionCreator *rc, const shared_kernel_ptr_type &k ) :  kernel_(k), region_creator(rc) { }
00125                         RegionSource( const RegionSource &other ) : kernel_(other.kernel_), region_creator(other.region_creator) { }
00126 
00127                         void revokeRegion( Region *r ) {
00128                                 kernel_->revokeRegion(r);
00129                         }
00130 
00131                         shared_kernel_ptr_type kernel( ) {
00132                                 return kernel_;
00133                         }
00134 
00135                         QtRegionDock *dock( ) {
00136                                 return kernel_->dock( );
00137                         }
00138                         int numFrames( ) const {
00139                                 return kernel_->numFrames( );
00140                         }
00141 
00142                         QtMouseToolNames::PointRegionSymbols currentPointSymbolType( ) const {
00143                                 return kernel_->currentPointSymbolType( );
00144                         }
00145                         virtual ~RegionSource( ) { }
00146 
00147                 private:
00148                         shared_kernel_ptr_type kernel_;
00149                         RegionCreator *region_creator;
00150                 };
00151         }
00152 }
00153 
00154 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1