casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PCTool.h
Go to the documentation of this file.
1 //# PCTool.h: base class for PixelCanvas event-based tools
2 //# Copyright (C) 1999,2000
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef TRIALDISPLAY_PCTOOL_H
29 #define TRIALDISPLAY_PCTOOL_H
30 
31 #include <casa/aips.h>
35 
36 namespace casa { //# NAMESPACE CASA - BEGIN
37 
38  class PCTool;
39  class PixelCanvas;
40 
41 // <summary>
42 // PixelCanvas position event handler for PCTool.
43 // </summary>
44 //
45 // <synopsis>
46 // This class is a simple implementation of a PCPositionEH which
47 // passes PixelCanvas position events on to a single PCTool.
48 // </synopsis>
49 
50  class PCToolPosEH : public PCPositionEH {
51  public:
52  PCToolPosEH(PCTool *tool);
53  virtual ~PCToolPosEH() {};
54  virtual void operator()(const PCPositionEvent& ev);
55  private:
57  };
58 
59 // <summary>
60 // PixelCanvas motion event handler for PCTool.
61 // </summary>
62 //
63 // <synopsis>
64 // This class is a simple implementation of a PCMotionEH which
65 // passes PixelCanvas motion events on to a single PCTool.
66 // </synopsis>
67 
68  class PCToolMotEH : public PCMotionEH {
69  public:
70  PCToolMotEH(PCTool *tool);
71  virtual ~PCToolMotEH() {};
72  virtual void operator()(const PCMotionEvent& ev);
73  private:
75  };
76 
77 // <summary>
78 // PixelCanvas refresh event handler for PCTool.
79 // </summary>
80 //
81 // <synopsis>
82 // This class is a simple implementation of a PCRefreshEH which
83 // passes PixelCanvas refresh events on to a single PCTool.
84 // </synopsis>
85 
86  class PCToolRefEH : public PCRefreshEH {
87  public:
88  PCToolRefEH(PCTool *tool);
89  virtual ~PCToolRefEH() {};
90  virtual void operator()(const PCRefreshEvent& ev);
91  private:
93  };
94 
95 // <summary>
96 // Base class for PixelCanvas event-based tools.
97 // </summary>
98 
99 // <use visibility=export>
100 
101 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
102 // </reviewed>
103 
104 // <prerequisites>
105 // <li> PCPositionEH
106 // <li> PCMotionEH
107 // <li> PCRefreshEH
108 // </prerequisites>
109 
110 // <etymology>
111 // PCTool stands for PixelCanvas Tool.
112 // </etymology>
113 
114 // <synopsis>
115 // This class is a base class upon which tools which respond to
116 // various events on a PixelCanvas can be built. It wraps up
117 // the position, motion and refresh events so that the programmer
118 // sees them all coming into one class, where they can be dealt
119 // with in a unified manner. PCTool is not actually abstract,
120 // so the programmer need only write handlers for the events in
121 // which they are interested.
122 // </synopsis>
123 
124 // <example>
125 // </example>
126 
127 // <motivation>
128 // The majority of tools written for the PixelCanvas will fall
129 // into the category that this class serves: they respond to a
130 // single key or mouse button, and they potentially need to
131 // respond to position, motion and refresh events.
132 // </motivation>
133 
134 // <todo asof="1999/10/09">
135 // <li> Nothing known
136 // </todo>
137 
138  class PCTool {
139 
140  public:
141 
142  // Constructor. A PixelCanvas to attach to must be specified,
143  // and normally a key to respond to as well.
144  PCTool(PixelCanvas *pcanvas,
146 
147  // Destructor.
148  virtual ~PCTool();
149 
150  // Switch the tool on/off. This simply registers or unregisters the
151  // event handlers.
152  // <group>
153  virtual void enable();
154  virtual void disable();
155  // </group>
156 
157  // Required operators for event handling. These are called when
158  // events occur, and distribute the events to the "user-level"
159  // methods.
160  // <group>
161  virtual void operator()(const PCPositionEvent& ev);
162  virtual void operator()(const PCMotionEvent& ev);
163  virtual void operator()(const PCRefreshEvent& ev);
164  // </group>
165 
166  // Functions called by the local event handling operators. By
167  // default they do nothing, so a derived class needs only implement
168  // the events it cares about.
169  // <group>
170  virtual void keyPressed(const PCPositionEvent &ev);
171  virtual void keyReleased(const PCPositionEvent &ev);
172  virtual void otherKeyPressed(const PCPositionEvent &ev);
173  virtual void otherKeyReleased(const PCPositionEvent &ev);
174  virtual void moved(const PCMotionEvent &ev);
175  virtual void refresh(const PCRefreshEvent &ev);
176  // </group>
177 
178  // Get the PixelCanvas to which this Tool is attached.
179  virtual PixelCanvas *pixelCanvas() const {
180  return itsPixelCanvas;
181  }
182 
183  // Set/get which key to catch.
184  // <group>
185  virtual void setKey(const Display::KeySym &keysym);
186  virtual Display::KeySym getKey() const {
187  return itsKeySym;
188  }
189  // </group>
190 
191  protected:
192 
193  // Indicate whether key is presently pressed.
194  virtual casacore::Bool keyPresentlyDown(const PCMotionEvent &ev);
195 
196  private:
197 
198  // The PixelCanvas to which this is connected.
200 
201  // The key to handle.
203 
204  // The modifier mask for the key.
206 
207  // Whether the event handlers are currently registered.
209 
210  // The event handlers.
214 
215  };
216 
217 
218 } //# NAMESPACE CASA - END
219 
220 #endif
221 
222 
PCToolMotEH * itsMotionEH
Definition: PCTool.h:212
virtual void refresh(const PCRefreshEvent &ev)
virtual void operator()(const PCPositionEvent &ev)
Required operators for event handling.
WorldCanvas Event Handler for managing events.
Definition: PCRefreshEH.h:76
virtual void keyReleased(const PCPositionEvent &ev)
PCToolRefEH(PCTool *tool)
PCToolMotEH(PCTool *tool)
virtual void keyPressed(const PCPositionEvent &ev)
Functions called by the local event handling operators.
PCTool(PixelCanvas *pcanvas, Display::KeySym keysym=Display::K_Pointer_Button1)
Constructor.
virtual void enable()
Switch the tool on/off.
virtual void operator()(const PCMotionEvent &ev)
Default just prints the event to cout.
virtual void setKey(const Display::KeySym &keysym)
Set/get which key to catch.
PixelCanvas motion event handler for PCTool.
Definition: PCTool.h:68
Class which stores PixelCanvas motion event information.
Definition: PCMotionEvent.h:82
virtual ~PCToolRefEH()
Definition: PCTool.h:89
virtual void moved(const PCMotionEvent &ev)
virtual void operator()(const PCPositionEvent &ev)
Default just prints the event to cout.
virtual ~PCToolMotEH()
Definition: PCTool.h:71
Base class defining interface to pixel-based output devices.
Definition: PixelCanvas.h:161
virtual ~PCToolPosEH()
Definition: PCTool.h:53
Class which stores PixelCanvas refresh event information.
Display::KeySym itsKeySym
The key to handle.
Definition: PCTool.h:202
virtual void disable()
PixelCanvas position event handler for PCTool.
Definition: PCTool.h:50
PCTool * itsTool
Definition: PCTool.h:92
Display::KeyModifier itsKeyModifier
The modifier mask for the key.
Definition: PCTool.h:205
PCToolPosEH(PCTool *tool)
virtual ~PCTool()
Destructor.
casacore::Bool itsEventHandlersRegistered
Whether the event handlers are currently registered.
Definition: PCTool.h:208
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
PixelCanvas refresh event handler for PCTool.
Definition: PCTool.h:86
PixelCanvas Event Handler for managing keyboard and mouse button events.
Definition: PCPositionEH.h:74
PCTool * itsTool
Definition: PCTool.h:56
virtual PixelCanvas * pixelCanvas() const
Get the PixelCanvas to which this Tool is attached.
Definition: PCTool.h:179
PCToolRefEH * itsRefreshEH
Definition: PCTool.h:213
KeyModifier
All events - modifier codes.
Definition: DisplayEnums.h:368
Class which stores PixelCanvas position event information.
virtual void otherKeyReleased(const PCPositionEvent &ev)
PCTool * itsTool
Definition: PCTool.h:74
Base class for PixelCanvas event-based tools.
Definition: PCTool.h:138
virtual void otherKeyPressed(const PCPositionEvent &ev)
virtual Display::KeySym getKey() const
Definition: PCTool.h:186
PCToolPosEH * itsPositionEH
The event handlers.
Definition: PCTool.h:211
PixelCanvas Event Handler for managing pointer motion events.
Definition: PCMotionEH.h:72
virtual casacore::Bool keyPresentlyDown(const PCMotionEvent &ev)
Indicate whether key is presently pressed.
KeySym
Keysyms for PixelCanvas keyboard events.
Definition: DisplayEnums.h:412
virtual void operator()(const PCRefreshEvent &ev)
Default just prints the event to cout.
PixelCanvas * itsPixelCanvas
The PixelCanvas to which this is connected.
Definition: PCTool.h:199