00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
00048 class QtRegionSourceKernel;
00049
00050
00051
00052
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
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 , double );
00073
00074
00075 region::PointInfo checkPoint( double x, double y ) const;
00076
00077
00078 unsigned int mouseMovement( double x, double y, bool other_selected );
00079
00080
00081
00082 int moveHandle( int handle, double x, double y );
00083 void move( double dx, double dy );
00084
00085 void resize( double , double );
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
00096 void boundingRectangle( double &blcx, double &blcy, double &trcx, double &trcy ) const;
00097
00098 void output( ds9writer &out ) const;
00099
00100
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 changePVInfo(int);
00108 void cursorBoundary(QtDisplayPanel::CursorBoundaryCondition);
00109 void cursorPosition(viewer::Position);
00110
00111 private slots:
00112 void dpg_deleted(QObject*);
00113
00114
00115
00116 protected:
00117
00118 PVLine( const std::string &name, WorldCanvas *wc, QtRegionDock *d, double x1,
00119 double y1, double x2, double y2, bool hold_signals=false,
00120 QtMouseToolNames::PointRegionSymbols sym=QtMouseToolNames::SYM_UNKNOWN );
00121
00122 RegionInfo::stats_t *get_ms_stats( MSAsRaster *msar, double x, double y );
00123 void generate_nonimage_statistics( DisplayData*, std::list<RegionInfo> * );
00124 std::list<SHARED_PTR<RegionInfo> > *generate_dds_centers( );
00125 ImageRegion *get_image_region( DisplayData* ) const;
00126 RegionInfo *newInfoObject( ImageInterface<Float> *image, PrincipalAxesDD * );
00127
00128 virtual void fetch_region_details( region::RegionTypes &type, std::vector<std::pair<int,int> > &pixel_pts,
00129 std::vector<std::pair<double,double> > &world_pts ) const;
00130
00131 void drawRegion( bool );
00132
00133
00134
00135
00136 double pt1_x, pt1_y;
00137 double pt2_x, pt2_y;
00138
00139 double handle_delta_x, handle_delta_y;
00140 int display_width;
00141
00142
00143
00144 class display_element {
00145 public:
00146 display_element( const std::string &n ) : name_(n), path_("") { }
00147 std::string name( ) {
00148 return name_;
00149 }
00150 std::string outputPath( );
00151 private:
00152 std::string name_;
00153 std::string path_;
00154 };
00155
00156 typedef std::list<display_element> display_list_t;
00157 display_list_t display_list;
00158
00159 SHARED_PTR<ImageInterface<Float> > generatePVImage( SHARED_PTR<ImageInterface<Float> >, std::string, int, bool );
00160
00161 private:
00162 bool within_vertex_handle( double x, double y ) const;
00163 unsigned int check_handle( double x, double y ) const;
00164 std::vector<double> calculate_offset_points( double slope, double off, double x, double y );
00165 void draw_pv_line( PixelCanvas *pc, bool selected=false );
00166
00167 QtDisplayPanelGui *sub_dpg;
00168 std::string worldCoordinateStrings( double x, double y );
00169 bool draw_cursor_point;
00170 double cursor_point_x, cursor_point_y;
00171 };
00172 }
00173 }
00174
00175 #endif