RegionTool.h
Go to the documentation of this file.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 #ifndef DISPLAY_REGIONTOOL_H__
00029 #define DISPLAY_REGIONTOOL_H__
00030
00031 #include <map>
00032 #include <set>
00033 #include <list>
00034 #include <display/region/RegionEnums.h>
00035 #include <display/DisplayEvents/MultiWCTool.h>
00036 #include <display/Utilities/VOID.h>
00037
00038 namespace casa {
00039 class RegionTool : public MultiWCTool {
00040 public:
00041 typedef std::map<viewer::Region*,viewer::region::PointInfo> region_map_type;
00042
00043 enum RegionToolTypes { POLYTOOL, RECTTOOL, POINTTOOL, ELLIPSETOOL, POLYLINETOOL, PVLINETOOL };
00044
00045 class State {
00046 public:
00047 State( WorldCanvas *wc, double X, double Y ) : wc_(wc), x_(X), y_(Y), refresh_count(0) { }
00048 void insert( RegionTool *tool, viewer::Region *region, const viewer::region::PointInfo &state );
00049
00050 unsigned int count( viewer::region::PointLocation state );
00051 bool exists( viewer::Region * ) const;
00052
00053
00054 viewer::region::region_list_type ®ions( ) {
00055 return all_regions;
00056 }
00057 viewer::region::region_list_type ®ions( RegionTool *tool );
00058 SHARED_PTR<viewer::region::region_list_type> regions( viewer::region::PointLocation loc,
00059 viewer::region::RegionSelect select );
00060 viewer::region::PointInfo state( viewer::Region *region );
00061
00062 double x( ) const {
00063 return x_;
00064 }
00065 double y( ) const {
00066 return y_;
00067 }
00068 WorldCanvas *wc( ) {
00069 return wc_;
00070 }
00071
00072 void refresh( ) {
00073 ++refresh_count;
00074 }
00075
00076 ~State( );
00077
00078 private:
00079
00080 SHARED_PTR<viewer::region::region_list_type> filter( SHARED_PTR<viewer::region::region_list_type>,
00081 viewer::region::RegionSelect );
00082
00083 void *operator new( size_t );
00084 State( const State & ) { }
00085 State( ) { }
00086
00087 typedef std::map< RegionTool*, viewer::region::region_list_type > tool_regions_type;
00088 typedef std::map< viewer::region::PointLocation, SHARED_PTR<viewer::region::region_list_type> > state_count_type;
00089
00090 WorldCanvas *wc_;
00091 double x_, y_;
00092 unsigned int refresh_count;
00093
00094 region_map_type state_map;
00095 tool_regions_type tool_map;
00096 state_count_type count_map;
00097 viewer::region::region_list_type all_regions;
00098 viewer::region::region_list_type default_region_list;
00099 };
00100
00101 RegionTool( Display::KeySym keysym = Display::K_Pointer_Button1) : MultiWCTool( keysym, false ) { }
00102 ~RegionTool( ) { }
00103
00104 void keyPressed(const WCPositionEvent &ev);
00105 void keyReleased(const WCPositionEvent &);
00106 void otherKeyPressed(const WCPositionEvent &);
00107 void otherKeyReleased(const WCPositionEvent &);
00108 void moved(const WCMotionEvent &ev, const viewer::region::region_list_type & );
00109 void draw(const WCRefreshEvent&, const viewer::region::region_list_type & );
00110
00111
00112
00113
00114 virtual void checkPoint( WorldCanvas *wc, State &state ) = 0;
00115
00116
00117
00118 virtual bool create( viewer::region::RegionTypes, WorldCanvas *, const std::vector<std::pair<double,double> > &,
00119 const std::string &, viewer::region::TextPosition , const std::vector<int> &,
00120 const std::string &, int , int , const std::string &,
00121 const std::string &, viewer::region::LineStyle , unsigned int ,
00122 bool , VOID * ) = 0;
00123
00124
00125
00126
00127 void enable() { }
00128 void disable() { }
00129
00130 virtual RegionToolTypes type( ) const = 0;
00131
00132
00133 virtual void revokeRegion( viewer::Region * ) = 0;
00134
00135 };
00136 }
00137
00138 #endif