casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MWCCrosshairTool.h
Go to the documentation of this file.
1 //# MWCCrosshairTool.h: Base class for WorldCanvas event-based crosshair tools
2 //# Copyright (C) 1999,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 
27 #ifndef TRIALDISPLAY_MWCCROSSHAIRTOOL_H
28 #define TRIALDISPLAY_MWCCROSSHAIRTOOL_H
29 
30 #include <casa/aips.h>
33 
34 namespace casa { //# NAMESPACE CASA - BEGIN
35 
36  class WorldCanvas;
37 
38 // <summary>
39 // Base class for MultiWorldCanvas event-based crosshair tools.
40 // </summary>
41 //
42 // <use visibility=export>
43 //
44 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
45 // </reviewed>
46 //
47 // <prerequisites>
48 // <li> WCTool
49 // </prerequisites>
50 //
51 // <etymology>
52 // MWCCrosshairTool stands for MultiWorldCanvas Crosshair Tool.
53 // </etymology>
54 //
55 // <synopsis>
56 // This class adds to its base MWCTool to provide a tool for placing
57 // and moving a crosshair on a WorldCanvas. While MWCCrosshairTool is
58 // not abstract, it performs no useful function. The programmer
59 // should derive from this class, and override the crosshairReady function,
60 // which is called when the mouse button is pressed, moved, or released
61 // within a WC draw area where events are handled. The get() function then
62 // retrieves the crosshair position in screen pixels.
63 //
64 // The crosshair will track the mouse as long as it is within the WC draw
65 // area and the button is pressed.
66 // The persistent parameter determines whether the crosshair remains visible
67 // once the button is released.
68 // The crosshair is removed when it is dragged off the draw area or the
69 // Esc key is pressed within the WC.
70 // </synopsis>
71 //
72 // <example>
73 // </example>
74 //
75 // <motivation>
76 // Many activities on the WorldCanvas will be based on the user causing
77 // some action by placing or moving a crosshair.
78 // Emitted positions are to be caught by some external process or method.
79 // </motivation>
80 //
81 // <todo asof="1999/11/26">
82 // </todo>
83 
84  class MWCCrosshairTool : public MultiWCTool, public DTVisible {
85 
86  public:
87 
88  // Constructor specifies the button to respond to, and whether the
89  // crosshair should remain on screen after the button is released.
90  // Base class methods must also be called to register event handling
91  // for the desired WorldCanvas[es].
93  const casacore::Bool persistent = true);
94 
95  // Destructor.
96  virtual ~MWCCrosshairTool();
97 
98  // Retrieve the crosshair position in pixels. A derived crosshairReady()
99  // routine would use this.
100  virtual void get(casacore::Int &x, casacore::Int &y) const ;
101 
102  //Rectrive the crosshair position in Lin
103  virtual void getLin(casacore::Double &x, casacore::Double &y) const;
104 
105  //Rectrive the crosshair position in World
106  virtual void getWorld(casacore::Double &x, casacore::Double &y) const;
107 
108  // Switch the tool off: this calls the base class disable to turn off
109  // event handling, and then erases the crosshair if necessary.
110  virtual void disable();
111 
112  // set crosshair cursor type
113  virtual void setCross(casacore::Bool cross=false);
114 
115  // Reset to non-showing, non-active crosshair.
116  // Refreshes if necessary to erase (unless skipRefresh==true).
117  // (Does not unregister from WCs or disable future event handling).
118  virtual void reset(casacore::Bool skipRefresh=false);
119 
120  // handle events, via new-style interface. Currently just for reset event.
121  virtual void handleEvent(DisplayEvent& ev);
122 
123 
124  protected:
125 
126  // Functions called by the base class mouse/kbd event handling operators--
127  // and normally only those. This is the input that controls the crosshair's
128  // action. When the crosshair is ready (positioned on the draw area)
129  // the crosshairReady() routine is called.
130  // <group>
131  virtual void keyPressed(const WCPositionEvent &/*ev*/);
132  virtual void keyReleased(const WCPositionEvent &/*ev*/);
133  virtual void otherKeyPressed(const WCPositionEvent &/*ev*/);
134  virtual void moved(const WCMotionEvent &/*ev*/, const viewer::region::region_list_type & /*selected_regions*/);
135  // </group>
136 
137  // draw the crosshair on the object's currently active WC.
138  // Only to be called by the base class refresh event handler. Derived
139  // objects should use refresh() if they need to redraw, but even that
140  // is normally handled automatically.
141  virtual void draw(const WCRefreshEvent&/*ev*/, const viewer::region::region_list_type & /*selected_regions*/);
142 
143  // Called when the crosshair position has been chosen. Override to
144  // handle the crosshair-position-ready 'event'.
145  // evtype is "down" "move" or "up" depending on the state of the
146  // mouse leading to this event.
147  virtual void crosshairReady(const casacore::String& ) { };
148 
149  private:
150 
151  // Set the current position from pixel coordinates.
152  // To do: reset the tool when the WC CS (linToWorld) transformation
153  // changes. (There is a WorldCoordinateChange RefreshReason, but it is
154  // not currently used when WC CS/Coordinatehandlers are set/changed).
155  virtual void set(casacore::Int x, casacore::Int y);
156 
157  // the last crosshair position.
158  // (zooms will change pixel but not linear coordinates; therefore this
159  // position is stored in the latter).
162 
163  // should the crosshair remain visible after its button is released?
165 
166  // what is the crosshair radius? (screen pixels)
168 
169  // was the crosshair drawing visible after last refresh cycle?
171 
172  // should the crosshair be drawn when X,Y are in the zoom window?
174 
175  // draw crosshair
177 
178  // is the crosshair's button down? (true when the
179  // tool's button was pressed in a WC where it is handling events,
180  // and has not yet been released, or the tool reset).
182 
183  };
184 
185 
186 } //# NAMESPACE CASA - END
187 
188 #endif
189 
190 
int Int
Definition: aipstype.h:50
virtual void crosshairReady(const casacore::String &)
Called when the crosshair position has been chosen.
Class which stores WorldCanvas refresh event information.
virtual void getWorld(casacore::Double &x, casacore::Double &y) const
Rectrive the crosshair position in World.
virtual void set(casacore::Int x, casacore::Int y)
Set the current position from pixel coordinates.
virtual void setCross(casacore::Bool cross=false)
set crosshair cursor type
virtual void getLin(casacore::Double &x, casacore::Double &y) const
Rectrive the crosshair position in Lin.
virtual void keyReleased(const WCPositionEvent &)
casacore::Int itsRadius
what is the crosshair radius? (screen pixels)
virtual void draw(const WCRefreshEvent &, const viewer::region::region_list_type &)
draw the crosshair on the object&#39;s currently active WC.
virtual ~MWCCrosshairTool()
Destructor.
virtual void keyPressed(const WCPositionEvent &)
Functions called by the base class mouse/kbd event handling operators– and normally only those...
virtual void reset(casacore::Bool skipRefresh=false)
Reset to non-showing, non-active crosshair.
MWCCrosshairTool(Display::KeySym keysym=Display::K_Pointer_Button1, const casacore::Bool persistent=true)
Constructor specifies the button to respond to, and whether the crosshair should remain on screen aft...
casacore::Bool itsPersist
should the crosshair remain visible after its button is released?
Class which stores WorldCanvas motion event information.
Definition: WCMotionEvent.h:79
virtual void otherKeyPressed(const WCPositionEvent &)
double Double
Definition: aipstype.h:55
casacore::Bool itsShow
should the crosshair be drawn when X,Y are in the zoom window?
virtual void handleEvent(DisplayEvent &ev)
handle events, via new-style interface.
Class describing the most basic event information in the display classes.
Definition: DisplayEvent.h:82
virtual void disable()
Switch the tool off: this calls the base class disable to turn off event handling, and then erases the crosshair if necessary.
casacore::Bool itsCross
draw crosshair
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void moved(const WCMotionEvent &, const viewer::region::region_list_type &)
Class providing draw style settings for visible DisplayTools.
Definition: DTVisible.h:95
Class which stores WorldCanvas position event information.
Base class for MultiWorldCanvas event-based tools.
Definition: MultiWCTool.h:89
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Bool itsBtnDn
is the crosshair&#39;s button down? (true when the tool&#39;s button was pressed in a WC where it is handling...
casacore::Vector< casacore::Double > itsPos
the last crosshair position.
std::set< Region * > region_list_type
Definition: RegionEnums.h:14
KeySym
Keysyms for PixelCanvas keyboard events.
Definition: DisplayEnums.h:412
casacore::Vector< casacore::Double > itsWorld
Base class for MultiWorldCanvas event-based crosshair tools.
casacore::Bool itsShowing
was the crosshair drawing visible after last refresh cycle?