casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PVLine.qo.h
Go to the documentation of this file.
1 //# pvline.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_PVLINE_H_
30 #define REGION_PVLINE_H_
31 
35 #include <casa/BasicSL/String.h>
36 #include <list>
37 
38 namespace casa {
39 
40  class PanelDisplay;
41  class AnnotationBase;
42  class MSAsRaster;
43  class DisplayData;
44 
45  namespace viewer {
46 
47  // carry over from QtRegion... hopefully, removed soon...
48  class QtRegionSourceKernel;
49 
50  // All regions are specified in "linear coordinates", not "pixel coordinates". This is necessary
51  // because "linear coordinates" scale with zooming whereas "pixel coordinates" do not. Unfortunately,
52  // this means that coordinate transformation is required each time the region is drawn.
53  class PVLine : public Region {
54  Q_OBJECT
55  public:
56  ~PVLine( );
57  PVLine( WorldCanvas *wc, QtRegionDock *d, double x1, double y1, double x2, double y2,
58  bool hold_signals=false );
59 
60  // carry over from QtRegion... hopefully, removed soon...
61  PVLine( QtRegionSourceKernel *rs, WorldCanvas *wc, double x1, double y1, double x2, double y2,
62  bool hold_signals=false);
63 
64  bool clickWithin( double x, double y ) const {
65  double blc_x, blc_y, trc_x, trc_y;
66  boundingRectangle( blc_x, blc_y, trc_x, trc_y );
67  return x > blc_x && x < trc_x && y > blc_y && y < trc_y;
68  }
69 
70  int clickHandle( double x, double y ) const;
71 
72  bool doubleClick( double /*x*/, double /*y*/ );
73 
74  // returns point state (Region::PointLocation)
75  region::PointInfo checkPoint( double x, double y ) const;
76 
77  // returns mouse state (Region::MouseState)
78  unsigned int mouseMovement( double x, double y, bool other_selected );
79 
80  // for rectangles, resizing can change the handle...
81  // for rectangles, moving a handle is resizing...
82  int moveHandle( int handle, double x, double y );
83  void move( double dx, double dy );
84 
85  void resize( double /*width_delta*/, double /*height_delta*/ );
86  bool valid_translation( double dx, double dy, double width_delta, double height_delta );
87 
88  void linearCenter( double &x, double &y ) const;
89  void pixelCenter( double &x, double &y ) const;
90 
91  AnnotationBase *annotation( ) const;
92 
93  virtual bool flag( MSAsRaster *msar );
94 
95  // in "linear" coordinates...
96  void boundingRectangle( double &blcx, double &blcy, double &trcx, double &trcy ) const;
97 
98  void output( ds9writer &out ) const;
99 
100  // fetch region type...
102  return region::PVLineRegion;
103  }
104 
105  public slots:
106  void createPVImage(const std::string&,const std::string&,int);
107  void changePVInfo(int);
110 
111  private slots:
112  void dpg_deleted(QObject*);
113 
114 
115 
116  protected:
117 
118  PVLine( const std::string &name, WorldCanvas *wc, QtRegionDock *d, double x1,
119  double y1, double x2, double y2, bool hold_signals=false,
121 
122  RegionInfo::stats_t *get_ms_stats( MSAsRaster *msar, double x, double y );
123  void generate_nonimage_statistics( DisplayData*, std::list<RegionInfo> * );
124  std::list<std::shared_ptr<RegionInfo> > *generate_dds_centers( );
127 
128  virtual void fetch_region_details( region::RegionTypes &type, std::vector<std::pair<int,int> > &pixel_pts,
129  std::vector<std::pair<double,double> > &world_pts ) const;
130 
131  void drawRegion( bool );
132  /* void drawHandles( ); */
133 
134  /* virtual void setCenter(double &x, double &y, double &deltx, double &delty) {center_x_=x; center_y_=y; center_delta_x_=deltx; center_delta_y_=delty;}; */
135 
136  double pt1_x, pt1_y;
137  double pt2_x, pt2_y;
138  /* double center_x, center_y; */
141 
142  // one display_element is created for each image created from this PVLine...
143  // the resulting display list may be useful in the future...
145  public:
146  display_element( const std::string &n ) : name_(n), path_("") { }
147  std::string name( ) {
148  return name_;
149  }
150  std::string outputPath( );
151  private:
152  std::string name_;
153  std::string path_;
154  };
155 
156  typedef std::list<display_element> display_list_t;
158 
159  std::shared_ptr<casacore::ImageInterface<float> > generatePVImage( std::shared_ptr<casacore::ImageInterface<float> >, std::string, int, bool );
160 
161  private:
162  bool within_vertex_handle( double x, double y ) const;
163  unsigned int check_handle( double x, double y ) const;
164  std::vector<double> calculate_offset_points( double slope, double off, double x, double y );
165  void draw_pv_line( PixelCanvas *pc, bool selected=false );
166 
168  std::string worldCoordinateStrings( double x, double y );
171  };
172  }
173 }
174 
175 #endif
void draw_pv_line(PixelCanvas *pc, bool selected=false)
void generate_nonimage_statistics(DisplayData *, std::list< RegionInfo > *)
Base class for annotations.
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
Class for displaying data within an casacore::MS as a raster (gridded) image.
Definition: MSAsRaster.h:128
void dpg_deleted(QObject *)
one display_element is created for each image created from this PVLine...
Definition: PVLine.qo.h:144
unsigned int check_handle(double x, double y) const
void cursorPosition(viewer::Position)
std::list< std::shared_ptr< RegionInfo > > * generate_dds_centers()
All regions are specified in &quot;linear coordinates&quot;, not &quot;pixel coordinates&quot;.
Definition: PVLine.qo.h:53
int moveHandle(int handle, double x, double y)
for rectangles, resizing can change the handle...
std::shared_ptr< casacore::ImageInterface< float > > generatePVImage(std::shared_ptr< casacore::ImageInterface< float > >, std::string, int, bool)
RegionInfo::stats_t * get_ms_stats(MSAsRaster *msar, double x, double y)
std::vector< double > calculate_offset_points(double slope, double off, double x, double y)
bool clickWithin(double x, double y) const
Definition: PVLine.qo.h:64
casacore::ImageStatistics< casacore::Float >::stat_list stats_t
Definition: RegionInfo.h:49
void boundingRectangle(double &blcx, double &blcy, double &trcx, double &trcy) const
in &quot;linear&quot; coordinates...
bool doubleClick(double, double)
Interface for DisplayDatas which have data arranged in axes.
Base class defining interface to pixel-based output devices.
Definition: PixelCanvas.h:161
RegionInfo * newInfoObject(casacore::ImageInterface< float > *image, PrincipalAxesDD *)
newInfoObject(...) is currently only used for PVLine regions, but it should be used for other regions...
AnnotationBase * annotation() const
display_list_t display_list
Definition: PVLine.qo.h:157
All regions are specified in &quot;linear coordinates&quot;, not &quot;pixel coordinates&quot;.
Definition: Region.qo.h:147
QtDisplayPanelGui * sub_dpg
Definition: PVLine.qo.h:167
void output(ds9writer &out) const
virtual bool flag(MSAsRaster *msar)
The main display window for the Qt version of the viewer.
std::list< display_element > display_list_t
Definition: PVLine.qo.h:156
void linearCenter(double &x, double &y) const
unsigned int mouseMovement(double x, double y, bool other_selected)
returns mouse state (Region::MouseState)
display_element(const std::string &n)
Definition: PVLine.qo.h:146
void cursorBoundary(QtDisplayPanel::CursorBoundaryCondition)
CursorBoundaryCondition
included in cursor boundary signals...
void pixelCenter(double &x, double &y) const
Class to hold a region of interest in an image.
Definition: ImageRegion.h:86
void move(double dx, double dy)
bool selected() const
Definition: Region.qo.h:271
bool valid_translation(double dx, double dy, double width_delta, double height_delta)
int clickHandle(double x, double y) const
region::PointInfo checkPoint(double x, double y) const
returns point state (Region::PointLocation)
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
void createPVImage(const std::string &, const std::string &, int)
const std::string name() const
user specified name
Definition: Region.qo.h:163
Base class for display objects.
Definition: DisplayData.h:317
casacore::ImageRegion * get_image_region(DisplayData *) const
PVLine(WorldCanvas *wc, QtRegionDock *d, double x1, double y1, double x2, double y2, bool hold_signals=false)
region::RegionTypes type() const
fetch region type...
Definition: PVLine.qo.h:101
void resize(double, double)
Why not use casacore::MDirection? It&#39;s limited by valid astronomical coordinates on the sky Hz vs arc...
Definition: Position.h:41
bool within_vertex_handle(double x, double y) const
std::string worldCoordinateStrings(double x, double y)