casa
$Rev:20696$
|
Base class for MultiWorldCanvas event-based rectangle tools. More...
#include <MWCRectTool.h>
Public Member Functions | |
MWCRectTool (Display::KeySym keysym=Display::K_Pointer_Button1, const Bool persistent=False) | |
Constructor. | |
virtual | ~MWCRectTool () |
Destructor. | |
virtual void | disable () |
Switch the tool off - this erases the rectangle, if any, and calls the base class disable. | |
virtual void | reset (Bool skipRefresh=False) |
reset to non-existent, non-active rectangle. | |
virtual Bool | rectangleDefined () |
Is a rectangle currently defined? | |
Protected Member Functions | |
virtual void | keyPressed (const WCPositionEvent &) |
Functions called by the base class event handling operators--and normally only those. | |
virtual void | keyReleased (const WCPositionEvent &) |
virtual void | otherKeyPressed (const WCPositionEvent &) |
virtual void | moved (const WCMotionEvent &, const viewer::region::region_list_type &) |
virtual void | draw (const WCRefreshEvent &, const viewer::region::region_list_type &) |
draw the rectangle (if any) on the object's currently active WC. | |
virtual void | doubleInside () |
Output callback functions--to be overridden in derived class. | |
virtual void | doubleOutside () |
virtual void | rectangleReady () |
Called when a rectangle is ready and not being edited. | |
virtual void | get (Int &x1, Int &y1, Int &x2, Int &y2) const |
Retrieve the rectangle coordinates, in screen pixels. | |
Private Member Functions | |
virtual void | set (const Int &x1, const Int &y1, const Int &x2, const Int &y2) |
set the pixel coordinates of the rectangle | |
virtual void | get (Int &x1, Int &y1) const |
get only the anchor point | |
Private Attributes | |
Bool | itsRectanglePersistent |
does the rectangle persist after double clicks (until a new one is started)? | |
Bool | itsRectangleExists |
do we have a rectangle yet? (if True, itsCurrentWC, itsEmitted, P1, and P2 are valid) | |
Bool | itsActive |
was the button pressed in the rectangle (or, if none, in an active WC) and not yet released/reset? | |
Bool | itsMoving |
(valid only if itsActive==True): True = being moved False = being resized | |
Bool | itsEmitted |
(valid only if itsRectangleExists==True) Has doubleInside/Outside been called for this rectangle? If so, a key press outside the rectangle will start a new rectangle, as if itsRectangleExists were False. | |
Vector< Double > | itsP1 |
(Linear) coordinates of the rectangle (invariant over zooms, but not coordinate system changes. | |
Vector< Double > | itsP2 |
Vector< Int > | itsHX |
storage of the handle (pixel) coordinates | |
Vector< Int > | itsHY |
Int | itsBaseMoveX |
position that move started from | |
Int | itsBaseMoveY |
Double | itsLastPressTime |
store the times of the last two presses here: | |
Double | its2ndLastPressTime |
Base class for MultiWorldCanvas event-based rectangle tools.
Public interface
<prerequisites> WCTool </prerequisites>
MWCRectTool stands for MultiWorldCanvas Rectangle Tool
This class adds to its base WCTool to provide a tool for drawing, resizing and moving rectangles on a WorldCanvas. While MWCRectTool is not abstract, it performs no useful function. The programmer should derive from this class, and implement the functions doubleInside and doubleOutside, which are called when the user double-clicks the key or mouse button inside or outside an existing rectangle respectively. It is up to the programmer to decide what double clicks inside and outside the rectangle correspond to, although it is recommended that a double click inside correspond to the main action of the tool, and a double click outside correspond to a secondary action of the tool, if indeed a secondary action exists.
The rectangle is drawn by dragging the mouse from one corner to the diagonally opposite corner. Once constructed, the rectangle can be resized by dragging its corners, or relocated by dragging inside the rectangle. The rectangle is removed from the display when the Esc key is pressed.
Many activities on the WorldCanvas will be based on the user drawing a rectangle, and then proceeding to some action with that rectangle. A nice example is zooming.
Definition at line 84 of file MWCRectTool.h.
casa::MWCRectTool::MWCRectTool | ( | Display::KeySym | keysym = Display::K_Pointer_Button1 , |
const Bool | persistent = False |
||
) |
Constructor.
virtual casa::MWCRectTool::~MWCRectTool | ( | ) | [virtual] |
Destructor.
virtual void casa::MWCRectTool::disable | ( | ) | [virtual] |
Switch the tool off - this erases the rectangle, if any, and calls the base class disable.
Reimplemented from casa::MultiWCTool.
virtual void casa::MWCRectTool::doubleInside | ( | ) | [inline, protected, virtual] |
Output callback functions--to be overridden in derived class.
Called when there is a double click inside/outside the rectangle
Reimplemented in casa::MWCRTZoomer, and casa::MWCRTRegion.
Definition at line 131 of file MWCRectTool.h.
virtual void casa::MWCRectTool::doubleOutside | ( | ) | [inline, protected, virtual] |
Reimplemented in casa::MWCRTZoomer.
Definition at line 132 of file MWCRectTool.h.
virtual void casa::MWCRectTool::draw | ( | const WCRefreshEvent & | , |
const viewer::region::region_list_type & | |||
) | [protected, virtual] |
draw the rectangle (if any) on the object's currently active WC.
Only to be called by the base class refresh event handler. Derived objects should use refresh() if they need to redraw, but even that is normally handled automatically.
Reimplemented from casa::MultiWCTool.
virtual void casa::MWCRectTool::get | ( | Int & | x1, |
Int & | y1, | ||
Int & | x2, | ||
Int & | y2 | ||
) | const [protected, virtual] |
Retrieve the rectangle coordinates, in screen pixels.
Anchor (if applicable) is (x1,y1). Valid during the output callbacks; to be used by them, as well as internally.
virtual void casa::MWCRectTool::get | ( | Int & | x1, |
Int & | y1 | ||
) | const [private, virtual] |
get only the anchor point
virtual void casa::MWCRectTool::keyPressed | ( | const WCPositionEvent & | ) | [protected, virtual] |
Functions called by the base class event handling operators--and normally only those.
This is the input that controls the rectangle's appearance and action. When the rectangle is ready and double-click is received, the doubleInside/Outside routine will be invoked.
Reimplemented from casa::MultiWCTool.
virtual void casa::MWCRectTool::keyReleased | ( | const WCPositionEvent & | ) | [protected, virtual] |
Reimplemented from casa::MultiWCTool.
virtual void casa::MWCRectTool::moved | ( | const WCMotionEvent & | , |
const viewer::region::region_list_type & | |||
) | [protected, virtual] |
Reimplemented from casa::MultiWCTool.
virtual void casa::MWCRectTool::otherKeyPressed | ( | const WCPositionEvent & | ) | [protected, virtual] |
Reimplemented from casa::MultiWCTool.
virtual Bool casa::MWCRectTool::rectangleDefined | ( | ) | [inline, virtual] |
Is a rectangle currently defined?
Definition at line 106 of file MWCRectTool.h.
References itsRectangleExists.
virtual void casa::MWCRectTool::rectangleReady | ( | ) | [inline, protected, virtual] |
Called when a rectangle is ready and not being edited.
(Unused so far on the glish level (12/01)).
Definition at line 137 of file MWCRectTool.h.
virtual void casa::MWCRectTool::reset | ( | Bool | skipRefresh = False | ) | [virtual] |
reset to non-existent, non-active rectangle.
Refreshes if necessary to erase (unless skipRefresh==True In that case, the caller should do the refresh itself). (Does not unregister from WCs or disable future event handling).
Reimplemented from casa::MultiWCTool.
virtual void casa::MWCRectTool::set | ( | const Int & | x1, |
const Int & | y1, | ||
const Int & | x2, | ||
const Int & | y2 | ||
) | [private, virtual] |
set the pixel coordinates of the rectangle
Double casa::MWCRectTool::its2ndLastPressTime [private] |
Definition at line 192 of file MWCRectTool.h.
Bool casa::MWCRectTool::itsActive [private] |
was the button pressed in the rectangle (or, if none, in an active WC) and not yet released/reset?
Definition at line 165 of file MWCRectTool.h.
Int casa::MWCRectTool::itsBaseMoveX [private] |
position that move started from
Definition at line 189 of file MWCRectTool.h.
Int casa::MWCRectTool::itsBaseMoveY [private] |
Definition at line 189 of file MWCRectTool.h.
Bool casa::MWCRectTool::itsEmitted [private] |
(valid only if itsRectangleExists==True) Has doubleInside/Outside been called for this rectangle? If so, a key press outside the rectangle will start a new rectangle, as if itsRectangleExists were False.
However, a key press inside the rectangle will reset itsEmitted to False, allowing the rectangle to be reused (possibly moved or resized, and emitted again).
Definition at line 178 of file MWCRectTool.h.
Vector<Int> casa::MWCRectTool::itsHX [private] |
storage of the handle (pixel) coordinates
Definition at line 186 of file MWCRectTool.h.
Vector<Int> casa::MWCRectTool::itsHY [private] |
Definition at line 186 of file MWCRectTool.h.
Double casa::MWCRectTool::itsLastPressTime [private] |
store the times of the last two presses here:
Definition at line 192 of file MWCRectTool.h.
Bool casa::MWCRectTool::itsMoving [private] |
(valid only if itsActive==True): True = being moved False = being resized
Definition at line 169 of file MWCRectTool.h.
Vector<Double> casa::MWCRectTool::itsP1 [private] |
(Linear) coordinates of the rectangle (invariant over zooms, but not coordinate system changes.
To do: support the WorldCoordinateChange refresh reason, and reset this tool when it occurs).
Definition at line 183 of file MWCRectTool.h.
Vector<Double> casa::MWCRectTool::itsP2 [private] |
Definition at line 183 of file MWCRectTool.h.
Bool casa::MWCRectTool::itsRectangleExists [private] |
do we have a rectangle yet? (if True, itsCurrentWC, itsEmitted, P1, and P2 are valid)
Definition at line 161 of file MWCRectTool.h.
Referenced by rectangleDefined().
does the rectangle persist after double clicks (until a new one is started)?
Definition at line 157 of file MWCRectTool.h.