casa
$Rev:20696$
|
00001 //# pvline.h: base class for statistical regions 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_PVLINE_H_ 00030 #define REGION_PVLINE_H_ 00031 00032 #include <display/region/Region.qo.h> 00033 #include <display/region/QtRegionSource.qo.h> 00034 #include <display/QtViewer/QtDisplayPanelGui.qo.h> 00035 #include <casa/BasicSL/String.h> 00036 #include <list> 00037 00038 namespace casa { 00039 00040 class PanelDisplay; 00041 class AnnotationBase; 00042 class MSAsRaster; 00043 class DisplayData; 00044 00045 namespace viewer { 00046 00047 // carry over from QtRegion... hopefully, removed soon... 00048 class QtRegionSourceKernel; 00049 00050 // All regions are specified in "linear coordinates", not "pixel coordinates". This is necessary 00051 // because "linear coordinates" scale with zooming whereas "pixel coordinates" do not. Unfortunately, 00052 // this means that coordinate transformation is required each time the region is drawn. 00053 class PVLine : public Region { 00054 Q_OBJECT 00055 public: 00056 ~PVLine( ); 00057 PVLine( WorldCanvas *wc, QtRegionDock *d, double x1, double y1, double x2, double y2, 00058 bool hold_signals=false ); 00059 00060 // carry over from QtRegion... hopefully, removed soon... 00061 PVLine( QtRegionSourceKernel *rs, WorldCanvas *wc, double x1, double y1, double x2, double y2, 00062 bool hold_signals=false); 00063 00064 bool clickWithin( double x, double y ) const 00065 { double blc_x, blc_y, trc_x, trc_y; 00066 boundingRectangle( blc_x, blc_y, trc_x, trc_y ); 00067 return x > blc_x && x < trc_x && y > blc_y && y < trc_y; 00068 } 00069 00070 int clickHandle( double x, double y ) const; 00071 00072 bool doubleClick( double /*x*/, double /*y*/ ); 00073 00074 // returns point state (Region::PointLocation) 00075 region::PointInfo checkPoint( double x, double y ) const; 00076 00077 // returns mouse state (Region::MouseState) 00078 unsigned int mouseMovement( double x, double y, bool other_selected ); 00079 00080 // for rectangles, resizing can change the handle... 00081 // for rectangles, moving a handle is resizing... 00082 int moveHandle( int handle, double x, double y ); 00083 void move( double dx, double dy ); 00084 00085 void resize( double /*width_delta*/, double /*height_delta*/ ); 00086 bool valid_translation( double dx, double dy, double width_delta, double height_delta ); 00087 00088 void linearCenter( double &x, double &y ) const; 00089 void pixelCenter( double &x, double &y ) const; 00090 00091 AnnotationBase *annotation( ) const; 00092 00093 virtual bool flag( MSAsRaster *msar ); 00094 00095 // in "linear" coordinates... 00096 void boundingRectangle( double &blcx, double &blcy, double &trcx, double &trcy ) const; 00097 00098 void output( ds9writer &out ) const; 00099 00100 // fetch region type... 00101 region::RegionTypes type( ) const { 00102 return region::PVLineRegion; 00103 } 00104 00105 public slots: 00106 void createPVImage(const std::string&,const std::string&,int); 00107 void cursorBoundary(QtDisplayPanel::CursorBoundaryCondition); 00108 void cursorPosition(viewer::Position); 00109 00110 private slots: 00111 void dpg_deleted(QObject*); 00112 00113 00114 00115 protected: 00116 00117 PVLine( const std::string &name, WorldCanvas *wc, QtRegionDock *d, double x1, 00118 double y1, double x2, double y2, bool hold_signals=false, 00119 QtMouseToolNames::PointRegionSymbols sym=QtMouseToolNames::SYM_UNKNOWN ); 00120 00121 RegionInfo::stats_t *get_ms_stats( MSAsRaster *msar, double x, double y ); 00122 void generate_nonimage_statistics( DisplayData*, std::list<RegionInfo> * ); 00123 std::list<std::tr1::shared_ptr<RegionInfo> > *generate_dds_centers( ); 00124 ImageRegion *get_image_region( DisplayData* ) const; 00125 RegionInfo *newInfoObject( ImageInterface<Float> *image, PrincipalAxesDD * ); 00126 00127 virtual void fetch_region_details( region::RegionTypes &type, std::vector<std::pair<int,int> > &pixel_pts, 00128 std::vector<std::pair<double,double> > &world_pts ) const; 00129 00130 void drawRegion( bool ); 00131 /* void drawHandles( ); */ 00132 00133 /* 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;}; */ 00134 00135 double pt1_x, pt1_y; 00136 double pt2_x, pt2_y; 00137 /* double center_x, center_y; */ 00138 double handle_delta_x, handle_delta_y; 00139 00140 // one display_element is created for each image created from this PVLine... 00141 // the resulting display list may be useful in the future... 00142 class display_element { 00143 public: 00144 display_element( const std::string &n ) : name_(n), path_("") { } 00145 std::string name( ) { 00146 return name_; 00147 } 00148 std::string outputPath( ); 00149 private: 00150 std::string name_; 00151 std::string path_; 00152 }; 00153 00154 typedef std::list<display_element> display_list_t; 00155 display_list_t display_list; 00156 00157 ImageInterface<Float> *generatePVImage( ImageInterface<Float> *, std::string, int, bool ); 00158 00159 private: 00160 QtDisplayPanelGui *sub_dpg; 00161 bool within_vertex_handle( double x, double y ) const; 00162 unsigned int check_handle( double x, double y ) const; 00163 std::string worldCoordinateStrings( double x, double y ); 00164 bool draw_cursor_point; 00165 double cursor_point_x, cursor_point_y; 00166 }; 00167 } 00168 } 00169 00170 #endif