RegionToolManager.qo.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_TOOLMANAGER_H__
00029 #define DISPLAY_TOOLMANAGER_H__
00030
00031 #include <QObject>
00032 #include <display/Display/PanelDisplay.h>
00033 #include <display/region/QtRegionSourceFactory.h>
00034
00035 #include <display/DisplayEvents/WCPositionEH.h>
00036 #include <display/DisplayEvents/WCMotionEH.h>
00037 #include <display/DisplayEvents/WCRefreshEH.h>
00038 #include <display/QtViewer/QtDisplayPanelGui.qo.h>
00039 #include <display/QtPlotter/QtMWCTools.qo.h>
00040
00041 namespace casa {
00042
00043
00044 class QtMouseTool;
00045 class QtRectTool;
00046
00047 namespace viewer {
00048
00049
00050
00051
00052 class RegionToolManager : public QObject, public WCPositionEH, public WCMotionEH, public WCRefreshEH {
00053 Q_OBJECT
00054 public:
00055
00056 enum ToolTypes { RectTool, PointTool, EllipseTool, PolyTool, PolylineTool, PVTool };
00057
00058
00059 RegionToolManager( QtRegionSourceFactory *rsf, QtDisplayPanelGui *dpg, PanelDisplay *pd );
00060 ~RegionToolManager( );
00061
00062
00063
00064
00065
00066 void operator()(const WCPositionEvent& ev);
00067 void operator()(const WCMotionEvent& ev);
00068 void operator()(const WCRefreshEvent& ev);
00069
00070
00071 void loadRegions( const std::string &path, const std::string &type );
00072
00073
00074 SHARED_PTR<RegionTool> tool( region::RegionTypes );
00075
00076 private:
00077
00078 region::RegionSelect tool_to_select(RegionTool::RegionToolTypes type ) const {
00079 return type == RegionTool::POLYTOOL ? region::SelectPoly :
00080 type == RegionTool::RECTTOOL ? region::SelectRect :
00081 type == RegionTool::POINTTOOL ? region::SelectPoint :
00082 type == RegionTool::ELLIPSETOOL ? region::SelectEllipse :
00083 type == RegionTool::POLYLINETOOL ? region::SelectPolyline : region::SelectAny;
00084 }
00085
00086 typedef std::pair<double,double> linear_point_type;
00087 PanelDisplay *pd;
00088 typedef std::map<ToolTypes,SHARED_PTR<RegionTool> > tool_map;
00089 tool_map tools;
00090
00091
00092
00093
00094
00095 bool inDrawArea( WorldCanvas *wc, const linear_point_type &new_blc, const linear_point_type &new_trc ) const;
00096 region::region_list_type moving_regions;
00097 linear_point_type moving_ref_point;
00098 linear_point_type moving_blc;
00099 linear_point_type moving_trc;
00100
00101
00102 bool moving_handle;
00103 viewer::region::PointInfo moving_handle_info;
00104 viewer::Region *moving_handle_region;
00105
00106
00107 bool add_mark_select( RegionTool::State &state, region::RegionSelect );
00108 void clear_mark_select( RegionTool::State &state, region::RegionSelect );
00109 bool setup_moving_regions( RegionTool::State &state, region::RegionSelect );
00110 void setup_moving_regions_state( double linx, double liny, const region::region_list_type & );
00111 void translate_moving_regions( WorldCanvas *wc, double dx, double dy );
00112 bool process_double_click( RegionTool::State &state, region::RegionSelect );
00113
00114
00115
00116 QtRegionSourceFactory *factory;
00117 QtDisplayPanelGui *panel;
00118
00119 };
00120 }
00121 }
00122
00123
00124 #endif