casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Rectangle.h
Go to the documentation of this file.
1 //# rectangle.h: base class for statistical regions
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_RECTANGLE_H_
30 #define REGION_RECTANGLE_H_
31 
34 #include <casa/BasicSL/String.h>
35 #include <list>
36 
37 namespace casa {
38 
39  class PanelDisplay;
40  class AnnotationBase;
41  class MSAsRaster;
42  class DisplayData;
43 
44  namespace viewer {
45 
46  // carry over from QtRegion... hopefully, removed soon...
47  class QtRegionSourceKernel;
48 
49  // All regions are specified in "linear coordinates", not "pixel coordinates". This is necessary
50  // because "linear coordinates" scale with zooming whereas "pixel coordinates" do not. Unfortunately,
51  // this means that coordinate transformation is required each time the region is drawn.
52  class Rectangle : public Region {
53  public:
54  ~Rectangle( );
55  Rectangle( WorldCanvas *wc, QtRegionDock *d, double x1, double y1, double x2, double y2,
56  bool hold_signals=false );
57 
58  // carry over from QtRegion... hopefully, removed soon...
59  Rectangle( QtRegionSourceKernel *rs, WorldCanvas *wc, double x1, double y1, double x2, double y2,
60  bool hold_signals=false);
61 
62  bool clickWithin( double x, double y ) const {
63  return x > blc_x && x < trc_x && y > blc_y && y < trc_y;
64  }
65 
66  int clickHandle( double x, double y ) const;
67 
68  bool doubleClick( double /*x*/, double /*y*/ );
69 
70  // returns point state (Region::PointLocation)
71  region::PointInfo checkPoint( double x, double y ) const;
72 
73  // returns mouse state (Region::MouseState)
74  unsigned int mouseMovement( double x, double y, bool other_selected );
75 
76  // for rectangles, resizing can change the handle...
77  // for rectangles, moving a handle is resizing...
78  int moveHandle( int handle, double x, double y );
79  void move( double dx, double dy );
80 
81  void resize( double /*width_delta*/, double /*height_delta*/ );
82  bool valid_translation( double dx, double dy, double width_delta, double height_delta );
83 
84  void linearCenter( double &x, double &y ) const;
85  void pixelCenter( double &x, double &y ) const;
86 
87  AnnotationBase *annotation( ) const;
88 
89  virtual bool flag( MSAsRaster *msar );
90 
91  // in "linear" coordinates...
92  void boundingRectangle( double &blcx, double &blcy, double &trcx, double &trcy ) const;
93 
94  void output( ds9writer &out ) const;
95 
96  // fetch region type...
98  return region::RectRegion;
99  }
100 
101  protected:
102  Rectangle( const std::string &name, WorldCanvas *wc, QtRegionDock *d, double x1,
103  double y1, double x2, double y2,
104  bool hold_signals=false, QtRegionState *supplied_state=0,
106  Region( name, wc, d, hold_signals, supplied_state, sym ), blc_x(x1<x2?x1:x2),
107  blc_y(y1<y2?y1:y2), trc_x(x1<x2?x2:x1), trc_y(y1<y2?y2:y1) {
108  initHistogram();
109  complete = true;
110  }
111 
112  RegionInfo::stats_t *get_ms_stats( MSAsRaster *msar, double x, double y );
113  void generate_nonimage_statistics( DisplayData*, std::list<RegionInfo> * );
114  std::list<std::shared_ptr<RegionInfo> > *generate_dds_centers( );
116 
117  virtual void fetch_region_details( region::RegionTypes &type, std::vector<std::pair<int,int> > &pixel_pts,
118  std::vector<std::pair<double,double> > &world_pts ) const;
119 
120  void drawRegion( bool );
121  /* void drawHandles( ); */
122 
123  virtual void setCenter(double &x, double &y, double &deltx, double &delty) {
124  center_x_=x;
125  center_y_=y;
126  center_delta_x_=deltx;
127  center_delta_y_=delty;
128  };
129 
130  double blc_x, blc_y;
131  double trc_x, trc_y;
135 
136  private:
137  virtual bool output_region( ds9writer &out, WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts ) const;
138 
139  bool within_vertex_handle( double x, double y ) const;
140  unsigned int check_handle( double x, double y ) const;
141 
142  };
143  }
144 }
145 
146 #endif
bool doubleClick(double, double)
Base class for annotations.
void linearCenter(double &x, double &y) const
Class for displaying data within an casacore::MS as a raster (gridded) image.
Definition: MSAsRaster.h:128
void resize(double, double)
Rectangle(const std::string &name, WorldCanvas *wc, QtRegionDock *d, double x1, double y1, double x2, double y2, bool hold_signals=false, QtRegionState *supplied_state=0, QtMouseToolNames::PointRegionSymbols sym=QtMouseToolNames::SYM_UNKNOWN)
Definition: Rectangle.h:102
virtual bool output_region(ds9writer &out, WorldCanvas *wc, const std::vector< std::pair< double, double > > &pts) const
void pixelCenter(double &x, double &y) const
bool valid_translation(double dx, double dy, double width_delta, double height_delta)
casacore::ImageStatistics< casacore::Float >::stat_list stats_t
Definition: RegionInfo.h:49
region::PointInfo checkPoint(double x, double y) const
returns point state (Region::PointLocation)
void initHistogram()
-----------------—==================== from old QtRegion ====================-----------------— ...
casacore::ImageRegion * get_image_region(DisplayData *) const
void move(double dx, double dy)
int clickHandle(double x, double y) const
RegionInfo::stats_t * get_ms_stats(MSAsRaster *msar, double x, double y)
All regions are specified in &quot;linear coordinates&quot;, not &quot;pixel coordinates&quot;.
Definition: Region.qo.h:147
bool clickWithin(double x, double y) const
Definition: Rectangle.h:62
void generate_nonimage_statistics(DisplayData *, std::list< RegionInfo > *)
bool complete
Should this region be considered complete? Set to true by derived classes...
Definition: Region.qo.h:556
virtual void fetch_region_details(region::RegionTypes &type, std::vector< std::pair< int, int > > &pixel_pts, std::vector< std::pair< double, double > > &world_pts) const
int moveHandle(int handle, double x, double y)
for rectangles, resizing can change the handle...
region::RegionTypes type() const
fetch region type...
Definition: Rectangle.h:97
std::list< std::shared_ptr< RegionInfo > > * generate_dds_centers()
virtual bool flag(MSAsRaster *msar)
void boundingRectangle(double &blcx, double &blcy, double &trcx, double &trcy) const
in &quot;linear&quot; coordinates...
unsigned int check_handle(double x, double y) const
Class to hold a region of interest in an image.
Definition: ImageRegion.h:86
void output(ds9writer &out) const
AnnotationBase * annotation() const
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
bool within_vertex_handle(double x, double y) const
All regions are specified in &quot;linear coordinates&quot;, not &quot;pixel coordinates&quot;.
Definition: Rectangle.h:52
const std::string name() const
user specified name
Definition: Region.qo.h:163
Base class for display objects.
Definition: DisplayData.h:317
virtual void setCenter(double &x, double &y, double &deltx, double &delty)
Definition: Rectangle.h:123
unsigned int mouseMovement(double x, double y, bool other_selected)
returns mouse state (Region::MouseState)
Rectangle(WorldCanvas *wc, QtRegionDock *d, double x1, double y1, double x2, double y2, bool hold_signals=false)