casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WCCrosshairTool.h
Go to the documentation of this file.
1 //# WCCrosshairTool.h: Base class for WorldCanvas event-based crosshair 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_WCCROSSHAIRTOOL_H
29 #define TRIALDISPLAY_WCCROSSHAIRTOOL_H
30 
31 #include <casa/aips.h>
34 
35 namespace casa { //# NAMESPACE CASA - BEGIN
36 
37 // <summary>
38 // Base class for WorldCanvas event-based crosshair tools.
39 // </summary>
40 //
41 // <use visibility=export>
42 //
43 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
44 // </reviewed>
45 //
46 // <prerequisites>
47 // <li> WCTool
48 // </prerequisites>
49 //
50 // <etymology>
51 // WCCrosshairTool stands for WorldCanvas Crosshair Tool.
52 // </etymology>
53 //
54 // <synopsis>
55 // This class adds to its base WCTool to provide a tool for placing
56 // and moving a crosshair on a WorldCanvas. While WCCrosshairTool is
57 // not abstract, it performs no useful function. The programmer
58 // should derive from this class, and override the functions
59 // doubleInside and doubleOutside, which are called when the user
60 // double-clicks the key or mouse button inside or outside the
61 // existing crosshair respectively. It is up to the programmer to
62 // decide what double clicks inside and outside the crosshair
63 // correspond to, although it is recommended that a double click
64 // inside correspond to the main action of the tool (eg. emitting the
65 // current position to an outside controller), and a double click
66 // outside correspond to a secondary action of the tool, if indeed a
67 // secondary action exists.
68 //
69 // The crosshair is drawn by simply clicking at the location the
70 // crosshair should be placed. Once constructed, the crosshair can be
71 // relocated by dragging inside the crosshair. The crosshair is
72 // removed from the display when the Esc key is pressed.
73 // </synopsis>
74 //
75 // <example>
76 // </example>
77 //
78 // <motivation>
79 // Many activities on the WorldCanvas will be based on the user placing
80 // a crosshair, and then proceeding to some action with that crosshair.
81 // A nice example is emitting positions to be caught by some external
82 // controlling process.
83 // </motivation>
84 //
85 // <todo asof="1999/11/26">
86 // </todo>
87 
88  class WCCrosshairTool : public WCTool, public DTVisible {
89 
90  public:
91 
92  // Constructor requires a WorldCanvas to operate on, and optional
93  // specifications of the key to respond to, and whether the
94  // crosshair should be persistent. A persistent crosshair will
95  // "stick around" after a double click action.
98  const casacore::Bool persistent = true);
99 
100  // Destructor.
101  virtual ~WCCrosshairTool();
102 
103  // Switch the tool off: this calls the base class disable, and then
104  // erases the crosshair if necessary.
105  virtual void disable();
106 
107  // Functions called by the local event handling operators - these
108  // handle the drawing of the crosshair. In special conditions,
109  // namely double clicking the key, they will pass control on to the
110  // doubleInside and doubleOutside functions.
111  // <group>
112  virtual void keyPressed(const WCPositionEvent &/*ev*/);
113  virtual void keyReleased(const WCPositionEvent &/*ev*/);
114  virtual void otherKeyPressed(const WCPositionEvent &/*ev*/);
115  virtual void moved(const WCMotionEvent &/*ev*/, const viewer::region::region_list_type & /*selected_regions*/);
116  virtual void refresh(const WCRefreshEvent &/*ev*/);
117  // </group>
118 
119  // Functions special to the crosshair event handling: called when
120  // there is a double click inside or outside the crosshair.
121  // <group>
122  virtual void doubleInside() { };
123  virtual void doubleOutside() { };
124  // </group>
125 
126  // Functions called when the crosshair is ready and not being
127  // editted, and when this status changes.
128  // <group>
129  virtual void crosshairReady() { };
130  virtual void crosshairNotReady() { };
131  // </group>
132 
133  // Retrieve the crosshair position.
134  virtual void get(casacore::Int &x1, casacore::Int &y1) const ;
135 
136  private:
137 
138  // does the crosshair persist after double clicks?
140 
141  // what radius is the crosshair? in pixels
143 
144  // is the crosshair on screen?
146 
147  // is some activity taking place with the crosshair?
149 
150  // has the crosshair been moved?
152 
153  // do we have a crosshair drawn yet?
155 
156  // adjustment mode
157  enum AdjustMode {
160  };
162 
163  // coordinates of the crosshair: pixel and world
164  // <group>
167  // </group>
168 
169  // set the coordinates of the crosshair
170  // <group>
171  virtual void set(const casacore::Int &x1, const casacore::Int &y1);
172  // </group>
173 
174  // set/get only the anchor point
175  // <group>
176  //virtual void set(const casacore::Int &x1, const casacore::Int &y1);
177  //virtual void get(casacore::Int &x1, casacore::Int &y1) const ;
178  // </group>
179 
180  // preserve/restore the world coordinates
181  // <group>
182  virtual void preserve();
183  virtual void restore();
184  // </group>
185 
186  // draw the crosshair on the WorldCanvas' PixelCanvas.
187  virtual void draw(const casacore::Bool drawHandles = false);
188 
189  // reset this drawer
190  virtual void reset();
191 
192  // position that move started from
194 
195  // position of last press event
198 
199  // position of last release event
201 
202  // store the times of the last two presses here:
204 
205  };
206 
207 
208 } //# NAMESPACE CASA - END
209 
210 #endif
211 
212 
int Int
Definition: aipstype.h:50
Base class for WorldCanvas event-based tools.
Definition: WCTool.h:141
WCCrosshairTool::AdjustMode itsAdjustMode
virtual void otherKeyPressed(const WCPositionEvent &)
Class which stores WorldCanvas refresh event information.
casacore::Int itsBaseMoveY
casacore::Int itsLastReleaseY
casacore::Double its2ndLastPressTime
casacore::Int itsLastReleaseX
position of last release event
casacore::Int its2ndLastPressX
casacore::Bool itsCrosshairPersistent
does the crosshair persist after double clicks?
virtual void crosshairReady()
Functions called when the crosshair is ready and not being editted, and when this status changes...
AdjustMode
adjustment mode
virtual void preserve()
set/get only the anchor point
casacore::Bool itsMoved
has the crosshair been moved?
virtual void reset()
reset this drawer
virtual void refresh(const WCRefreshEvent &)
Base class for WorldCanvas event-based crosshair tools.
virtual ~WCCrosshairTool()
Destructor.
WCCrosshairTool(WorldCanvas *wcanvas, Display::KeySym keysym=Display::K_Pointer_Button1, const casacore::Bool persistent=true)
Constructor requires a WorldCanvas to operate on, and optional specifications of the key to respond t...
virtual void keyPressed(const WCPositionEvent &)
Functions called by the local event handling operators - these handle the drawing of the crosshair...
casacore::Bool itsOnScreen
is the crosshair on screen?
Class which stores WorldCanvas motion event information.
Definition: WCMotionEvent.h:79
virtual void restore()
double Double
Definition: aipstype.h:55
virtual void draw(const casacore::Bool drawHandles=false)
draw the crosshair on the WorldCanvas&#39; PixelCanvas.
virtual void keyReleased(const WCPositionEvent &)
casacore::Int itsLastPressY
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void set(const casacore::Int &x1, const casacore::Int &y1)
set the coordinates of the crosshair
virtual void moved(const WCMotionEvent &, const viewer::region::region_list_type &)
casacore::Bool itsCrosshairExists
do we have a crosshair drawn yet?
Class providing draw style settings for visible DisplayTools.
Definition: DTVisible.h:95
Class which stores WorldCanvas position event information.
virtual void disable()
Switch the tool off: this calls the base class disable, and then erases the crosshair if necessary...
casacore::Bool itsActive
is some activity taking place with the crosshair?
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
casacore::Int itsBaseMoveX
position that move started from
casacore::Int its2ndLastPressY
casacore::Int itsCrosshairRadius
what radius is the crosshair? in pixels
virtual void doubleInside()
Functions special to the crosshair event handling: called when there is a double click inside or outs...
std::set< Region * > region_list_type
Definition: RegionEnums.h:14
casacore::Int itsX1
coordinates of the crosshair: pixel and world
KeySym
Keysyms for PixelCanvas keyboard events.
Definition: DisplayEnums.h:412
virtual void crosshairNotReady()
casacore::Double itsLastPressTime
store the times of the last two presses here:
casacore::Int itsLastPressX
position of last press event
casacore::Vector< casacore::Double > itsStoredWorldPosition
virtual void doubleOutside()