casa
$Rev:20696$
|
00001 //# MWCPannerTool.h: MultiWorldCanvas panning tool 00002 //# Copyright (C) 2000,2001,2002 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 00027 #ifndef TRIALDISPLAY_MWCPANNERTOOL_H 00028 #define TRIALDISPLAY_MWCPANNERTOOL_H 00029 00030 #include <casa/aips.h> 00031 #include <casa/Arrays/Vector.h> 00032 #include <display/DisplayEvents/MultiWCTool.h> 00033 #include <display/DisplayEvents/DTVisible.h> 00034 00035 namespace casa { //# NAMESPACE CASA - BEGIN 00036 00037 class WorldCanvas; 00038 00039 // <summary> 00040 // 00041 // </summary> 00042 // 00043 // <use visibility=export> 00044 // 00045 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00046 // </reviewed> 00047 // 00048 // <prerequisites> 00049 // <li> MWCTool 00050 // </prerequisites> 00051 // 00052 // <etymology> 00053 // MWCPannerTool stands for MultiWorldCanvas Panner Tool 00054 // </etymology> 00055 // 00056 // <synopsis> 00057 // This class provides panning functionality. The zoomed() function should 00058 // be overriden to catch the event, if needed. 00059 // 00060 // The pan line is drawn by dragging the mouse from one point to 00061 // another. The release of the mouse button triggers the movement of the 00062 // image by the same displacement. 00063 // 00064 // The Tool also responds to the arrow keys, scroll wheel, et. al., 00065 // moving the zoom window in the same direction through the image. 00066 // A constructor parameter is provided to turn these features off, 00067 // if needed. 00068 // </synopsis> 00069 // 00070 // <example> 00071 // </example> 00072 // 00073 // <motivation> 00074 // Panning is a common function in most visualization applications 00075 // </motivation> 00076 // 00077 // <todo asof="2001/02/24"> 00078 // Nothing known 00079 // </todo> 00080 00081 class MWCPannerTool : public MultiWCTool, public DTVisible { 00082 00083 public: 00084 // Constructor 00085 MWCPannerTool(Display::KeySym keysym = Display::K_Pointer_Button1, 00086 Bool scrollingAllowed = True); 00087 00088 // Destructor 00089 virtual ~MWCPannerTool(); 00090 00091 // Reset to non-showing, non-active. Refreshes if necessary to erase 00092 // (unless skipRefresh==True). 00093 // (Does not unregister from WCs or disable future event handling). 00094 virtual void reset(Bool skipRefresh=False); 00095 00096 protected: 00097 00098 // Functions called by the base class mouse event handling operators - 00099 // these maintain the state of the pan vector and order it to be drawn 00100 // via refresh(), send the pan request to the WC, and pass on notice 00101 // of the pan (zoomed()) when it is complete. 00102 // functions 00103 // <group> 00104 virtual void keyPressed(const WCPositionEvent &/*ev*/); 00105 virtual void keyReleased(const WCPositionEvent &/*ev*/); 00106 virtual void moved(const WCMotionEvent &/*ev*/, const viewer::region::region_list_type & /*selected_regions*/); 00107 virtual void otherKeyPressed(const WCPositionEvent &/*ev*/); 00108 // </group> 00109 00110 // draw the pan vector on a PixelCanvas. (To be called only by the 00111 // base class refresh event handler). 00112 virtual void draw(const WCRefreshEvent&/*ev*/, const viewer::region::region_list_type & /*selected_regions*/); 00113 00114 // Output callback to indicate that we have zoomed. Override to 00115 // handle, if needed. 00116 virtual void zoomed(const Vector<Double> &/*linBlc*/, 00117 const Vector<Double> &/*linTrc*/) { }; 00118 00119 private: 00120 00121 // execute the pan. shift is the (2-element) shift vector for the 00122 // zoom window, in linear coordinates. Resets the tool, removing 00123 // the line (if any) from screen 00124 virtual void pan(Vector<Double> &shift); 00125 00126 // Should we respond to mouse movement and button release? Should 00127 // we draw? Set when the button is pushed in one of the tool's WCs. 00128 Bool itsActive; 00129 00130 // pixel coordinates of the pan vector. 1 = anchor, 2 = new position. 00131 Int itsX1, itsY1, itsX2, itsY2; 00132 00133 // allow scrolling via arrow keys, et. al.? 00134 Bool itsScrollingAllowed; 00135 00136 // prevents key repeat from piling up scroll events, 00137 // if refresh can't keep up with them 00138 // <group> 00139 Double itsLastScrollTime; 00140 Int itsLastKey; 00141 // </group> 00142 00143 }; 00144 00145 00146 } //# NAMESPACE CASA - END 00147 00148 #endif 00149 00150