casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiWCTool.h
Go to the documentation of this file.
1 //# MultiWCTool.h: base class for MultiWorldCanvas event-based tools
2 //# Copyright (C) 2000,2001,2002
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_MULTIWCTOOL_H
29 #define TRIALDISPLAY_MULTIWCTOOL_H
30 
31 #include <list>
32 #include <casa/aips.h>
38 
39 namespace casa { //# NAMESPACE CASA - BEGIN
40 
41  class MultiWCTool;
42  class WorldCanvas;
43  class PixelCanvas;
44  class PanelDisplay;
45 
46 // <summary>
47 // Base class for MultiWorldCanvas event-based tools.
48 // </summary>
49 //
50 // <use visibility=export>
51 //
52 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
53 // </reviewed>
54 //
55 // <prerequisites>
56 // <li> WCPositionEH
57 // <li> WCMotionEH
58 // <li> WCRefreshEH
59 // </prerequisites>
60 //
61 // <etymology>
62 // MultiWCTool stands for MultiWorldCanvas Tool
63 // </etymology>
64 //
65 // <synopsis>
66 // This class is a base class upon which tools which respond to
67 // various events on a WorldCanvas can be built. It wraps up
68 // the position, motion and refresh events so that the programmer
69 // sees them all coming into one class, where they can be dealt
70 // with in a unified manner. MultiWCTool is not actually abstract,
71 // so the programmer need only write handlers for the events in
72 // which they are interested.
73 // </synopsis>
74 //
75 // <example>
76 // </example>
77 //
78 // <motivation>
79 // The majority of tools written for the WorldCanvas will fall
80 // into the category that this class serves: they respond to a
81 // single key or mouse button, and they potentially need to
82 // respond to position, motion and refresh events.
83 // </motivation>
84 //
85 // <todo asof="2000/07/12">
86 // <li> Nothing known
87 // </todo>
88 
89  class MultiWCTool : public DisplayTool,
90  public WCPositionEH,
91  public WCMotionEH,
92  public WCRefreshEH {
93 
94  public:
95 
96  // Constructor taking the primary key to which this tool will
97  // respond.
98  MultiWCTool(const Display::KeySym &keysym = Display::K_Pointer_Button1, bool enable_events=true );
99 
100  // Destructor.
101  virtual ~MultiWCTool();
102 
103  // Add/remove a WorldCanvas from the control of this tool.
104  // <group>
105  virtual void addWorldCanvas(WorldCanvas &worldcanvas);
106  virtual void removeWorldCanvas(WorldCanvas &worldcanvas);
107  // </group>
108 
109  // Add/Remove a list of WorldCanvases from PanelDisplay
110  // <group>
111  virtual void addWorldCanvases(PanelDisplay* pdisp);
112  virtual void removeWorldCanvases(PanelDisplay* pdisp);
113  // </group>
114 
115  // Switch the tool on/off - this simply registers or unregisters
116  // the event handlers on the WorldCanvases.
117  // <group>
118  virtual void enable();
119  virtual void disable();
120  // </group>
121 
122  // Required operators for event handling - these are called when
123  // events occur, and distribute the events to the "user-level"
124  // methods
125  // <group>
126  virtual void operator()(const WCPositionEvent& ev);
127  virtual void operator()(const WCMotionEvent& ev);
128  virtual void operator()(const WCRefreshEvent& ev);
129  // </group>
130 
131  // Derived classes should implement this to return to the non-showing,
132  // non-active state. It should not unregister the tool from WCs or
133  // disable event handling. If skipRefresh is false and the tool was showing,
134  // it also calls refresh() to erase. (The caller should set skipRefresh=true
135  // (only) if it will handle refresh itself).
136  virtual void reset(casacore::Bool /*skipRefresh*/=false) { }
137 
138  protected:
139 
140  // Functions called by the local event handling operators -
141  // by default they do nothing, so a derived class needs only
142  // implement the events it cares about
143  // <group>
144  virtual void keyPressed(const WCPositionEvent &/*ev*/);
145  virtual void keyReleased(const WCPositionEvent &/*ev*/);
146  virtual void otherKeyPressed(const WCPositionEvent &/*ev*/);
147  virtual void otherKeyReleased(const WCPositionEvent &/*ev*/);
148  virtual void moved(const WCMotionEvent & /*ev*/, const viewer::region::region_list_type & /*selected_regions*/);
149  virtual void updateRegion() {}
150  virtual void clicked(casacore::Int /*x*/, casacore::Int /*y*/) {}
151  virtual void doubleClicked(casacore::Int /*x*/, casacore::Int /*y*/) {}
152  // </group>
153 
154  // Draw whatever should be drawn (if anything) on current WC.
155  // Should only be called by refresh event handler.
156  virtual void draw(const WCRefreshEvent&/*ev*/, const viewer::region::region_list_type & /*selected_regions*/);
157 
158  // Copy back-to-front buffer (erasing all MWCTool drawings),
159  // then cause this (and all MWCTools on current WC's PC)
160  // to draw (or not draw) themselves, according to their
161  // current state. Mouse and kbd event handlers within the tools
162  // now call this in response to drawing state changes, rather than
163  // calling draw() directly, so that only valid tool drawings are
164  // displayed, even when more than one is active. NB: the meaning of
165  // this routine has changed to be more in line with the rest of the DL
166  // (i.e., it now causes, rather than responds to, refresh events).
167  virtual void refresh();
168 
169  // Cause subsequent drawing commands to be clipped to the current WC
170  // (or its drawing area). Be sure to reset when finished drawing;
171  // clipping will apply to drawing on entire PC.
172  // <group>
173  virtual void setClipToDrawArea();
174  virtual void setClipToWC();
175  virtual void resetClip();
176  // </group>
177 
178  // WC being (or to be) drawn on (may be 0 initially). WC where latest
179  // relevant input event was received.
181 
182  private:
183 
184  // copy, default constructors (do not use)
185  // <group>
186  MultiWCTool();
187  MultiWCTool(const MultiWCTool &other);
188  MultiWCTool &operator=(const MultiWCTool &other);
189  // </group>
190 
191  // The WorldCanvases to which this tool is connected.
192  friend class MWCRTZoomer;
193  friend class MWCPannerTool;
194  std::list<WorldCanvas*> itsWCList;
195 
196  // whether the event handlers are registered
198 
199  };
200 
201 
202 } //# NAMESPACE CASA - END
203 
204 #endif
virtual void otherKeyReleased(const WCPositionEvent &)
Multi WorldCanvas event-based zoomer.
Definition: MWCRTZoomer.h:72
int Int
Definition: aipstype.h:50
virtual void moved(const WCMotionEvent &, const viewer::region::region_list_type &)
Class which stores WorldCanvas refresh event information.
virtual void keyReleased(const WCPositionEvent &)
Base class for handling WorldCanvas motion events.
Definition: WCMotionEH.h:70
virtual void addWorldCanvases(PanelDisplay *pdisp)
Add/Remove a list of WorldCanvases from PanelDisplay.
virtual void clicked(casacore::Int, casacore::Int)
Definition: MultiWCTool.h:150
std::list< WorldCanvas * > itsWCList
Definition: MultiWCTool.h:194
virtual void removeWorldCanvases(PanelDisplay *pdisp)
virtual void doubleClicked(casacore::Int, casacore::Int)
Definition: MultiWCTool.h:151
virtual void enable()
Switch the tool on/off - this simply registers or unregisters the event handlers on the WorldCanvases...
Base class for handling WorldCanvas refresh events.
Definition: WCRefreshEH.h:95
WorldCanvas * itsCurrentWC
WC being (or to be) drawn on (may be 0 initially).
Definition: MultiWCTool.h:180
Base class for event-based tools in the display classes.
Definition: DisplayTool.h:74
Class which stores WorldCanvas motion event information.
Definition: WCMotionEvent.h:79
virtual void operator()(const WCPositionEvent &ev)
Required operators for event handling - these are called when events occur, and distribute the events...
MultiWCTool & operator=(const MultiWCTool &other)
MultiWCTool()
copy, default constructors (do not use)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void setClipToWC()
virtual void setClipToDrawArea()
Cause subsequent drawing commands to be clipped to the current WC (or its drawing area)...
virtual void addWorldCanvas(WorldCanvas &worldcanvas)
Add/remove a WorldCanvas from the control of this tool.
virtual void refresh()
Copy back-to-front buffer (erasing all MWCTool drawings), then cause this (and all MWCTools on curren...
virtual void disable()
virtual void resetClip()
Class which stores WorldCanvas position event information.
virtual ~MultiWCTool()
Destructor.
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
virtual void reset(casacore::Bool=false)
Derived classes should implement this to return to the non-showing, non-active state.
Definition: MultiWCTool.h:136
A class which creates and manages &quot;panelled&quot; displays.
Definition: PanelDisplay.h:79
Base class for MultiWorldCanvas event-based tools.
Definition: MultiWCTool.h:89
virtual void updateRegion()
Definition: MultiWCTool.h:149
Base class for handling WorldCanvas position events.
Definition: WCPositionEH.h:75
std::set< Region * > region_list_type
Definition: RegionEnums.h:14
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.
KeySym
Keysyms for PixelCanvas keyboard events.
Definition: DisplayEnums.h:412
virtual void removeWorldCanvas(WorldCanvas &worldcanvas)
virtual void draw(const WCRefreshEvent &, const viewer::region::region_list_type &)
Draw whatever should be drawn (if anything) on current WC.
virtual void otherKeyPressed(const WCPositionEvent &)
casacore::Bool itsEventHandlersRegistered
whether the event handlers are registered
Definition: MultiWCTool.h:197