casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WCTool.h
Go to the documentation of this file.
1 //# WCTool.h: base class for WorldCanvas 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_WCTOOL_H
29 #define TRIALDISPLAY_WCTOOL_H
30 
31 #include <casa/aips.h>
37 
38 namespace casa { //# NAMESPACE CASA - BEGIN
39 
40  class WCTool;
41  class WorldCanvas;
42  class PixelCanvas;
43 
44 // <summary>
45 // WorldCanvas position event handler for WCTool.
46 // </summary>
47 //
48 // <synopsis>
49 // This class is a simple implementation of a WCPositionEH which
50 // passes WorldCanvas position events on to a single WCTool.
51 // </synopsis>
52 
53  class WCToolPosEH : public WCPositionEH {
54  public:
55  WCToolPosEH(WCTool *tool);
56  virtual ~WCToolPosEH() {};
57  virtual void operator()(const WCPositionEvent& ev);
58  private:
60  };
61 
62 // <summary>
63 // WorldCanvas motion event handler for WCTool.
64 // </summary>
65 //
66 // <synopsis>
67 // This class is a simple implementation of a WCMotionEH which
68 // passes WorldCanvas motion events on to a single WCTool.
69 // </synopsis>
70 
71  class WCToolMotEH : public WCMotionEH {
72  public:
73  WCToolMotEH(WCTool *tool);
74  virtual ~WCToolMotEH() {};
75  virtual void operator()(const WCMotionEvent& ev);
76  private:
78  };
79 
80 // <summary>
81 // WorldCanvas refresh event handler for WCTool.
82 // </summary>
83 //
84 // <synopsis>
85 // This class is a simple implementation of a WCRefreshEH which
86 // passes WorldCanvas refresh events on to a single WCTool.
87 // </synopsis>
88 
89  class WCToolRefEH : public WCRefreshEH {
90  public:
91  WCToolRefEH(WCTool *tool);
92  virtual ~WCToolRefEH() {};
93  virtual void operator()(const WCRefreshEvent& ev);
94  private:
96  };
97 
98 // <summary>
99 // Base class for WorldCanvas event-based tools.
100 // </summary>
101 
102 // <use visibility=export>
103 
104 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
105 // </reviewed>
106 
107 // <prerequisites>
108 // <li> WCPositionEH
109 // <li> WCMotionEH
110 // <li> WCRefreshEH
111 // </prerequisites>
112 
113 // <etymology>
114 // WCTool stands for WorldCanvas Tool
115 // </etymology>
116 
117 // <synopsis>
118 // This class is a base class upon which tools which respond to
119 // various events on a WorldCanvas can be built. It wraps up
120 // the position, motion and refresh events so that the programmer
121 // sees them all coming into one class, where they can be dealt
122 // with in a unified manner. WCTool is not actually abstract,
123 // so the programmer need only write handlers for the events in
124 // which they are interested.
125 // </synopsis>
126 
127 // <example>
128 // </example>
129 
130 // <motivation>
131 // The majority of tools written for the WorldCanvas will fall
132 // into the category that this class serves: they respond to a
133 // single key or mouse button, and they potentially need to
134 // respond to position, motion and refresh events.
135 // </motivation>
136 
137 // <todo asof="1999/10/18">
138 // <li> Nothing known
139 // </todo>
140 
141  class WCTool : public DisplayTool {
142 
143  public:
144 
145  // Constructor taking a pointer to a WorldCanvas to which this tool
146  // will attach, and a primary key to respond to.
147  WCTool(WorldCanvas *wcanvas,
149 
150  // Destructor.
151  virtual ~WCTool();
152 
153  // Switch the tool on/off - this simply registers or unregisters
154  // the event handlers
155  // <group>
156  virtual void enable();
157  virtual void disable();
158  // </group>
159 
160  // Required operators for event handling - these are called when
161  // an events occur, and distribute the events to the "user-level"
162  // methods
163  // <group>
164  virtual void operator()(const WCPositionEvent& ev);
165  virtual void operator()(const WCMotionEvent& ev);
166  virtual void operator()(const WCRefreshEvent& ev);
167  // </group>
168 
169  // Functions called by the local event handling operators -
170  // by default they do nothing, so a derived class needs only
171  // implement the events it cares about
172  // <group>
173  virtual void keyPressed(const WCPositionEvent &/*ev*/);
174  virtual void keyReleased(const WCPositionEvent &/*ev*/);
175  virtual void otherKeyPressed(const WCPositionEvent &/*ev*/);
176  virtual void otherKeyReleased(const WCPositionEvent &/*ev*/);
177  virtual void moved(const WCMotionEvent &/*ev*/, const viewer::region::region_list_type & /*selected_regions*/);
178  virtual void refresh(const WCRefreshEvent &/*ev*/);
179  // </group>
180 
181  // Get the WorldCanvas that this Tool is attached to
182  virtual WorldCanvas *worldCanvas() const {
183  return itsWorldCanvas;
184  }
185 
186  // Get the PixelCanvas that this Tool is attached to via its WorldCanvas
187  virtual PixelCanvas *pixelCanvas() const {
188  return itsPixelCanvas;
189  }
190 
191  protected:
192 
193  // (Required) default constructor.
194  WCTool();
195 
196  // (Required) copy constructor.
197  WCTool(const WCTool &other);
198 
199  // (Required) copy assignment.
200  WCTool &operator=(const WCTool &other);
201 
202  private:
203 
204  // The WorldCanvas to which this is connected
206 
207  // The PixelCanvas to which this is connected via the WorldCanvas
209 
210  // whether the event handlers are registered
212 
213  // event handlers:
217 
218  };
219 
220 
221 } //# NAMESPACE CASA - END
222 
223 #endif
224 
225 
WCTool * itsTool
Definition: WCTool.h:95
WCTool * itsTool
Definition: WCTool.h:77
WCToolMotEH(WCTool *tool)
Base class for WorldCanvas event-based tools.
Definition: WCTool.h:141
casacore::Bool itsEventHandlersRegistered
whether the event handlers are registered
Definition: WCTool.h:211
Class which stores WorldCanvas refresh event information.
virtual void keyPressed(const WCPositionEvent &)
Functions called by the local event handling operators - by default they do nothing, so a derived class needs only implement the events it cares about.
virtual void moved(const WCMotionEvent &, const viewer::region::region_list_type &)
virtual PixelCanvas * pixelCanvas() const
Get the PixelCanvas that this Tool is attached to via its WorldCanvas.
Definition: WCTool.h:187
Base class for handling WorldCanvas motion events.
Definition: WCMotionEH.h:70
WCToolRefEH(WCTool *tool)
WorldCanvas refresh event handler for WCTool.
Definition: WCTool.h:89
WCToolMotEH * itsMotionEH
Definition: WCTool.h:215
WCTool()
(Required) default constructor.
virtual void refresh(const WCRefreshEvent &)
virtual void operator()(const WCPositionEvent &ev)
Default just prints the event to cout.
virtual void enable()
Switch the tool on/off - this simply registers or unregisters the event handlers. ...
WCToolPosEH * itsPositionEH
event handlers:
Definition: WCTool.h:214
Base class defining interface to pixel-based output devices.
Definition: PixelCanvas.h:161
virtual void operator()(const WCRefreshEvent &ev)
original handler interface (still used for WCRefreshEvents)
Base class for handling WorldCanvas refresh events.
Definition: WCRefreshEH.h:95
WCTool & operator=(const WCTool &other)
(Required) copy assignment.
WCTool * itsTool
Definition: WCTool.h:59
virtual void otherKeyPressed(const WCPositionEvent &)
Base class for event-based tools in the display classes.
Definition: DisplayTool.h:74
virtual WorldCanvas * worldCanvas() const
Get the WorldCanvas that this Tool is attached to.
Definition: WCTool.h:182
Class which stores WorldCanvas motion event information.
Definition: WCMotionEvent.h:79
virtual void otherKeyReleased(const WCPositionEvent &)
PixelCanvas * itsPixelCanvas
The PixelCanvas to which this is connected via the WorldCanvas.
Definition: WCTool.h:208
virtual ~WCToolMotEH()
Definition: WCTool.h:74
virtual void disable()
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
WCToolPosEH(WCTool *tool)
WorldCanvas * itsWorldCanvas
The WorldCanvas to which this is connected.
Definition: WCTool.h:205
WorldCanvas position event handler for WCTool.
Definition: WCTool.h:53
virtual ~WCTool()
Destructor.
Class which stores WorldCanvas position event information.
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
virtual ~WCToolPosEH()
Definition: WCTool.h:56
virtual void keyReleased(const WCPositionEvent &)
Base class for handling WorldCanvas position events.
Definition: WCPositionEH.h:75
std::set< Region * > region_list_type
Definition: RegionEnums.h:14
WCToolRefEH * itsRefreshEH
Definition: WCTool.h:216
KeySym
Keysyms for PixelCanvas keyboard events.
Definition: DisplayEnums.h:412
virtual void operator()(const WCPositionEvent &ev)
Required operators for event handling - these are called when an events occur, and distribute the eve...
virtual ~WCToolRefEH()
Definition: WCTool.h:92
WorldCanvas motion event handler for WCTool.
Definition: WCTool.h:71
virtual void operator()(const WCMotionEvent &ev)
default sends event to cout