casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MWCEllipseTool.h
Go to the documentation of this file.
1 //# MWCEllipseTool.h: Base class for MultiWorldCanvas event-based ellipse 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_MWCELLIPSETOOL_H
29 #define TRIALDISPLAY_MWCELLIPSETOOL_H
30 
31 #include <casa/aips.h>
34 
35 namespace casa { //# NAMESPACE CASA - BEGIN
36 
37 // <summary>
38 // Base class for MultiWorldCanvas event-based ellipse 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 // MWCEllipseTool stands for MultiWorldCanvas Ellipse Tool
52 // </etymology>
53 //
54 // <synopsis>
55 // This class adds to its base WCTool to provide a tool for drawing,
56 // resizing and moving ellipses on a WorldCanvas. While MWCEllipseTool
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 // ellipse respectively. It is up to the programmer to decide what
62 // double clicks inside and outside the ellipse 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 ellipse is drawn by dragging the mouse from one corner to
69 // the diagonally opposite corner. Once constructed, the ellipse
70 // can be resized by dragging its corners, or relocated by dragging
71 // inside the ellipse. The ellipse 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 ellipse, and then proceeding to some action with that ellipse.
81 // </motivation>
82 
83  class MWCEllipseTool : public MultiWCTool, public DTVisible {
84 
85  public:
86 
87  // Constructor
89  const casacore::Bool persistent = false);
90 
91  // Destructor
92  virtual ~MWCEllipseTool();
93 
94  // Switch the tool off - this erases the ellipse, if any,
95  // and calls the base class disable.
96  virtual void disable();
97 
98  // reset to non-existent, non-active ellipse.
99  // Refreshes if necessary to erase (unless skipRefresh==true In
100  // that case, the caller should do the refresh itself).
101  // (Does not unregister from WCs or disable future event handling).
102  virtual void reset(casacore::Bool skipRefresh=false);
103 
104  // Is a ellipse currently defined?
105  //virtual casacore::Bool rectangleDefined() { return itsRectangleExists; }
107  return itsEllipseExists;
108  }
109 
110 
111  protected:
112 
113  // Functions called by the base class event handling operators--and
114  // normally only those. This is the input that controls the ellipse's
115  // appearance and action. When the ellipse is ready and double-click
116  // is received, the doubleInside/Outside routine will be invoked.
117  // <group>
118  virtual void keyPressed(const WCPositionEvent &ev);
119  virtual void keyReleased(const WCPositionEvent &ev);
120  virtual void otherKeyPressed(const WCPositionEvent &ev);
121  virtual void moved(const WCMotionEvent &/*ev*/, const viewer::region::region_list_type & /*selected_regions*/);
122  // </group>
123 
124  // draw the ellipse (if any) on the object's currently active WC.
125  // Only to be called by the base class refresh event handler. Derived
126  // objects should use refresh() if they need to redraw, but even that
127  // is normally handled automatically.
128  virtual void draw(const WCRefreshEvent&/*ev*/, const viewer::region::region_list_type & /*selected_regions*/);
129 
130  // Output callback functions--to be overridden in derived class.
131  // Called when there is a double click inside/outside the ellipse
132  // <group>
133  virtual void doubleInside() { };
134  virtual void doubleOutside() { };
135  // </group>
136 
137  // Called when a ellipse is ready and not being
138  // edited. (Unused so far on the glish level (12/01)).
139  virtual void ellipseReady() { };
140  //virtual void rectangleReady() { };
141 
142 
143  // Retrieve the ellipse coordinates, in screen pixels.
144  // Anchor (if applicable) is (x1,y1). Valid during the output callbacks;
145  // to be used by them, as well as internally.
146  virtual void get(casacore::Int &x1, casacore::Int &y1, casacore::Int &x2, casacore::Int &y2) const ;
147 
148  private:
149 
150  // set the pixel coordinates of the ellipse
151  virtual void set(const casacore::Int &x1, const casacore::Int &y1,
152  const casacore::Int &x2, const casacore::Int &y2);
153 
154  // get only the anchor point
155  virtual void get(casacore::Int &x1, casacore::Int &y1) const;
156 
157 
158  // does the ellipse persist after double clicks (until a new one
159  // is started)?
161  //casacore::Bool itsRectanglePersistent;
162 
163  // do we have a ellipse yet?
164  // (if true, itsCurrentWC, itsEmitted, P1, and P2 are valid)
166  //casacore::Bool itsRectangleExists;
167 
168  // was the button pressed in the ellipse (or, if none, in an active WC)
169  // and not yet released/reset?
171 
172  // (valid only if itsActive==true):
173  // true = being moved false = being resized
175 
176  // (valid only if itsEllipseExists==true)
177  // Has doubleInside/Outside been called for this ellipse? If so, a
178  // key press outside the ellipse will start a new ellipse, as if
179  // itsEllipseExists were false.
180  // However, a key press inside the ellipse will reset
181  // itsEmitted to false, allowing the ellipse to be reused
182  // (possibly moved or resized, and emitted again).
184 
185  // (Linear) coordinates of the ellipse (invariant over zooms, but not
186  // coordinate system changes. To do: support the WorldCoordinateChange
187  // refresh reason, and reset this tool when it occurs).
189 
190  // storage of the handle (pixel) coordinates
192 
193  // position that move started from
195 
196  // store the times of the last two presses here:
198 
199  };
200 
201 
202 } //# NAMESPACE CASA - END
203 
204 #endif
205 
206 
int Int
Definition: aipstype.h:50
casacore::Bool itsEllipseExists
casacore::Bool itsRectanglePersistent;
Class which stores WorldCanvas refresh event information.
casacore::Bool itsEllipsePersistent
does the ellipse persist after double clicks (until a new one is started)?
casacore::Vector< casacore::Int > itsHX
storage of the handle (pixel) coordinates
virtual void set(const casacore::Int &x1, const casacore::Int &y1, const casacore::Int &x2, const casacore::Int &y2)
set the pixel coordinates of the ellipse
virtual void doubleOutside()
virtual ~MWCEllipseTool()
Destructor.
virtual void keyPressed(const WCPositionEvent &ev)
Functions called by the base class event handling operators–and normally only those.
MWCEllipseTool(Display::KeySym keysym=Display::K_Pointer_Button1, const casacore::Bool persistent=false)
Constructor.
casacore::Vector< casacore::Double > itsP1
(Linear) coordinates of the ellipse (invariant over zooms, but not coordinate system changes...
virtual void disable()
Switch the tool off - this erases the ellipse, if any, and calls the base class disable.
virtual void draw(const WCRefreshEvent &, const viewer::region::region_list_type &)
draw the ellipse (if any) on the object&#39;s currently active WC.
virtual casacore::Bool ellipseDefined()
Is a ellipse currently defined? virtual casacore::Bool rectangleDefined() { return itsRectangleExist...
Class which stores WorldCanvas motion event information.
Definition: WCMotionEvent.h:79
double Double
Definition: aipstype.h:55
casacore::Int itsBaseMoveY
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Double itsLastPressTime
store the times of the last two presses here:
casacore::Vector< casacore::Int > itsHY
Class providing draw style settings for visible DisplayTools.
Definition: DTVisible.h:95
virtual void ellipseReady()
Called when a ellipse is ready and not being edited.
Class which stores WorldCanvas position event information.
virtual void doubleInside()
Output callback functions–to be overridden in derived class.
casacore::Int itsBaseMoveX
position that move started from
Base class for MultiWorldCanvas event-based tools.
Definition: MultiWCTool.h:89
casacore::Bool itsMoving
(valid only if itsActive==true): true = being moved false = being resized
casacore::Bool itsActive
casacore::Bool itsRectangleExists;
casacore::Double its2ndLastPressTime
virtual void moved(const WCMotionEvent &, const viewer::region::region_list_type &)
std::set< Region * > region_list_type
Definition: RegionEnums.h:14
virtual void reset(casacore::Bool skipRefresh=false)
reset to non-existent, non-active ellipse.
KeySym
Keysyms for PixelCanvas keyboard events.
Definition: DisplayEnums.h:412
virtual void otherKeyPressed(const WCPositionEvent &ev)
Base class for MultiWorldCanvas event-based ellipse tools.
casacore::Vector< casacore::Double > itsP2
casacore::Bool itsEmitted
(valid only if itsEllipseExists==true) Has doubleInside/Outside been called for this ellipse...
virtual void keyReleased(const WCPositionEvent &ev)