RegionToolManager.qo.h

Go to the documentation of this file.
00001 //# RegionToolManager.qo.h: class designed to unify the behavior of all of the mouse tools
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 #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         /* class QtMWCTool; */
00044         class QtMouseTool;
00045         class QtRectTool;
00046 
00047         namespace viewer {
00048 
00049                 // the RegionCreator class now has static members which allow for the
00050                 // retrieval of lists of RegionCreator objects for creating each type
00051                 // of region (currently rectangle, polygon, ellipse, and point).
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                         // Required operators for event handling - these are called when
00063                         // events occur, and distribute the events to the "user-level"
00064                         // methods
00065                         // <group>
00066                         void operator()(const WCPositionEvent& ev);
00067                         void operator()(const WCMotionEvent& ev);
00068                         void operator()(const WCRefreshEvent& ev);
00069                         // </group>
00070 
00071                         void loadRegions( const std::string &path, const std::string &type );
00072 
00073                         // fetch tool for a particular region type...
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                         // members for keeping track of marked (sticky-selected) regions...
00092                         /* region_list_type marked_regions; */
00093 
00094                         // members for state when moving selected region...
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                         // members for state when moving a region handle...
00102                         bool moving_handle;
00103                         viewer::region::PointInfo moving_handle_info;
00104                         viewer::Region *moving_handle_region;
00105 
00106                         // returns new region marked state...
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                         // region source factory is needed to retrieve the region dock
00115                         // which can provide a list of selected regions...
00116                         QtRegionSourceFactory *factory;
00117                         QtDisplayPanelGui *panel;
00118 
00119                 };
00120         }
00121 }
00122 
00123 
00124 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1