casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
casa::MWCEllipseTool Class Reference

Base class for MultiWorldCanvas event-based ellipse tools. More...

#include <MWCEllipseTool.h>

Inheritance diagram for casa::MWCEllipseTool:
casa::MultiWCTool casa::DTVisible casa::DisplayTool casa::WCPositionEH casa::WCMotionEH casa::WCRefreshEH casa::DisplayEH casa::MWCETRegion casa::QtOldELRegion casa::QtOldEllipseTool

Public Member Functions

 MWCEllipseTool (Display::KeySym keysym=Display::K_Pointer_Button1, const casacore::Bool persistent=false)
 Constructor. More...
 
virtual ~MWCEllipseTool ()
 Destructor. More...
 
virtual void disable ()
 Switch the tool off - this erases the ellipse, if any, and calls the base class disable. More...
 
virtual void reset (casacore::Bool skipRefresh=false)
 reset to non-existent, non-active ellipse. More...
 
virtual casacore::Bool ellipseDefined ()
 
Is a ellipse currently defined?

virtual casacore::Bool rectangleDefined() { return itsRectangleExists; } More...

 
- Public Member Functions inherited from casa::MultiWCTool
 MultiWCTool (const Display::KeySym &keysym=Display::K_Pointer_Button1, bool enable_events=true)
 Constructor taking the primary key to which this tool will respond. More...
 
virtual ~MultiWCTool ()
 Destructor. More...
 
virtual void addWorldCanvas (WorldCanvas &worldcanvas)
 Add/remove a WorldCanvas from the control of this tool. More...
 
virtual void removeWorldCanvas (WorldCanvas &worldcanvas)
 
virtual void addWorldCanvases (PanelDisplay *pdisp)
 Add/Remove a list of WorldCanvases from PanelDisplay. More...
 
virtual void removeWorldCanvases (PanelDisplay *pdisp)
 
virtual void enable ()
 Switch the tool on/off - this simply registers or unregisters the event handlers on the WorldCanvases. More...
 
virtual void operator() (const WCPositionEvent &ev)
 Required operators for event handling - these are called when events occur, and distribute the events to the "user-level" methods. More...
 
virtual void operator() (const WCMotionEvent &ev)
 default sends event to cout More...
 
virtual void operator() (const WCRefreshEvent &ev)
 original handler interface (still used for WCRefreshEvents) More...
 
- Public Member Functions inherited from casa::DisplayTool
virtual ~DisplayTool ()
 Destructor. More...
 
virtual void setKey (const Display::KeySym &keysym)
 Set/get which key to catch. More...
 
virtual Display::KeySym getKey () const
 
- Public Member Functions inherited from casa::WCPositionEH
 WCPositionEH ()
 Default Constructor Required. More...
 
virtual ~WCPositionEH ()
 Destructor. More...
 
- Public Member Functions inherited from casa::WCMotionEH
 WCMotionEH ()
 Default Constructor Required. More...
 
virtual ~WCMotionEH ()
 Destructor. More...
 
- Public Member Functions inherited from casa::WCRefreshEH
 WCRefreshEH ()
 Default Constructor Required. More...
 
virtual ~WCRefreshEH ()
 Destructor. More...
 
- Public Member Functions inherited from casa::DisplayEH
virtual void handleEvent (DisplayEvent &)
 Classes that contain this interface (i.e., derive from it) can override this method to implement actions for whatever types of DisplayEvent they're interested in. More...
 
virtual ~DisplayEH ()
 
- Public Member Functions inherited from casa::DTVisible
 DTVisible ()
 Default constructor. More...
 
virtual ~DTVisible ()
 Destructor. More...
 
virtual casacore::String drawColor () const
 Return the color to use. More...
 
virtual casacore::Int lineWidth () const
 Return the line width to use. More...
 
virtual casacore::Double doubleClickInterval () const
 Return the double click interval (in seconds). More...
 

Protected Member Functions

virtual void keyPressed (const WCPositionEvent &ev)
 Functions called by the base class event handling operators–and normally only those. More...
 
virtual void keyReleased (const WCPositionEvent &ev)
 
virtual void otherKeyPressed (const WCPositionEvent &ev)
 
virtual void moved (const WCMotionEvent &, const viewer::region::region_list_type &)
 
virtual void draw (const WCRefreshEvent &, const viewer::region::region_list_type &)
 draw the ellipse (if any) on the object's currently active WC. More...
 
virtual void doubleInside ()
 Output callback functions–to be overridden in derived class. More...
 
virtual void doubleOutside ()
 
virtual void ellipseReady ()
 Called when a ellipse is ready and not being edited. More...
 
virtual void get (casacore::Int &x1, casacore::Int &y1, casacore::Int &x2, casacore::Int &y2) const
 virtual void rectangleReady() { }; More...
 
- Protected Member Functions inherited from casa::MultiWCTool
virtual void otherKeyReleased (const WCPositionEvent &)
 
virtual void updateRegion ()
 
virtual void clicked (casacore::Int, casacore::Int)
 
virtual void doubleClicked (casacore::Int, casacore::Int)
 
virtual void refresh ()
 Copy back-to-front buffer (erasing all MWCTool drawings), then cause this (and all MWCTools on current WC's PC) to draw (or not draw) themselves, according to their current state. More...
 
virtual void setClipToDrawArea ()
 Cause subsequent drawing commands to be clipped to the current WC (or its drawing area). More...
 
virtual void setClipToWC ()
 
virtual void resetClip ()
 
- Protected Member Functions inherited from casa::DisplayTool
 DisplayTool (const Display::KeySym &keysym=Display::K_Pointer_Button1)
 
Constructor taking a key to which this tool will initially be

attached, typically one of the pointer buttons. More...

 
 DisplayTool (const DisplayTool &other)
 Copy constructor - construct a new DisplayTool from other, using copy semantics. More...
 
DisplayTooloperator= (const DisplayTool &other)
 Copy assignment using copy semantics. More...
 
Display::KeyModifier keyModifiers ()
 Return the modifier mask. More...
 
- Protected Member Functions inherited from casa::DTVisible
 DTVisible (const DTVisible &other)
 (Required) copy constructor. More...
 
DTVisibleoperator= (const DTVisible &other)
 (Required) copy assignment. More...
 

Private Member Functions

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 More...
 
virtual void get (casacore::Int &x1, casacore::Int &y1) const
 get only the anchor point More...
 

Private Attributes

casacore::Bool itsEllipsePersistent
 does the ellipse persist after double clicks (until a new one is started)? More...
 
casacore::Bool itsEllipseExists
 casacore::Bool itsRectanglePersistent; More...
 
casacore::Bool itsActive
 casacore::Bool itsRectangleExists; More...
 
casacore::Bool itsMoving
 (valid only if itsActive==true): true = being moved false = being resized More...
 
casacore::Bool itsEmitted
 (valid only if itsEllipseExists==true) Has doubleInside/Outside been called for this ellipse? If so, a key press outside the ellipse will start a new ellipse, as if itsEllipseExists were false. More...
 
casacore::Vector
< casacore::Double
itsP1
 (Linear) coordinates of the ellipse (invariant over zooms, but not coordinate system changes. More...
 
casacore::Vector
< casacore::Double
itsP2
 
casacore::Vector< casacore::IntitsHX
 storage of the handle (pixel) coordinates More...
 
casacore::Vector< casacore::IntitsHY
 
casacore::Int itsBaseMoveX
 position that move started from More...
 
casacore::Int itsBaseMoveY
 
casacore::Double itsLastPressTime
 store the times of the last two presses here: More...
 
casacore::Double its2ndLastPressTime
 

Additional Inherited Members

- Protected Attributes inherited from casa::MultiWCTool
WorldCanvasitsCurrentWC
 WC being (or to be) drawn on (may be 0 initially). More...
 

Detailed Description

Base class for MultiWorldCanvas event-based ellipse tools.

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

<prerequisites> WCTool </prerequisites>

Etymology

MWCEllipseTool stands for MultiWorldCanvas Ellipse Tool

Synopsis

This class adds to its base WCTool to provide a tool for drawing, resizing and moving ellipses on a WorldCanvas. While MWCEllipseTool 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 ellipse respectively. It is up to the programmer to decide what double clicks inside and outside the ellipse 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 ellipse is drawn by dragging the mouse from one corner to the diagonally opposite corner. Once constructed, the ellipse can be resized by dragging its corners, or relocated by dragging inside the ellipse. The ellipse is removed from the display when the Esc key is pressed.

Example

Motivation

Many activities on the WorldCanvas will be based on the user drawing a ellipse, and then proceeding to some action with that ellipse.

Definition at line 83 of file MWCEllipseTool.h.

Constructor & Destructor Documentation

casa::MWCEllipseTool::MWCEllipseTool ( Display::KeySym  keysym = Display::K_Pointer_Button1,
const casacore::Bool  persistent = false 
)

Constructor.

virtual casa::MWCEllipseTool::~MWCEllipseTool ( )
virtual

Destructor.

Member Function Documentation

virtual void casa::MWCEllipseTool::disable ( )
virtual

Switch the tool off - this erases the ellipse, if any, and calls the base class disable.

Reimplemented from casa::MultiWCTool.

virtual void casa::MWCEllipseTool::doubleInside ( )
inlineprotectedvirtual

Output callback functions–to be overridden in derived class.

Called when there is a double click inside/outside the ellipse

Reimplemented in casa::MWCETRegion.

Definition at line 133 of file MWCEllipseTool.h.

virtual void casa::MWCEllipseTool::doubleOutside ( )
inlineprotectedvirtual

Definition at line 134 of file MWCEllipseTool.h.

virtual void casa::MWCEllipseTool::draw ( const WCRefreshEvent ,
const viewer::region::region_list_type  
)
protectedvirtual

draw the ellipse (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 casacore::Bool casa::MWCEllipseTool::ellipseDefined ( )
inlinevirtual

Is a ellipse currently defined?

virtual casacore::Bool rectangleDefined() { return itsRectangleExists; }

Definition at line 106 of file MWCEllipseTool.h.

References itsEllipseExists.

virtual void casa::MWCEllipseTool::ellipseReady ( )
inlineprotectedvirtual

Called when a ellipse is ready and not being edited.

(Unused so far on the glish level (12/01)).

Definition at line 139 of file MWCEllipseTool.h.

virtual void casa::MWCEllipseTool::get ( casacore::Int x1,
casacore::Int y1,
casacore::Int x2,
casacore::Int y2 
) const
protectedvirtual

virtual void rectangleReady() { };

Retrieve the ellipse 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::MWCEllipseTool::get ( casacore::Int x1,
casacore::Int y1 
) const
privatevirtual

get only the anchor point

virtual void casa::MWCEllipseTool::keyPressed ( const WCPositionEvent ev)
protectedvirtual

Functions called by the base class event handling operators–and normally only those.

This is the input that controls the ellipse's appearance and action. When the ellipse is ready and double-click is received, the doubleInside/Outside routine will be invoked.

Reimplemented from casa::MultiWCTool.

virtual void casa::MWCEllipseTool::keyReleased ( const WCPositionEvent ev)
protectedvirtual

Reimplemented from casa::MultiWCTool.

virtual void casa::MWCEllipseTool::moved ( const WCMotionEvent ,
const viewer::region::region_list_type  
)
protectedvirtual

Reimplemented from casa::MultiWCTool.

virtual void casa::MWCEllipseTool::otherKeyPressed ( const WCPositionEvent ev)
protectedvirtual

Reimplemented from casa::MultiWCTool.

virtual void casa::MWCEllipseTool::reset ( casacore::Bool  skipRefresh = false)
virtual

reset to non-existent, non-active ellipse.

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::MWCEllipseTool::set ( const casacore::Int x1,
const casacore::Int y1,
const casacore::Int x2,
const casacore::Int y2 
)
privatevirtual

set the pixel coordinates of the ellipse

Member Data Documentation

casacore::Double casa::MWCEllipseTool::its2ndLastPressTime
private

Definition at line 197 of file MWCEllipseTool.h.

casacore::Bool casa::MWCEllipseTool::itsActive
private

casacore::Bool itsRectangleExists;

was the button pressed in the ellipse (or, if none, in an active WC) and not yet released/reset?

Definition at line 170 of file MWCEllipseTool.h.

casacore::Int casa::MWCEllipseTool::itsBaseMoveX
private

position that move started from

Definition at line 194 of file MWCEllipseTool.h.

casacore::Int casa::MWCEllipseTool::itsBaseMoveY
private

Definition at line 194 of file MWCEllipseTool.h.

casacore::Bool casa::MWCEllipseTool::itsEllipseExists
private

casacore::Bool itsRectanglePersistent;

do we have a ellipse yet? (if true, itsCurrentWC, itsEmitted, P1, and P2 are valid)

Definition at line 165 of file MWCEllipseTool.h.

Referenced by ellipseDefined().

casacore::Bool casa::MWCEllipseTool::itsEllipsePersistent
private

does the ellipse persist after double clicks (until a new one is started)?

Definition at line 160 of file MWCEllipseTool.h.

casacore::Bool casa::MWCEllipseTool::itsEmitted
private

(valid only if itsEllipseExists==true) Has doubleInside/Outside been called for this ellipse? If so, a key press outside the ellipse will start a new ellipse, as if itsEllipseExists were false.

However, a key press inside the ellipse will reset itsEmitted to false, allowing the ellipse to be reused (possibly moved or resized, and emitted again).

Definition at line 183 of file MWCEllipseTool.h.

casacore::Vector<casacore::Int> casa::MWCEllipseTool::itsHX
private

storage of the handle (pixel) coordinates

Definition at line 191 of file MWCEllipseTool.h.

casacore::Vector<casacore::Int> casa::MWCEllipseTool::itsHY
private

Definition at line 191 of file MWCEllipseTool.h.

casacore::Double casa::MWCEllipseTool::itsLastPressTime
private

store the times of the last two presses here:

Definition at line 197 of file MWCEllipseTool.h.

casacore::Bool casa::MWCEllipseTool::itsMoving
private

(valid only if itsActive==true): true = being moved false = being resized

Definition at line 174 of file MWCEllipseTool.h.

casacore::Vector<casacore::Double> casa::MWCEllipseTool::itsP1
private

(Linear) coordinates of the ellipse (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 188 of file MWCEllipseTool.h.

casacore::Vector<casacore::Double> casa::MWCEllipseTool::itsP2
private

Definition at line 188 of file MWCEllipseTool.h.


The documentation for this class was generated from the following file: