casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WCRectTool.h
Go to the documentation of this file.
1 //# WCRectTool.h: Base class for WorldCanvas event-based rectangle 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_WCRECTTOOL_H
29 #define TRIALDISPLAY_WCRECTTOOL_H
30 
31 #include <casa/aips.h>
34 
35 namespace casa { //# NAMESPACE CASA - BEGIN
36 
37 // <summary>
38 // Base class for WorldCanvas event-based rectangle 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 // WCRectTool stands for WorldCanvas Rectangle Tool
52 // </etymology>
53 //
54 // <synopsis>
55 // This class adds to its base WCTool to provide a tool for drawing,
56 // resizing and moving rectangles on a WorldCanvas. While WCRectTool
57 // is not abstract, it performs no useful function. The programmer
58 // should derive from this class, and implement the functions
59 // doubleInside and doubleOutside, which are called when the user
60 // double-clicks the key or mouse button inside or outside an existing
61 // rectangle respectively. It is up to the programmer to decide what
62 // double clicks inside and outside the rectangle correspond to,
63 // although it is recommended that a double click inside correspond to
64 // the main action of the tool, and a double click outside correspond
65 // to a secondary action of the tool, if indeed a secondary action
66 // exists.
67 //
68 // The rectangle is drawn by dragging the mouse from one corner to
69 // the diagonally opposite corner. Once constructed, the rectangle
70 // can be resized by dragging its corners, or relocated by dragging
71 // inside the rectangle. The rectangle is removed from the display
72 // 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 drawing
80 // a rectangle, and then proceeding to some action with that rectangle.
81 // A nice example is zooming.
82 // </motivation>
83 //
84 // <todo asof="1999/07/23">
85 // <li> Add time constraint to double click detection
86 // </todo>
87 
88  class WCRectTool : public WCTool, public DTVisible {
89 
90  public:
91 
92  // Constructor
93  WCRectTool(WorldCanvas *wcanvas,
95  const casacore::Bool persistent = false);
96 
97  // Destructor
98  virtual ~WCRectTool();
99 
100  // Switch the tool off - this calls the base class disable, and
101  // then erases the rectangle if it's around
102  virtual void disable();
103 
104  // Functions called by the local event handling operators -
105  // these handle the drawing of the rectangle. In special
106  // conditions, namely double clicking the key, they will
107  // pass control on to the doubleInside and doubleOutside
108  // functions
109  // <group>
110  virtual void keyPressed(const WCPositionEvent &ev);
111  virtual void keyReleased(const WCPositionEvent &ev);
112  virtual void otherKeyPressed(const WCPositionEvent &ev);
113  virtual void moved(const WCMotionEvent &ev, const viewer::region::region_list_type & /*selected_regions*/);
114  virtual void refresh(const WCRefreshEvent &ev);
115  // </group>
116 
117  // Functions special to the rectangle event handling - called when
118  // there is a double click inside/outside the rectangle
119  // <group>
120  virtual void doubleInside() { };
121  virtual void doubleOutside() { };
122  // </group>
123 
124  // Functions called when a rectangle is ready and not being
125  // editted, and when this status changes
126  // <group>
127  virtual void rectangleReady() { };
128  virtual void rectangleNotReady() { };
129  // </group>
130 
131  // Retrieve the rectangle corners
132  virtual void get(casacore::Int &x1, casacore::Int &y1, casacore::Int &x2, casacore::Int &y2) const ;
133 
134  private:
135 
136  // do the rectangles persist after double clicks?
138 
139  // is the rectangle on screen?
141 
142  // are we actively zooming?
144 
145  // have we moved?
147 
148  // do we have a rectangle drawn yet?
150 
151  // adjustment mode
152  enum AdjustMode {
155  };
157 
158  // coordinates of the rectangle: pixel and world
159  // <group>
162  // </group>
163 
164  // set the coordinates of the rectangle
165  // <group>
166  virtual void set(const casacore::Int &x1, const casacore::Int &y1, const casacore::Int &x2, const casacore::Int &y2);
167  // </group>
168 
169  // set/get only the anchor point
170  // <group>
171  virtual void set(const casacore::Int &x1, const casacore::Int &y1);
172  virtual void get(casacore::Int &x1, casacore::Int &y1) const ;
173  // </group>
174 
175  // preserve/restore the world coordinates
176  // <group>
177  virtual void preserve();
178  virtual void restore();
179  // </group>
180 
181  // draw the rubberband box on a PixelCanvas
182  virtual void draw(const casacore::Bool drawHandles = false);
183 
184  // reset this drawer
185  virtual void reset();
186 
187  // storage of the handle coordinates
189 
190  // position that move started from
192 
193  // position of last press event
196 
197  // position of last release event
199 
200  // store the times of the last two presses here:
202 
203  };
204 
205 
206 } //# NAMESPACE CASA - END
207 
208 #endif
209 
210 
virtual void refresh(const WCRefreshEvent &ev)
virtual void preserve()
preserve/restore the world coordinates
casacore::Int itsX2
Definition: WCRectTool.h:160
casacore::Bool itsRectangleExists
do we have a rectangle drawn yet?
Definition: WCRectTool.h:149
casacore::Bool itsRectanglePersistent
do the rectangles persist after double clicks?
Definition: WCRectTool.h:137
int Int
Definition: aipstype.h:50
casacore::Int itsLastPressX
position of last press event
Definition: WCRectTool.h:194
Base class for WorldCanvas event-based tools.
Definition: WCTool.h:141
casacore::Vector< casacore::Int > itsHY
Definition: WCRectTool.h:188
Class which stores WorldCanvas refresh event information.
casacore::Int itsLastPressY
Definition: WCRectTool.h:194
virtual void set(const casacore::Int &x1, const casacore::Int &y1, const casacore::Int &x2, const casacore::Int &y2)
set the coordinates of the rectangle
virtual void reset()
reset this drawer
casacore::Vector< casacore::Double > itsStoredWorldBlc
Definition: WCRectTool.h:161
WCRectTool::AdjustMode itsAdjustMode
Definition: WCRectTool.h:156
casacore::Vector< casacore::Double > itsStoredWorldTrc
Definition: WCRectTool.h:161
casacore::Bool itsMoved
have we moved?
Definition: WCRectTool.h:146
virtual void rectangleReady()
Functions called when a rectangle is ready and not being editted, and when this status changes...
Definition: WCRectTool.h:127
casacore::Int itsY2
Definition: WCRectTool.h:160
Base class for WorldCanvas event-based rectangle tools.
Definition: WCRectTool.h:88
virtual void otherKeyPressed(const WCPositionEvent &ev)
AdjustMode
adjustment mode
Definition: WCRectTool.h:152
casacore::Bool itsActive
are we actively zooming?
Definition: WCRectTool.h:143
virtual void draw(const casacore::Bool drawHandles=false)
draw the rubberband box on a PixelCanvas
virtual void disable()
Switch the tool off - this calls the base class disable, and then erases the rectangle if it&#39;s around...
casacore::Int itsLastReleaseY
Definition: WCRectTool.h:198
virtual void doubleOutside()
Definition: WCRectTool.h:121
Class which stores WorldCanvas motion event information.
Definition: WCMotionEvent.h:79
casacore::Int itsBaseMoveX
position that move started from
Definition: WCRectTool.h:191
double Double
Definition: aipstype.h:55
casacore::Vector< casacore::Int > itsHX
storage of the handle coordinates
Definition: WCRectTool.h:188
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual ~WCRectTool()
Destructor.
casacore::Int itsX1
coordinates of the rectangle: pixel and world
Definition: WCRectTool.h:160
WCRectTool(WorldCanvas *wcanvas, Display::KeySym keysym=Display::K_Pointer_Button1, const casacore::Bool persistent=false)
Constructor.
Class providing draw style settings for visible DisplayTools.
Definition: DTVisible.h:95
casacore::Double its2ndLastPressTime
Definition: WCRectTool.h:201
casacore::Int its2ndLastPressX
Definition: WCRectTool.h:195
Class which stores WorldCanvas position event information.
casacore::Int itsLastReleaseX
position of last release event
Definition: WCRectTool.h:198
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
virtual void keyPressed(const WCPositionEvent &ev)
Functions called by the local event handling operators - these handle the drawing of the rectangle...
virtual void rectangleNotReady()
Definition: WCRectTool.h:128
virtual void doubleInside()
Functions special to the rectangle event handling - called when there is a double click inside/outsid...
Definition: WCRectTool.h:120
virtual void restore()
casacore::Int its2ndLastPressY
Definition: WCRectTool.h:195
casacore::Double itsLastPressTime
store the times of the last two presses here:
Definition: WCRectTool.h:201
std::set< Region * > region_list_type
Definition: RegionEnums.h:14
KeySym
Keysyms for PixelCanvas keyboard events.
Definition: DisplayEnums.h:412
casacore::Int itsY1
Definition: WCRectTool.h:160
casacore::Int itsBaseMoveY
Definition: WCRectTool.h:191
virtual void moved(const WCMotionEvent &ev, const viewer::region::region_list_type &)
casacore::Bool itsOnScreen
is the rectangle on screen?
Definition: WCRectTool.h:140
virtual void keyReleased(const WCPositionEvent &ev)