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_RECTANGLE_H_
00030 #define REGION_RECTANGLE_H_
00031
00032 #include <display/region/Region.qo.h>
00033 #include <display/region/QtRegionSource.qo.h>
00034 #include <casa/BasicSL/String.h>
00035 #include <list>
00036
00037 namespace casa {
00038
00039 class PanelDisplay;
00040 class AnnotationBase;
00041 class MSAsRaster;
00042 class DisplayData;
00043
00044 namespace viewer {
00045
00046
00047 class QtRegionSourceKernel;
00048
00049
00050
00051
00052 class Rectangle : public Region {
00053 public:
00054 ~Rectangle( );
00055 Rectangle( WorldCanvas *wc, QtRegionDock *d, double x1, double y1, double x2, double y2,
00056 bool hold_signals=false );
00057
00058
00059 Rectangle( QtRegionSourceKernel *rs, WorldCanvas *wc, double x1, double y1, double x2, double y2,
00060 bool hold_signals=false);
00061
00062 bool clickWithin( double x, double y ) const {
00063 return x > blc_x && x < trc_x && y > blc_y && y < trc_y;
00064 }
00065
00066 int clickHandle( double x, double y ) const;
00067
00068 bool doubleClick( double , double );
00069
00070
00071 region::PointInfo checkPoint( double x, double y ) const;
00072
00073
00074 unsigned int mouseMovement( double x, double y, bool other_selected );
00075
00076
00077
00078 int moveHandle( int handle, double x, double y );
00079 void move( double dx, double dy );
00080
00081 void resize( double , double );
00082 bool valid_translation( double dx, double dy, double width_delta, double height_delta );
00083
00084 void linearCenter( double &x, double &y ) const;
00085 void pixelCenter( double &x, double &y ) const;
00086
00087 AnnotationBase *annotation( ) const;
00088
00089 virtual bool flag( MSAsRaster *msar );
00090
00091
00092 void boundingRectangle( double &blcx, double &blcy, double &trcx, double &trcy ) const;
00093
00094 void output( ds9writer &out ) const;
00095
00096
00097 region::RegionTypes type( ) const {
00098 return region::RectRegion;
00099 }
00100
00101 protected:
00102 Rectangle( const std::string &name, WorldCanvas *wc, QtRegionDock *d, double x1,
00103 double y1, double x2, double y2,
00104 bool hold_signals=false, QtRegionState *supplied_state=0,
00105 QtMouseToolNames::PointRegionSymbols sym=QtMouseToolNames::SYM_UNKNOWN ) :
00106 Region( name, wc, d, hold_signals, supplied_state, sym ), blc_x(x1<x2?x1:x2),
00107 blc_y(y1<y2?y1:y2), trc_x(x1<x2?x2:x1), trc_y(y1<y2?y2:y1) {
00108 initHistogram();
00109 complete = true;
00110 }
00111
00112 RegionInfo::stats_t *get_ms_stats( MSAsRaster *msar, double x, double y );
00113 void generate_nonimage_statistics( DisplayData*, std::list<RegionInfo> * );
00114 std::list<SHARED_PTR<RegionInfo> > *generate_dds_centers( );
00115 ImageRegion *get_image_region( DisplayData* ) const;
00116
00117 virtual void fetch_region_details( region::RegionTypes &type, std::vector<std::pair<int,int> > &pixel_pts,
00118 std::vector<std::pair<double,double> > &world_pts ) const;
00119
00120 void drawRegion( bool );
00121
00122
00123 virtual void setCenter(double &x, double &y, double &deltx, double &delty) {
00124 center_x_=x;
00125 center_y_=y;
00126 center_delta_x_=deltx;
00127 center_delta_y_=delty;
00128 };
00129
00130 double blc_x, blc_y;
00131 double trc_x, trc_y;
00132 double center_x_, center_y_;
00133 double center_delta_x_, center_delta_y_;
00134 double handle_delta_x, handle_delta_y;
00135
00136 private:
00137 virtual bool output_region( ds9writer &out, WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts ) const;
00138
00139 bool within_vertex_handle( double x, double y ) const;
00140 unsigned int check_handle( double x, double y ) const;
00141
00142 };
00143 }
00144 }
00145
00146 #endif