PCTool.h

Go to the documentation of this file.
00001 //# PCTool.h: base class for PixelCanvas event-based tools
00002 //# Copyright (C) 1999,2000
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 TRIALDISPLAY_PCTOOL_H
00029 #define TRIALDISPLAY_PCTOOL_H
00030 
00031 #include <casa/aips.h>
00032 #include <display/DisplayEvents/PCPositionEH.h>
00033 #include <display/DisplayEvents/PCMotionEH.h>
00034 #include <display/DisplayEvents/PCRefreshEH.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038         class PCTool;
00039         class PixelCanvas;
00040 
00041 // <summary>
00042 // PixelCanvas position event handler for PCTool.
00043 // </summary>
00044 //
00045 // <synopsis>
00046 // This class is a simple implementation of a PCPositionEH which
00047 // passes PixelCanvas position events on to a single PCTool.
00048 // </synopsis>
00049 
00050         class PCToolPosEH : public PCPositionEH {
00051         public:
00052                 PCToolPosEH(PCTool *tool);
00053                 virtual ~PCToolPosEH() {};
00054                 virtual void operator()(const PCPositionEvent& ev);
00055         private:
00056                 PCTool *itsTool;
00057         };
00058 
00059 // <summary>
00060 // PixelCanvas motion event handler for PCTool.
00061 // </summary>
00062 //
00063 // <synopsis>
00064 // This class is a simple implementation of a PCMotionEH which
00065 // passes PixelCanvas motion events on to a single PCTool.
00066 // </synopsis>
00067 
00068         class PCToolMotEH : public PCMotionEH {
00069         public:
00070                 PCToolMotEH(PCTool *tool);
00071                 virtual ~PCToolMotEH() {};
00072                 virtual void operator()(const PCMotionEvent& ev);
00073         private:
00074                 PCTool *itsTool;
00075         };
00076 
00077 // <summary>
00078 // PixelCanvas refresh event handler for PCTool.
00079 // </summary>
00080 //
00081 // <synopsis>
00082 // This class is a simple implementation of a PCRefreshEH which
00083 // passes PixelCanvas refresh events on to a single PCTool.
00084 // </synopsis>
00085 
00086         class PCToolRefEH : public PCRefreshEH {
00087         public:
00088                 PCToolRefEH(PCTool *tool);
00089                 virtual ~PCToolRefEH() {};
00090                 virtual void operator()(const PCRefreshEvent& ev);
00091         private:
00092                 PCTool *itsTool;
00093         };
00094 
00095 // <summary>
00096 // Base class for PixelCanvas event-based tools.
00097 // </summary>
00098 
00099 // <use visibility=export>
00100 
00101 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00102 // </reviewed>
00103 
00104 // <prerequisites>
00105 //   <li> PCPositionEH
00106 //   <li> PCMotionEH
00107 //   <li> PCRefreshEH
00108 // </prerequisites>
00109 
00110 // <etymology>
00111 // PCTool stands for PixelCanvas Tool.
00112 // </etymology>
00113 
00114 // <synopsis>
00115 // This class is a base class upon which tools which respond to
00116 // various events on a PixelCanvas can be built.  It wraps up
00117 // the position, motion and refresh events so that the programmer
00118 // sees them all coming into one class, where they can be dealt
00119 // with in a unified manner.  PCTool is not actually abstract,
00120 // so the programmer need only write handlers for the events in
00121 // which they are interested.
00122 // </synopsis>
00123 
00124 // <example>
00125 // </example>
00126 
00127 // <motivation>
00128 // The majority of tools written for the PixelCanvas will fall
00129 // into the category that this class serves: they respond to a
00130 // single key or mouse button, and they potentially need to
00131 // respond to position, motion and refresh events.
00132 // </motivation>
00133 
00134 // <todo asof="1999/10/09">
00135 //   <li> Nothing known
00136 // </todo>
00137 
00138         class PCTool {
00139 
00140         public:
00141 
00142                 // Constructor.  A PixelCanvas to attach to must be specified,
00143                 // and normally a key to respond to as well.
00144                 PCTool(PixelCanvas *pcanvas,
00145                        Display::KeySym keysym = Display::K_Pointer_Button1);
00146 
00147                 // Destructor.
00148                 virtual ~PCTool();
00149 
00150                 // Switch the tool on/off.  This simply registers or unregisters the
00151                 // event handlers.
00152                 // <group>
00153                 virtual void enable();
00154                 virtual void disable();
00155                 // </group>
00156 
00157                 // Required operators for event handling.  These are called when
00158                 // events occur, and distribute the events to the "user-level"
00159                 // methods.
00160                 // <group>
00161                 virtual void operator()(const PCPositionEvent& ev);
00162                 virtual void operator()(const PCMotionEvent& ev);
00163                 virtual void operator()(const PCRefreshEvent& ev);
00164                 // </group>
00165 
00166                 // Functions called by the local event handling operators.  By
00167                 // default they do nothing, so a derived class needs only implement
00168                 // the events it cares about.
00169                 // <group>
00170                 virtual void keyPressed(const PCPositionEvent &ev);
00171                 virtual void keyReleased(const PCPositionEvent &ev);
00172                 virtual void otherKeyPressed(const PCPositionEvent &ev);
00173                 virtual void otherKeyReleased(const PCPositionEvent &ev);
00174                 virtual void moved(const PCMotionEvent &ev);
00175                 virtual void refresh(const PCRefreshEvent &ev);
00176                 // </group>
00177 
00178                 // Get the PixelCanvas to which this Tool is attached.
00179                 virtual PixelCanvas *pixelCanvas() const {
00180                         return itsPixelCanvas;
00181                 }
00182 
00183                 // Set/get which key to catch.
00184                 // <group>
00185                 virtual void setKey(const Display::KeySym &keysym);
00186                 virtual Display::KeySym getKey() const {
00187                         return itsKeySym;
00188                 }
00189                 // </group>
00190 
00191         protected:
00192 
00193                 // Indicate whether key is presently pressed.
00194                 virtual Bool keyPresentlyDown(const PCMotionEvent &ev);
00195 
00196         private:
00197 
00198                 // The PixelCanvas to which this is connected.
00199                 PixelCanvas *itsPixelCanvas;
00200 
00201                 // The key to handle.
00202                 Display::KeySym itsKeySym;
00203 
00204                 // The modifier mask for the key.
00205                 Display::KeyModifier itsKeyModifier;
00206 
00207                 // Whether the event handlers are currently registered.
00208                 Bool itsEventHandlersRegistered;
00209 
00210                 // The event handlers.
00211                 PCToolPosEH *itsPositionEH;
00212                 PCToolMotEH *itsMotionEH;
00213                 PCToolRefEH *itsRefreshEH;
00214 
00215         };
00216 
00217 
00218 } //# NAMESPACE CASA - END
00219 
00220 #endif
00221 
00222 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1