casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RegionSource.h
Go to the documentation of this file.
1 //# regionsource.h: regionsource producing persistent regions used within the casa viewer
2 //# Copyright (C) 2011
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 
29 #ifndef REGION_REGIONSOURCE_H_
30 #define REGION_REGIONSOURCE_H_
31 #include <list>
34 #include <display/Utilities/dtor.h>
36 
37 namespace casa {
38 
39  class WorldCanvas;
40 
41  namespace viewer {
42 
43  class Rectangle;
44  class Polygon;
45  class Polyline;
46  class Ellipse;
47  class PVLine;
48 
49  class QtRegionDock;
50  class RegionSource;
51  class RegionCreator;
52 
54  public:
55  typedef std::shared_ptr<RegionSourceKernel> shared_kernel_ptr_type;
56 
58  virtual ~RegionSourceKernel( );
59 
60  // inherited pure-virtual from dtorNotifiee, removes deleted regions...
61  void dtorCalled( const dtorNotifier * );
62 
63  // re-generate regionUpdateResponse( ) signals for existing regions...
64  // with *same* arguments as regionCreated( ), for the benefit of a newly created (e.g. QtProfile) tool...
65  virtual void generateExistingRegionUpdates( );
66 
67  virtual QtRegionDock *dock( ) {
68  return 0;
69  }
70  virtual int numFrames( ) const {
71  return -1;
72  }
73 
74  virtual void revokeRegion( Region *r ) = 0;
75 
76  protected:
77  friend class RegionSource;
78  virtual std::shared_ptr<Rectangle> rectangle( RegionCreator *rc, WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ) = 0;
79  virtual std::shared_ptr<Polygon> polygon( RegionCreator *rc, WorldCanvas *wc, double x1, double y1 ) = 0;
80  virtual std::shared_ptr<Polygon> polygon( RegionCreator *rc, WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts ) = 0;
81  virtual std::shared_ptr<Polyline> polyline( RegionCreator *rc, WorldCanvas *wc, double x1, double y1 ) = 0;
82  virtual std::shared_ptr<Polyline> polyline( RegionCreator *rc, WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts ) = 0;
83  virtual std::shared_ptr<Rectangle> ellipse( RegionCreator *rc, WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ) = 0;
84  virtual std::shared_ptr<Rectangle> point( RegionCreator *rc, WorldCanvas *wc, double x, double y, QtMouseToolNames::PointRegionSymbols sym, int size ) = 0;
85  virtual std::shared_ptr<PVLine> pvline( RegionCreator *rc, WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ) = 0;
86 
88 
89  // register region for dtor callback, and add to list of created regions...
90  void register_new_region( Region * );
91 
92  std::list<Region*> created_regions;
93  };
94 
95  class RegionSource {
96  public:
98 
99  std::shared_ptr<Rectangle> rectangle( WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ) {
100  return kernel_->rectangle(region_creator,wc,blc_x,blc_y,trc_x,trc_y);
101  }
102  virtual std::shared_ptr<Polygon> polygon( WorldCanvas *wc, double x1, double y1 ) {
103  return kernel_->polygon(region_creator,wc,x1,y1);
104  }
105  virtual std::shared_ptr<Polygon> polygon( WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts ) {
106  return kernel_->polygon(region_creator,wc,pts);
107  }
108  virtual std::shared_ptr<Polyline> polyline( WorldCanvas *wc, double x1, double y1 ) {
109  return kernel_->polyline(region_creator,wc,x1,y1);
110  }
111  virtual std::shared_ptr<Polyline> polyline( WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts ) {
112  return kernel_->polyline(region_creator,wc,pts);
113  }
114  virtual std::shared_ptr<Rectangle> ellipse( WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ) {
115  return kernel_->ellipse(region_creator,wc,blc_x,blc_y,trc_x,trc_y);
116  }
117  virtual std::shared_ptr<Rectangle> point( WorldCanvas *wc, double x, double y, QtMouseToolNames::PointRegionSymbols sym, int size ) {
118  return kernel_->point(region_creator,wc,x,y,sym,size);
119  }
120  std::shared_ptr<PVLine> pvline( WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ) {
121  return kernel_->pvline(region_creator,wc,blc_x,blc_y,trc_x,trc_y);
122  }
123 
126 
127  void revokeRegion( Region *r ) {
128  kernel_->revokeRegion(r);
129  }
130 
132  return kernel_;
133  }
134 
136  return kernel_->dock( );
137  }
138  int numFrames( ) const {
139  return kernel_->numFrames( );
140  }
141 
143  return kernel_->currentPointSymbolType( );
144  }
145  virtual ~RegionSource( ) { }
146 
147  private:
150  };
151  }
152 }
153 
154 #endif
virtual int numFrames() const
Definition: RegionSource.h:70
QtMouseToolNames::PointRegionSymbols currentPointSymbolType() const
Definition: RegionSource.h:142
virtual std::shared_ptr< Rectangle > point(WorldCanvas *wc, double x, double y, QtMouseToolNames::PointRegionSymbols sym, int size)
Definition: RegionSource.h:117
virtual std::shared_ptr< PVLine > pvline(RegionCreator *rc, WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y)=0
std::shared_ptr< Rectangle > rectangle(WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y)
Definition: RegionSource.h:99
virtual std::shared_ptr< Polyline > polyline(WorldCanvas *wc, double x1, double y1)
Definition: RegionSource.h:108
std::list< Region * > created_regions
Definition: RegionSource.h:92
virtual void generateExistingRegionUpdates()
re-generate regionUpdateResponse() signals for existing regions...
virtual QtRegionDock * dock()
Definition: RegionSource.h:67
RegionSource(RegionCreator *rc, const shared_kernel_ptr_type &k)
Definition: RegionSource.h:124
virtual QtMouseToolNames::PointRegionSymbols currentPointSymbolType() const =0
virtual std::shared_ptr< Rectangle > point(RegionCreator *rc, WorldCanvas *wc, double x, double y, QtMouseToolNames::PointRegionSymbols sym, int size)=0
shared_kernel_ptr_type kernel()
Definition: RegionSource.h:131
shared_kernel_ptr_type kernel_
Definition: RegionSource.h:148
size_t size() const
virtual std::shared_ptr< Rectangle > ellipse(WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y)
Definition: RegionSource.h:114
RegionSourceKernel::shared_kernel_ptr_type shared_kernel_ptr_type
Definition: RegionSource.h:97
void revokeRegion(Region *r)
Definition: RegionSource.h:127
virtual std::shared_ptr< Polygon > polygon(RegionCreator *rc, WorldCanvas *wc, double x1, double y1)=0
std::shared_ptr< PVLine > pvline(WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y)
Definition: RegionSource.h:120
All regions are specified in &quot;linear coordinates&quot;, not &quot;pixel coordinates&quot;.
Definition: Region.qo.h:147
virtual std::shared_ptr< Polyline > polyline(WorldCanvas *wc, const std::vector< std::pair< double, double > > &pts)
Definition: RegionSource.h:111
virtual std::shared_ptr< Rectangle > rectangle(RegionCreator *rc, WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y)=0
RegionSource(const RegionSource &other)
Definition: RegionSource.h:125
std::shared_ptr< RegionSourceKernel > shared_kernel_ptr_type
Definition: RegionSource.h:55
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
void register_new_region(Region *)
register region for dtor callback, and add to list of created regions...
virtual std::shared_ptr< Rectangle > ellipse(RegionCreator *rc, WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y)=0
virtual std::shared_ptr< Polygon > polygon(WorldCanvas *wc, const std::vector< std::pair< double, double > > &pts)
Definition: RegionSource.h:105
virtual std::shared_ptr< Polygon > polygon(WorldCanvas *wc, double x1, double y1)
Definition: RegionSource.h:102
RegionCreator * region_creator
Definition: RegionSource.h:149
virtual void revokeRegion(Region *r)=0
void dtorCalled(const dtorNotifier *)
inherited pure-virtual from dtorNotifiee, removes deleted regions...
virtual std::shared_ptr< Polyline > polyline(RegionCreator *rc, WorldCanvas *wc, double x1, double y1)=0